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

            Bug ID: 45998
           Summary: volatile lead to inconsistent behaviors between
                    step-by-step and stepi-by-stepi in lldb
           Product: lldb
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev@lists.llvm.org
          Reporter: yangyib...@hust.edu.cn
                CC: jdevliegh...@apple.com, llvm-b...@lists.llvm.org

$ clang --version
clang version 11.0.0 (/home/yibiao/.cache/yay/llvm-git/llvm-project
871beba234a83a2a02da9dedbd59b91a1bfbd7af)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ lldb --version
lldb version 11.0.0
  clang revision 871beba234a83a2a02da9dedbd59b91a1bfbd7af
  llvm revision 871beba234a83a2a02da9dedbd59b91a1bfbd7af


$ clang -g -O3 small.c; 

$ lldb a.out
(lldb) target create "a.out"
Current executable set to '/home/yibiao/Debugger/a.out' (x86_64).
(lldb) b main
Breakpoint 1: where = a.out`main + 5 at small.c:8:6, address =
0x0000000000401125
(lldb) r
Process 2172958 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 2172958 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000401125 a.out`main at small.c:8:6
   5    
   6    int main() {
   7      char a;
-> 8      pa = &a;
   9    
   10     foo(pa);
   11   
(lldb) s
Process 2172958 stopped
* thread #1, name = 'a.out', stop reason = step in
    frame #0: 0x000000000040112c a.out`main at small.c:10
   7      char a;
   8      pa = &a;
   9    
-> 10     foo(pa);
   11   
   12     return 0;
   13   }
(lldb) s
Process 2172958 stopped
* thread #1, name = 'a.out', stop reason = step in
    frame #0: 0x000000000040112c a.out`main [inlined] foo(ptr="") at
small.c:3:8
   1    char *pa;
   2    void foo(volatile char *ptr) {
-> 3      *ptr = 'x';
   4    }
   5    
   6    int main() {
   7      char a;
(lldb) s
Process 2172958 stopped
* thread #1, name = 'a.out', stop reason = step in
    frame #0: 0x0000000000401131 a.out`main at small.c:12:3
   9    
   10     foo(pa);
   11   
-> 12     return 0;
   13   }
(lldb)


/*************************************
We can find that Line #3 is hit by lldb when step-by-step.
However, Line #3 will be not hit by lldb when stepi-by-stepi
***************************************/


$ lldb a.out
(lldb) target create "a.out"
Current executable set to '/home/yibiao/Debugger/a.out' (x86_64).
(lldb) b main
Breakpoint 1: where = a.out`main + 5 at small.c:8:6, address =
0x0000000000401125
(lldb) r
Process 2173507 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 2173507 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000401125 a.out`main at small.c:8:6
   5    
   6    int main() {
   7      char a;
-> 8      pa = &a;
   9    
   10     foo(pa);
   11   
(lldb) si
Process 2173507 stopped
* thread #1, name = 'a.out', stop reason = instruction step into
    frame #0: 0x000000000040112c a.out`main at small.c:10
   7      char a;
   8      pa = &a;
   9    
-> 10     foo(pa);
   11   
   12     return 0;
   13   }
(lldb) si
Process 2173507 stopped
* thread #1, name = 'a.out', stop reason = instruction step into
    frame #0: 0x0000000000401131 a.out`main at small.c:12:3
   9    
   10     foo(pa);
   11   
-> 12     return 0;
   13   }
(lldb) 


$ cat small.c
char *pa;
void foo(volatile char *ptr) {
  *ptr = 'x';
}

int main() {
  char a;
  pa = &a;

  foo(pa);

  return 0;
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
lldb-dev mailing list
lldb-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev

Reply via email to