Bug 30871 - [gdb/symtab] Means to control finding debuginfo (without/with sysroot prefix)
Summary: [gdb/symtab] Means to control finding debuginfo (without/with sysroot prefix)
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: HEAD
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-19 08:18 UTC by Tom de Vries
Modified: 2023-09-19 09:49 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2023-09-19 08:18:55 UTC
As documented here ( https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html ), there are two ways to find debuginfo:
- build-id, and
- debug link.

The build-id is tried first, then the debug link.

Then each case also tries first without, then with sysroot prefix.

Together this results in 4 different ways to get to the debuginfo.

AFAIK, in the test-suite we have test-cases that exercise the build-id and debug link scenarios individually.

But that's not the case for the without/with sysroot prefix cases.

It would be good to have a way (say a maintenance command) that determines the ways in which debug info can be found.

That way we could enforce using the with sysroot case.

[ This is relevant in the context of containers.  Say we have a container, with an exec and corresponding debug info installed.  When we use gdb inside the container to debug the exec, we find the debuginfo using the without sysroot method.  When we try the same from outside the container, the without sysroot method fails (because the debug info is installed in the container, not outside) and falls back to the with sysroot method, which will look for the debug info inside the container. ]
Comment 1 Tom de Vries 2023-09-19 09:49:43 UTC
Put differently, with this patch applied:
...
diff --git a/gdb/build-id.c b/gdb/build-id.c
index f68384f0197..1ab9fd8b4c5 100644
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -174,6 +174,7 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id,
       if (debug_bfd != NULL)
 	return debug_bfd;
 
+#if 0
       /* Try to look under the sysroot as well.  If the sysroot is
 	 "/the/sysroot", it will give
 	 "/the/sysroot/usr/lib/debug/.build-id/ab/cdef.debug".  */
@@ -185,6 +186,7 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id,
 	  if (debug_bfd != NULL)
 	    return debug_bfd;
 	}
+#endif
     }
 
   return {};
...
no test-case in the test suite starts failing.