<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Regression: JITed Code Debugging Broken on LLDB 6.0 Release Branch"
   href="https://bugs.llvm.org/show_bug.cgi?id=36209">36209</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Regression: JITed Code Debugging Broken on LLDB 6.0 Release Branch
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lldb
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>lldb-dev@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>stefan.graenitz@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19797" name="attach_19797" title="Full logs from LLDB 6.0, LLDB 5.0 and LLDB 4.0">attachment 19797</a> <a href="attachment.cgi?id=19797&action=edit" title="Full logs from LLDB 6.0, LLDB 5.0 and LLDB 4.0">[details]</a></span>
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 <stdio.h>

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 (0x00000000) 
(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: 0x00007ffff7fee004 JIT(0x754850)`jitbp() at hellow.cpp:4
   1    #include <stdio.h>
   2    
   3    void jitbp() {
-> 4      printf("Hello World!\n");
   5    }
   6    
   7    int main() {
(lldb) n
Hello World!
Process 16807 stopped
* thread #1, name = 'lli', stop reason = step over
    frame #0: 0x00007ffff7fee01c JIT(0x754850)`jitbp() at hellow.cpp:5
   2    
   3    void jitbp() {
   4      printf("Hello World!\n");
-> 5    }
   6    
   7    int 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 (0x00000000) 
(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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>