set sysroot rescans, but only if run twice

Andrey Utkin autkin@undo.io
Mon Oct 29 17:28:00 GMT 2018


Hi,

I would appreciate some explanation of how "set sysroot" is supposed to
work. I almost got an impression that it is supposed to rescan "all
known binaries" (just like "set solib-search-path"), besides other
things. This seems to happen in most of cases, but apparently not in
every case.

For example, let's create a remote debugging session with localhost, and
then set sysroot to / . My expectation was that the backtrace would have
all information after "set sysroot /", but it was not the case. However,
a second "set sysroot /" did it. "Insanity is repeating the same and
expecting different results", right?

Say, we attach gdbserver to some trivial process like "sleep":


$ sleep 500h &
[1] 2757
$ gdbserver --attach :5555 $!
Attached; pid = 2757
Listening on port 5555
Remote debugging from host 127.0.0.1


Then we attach to gdbserver:


$ gdb
GNU gdb (Gentoo 8.2 vanilla) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
   <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target remote :5555
Remote debugging using :5555
Reading /bin/sleep from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /bin/sleep from remote target...
Reading symbols from target:/bin/sleep...Reading /bin/sleep.debug from remote target...
Reading /bin/.debug/sleep.debug from remote target...
Reading symbols from /usr/lib/debug/bin//sleep.debug...done.
done.
Reading /lib64/libc.so.6 from remote target...
Reading /lib64/ld-linux-x86-64.so.2 from remote target...
Reading symbols from target:/lib64/libc.so.6...done.
Reading symbols from target:/lib64/ld-linux-x86-64.so.2...done.
Reading /lib64/ld-linux-x86-64.so.2 from remote target...
0x00007f7277f8d495 in __GI___nanosleep (requested_time=requested_time@entry=0x7ffef6d02e40, remaining=remaining@entry=0x0) at ../sysdeps/unix/sysv/linux/nanosleep.c:27
27      ../sysdeps/unix/sysv/linux/nanosleep.c: No such file or directory.
(gdb) bt
#0  0x00007f7277f8d495 in __GI___nanosleep (requested_time=requested_time@entry=0x7ffef6d02e40, remaining=remaining@entry=0x0) at ../sysdeps/unix/sysv/linux/nanosleep.c:27
#1  0x000056334afe81c3 in rpl_nanosleep (requested_delay=requested_delay@entry=0x7ffef6d02e80, remaining_delay=remaining_delay@entry=0x0) at lib/nanosleep.c:85
#2  0x000056334afe7fbd in xnanosleep (seconds=<optimized out>) at lib/xnanosleep.c:51
#3  0x000056334afe5be8 in main (argc=2, argv=0x7ffef6d02fe8) at src/sleep.c:150
(gdb) file /bin/sleep
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Load new symbol table from "/bin/sleep"? (y or n) y
Reading symbols from /bin/sleep...Load new symbol table from "/usr/lib/debug//bin/sleep.debug"? (y or n) y
Reading symbols from /usr/lib/debug//bin/sleep.debug...done.
done.
(gdb) bt
#0  0x00007f7277f8d495 in __GI___nanosleep (requested_time=0x7ffef6d02e40, remaining=0x0) at ../sysdeps/unix/sysv/linux/nanosleep.c:27
#1  0x000056334afe81c3 in ?? ()
#2  0x00000000001b7740 in ?? ()
#3  0x0000000000000000 in ?? ()
(gdb) show remote exec-file
(null)
(gdb) set remote exec-file /bin/sleep
(gdb) bt
#0  0x00007f7277f8d495 in __GI___nanosleep (requested_time=0x7ffef6d02e40, remaining=0x0) at ../sysdeps/unix/sysv/linux/nanosleep.c:27
#1  0x000056334afe81c3 in ?? ()
#2  0x00000000001b7740 in ?? ()
#3  0x0000000000000000 in ?? ()
(gdb) set sysroot /
(gdb) bt
#0  0x00007f7277f8d495 in ?? ()
#1  0x00007f727845c480 in ?? ()
#2  0x00007ffef6d02e70 in ?? ()
#3  0x00000000001b7740 in ?? ()
#4  0x3e01475224fd8c00 in ?? ()
#5  0x0000000000000010 in ?? ()
#6  0x000056334afe81c3 in rpl_nanosleep (requested_delay=requested_delay@entry=0x7ffef6d02e80, remaining_delay=remaining_delay@entry=0x0) at lib/nanosleep.c:85
#7  0x000056334afe7fbd in xnanosleep (seconds=<optimized out>) at lib/xnanosleep.c:51
#8  0x000056334afe5be8 in main (argc=2, argv=0x7ffef6d02fe8) at src/sleep.c:150
(gdb) set sysroot /
Reading symbols from /lib64/libc.so.6...done.
Reading symbols from /lib64/ld-linux-x86-64.so.2...done.
(gdb) bt
#0  0x00007f7277f8d495 in __GI___nanosleep (requested_time=requested_time@entry=0x7ffef6d02e40, remaining=remaining@entry=0x0) at ../sysdeps/unix/sysv/linux/nanosleep.c:27
#1  0x000056334afe81c3 in rpl_nanosleep (requested_delay=requested_delay@entry=0x7ffef6d02e80, remaining_delay=remaining_delay@entry=0x0) at lib/nanosleep.c:85
#2  0x000056334afe7fbd in xnanosleep (seconds=<optimized out>) at lib/xnanosleep.c:51
#3  0x000056334afe5be8 in main (argc=2, argv=0x7ffef6d02fe8) at src/sleep.c:150
(gdb)



More information about the Gdb mailing list