<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 - const char * summary providers don't respect the bounds of char[] arrays"
href="https://bugs.llvm.org/show_bug.cgi?id=44649">44649</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>const char * summary providers don't respect the bounds of char[] arrays
</td>
</tr>
<tr>
<th>Product</th>
<td>lldb
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>enhancement
</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>labath@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>jdevlieghere@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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 }</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>