From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24145 invoked by alias); 11 Nov 2002 17:50:00 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 24131 invoked from network); 11 Nov 2002 17:49:58 -0000 Received: from unknown (HELO crack.them.org) (65.125.64.184) by sources.redhat.com with SMTP; 11 Nov 2002 17:49:58 -0000 Received: from nevyn.them.org ([66.93.61.169] ident=mail) by crack.them.org with asmtp (Exim 3.12 #1 (Debian)) id 18BKZU-0008G8-00; Mon, 11 Nov 2002 13:50:08 -0600 Received: from drow by nevyn.them.org with local (Exim 3.36 #1 (Debian)) id 18BIi9-0001qN-00; Mon, 11 Nov 2002 12:50:57 -0500 Date: Mon, 11 Nov 2002 09:50:00 -0000 From: Daniel Jacobowitz To: Stuart Hughes Cc: gdb Subject: Re: software single step Message-ID: <20021111175057.GA5802@nevyn.them.org> Mail-Followup-To: Stuart Hughes , gdb References: <3DC52A84.18B7BF92@zee2.com> <20021104012251.GB7441@nevyn.them.org> <3DCFE500.8185926F@zee2.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3DCFE500.8185926F@zee2.com> User-Agent: Mutt/1.5.1i X-SW-Source: 2002-11/txt/msg00109.txt.bz2 On Mon, Nov 11, 2002 at 05:12:32PM +0000, Stuart Hughes wrote: > Daniel Jacobowitz wrote: > > > > On Sun, Nov 03, 2002 at 08:54:12AM -0500, Stuart Hughes wrote: > > > Hi, > > > > > > I'm trying to use gdb/gdbserver to debug a strong-arm target. I'm > > > having problems with single stepping. If I try to step into the loop > > > shown below, it simply runs on printing all 10 loop iterations. > > > > > > for ( i = 0; i < 10 ; i++ ) { > > > printf("loop count = %d\n", i); > > > } > > > > [snip] > > > > > > Has anyone else seen this problem ? Does anyone know of a work around, > > > or a fix ? > > > > gdbserver doesn't implement software single step; the connected GDB > > client handles it. You may want to 'set debug target 1' and 'set debug > > remote 1', and watch for differences. > > > Hi Daniel, > > I've investigted this further. I tried the things you suggested, but > I'm finding it hard to correlate the output from the native sesion and > the remote session. The native session outputs a a huge slew of output > before it first manages to control the inferior. > > Looking at the ouput from the remote debugging session, it looks okay, > it seems to insert a breakpoint (I'm guessing, it writes 10300be5 to the > point to break at), and then continues. When the inferior wakes up, it > sends back a 'T' packet. I thought this should stop gdb, but it > doesn't. The session carries on, without any user intervention until > the end of the program. > > The code of the loop looks like this when disassembled: > > for ( i = 0; i < 10 ; i++ ) { > 84b0: e3a03000 mov r3, #0 ; 0x0 > 84b4: e50b3010 str r3, [fp, -#16] > 84b8: e51b3010 ldr r3, [fp, -#16] > 84bc: e3530009 cmp r3, #9 ; 0x9 > 84c0: da000000 ble 84c8 > 84c4: ea000006 b 84e4 > printf("loop count = %d\n", i); > 84c8: e59f0020 ldr r0, [pc, #32] ; 84f0 > > 84cc: e51b1010 ldr r1, [fp, -#16] > 84d0: ebffff9d bl 834c <_init+0x64> > 84d4: e51b3010 ldr r3, [fp, -#16] > 84d8: e2833001 add r3, r3, #1 ; 0x1 > 84dc: e50b3010 str r3, [fp, -#16] > 84e0: eafffff4 b 84b8 > } > > I've attached the output captured from 'set debug remote' FYI. > > > Do you have any suggestions where I could look next ?? Well, first let me explain the relevant bits of your transcript. What it's trying to do is to step one instruction at a time until the source line changes. > Sending packet: $m4000ca4c,4#ec...Ack > Packet received: 98040000 > Sending packet: $M4000ca4c,4:01009fef#31...Ack > Packet received: OK > Sending packet: $m84b0,4#cb...Ack > Packet received: 0030a0e3 > Sending packet: $M84b0,4:01009fef#10...Ack > Packet received: OK Set the shared library breakpoint and main breakpoint. > Sending packet: $Hc0#db...Ack > Packet received: OK > Sending packet: $c#63...Ack > Packet received: T050b:e4fcffbf;0d:d4fcffbf;0f:b0840000; Continue; stopped at main. > Sending packet: $M4000ca4c,4:98040000#9b...Ack > Packet received: OK > Sending packet: $M84b0,4:0030a0e3#d1...Ack > Packet received: OK Remove breakpoints. > Breakpoint 1, main () at hello.c:7 > 7 for ( i = 0; i < 10 ; i++ ) { > (gdb) step > Sending packet: $m84b0,4#cb...Ack > Packet received: 0030a0e3 > Sending packet: $m84b4,4#cf...Ack > Packet received: 10300be5 > Sending packet: $M84b4,4:01009fef#14...Ack > Packet received: OK > Sending packet: $Hc0#db...Ack > Packet received: OK > Sending packet: $c#63...Ack > Packet received: T050b:e4fcffbf;0d:d4fcffbf;0f:b4840000; Insert only the breakpoint at $pc+4, and continue; then we stop at $pc+4. 0x84b4. > Sending packet: $M84b4,4:10300be5#d9...Ack > Packet received: OK Remove the temporary step breakpoint. > Sending packet: $m4000ca4c,4#ec...Ack > Packet received: 98040000 > Sending packet: $M4000ca4c,4:01009fef#31...Ack > Packet received: OK > Sending packet: $m84b0,4#cb...Ack > Packet received: 0030a0e3 > Sending packet: $M84b0,4:01009fef#10...Ack > Packet received: OK Reinsert breakpoints. > Sending packet: $m84b4,4#cf...Ack > Packet received: 10300be5 > Sending packet: $g#67...Ack > Packet received: 0100000014fdffbf1cfdffbf0000000024e7014014fdffbfe882000040d9004001000000a084000080071240e4fcffbfe8fcffbfd4fcffbff0d20340b48400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Fetch the instruction and the register values... > Sending packet: $m84b8,4#d3...Ack > Packet received: 10301be5 > Sending packet: $M84b8,4:01009fef#18...Ack > Packet received: OK Set a step breakpoint at 0x84b8. > Sending packet: $Hc0#db...Ack > Packet received: OK > Sending packet: $c#63...Ack > Packet received: T050b:e4fcffbf;0d:d4fcffbf;0f:b8840000; Continue, stopping at 0x84b8. > Sending packet: $M84b8,4:10301be5#de...Ack > Packet received: OK > Sending packet: $m84b8,4#d3...Ack > Packet received: 10301be5 > Sending packet: $g#67...Ack > Packet received: 0100000014fdffbf1cfdffbf0000000024e7014014fdffbfe882000040d9004001000000a084000080071240e4fcffbfe8fcffbfd4fcffbff0d20340b88400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 > Sending packet: $m84bc,4#fe...Ack > Packet received: 090053e3 > Sending packet: $M84bc,4:01009fef#43...Ack > Packet received: OK > Sending packet: $c#63...Ack > Packet received: T050b:e4fcffbf;0d:d4fcffbf;0f:bc840000; Same, to 0x84bc. > Sending packet: $M84bc,4:090053e3#e1...Ack > Packet received: OK > Sending packet: $m84bc,4#fe...Ack > Packet received: 090053e3 > Sending packet: $g#67...Ack > Packet received: 0100000014fdffbf1cfdffbf0000000024e7014014fdffbfe882000040d9004001000000a084000080071240e4fcffbfe8fcffbfd4fcffbff0d20340bc8400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 > Sending packet: $m84c0,4#cc...Ack > Packet received: 000000da > Sending packet: $M84c0,4:01009fef#11...Ack > Packet received: OK > Sending packet: $c#63...Ack > Packet received: T050b:e4fcffbf;0d:d4fcffbf;0f:c0840000; Same, to 0x84c0. > Sending packet: $M84c0,4:000000da#cb...Ack > Packet received: OK > Sending packet: $m84c0,4#cc...Ack > Packet received: 000000da > Sending packet: $g#67...Ack > Packet received: 0100000014fdffbf1cfdffbf0000000024e7014014fdffbfe882000040d9004001000000a084000080071240e4fcffbfe8fcffbfd4fcffbff0d20340c08400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 > Sending packet: $m84c4,4#d0...Ack > Packet received: 060000ea > Sending packet: $M84c4,4:01009fef#15...Ack > Packet received: OK > Sending packet: $c#63...Ack > Packet received: T050b:e4fcffbf;0d:d4fcffbf;0f:c4840000; Same, to 0x84c4. Now this is the strange one. What happened? It seems to have mispredicted the next instruction when placing the breakpoint; the branch was presumably taken. You might want to debug arm_get_next_pc when the argument is 0x84c0, and see how it's making this decision. > Sending packet: $M84c4,4:060000ea#d6...Ack > Packet received: OK > Sending packet: $m84c4,4#d0...Ack > Packet received: 060000ea > Sending packet: $g#67...Ack > Packet received: 0f0000000f0000000f0000000a00000024e7014014fdffbfe882000040d9004001000000a084000080071240e4fcffbff0081240d4fcffbfd4840000c48400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 > Sending packet: $m84e4,4#d2...Ack > Packet received: 0030a0e3 > Sending packet: $M84e4,4:01009fef#17...Ack > Packet received: OK > Sending packet: $c#63...Ack > Packet received: T050b:e4fcffbf;0d:d4fcffbf;0f:e4840000; Same, to 0x84e4. > Sending packet: $M84e4,4:0030a0e3#d8...Ack > Packet received: OK > Sending packet: $m84e4,4#d2...Ack > Packet received: 0030a0e3 > Sending packet: $g#67...Ack > Packet received: 0f0000000f0000000f0000000a00000024e7014014fdffbfe882000040d9004001000000a084000080071240e4fcffbff0081240d4fcffbfd4840000e48400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 > Sending packet: $m84e4,4#d2...Ack > Packet received: 0030a0e3 > Sending packet: $m84e4,4#d2...Ack > Packet received: 0030a0e3 > Sending packet: $m84a0,4#ca...Ack > Packet received: 0dc0a0e1 > Sending packet: $m84a4,4#ce...Ack > Packet received: 00d82de9 > Sending packet: $m84a8,4#d2...Ack > Packet received: 04b04ce2 > Sending packet: $m84ac,4#fd...Ack > Packet received: 04d04de2 > Sending packet: $m84b0,4#cb...Ack > Packet received: 01009fef > Sending packet: $m84b4,4#cf...Ack > Packet received: 10300be5 > Sending packet: $m84b8,4#d3...Ack > Packet received: 10301be5 > Sending packet: $m84bc,4#fe...Ack > Packet received: 090053e3 > Sending packet: $m84c0,4#cc...Ack > Packet received: 000000da > Sending packet: $M4000ca4c,4:98040000#9b...Ack > Packet received: OK > Sending packet: $M84b0,4:0030a0e3#d1...Ack > Packet received: OK > 10 return 0; > (gdb) quit -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer