[lldb][Linux][x86] Watchpoint expression hit reports garbage
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Setting watchpoint on a data segment variable reports garbage on being hit:
```
(lldb) target create "wp"
Current executable set to '/root/dhruv/wp' (x86_64).
```
```
(lldb) p &g
(int *) 0x000000000040400c
(lldb) watch set expression -- 0x000000000040400c
Watchpoint created: Watchpoint 1: addr = 0x0040400c size = 8 state = enabled type = m
watchpoint spec = '0x000000000040400c'
watchpoint resources:
#0: addr = 0x00404008 size = 8
#1: addr = 0x00404010 size = 8
Watchpoint 1 hit:
new value: "d"
(lldb) c
Process 3608952 resuming
g address: 0x40400c, value: 100
Watchpoint 1 hit:
old value: "\xc8"
new value: "\xc8"
Process 3608952 stopped
* thread #1, name = 'wp', stop reason = watchpoint 1
frame #0: 0x000000000040116c wp`main at wp.c:6:7
3 int main() {
4 printf("g address: %p, value: %d\n", &g, g);
5 g = 200;
-> 6 g = 300;
7 printf("Final g: %d\n", g);
8 return 0;
9 }
(lldb) p g
(int) 200
(lldb) c
Process 3608952 resuming
Watchpoint 1 hit:
old value: ",\U00000001"
new value: ",\U00000001"
Process 3608952 stopped
* thread #1, name = 'wp', stop reason = watchpoint 1
frame #0: 0x0000000000401177 wp`main at wp.c:7:29
4 printf("g address: %p, value: %d\n", &g, g);
5 g = 200;
6 g = 300;
-> 7 printf("Final g: %d\n", g);
8 return 0;
9 }
```
In contrast, it works fine with `watchpoint set variable g` :
```
(lldb) c
Process 3606443 resuming
g address: 0x40400c, value: 100
Watchpoint 1 hit:
old value: 100
new value: 200
Process 3606443 stopped
* thread #1, name = 'wp', stop reason = watchpoint 1
frame #0: 0x000000000040116c wp`main at wp.c:6:7
3 int main() {
4 printf("g address: %p, value: %d\n", &g, g);
5 g = 200;
-> 6 g = 300;
7 printf("Final g: %d\n", g);
8 return 0;
9 }
```
Contributor guide
Research direction
Reproduce the issue with the supplied wp.c example on Linux x86 using an expression watchpoint, then compare it with `watchpoint set variable g`. Trace the LLDB watchpoint value-reporting path and verify that hits report the actual old and new values, such as 100 and 200, rather than garbage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, linux
- Domain
- devtools, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100