public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug rust/31401] New: Error when placing watchpoint rust debug build
@ 2024-02-19 14:20 jlmacedomatos at gmail dot com
  2024-02-20 14:37 ` [Bug rust/31401] " tromey at sourceware dot org
  2024-02-21 16:00 ` jlmacedomatos at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: jlmacedomatos at gmail dot com @ 2024-02-19 14:20 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31401

            Bug ID: 31401
           Summary: Error when placing watchpoint rust debug build
           Product: gdb
           Version: 15.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: rust
          Assignee: unassigned at sourceware dot org
          Reporter: jlmacedomatos at gmail dot com
  Target Milestone: ---

When trying to place a watchpoint on a rust binary build with `cargo build`

it throws an error:
```
Breakpoint 1, 0x000055555555c8b0 in main.rs:1 ()
(gdb) watch *0x123456789
Attempt to take contents of a non-pointer value.
(gdb) watch *(char*)0x123456789
unexpected token
```

if you put it between quote it seems to at least place the watchpoint but its
unclear if its working or not
```
fn main() {
    let mut a = 123;
    a = 321;
    a = 555;
    a = 222;
}

Breakpoint 1, example::main () at src/main.rs:2
2           let mut a = 123;
(gdb) next
3           a = 321;
(gdb) p &a
$1 = (*mut i32) 0x7fffffffd214
(gdb) watch "0x7fffffffd214"
Watchpoint 2: "0x7fffffffd214"
(gdb) watch a
Hardware watchpoint 3: a
(gdb) next

Watchpoint 2: "0x7fffffffd214"

Old value = "0x7fffffffd214"
New value = "0x7fffffffd214"

Watchpoint 2: "0x7fffffffd214"

Old value = "0x7fffffffd214"
New value = "0x7fffffffd214"

Watchpoint 2: "0x7fffffffd214"

Old value = "0x7fffffffd214"
New value = "0x7fffffffd214"
example::main () at src/main.rs:4
4           a = 555;
```

also using -l/-location doesn't seem to make any difference
```
(gdb) watch -l *0x123456789
Attempt to take contents of a non-pointer value.
(gdb) watch -location *0x123456789
Attempt to take contents of a non-pointer value.
(gdb) 
```

Took the examples from:
https://sourceware.org/gdb/current/onlinedocs/gdb.html/Set-Watchpoints.html#Set-Watchpoints

How to reproduce:
```
mkdir example
cd example
cargo init .
cargo build
cargo build --release
gdb -nh -nx -ex 'b main.rs:1' -ex 'run' -ex 'watch *0x12345678' --batch
target/debug/example
gdb -nh -nx -ex 'b main.rs:1' -ex 'run' -ex 'watch *0x12345678' --batch
target/release/example
```

Both of the examples above work normally in the release build.

Tested on gdb 13.1 and on master
Rust versions 1.64, 1.66

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-21 16:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-19 14:20 [Bug rust/31401] New: Error when placing watchpoint rust debug build jlmacedomatos at gmail dot com
2024-02-20 14:37 ` [Bug rust/31401] " tromey at sourceware dot org
2024-02-21 16:00 ` jlmacedomatos at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).