public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Introduce "set debug separate-debug-file"
@ 2017-05-24 23:24 Simon Marchi
  2017-05-25 11:07 ` Pedro Alves
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Marchi @ 2017-05-24 23:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

I helped someone figure out why their separate debug info (debug
link-based) was not found by gdb.  It turns out that the debug file was
not named properly.  It made me realize that it is quite difficult to
diagnose this kind of problems.  This patch adds some debug output to
show where GDB looks for those files, so that it should be (more)
obvious to find what's wrong.

Here's an example of the result, first with an example of unsuccessful lookup,
and then a successful one.

  (gdb) set debug separate-debug-file on
  (gdb) file /usr/bin/gnome-calculator
  Reading symbols from /usr/bin/gnome-calculator...
  Looking for separate debug info (build-id) for /usr/bin/gnome-calculator
    Trying /usr/local/lib/debug/.build-id/0d/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug

  Looking for separate debug info (debug link) for /usr/bin/gnome-calculator
    Trying /usr/bin/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug
    Trying /usr/bin/.debug/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug
    Trying /usr/local/lib/debug//usr/bin/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug
  (no debugging symbols found)...done.
  (gdb) set debug-file-directory /usr/lib/debug
  (gdb) file /usr/bin/gnome-calculator
  Reading symbols from /usr/bin/gnome-calculator...
  Looking for separate debug info by build-id for /usr/bin/gnome-calculator
    Trying /usr/lib/debug/.build-id/0d/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug
  Reading symbols from /usr/lib/debug/.build-id/0d/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug...done.
  done.

Note: here, the debug link happens to be named like the build-id, but it
doesn't have to be this way.  It puzzled me for a minute.

gdb/ChangeLog:

	* symfile.h (separate_debug_file_debug): New global.
	* symfile.c (separate_debug_file_debug): New global.
	(separate_debug_file_exists, find_separate_debug_file): Add
	debug output.
	(_initialize_symfile): Add "set debug separate-debug-file"
	command.
	* build-id.c (build_id_to_debug_bfd,
	find_separate_debug_file_by_buildid): Add debug output.
---
 gdb/build-id.c |  7 +++++++
 gdb/symfile.c  | 19 +++++++++++++++++++
 gdb/symfile.h  |  5 +++++
 3 files changed, 31 insertions(+)

diff --git a/gdb/build-id.c b/gdb/build-id.c
index 0f63223..2b7c046 100644
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -112,6 +112,9 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
 	s += sprintf (s, "%02x", (unsigned) *data++);
       strcpy (s, ".debug");
 
+      if (separate_debug_file_debug)
+	printf_unfiltered ("  Trying %s\n", link);
+
       /* lrealpath() is expensive even for the usually non-existent files.  */
       if (access (link, F_OK) == 0)
 	filename = lrealpath (link);
@@ -147,6 +150,10 @@ find_separate_debug_file_by_buildid (struct objfile *objfile)
   build_id = build_id_bfd_get (objfile->obfd);
   if (build_id != NULL)
     {
+      if (separate_debug_file_debug)
+	printf_unfiltered ("\nLooking for separate debug info (build-id) for "
+			   "%s\n", objfile_name (objfile));
+
       gdb_bfd_ref_ptr abfd (build_id_to_debug_bfd (build_id->size,
 						   build_id->data));
       /* Prevent looping on a stripped .debug file.  */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 846aabe..beda370 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1333,6 +1333,11 @@ symbol_file_clear (int from_tty)
     printf_unfiltered (_("No symbol file now.\n"));
 }
 
+/* See symfile.h.  */
+
+int separate_debug_file_debug = 0;
+
+
 static int
 separate_debug_file_exists (const char *name, unsigned long crc,
 			    struct objfile *parent_objfile)
@@ -1351,6 +1356,9 @@ separate_debug_file_exists (const char *name, unsigned long crc,
   if (filename_cmp (name, objfile_name (parent_objfile)) == 0)
     return 0;
 
+  if (separate_debug_file_debug)
+    printf_unfiltered ("  Trying %s\n", name);
+
   gdb_bfd_ref_ptr abfd (gdb_bfd_open (name, gnutarget, -1));
 
   if (abfd == NULL)
@@ -1444,6 +1452,10 @@ find_separate_debug_file (const char *dir,
   struct cleanup *back_to;
   int ix;
 
+  if (separate_debug_file_debug)
+    printf_unfiltered ("\nLooking for separate debug info (debug link) for "
+		       "%s\n", objfile_name (objfile));
+
   /* Set I to std::max (strlen (canon_dir), strlen (dir)).  */
   i = strlen (dir);
   if (canon_dir != NULL && strlen (canon_dir) > i)
@@ -3975,4 +3987,11 @@ full  == print messages for the executable,\n\
 			NULL,
 			NULL,
 			&setprintlist, &showprintlist);
+
+  add_setshow_boolean_cmd ("separate-debug-file", no_class,
+			   &separate_debug_file_debug, _("\
+Set printing of separate debug info file search debug."), _("\
+Show printing of separate debug info file search debug."), _("\
+When on, GDB will print the searched locations while looking for separate \
+debug info files."), NULL, NULL, &setdebuglist, &showdebuglist);
 }
diff --git a/gdb/symfile.h b/gdb/symfile.h
index ab536e8..d05cb09 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -646,4 +646,9 @@ extern void elfmdebug_build_psymtabs (struct objfile *,
 
 extern gdb_bfd_ref_ptr find_separate_debug_file_in_section (struct objfile *);
 
+
+/* True if we are printing debug output about separate debug info files.  */
+
+extern int separate_debug_file_debug;
+
 #endif /* !defined(SYMFILE_H) */
-- 
2.7.4

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

* Re: [PATCH] Introduce "set debug separate-debug-file"
  2017-05-24 23:24 [PATCH] Introduce "set debug separate-debug-file" Simon Marchi
@ 2017-05-25 11:07 ` Pedro Alves
  2017-05-25 11:33   ` Simon Marchi
  2017-05-25 11:41   ` [PATCH v2] " Simon Marchi
  0 siblings, 2 replies; 7+ messages in thread
