Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Neo Jia <cjia@cse.unl.edu>
To: yang xiaoli <alula418@hotmail.com>
Cc: gdb@sourceware.org
Subject: Re: local gdb could not stop at breakpoint?
Date: Tue, 29 Nov 2005 04:41:00 -0000	[thread overview]
Message-ID: <438BD8D4.7050901@cse.unl.edu> (raw)
In-Reply-To: <BAY109-F1314B406A3F6B107890CCB874B0@phx.gbl>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=GB2312, Size: 2654 bytes --]

I think it would be better to post your assembly code instead of the
source code, since we are in the gdb community. : )

So, I am guessing that your compiler does some optimization for your
code, since I don't know the option you used.

If you compile this code with -O2, you will get the following assembly code.

02000194 <main>:
{
int a, b;
a = 10;
b = 20;
printf("hello world\n"); <-- gdb should stop your problem here.
2000194: e1a0c00d mov r12, sp
2000198: e92dd800 stmdb sp!, {r11, r12, lr, pc}
200019c: e59f0014 ldr r0, [pc, #14] ; 20001b8 <main+0x24>
20001a0: e24cb004 sub r11, r12, #4 ; 0x4
20001a4: eb000178 bl 200078c <_IO_printf>
printf("a+b=%d", a+b);
20001a8: e59f000c ldr r0, [pc, #c] ; 20001bc <main+0x28>
20001ac: e3a0101e mov r1, #30 ; 0x1e
20001b0: eb000175 bl 200078c <_IO_printf>
}

If you compile this code without any optimization, you will get the
following assmebly code.

02000194 <main>:
#include <stdlib.h>
int main()
{
2000194: e1a0c00d mov r12, sp
2000198: e92dd800 stmdb sp!, {r11, r12, lr, pc}
200019c: e24cb004 sub r11, r12, #4 ; 0x4
20001a0: e24dd008 sub sp, sp, #8 ; 0x8
int a, b;
a = 10;
20001a4: e3a0300a mov r3, #10 ; 0xa
20001a8: e50b3010 str r3, [r11, -#16]
b = 20;
20001ac: e3a03014 mov r3, #20 ; 0x14
20001b0: e50b3014 str r3, [r11, -#20]
printf("hello world\n");
20001b4: e59f001c ldr r0, [pc, #1c] ; 20001d8 <main+0x44>
20001b8: eb00017c bl 20007b0 <_IO_printf>
printf("a+b=%d", a+b);
20001bc: e51b3010 ldr r3, [r11, -#16]
20001c0: e51b2014 ldr r2, [r11, -#20]
20001c4: e0833002 add r3, r3, r2
20001c8: e59f000c ldr r0, [pc, #c] ; 20001dc <main+0x48>
20001cc: e1a01003 mov r1, r3
20001d0: eb000176 bl 20007b0 <_IO_printf>
20001d4: ea000001 b 20001e0 <main+0x4c>
20001d8: 0202d758 andeq sp, r2, #23068672 ; 0x1600000
20001dc: 0202d768 andeq sp, r2, #27262976 ; 0x1a00000
}


yang xiaoli wrote:

> I compile gdb6.0 for arm , now it works, but when I debug a program
> and set breakpoint at a line, it does't stop at breakpoint, it runs
> over, for example like this:
>
> (gdb)l
> 1 #include <stdlib.h>
> 2 int main()
> 3 {
> 4 int a, b;
> 5 6 a = 10;
> 7 b = 20;
> 8 printf("hello world\n");
> 9 printf("a+b= %d", a+b);
> (gdb)b 6
> (gdb)r
> Startomg program...
> hello world
> a+b= 30
>
> Program exited normally (gdb)
>
> when I see breakpoints using command "info b" ,it display the
> breakpoints information normally, why it does not stop at breakpoints?
>
> _________________________________________________________________
> Ãâ·ÑÏÂÔØ MSN Explorer: http://explorer.msn.com/lccn 


-- 
I would remember that if researchers were not ambitions
probably today we haven't the technology we are using!


  reply	other threads:[~2005-11-29  4:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-29  4:27 yang xiaoli
2005-11-29  4:41 ` Neo Jia [this message]
2005-11-29 10:13 ` Jim Blandy
2005-11-30  2:47   ` yang xiaoli
2005-11-30  4:23     ` Jim Blandy
2005-11-30  9:42       ` Daniel Jacobowitz

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=438BD8D4.7050901@cse.unl.edu \
    --to=cjia@cse.unl.edu \
    --cc=alula418@hotmail.com \
    --cc=gdb@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