public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
* FYI bpstat evaluations vs. breakpoint hits
@ 2010-11-02  7:38 Jan Kratochvil
  0 siblings, 0 replies; only message in thread
From: Jan Kratochvil @ 2010-11-02  7:38 UTC (permalink / raw)
  To: Phil Muldoon; +Cc: archer

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-11-02  7:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-02  7:38 FYI bpstat evaluations vs. breakpoint hits Jan Kratochvil

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