From: Pedro Alves @ 2017-05-25 11:07 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

I think this is a good idea.

You're missing NEWS and manual bits though.

On 05/25/2017 12:24 AM, Simon Marchi wrote:

> +      if (separate_debug_file_debug)
> +	printf_unfiltered ("  Trying %s\n", link);
> +

Missing "_()" in several of these new calls.

> +
> +  add_setshow_boolean_cmd ("separate-debug-file", no_class,
> +			   &separate_debug_file_debug, _("\
> +Set printing of separate debug info file search debug."), _("\
> +Show printing of separate debug info file search debug."), _("\
> +When on, GDB will print the searched locations while looking for separate \
> +debug info files."), NULL, NULL, &setdebuglist, &showdebuglist);

FWIW, I think it's better to avoid future tense when possible:

  "When on, GDB prints the searched locations"

Thanks,
Pedro Alves

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

* Re: [PATCH] Introduce "set debug separate-debug-file"
  2017-05-25 11:07 ` Pedro Alves
@ 2017-05-25 11:33   ` Simon Marchi
  2017-05-25 11:41   ` [PATCH v2] " Simon Marchi
  1 sibling, 0 replies; 7+ messages in thread
From: Simon Marchi @ 2017-05-25 11:33 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches

On 2017-05-25 01:07 PM, Pedro Alves wrote:
> I think this is a good idea.
> 
> You're missing NEWS and manual bits though.
> 
> On 05/25/2017 12:24 AM, Simon Marchi wrote:
> 
>> +      if (separate_debug_file_debug)
>> +	printf_unfiltered ("  Trying %s\n", link);
>> +
> 
> Missing "_()" in several of these new calls.
> 
>> +
>> +  add_setshow_boolean_cmd ("separate-debug-file", no_class,
>> +			   &separate_debug_file_debug, _("\
>> +Set printing of separate debug info file search debug."), _("\
>> +Show printing of separate debug info file search debug."), _("\
>> +When on, GDB will print the searched locations while looking for separate \
>> +debug info files."), NULL, NULL, &setdebuglist, &showdebuglist);
> 
> FWIW, I think it's better to avoid future tense when possible:
> 
>   "When on, GDB prints the searched locations"

Thanks for the comments, sending a v2 now.

Simon

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

* [PATCH v2] Introduce "set debug separate-debug-file"
  2017-05-25 11:07 ` Pedro Alves
  2017-05-25 11:33   ` Simon Marchi
@ 2017-05-25 11:41   ` Simon Marchi
  2017-05-25 12:18     ` [PATCH v3] " Simon Marchi
  1 sibling, 1 reply; 7+ messages in thread
From: Simon Marchi @ 2017-05-25 11:41 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

New in v2:

 - Add NEWS and doc.
 - Add missing _() at various places.
 - Change verb tense in command help.


I helped someone figure out why their separate debug info (debug
link-based) was not found by gdb.  It turns out that the debug file was
not named properly.  It made me realize that it is quite difficult to
diagnose this kind of problems.  This patch adds some debug output to
show where GDB looks for those files, so that it should be (more)
obvious to find what's wrong.

Here's an example of the result, first with an example of unsuccessful lookup,
and then a successful one.

  (gdb) set debug separate-debug-file on
  (gdb) file /usr/bin/gnome-calculator
  Reading symbols from /usr/bin/gnome-calculator...
  Looking for separate debug info (build-id) for /usr/bin/gnome-calculator
    Trying /usr/local/lib/debug/.build-id/0d/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug

  Looking for separate debug info (debug link) for /usr/bin/gnome-calculator
    Trying /usr/bin/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug
    Trying /usr/bin/.debug/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug
    Trying /usr/local/lib/debug//usr/bin/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug
  (no debugging symbols found)...done.
  (gdb) set debug-file-directory /usr/lib/debug
  (gdb) file /usr/bin/gnome-calculator
  Reading symbols from /usr/bin/gnome-calculator...
  Looking for separate debug info by build-id for /usr/bin/gnome-calculator
    Trying /usr/lib/debug/.build-id/0d/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug
  Reading symbols from /usr/lib/debug/.build-id/0d/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug...done.
  done.

Note: here, the debug link happens to be named like the build-id, but it
doesn't have to be this way.  It puzzled me for a minute.

gdb/ChangeLog:

	* NEWS: Announce {set,show} debug separate-debug-file commands.
	* symfile.h (separate_debug_file_debug): New global.
	* symfile.c (separate_debug_file_debug): New global.
	(separate_debug_file_exists, find_separate_debug_file): Add
	debug output.
	(_initialize_symfile): Add "set debug separate-debug-file"
	command.
	* build-id.c (build_id_to_debug_bfd,
	find_separate_debug_file_by_buildid): Add debug output.

gdb/doc/ChangeLog:

	* gdb.texinfo (Optional Messages about Internal Happenings):
	Document {set,show} debug separate-debug-file commands.
---
 gdb/NEWS            | 26 ++++++++++++++------------
 gdb/build-id.c      |  7 +++++++
 gdb/doc/gdb.texinfo |  6 ++++++
 gdb/symfile.c       | 18 ++++++++++++++++++
 gdb/symfile.h       |  4 ++++
 5 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index eb1a589..bf4cadd 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -83,18 +83,6 @@ FreeBSD/mips			mips*-*-freebsd
 flash-erase
   Erases all the flash memory regions reported by the target.
 
-* New MI commands
-
--target-flash-erase
-  Erases all the flash memory regions reported by the target.  This is
-  equivalent to the CLI command flash-erase.
-
--file-list-shared-libraries
-  List the shared libraries in the program.  This is
-  equivalent to the CLI command "info shared".
-
-* New commands
-
 set disassembler-options
 show disassembler-options
   Controls the passing of target specific information to the disassembler.
@@ -106,6 +94,20 @@ show disassembler-options
 maint print arc arc-instruction address
   Print internal disassembler information about instruction at a given address.
 
+set debug separate-debug-file
+show debug separate-debug-file
+  Control the display of debug output about separate debug file search.
+
+* New MI commands
+
+-target-flash-erase
+  Erases all the flash memory regions reported by the target.  This is
+  equivalent to the CLI command flash-erase.
+
+-file-list-shared-libraries
+  List the shared libraries in the program.  This is
+  equivalent to the CLI command "info shared".
+
 * Removed targets and native configurations
 
 Alpha running FreeBSD         alpha*-*-freebsd*
diff --git a/gdb/build-id.c b/gdb/build-id.c
index 0f63223..4b2b63e 100644
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -112,6 +112,9 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
 	s += sprintf (s, "%02x", (unsigned) *data++);
       strcpy (s, ".debug");
 
+      if (separate_debug_file_debug)
+	printf_unfiltered (_("  Trying %s\n"), link);
+
       /* lrealpath() is expensive even for the usually non-existent files.  */
       if (access (link, F_OK) == 0)
 	filename = lrealpath (link);
@@ -147,6 +150,10 @@ find_separate_debug_file_by_buildid (struct objfile *objfile)
   build_id = build_id_bfd_get (objfile->obfd);
   if (build_id != NULL)
     {
+      if (separate_debug_file_debug)
+	printf_unfiltered (_("\nLooking for separate debug info (build-id) for "
+			     "%s\n"), objfile_name (objfile));
+
       gdb_bfd_ref_ptr abfd (build_id_to_debug_bfd (build_id->size,
 						   build_id->data));
       /* Prevent looping on a stripped .debug file.  */
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 9fb70f6..c1f65f6 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -23979,6 +23979,12 @@ the serial line to the remote machine.  The info is printed on the
 @value{GDBN} standard output stream. The default is off.
 @item show debug remote
 Displays the state of display of remote packets.
+
+@item set debug separate-debug-file
+Turns on or off display of debug output about separate debug file search.
+@item show debug separate-debug-file
+Displays the state of separate debug file search debug output.
+
 @item set debug serial
 Turns on or off display of @value{GDBN} serial debugging info. The
 default is off.
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 846aabe..f936cf3 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1333,6 +1333,10 @@ symbol_file_clear (int from_tty)
     printf_unfiltered (_("No symbol file now.\n"));
 }
 
+/* See symfile.h.  */
+
+int separate_debug_file_debug = 0;
+
 static int
 separate_debug_file_exists (const char *name, unsigned long crc,
 			    struct objfile *parent_objfile)
@@ -1351,6 +1355,9 @@ separate_debug_file_exists (const char *name, unsigned long crc,
   if (filename_cmp (name, objfile_name (parent_objfile)) == 0)
     return 0;
 
+  if (separate_debug_file_debug)
+    printf_unfiltered (_("  Trying %s\n"), name);
+
   gdb_bfd_ref_ptr abfd (gdb_bfd_open (name, gnutarget, -1));
 
   if (abfd == NULL)
@@ -1444,6 +1451,10 @@ find_separate_debug_file (const char *dir,
   struct cleanup *back_to;
   int ix;
 
+  if (separate_debug_file_debug)
+    printf_unfiltered (_("\nLooking for separate debug info (debug link) for "
+		         "%s\n"), objfile_name (objfile));
+
   /* Set I to std::max (strlen (canon_dir), strlen (dir)).  */
   i = strlen (dir);
   if (canon_dir != NULL && strlen (canon_dir) > i)
@@ -3975,4 +3986,11 @@ full  == print messages for the executable,\n\
 			NULL,
 			NULL,
 			&setprintlist, &showprintlist);
+
+  add_setshow_boolean_cmd ("separate-debug-file", no_class,
+			   &separate_debug_file_debug, _("\
+Set printing of separate debug info file search debug."), _("\
+Show printing of separate debug info file search debug."), _("\
+When on, GDB prints the searched locations while looking for separate debug \
+info files."), NULL, NULL, &setdebuglist, &showdebuglist);
 }
diff --git a/gdb/symfile.h b/gdb/symfile.h
index ab536e8..bb47fdf 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -646,4 +646,8 @@ extern void elfmdebug_build_psymtabs (struct objfile *,
 
 extern gdb_bfd_ref_ptr find_separate_debug_file_in_section (struct objfile *);
 
+/* True if we are printing debug output about separate debug info files.  */
+
+extern int separate_debug_file_debug;
+
 #endif /* !defined(SYMFILE_H) */
-- 
2.7.4

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

* [PATCH v3] Introduce "set debug separate-debug-file"
  2017-05-25 11:41   ` [PATCH v2] " Simon Marchi
