public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] "info source" now includes producer string
@ 2015-01-05 20:41 Doug Evans
  2015-01-05 20:50 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Doug Evans @ 2015-01-05 20:41 UTC (permalink / raw)
  To: gdb-patches, eliz

Hi.

This is something I've wanted for awhile.

bash$ g++ -g -Og hello.cc -o hello
bash$ gdb hello
(gdb) start
(gdb) info source
Current source file is hello.cc
Compilation directory is /home/dje
Located in /home/dje/hello.cc
Contains 8 lines.
Source language is c++.
Producer is GNU C++ 4.8.2 -mtune=generic -march=x86-64 -g -Og -fstack-protector.
Compiled with DWARF 2 debugging format.
Does not include preprocessor macro info.
(gdb) 

Regression tested on amd64-linux.

2015-01-05  Doug Evans  <dje@google.com>

	* NEWS: "info source" command now display producer string if present.
	* source.c (source_info): Print producer string if present.

	doc/
	* gdb.texinfo (Symbols) <info source>: Output now contains producer
	string if present.

diff --git a/gdb/NEWS b/gdb/NEWS
index 9a668c4..ebcc0e3 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -113,6 +113,9 @@ VAX running Ultrix 			vax-*-ultrix*
   and "assf"), have been removed.  Use the "sharedlibrary" command, or
   its alias "share", instead.
 
+* The "info source" command now displays the producer string if it was
+  present in the debug info.
+
 *** Changes in GDB 7.8
 
 * New command line options
diff --git a/gdb/source.c b/gdb/source.c
index 574d9fa..49c9d83 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -654,12 +654,15 @@ static void
 source_info (char *ignore, int from_tty)
 {
   struct symtab *s = current_source_symtab;
+  struct compunit_symtab *cust;
 
   if (!s)
     {
       printf_filtered (_("No current source file.\n"));
       return;
     }
+
+  cust = SYMTAB_COMPUNIT (s);
   printf_filtered (_("Current source file is %s\n"), s->filename);
   if (SYMTAB_DIRNAME (s) != NULL)
     printf_filtered (_("Compilation directory is %s\n"), SYMTAB_DIRNAME (s));
@@ -670,10 +673,13 @@ source_info (char *ignore, int from_tty)
 		     s->nlines == 1 ? "" : "s");
 
   printf_filtered (_("Source language is %s.\n"), language_str (s->language));
+  printf_filtered (_("Producer is %s.\n"),
+		   COMPUNIT_PRODUCER (cust) != NULL
+		   ? COMPUNIT_PRODUCER (cust) : _("unknown"));
   printf_filtered (_("Compiled with %s debugging format.\n"),
-		   COMPUNIT_DEBUGFORMAT (SYMTAB_COMPUNIT (s)));
+		   COMPUNIT_DEBUGFORMAT (cust));
   printf_filtered (_("%s preprocessor macro info.\n"),
-		   COMPUNIT_MACRO_TABLE (SYMTAB_COMPUNIT (s)) != NULL
+		   COMPUNIT_MACRO_TABLE (cust) != NULL
 		   ? "Includes" : "Does not include");
 }
 \f
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index f4d7132..b22f644 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -16279,6 +16279,8 @@ its length, in lines,
 @item
 which programming language it is written in,
 @item
+if the debug information provides it, the program that compiled the file,
+@item
 whether the executable includes debugging information for that file, and
 if so, what format the information is in (e.g., STABS, Dwarf 2, etc.), and
 @item

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] "info source" now includes producer string
  2015-01-05 20:41 [PATCH] "info source" now includes producer string Doug Evans
@ 2015-01-05 20:50 ` Eli Zaretskii
  2015-01-06  0:28   ` Doug Evans
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2015-01-05 20:50 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

> From: Doug Evans <dje@google.com>
> Date: Mon, 05 Jan 2015 12:41:52 -0800
> 
> bash$ g++ -g -Og hello.cc -o hello
> bash$ gdb hello
> (gdb) start
> (gdb) info source
> Current source file is hello.cc
> Compilation directory is /home/dje
> Located in /home/dje/hello.cc
> Contains 8 lines.
> Source language is c++.
> Producer is GNU C++ 4.8.2 -mtune=generic -march=x86-64 -g -Og -fstack-protector.
> Compiled with DWARF 2 debugging format.
> Does not include preprocessor macro info.

