[lldb-dev] MCJIT Mach-O JIT debugging
Greg Clayton
gclayton at apple.com
Wed May 28 09:53:18 PDT 2014
> On May 28, 2014, at 8:57 AM, Keno Fischer <kfischer at college.harvard.edu> wrote:
>
> Hello,
>
> I'm finally getting back to getting JIT debugging work for MCJIT. This has worked for ELF for a while in LLVM and support in lldb was added in January (for ELF). I'm now trying to add support for Mach-O and would appreciate some feedback (though I'm fighting my way through learning the format, I'm still just a novice).
>
> My current patchset for llvm is here: https://gist.github.com/loladiro/8d909ddd04e6d7e9a5d0 . I have a corresponding patch for lldb and I basically got this working (modulo line table information, though I'm sure I'm doing something stupid in lldb here).
> The basic approach is to, when a section gets allocated rewrite the sections `addr` and update every symbols `n_value` correspondingly. This is very much in line with what is done for ELF, but I'm not sure if it's the right approach, so I'd appreciate if somebody who has more experience with Mach-O could look at the above patch and give some feedback. If this approach looks sane in general, I'll finish up and post both the LLVM and the LLDB patch for formal review.
The one thing you might want to look into is the n_value only needs to be updated "if ((N_TYPE & n_type) == N_SECT)" (the symbol is in a section and therefore is has a address value). Other symbols have values that usually don't need to be modified. You might also need to watch out for absolute symbols (if ((N_TYPE & n_type) == N_ABS)) as there are a few that sometimes don't claim to be a symbol that has a valid address, but they actually do point to an address. The symbol named "mach_header" is one such absolute symbol.
If this is all new code, get it as close as you can and then we can work the kinks out once it is in the codebase.
Greg
More information about the lldb-dev
mailing list