@ 2017-05-25 12:18     ` Simon Marchi
  2017-05-25 15:27       ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Marchi @ 2017-05-25 12:18 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

New in v3: In v2, the NEWS entry was wrongfully in the "Changes in GDB 8.0"
section, it is now in the "Changes since GDB 8.0".  It also merged duplicate
"New commands" sub-sections.  This is now done in a separate patch.


I helped someone figure out why their separate debug info (debug
link-based) was not found by gdb.  It turns out that the debug file was
not named properly.  It made me realize that it is quite difficult to
diagnose this kind of problems.  This patch adds some debug output to
show where GDB looks for those files, so that it should be (more)
obvious to find what's wrong.

Here's an example of the result, first with an example of unsuccessful lookup,
and then a successful one.

  (gdb) set debug separate-debug-file on
  (gdb) file /usr/bin/gnome-calculator
  Reading symbols from /usr/bin/gnome-calculator...
  Looking for separate debug info (build-id) for /usr/bin/gnome-calculator
    Trying /usr/local/lib/debug/.build-id/0d/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug

  Looking for separate debug info (debug link) for /usr/bin/gnome-calculator
    Trying /usr/bin/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug
    Trying /usr/bin/.debug/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug
    Trying /usr/local/lib/debug//usr/bin/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug
  (no debugging symbols found)...done.
  (gdb) set debug-file-directory /usr/lib/debug
  (gdb) file /usr/bin/gnome-calculator
  Reading symbols from /usr/bin/gnome-calculator...
  Looking for separate debug info by build-id for /usr/bin/gnome-calculator
    Trying /usr/lib/debug/.build-id/0d/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug
  Reading symbols from /usr/lib/debug/.build-id/0d/5c5e8c86dbe4f4f95f7a13de04f91d377f3c6a.debug...done.
  done.

Note: here, the debug link happens to be named like the build-id, but it
doesn't have to be this way.  It puzzled me for a minute.

gdb/ChangeLog:

	* NEWS (Changes since GDB 8.0): Announce {set,show} debug
	separate-debug-file commands.
	* symfile.h (separate_debug_file_debug): New global.
	* symfile.c (separate_debug_file_debug): New global.
	(separate_debug_file_exists, find_separate_debug_file): Add
	debug output.
	(_initialize_symfile): Add "set debug separate-debug-file"
	command.
	* build-id.c (build_id_to_debug_bfd,
	find_separate_debug_file_by_buildid): Add debug output.

gdb/doc/ChangeLog:

	* gdb.texinfo (Optional Messages about Internal Happenings):
	Document {set,show} debug separate-debug-file commands.
---
 gdb/NEWS            |  6 ++++++
 gdb/build-id.c      |  7 +++++++
 gdb/doc/gdb.texinfo |  6 ++++++
 gdb/symfile.c       | 18 ++++++++++++++++++
 gdb/symfile.h       |  4 ++++
 5 files changed, 41 insertions(+)

diff --git a/gdb/NEWS b/gdb/NEWS
index 23443eb..82a17a3 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,12 @@
 
 *** Changes since GDB 8.0
 
+* New commands
+
+set debug separate-debug-file
+show debug separate-debug-file
+  Control the display of debug output about separate debug file search.
+
 *** Changes in GDB 8.0
 
 * GDB now supports access to the PKU register on GNU/Linux. The register is
diff --git a/gdb/build-id.c b/gdb/build-id.c
index 0f63223..4b2b63e 100644
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -112,6 +112,9 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
 	s += sprintf (s, "%02x", (unsigned) *data++);
       strcpy (s, ".debug");
 
+      if (separate_debug_file_debug)
+	printf_unfiltered (_("  Trying %s\n"), link);
+
       /* lrealpath() is expensive even for the usually non-existent files.  */
       if (access (link, F_OK) == 0)
 	filename = lrealpath (link);
@@ -147,6 +150,10 @@ find_separate_debug_file_by_buildid (struct objfile *objfile)
   build_id = build_id_bfd_get (objfile->obfd);
   if (build_id != NULL)
     {
+      if (separate_debug_file_debug)
+	printf_unfiltered (_("\nLooking for separate debug info (build-id) for "
+			     "%s\n"), objfile_name (objfile));
+
       gdb_bfd_ref_ptr abfd (build_id_to_debug_bfd (build_id->size,
 						   build_id->data));
       /* Prevent looping on a stripped .debug file.  */
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 9fb70f6..c1f65f6 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -23979,6 +23979,12 @@ the serial line to the remote machine.  The info is printed on the
 @value{GDBN} standard output stream. The default is off.
 @item show debug remote
 Displays the state of display of remote packets.
+
+@item set debug separate-debug-file
+Turns on or off display of debug output about separate debug file search.
+@item show debug separate-debug-file
+Displays the state of separate debug file search debug output.
+
 @item set debug serial
 Turns on or off display of @value{GDBN} serial debugging info. The
 default is off.
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 846aabe..f936cf3 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1333,6 +1333,10 @@ symbol_file_clear (int from_tty)
     printf_unfiltered (_("No symbol file now.\n"));
 }
 
+/* See symfile.h.  */
+
+int separate_debug_file_debug = 0;
+
 static int
 separate_debug_file_exists (const char *name, unsigned long crc,
 			    struct objfile *parent_objfile)
@@ -1351,6 +1355,9 @@ separate_debug_file_exists (const char *name, unsigned long crc,
   if (filename_cmp (name, objfile_name (parent_objfile)) == 0)
     return 0;
 
+  if (separate_debug_file_debug)
+    printf_unfiltered (_("  Trying %s\n"), name);
+
   gdb_bfd_ref_ptr abfd (gdb_bfd_open (name, gnutarget, -1));
 
   if (abfd == NULL)
@@ -1444,6 +1451,10 @@ find_separate_debug_file (const char *dir,
   struct cleanup *back_to;
   int ix;
 
+  if (separate_debug_file_debug)
+    printf_unfiltered (_("\nLooking for separate debug info (debug link) for "
+		         "%s\n"), objfile_name (objfile));
+
   /* Set I to std::max (strlen (canon_dir), strlen (dir)).  */
   i = strlen (dir);
   if (canon_dir != NULL && strlen (canon_dir) > i)
@@ -3975,4 +3986,11 @@ full  == print messages for the executable,\n\
 			NULL,
 			NULL,
 			&setprintlist, &showprintlist);
+
+  add_setshow_boolean_cmd ("separate-debug-file", no_class,
+			   &separate_debug_file_debug, _("\
+Set printing of separate debug info file search debug."), _("\
+Show printing of separate debug info file search debug."), _("\
+When on, GDB prints the searched locations while looking for separate debug \
+info files."), NULL, NULL, &setdebuglist, &showdebuglist);
 }
diff --git a/gdb/symfile.h b/gdb/symfile.h
index ab536e8..bb47fdf 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -646,4 +646,8 @@ extern void elfmdebug_build_psymtabs (struct objfile *,
 
 extern gdb_bfd_ref_ptr find_separate_debug_file_in_section (struct objfile *);
 
+/* True if we are printing debug output about separate debug info files.  */
+
+extern int separate_debug_file_debug;
+
 #endif /* !defined(SYMFILE_H) */
-- 
2.7.4

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

* Re: [PATCH v3] Introduce "set debug separate-debug-file"
  2017-05-25 12:18     ` [PATCH v3] " Simon Marchi