Thanks.

> 	* NEWS: "info source" command now display producer string if present.
                                          ^^^^^^^
"displays"

> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -113,6 +113,9 @@ VAX running Ultrix 			vax-*-ultrix*
>    and "assf"), have been removed.  Use the "sharedlibrary" command, or
>    its alias "share", instead.
>  
> +* The "info source" command now displays the producer string if it was
> +  present in the debug info.

I wonder whether we should replace "producer" with something less
abstract.  Would "compilation command line" be accurate enough?

> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -16279,6 +16279,8 @@ its length, in lines,
>  @item
>  which programming language it is written in,
>  @item
> +if the debug information provides it, the program that compiled the file,

Not just the program, but also its command line, right?

Okay with those fixed.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] "info source" now includes producer string
  2015-01-05 20:50 ` Eli Zaretskii
@ 2015-01-06  0:28   ` Doug Evans
  2015-01-06  3:31     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Doug Evans @ 2015-01-06  0:28 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Mon, Jan 5, 2015 at 12:50 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Doug Evans <dje@google.com>
>> Date: Mon, 05 Jan 2015 12:41:52 -0800
>>
>> bash$ g++ -g -Og hello.cc -o hello
>> bash$ gdb hello
>> (gdb) start
>> (gdb) info source
>> Current source file is hello.cc
>> Compilation directory is /home/dje
>> Located in /home/dje/hello.cc
>> Contains 8 lines.
>> Source language is c++.
>> Producer is GNU C++ 4.8.2 -mtune=generic -march=x86-64 -g -Og -fstack-protector.
>> Compiled with DWARF 2 debugging format.
>> Does not include preprocessor macro info.
>
> Thanks.
>
>>       * NEWS: "info source" command now display producer string if present.
>                                           ^^^^^^^
> "displays"
>
>> --- a/gdb/NEWS
>> +++ b/gdb/NEWS
>> @@ -113,6 +113,9 @@ VAX running Ultrix                        vax-*-ultrix*
>>    and "assf"), have been removed.  Use the "sharedlibrary" command, or
>>    its alias "share", instead.
>>
>> +* The "info source" command now displays the producer string if it was
>> +  present in the debug info.
>
> I wonder whether we should replace "producer" with something less
> abstract.  Would "compilation command line" be accurate enough?

The producer string can be anything, it's whatever the compiler
decides, so I'm really hesitant to be specific here (and "command
line" is too specific for me), because often it will be wrong.

I don't mind introducing users to the term "producer".
It's the term we use, and it's not gdb or even gnu-specific.

>
>> --- a/gdb/doc/gdb.texinfo
>> +++ b/gdb/doc/gdb.texinfo
>> @@ -16279,6 +16279,8 @@ its length, in lines,
>>  @item
>>  which programming language it is written in,
>>  @item
>> +if the debug information provides it, the program that compiled the file,
>
> Not just the program, but also its command line, right?

Again, I don't want to provide too much detail here.
What the compiler decides to put in its producer string is up to the compiler.

>
> Okay with those fixed.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] "info source" now includes producer string
  2015-01-06  0:28   ` Doug Evans
@ 2015-01-06  3:31     ` Eli Zaretskii
  2015-01-31 22:29       ` Doug Evans
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2015-01-06  3:31 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

> Date: Mon, 5 Jan 2015 16:28:20 -0800
> From: Doug Evans <dje@google.com>
> Cc: gdb-patches <gdb-patches@sourceware.org>
> 
> >> +* The "info source" command now displays the producer string if it was
> >> +  present in the debug info.
> >
> > I wonder whether we should replace "producer" with something less
> > abstract.  Would "compilation command line" be accurate enough?
> 
> The producer string can be anything, it's whatever the compiler
> decides, so I'm really hesitant to be specific here (and "command
> line" is too specific for me), because often it will be wrong.

We can always say "e.g." or "such as".  That would at least describe
the most frequent use cases.  We don't have to be 110% accurate here,
just clear enough to convey the intent.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] "info source" now includes producer string
  2015-01-06  3:31     ` Eli Zaretskii
