public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "joe at lothan dot net" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug breakpoints/30335] Watchpoints aren't triggered when calling program functions
Date: Tue, 11 Apr 2023 16:39:55 +0000	[thread overview]
Message-ID: <bug-30335-4717-LopLSHrNaq@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-30335-4717@http.sourceware.org/bugzilla/>

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

--- Comment #1 from Joe Lothan <joe at lothan dot net> ---
Forgot to mention that breakpoints do trigger when calling program functions,
it's just watchpoints that do not. And interestingly enough, when a breakpoint
is hit, it allows the watchpoint to be hit later in the program function
execution.

Using the same example: 
$ gdb -q ./test
Reading symbols from ./test...
(gdb) break main
Breakpoint 1 at 0x118b: file test.c, line 11.
(gdb) run
Starting program: /home/joe/test
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, main () at test.c:11
11          for (int i = 0; i < 5; i++)
(gdb) watch towatch
Hardware watchpoint 2: towatch
(gdb) break change_var
Breakpoint 3 at 0x555555555151: file test.c, line 6.
(gdb) call change_var()

Breakpoint 3, change_var () at test.c:6
6           towatch ++;
The program being debugged stopped while in a function called from GDB.
Evaluation of the expression containing the function
(change_var) will be abandoned.
When the function is done executing, GDB will silently stop.
(gdb) finish
Run till exit from #0  change_var () at test.c:6

Hardware watchpoint 2: towatch

Old value = 0
New value = 1
change_var () at test.c:7
7           printf("new towatch: %d\n", towatch);
(gdb)

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

      reply	other threads:[~2023-04-11 16:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11 16:15 [Bug breakpoints/30335] New: " joe at lothan dot net
2023-04-11 16:39 ` joe at lothan dot net [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-30335-4717-LopLSHrNaq@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).