• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修订版d246674d8cd0262e7587925b06040a8347d4ed55 (tree)
时间2017-02-22 06:32:56
作者Keith Seitz <keiths@redh...>
CommiterKeith Seitz

Log Message

compile: Add 'set compile-gcc'

gdb/ChangeLog
2015-05-24 Jan Kratochvil <jan.kratochvil@redhat.com>

    • NEWS (Changes since GDB 7.9): Add set compile-gcc and show
      compile-gcc.
    • compile/compile.c (compile_gcc, show_compile_gcc): New.
      (compile_to_object): Implement compile_gcc.
      (_initialize_compile): Install "set compile-gcc". Initialize
      compile_gcc.

gdb/doc/ChangeLog
2015-05-24 Jan Kratochvil <jan.kratochvil@redhat.com>

    • gdb.texinfo (Compiling and Injecting Code): Add to subsection
      "Compiler search for the compile command" descriptions of set
      compile-gcc and show compile-gcc.

include/ChangeLog
2015-05-24 Jan Kratochvil <jan.kratochvil@redhat.com>

    • gcc-interface.h (enum gcc_base_api_version): Update comment for
      GCC_FE_VERSION_1.
      (struct gcc_base_vtable): Rename set_arguments to set_arguments_v0.
      Add set_arguments, set_triplet_regexp and set_driver_filename.

更改概述

差异

