compile.c revision 1.9 1 1.1 christos /* General Compile and inject code
2 1.1 christos
3 1.9 christos Copyright (C) 2014-2024 Free Software Foundation, Inc.
4 1.1 christos
5 1.1 christos This file is part of GDB.
6 1.1 christos
7 1.1 christos This program is free software; you can redistribute it and/or modify
8 1.1 christos it under the terms of the GNU General Public License as published by
9 1.1 christos the Free Software Foundation; either version 3 of the License, or
10 1.1 christos (at your option) any later version.
11 1.1 christos
12 1.1 christos This program is distributed in the hope that it will be useful,
13 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
14 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 1.1 christos GNU General Public License for more details.
16 1.1 christos
17 1.1 christos You should have received a copy of the GNU General Public License
18 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 1.1 christos
20 1.9 christos #include "ui.h"
21 1.1 christos #include "ui-out.h"
22 1.1 christos #include "command.h"
23 1.1 christos #include "cli/cli-script.h"
24 1.1 christos #include "cli/cli-utils.h"
25 1.7 christos #include "cli/cli-option.h"
26 1.1 christos #include "completer.h"
27 1.9 christos #include "cli/cli-cmds.h"
28 1.1 christos #include "compile.h"
29 1.1 christos #include "compile-internal.h"
30 1.1 christos #include "compile-object-load.h"
31 1.1 christos #include "compile-object-run.h"
32 1.1 christos #include "language.h"
33 1.1 christos #include "frame.h"
34 1.1 christos #include "source.h"
35 1.1 christos #include "block.h"
36 1.1 christos #include "arch-utils.h"
37 1.7 christos #include "gdbsupport/filestuff.h"
38 1.1 christos #include "target.h"
39 1.1 christos #include "osabi.h"
40 1.7 christos #include "gdbsupport/gdb_wait.h"
41 1.3 christos #include "valprint.h"
42 1.9 christos #include <optional>
43 1.7 christos #include "gdbsupport/gdb_unlinker.h"
44 1.7 christos #include "gdbsupport/pathstuff.h"
45 1.8 christos #include "gdbsupport/scoped_ignore_signal.h"
46 1.8 christos #include "gdbsupport/buildargv.h"
47 1.1 christos
48 1.1 christos
49 1.1 christos
51 1.1 christos /* Initial filename for temporary files. */
52 1.1 christos
53 1.1 christos #define TMP_PREFIX "/tmp/gdbobj-"
54 1.1 christos
55 1.1 christos /* Hold "compile" commands. */
56 1.1 christos
57 1.1 christos static struct cmd_list_element *compile_command_list;
58 1.1 christos
59 1.1 christos /* Debug flag for "compile" commands. */
60 1.7 christos
61 1.1 christos bool compile_debug;
62 1.6 christos
63 1.6 christos /* Object of this type are stored in the compiler's symbol_err_map. */
64 1.6 christos
65 1.6 christos struct symbol_error
66 1.6 christos {
67 1.6 christos /* The symbol. */
68 1.6 christos
69 1.6 christos const struct symbol *sym;
70 1.6 christos
71 1.6 christos /* The error message to emit. This is malloc'd and owned by the
72 1.6 christos hash table. */
73 1.6 christos
74 1.6 christos char *message;
75 1.6 christos };
76 1.9 christos
77 1.9 christos /* An object that maps a gdb type to a gcc type. */
78 1.9 christos
79 1.9 christos struct type_map_instance
80 1.9 christos {
81 1.9 christos /* The gdb type. */
82 1.9 christos
83 1.9 christos struct type *type;
84 1.9 christos
85 1.9 christos /* The corresponding gcc type handle. */
86 1.9 christos
87 1.9 christos gcc_type gcc_type_handle;
88 1.9 christos };
89 1.6 christos
90 1.6 christos /* Hash a type_map_instance. */
91 1.6 christos
92 1.6 christos static hashval_t
93 1.6 christos hash_type_map_instance (const void *p)
94 1.6 christos {
95 1.6 christos const struct type_map_instance *inst = (const struct type_map_instance *) p;
96 1.6 christos
97 1.6 christos return htab_hash_pointer (inst->type);
98 1.6 christos }
99 1.6 christos
100 1.6 christos /* Check two type_map_instance objects for equality. */
101 1.6 christos
102 1.6 christos static int
103 1.6 christos eq_type_map_instance (const void *a, const void *b)
104 1.6 christos {
105 1.6 christos const struct type_map_instance *insta = (const struct type_map_instance *) a;
106 1.6 christos const struct type_map_instance *instb = (const struct type_map_instance *) b;
107 1.6 christos
108 1.6 christos return insta->type == instb->type;
109 1.6 christos }
110 1.6 christos
111 1.6 christos /* Hash function for struct symbol_error. */
112 1.6 christos
113 1.6 christos static hashval_t
114 1.6 christos hash_symbol_error (const void *a)
115 1.6 christos {
116 1.6 christos const struct symbol_error *se = (const struct symbol_error *) a;
117 1.6 christos
118 1.6 christos return htab_hash_pointer (se->sym);
119 1.6 christos }
120 1.6 christos
121 1.6 christos /* Equality function for struct symbol_error. */
122 1.6 christos
123 1.6 christos static int
124 1.6 christos eq_symbol_error (const void *a, const void *b)
125 1.6 christos {
126 1.6 christos const struct symbol_error *sea = (const struct symbol_error *) a;
127 1.6 christos const struct symbol_error *seb = (const struct symbol_error *) b;
128 1.6 christos
129 1.6 christos return sea->sym == seb->sym;
130 1.6 christos }
131 1.6 christos
132 1.6 christos /* Deletion function for struct symbol_error. */
133 1.6 christos
134 1.6 christos static void
135 1.6 christos del_symbol_error (void *a)
136 1.6 christos {
137 1.6 christos struct symbol_error *se = (struct symbol_error *) a;
138 1.6 christos
139 1.6 christos xfree (se->message);
140 1.6 christos xfree (se);
141 1.6 christos }
142 1.6 christos
143 1.6 christos /* Constructor for compile_instance. */
144 1.6 christos
145 1.6 christos compile_instance::compile_instance (struct gcc_base_context *gcc_fe,
146 1.6 christos const char *options)
147 1.6 christos : m_gcc_fe (gcc_fe), m_gcc_target_options (options),
148 1.6 christos m_type_map (htab_create_alloc (10, hash_type_map_instance,
149 1.6 christos eq_type_map_instance,
150 1.6 christos xfree, xcalloc, xfree)),
151 1.6 christos m_symbol_err_map (htab_create_alloc (10, hash_symbol_error,
152 1.6 christos eq_symbol_error, del_symbol_error,
153 1.6 christos xcalloc, xfree))
154 1.6 christos {
155 1.6 christos }
156 1.6 christos
157 1.6 christos /* See compile-internal.h. */
158 1.6 christos
159 1.6 christos bool
160 1.6 christos compile_instance::get_cached_type (struct type *type, gcc_type *ret) const
161 1.6 christos {
162 1.6 christos struct type_map_instance inst, *found;
163 1.6 christos
164 1.6 christos inst.type = type;
165 1.6 christos found = (struct type_map_instance *) htab_find (m_type_map.get (), &inst);
166 1.6 christos if (found != NULL)
167 1.6 christos {
168 1.6 christos *ret = found->gcc_type_handle;
169 1.6 christos return true;
170 1.6 christos }
171 1.6 christos
172 1.6 christos return false;
173 1.6 christos }
174 1.6 christos
175 1.6 christos /* See compile-internal.h. */
176 1.6 christos
177 1.6 christos void
178 1.6 christos compile_instance::insert_type (struct type *type, gcc_type gcc_type)
179 1.6 christos {
180 1.6 christos struct type_map_instance inst, *add;
181 1.6 christos void **slot;
182 1.6 christos
183 1.6 christos inst.type = type;
184 1.6 christos inst.gcc_type_handle = gcc_type;
185 1.6 christos slot = htab_find_slot (m_type_map.get (), &inst, INSERT);
186 1.6 christos
187 1.6 christos add = (struct type_map_instance *) *slot;
188 1.6 christos /* The type might have already been inserted in order to handle
189 1.6 christos recursive types. */
190 1.6 christos if (add != NULL && add->gcc_type_handle != gcc_type)
191 1.6 christos error (_("Unexpected type id from GCC, check you use recent enough GCC."));
192 1.6 christos
193 1.6 christos if (add == NULL)
194 1.6 christos {
195 1.6 christos add = XNEW (struct type_map_instance);
196 1.6 christos *add = inst;
197 1.6 christos *slot = add;
198 1.6 christos }
199 1.6 christos }
200 1.6 christos
201 1.6 christos /* See compile-internal.h. */
202 1.6 christos
203 1.6 christos void
204 1.6 christos compile_instance::insert_symbol_error (const struct symbol *sym,
205 1.6 christos const char *text)
206 1.6 christos {
207 1.6 christos struct symbol_error e;
208 1.6 christos void **slot;
209 1.6 christos
210 1.6 christos e.sym = sym;
211 1.6 christos slot = htab_find_slot (m_symbol_err_map.get (), &e, INSERT);
212 1.6 christos if (*slot == NULL)
213 1.6 christos {
214 1.6 christos struct symbol_error *ep = XNEW (struct symbol_error);
215 1.6 christos
216 1.6 christos ep->sym = sym;
217 1.6 christos ep->message = xstrdup (text);
218 1.6 christos *slot = ep;
219 1.6 christos }
220 1.6 christos }
221 1.6 christos
222 1.6 christos /* See compile-internal.h. */
223 1.6 christos
224 1.6 christos void
225 1.6 christos compile_instance::error_symbol_once (const struct symbol *sym)
226 1.6 christos {
227 1.6 christos struct symbol_error search;
228 1.6 christos struct symbol_error *err;
229 1.6 christos
230 1.6 christos if (m_symbol_err_map == NULL)
231 1.6 christos return;
232 1.6 christos
233 1.6 christos search.sym = sym;
234 1.6 christos err = (struct symbol_error *) htab_find (m_symbol_err_map.get (), &search);
235 1.6 christos if (err == NULL || err->message == NULL)
236 1.6 christos return;
237 1.6 christos
238 1.6 christos gdb::unique_xmalloc_ptr<char> message (err->message);
239 1.6 christos err->message = NULL;
240 1.6 christos error (_("%s"), message.get ());
241 1.6 christos }
242 1.1 christos
243 1.1 christos /* Implement "show debug compile". */
244 1.1 christos
245 1.1 christos static void
246 1.1 christos show_compile_debug (struct ui_file *file, int from_tty,
247 1.1 christos struct cmd_list_element *c, const char *value)
248 1.8 christos {
249 1.1 christos gdb_printf (file, _("Compile debugging is %s.\n"), value);
250 1.1 christos }
251 1.1 christos
252 1.1 christos
253 1.7 christos
255 1.7 christos /* Options for the compile command. */
256 1.1 christos
257 1.7 christos struct compile_options
258 1.7 christos {
259 1.7 christos /* For -raw. */
260 1.7 christos bool raw = false;
261 1.7 christos };
262 1.7 christos
263 1.7 christos using compile_flag_option_def
264 1.7 christos = gdb::option::flag_option_def<compile_options>;
265 1.7 christos
266 1.7 christos static const gdb::option::option_def compile_command_option_defs[] = {
267 1.7 christos
268 1.7 christos compile_flag_option_def {
269 1.7 christos "raw",
270 1.7 christos [] (compile_options *opts) { return &opts->raw; },
271 1.7 christos N_("Suppress automatic 'void _gdb_expr () { CODE }' wrapping."),
272 1.7 christos },
273 1.7 christos
274 1.7 christos };
275 1.7 christos
276 1.1 christos /* Create an option_def_group for the "compile" command's options,
277 1.7 christos with OPTS as context. */
278 1.7 christos
279 1.7 christos static gdb::option::option_def_group
280 1.7 christos make_compile_options_def_group (compile_options *opts)
281 1.1 christos {
282 1.1 christos return {{compile_command_option_defs}, opts};
283 1.1 christos }
284 1.1 christos
285 1.1 christos /* Handle the input from the 'compile file' command. The "compile
286 1.1 christos file" command is used to evaluate an expression contained in a file
287 1.1 christos that may contain calls to the GCC compiler. */
288 1.7 christos
289 1.1 christos static void
290 1.7 christos compile_file_command (const char *args, int from_tty)
291 1.7 christos {
292 1.7 christos scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0);
293 1.1 christos
294 1.7 christos /* Check if a -raw option is provided. */
295 1.1 christos
296 1.7 christos compile_options options;
297 1.7 christos
298 1.7 christos const gdb::option::option_def_group group
299 1.7 christos = make_compile_options_def_group (&options);
300 1.7 christos gdb::option::process_options
301 1.1 christos (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR,
302 1.7 christos group);
303 1.7 christos
304 1.1 christos enum compile_i_scope_types scope
305 1.7 christos = options.raw ? COMPILE_I_RAW_SCOPE : COMPILE_I_SIMPLE_SCOPE;
306 1.1 christos
307 1.7 christos args = skip_spaces (args);
308 1.7 christos
309 1.7 christos /* After processing options, check whether we have a filename. */
310 1.1 christos if (args == nullptr || args[0] == '\0')
311 1.7 christos error (_("You must provide a filename for this command."));
312 1.8 christos
313 1.8 christos args = skip_spaces (args);
314 1.6 christos std::string abspath = gdb_abspath (args);
315 1.1 christos std::string buffer = string_printf ("#include \"%s\"\n", abspath.c_str ());
316 1.1 christos eval_compile_command (NULL, buffer.c_str (), scope, NULL);
317 1.7 christos }
318 1.7 christos
319 1.7 christos /* Completer for the "compile file" command. */
320 1.7 christos
321 1.7 christos static void
322 1.7 christos compile_file_command_completer (struct cmd_list_element *ignore,
323 1.7 christos completion_tracker &tracker,
324 1.7 christos const char *text, const char *word)
325 1.7 christos {
326 1.7 christos const gdb::option::option_def_group group
327 1.7 christos = make_compile_options_def_group (nullptr);
328 1.7 christos if (gdb::option::complete_options
329 1.7 christos (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, group))
330 1.7 christos return;
331 1.7 christos
332 1.7 christos word = advance_to_filename_complete_word_point (tracker, text);
333 1.7 christos filename_completer (ignore, tracker, text, word);
334 1.1 christos }
335 1.1 christos
336 1.1 christos /* Handle the input from the 'compile code' command. The
337 1.1 christos "compile code" command is used to evaluate an expression that may
338 1.1 christos contain calls to the GCC compiler. The language expected in this
339 1.1 christos compile command is the language currently set in GDB. */
340 1.7 christos
341 1.1 christos static void
342 1.5 christos compile_code_command (const char *args, int from_tty)
343 1.1 christos {
344 1.7 christos scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0);
345 1.1 christos
346 1.7 christos compile_options options;
347 1.7 christos
348 1.7 christos const gdb::option::option_def_group group
349 1.7 christos = make_compile_options_def_group (&options);
350 1.1 christos gdb::option::process_options
351 1.7 christos (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, group);
352 1.7 christos
353 1.1 christos enum compile_i_scope_types scope
354 1.7 christos = options.raw ? COMPILE_I_RAW_SCOPE : COMPILE_I_SIMPLE_SCOPE;
355 1.7 christos
356 1.1 christos if (args && *args)
357 1.1 christos eval_compile_command (NULL, args, scope, NULL);
358 1.6 christos else
359 1.1 christos {
360 1.1 christos counted_command_line l = get_command_line (compile_control, "");
361 1.5 christos
362 1.1 christos l->control_u.compile.scope = scope;
363 1.1 christos execute_control_command_untraced (l.get ());
364 1.1 christos }
365 1.7 christos }
366 1.7 christos
367 1.7 christos /* Completer for the "compile code" command. */
368 1.7 christos
369 1.7 christos static void
370 1.7 christos compile_code_command_completer (struct cmd_list_element *ignore,
371 1.7 christos completion_tracker &tracker,
372 1.7 christos const char *text, const char *word)
373 1.7 christos {
374 1.7 christos const gdb::option::option_def_group group
375 1.7 christos = make_compile_options_def_group (nullptr);
376 1.7 christos if (gdb::option::complete_options
377 1.7 christos (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, group))
378 1.7 christos return;
379 1.7 christos
380 1.7 christos word = advance_to_expression_complete_word_point (tracker, text);
381 1.7 christos symbol_completer (ignore, tracker, text, word);
382 1.3 christos }
383 1.3 christos
384 1.3 christos /* Callback for compile_print_command. */
385 1.3 christos
386 1.3 christos void
387 1.7 christos compile_print_value (struct value *val, void *data_voidp)
388 1.3 christos {
389 1.7 christos const value_print_options *print_opts = (value_print_options *) data_voidp;
390 1.3 christos
391 1.3 christos print_value (val, *print_opts);
392 1.3 christos }
393 1.3 christos
394 1.3 christos /* Handle the input from the 'compile print' command. The "compile
395 1.3 christos print" command is used to evaluate and print an expression that may
396 1.3 christos contain calls to the GCC compiler. The language expected in this
397 1.3 christos compile command is the language currently set in GDB. */
398 1.6 christos
399 1.3 christos static void
400 1.3 christos compile_print_command (const char *arg, int from_tty)
401 1.7 christos {
402 1.3 christos enum compile_i_scope_types scope = COMPILE_I_PRINT_ADDRESS_SCOPE;
403 1.5 christos value_print_options print_opts;
404 1.3 christos
405 1.7 christos scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0);
406 1.7 christos
407 1.7 christos get_user_print_options (&print_opts);
408 1.7 christos /* Override global settings with explicit options, if any. */
409 1.7 christos auto group = make_value_print_options_def_group (&print_opts);
410 1.7 christos gdb::option::process_options
411 1.7 christos (&arg, gdb::option::PROCESS_OPTIONS_REQUIRE_DELIMITER, group);
412 1.7 christos
413 1.7 christos print_command_parse_format (&arg, "compile print", &print_opts);
414 1.7 christos
415 1.7 christos /* Passing &PRINT_OPTS as SCOPE_DATA is safe as do_module_cleanup
416 1.3 christos will not touch the stale pointer if compile_object_run has
417 1.3 christos already quit. */
418 1.7 christos
419 1.3 christos if (arg && *arg)
420 1.3 christos eval_compile_command (NULL, arg, scope, &print_opts);
421 1.6 christos else
422 1.3 christos {
423 1.3 christos counted_command_line l = get_command_line (compile_control, "");
424 1.7 christos
425 1.5 christos l->control_u.compile.scope = scope;
426 1.3 christos l->control_u.compile.scope_data = &print_opts;
427 1.3 christos execute_control_command_untraced (l.get ());
428 1.3 christos }
429 1.1 christos }
430 1.1 christos
431 1.1 christos /* Return the name of the temporary directory to use for .o files, and
432 1.1 christos arrange for the directory to be removed at shutdown. */
433 1.1 christos
434 1.1 christos static const char *
435 1.1 christos get_compile_file_tempdir (void)
436 1.1 christos {
437 1.1 christos static char *tempdir_name;
438 1.1 christos
439 1.1 christos #define TEMPLATE TMP_PREFIX "XXXXXX"
440 1.1 christos char tname[sizeof (TEMPLATE)];
441 1.1 christos
442 1.1 christos if (tempdir_name != NULL)
443 1.1 christos return tempdir_name;
444 1.1 christos
445 1.1 christos strcpy (tname, TEMPLATE);
446 1.1 christos #undef TEMPLATE
447 1.1 christos tempdir_name = mkdtemp (tname);
448 1.1 christos if (tempdir_name == NULL)
449 1.1 christos perror_with_name (_("Could not make temporary directory"));
450 1.9 christos
451 1.9 christos tempdir_name = xstrdup (tempdir_name);
452 1.9 christos add_final_cleanup ([] ()
453 1.9 christos {
454 1.9 christos char *zap;
455 1.9 christos int wstat;
456 1.9 christos
457 1.9 christos gdb_assert (startswith (tempdir_name, TMP_PREFIX));
458 1.9 christos zap = concat ("rm -rf ", tempdir_name, (char *) NULL);
459 1.9 christos wstat = system (zap);
460 1.9 christos if (wstat == -1 || !WIFEXITED (wstat) || WEXITSTATUS (wstat) != 0)
461 1.9 christos warning (_("Could not remove temporary directory %s"), tempdir_name);
462 1.1 christos XDELETEVEC (zap);
463 1.1 christos });
464 1.1 christos return tempdir_name;
465 1.5 christos }
466 1.1 christos
467 1.5 christos /* Compute the names of source and object files to use. */
468 1.5 christos
469 1.1 christos static compile_file_names
470 1.1 christos get_new_file_names ()
471 1.1 christos {
472 1.1 christos static int seq;
473 1.1 christos const char *dir = get_compile_file_tempdir ();
474 1.5 christos
475 1.5 christos ++seq;
476 1.5 christos
477 1.5 christos return compile_file_names (string_printf ("%s%sout%d.c",
478 1.5 christos dir, SLASH_STRING, seq),
479 1.1 christos string_printf ("%s%sout%d.o",
480 1.1 christos dir, SLASH_STRING, seq));
481 1.1 christos }
482 1.1 christos
483 1.1 christos /* Get the block and PC at which to evaluate an expression. */
484 1.1 christos
485 1.1 christos static const struct block *
486 1.1 christos get_expr_block_and_pc (CORE_ADDR *pc)
487 1.1 christos {
488 1.1 christos const struct block *block = get_selected_block (pc);
489 1.1 christos
490 1.1 christos if (block == NULL)
491 1.1 christos {
492 1.1 christos struct symtab_and_line cursal = get_current_source_symtab_and_line ();
493 1.8 christos
494 1.8 christos if (cursal.symtab)
495 1.1 christos block = cursal.symtab->compunit ()->blockvector ()->static_block ();
496 1.8 christos
497 1.1 christos if (block != NULL)
498 1.1 christos *pc = block->entry_pc ();
499 1.8 christos }
500 1.1 christos else
501 1.1 christos *pc = block->entry_pc ();
502 1.1 christos
503 1.1 christos return block;
504 1.1 christos }
505 1.8 christos
506 1.8 christos /* String for 'set compile-args' and 'show compile-args'. */
507 1.8 christos static std::string compile_args =
508 1.8 christos /* Override flags possibly coming from DW_AT_producer. */
509 1.8 christos "-O0 -gdwarf-4"
510 1.8 christos /* We use -fPIE Otherwise GDB would need to reserve space large enough for
511 1.8 christos any object file in the inferior in advance to get the final address when
512 1.8 christos to link the object file to and additionally the default system linker
513 1.8 christos script would need to be modified so that one can specify there the
514 1.8 christos absolute target address.
515 1.8 christos -fPIC is not used at is would require from GDB to generate .got. */
516 1.8 christos " -fPIE"
517 1.8 christos /* We want warnings, except for some commonly happening for GDB commands. */
518 1.8 christos " -Wall "
519 1.8 christos " -Wno-unused-but-set-variable"
520 1.8 christos " -Wno-unused-variable"
521 1.1 christos /* Override CU's possible -fstack-protector-strong. */
522 1.8 christos " -fno-stack-protector";
523 1.8 christos
524 1.1 christos /* Parsed form of COMPILE_ARGS. */
525 1.1 christos static gdb_argv compile_args_argv;
526 1.1 christos
527 1.1 christos /* Implement 'set compile-args'. */
528 1.6 christos
529 1.1 christos static void
530 1.8 christos set_compile_args (const char *args, int from_tty, struct cmd_list_element *c)
531 1.1 christos {
532 1.1 christos compile_args_argv = gdb_argv (compile_args.c_str ());
533 1.1 christos }
534 1.1 christos
535 1.1 christos /* Implement 'show compile-args'. */
536 1.1 christos
537 1.1 christos static void
538 1.1 christos show_compile_args (struct ui_file *file, int from_tty,
539 1.8 christos struct cmd_list_element *c, const char *value)
540 1.8 christos {
541 1.8 christos gdb_printf (file, _("Compile command command-line arguments "
542 1.1 christos "are \"%s\".\n"),
543 1.1 christos value);
544 1.6 christos }
545 1.8 christos
546 1.6 christos /* String for 'set compile-gcc' and 'show compile-gcc'. */
547 1.6 christos static std::string compile_gcc;
548 1.6 christos
549 1.6 christos /* Implement 'show compile-gcc'. */
550 1.6 christos
551 1.6 christos static void
552 1.6 christos show_compile_gcc (struct ui_file *file, int from_tty,
553 1.8 christos struct cmd_list_element *c, const char *value)
554 1.8 christos {
555 1.6 christos gdb_printf (file, _("Compile command GCC driver filename is \"%s\".\n"),
556 1.6 christos value);
557 1.1 christos }
558 1.1 christos
559 1.1 christos /* Return DW_AT_producer parsed for get_selected_frame () (if any).
560 1.1 christos Return NULL otherwise.
561 1.1 christos
562 1.1 christos GCC already filters its command-line arguments only for the suitable ones to
563 1.1 christos put into DW_AT_producer - see GCC function gen_producer_string. */
564 1.1 christos
565 1.1 christos static const char *
566 1.1 christos get_selected_pc_producer_options (void)
567 1.1 christos {
568 1.1 christos CORE_ADDR pc = get_frame_pc (get_selected_frame (NULL));
569 1.1 christos struct compunit_symtab *symtab = find_pc_compunit_symtab (pc);
570 1.8 christos const char *cs;
571 1.8 christos
572 1.1 christos if (symtab == NULL || symtab->producer () == NULL
573 1.1 christos || !startswith (symtab->producer (), "GNU "))
574 1.8 christos return NULL;
575 1.1 christos
576 1.6 christos cs = symtab->producer ();
577 1.1 christos while (*cs != 0 && *cs != '-')
578 1.1 christos cs = skip_spaces (skip_to_space (cs));
579 1.1 christos if (*cs != '-')
580 1.1 christos return NULL;
581 1.1 christos return cs;
582 1.8 christos }
583 1.1 christos
584 1.1 christos /* Filter out unwanted options from ARGV. */
585 1.8 christos
586 1.1 christos static void
587 1.1 christos filter_args (char **argv)
588 1.1 christos {
589 1.1 christos char **destv;
590 1.1 christos
591 1.1 christos for (destv = argv; *argv != NULL; argv++)
592 1.1 christos {
593 1.1 christos /* -fpreprocessed may get in commonly from ccache. */
594 1.1 christos if (strcmp (*argv, "-fpreprocessed") == 0)
595 1.1 christos {
596 1.1 christos xfree (*argv);
597 1.1 christos continue;
598 1.1 christos }
599 1.1 christos *destv++ = *argv;
600 1.1 christos }
601 1.1 christos *destv = NULL;
602 1.6 christos }
603 1.6 christos
604 1.6 christos /* Produce final vector of GCC compilation options.
605 1.6 christos
606 1.6 christos The first element of the combined argument vector are arguments
607 1.6 christos relating to the target size ("-m64", "-m32" etc.). These are
608 1.6 christos sourced from the inferior's architecture.
609 1.6 christos
610 1.6 christos The second element of the combined argument vector are arguments
611 1.6 christos stored in the inferior DW_AT_producer section. If these are stored
612 1.6 christos in the inferior (there is no guarantee that they are), they are
613 1.6 christos added to the vector.
614 1.6 christos
615 1.6 christos The third element of the combined argument vector are argument
616 1.6 christos supplied by the language implementation provided by
617 1.6 christos compile-{lang}-support. These contain language specific arguments.
618 1.6 christos
619 1.6 christos The final element of the combined argument vector are arguments
620 1.6 christos supplied by the "set compile-args" command. These are always
621 1.1 christos appended last so as to override any of the arguments automatically
622 1.8 christos generated above. */
623 1.8 christos
624 1.1 christos static gdb_argv
625 1.1 christos get_args (const compile_instance *compiler, struct gdbarch *gdbarch)
626 1.8 christos {
627 1.1 christos const char *cs_producer_options;
628 1.8 christos gdb_argv result;
629 1.8 christos
630 1.8 christos std::string gcc_options = gdbarch_gcc_target_options (gdbarch);
631 1.8 christos
632 1.8 christos /* Make sure we have a non-empty set of options, otherwise GCC will
633 1.8 christos error out trying to look for a filename that is an empty string. */
634 1.1 christos if (!gcc_options.empty ())
635 1.1 christos result = gdb_argv (gcc_options.c_str ());
636 1.1 christos
637 1.1 christos cs_producer_options = get_selected_pc_producer_options ();
638 1.8 christos if (cs_producer_options != NULL)
639 1.8 christos {
640 1.1 christos gdb_argv argv_producer (cs_producer_options);
641 1.8 christos filter_args (argv_producer.get ());
642 1.1 christos
643 1.1 christos result.append (std::move (argv_producer));
644 1.8 christos }
645 1.8 christos
646 1.1 christos result.append (gdb_argv (compiler->gcc_target_options ().c_str ()));
647 1.8 christos result.append (compile_args_argv);
648 1.1 christos
649 1.1 christos return result;
650 1.1 christos }
651 1.1 christos
652 1.1 christos /* A helper function suitable for use as the "print_callback" in the
653 1.1 christos compiler object. */
654 1.1 christos
655 1.1 christos static void
656 1.8 christos print_callback (void *ignore, const char *message)
657 1.1 christos {
658 1.1 christos gdb_puts (message, gdb_stderr);
659 1.1 christos }
660 1.5 christos
661 1.5 christos /* Process the compilation request. On success it returns the object
662 1.1 christos and source file names. On an error condition, error () is
663 1.5 christos called. */
664 1.3 christos
665 1.5 christos static compile_file_names
666 1.1 christos compile_to_object (struct command_line *cmd, const char *cmd_string,
667 1.1 christos enum compile_i_scope_types scope)
668 1.1 christos {
669 1.1 christos const struct block *expr_block;
670 1.1 christos CORE_ADDR trash_pc, expr_pc;
671 1.6 christos int ok;
672 1.1 christos struct gdbarch *gdbarch = get_current_arch ();
673 1.8 christos std::string triplet_rx;
674 1.1 christos
675 1.1 christos if (!target_has_execution ())
676 1.1 christos error (_("The program must be running for the compile command to "\
677 1.1 christos "work."));
678 1.1 christos
679 1.1 christos expr_block = get_expr_block_and_pc (&trash_pc);
680 1.1 christos expr_pc = get_frame_address_in_block (get_selected_frame (NULL));
681 1.8 christos
682 1.8 christos /* Set up instance and context for the compiler. */
683 1.7 christos std::unique_ptr<compile_instance> compiler
684 1.4 christos = current_language->get_compile_instance ();
685 1.8 christos if (compiler == nullptr)
686 1.6 christos error (_("No compiler support for language %s."),
687 1.6 christos current_language->name ());
688 1.6 christos compiler->set_print_callback (print_callback, NULL);
689 1.1 christos compiler->set_scope (scope);
690 1.1 christos compiler->set_block (expr_block);
691 1.1 christos
692 1.5 christos /* From the provided expression, build a scope to pass to the
693 1.5 christos compiler. */
694 1.5 christos
695 1.5 christos string_file input_buf;
696 1.1 christos const char *input;
697 1.1 christos
698 1.1 christos if (cmd != NULL)
699 1.1 christos {
700 1.6 christos struct command_line *iter;
701 1.1 christos
702 1.5 christos for (iter = cmd->body_list_0.get (); iter; iter = iter->next)
703 1.5 christos {
704 1.1 christos input_buf.puts (iter->line);
705 1.1 christos input_buf.puts ("\n");
706 1.5 christos }
707 1.1 christos
708 1.1 christos input = input_buf.c_str ();
709 1.3 christos }
710 1.1 christos else if (cmd_string != NULL)
711 1.1 christos input = cmd_string;
712 1.1 christos else
713 1.5 christos error (_("Neither a simple expression, or a multi-line specified."));
714 1.7 christos
715 1.7 christos std::string code
716 1.1 christos = current_language->compute_program (compiler.get (), input, gdbarch,
717 1.8 christos expr_block, expr_pc);
718 1.1 christos if (compile_debug)
719 1.6 christos gdb_printf (gdb_stdlog, "debug output:\n\n%s", code.c_str ());
720 1.6 christos
721 1.8 christos compiler->set_verbose (compile_debug);
722 1.6 christos
723 1.6 christos if (!compile_gcc.empty ())
724 1.6 christos {
725 1.6 christos if (compiler->version () < GCC_FE_VERSION_1)
726 1.6 christos error (_("Command 'set compile-gcc' requires GCC version 6 or higher "
727 1.8 christos "(libcc1 interface version 1 or higher)"));
728 1.6 christos
729 1.6 christos compiler->set_driver_filename (compile_gcc.c_str ());
730 1.6 christos }
731 1.6 christos else
732 1.6 christos {
733 1.1 christos const char *os_rx = osabi_triplet_regexp (gdbarch_osabi (gdbarch));
734 1.6 christos const char *arch_rx = gdbarch_gnu_triplet_regexp (gdbarch);
735 1.8 christos
736 1.8 christos /* Allow triplets with or without vendor set. */
737 1.8 christos triplet_rx = std::string (arch_rx) + "(-[^-]*)?-";
738 1.6 christos if (os_rx != nullptr)
739 1.6 christos triplet_rx += os_rx;
740 1.1 christos compiler->set_triplet_regexp (triplet_rx.c_str ());
741 1.1 christos }
742 1.8 christos
743 1.8 christos /* Set compiler command-line arguments. */
744 1.8 christos gdb_argv argv_holder = get_args (compiler.get (), gdbarch);
745 1.6 christos int argc = argv_holder.count ();
746 1.8 christos char **argv = argv_holder.get ();
747 1.8 christos
748 1.1 christos gdb::unique_xmalloc_ptr<char> error_message
749 1.1 christos = compiler->set_arguments (argc, argv, triplet_rx.c_str ());
750 1.6 christos
751 1.1 christos if (error_message != NULL)
752 1.1 christos error ("%s", error_message.get ());
753 1.1 christos
754 1.1 christos if (compile_debug)
755 1.1 christos {
756 1.8 christos int argi;
757 1.1 christos
758 1.8 christos gdb_printf (gdb_stdlog, "Passing %d compiler options:\n", argc);
759 1.8 christos for (argi = 0; argi < argc; argi++)
760 1.1 christos gdb_printf (gdb_stdlog, "Compiler option %d: <%s>\n",
761 1.1 christos argi, argv[argi]);
762 1.5 christos }
763 1.1 christos
764 1.9 christos compile_file_names fnames = get_new_file_names ();
765 1.6 christos
766 1.6 christos std::optional<gdb::unlinker> source_remover;
767 1.6 christos
768 1.6 christos {
769 1.6 christos gdb_file_up src = gdb_fopen_cloexec (fnames.source_file (), "w");
770 1.6 christos if (src == NULL)
771 1.6 christos perror_with_name (_("Could not open source file for writing"));
772 1.6 christos
773 1.6 christos source_remover.emplace (fnames.source_file ());
774 1.6 christos
775 1.6 christos if (fputs (code.c_str (), src.get ()) == EOF)
776 1.1 christos perror_with_name (_("Could not write to source file"));
777 1.1 christos }
778 1.8 christos
779 1.8 christos if (compile_debug)
780 1.8 christos gdb_printf (gdb_stdlog, "source file produced: %s\n\n",
781 1.8 christos fnames.source_file ());
782 1.8 christos
783 1.8 christos /* If we don't do this, then GDB simply exits
784 1.1 christos when the compiler dies. */
785 1.1 christos scoped_ignore_sigpipe ignore_sigpipe;
786 1.6 christos
787 1.6 christos /* Call the compiler and start the compilation process. */
788 1.6 christos compiler->set_source_file (fnames.source_file ());
789 1.1 christos ok = compiler->compile (fnames.object_file (), compile_debug);
790 1.1 christos if (!ok)
791 1.1 christos error (_("Compilation failed."));
792 1.8 christos
793 1.8 christos if (compile_debug)
794 1.1 christos gdb_printf (gdb_stdlog, "object file produced: %s\n\n",
795 1.6 christos fnames.object_file ());
796 1.6 christos
797 1.5 christos /* Keep the source file. */
798 1.1 christos source_remover->keep ();
799 1.1 christos return fnames;
800 1.1 christos }
801 1.1 christos
802 1.1 christos /* The "compile" prefix command. */
803 1.6 christos
804 1.1 christos static void
805 1.1 christos compile_command (const char *args, int from_tty)
806 1.1 christos {
807 1.1 christos /* If a sub-command is not specified to the compile prefix command,
808 1.1 christos assume it is a direct code compilation. */
809 1.1 christos compile_code_command (args, from_tty);
810 1.1 christos }
811 1.1 christos
812 1.1 christos /* See compile.h. */
813 1.3 christos
814 1.3 christos void
815 1.1 christos eval_compile_command (struct command_line *cmd, const char *cmd_string,
816 1.5 christos enum compile_i_scope_types scope, void *scope_data)
817 1.1 christos {
818 1.6 christos compile_file_names fnames = compile_to_object (cmd, cmd_string, scope);
819 1.6 christos
820 1.6 christos gdb::unlinker object_remover (fnames.object_file ());
821 1.8 christos gdb::unlinker source_remover (fnames.source_file ());
822 1.8 christos
823 1.5 christos compile_module_up compile_module = compile_object_load (fnames, scope,
824 1.5 christos scope_data);
825 1.5 christos if (compile_module == NULL)
826 1.5 christos {
827 1.5 christos gdb_assert (scope == COMPILE_I_PRINT_ADDRESS_SCOPE);
828 1.5 christos eval_compile_command (cmd, cmd_string,
829 1.1 christos COMPILE_I_PRINT_VALUE_SCOPE, scope_data);
830 1.6 christos return;
831 1.6 christos }
832 1.6 christos
833 1.6 christos /* Keep the files. */
834 1.6 christos source_remover.keep ();
835 1.8 christos object_remover.keep ();
836 1.1 christos
837 1.1 christos compile_object_run (std::move (compile_module));
838 1.1 christos }
839 1.1 christos
840 1.6 christos /* See compile/compile-internal.h. */
841 1.1 christos
842 1.1 christos std::string
843 1.1 christos compile_register_name_mangled (struct gdbarch *gdbarch, int regnum)
844 1.1 christos {
845 1.6 christos const char *regname = gdbarch_register_name (gdbarch, regnum);
846 1.1 christos
847 1.1 christos return string_printf ("__%s", regname);
848 1.1 christos }
849 1.1 christos
850 1.1 christos /* See compile/compile-internal.h. */
851 1.1 christos
852 1.1 christos int
853 1.1 christos compile_register_name_demangle (struct gdbarch *gdbarch,
854 1.1 christos const char *regname)
855 1.1 christos {
856 1.1 christos int regnum;
857 1.1 christos
858 1.1 christos if (regname[0] != '_' || regname[1] != '_')
859 1.1 christos error (_("Invalid register name \"%s\"."), regname);
860 1.1 christos regname += 2;
861 1.1 christos
862 1.1 christos for (regnum = 0; regnum < gdbarch_num_regs (gdbarch); regnum++)
863 1.1 christos if (strcmp (regname, gdbarch_register_name (gdbarch, regnum)) == 0)
864 1.1 christos return regnum;
865 1.1 christos
866 1.1 christos error (_("Cannot find gdbarch register \"%s\"."), regname);
867 1.6 christos }
868 1.6 christos
869 1.6 christos /* Forwards to the plug-in. */
870 1.6 christos
871 1.6 christos #define FORWARD(OP,...) (m_gcc_fe->ops->OP (m_gcc_fe, ##__VA_ARGS__))
872 1.6 christos
873 1.6 christos /* See compile-internal.h. */
874 1.6 christos
875 1.6 christos void
876 1.6 christos compile_instance::set_print_callback
877 1.6 christos (void (*print_function) (void *, const char *), void *datum)
878 1.6 christos {
879 1.6 christos FORWARD (set_print_callback, print_function, datum);
880 1.6 christos }
881 1.6 christos
882 1.6 christos /* See compile-internal.h. */
883 1.6 christos
884 1.6 christos unsigned int
885 1.6 christos compile_instance::version () const
886 1.6 christos {
887 1.6 christos return m_gcc_fe->ops->version;
888 1.6 christos }
889 1.6 christos
890 1.6 christos /* See compile-internal.h. */
891 1.6 christos
892 1.6 christos void
893 1.6 christos compile_instance::set_verbose (int level)
894 1.6 christos {
895 1.6 christos if (version () >= GCC_FE_VERSION_1)
896 1.6 christos FORWARD (set_verbose, level);
897 1.6 christos }
898 1.6 christos
899 1.6 christos /* See compile-internal.h. */
900 1.6 christos
901 1.6 christos void
902 1.6 christos compile_instance::set_driver_filename (const char *filename)
903 1.6 christos {
904 1.6 christos if (version () >= GCC_FE_VERSION_1)
905 1.6 christos FORWARD (set_driver_filename, filename);
906 1.6 christos }
907 1.6 christos
908 1.6 christos /* See compile-internal.h. */
909 1.6 christos
910 1.6 christos void
911 1.6 christos compile_instance::set_triplet_regexp (const char *regexp)
912 1.6 christos {
913 1.6 christos if (version () >= GCC_FE_VERSION_1)
914 1.6 christos FORWARD (set_triplet_regexp, regexp);
915 1.6 christos }
916 1.6 christos
917 1.8 christos /* See compile-internal.h. */
918 1.6 christos
919 1.6 christos gdb::unique_xmalloc_ptr<char>
920 1.6 christos compile_instance::set_arguments (int argc, char **argv, const char *regexp)
921 1.8 christos {
922 1.6 christos if (version () >= GCC_FE_VERSION_1)
923 1.8 christos return gdb::unique_xmalloc_ptr<char> (FORWARD (set_arguments, argc, argv));
924 1.8 christos else
925 1.6 christos return gdb::unique_xmalloc_ptr<char> (FORWARD (set_arguments_v0, regexp,
926 1.6 christos argc, argv));
927 1.6 christos }
928 1.6 christos
929 1.6 christos /* See compile-internal.h. */
930 1.6 christos
931 1.6 christos void
932 1.6 christos compile_instance::set_source_file (const char *filename)
933 1.6 christos {
934 1.6 christos FORWARD (set_source_file, filename);
935 1.6 christos }
936 1.6 christos
937 1.6 christos /* See compile-internal.h. */
938 1.6 christos
939 1.6 christos bool
940 1.6 christos compile_instance::compile (const char *filename, int verbose_level)
941 1.6 christos {
942 1.6 christos if (version () >= GCC_FE_VERSION_1)
943 1.6 christos return FORWARD (compile, filename);
944 1.6 christos else
945 1.6 christos return FORWARD (compile_v0, filename, verbose_level);
946 1.6 christos }
947 1.6 christos
948 1.6 christos #undef FORWARD
949 1.6 christos
950 1.1 christos /* See compile.h. */
951 1.7 christos cmd_list_element *compile_cmd_element = nullptr;
952 1.1 christos
953 1.7 christos void _initialize_compile ();
954 1.1 christos void
955 1.1 christos _initialize_compile ()
956 1.1 christos {
957 1.6 christos struct cmd_list_element *c = NULL;
958 1.6 christos
959 1.1 christos compile_cmd_element = add_prefix_cmd ("compile", class_obscure,
960 1.8 christos compile_command, _("\
961 1.8 christos Command to compile source code and inject it into the inferior."),
962 1.1 christos &compile_command_list, 1, &cmdlist);
963 1.7 christos add_com_alias ("expression", compile_cmd_element, class_obscure, 0);
964 1.7 christos
965 1.7 christos const auto compile_opts = make_compile_options_def_group (nullptr);
966 1.7 christos
967 1.1 christos static const std::string compile_code_help
968 1.1 christos = gdb::option::build_help (_("\
969 1.7 christos Compile, inject, and execute code.\n\
970 1.7 christos \n\
971 1.7 christos Usage: compile code [OPTION]... [CODE]\n\
972 1.7 christos \n\
973 1.1 christos Options:\n\
974 1.1 christos %OPTIONS%\n\
975 1.1 christos \n\
976 1.1 christos The source code may be specified as a simple one line expression, e.g.:\n\
977 1.1 christos \n\
978 1.3 christos compile code printf(\"Hello world\\n\");\n\
979 1.3 christos \n\
980 1.3 christos Alternatively, you can type a multiline expression by invoking\n\
981 1.3 christos this command with no argument. GDB will then prompt for the\n\
982 1.7 christos expression interactively; type a line containing \"end\" to\n\
983 1.7 christos indicate the end of the expression."),
984 1.7 christos compile_opts);
985 1.7 christos
986 1.7 christos c = add_cmd ("code", class_obscure, compile_code_command,
987 1.7 christos compile_code_help.c_str (),
988 1.1 christos &compile_command_list);
989 1.7 christos set_cmd_completer_handle_brkchars (c, compile_code_command_completer);
990 1.7 christos
991 1.1 christos static const std::string compile_file_help
992 1.1 christos = gdb::option::build_help (_("\
993 1.7 christos Evaluate a file containing source code.\n\
994 1.7 christos \n\
995 1.7 christos Usage: compile file [OPTION].. [FILENAME]\n\
996 1.7 christos \n\
997 1.7 christos Options:\n\
998 1.7 christos %OPTIONS%"),
999 1.7 christos compile_opts);
1000 1.7 christos
1001 1.1 christos c = add_cmd ("file", class_obscure, compile_file_command,
1002 1.7 christos compile_file_help.c_str (),
1003 1.7 christos &compile_command_list);
1004 1.7 christos set_cmd_completer_handle_brkchars (c, compile_file_command_completer);
1005 1.1 christos
1006 1.7 christos const auto compile_print_opts = make_value_print_options_def_group (nullptr);
1007 1.7 christos
1008 1.3 christos static const std::string compile_print_help
1009 1.3 christos = gdb::option::build_help (_("\
1010 1.7 christos Evaluate EXPR by using the compiler and print result.\n\
1011 1.7 christos \n\
1012 1.7 christos Usage: compile print [[OPTION]... --] [/FMT] [EXPR]\n\
1013 1.7 christos \n\
1014 1.7 christos Options:\n\
1015 1.7 christos %OPTIONS%\n\
1016 1.7 christos \n\
1017 1.7 christos Note: because this command accepts arbitrary expressions, if you\n\
1018 1.3 christos specify any command option, you must use a double dash (\"--\")\n\
1019 1.3 christos to mark the end of option processing. E.g.: \"compile print -o -- myobj\".\n\
1020 1.3 christos \n\
1021 1.3 christos The expression may be specified on the same line as the command, e.g.:\n\
1022 1.3 christos \n\
1023 1.3 christos compile print i\n\
1024 1.3 christos \n\
1025 1.3 christos Alternatively, you can type a multiline expression by invoking\n\
1026 1.3 christos this command with no argument. GDB will then prompt for the\n\
1027 1.3 christos expression interactively; type a line containing \"end\" to\n\
1028 1.3 christos indicate the end of the expression.\n\
1029 1.3 christos \n\
1030 1.7 christos EXPR may be preceded with /FMT, where FMT is a format letter\n\
1031 1.7 christos but no count or size letter (see \"x\" command)."),
1032 1.7 christos compile_print_opts);
1033 1.7 christos
1034 1.7 christos c = add_cmd ("print", class_obscure, compile_print_command,
1035 1.7 christos compile_print_help.c_str (),
1036 1.3 christos &compile_command_list);
1037 1.1 christos set_cmd_completer_handle_brkchars (c, print_command_completer);
1038 1.1 christos
1039 1.1 christos add_setshow_boolean_cmd ("compile", class_maintenance, &compile_debug, _("\
1040 1.1 christos Set compile command debugging."), _("\
1041 1.1 christos Show compile command debugging."), _("\
1042 1.1 christos When on, compile command debugging is enabled."),
1043 1.1 christos NULL, show_compile_debug,
1044 1.1 christos &setdebuglist, &showdebuglist);
1045 1.1 christos
1046 1.7 christos add_setshow_string_cmd ("compile-args", class_support,
1047 1.7 christos &compile_args,
1048 1.1 christos _("Set compile command GCC command-line arguments."),
1049 1.1 christos _("Show compile command GCC command-line arguments."),
1050 1.1 christos _("\
1051 1.1 christos Use options like -I (include file directory) or ABI settings.\n\
1052 1.1 christos String quoting is parsed like in shell, for example:\n\
1053 1.1 christos -mno-align-double \"-I/dir with a space/include\""),
1054 1.8 christos set_compile_args, show_compile_args, &setlist, &showlist);
1055 1.8 christos
1056 1.8 christos
1057 1.6 christos /* Initialize compile_args_argv. */
1058 1.6 christos set_compile_args (compile_args.c_str (), 0, NULL);
1059 1.6 christos
1060 1.6 christos add_setshow_optional_filename_cmd ("compile-gcc", class_support,
1061 1.7 christos &compile_gcc,
1062 1.6 christos _("Set compile command "
1063 1.7 christos "GCC driver filename."),
1064 1.6 christos _("Show compile command "
1065 1.6 christos "GCC driver filename."),
1066 1.6 christos _("\
1067 1.6 christos It should be absolute filename of the gcc executable.\n\
1068 1.6 christos If empty the default target triplet will be searched in $PATH."),
1069 1.1 christos NULL, show_compile_gcc, &setlist,
1070 &showlist);
1071 }
1072