From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8241 invoked by alias); 2 Nov 2010 07:38:20 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 8082 invoked by uid 22791); 2 Nov 2010 07:38:18 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Date: Tue, 02 Nov 2010 07:38:00 -0000 From: Jan Kratochvil To: Phil Muldoon Cc: archer@sourceware.org Subject: FYI bpstat evaluations vs. breakpoint hits Message-ID: <20101102073801.GA27966@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2010-q4/txt/msg00026.txt.bz2 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 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 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