--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -1,3 +1,7 @@
1+set|show compile-gcc
2+ Set and show compilation command used for compiling and injecting code
3+ with the 'compile' commands.
4+
15 What has changed in GDB?
26 (Organized release by release)
37
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -340,6 +340,19 @@ append_args (int *argcp, char ***argvp, int argc, char **argv)
340340 (*argvp)[(*argcp)] = NULL;
341341 }
342342
343+/* String for 'set compile-gcc' and 'show compile-gcc'. */
344+static char *compile_gcc;
345+
346+/* Implement 'show compile-gcc'. */
347+
348+static void
349+show_compile_gcc (struct ui_file *file, int from_tty,
350+ struct cmd_list_element *c, const char *value)
351+{
352+ fprintf_filtered (file, _("Compile command GCC driver filename is \"%s\".\n"),
353+ value);
354+}
355+
343356 /* Return DW_AT_producer parsed for get_selected_frame () (if any).
344357 Return NULL otherwise.
345358
@@ -467,8 +480,6 @@ compile_to_object (struct command_line *cmd, const char *cmd_string,
467480 int ok;
468481 FILE *src;
469482 struct gdbarch *gdbarch = get_current_arch ();
470- const char *os_rx;
471- const char *arch_rx;
472483 char *triplet_rx;
473484 char *error_message;
474485
@@ -520,22 +531,39 @@ compile_to_object (struct command_line *cmd, const char *cmd_string,
520531 if (compile_debug)
521532 fprintf_unfiltered (gdb_stdlog, "debug output:\n\n%s", code.c_str ());
522533
523- os_rx = osabi_triplet_regexp (gdbarch_osabi (gdbarch));
524- arch_rx = gdbarch_gnu_triplet_regexp (gdbarch);
534+ if (compiler->fe->ops->version >= GCC_FE_VERSION_1)
535+ compiler->fe->ops->set_verbose (compiler->fe, compile_debug);
525536
526- /* Allow triplets with or without vendor set. */
527- triplet_rx = concat (arch_rx, "(-[^-]*)?-", os_rx, (char *) NULL);
528- make_cleanup (xfree, triplet_rx);
537+ if (compile_gcc[0] != 0)
538+ {
539+ if (compiler->fe->ops->version < GCC_FE_VERSION_1)
540+ error (_("Command 'set compile-gcc' requires GCC version 6 or higher "
541+ "(libcc1 interface version 1 or higher)"));
542+
543+ compiler->fe->ops->set_driver_filename (compiler->fe, compile_gcc);
544+ }
545+ else
546+ {
547+ const char *os_rx = osabi_triplet_regexp (gdbarch_osabi (gdbarch));
548+ const char *arch_rx = gdbarch_gnu_triplet_regexp (gdbarch);
549+
550+ /* Allow triplets with or without vendor set. */
551+ triplet_rx = concat (arch_rx, "(-[^-]*)?-", os_rx, (char *) NULL);
552+ make_cleanup (xfree, triplet_rx);
553+
554+ if (compiler->fe->ops->version >= GCC_FE_VERSION_1)
555+ compiler->fe->ops->set_triplet_regexp (compiler->fe, triplet_rx);
556+ }
529557
530558 /* Set compiler command-line arguments. */
531559 get_args (compiler, gdbarch, &argc, &argv);
532560 make_cleanup_freeargv (argv);
533561
534562 if (compiler->fe->ops->version >= GCC_FE_VERSION_1)
535- compiler->fe->ops->set_verbose (compiler->fe, compile_debug);
536-
537- error_message = compiler->fe->ops->set_arguments (compiler->fe, triplet_rx,
538- argc, argv);
563+ error_message = compiler->fe->ops->set_arguments (compiler->fe, argc, argv);
564+ else
565+ error_message = compiler->fe->ops->set_arguments_v0 (compiler->fe, triplet_rx,
566+ argc, argv);
539567 if (error_message != NULL)
540568 {
541569 make_cleanup (xfree, error_message);
@@ -748,4 +776,17 @@ String quoting is parsed like in shell, for example:\n\
748776 " -fno-stack-protector"
749777 );
750778 set_compile_args (compile_args, 0, NULL);
779+
780+ add_setshow_optional_filename_cmd ("compile-gcc", class_support,
781+ &compile_gcc,
782+ _("Set compile command "
783+ "GCC driver filename"),
784+ _("Show compile command "
785+ "GCC driver filename"),
786+ _("\
787+It should be absolute filename of the gcc executable.\n\
788+If empty the default target triplet will be searched in $PATH."),
789+ NULL, show_compile_gcc, &setlist,
790+ &showlist);
791+ compile_gcc = xstrdup ("");
751792 }
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -18132,13 +18132,15 @@ will print to the console.
1813218132
1813318133 @subsection Compiler search for the @code{compile} command
1813418134
18135-@value{GDBN} needs to find @value{NGCC} for the inferior being debugged which
18136-may not be obvious for remote targets of different architecture than where
18137-@value{GDBN} is running. Environment variable @code{PATH} (@code{PATH} from
18138-shell that executed @value{GDBN}, not the one set by @value{GDBN}
18139-command @code{set environment}). @xref{Environment}. @code{PATH} on
18135+@value{GDBN} needs to find @value{NGCC} for the inferior being debugged
18136+which may not be obvious for remote targets of different architecture
18137+than where @value{GDBN} is running. Environment variable @code{PATH} on
1814018138 @value{GDBN} host is searched for @value{NGCC} binary matching the
18141-target architecture and operating system.
18139+target architecture and operating system. This search can be overriden
18140+by @code{set compile-gcc} @value{GDBN} command below. @code{PATH} is
18141+taken from shell that executed @value{GDBN}, it is not the value set by
18142+@value{GDBN} command @code{set environment}). @xref{Environment}.
18143+
1814218144
1814318145 Specifically @code{PATH} is searched for binaries matching regular expression
1814418146 @code{@var{arch}(-[^-]*)?-@var{os}-gcc} according to the inferior target being
@@ -18148,6 +18150,28 @@ example both @code{i386} and @code{x86_64} targets look for pattern
1814818150 for pattern @code{s390x?}. @var{os} is currently supported only for
1814918151 pattern @code{linux(-gnu)?}.
1815018152
18153+On Posix hosts the compiler driver @value{GDBN} needs to find also
18154+shared library @file{libcc1.so} from the compiler. It is searched in
18155+default shared library search path (overridable with usual environment
18156+variable @code{LD_LIBRARY_PATH}), unrelated to @code{PATH} or @code{set
18157+compile-gcc} settings. Contrary to it @file{libcc1plugin.so} is found
18158+according to the installation of the found compiler --- as possibly
18159+specified by the @code{set compile-gcc} command.
18160+
18161+@table @code
18162+@item set compile-gcc
18163+@cindex compile command driver filename override
18164+Set compilation command used for compiling and injecting code with the
18165+@code{compile} commands. If this option is not set (it is set to
18166+an empty string), the search described above will occur --- that is the
18167+default.
18168+
18169+@item show compile-gcc
18170+Displays the current compile command @value{NGCC} driver filename.
18171+If set, it is the main command @command{gcc}, found usually for example
18172+under name @file{x86_64-linux-gnu-gcc}.
18173+@end table
18174+
1815118175 @node GDB Files
1815218176 @chapter @value{GDBN} Files
1815318177
--- a/include/gcc-interface.h
+++ b/include/gcc-interface.h
@@ -46,7 +46,9 @@ enum gcc_base_api_version
4646 {
4747 GCC_FE_VERSION_0 = 0,
4848
49- /* Deprecated method compile_v0. Added method set_verbose and compile. */
49+ /* Deprecated methods set_arguments_v0 and compile_v0. Added methods
50+ set_arguments, set_triplet_regexp, set_driver_filename, set_verbose and
51+ compile. */
5052 GCC_FE_VERSION_1 = 1,
5153 };
5254
@@ -67,20 +69,12 @@ struct gcc_base_vtable
6769
6870 unsigned int version;
6971
70- /* Set the compiler's command-line options for the next compilation.
71- TRIPLET_REGEXP is a regular expression that is used to match the
72- configury triplet prefix to the compiler.
73- The arguments are copied by GCC. ARGV need not be
74- NULL-terminated. The arguments must be set separately for each
75- compilation; that is, after a compile is requested, the
76- previously-set arguments cannot be reused.
77-
78- This returns NULL on success. On failure, returns a malloc()d
79- error message. The caller is responsible for freeing it. */
72+ /* Deprecated GCC_FE_VERSION_0 variant of the GCC_FE_VERSION_1
73+ methods set_triplet_regexp and set_arguments. */
8074
81- char *(*set_arguments) (struct gcc_base_context *self,
82- const char *triplet_regexp,
83- int argc, char **argv);
75+ char *(*set_arguments_v0) (struct gcc_base_context *self,
76+ const char *triplet_regexp,
77+ int argc, char **argv);
8478
8579 /* Set the file name of the program to compile. The string is
8680 copied by the method implementation, but the caller must
@@ -125,6 +119,45 @@ struct gcc_base_vtable
125119
126120 int /* bool */ (*compile) (struct gcc_base_context *self,
127121 const char *filename);
122+
123+ /* Set the compiler's command-line options for the next compilation.
124+ The arguments are copied by GCC. ARGV need not be
125+ NULL-terminated. The arguments must be set separately for each
126+ compilation; that is, after a compile is requested, the
127+ previously-set arguments cannot be reused.
128+
129+ This returns NULL on success. On failure, returns a malloc()d
130+ error message. The caller is responsible for freeing it.
131+
132+ This method is only available since GCC_FE_VERSION_1. */
133+
134+ char *(*set_arguments) (struct gcc_base_context *self,
135+ int argc, char **argv);
136+
137+ /* Set TRIPLET_REGEXP as a regular expression that is used to match
138+ the configury triplet prefix to the compiler. Calling this method
139+ overrides possible previous call of itself or set_driver_filename.
140+
141+ This returns NULL on success. On failure, returns a malloc()d
142+ error message. The caller is responsible for freeing it.
143+
144+ This method is only available since GCC_FE_VERSION_1. */
145+
146+ char *(*set_triplet_regexp) (struct gcc_base_context *self,
147+ const char *triplet_regexp);
148+
149+ /* DRIVER_FILENAME should be filename of the gcc compiler driver
150+ program. It will be searched in PATH components like
151+ TRIPLET_REGEXP. Calling this method overrides possible previous
152+ call of itself or set_triplet_regexp.
153+
154+ This returns NULL on success. On failure, returns a malloc()d
155+ error message. The caller is responsible for freeing it.
156+
157+ This method is only available since GCC_FE_VERSION_1. */
158+
159+ char *(*set_driver_filename) (struct gcc_base_context *self,
160+ const char *driver_filename);
128161 };
129162
130163 /* The GCC object. */