Bug 12192 - attaching gdb to running mach-o process does not load shared libraries and debug symbols
Summary: attaching gdb to running mach-o process does not load shared libraries and de...
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-04 06:58 UTC by Aman Gupta
Modified: 2018-09-15 19:23 UTC (History)
2 users (show)

See Also:
Host:
Target: *-*-darwin*
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aman Gupta 2010-11-04 06:58:53 UTC
$ ../gdb/gdb -v
GNU gdb (GDB) 7.2.50.20101104-cvs
This GDB was configured as "x86_64-apple-darwin10".

$ uname -a
Darwin aman-guptas-imac.local 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386

Build a simple test case:

$ echo "int main() { while(42) sleep(1); }" > main.c
$ gcc -o main main.c
$ ./main &
[1] 67119
$ export PID=$!

Attach to running process (no debug info):

$ ../gdb/gdb -ex "attach $PID" -ex "where" -ex "detach" -ex "quit"

#0  0x00007fff85d18eb6 in ?? ()
#1  0x00007fff85d18d45 in ?? ()
#2  0x2c3e4603000c5877 in ?? ()
#3  0x00ffffffffffffff in ?? ()

Run the process inside gdb instead (works):

$ ../gdb/gdb ./main -ex 'run' -ex 'where' -ex 'quit'

#0  0x00007fff85d18eb6 in __semwait_signal () from /usr/lib/libSystem.B.dylib
#1  0x00007fff85d18d45 in nanosleep () from /usr/lib/libSystem.B.dylib
#2  0x00007fff85d65b14 in sleep () from /usr/lib/libSystem.B.dylib
#3  0x0000000100000f2b in main ()
Comment 1 Tom Tromey 2018-06-28 18:15:58 UTC
I also experience this on macOS 10.13.5.

Debug info is read -- if I hack in some types and global variables,
gdb can print them correctly.

However, stack traces all print "??".

The needed info must be somewhere, because lldb can get the stack trace
correctly.