compile: set debug compile: Display GCC driver filename
authorJan Kratochvil <jan.kratochvil@redhat.com>
Tue, 21 Feb 2017 21:32:55 +0000 (13:32 -0800)
committerSergio Durigan Junior <sergiodj@redhat.com>
Wed, 23 Aug 2017 15:15:03 +0000 (11:15 -0400)
As discussed in
How to use compile & execute function in GDB
https://sourceware.org/ml/gdb/2015-04/msg00026.html

GDB currently searches for compilers on /usr/bin/ARCH-OS-gcc and
chooses a match from there.  However, it is not currently possible for
the user to display which compiler was selected.  Up until now, GDB's
compiler interface was not up-to-date with GCC's one, which means that
it wasn't possible to obtain this information.  This patch implements
the mechanisms necessary for that.

gdb/ChangeLog
2017-08-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

* compile/compile.c (compile_to_object): Conditionally call
set_verbose.  Conditionally call compile or compile_v0.

include/ChangeLog
2017-08-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gcc-interface.h (enum gcc_base_api_version): Add
GCC_FE_VERSION_1.
(struct gcc_base_vtable): Rename compile to compile_v0.  Update
comment for compile.  New methods set_verbose and compile.

gdb/ChangeLog
gdb/compile/compile.c
include/ChangeLog
include/gcc-interface.h

index 77a19c2ff07ee68bcea46ac4bfc76a58e63c5c39..d7466d05780ff34229be8ac7e8a4024f505e7335 100644 (file)
@@ -1,3 +1,8 @@
+2017-08-23  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * compile/compile.c (compile_to_object): Conditionally call
+       set_verbose.  Conditionally call compile or compile_v0.
+
 2017-08-07  Weimin Pan  <weimin.pan@oracle.com>
 
        * sparc64-tdep.h: (adi_normalize_address): New export.
index 91e084f89f5fa3e32a6e4c588645e30ec2813e5d..36baab3ede0b7320ab1b87d5a6587228fe8e3dbb 100644 (file)
@@ -516,6 +516,9 @@ compile_to_object (struct command_line *cmd, const char *cmd_string,
   get_args (compiler, gdbarch, &argc, &argv);
   gdb_argv argv_holder (argv);
 
+  if (compiler->fe->ops->version >= GCC_FE_VERSION_1)
+    compiler->fe->ops->set_verbose (compiler->fe, compile_debug);
+
   error_message = compiler->fe->ops->set_arguments (compiler->fe, triplet_rx,
                                                    argc, argv);
   if (error_message != NULL)
@@ -556,8 +559,12 @@ compile_to_object (struct command_line *cmd, const char *cmd_string,
   /* Call the compiler and start the compilation process.  */
   compiler->fe->ops->set_source_file (compiler->fe, fnames.source_file ());
 
-  if (!compiler->fe->ops->compile (compiler->fe, fnames.object_file (),
-                                  compile_debug))
+  if (compiler->fe->ops->version >= GCC_FE_VERSION_1)
+    ok = compiler->fe->ops->compile (compiler->fe, fnames.object_file ());
+  else
+    ok = compiler->fe->ops->compile_v0 (compiler->fe, fnames.object_file (),
+                                       compile_debug);
+  if (!ok)
     error (_("Compilation failed."));
 
   if (compile_debug)
index db500dce937dd19db11772edc475ee5cc99606f1..02ee554b90686cdc2e2431da1958ccac98cceea5 100644 (file)
@@ -1,3 +1,10 @@
+2017-08-23  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * gcc-interface.h (enum gcc_base_api_version): Add
+       GCC_FE_VERSION_1.
+       (struct gcc_base_vtable): Rename compile to compile_v0.  Update
+       comment for compile.  New methods set_verbose and compile.
+
 2017-08-21  Alexander Fedotov <alexander.fedotov@nxp.com>
            Edmar Wienskoski <edmar.wienskoski@nxp.com>
 
index d4c4ec699788b2bd9f29ffea60bb96c4fad65b78..c98f078454533c0b5b180b7bfbfe6525db9bd64f 100644 (file)
@@ -44,7 +44,10 @@ struct gcc_base_context;
 
 enum gcc_base_api_version
 {
-  GCC_FE_VERSION_0 = 0
+  GCC_FE_VERSION_0 = 0,
+
+  /* Deprecated method compile_v0.  Added method set_verbose and compile.  */
+  GCC_FE_VERSION_1 = 1,
 };
 
 /* The operations defined by the GCC base API.  This is the vtable for
@@ -93,18 +96,35 @@ struct gcc_base_vtable
                                                      const char *message),
                              void *datum);
 
-  /* Perform the compilation.  FILENAME is the name of the resulting
-     object file.  VERBOSE can be set to cause GCC to print some
-     information as it works.  Returns true on success, false on
-     error.  */
+  /* Deprecated GCC_FE_VERSION_0 variant of the GCC_FE_VERSION_1
+     compile method.  GCC_FE_VERSION_0 version verbose parameter has
+     been replaced by the set_verbose method.  */
 
-  int /* bool */ (*compile) (struct gcc_base_context *self,
-                            const char *filename,
-                            int /* bool */ verbose);
+  int /* bool */ (*compile_v0) (struct gcc_base_context *self,
+                               const char *filename,
+                               int /* bool */ verbose);
 
   /* Destroy this object.  */
 
   void (*destroy) (struct gcc_base_context *self);
+
+  /* VERBOSE can be set to non-zero to cause GCC to print some
+     information as it works.  Calling this method overrides its
+     possible previous calls.
+
+     This method is only available since GCC_FE_VERSION_1.  */
+
+  void (*set_verbose) (struct gcc_base_context *self,
+                      int /* bool */ verbose);
+
+  /* Perform the compilation.  FILENAME is the name of the resulting
+     object file.  Either set_triplet_regexp or set_driver_filename must
+     be called before.  Returns true on success, false on error.
+
+     This method is only available since GCC_FE_VERSION_1.  */
+
+  int /* bool */ (*compile) (struct gcc_base_context *self,
+                            const char *filename);
 };
 
 /* The GCC object.  */
This page took 0.029911 seconds and 4 git commands to generate.