@ 2015-01-31 22:29       ` Doug Evans
  0 siblings, 0 replies; 5+ messages in thread
From: Doug Evans @ 2015-01-31 22:29 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

Eli Zaretskii writes:
 > > Date: Mon, 5 Jan 2015 16:28:20 -0800
 > > From: Doug Evans <dje@google.com>
 > > Cc: gdb-patches <gdb-patches@sourceware.org>
 > > 
 > > >> +* The "info source" command now displays the producer string if it was
 > > >> +  present in the debug info.
 > > >
 > > > I wonder whether we should replace "producer" with something less
 > > > abstract.  Would "compilation command line" be accurate enough?
 > > 
 > > The producer string can be anything, it's whatever the compiler
 > > decides, so I'm really hesitant to be specific here (and "command
 > > line" is too specific for me), because often it will be wrong.
 > 
 > We can always say "e.g." or "such as".  That would at least describe
 > the most frequent use cases.  We don't have to be 110% accurate here,
 > just clear enough to convey the intent.

Here is what I committed.

2015-01-30  Doug Evans  <dje@google.com>

	* NEWS: "info source" command now display producer string if present.
	* source.c (source_info): Print producer string if present.

	doc/
	* gdb.texinfo (Symbols) <info source>: Output now contains producer
	string if present.

diff --git a/gdb/NEWS b/gdb/NEWS
index bd85967..2fca5f2 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,10 @@
 
 *** Changes since GDB 7.9
 
+* The "info source" command now displays the producer string if it was
+  present in the debug info.  This typically includes the compiler version
+  and may include things like its command line arguments.
+
 * Python Scripting
 
   ** gdb.Objfile objects have a new attribute "username",
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 277df25..2e58a53 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -16300,6 +16300,9 @@ its length, in lines,
 @item
 which programming language it is written in,
 @item
+if the debug information provides it, the program that compiled the file
+(which may include, e.g., the compiler version and command line arguments),
+@item
 whether the executable includes debugging information for that file, and
 if so, what format the information is in (e.g., STABS, Dwarf 2, etc.), and
 @item
diff --git a/gdb/source.c b/gdb/source.c
index 574d9fa..49c9d83 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -654,12 +654,15 @@ static void
 source_info (char *ignore, int from_tty)
 {
   struct symtab *s = current_source_symtab;
+  struct compunit_symtab *cust;
 
   if (!s)
     {
       printf_filtered (_("No current source file.\n"));
       return;
     }
+
+  cust = SYMTAB_COMPUNIT (s);
   printf_filtered (_("Current source file is %s\n"), s->filename);
   if (SYMTAB_DIRNAME (s) != NULL)
     printf_filtered (_("Compilation directory is %s\n"), SYMTAB_DIRNAME (s));
@@ -670,10 +673,13 @@ source_info (char *ignore, int from_tty)
 		     s->nlines == 1 ? "" : "s");
 
   printf_filtered (_("Source language is %s.\n"), language_str (s->language));
+  printf_filtered (_("Producer is %s.\n"),
+		   COMPUNIT_PRODUCER (cust) != NULL
+		   ? COMPUNIT_PRODUCER (cust) : _("unknown"));
   printf_filtered (_("Compiled with %s debugging format.\n"),
-		   COMPUNIT_DEBUGFORMAT (SYMTAB_COMPUNIT (s)));
+		   COMPUNIT_DEBUGFORMAT (cust));
   printf_filtered (_("%s preprocessor macro info.\n"),
-		   COMPUNIT_MACRO_TABLE (SYMTAB_COMPUNIT (s)) != NULL
+		   COMPUNIT_MACRO_TABLE (cust) != NULL
 		   ? "Includes" : "Does not include");
 }
 \f

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-01-31 18:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-05 20:41 [PATCH] "info source" now includes producer string Doug Evans
2015-01-05 20:50 ` Eli Zaretskii
2015-01-06  0:28   ` Doug Evans
2015-01-06  3:31     ` Eli Zaretskii
2015-01-31 22:29       ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).