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