My end goal is to modify an Objective-C program's symfile in LLDB. I want to augment the method names so a new, unique name can be used to reference an existing method in the debug symbol file.
For example, if there is a method named -[Foo bar]
, I can of course break on this method using (lldb) b -[Foo bar]
, however, I want to create an "alias" for this method named -[Foo baz]
, so when I execute the following in lldb:
(lldb) b -[Foo baz]
A breakpoint will get set on the address at:
method_getImplementation(class_getInstanceMethod([Foo class], @selector(bar)))
My current method of solving this is to use the dsymutil function to dump the symfile:
dsymutil /path/to/executable -o dump.dYSM
From there, I can use the dwarfdump command to prettify the output into something I can actually edit.
dwarfdump dump.dYSM/Contents/Resources/DWARF/ExecName
Now I can easily edit the AT_name
property which contains -[Foo bar]
However, I don't know how to regenerate the dYSM after I have the debug info in this "prettify" format.
Provided I can regenerate the edited dYSM, I am hoping to stick it back into LLDB using either:
(lldb) target modules add
or (lldb) target symbol add
So my questions are:
- Is there a better way to go about this? Note that I do not have the source nor the object files to regenerate a new dYSM.
- Is there a Terminal command that can patch up my edited dwarfdump for me into a LLDB readable debug symbol file?
Cheers!