This is the mail archive of the
mailing list for the GDB project.
Re: [PATCH] "info source" now includes producer string
- From: Doug Evans <dje at google dot com>
- To: Eli Zaretskii <eliz at gnu dot org>
- Cc: gdb-patches at sourceware dot org
- Date: Sat, 31 Jan 2015 10:46:39 -0800
- Subject: Re: [PATCH] "info source" now includes producer string
- Authentication-results: sourceware.org; auth=none
- References: <yjt2h9w52c4v dot fsf at ruffy dot mtv dot corp dot google dot com> <838uhh7y0t dot fsf at gnu dot org> <CADPb22SZSG0YYDd-Y3Sdt5M4v_j=31uCMwhVPTZuyR6Zdop5BQ at mail dot gmail dot com> <8361ck8tzx dot fsf at gnu dot org>
Eli Zaretskii writes:
> > Date: Mon, 5 Jan 2015 16:28:20 -0800
> > From: Doug Evans <email@example.com>
> > Cc: gdb-patches <firstname.lastname@example.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 <email@example.com>
* NEWS: "info source" command now display producer string if present.
* source.c (source_info): Print producer string if present.
* gdb.texinfo (Symbols) <info source>: Output now contains producer
string if present.
diff --git a/gdb/NEWS b/gdb/NEWS
index bd85967..2fca5f2 100644
@@ -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
@@ -16300,6 +16300,9 @@ its length, in lines,
which programming language it is written in,
+if the debug information provides it, the program that compiled the file
+(which may include, e.g., the compiler version and command line arguments),
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
diff --git a/gdb/source.c b/gdb/source.c
index 574d9fa..49c9d83 100644
@@ -654,12 +654,15 @@ static void
source_info (char *ignore, int from_tty)
struct symtab *s = current_source_symtab;
+ struct compunit_symtab *cust;
printf_filtered (_("No current source file.\n"));
+ 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");