@ 2017-05-25 15:27       ` Eli Zaretskii
  2017-06-11 21:17         ` Simon Marchi
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2017-05-25 15:27 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches

> From: Simon Marchi <simon.marchi@ericsson.com>
> CC: Simon Marchi <simon.marchi@ericsson.com>
> Date: Thu, 25 May 2017 14:17:42 +0200
> 
> gdb/ChangeLog:
> 
> 	* NEWS (Changes since GDB 8.0): Announce {set,show} debug
> 	separate-debug-file commands.
> 	* symfile.h (separate_debug_file_debug): New global.
> 	* symfile.c (separate_debug_file_debug): New global.
> 	(separate_debug_file_exists, find_separate_debug_file): Add
> 	debug output.
> 	(_initialize_symfile): Add "set debug separate-debug-file"
> 	command.
> 	* build-id.c (build_id_to_debug_bfd,
> 	find_separate_debug_file_by_buildid): Add debug output.
> 
> gdb/doc/ChangeLog:
> 
> 	* gdb.texinfo (Optional Messages about Internal Happenings):
> 	Document {set,show} debug separate-debug-file commands.

OK for the documentation parts.

Thanks.

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

* Re: [PATCH v3] Introduce "set debug separate-debug-file"
  2017-05-25 15:27       ` Eli Zaretskii
@ 2017-06-11 21:17         ` Simon Marchi
  0 siblings, 0 replies; 7+ messages in thread
