compile.c revision 1.4 1 /* General Compile and inject code
2
3 Copyright (C) 2014-2016 Free Software Foundation, Inc.
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"
21 #include "top.h"
22 #include "ui-out.h"
23 #include "command.h"
24 #include "cli/cli-script.h"
25 #include "cli/cli-utils.h"
26 #include "completer.h"
27 #include "gdbcmd.h"
28 #include "compile.h"
29 #include "compile-internal.h"
30 #include "compile-object-load.h"
31 #include "compile-object-run.h"
32 #include "language.h"
33 #include "frame.h"
34 #include "source.h"
35 #include "block.h"
36 #include "arch-utils.h"
37 #include "filestuff.h"
38 #include "target.h"
39 #include "osabi.h"
40 #include "gdb_wait.h"
41 #include "valprint.h"
42
43
44
46 /* Initial filename for temporary files. */
47
48 #define TMP_PREFIX "/tmp/gdbobj-"
49
50 /* Hold "compile" commands. */
51
52 static struct cmd_list_element *compile_command_list;
53
54 /* Debug flag for "compile" commands. */
55
56 int compile_debug;
57
58 /* Implement "show debug compile". */
59
60 static void
61 show_compile_debug (struct ui_file *file, int from_tty,
62 struct cmd_list_element *c, const char *value)
63 {
64 fprintf_filtered (file, _("Compile debugging is %s.\n"), value);
65 }
66
67
68
70 /* Check *ARG for a "-raw" or "-r" argument. Return 0 if not seen.
71 Return 1 if seen and update *ARG. */
72
73 static int
74 check_raw_argument (char **arg)
75 {
76 *arg = skip_spaces (*arg);
77
78 if (arg != NULL
79 && (check_for_argument (arg, "-raw", sizeof ("-raw") - 1)
80 || check_for_argument (arg, "-r", sizeof ("-r") - 1)))
81 return 1;
82 return 0;
83 }
84
85 /* Handle the input from the 'compile file' command. The "compile
86 file" command is used to evaluate an expression contained in a file
87 that may contain calls to the GCC compiler. */
88
89 static void
90 compile_file_command (char *arg, int from_tty)
91 {
92 enum compile_i_scope_types scope = COMPILE_I_SIMPLE_SCOPE;
93 char *buffer;
94 struct cleanup *cleanup;
95
96 cleanup = make_cleanup_restore_integer (¤t_ui->async);
97 current_ui->async = 0;
98
99 /* Check the user did not just <enter> after command. */
100 if (arg == NULL)
101 error (_("You must provide a filename for this command."));
102
103 /* Check if a raw (-r|-raw) argument is provided. */
104 if (arg != NULL && check_raw_argument (&arg))
105 {
106 scope = COMPILE_I_RAW_SCOPE;
107 arg = skip_spaces (arg);
108 }
109
110 /* After processing arguments, check there is a filename at the end
111 of the command. */
112 if (arg[0] == '\0')
113 error (_("You must provide a filename with the raw option set."));
114
115 if (arg[0] == '-')
116 error (_("Unknown argument specified."));
117
118 arg = skip_spaces (arg);
119 arg = gdb_abspath (arg);
120 make_cleanup (xfree, arg);
121 buffer = xstrprintf ("#include \"%s\"\n", arg);
122 make_cleanup (xfree, buffer);
123 eval_compile_command (NULL, buffer, scope, NULL);
124 do_cleanups (cleanup);
125 }
126
127 /* Handle the input from the 'compile code' command. The
128 "compile code" command is used to evaluate an expression that may
129 contain calls to the GCC compiler. The language expected in this
130 compile command is the language currently set in GDB. */
131
132 static void
133 compile_code_command (char *arg, int from_tty)
134 {
135 struct cleanup *cleanup;
136 enum compile_i_scope_types scope = COMPILE_I_SIMPLE_SCOPE;
137
138 cleanup = make_cleanup_restore_integer (¤t_ui->async);
139 current_ui->async = 0;
140
141 if (arg != NULL && check_raw_argument (&arg))
142 {
143 scope = COMPILE_I_RAW_SCOPE;
144 arg = skip_spaces (arg);
145 }
146
147 arg = skip_spaces (arg);
148
149 if (arg != NULL && !check_for_argument (&arg, "--", sizeof ("--") - 1))
150 {
151 if (arg[0] == '-')
152 error (_("Unknown argument specified."));
153 }
154
155 if (arg && *arg)
156 eval_compile_command (NULL, arg, scope, NULL);
157 else
158 {
159 struct command_line *l = get_command_line (compile_control, "");
160
161 make_cleanup_free_command_lines (&l);
162 l->control_u.compile.scope = scope;
163 execute_control_command_untraced (l);
164 }
165
166 do_cleanups (cleanup);
167 }
168
169 /* Callback for compile_print_command. */
170
171 void
172 compile_print_value (struct value *val, void *data_voidp)
173 {
174 const struct format_data *fmtp = (const struct format_data *) data_voidp;
175
176 print_value (val, fmtp);
177 }
178
179 /* Handle the input from the 'compile print' command. The "compile
180 print" command is used to evaluate and print an expression that may
181 contain calls to the GCC compiler. The language expected in this
182 compile command is the language currently set in GDB. */
183
184 static void
185 compile_print_command (char *arg_param, int from_tty)
186 {
187 const char *arg = arg_param;
188 struct cleanup *cleanup;
189 enum compile_i_scope_types scope = COMPILE_I_PRINT_ADDRESS_SCOPE;
190 struct format_data fmt;
191
192 cleanup = make_cleanup_restore_integer (¤t_ui->async);
193 current_ui->async = 0;
194
195 /* Passing &FMT as SCOPE_DATA is safe as do_module_cleanup will not
196 touch the stale pointer if compile_object_run has already quit. */
197 print_command_parse_format (&arg, "compile print", &fmt);
198
199 if (arg && *arg)
200 eval_compile_command (NULL, arg, scope, &fmt);
201 else
202 {
203 struct command_line *l = get_command_line (compile_control, "");
204
205 make_cleanup_free_command_lines (&l);
206 l->control_u.compile.scope = scope;
207 l->control_u.compile.scope_data = &fmt;
208 execute_control_command_untraced (l);
209 }
210
211 do_cleanups (cleanup);
212 }
213
214 /* A cleanup function to remove a directory and all its contents. */
215
216 static void
217 do_rmdir (void *arg)
218 {
219 const char *dir = (const char *) arg;
220 char *zap;
221 int wstat;
222
223 gdb_assert (startswith (dir, TMP_PREFIX));
224 zap = concat ("rm -rf ", dir, (char *) NULL);
225 wstat = system (zap);
226 if (wstat == -1 || !WIFEXITED (wstat) || WEXITSTATUS (wstat) != 0)
227 warning (_("Could not remove temporary directory %s"), dir);
228 XDELETEVEC (zap);
229 }
230
231 /* Return the name of the temporary directory to use for .o files, and
232 arrange for the directory to be removed at shutdown. */
233
234 static const char *
235 get_compile_file_tempdir (void)
236 {
237 static char *tempdir_name;
238
239 #define TEMPLATE TMP_PREFIX "XXXXXX"
240 char tname[sizeof (TEMPLATE)];
241
242 if (tempdir_name != NULL)
243 return tempdir_name;
244
245 strcpy (tname, TEMPLATE);
246 #undef TEMPLATE
247 #ifdef HAVE_MKDTEMP
248 tempdir_name = mkdtemp (tname);
249 #else
250 error (_("Command not supported on this host."));
251 #endif
252 if (tempdir_name == NULL)
253 perror_with_name (_("Could not make temporary directory"));
254
255 tempdir_name = xstrdup (tempdir_name);
256 make_final_cleanup (do_rmdir, tempdir_name);
257 return tempdir_name;
258 }
259
260 /* Compute the names of source and object files to use. The names are
261 allocated by malloc and should be freed by the caller. */
262
263 static void
264 get_new_file_names (char **source_file, char **object_file)
265 {
266 static int seq;
267 const char *dir = get_compile_file_tempdir ();
268
269 ++seq;
270 *source_file = xstrprintf ("%s%sout%d.c", dir, SLASH_STRING, seq);
271 *object_file = xstrprintf ("%s%sout%d.o", dir, SLASH_STRING, seq);
272 }
273
274 /* Get the block and PC at which to evaluate an expression. */
275
276 static const struct block *
277 get_expr_block_and_pc (CORE_ADDR *pc)
278 {
279 const struct block *block = get_selected_block (pc);
280
281 if (block == NULL)
282 {
283 struct symtab_and_line cursal = get_current_source_symtab_and_line ();
284
285 if (cursal.symtab)
286 block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (cursal.symtab),
287 STATIC_BLOCK);
288 if (block != NULL)
289 *pc = BLOCK_START (block);
290 }
291 else
292 *pc = BLOCK_START (block);
293
294 return block;
295 }
296
297 /* Call gdb_buildargv, set its result for S into *ARGVP but calculate also the
298 number of parsed arguments into *ARGCP. If gdb_buildargv has returned NULL
299 then *ARGCP is set to zero. */
300
301 static void
302 build_argc_argv (const char *s, int *argcp, char ***argvp)
303 {
304 *argvp = gdb_buildargv (s);
305 *argcp = countargv (*argvp);
306 }
307
308 /* String for 'set compile-args' and 'show compile-args'. */
309 static char *compile_args;
310
311 /* Parsed form of COMPILE_ARGS. COMPILE_ARGS_ARGV is NULL terminated. */
312 static int compile_args_argc;
313 static char **compile_args_argv;
314
315 /* Implement 'set compile-args'. */
316
317 static void
318 set_compile_args (char *args, int from_tty, struct cmd_list_element *c)
319 {
320 freeargv (compile_args_argv);
321 build_argc_argv (compile_args, &compile_args_argc, &compile_args_argv);
322 }
323
324 /* Implement 'show compile-args'. */
325
326 static void
327 show_compile_args (struct ui_file *file, int from_tty,
328 struct cmd_list_element *c, const char *value)
329 {
330 fprintf_filtered (file, _("Compile command command-line arguments "
331 "are \"%s\".\n"),
332 value);
333 }
334
335 /* Append ARGC and ARGV (as parsed by build_argc_argv) to *ARGCP and *ARGVP.
336 ARGCP+ARGVP can be zero+NULL and also ARGC+ARGV can be zero+NULL. */
337
338 static void
339 append_args (int *argcp, char ***argvp, int argc, char **argv)
340 {
341 int argi;
342
343 *argvp = XRESIZEVEC (char *, *argvp, (*argcp + argc + 1));
344
345 for (argi = 0; argi < argc; argi++)
346 (*argvp)[(*argcp)++] = xstrdup (argv[argi]);
347 (*argvp)[(*argcp)] = NULL;
348 }
349
350 /* Return DW_AT_producer parsed for get_selected_frame () (if any).
351 Return NULL otherwise.
352
353 GCC already filters its command-line arguments only for the suitable ones to
354 put into DW_AT_producer - see GCC function gen_producer_string. */
355
356 static const char *
357 get_selected_pc_producer_options (void)
358 {
359 CORE_ADDR pc = get_frame_pc (get_selected_frame (NULL));
360 struct compunit_symtab *symtab = find_pc_compunit_symtab (pc);
361 const char *cs;
362
363 if (symtab == NULL || symtab->producer == NULL
364 || !startswith (symtab->producer, "GNU "))
365 return NULL;
366
367 cs = symtab->producer;
368 while (*cs != 0 && *cs != '-')
369 cs = skip_spaces_const (skip_to_space_const (cs));
370 if (*cs != '-')
371 return NULL;
372 return cs;
373 }
374
375 /* Filter out unwanted options from *ARGCP and ARGV. */
376
377 static void
378 filter_args (int *argcp, char **argv)
379 {
380 char **destv;
381
382 for (destv = argv; *argv != NULL; argv++)
383 {
384 /* -fpreprocessed may get in commonly from ccache. */
385 if (strcmp (*argv, "-fpreprocessed") == 0)
386 {
387 xfree (*argv);
388 (*argcp)--;
389 continue;
390 }
391 *destv++ = *argv;
392 }
393 *destv = NULL;
394 }
395
396 /* Produce final vector of GCC compilation options. First element is target
397 size ("-m64", "-m32" etc.), optionally followed by DW_AT_producer options
398 and then compile-args string GDB variable. */
399
400 static void
401 get_args (const struct compile_instance *compiler, struct gdbarch *gdbarch,
402 int *argcp, char ***argvp)
403 {
404 const char *cs_producer_options;
405 int argc_compiler;
406 char **argv_compiler;
407
408 build_argc_argv (gdbarch_gcc_target_options (gdbarch),
409 argcp, argvp);
410
411 cs_producer_options = get_selected_pc_producer_options ();
412 if (cs_producer_options != NULL)
413 {
414 int argc_producer;
415 char **argv_producer;
416
417 build_argc_argv (cs_producer_options, &argc_producer, &argv_producer);
418 filter_args (&argc_producer, argv_producer);
419 append_args (argcp, argvp, argc_producer, argv_producer);
420 freeargv (argv_producer);
421 }
422
423 build_argc_argv (compiler->gcc_target_options,
424 &argc_compiler, &argv_compiler);
425 append_args (argcp, argvp, argc_compiler, argv_compiler);
426 freeargv (argv_compiler);
427
428 append_args (argcp, argvp, compile_args_argc, compile_args_argv);
429 }
430
431 /* A cleanup function to destroy a gdb_gcc_instance. */
432
433 static void
434 cleanup_compile_instance (void *arg)
435 {
436 struct compile_instance *inst = (struct compile_instance *) arg;
437
438 inst->destroy (inst);
439 }
440
441 /* A cleanup function to unlink a file. */
442
443 static void
444 cleanup_unlink_file (void *arg)
445 {
446 const char *filename = (const char *) arg;
447
448 unlink (filename);
449 }
450
451 /* A helper function suitable for use as the "print_callback" in the
452 compiler object. */
453
454 static void
455 print_callback (void *ignore, const char *message)
456 {
457 fputs_filtered (message, gdb_stderr);
458 }
459
460 /* Process the compilation request. On success it returns the object
461 file name and *SOURCE_FILEP is set to source file name. On an
462 error condition, error () is called. The caller is responsible for
463 freeing both strings. */
464
465 static char *
466 compile_to_object (struct command_line *cmd, const char *cmd_string,
467 enum compile_i_scope_types scope,
468 char **source_filep)
469 {
470 char *code;
471 const char *input;
472 char *source_file, *object_file;
473 struct compile_instance *compiler;
474 struct cleanup *cleanup, *inner_cleanup;
475 const struct block *expr_block;
476 CORE_ADDR trash_pc, expr_pc;
477 int argc;
478 char **argv;
479 int ok;
480 FILE *src;
481 struct gdbarch *gdbarch = get_current_arch ();
482 const char *os_rx;
483 const char *arch_rx;
484 char *triplet_rx;
485 char *error_message;
486
487 if (!target_has_execution)
488 error (_("The program must be running for the compile command to "\
489 "work."));
490
491 expr_block = get_expr_block_and_pc (&trash_pc);
492 expr_pc = get_frame_address_in_block (get_selected_frame (NULL));
493
494 /* Set up instance and context for the compiler. */
495 if (current_language->la_get_compile_instance == NULL)
496 error (_("No compiler support for language %s."),
497 current_language->la_name);
498 compiler = current_language->la_get_compile_instance ();
499 cleanup = make_cleanup (cleanup_compile_instance, compiler);
500
501 compiler->fe->ops->set_print_callback (compiler->fe, print_callback, NULL);
502
503 compiler->scope = scope;
504 compiler->block = expr_block;
505
506 /* From the provided expression, build a scope to pass to the
507 compiler. */
508 if (cmd != NULL)
509 {
510 struct ui_file *stream = mem_fileopen ();
511 struct command_line *iter;
512 char *stream_buf;
513
514 make_cleanup_ui_file_delete (stream);
515 for (iter = cmd->body_list[0]; iter; iter = iter->next)
516 {
517 fputs_unfiltered (iter->line, stream);
518 fputs_unfiltered ("\n", stream);
519 }
520
521 stream_buf = ui_file_xstrdup (stream, NULL);
522 make_cleanup (xfree, stream_buf);
523 input = stream_buf;
524 }
525 else if (cmd_string != NULL)
526 input = cmd_string;
527 else
528 error (_("Neither a simple expression, or a multi-line specified."));
529
530 code = current_language->la_compute_program (compiler, input, gdbarch,
531 expr_block, expr_pc);
532 make_cleanup (xfree, code);
533 if (compile_debug)
534 fprintf_unfiltered (gdb_stdlog, "debug output:\n\n%s", code);
535
536 os_rx = osabi_triplet_regexp (gdbarch_osabi (gdbarch));
537 arch_rx = gdbarch_gnu_triplet_regexp (gdbarch);
538
539 /* Allow triplets with or without vendor set. */
540 triplet_rx = concat (arch_rx, "(-[^-]*)?-", os_rx, (char *) NULL);
541 make_cleanup (xfree, triplet_rx);
542
543 /* Set compiler command-line arguments. */
544 get_args (compiler, gdbarch, &argc, &argv);
545 make_cleanup_freeargv (argv);
546
547 error_message = compiler->fe->ops->set_arguments (compiler->fe, triplet_rx,
548 argc, argv);
549 if (error_message != NULL)
550 {
551 make_cleanup (xfree, error_message);
552 error ("%s", error_message);
553 }
554
555 if (compile_debug)
556 {
557 int argi;
558
559 fprintf_unfiltered (gdb_stdlog, "Passing %d compiler options:\n", argc);
560 for (argi = 0; argi < argc; argi++)
561 fprintf_unfiltered (gdb_stdlog, "Compiler option %d: <%s>\n",
562 argi, argv[argi]);
563 }
564
565 get_new_file_names (&source_file, &object_file);
566 inner_cleanup = make_cleanup (xfree, source_file);
567 make_cleanup (xfree, object_file);
568
569 src = gdb_fopen_cloexec (source_file, "w");
570 if (src == NULL)
571 perror_with_name (_("Could not open source file for writing"));
572 make_cleanup (cleanup_unlink_file, source_file);
573 if (fputs (code, src) == EOF)
574 perror_with_name (_("Could not write to source file"));
575 fclose (src);
576
577 if (compile_debug)
578 fprintf_unfiltered (gdb_stdlog, "source file produced: %s\n\n",
579 source_file);
580
581 /* Call the compiler and start the compilation process. */
582 compiler->fe->ops->set_source_file (compiler->fe, source_file);
583
584 if (!compiler->fe->ops->compile (compiler->fe, object_file,
585 compile_debug))
586 error (_("Compilation failed."));
587
588 if (compile_debug)
589 fprintf_unfiltered (gdb_stdlog, "object file produced: %s\n\n",
590 object_file);
591
592 discard_cleanups (inner_cleanup);
593 do_cleanups (cleanup);
594 *source_filep = source_file;
595 return object_file;
596 }
597
598 /* The "compile" prefix command. */
599
600 static void
601 compile_command (char *args, int from_tty)
602 {
603 /* If a sub-command is not specified to the compile prefix command,
604 assume it is a direct code compilation. */
605 compile_code_command (args, from_tty);
606 }
607
608 /* See compile.h. */
609
610 void
611 eval_compile_command (struct command_line *cmd, const char *cmd_string,
612 enum compile_i_scope_types scope, void *scope_data)
613 {
614 char *object_file, *source_file;
615
616 object_file = compile_to_object (cmd, cmd_string, scope, &source_file);
617 if (object_file != NULL)
618 {
619 struct cleanup *cleanup_xfree, *cleanup_unlink;
620 struct compile_module *compile_module;
621
622 cleanup_xfree = make_cleanup (xfree, object_file);
623 make_cleanup (xfree, source_file);
624 cleanup_unlink = make_cleanup (cleanup_unlink_file, object_file);
625 make_cleanup (cleanup_unlink_file, source_file);
626 compile_module = compile_object_load (object_file, source_file,
627 scope, scope_data);
628 if (compile_module == NULL)
629 {
630 gdb_assert (scope == COMPILE_I_PRINT_ADDRESS_SCOPE);
631 do_cleanups (cleanup_xfree);
632 eval_compile_command (cmd, cmd_string,
633 COMPILE_I_PRINT_VALUE_SCOPE, scope_data);
634 return;
635 }
636 discard_cleanups (cleanup_unlink);
637 do_cleanups (cleanup_xfree);
638 compile_object_run (compile_module);
639 }
640 }
641
642 /* See compile/compile-internal.h. */
643
644 char *
645 compile_register_name_mangled (struct gdbarch *gdbarch, int regnum)
646 {
647 const char *regname = gdbarch_register_name (gdbarch, regnum);
648
649 return xstrprintf ("__%s", regname);
650 }
651
652 /* See compile/compile-internal.h. */
653
654 int
655 compile_register_name_demangle (struct gdbarch *gdbarch,
656 const char *regname)
657 {
658 int regnum;
659
660 if (regname[0] != '_' || regname[1] != '_')
661 error (_("Invalid register name \"%s\"."), regname);
662 regname += 2;
663
664 for (regnum = 0; regnum < gdbarch_num_regs (gdbarch); regnum++)
665 if (strcmp (regname, gdbarch_register_name (gdbarch, regnum)) == 0)
666 return regnum;
667
668 error (_("Cannot find gdbarch register \"%s\"."), regname);
669 }
670
671 extern initialize_file_ftype _initialize_compile;
672
673 void
674 _initialize_compile (void)
675 {
676 struct cmd_list_element *c = NULL;
677
678 add_prefix_cmd ("compile", class_obscure, compile_command,
679 _("\
680 Command to compile source code and inject it into the inferior."),
681 &compile_command_list, "compile ", 1, &cmdlist);
682 add_com_alias ("expression", "compile", class_obscure, 0);
683
684 add_cmd ("code", class_obscure, compile_code_command,
685 _("\
686 Compile, inject, and execute code.\n\
687 \n\
688 Usage: compile code [-r|-raw] [--] [CODE]\n\
689 -r|-raw: Suppress automatic 'void _gdb_expr () { CODE }' wrapping.\n\
690 --: Do not parse any options beyond this delimiter. All text to the\n\
691 right will be treated as source code.\n\
692 \n\
693 The source code may be specified as a simple one line expression, e.g.:\n\
694 \n\
695 compile code printf(\"Hello world\\n\");\n\
696 \n\
697 Alternatively, you can type a multiline expression by invoking\n\
698 this command with no argument. GDB will then prompt for the\n\
699 expression interactively; type a line containing \"end\" to\n\
700 indicate the end of the expression."),
701 &compile_command_list);
702
703 c = add_cmd ("file", class_obscure, compile_file_command,
704 _("\
705 Evaluate a file containing source code.\n\
706 \n\
707 Usage: compile file [-r|-raw] [filename]\n\
708 -r|-raw: Suppress automatic 'void _gdb_expr () { CODE }' wrapping."),
709 &compile_command_list);
710 set_cmd_completer (c, filename_completer);
711
712 add_cmd ("print", class_obscure, compile_print_command,
713 _("\
714 Evaluate EXPR by using the compiler and print result.\n\
715 \n\
716 Usage: compile print[/FMT] [EXPR]\n\
717 \n\
718 The expression may be specified on the same line as the command, e.g.:\n\
719 \n\
720 compile print i\n\
721 \n\
722 Alternatively, you can type a multiline expression by invoking\n\
723 this command with no argument. GDB will then prompt for the\n\
724 expression interactively; type a line containing \"end\" to\n\
725 indicate the end of the expression.\n\
726 \n\
727 EXPR may be preceded with /FMT, where FMT is a format letter\n\
728 but no count or size letter (see \"x\" command)."),
729 &compile_command_list);
730
731 add_setshow_boolean_cmd ("compile", class_maintenance, &compile_debug, _("\
732 Set compile command debugging."), _("\
733 Show compile command debugging."), _("\
734 When on, compile command debugging is enabled."),
735 NULL, show_compile_debug,
736 &setdebuglist, &showdebuglist);
737
738 add_setshow_string_cmd ("compile-args", class_support,
739 &compile_args,
740 _("Set compile command GCC command-line arguments"),
741 _("Show compile command GCC command-line arguments"),
742 _("\
743 Use options like -I (include file directory) or ABI settings.\n\
744 String quoting is parsed like in shell, for example:\n\
745 -mno-align-double \"-I/dir with a space/include\""),
746 set_compile_args, show_compile_args, &setlist, &showlist);
747
748 /* Override flags possibly coming from DW_AT_producer. */
749 compile_args = xstrdup ("-O0 -gdwarf-4"
750 /* We use -fPIE Otherwise GDB would need to reserve space large enough for
751 any object file in the inferior in advance to get the final address when
752 to link the object file to and additionally the default system linker
753 script would need to be modified so that one can specify there the
754 absolute target address.
755 -fPIC is not used at is would require from GDB to generate .got. */
756 " -fPIE"
757 /* We want warnings, except for some commonly happening for GDB commands. */
758 " -Wall "
759 " -Wno-implicit-function-declaration"
760 " -Wno-unused-but-set-variable"
761 " -Wno-unused-variable"
762 /* Override CU's possible -fstack-protector-strong. */
763 " -fno-stack-protector"
764 );
765 set_compile_args (compile_args, 0, NULL);
766 }
767