<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - lldb evaluates $N incorrectly when it was a printed register value"
   href="https://llvm.org/bugs/show_bug.cgi?id=30824">30824</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>lldb evaluates $N incorrectly when it was a printed register value
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.8
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>rsc@swtch.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Using Ubuntu 14.04 LTS's lldb-3.8 package to debug a trivial program, try
printing a register value (first print, so it ends up being $0) and then
referring to that print in a later expression. The later reference is
incorrectly evaluated:

$ echo 'int main() {return 0;}' | gcc -xc - -o a.out # any binary will do
$ lldb-3.8 --version
lldb version 3.8.0 ( revision )
$ lldb-3.8 a.out
(lldb) target create "a.out"
Current executable set to 'a.out' (x86_64).
(lldb) b main
Breakpoint 1: where = a.out`main, address = 0x00000000004004ed
(lldb) r
Process 62061 launched: '/usr/local/google/home/rsc/a.out' (x86_64)
Process 62061 stopped
* thread #1: tid = 62061, 0x00000000004004ed a.out`main, name = 'a.out', stop
reason = breakpoint 1.1
    frame #0: 0x00000000004004ed a.out`main
a.out`main:
->  0x4004ed <+0>: pushq  %rbp
    0x4004ee <+1>: movq   %rsp, %rbp
    0x4004f1 <+4>: movl   $0x0, %eax
    0x4004f6 <+9>: popq   %rbp
(lldb) print/x $rdi
(unsigned long) $0 = 0x0000000000000001
(lldb) print/x ($rdi)
(unsigned long) $1 = 0x0000000000000001
(lldb) print/x $0
(unsigned long) $0 = 0x0000000000000001
(lldb) print/x ($0)
(unsigned long) $2 = 0x00007ffff7ff6008  <<< WRONG!
(lldb) 

$0 and ($0) should evaluate to the same value. The final print is wrong. This
happens in any non-trivial expression involving printed register values.
Continuing:

(lldb) print/x $rdi
(unsigned long) $3 = 0x0000000000000001
(lldb) print/x $rsi
(unsigned long) $4 = 0x00007fffffffe058
(lldb) print/x $rdi+$rsi
(unsigned long) $5 = 0x00007fffffffe059
(lldb) print/x $3+$4
(unsigned long) $6 = 0x0000ffffeffec010  <<< WRONG!
(lldb)

And so on.

I see this on OS X with the Xcode toolchain lldb as well.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>