[lldb-dev] [Bug 36209] New: Regression: JITed Code Debugging Broken on LLDB 6.0 Release Branch
https://bugs.llvm.org/show_bug.cgi?id=36209 Bug ID: 36209 Summary: Regression: JITed Code Debugging Broken on LLDB 6.0 Release Branch Product: lldb Version: 6.0 Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: All Bugs Assignee: lldb-dev@lists.llvm.org Reporter: stefan.graen...@gmail.com CC: llvm-b...@lists.llvm.org Created attachment 19797 --> https://bugs.llvm.org/attachment.cgi?id=19797&action=edit Full logs from LLDB 6.0, LLDB 5.0 and LLDB 4.0 With LLDB built from branch release_60 it is no longer possible to set a breakpoint in JIT-compiled code. This worked well for release_50. LLDB 6.0 fails with error message: warning: failed to set breakpoint site at 0x4 for breakpoint 1.1: error: 2 sending the breakpoint request Repro with a default configuration of LLVM/Clang/LLDB on Linux Mint 18: $ cat hellow.cpp #include void jitbp() { printf("Hello World!\n"); } int main() { jitbp(); return 0; } $ clang -g -c -S -emit-llvm hellow.cpp $ ./lli hellow.ll Hello World! $ ./lldb -- lli (lldb) target create "lli" Current executable set to 'lli' (x86_64). (lldb) b jitbp Breakpoint 1: no locations (pending). WARNING: Unable to resolve breakpoint to any actual locations. (lldb) log enable lldb jit (lldb) r hellow.ll Actual output with LLDB 6.0: lldb JITLoaderGDB::SetJITBreakpoint looking for JIT register hook lldb JITLoaderGDB::SetJITBreakpoint looking for JIT register hook Process 17664 launched: '/media/LLVM/llvm60/build-debug-clang-lld-lldb/bin/lli' (x86_64) intern-state JITLoaderGDB::SetJITBreakpoint looking for JIT register hook ... intern-state JITLoaderGDB::SetJITBreakpoint looking for JIT register hook intern-state JITLoaderGDB::SetJITBreakpoint setting JIT breakpoint intern-state JITLoaderGDB::JITDebugBreakpointHit hit JIT breakpoint intern-state JITLoaderGDB::ReadJITDescriptorImpl registering JIT entry at 0x781230 (3432 bytes) warning: failed to set breakpoint site at 0x4 for breakpoint 1.1: error: 2 sending the breakpoint request 1 location added to breakpoint 1 warning: failed to set breakpoint site at 0x4 for breakpoint 1.1: error: 2 sending the breakpoint request Hello World! intern-state JITLoaderGDB::JITDebugBreakpointHit hit JIT breakpoint intern-state JITLoaderGDB::ReadJITDescriptorImpl unregistering JIT entry at 0x781230 Process 17664 exited with status = 0 (0x) (lldb) q Expected output, tested with LLDB 5.0 and LLDB 4.0: JITLoaderGDB::SetJITBreakpoint looking for JIT register hook JITLoaderGDB::SetJITBreakpoint looking for JIT register hook Process 16807 launched: '/media/LLVM/llvm50/build-debug-clang-lld-lldb/bin/lli' (x86_64) JITLoaderGDB::SetJITBreakpoint looking for JIT register hook ... JITLoaderGDB::SetJITBreakpoint looking for JIT register hook JITLoaderGDB::SetJITBreakpoint setting JIT breakpoint JITLoaderGDB::JITDebugBreakpointHit hit JIT breakpoint JITLoaderGDB::ReadJITDescriptorImpl registering JIT entry at 0x754850 (3432 bytes) 1 location added to breakpoint 1 Process 16807 stopped * thread #1, name = 'lli', stop reason = breakpoint 1.1 frame #0: 0x77fee004 JIT(0x754850)`jitbp() at hellow.cpp:4 1#include 2 3void jitbp() { -> 4 printf("Hello World!\n"); 5} 6 7int main() { (lldb) n Hello World! Process 16807 stopped * thread #1, name = 'lli', stop reason = step over frame #0: 0x77fee01c JIT(0x754850)`jitbp() at hellow.cpp:5 2 3void jitbp() { 4 printf("Hello World!\n"); -> 5} 6 7int main() { 8 jitbp(); (lldb) c Process 16807 resuming JITLoaderGDB::JITDebugBreakpointHit hit JIT breakpoint JITLoaderGDB::ReadJITDescriptorImpl unregistering JIT entry at 0x754850 Process 16807 exited with status = 0 (0x) (lldb) q The same issue can be reproduced with a slightly modified version of LLDB that allows debugging JITed code on Mac OS X. Please find attached the full logs. -- You are receiving this mail because: You are the assignee for the bug.___ lldb-dev mailing list lldb-dev@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
[lldb-dev] Testcase startup boiler-plate...
I've seen a couple new testcases coming past that copy the standard: exe = self.getBuildArtifact("a.out") self.target = self.dbg.CreateTarget(exe) self.assertTrue(self.target, VALID_TARGET) main_bp = self.target.BreakpointCreateByName("main") self.assertTrue(main_bp, VALID_BREAKPOINT) self.process = self.target.LaunchSimple( None, None, self.get_process_working_directory()) self.assertTrue(self.process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. self.assertTrue(self.process.GetState() == lldb.eStateStopped, STOPPED_DUE_TO_BREAKPOINT) etc. to make a target, set a breakpoint by name (or source regex), run the target, and make sure it hits the breakpoint. That's really my fault, I should have provided a better way to do that a long time ago - apologies - but now you should be able to do all that with: (target, process, thread, breakpoint) = lldbutil.run_to_name_breakpoint(self, "main") or the equivalent "run_to_source_breakpoint". I bet a good percentage of the text in the testsuite is this repetitive pattern. Simplifying it would for instance have made Adrian's task of building out of tree much less tedious... It would be great if folks writing new tests would use this form instead, and if you're touching a test and have itchy fingers (or generally find time hanging heavy on your hands) by all means convert tests to this form! If there's anything else that needs to get added to make these functions broadly useable, please ping me and I'll add it. For reference, there's a sample test in: packages/Python/lldbsuite/test/sample_test/TestSampleTest.py that does it this way and is a better starting point for new tests. Thanks! Jim ___ lldb-dev mailing list lldb-dev@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev