public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* gdb deletes watchpoint for local variables in scope
@ 2023-01-05 12:46 Varun Kumar Erigila
  2023-01-24 15:29 ` Simon Sobisch
  0 siblings, 1 reply; 2+ messages in thread
From: Varun Kumar Erigila @ 2023-01-05 12:46 UTC (permalink / raw)
  To: gdb

[-- Attachment #1: Type: text/plain, Size: 1137 bytes --]

Hello everyone,
              Gdb complains saying "Watchpoint <number> deleted because the program has left the block in which its expression is valid", even though the local variable is still in scope for RISC-V architecture.
              Test Code: Compiler Explorer (godbolt.org)<https://godbolt.org/z/dhb5K5KK4>

               Code compiled with clang(trunk):

        *   clang -g -static -c program.c
        *   riscv64-unknown-elf-gcc program.o -o program -march=rv64imac -mabi=lp64

              Gdb(12.1):

  *   riscv64-unknown-elf-gdb program
  *   break main
  *   set can-use-hw-watchpoints 0
  *   watch q
  *   continue
  *   Watchpoint 2 deleted because the program has left the block in
  *   which its expression is valid.
  *   0x00000000000101e0 in func () at watch_cond.c:2

              Even though the variable q is still in scope in main, gdb prints this message immediately after func() returns.
               I'm trying to debug gdb on update_watchpoint function where this message is originating from.

               Any suggestions on why gdb is behaving so.

regards
Varun

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

* Re: gdb deletes watchpoint for local variables in scope
  2023-01-05 12:46 gdb deletes watchpoint for local variables in scope Varun Kumar Erigila
@ 2023-01-24 15:29 ` Simon Sobisch
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Sobisch @ 2023-01-24 15:29 UTC (permalink / raw)
  To: varun.erigila; +Cc: GDB mailing list


If you did not do that already try adding
    -O -ggdb
to your clang invocation.

Also:
* Does it make any difference if you compile with gcc?
* Does "print q" still return something - and the same as before
   "watch q"?

Simon

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

end of thread, other threads:[~2023-01-24 15:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 12:46 gdb deletes watchpoint for local variables in scope Varun Kumar Erigila
2023-01-24 15:29 ` Simon Sobisch

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).