* GDB infinite loop when stepping on "while (1) i++;"
@ 2007-03-22 7:44 qinwei
2007-03-22 8:33 ` Kunal Parmar
0 siblings, 1 reply; 4+ messages in thread
From: qinwei @ 2007-03-22 7:44 UTC (permalink / raw)
To: gdb
Dears, problems are here:
gcc -o t -gdwarf-2 tp_while1.c
gdb t
(gdb) b main
Breakpoint 1 at 0x8048350: file tp_while1.c, line 3.
(gdb) r
Starting program: /home/qinwei/GJ283/code/build_linux/debug-gdb/t
Breakpoint 1, main () at tp_while1.c:3
3 int i = 10;
(gdb) n
4 while (1) i++;
(gdb) n
When program stops at "while (1) i++;", and printing "next" command will
cause gdb infinite loop.
The target are x86, score, or other? (gdb-6.6 release version)
Is the reason that the following dwarf-2 info:
"Special opcode 104: advance Address by 7 to 0x8048357 and Line by 1 to
4"
"Advance PC by 7 to 804835e"
which makes "while (1)" and "i++;" the same line number? And gdb will get
"stop_pc" from the range [0x8048357, 0x804835e] and will not stop?
How to solve it? Thanks!
int main (void)
{
int i = 10;
while (1) i++;
return 0;
}
Line Number Statements:
Extended opcode 2: set Address to 0x8048334
Special opcode 6: advance Address by 0 to 0x8048334 and Line by 1 to 2
Advance PC by constant 17 to 0x8048345
Special opcode 160: advance Address by 11 to 0x8048350 and Line by 1 to
3
Special opcode 104: advance Address by 7 to 0x8048357 and Line by 1 to 4
Advance PC by 7 to 804835e
Extended opcode 1: End of Sequence
08048334 <main>:
8048334: 55 push %ebp
8048335: 89 e5 mov %esp,%ebp
8048337: 83 ec 08 sub $0x8,%esp
804833a: 83 e4 f0 and $0xfffffff0,%esp
804833d: b8 00 00 00 00 mov $0x0,%eax
8048342: 83 c0 0f add $0xf,%eax
8048345: 83 c0 0f add $0xf,%eax
8048348: c1 e8 04 shr $0x4,%eax
804834b: c1 e0 04 shl $0x4,%eax
804834e: 29 c4 sub %eax,%esp
8048350: c7 45 fc 0a 00 00 00 movl $0xa,0xfffffffc(%ebp)
8048357: 8d 45 fc lea 0xfffffffc(%ebp),%eax
804835a: ff 00 incl (%eax)
804835c: eb f9 jmp 8048357 <main+0x23>
804835e: 90 nop
804835f: 90 nop
Best regards,
Qinwei
Mail qinwei@sunnorth.com.cn
Phone +86-010-62981668-2708
Fax +86-010-62985972
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: GDB infinite loop when stepping on "while (1) i++;"
2007-03-22 7:44 GDB infinite loop when stepping on "while (1) i++;" qinwei
@ 2007-03-22 8:33 ` Kunal Parmar
2007-03-22 9:15 ` qinwei
0 siblings, 1 reply; 4+ messages in thread
From: Kunal Parmar @ 2007-03-22 8:33 UTC (permalink / raw)
To: qinwei; +Cc: gdb
Hi,
On Thu, 2007-03-22 at 15:44 +0800, qinwei wrote:
> Dears, problems are here:
>
> gcc -o t -gdwarf-2 tp_while1.c
> gdb t
> (gdb) b main
> Breakpoint 1 at 0x8048350: file tp_while1.c, line 3.
> (gdb) r
> Starting program: /home/qinwei/GJ283/code/build_linux/debug-gdb/t
>
> Breakpoint 1, main () at tp_while1.c:3
> 3 int i = 10;
> (gdb) n
> 4 while (1) i++;
> (gdb) n
>
> When program stops at "while (1) i++;", and printing "next" command will
> cause gdb infinite loop.
> The target are x86, score, or other? (gdb-6.6 release version)
>
> Is the reason that the following dwarf-2 info:
>
> "Special opcode 104: advance Address by 7 to 0x8048357 and Line by 1 to
> 4"
> "Advance PC by 7 to 804835e"
>
> which makes "while (1)" and "i++;" the same line number? And gdb will get
> "stop_pc" from the range [0x8048357, 0x804835e] and will not stop?
Yes. The command `next' is used to move to advance execution to the next
line of the current function.
> How to solve it? Thanks!
Try using `nexti' of `stepi'.
Cheers,
Kunal
>
> int main (void)
> {
> int i = 10;
> while (1) i++;
> return 0;
> }
>
> Line Number Statements:
> Extended opcode 2: set Address to 0x8048334
> Special opcode 6: advance Address by 0 to 0x8048334 and Line by 1 to 2
> Advance PC by constant 17 to 0x8048345
> Special opcode 160: advance Address by 11 to 0x8048350 and Line by 1 to
> 3
> Special opcode 104: advance Address by 7 to 0x8048357 and Line by 1 to 4
> Advance PC by 7 to 804835e
> Extended opcode 1: End of Sequence
>
> 08048334 <main>:
> 8048334: 55 push %ebp
> 8048335: 89 e5 mov %esp,%ebp
> 8048337: 83 ec 08 sub $0x8,%esp
> 804833a: 83 e4 f0 and $0xfffffff0,%esp
> 804833d: b8 00 00 00 00 mov $0x0,%eax
> 8048342: 83 c0 0f add $0xf,%eax
> 8048345: 83 c0 0f add $0xf,%eax
> 8048348: c1 e8 04 shr $0x4,%eax
> 804834b: c1 e0 04 shl $0x4,%eax
> 804834e: 29 c4 sub %eax,%esp
> 8048350: c7 45 fc 0a 00 00 00 movl $0xa,0xfffffffc(%ebp)
> 8048357: 8d 45 fc lea 0xfffffffc(%ebp),%eax
> 804835a: ff 00 incl (%eax)
> 804835c: eb f9 jmp 8048357 <main+0x23>
> 804835e: 90 nop
> 804835f: 90 nop
>
> Best regards,
> Qinwei
> Mail qinwei@sunnorth.com.cn
> Phone +86-010-62981668-2708
> Fax +86-010-62985972
--
Kunal Parmar
Tools Team,
Celunite Inc. (www.celunite.com)
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: GDB infinite loop when stepping on "while (1) i++;"
2007-03-22 8:33 ` Kunal Parmar
@ 2007-03-22 9:15 ` qinwei
0 siblings, 0 replies; 4+ messages in thread
From: qinwei @ 2007-03-22 9:15 UTC (permalink / raw)
To: gdb
> > When program stops at "while (1) i++;", and printing "next" command
will
> > cause gdb infinite loop.
> > The target are x86, score, or other? (gdb-6.6 release version)
> >
> > Is the reason that the following dwarf-2 info:
> >
> > "Special opcode 104: advance Address by 7 to 0x8048357 and Line by 1
to
> > 4"
> > "Advance PC by 7 to 804835e"
> >
> > which makes "while (1)" and "i++;" the same line number? And gdb will
get
> > "stop_pc" from the range [0x8048357, 0x804835e] and will not stop?
>
> Yes. The command `next' is used to move to advance execution to the next
> line of the current function.
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re:GDB infinite loop when stepping on "while (1) i++;"
@ 2007-03-22 8:58 Wenbo Yang
2007-03-22 9:04 ` GDB " Wenbo Yang
0 siblings, 1 reply; 4+ messages in thread
From: Wenbo Yang @ 2007-03-22 8:58 UTC (permalink / raw)
To: qinwei; +Cc: gdb
> (gdb) n
> 4 while (1) i++;
> (gdb) n
I think there is nothing wrong. You let GDB next, it next. And your line is a infinite loop, so it never stops.
If "while (1) i++;" in you source code is put in a line. I think the debugging information should be a line. If not, maybe you compiler has problems. It is different with a single line function, i.e. "int a() {}".
If you want to step into, why not use "step"?
Wenbo
--
Wenbo Yang
SimpLight Nanoelectronics Ltd.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: GDB infinite loop when stepping on "while (1) i++;"
2007-03-22 8:58 Wenbo Yang
@ 2007-03-22 9:04 ` Wenbo Yang
0 siblings, 0 replies; 4+ messages in thread
From: Wenbo Yang @ 2007-03-22 9:04 UTC (permalink / raw)
To: qinwei; +Cc: gdb
>> (gdb) n
>> 4 while (1) i++;
>> (gdb) n
>
> I think there is nothing wrong. You let GDB next, it next. And your
> line is a infinite loop, so it never stops.
>
> If "while (1) i++;" in you source code is put in a line. I think the
> debugging information should be a line. If not, maybe you compiler has
> problems. It is different with a single line function, i.e. "int a() {}".
>
> If you want to step into, why not use "step"?
I'm sorry. Step should not work too. I mean "stepi". :-)
Wenbo
--
Wenbo Yang
SimpLight Nanoelectronics Ltd.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-03-22 9:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-22 7:44 GDB infinite loop when stepping on "while (1) i++;" qinwei
2007-03-22 8:33 ` Kunal Parmar
2007-03-22 9:15 ` qinwei
2007-03-22 8:58 Wenbo Yang
2007-03-22 9:04 ` GDB " Wenbo Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox