0

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:

  1. 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.
  2. Is there a Terminal command that can patch up my edited dwarfdump for me into a LLDB readable debug symbol file?

Cheers!

Sozin's Comet
  • 483
  • 5
  • 13

1 Answers1

1

I'm not entirely clear what you are trying to achieve. It sounded at first like you were trying to break on the dynamically determined implementation of some class/selector pair, in which case you can just do:

(lldb) break set -a `(void *) method_getImplementation((void *)class_getInstanceMethod([Foo class], @selector(bar)))`

Note, you'll have to do this after you've run your program and hit a breakpoint, but then you won't know the specific implementation that's going to get called until you run anyway, so this isn't much of a restriction.

But just munging the name in the DWARF wouldn't have actually achieved this effect. So maybe if you say a little more about your actual aims we can be of more help.

As to question 2, there are no tools to edit dSYM DWARF content after the fact. That's not something there's been much call for.

Jim Ingham
  • 25,260
  • 2
  • 55
  • 63