[llvm-bugs] [Bug 44649] New: const char * summary providers don't respect the bounds of char[] arrays

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jan 24 03:01:00 PST 2020


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

            Bug ID: 44649
           Summary: const char * summary providers don't respect the
                    bounds of char[] arrays
           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: labath at google.com
                CC: jdevlieghere at apple.com, llvm-bugs at lists.llvm.org

If I have a char[3] variable, it seems reasonable to have the summary provider
stop at the third character even if it did not encounter a nul character.

This is what gdb does. Lldb currently does not do that:

$ cat /tmp/a.cc 
struct A {
  char arr[3];
  char a, b, c;
} a;

int main() {
  a.arr[0] = 'a';
  a.arr[1] = 'r';
  a.arr[2] = 'r';
  a.a = 0x42;
  a.b = 0x47;
  a.c = 0x42;
  return 0;
}
$ bin/clang /tmp/a.cc -g -o /tmp/a.out
$ bin/lldb /tmp/a.out 
(lldb) target create "/tmp/a.out"
Current executable set to '/tmp/a.out' (x86_64).
(lldb) target stop-hook add -o "v a"
Stop hook #1 added.
(lldb) b main
Breakpoint 1: where = a.out`main + 13 at a.cc:7:12, address =
0x000000000040112d
(lldb) r
Process 15123 launched: '/tmp/a.out' (x86_64)
(A) ::a = (arr = "", a = '\0', b = '\0', c = '\0')

Process 15123 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x000000000040112d a.out`main at a.cc:7:12
   4    } a;
   5    
   6    int main() {
-> 7      a.arr[0] = 'a';
   8      a.arr[1] = 'r';
   9      a.arr[2] = 'r';
   10     a.a = 0x42;
(lldb) n
(A) ::a = (arr = "a", a = '\0', b = '\0', c = '\0')

Process 15123 stopped
* thread #1, name = 'a.out', stop reason = step over
    frame #0: 0x0000000000401135 a.out`main at a.cc:8:12
   5    
   6    int main() {
   7      a.arr[0] = 'a';
-> 8      a.arr[1] = 'r';
   9      a.arr[2] = 'r';
   10     a.a = 0x42;
   11     a.b = 0x47;
(lldb) 
(A) ::a = (arr = "ar", a = '\0', b = '\0', c = '\0')

Process 15123 stopped
* thread #1, name = 'a.out', stop reason = step over
    frame #0: 0x000000000040113d a.out`main at a.cc:9:12
   6    int main() {
   7      a.arr[0] = 'a';
   8      a.arr[1] = 'r';
-> 9      a.arr[2] = 'r';
   10     a.a = 0x42;
   11     a.b = 0x47;
   12     a.c = 0x42;
(lldb) 
(A) ::a = (arr = "arr", a = '\0', b = '\0', c = '\0')

Process 15123 stopped
* thread #1, name = 'a.out', stop reason = step over
    frame #0: 0x0000000000401145 a.out`main at a.cc:10:7
   7      a.arr[0] = 'a';
   8      a.arr[1] = 'r';
   9      a.arr[2] = 'r';
-> 10     a.a = 0x42;
   11     a.b = 0x47;
   12     a.c = 0x42;
   13     return 0;
(lldb) 
(A) ::a = (arr = "arrB", a = 'B', b = '\0', c = '\0')

Process 15123 stopped
* thread #1, name = 'a.out', stop reason = step over
    frame #0: 0x000000000040114d a.out`main at a.cc:11:7
   8      a.arr[1] = 'r';
   9      a.arr[2] = 'r';
   10     a.a = 0x42;
-> 11     a.b = 0x47;
   12     a.c = 0x42;
   13     return 0;
   14   }
(lldb) 
(A) ::a = (arr = "arrBG", a = 'B', b = 'G', c = '\0')

Process 15123 stopped
* thread #1, name = 'a.out', stop reason = step over
    frame #0: 0x0000000000401155 a.out`main at a.cc:12:7
   9      a.arr[2] = 'r';
   10     a.a = 0x42;
   11     a.b = 0x47;
-> 12     a.c = 0x42;
   13     return 0;
   14   }
(lldb) 
(A) ::a = (arr = "arrBGB", a = 'B', b = 'G', c = 'B')

Process 15123 stopped
* thread #1, name = 'a.out', stop reason = step over
    frame #0: 0x000000000040115d a.out`main at a.cc:13:3
   10     a.a = 0x42;
   11     a.b = 0x47;
   12     a.c = 0x42;
-> 13     return 0;
   14   }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200124/16587bb0/attachment.html>


More information about the llvm-bugs mailing list