public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* set sysroot and debug-file-directory don't work together?
@ 2023-11-27 20:55 Mike Tsai
  2023-12-10 23:11 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Tsai @ 2023-11-27 20:55 UTC (permalink / raw)
  To: gdb

Greetings everyone,

I have a dummy question regarding using "set sysroot LOCAL_DIR" and
"set debug-file-directory SOME_OTHER_DIR" together to find symbols for
a debug session. I was under the impression, gdb is able to fallback
to debug-file-directory and do build-id style lookup if symbols cannot
be found in "sysroot", but it does not seem to be doing that so I am
curious if it's I am doing something wrong or this is not "supported".

A little context, we are doing embedded device debugging for Linux
based platform hence, the target device will not have sufficient space
to host all debug symbols. We have most of the debug symbols in the
"sysroot", and for something that is built outside, we want to export
additional symbols look up through debug-file-directory and debug over
gdb+gdbserver.

I will share my gdbinit as well. It isn't terribly sophisticated :)
and I am on GNU gdb (GDB) 11.2
```
set verbose on
set pagination off
set sysroot /path/to/rootfs
set debug-file-directory /path/to/more-debug/
set substitute-path /usr/src/debug /path/to/rootfs/usr/src/debug
set detach-on-fork on
set follow-fork-mode child
target remote :5039
where
```

I am trying to debug a binary whose symbols do not exist in the
"sysroot", so I expect the symbols to be picked up from
debug-file-directory, but above isn't working as it seems if sysroot
is specified, it will not fallback to debug-file-directory. If I
comment out sysroot line, GDB will attempt to load the debug symbols
through the local build-id/ mechanism as I would expect, but then it
will not have additional libs debug provided by the "sysroot". So yap,
this is what I am struggling with currently and would like to know if
I am not configuring something right or this is expected behavior and
how to get it to work the way I intend to use this.

Thanks,
Mike

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

* Re: set sysroot and debug-file-directory don't work together?
  2023-11-27 20:55 set sysroot and debug-file-directory don't work together? Mike Tsai
@ 2023-12-10 23:11 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2023-12-10 23:11 UTC (permalink / raw)
  To: Mike Tsai via Gdb; +Cc: Mike Tsai

>>>>> "Mike" == Mike Tsai via Gdb <gdb@sourceware.org> writes:

Mike> I have a dummy question regarding using "set sysroot LOCAL_DIR" and
Mike> "set debug-file-directory SOME_OTHER_DIR" together to find symbols for
Mike> a debug session. I was under the impression, gdb is able to fallback
Mike> to debug-file-directory and do build-id style lookup if symbols cannot
Mike> be found in "sysroot", but it does not seem to be doing that so I am
Mike> curious if it's I am doing something wrong or this is not "supported".

I didn't know the answer either, so I looked through the source a bit.

In the end it's just a pain to try to figure out what this code is
doing.  Far easier, probably, is for you to:

    set debug separate-debug-file 1

... and then try.  I think that will show exactly the paths gdb is
trying to use.

I tried it with "file /bin/ls":

    (gdb) file /bin/ls
    Reading symbols from /bin/ls...

    Looking for separate debug info (build-id) for /usr/bin/ls
      Trying /usr/lib/debug/.build-id/a1/46002a40b622e4d8420c5b96513f0784c8eb7b.debug... no, unable to compute real path
      Trying target:/usr/lib/debug/.build-id/a1/46002a40b622e4d8420c5b96513f0784c8eb7b.debug... no, unable to open.

    Looking for separate debug info (debug link) for /usr/bin/ls
      Trying /usr/bin/ls-9.1-12.fc38.x86_64.debug... no, unable to open.
      Trying /usr/bin/.debug/ls-9.1-12.fc38.x86_64.debug... no, unable to open.
      Trying /usr/lib/debug//usr/bin/ls-9.1-12.fc38.x86_64.debug... no, unable to open.
    Reading symbols from .gnu_debugdata for /usr/bin/ls...
    (No debugging symbols found in .gnu_debugdata for /usr/bin/ls)

... IMO pretty readable.

If I "set sysroot /tmp/nonesuch" first, then only that "target:" line
changes.

This order seems sort of backward to me somehow, like if I had a
complete sysroot setup (including all separate debug files), then "set
sysroot" should be sufficient and it should never check outside.  I
suppose with .build-id the idea is that the hashes are global and so it
doesn't matter exactly where gdb finds the match.

Tom

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

end of thread, other threads:[~2023-12-10 23:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-27 20:55 set sysroot and debug-file-directory don't work together? Mike Tsai
2023-12-10 23:11 ` Tom Tromey

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