Re: [PATCH v2 2/4] libcc1: set debug compile: Display GCC driver filename

2015-04-23 Thread Jeff Law

On 04/23/2015 02:38 PM, Jan Kratochvil wrote:

Hi,

already approved, reposting just to keep it a part of the series:
https://gcc.gnu.org/ml/gcc-patches/2015-04/msg01301.html

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.

Unfortunately this changes libcc1 API in an incompatible way.  There is
a possibility of a hack to keep the API the same - one could pass "-v" option
explicitly to set_arguments(), set_arguments() could compare the "-v" string
and print the GCC filename accordingly.  Then the 'verbose' parameter of
compile() would lose its meaning.  What do you think?

GDB counterpart:
[PATCH v2 1/2] compile: set debug compile: Display GCC driver filename
https://sourceware.org/ml/gdb-patches/2015-04/msg00909.html
Message-ID: <20150423203402.23140.92757.st...@host1.jankratochvil.net>


Jan


include/ChangeLog
2015-04-23  Jan Kratochvil  

* gcc-interface.h (enum gcc_base_api_version): Add comment to
GCC_FE_VERSION_1.
(struct gcc_base_vtable): Rename set_arguments to set_arguments_v0.
Update comment for compile.  New method set_arguments.

libcc1/ChangeLog
2015-04-23  Jan Kratochvil  

* libcc1.cc: Include intl.h.
(struct libcc1): Add field verbose.
(libcc1::libcc1): Initialize it.
(libcc1_set_arguments): Add parameter verbose, implement it.
(libcc1_set_arguments_v0): New function.
(libcc1_compile): Set parameter verbose to SELF.
(vtable): Use libcc1_set_arguments_v0 and add libcc1_set_arguments.

OK.
jeff



Re: [PATCH v2 2/4] libcc1: set debug compile: Display GCC driver filename

2015-04-23 Thread Jan Kratochvil
On Thu, 23 Apr 2015 22:38:34 +0200, Jan Kratochvil wrote:
> Unfortunately this changes libcc1 API in an incompatible way.  There is
> a possibility of a hack to keep the API the same - one could pass "-v" option
> explicitly to set_arguments(), set_arguments() could compare the "-v" string
> and print the GCC filename accordingly.  Then the 'verbose' parameter of
> compile() would lose its meaning.  What do you think?

This paragraph is no longer true, 'compile' keeps its parameter duplicate to
the new 'set_arguments's one.


Jan


[PATCH v2 2/4] libcc1: set debug compile: Display GCC driver filename

2015-04-23 Thread Jan Kratochvil
Hi,

already approved, reposting just to keep it a part of the series:
https://gcc.gnu.org/ml/gcc-patches/2015-04/msg01301.html

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.

Unfortunately this changes libcc1 API in an incompatible way.  There is
a possibility of a hack to keep the API the same - one could pass "-v" option
explicitly to set_arguments(), set_arguments() could compare the "-v" string
and print the GCC filename accordingly.  Then the 'verbose' parameter of
compile() would lose its meaning.  What do you think?

GDB counterpart:
[PATCH v2 1/2] compile: set debug compile: Display GCC driver filename
https://sourceware.org/ml/gdb-patches/2015-04/msg00909.html
Message-ID: <20150423203402.23140.92757.st...@host1.jankratochvil.net>


Jan


include/ChangeLog
2015-04-23  Jan Kratochvil  

* gcc-interface.h (enum gcc_base_api_version): Add comment to
GCC_FE_VERSION_1.
(struct gcc_base_vtable): Rename set_arguments to set_arguments_v0.
Update comment for compile.  New method set_arguments.

libcc1/ChangeLog
2015-04-23  Jan Kratochvil  

* libcc1.cc: Include intl.h.
(struct libcc1): Add field verbose.
(libcc1::libcc1): Initialize it.
(libcc1_set_arguments): Add parameter verbose, implement it.
(libcc1_set_arguments_v0): New function.
(libcc1_compile): Set parameter verbose to SELF.
(vtable): Use libcc1_set_arguments_v0 and add libcc1_set_arguments.
---
 include/gcc-interface.h |   45 +
 libcc1/libcc1.cc|   34 +-
 2 files changed, 58 insertions(+), 21 deletions(-)

diff --git a/include/gcc-interface.h b/include/gcc-interface.h
index dcfa6ce..21cc403 100644
--- a/include/gcc-interface.h
+++ b/include/gcc-interface.h
@@ -45,6 +45,8 @@ struct gcc_base_context;
 enum gcc_base_api_version
 {
   GCC_FE_VERSION_0 = 0,
+
+  /* Parameter verbose has been moved from compile to set_arguments.  */
   GCC_FE_VERSION_1 = 1,
 };
 
@@ -65,20 +67,13 @@ struct gcc_base_vtable
 
   unsigned int version;
 
-  /* Set the compiler's command-line options for the next compilation.
- TRIPLET_REGEXP is a regular expression that is used to match the
- configury triplet prefix to the compiler.
- The arguments are copied by GCC.  ARGV need not be
- NULL-terminated.  The arguments must be set separately for each
- compilation; that is, after a compile is requested, the
- previously-set arguments cannot be reused.
-
- This returns NULL on success.  On failure, returns a malloc()d
- error message.  The caller is responsible for freeing it.  */
+  /* Deprecated GCC_FE_VERSION_0 variant of the GCC_FE_VERSION_1
+ set_arguments method.  GCC_FE_VERSION_0 version did not have the
+ verbose parameter.  */
 
-  char *(*set_arguments) (struct gcc_base_context *self,
- const char *triplet_regexp,
- int argc, char **argv);
+  char *(*set_arguments_v0) (struct gcc_base_context *self,
+const char *triplet_regexp,
+int argc, char **argv);
 
   /* Set the file name of the program to compile.  The string is
  copied by the method implementation, but the caller must
@@ -95,9 +90,9 @@ struct gcc_base_vtable
  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.  */
+ object file.  VERBOSE should be the same value as passed
+ to gcc_base_vtable::set_arguments.  Returns true on success, false
+ on error.  */
 
   int /* bool */ (*compile) (struct gcc_base_context *self,
 const char *filename,
@@ -106,6 +101,24 @@ struct gcc_base_vtable
   /* Destroy this object.  */
 
   void (*destroy) (struct gcc_base_context *self);
+
+  /* Set the compiler's command-line options for the next compilation.
+ TRIPLET_REGEXP is a regular expression that is used to match the
+ configury triplet prefix to the compiler.
+ The arguments are copied by GCC.  ARGV need not be
+ NULL-terminated.  The arguments must be set separately for each
+ compilation; that is, after a compile is requested, the
+ previously-set arguments cannot be reused.  VERBOSE can be set
+ to cause GCC to print some information as it works.  
+
+ This returns NULL on success.  On failure, returns a malloc()d
+ error message.  The caller is responsible for freeing it.
+ 
+ This method is only av