[lldb-dev] [Bug 37840] New: incorrect results of expression evaluation

via lldb-dev lldb-dev at lists.llvm.org
Mon Jun 18 17:46:13 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37840

            Bug ID: 37840
           Summary: incorrect results of expression evaluation
           Product: lldb
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: tianxiao.gu at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20442
  --> https://bugs.llvm.org/attachment.cgi?id=20442&action=edit
scripts to reproduce the issue.

## Overview

lldb command print/expression produces incorrect values.
This issue can be reproduced with lldb 7.0.

~~~
$ lldb -version
lldb version 7.0.0 (http://llvm.org/svn/llvm-project/lldb/trunk revision
334970)
  clang revision 334970
  llvm revision 334970
~~~

## Input Program

~~~~
#include <stdio.h>
#include <stdlib.h>
int main() {
  int32_t g_1974 = 1482617779;
  int16_t g_159  = -7666;
  printf("%d\n", g_1974 & g_159); // break here and see the result of (g_1974 &
g_159)
  return 0;
}
~~~


## Reproduce Steps

The attached zip file contains files that can reproduce the issue.

1. See results of lldb by running `run-lldb.sh`.

(lldb) target create "a.out"
Current executable set to 'a.out' (x86_64).
(lldb) command source -s 0 'lldb-cmds.txt'
Executing commands in '/home/t/bug1/lldb-cmds.txt'.
(lldb) breakpoint set -file test.c -line 7
Breakpoint 1: where = a.out`main + 45 at test.c:7, address = 0x0000000000400553
(lldb) process launch
1482613250
Process 20892 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400553 a.out`main at test.c:7
   4      int32_t g_1974 = 1482617779;
   5      int16_t g_159  = -7666;
   6      printf("%d\n", g_1974 & g_159);
-> 7      return 0;
   8    }

Process 20892 launched: '/home/t/bug1/a.out' (x86_64)
(lldb) print g_1974
(int32_t) $0 = 1482617779
(lldb) print g_159
(int16_t) $1 = -7666
(lldb) print (g_1974 & g_159)
(int) $2 = 57858 <--- HERE SHOULD BE 1482613250

2. Run `run-gdb.sh` for gdb.

Breakpoint 1 at 0x400553: file test.c, line 7.
1482613250

Breakpoint 1, main () at test.c:7
7         return 0;
$1 = 1482617779
$2 = -7666
$3 = 1482613250

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20180619/f4b79ac8/attachment.html>


More information about the lldb-dev mailing list