public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Phil Muldoon <pmuldoon@redhat.com>
Cc: archer@sourceware.org
Subject: FYI bpstat evaluations vs. breakpoint hits
Date: Tue, 02 Nov 2010 07:38:00 -0000	[thread overview]
Message-ID: <20101102073801.GA27966@host0.dyn.jankratochvil.net> (raw)

Hi Phil,

bpstats get evaluated first, incl. breakpoint conditions.  Only then infrun
decides whether to act on that breakpoint.  Sometimes it does not have to.

Therefore the conditionals may get evaluated more times than the breakpoint is
hit.

With the WIP patch
	[patch] Fix stale tp->step_resume_breakpoint
	http://sourceware.org/ml/gdb-patches/2010-11/msg00010.html

(as otherwise GDB internal errors) and

#include <stdio.h>
int cond (void) { puts ("cond"); return 1; } 
int func (void) { return 0; }
int main (void)
{
  int i = func ();
  return 0;
}

gcc -o 2 2.c -Wall -g;./gdb -nx ./2 -ex start -ex 'b *$pc+5 if cond ()' -ex disass -ex "echo Let's roll\n" -ex 'set debug infrun 0' -ex next 

GNU gdb (GDB) 7.2.50.20101102-cvs
x86_64-fedora14snapshot-linux-gnu

Breakpoint 2 at 0x4004f1: file 2.c, line 6.
Dump of assembler code for function main:
   0x00000000004004e4 <+0>:	push   %rbp
   0x00000000004004e5 <+1>:	mov    %rsp,%rbp
   0x00000000004004e8 <+4>:	sub    $0x10,%rsp
=> 0x00000000004004ec <+8>:	callq  0x4004d9 <func>
   0x00000000004004f1 <+13>:	mov    %eax,-0x4(%rbp)
   0x00000000004004f4 <+16>:	mov    $0x0,%eax
   0x00000000004004f9 <+21>:	leaveq 
   0x00000000004004fa <+22>:	retq   
End of assembler dump.
Let's roll
cond
cond

Breakpoint 2, 0x00000000004004f1 in main () at 2.c:6
6	  int i = func ();
(gdb) _


Therefore any actions upon breakpoint should be executed somewhere around
bpstat_do_actions, which happens much later than bpstat_stop_status and its
bpstat_check_breakpoint_conditions.


Regards,
Jan

                 reply	other threads:[~2010-11-02  7:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20101102073801.GA27966@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=archer@sourceware.org \
    --cc=pmuldoon@redhat.com \
    /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).