llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.73k stars 11.42k forks source link

DW_AT_trampoline support? #80438

Open rjra100 opened 7 months ago

rjra100 commented 7 months ago

We're seeing behaviour when debugging code in shared objects, where LLDB thread step-in steps over functions instead of stepping into them unless target.process.thread.step-in-avoid-nodebug is set to false. If set false, we can step into a couple of lines of disassembly of what is presumably a trampoline function, then through to the function of interest. That's a viable workaround, but it's not ideal.

I can't be certain, but this review in the llvm phabricator archive looks relevant: https://reviews.llvm.org/D147292. It seems to have been accepted. However, as far as I can see the code never actually landed into the lldb source.

llvmbot commented 7 months ago

@llvm/issue-subscribers-lldb

Author: None (rjra100)

We're seeing behaviour when debugging code in shared objects, where LLDB `thread step-in` steps _over_ functions instead of stepping _into_ them unless `target.process.thread.step-in-avoid-nodebug` is set to false. If set false, we can step into a couple of lines of disassembly of what is presumably a trampoline function, then through to the function of interest. That's a viable workaround, but it's not ideal. I can't be certain, but this review in the llvm phabricator archive looks relevant: https://reviews.llvm.org/D147292. It seems to have been accepted. However, as far as I can see the code never actually landed into the lldb source.
bulbazord commented 7 months ago

@augusto2112 Looks like you worked on something that would fix this but never landed it. Can you take a look?

augusto2112 commented 6 months ago

Hi @rjra100, thanks for reminding me of this, I got side-tracked with other work and didn't upstream this and the accompanying clang patch. If you're on macOS or don't mind compiling clang and lldb from the apple fork (branch stable/20230725 should have the change), you can use the feature until I land this upstream. It requires you to annotate the trampoline function with __attribute__((transparent_stepping)) though. There's some documentation in https://github.com/apple/llvm-project/pull/6597. Let me know if you have any questions!

igorkudrin commented 5 months ago

Hi @augusto2112, thanks for the patches! I have tried them for our downstream project and they work amazingly well. I'm looking forward to seeing them ported to the upstream.

igorkudrin commented 1 month ago

you can use the feature until I land this upstream.

Hi @augusto2112, do you have any updates on this? The patch is awesome and I believe other platforms besides macOS will benefit from it. When do you plan to land it on the mainline? It would be great to have it in the coming LLVM 19 release. Please let me know if you need any help with reviewing the patch or anything.