mirror of
https://github.com/darlinghq/darling.git
synced 2025-03-03 07:18:35 +00:00
Add a gdb script to show backtrace with Mach-O symbols.
This commit is contained in:
parent
fa8b47d788
commit
2a4cd68ca3
11
.gdbinit
Normal file
11
.gdbinit
Normal file
@ -0,0 +1,11 @@
|
||||
python sys.path.insert(0, '.')
|
||||
python import gdb_maloader
|
||||
|
||||
define mreload
|
||||
python reload(gdb_maloader)
|
||||
end
|
||||
|
||||
define mbt
|
||||
mreload
|
||||
python gdb_maloader.bt()
|
||||
end
|
29
gdb_maloader.py
Normal file
29
gdb_maloader.py
Normal file
@ -0,0 +1,29 @@
|
||||
import gdb
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
def bt():
|
||||
# Find the newest frame.
|
||||
frame = gdb.selected_frame()
|
||||
while True:
|
||||
next = frame.newer()
|
||||
if not next:
|
||||
break
|
||||
frame = next
|
||||
|
||||
pipe = os.popen('c++filt', 'w')
|
||||
|
||||
i = 0
|
||||
while frame:
|
||||
s = gdb.execute('p dumpExportedSymbol((void*)0x%x)' % frame.pc(),
|
||||
to_string=True)
|
||||
m = re.match(r'.*"(.*)"$', s)
|
||||
if m:
|
||||
pipe.write("%s\n" % m.group(1))
|
||||
else:
|
||||
pipe.write("0x%x\n" % frame.pc())
|
||||
frame = frame.older()
|
||||
i += 1
|
||||
|
||||
pipe.close()
|
Loading…
x
Reference in New Issue
Block a user