From: Simon Marchi @ 2017-06-11 21:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Simon Marchi, gdb-patches

On 2017-05-25 17:27, Eli Zaretskii wrote:
>> From: Simon Marchi <simon.marchi@ericsson.com>
>> CC: Simon Marchi <simon.marchi@ericsson.com>
>> Date: Thu, 25 May 2017 14:17:42 +0200
>> 
>> gdb/ChangeLog:
>> 
>> 	* NEWS (Changes since GDB 8.0): Announce {set,show} debug
>> 	separate-debug-file commands.
>> 	* symfile.h (separate_debug_file_debug): New global.
>> 	* symfile.c (separate_debug_file_debug): New global.
>> 	(separate_debug_file_exists, find_separate_debug_file): Add
>> 	debug output.
>> 	(_initialize_symfile): Add "set debug separate-debug-file"
>> 	command.
>> 	* build-id.c (build_id_to_debug_bfd,
>> 	find_separate_debug_file_by_buildid): Add debug output.
>> 
>> gdb/doc/ChangeLog:
>> 
>> 	* gdb.texinfo (Optional Messages about Internal Happenings):
>> 	Document {set,show} debug separate-debug-file commands.
> 
> OK for the documentation parts.
> 
> Thanks.

Thanks, this is now pushed.

Simon

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

end of thread, other threads:[~2017-06-11 21:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-24 23:24 [PATCH] Introduce "set debug separate-debug-file" Simon Marchi
2017-05-25 11:07 ` Pedro Alves
2017-05-25 11:33   ` Simon Marchi
2017-05-25 11:41   ` [PATCH v2] " Simon Marchi
2017-05-25 12:18     ` [PATCH v3] " Simon Marchi
2017-05-25 15:27       ` Eli Zaretskii
2017-06-11 21:17         ` Simon Marchi

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).