diff mbox

[v4,1/2] compile: set debug compile: Display GCC driver filename

Message ID 20150524185752.31862.62312.stgit@host1.jankratochvil.net
State New
Headers show

Commit Message

Jan Kratochvil May 24, 2015, 6:57 p.m. UTC
Hi,

as discussed in
	How to use compile & execute function in GDB
	https://sourceware.org/ml/gdb/2015-04/msg00026.html

GDB currently searches for /usr/bin/ARCH-OS-gcc and chooses one but it does not
display which one.  It cannot, GCC method set_arguments() does not yet know
whether 'set debug compile' is enabled or not.


Jan


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

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

include/ChangeLog
2015-05-24  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/compile/compile.c   |   11 +++++++++--
 include/gcc-interface.h |   36 ++++++++++++++++++++++++++++--------
 2 files changed, 37 insertions(+), 10 deletions(-)

Comments

Pedro Alves May 29, 2015, 11:02 a.m. UTC | #1
On 05/24/2015 07:57 PM, Jan Kratochvil wrote:
> Hi,
> 
> as discussed in
> 	How to use compile & execute function in GDB
> 	https://sourceware.org/ml/gdb/2015-04/msg00026.html
> 
> GDB currently searches for /usr/bin/ARCH-OS-gcc and chooses one but it does not
> display which one.  It cannot, GCC method set_arguments() does not yet know
> whether 'set debug compile' is enabled or not.
> 
> 

OK.

Thanks,
Pedro Alves
diff mbox

Patch

diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 499c530..7980153 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -541,6 +541,9 @@  compile_to_object (struct command_line *cmd, const char *cmd_string,
   get_args (compiler, gdbarch, &argc, &argv);
   make_cleanup_freeargv (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)
@@ -578,8 +581,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, source_file);
 
-  if (!compiler->fe->ops->compile (compiler->fe, object_file,
-				   compile_debug))
+  if (compiler->fe->ops->version >= GCC_FE_VERSION_1)
+    ok = compiler->fe->ops->compile (compiler->fe, object_file);
+  else
+    ok = compiler->fe->ops->compile_v0 (compiler->fe, object_file,
+					compile_debug);
+  if (!ok)
     error (_("Compilation failed."));
 
   if (compile_debug)
diff --git a/include/gcc-interface.h b/include/gcc-interface.h
index df7db6e..90be018 100644
--- a/include/gcc-interface.h
+++ b/include/gcc-interface.h
@@ -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.  */