[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug in avr-gdb? was:Re: [avr-gcc-list] AVR simulator and interrupts
From: |
Theodore A. Roth |
Subject: |
Re: Bug in avr-gdb? was:Re: [avr-gcc-list] AVR simulator and interrupts |
Date: |
Fri, 16 Jul 2004 13:06:09 -0700 (PDT) |
On Fri, 16 Jul 2004, Klaus Rudolph wrote:
> Hi James,
>
> I could rproduce the problem also with actual simulavr.
> After traceing through the gdb output I could found
> a senseless continue command which is send from gdb to simulator.
> The result is endless running of simulavr which is exact what the
> gdb wants but what is not what the user want from gdb :-)
>
>
> I think we have a bug in gdb for avr.
I don't think this is a bug in gdb and it's not something that can be
easily worked around in gdb.
The problem is gdb doesn't have enough information to step through the
"__vectors" function. In reality, __vectors is not a function at all,
but a jump table. The assembler marks it as a function because of this
(from gcrt1.S):
.section .vectors,"ax",@progbits
.global __vectors
.func __vectors
__vectors:
I think it's done that way to allow locating the .vectors section at
flash addr 0x00 (someone correct me if I'm wrong). This confuses gdb
since it thinks it's looking at a function expecting it to return at
some point. Instead, we jmp/rjmp out of __vectors directly in the
interrupt handler.
I just hacked simulavr-0.1.2.1 to automatically perform an extra step
when it vectors into the __vectors table (see attached patch). This
makes the 'step' command step right into the interrupt when it fires off
which is what I would expect the user to expect. This is similar in idea
to avarice's --ignore-intr option.
There's still a problem with the 'next' command. In my modified example
program (see test.c attached), if I tell gdb to 'next' when it's at line
28 in this code,
25 while (1)
26 {
27 /* Chew up some MCU cycles. */
28 clk += TCNT0;
29 //dummy -= TCNT0;
30 }
it goes into an infinite loop of stepping (but not jumping into
__vectors). This falls under the "don't expect gdb to do the right thing
if you compile with optimizations" category. A simple work around in
this case is to just set a breakpoint at line 28.
If I uncomment line 29, then 'next' works fine and I never jump int
__vectors or the interrupt.
---
Ted Roth
PGP Key ID: 0x18F846E9
Jabber ID: address@hidden
test.c
Description: Text document
simulavr-step-vect.diff
Description: Text document
- Bug in avr-gdb? was:Re: [avr-gcc-list] AVR simulator and interrupts, Klaus Rudolph, 2004/07/16
- Re: Bug in avr-gdb? was:Re: [avr-gcc-list] AVR simulator and interrupts,
Theodore A. Roth <=
- Re: Bug in avr-gdb? was:Re: [avr-gcc-list] AVR simulator and interrupts, Klaus Rudolph, 2004/07/18
- Re: Bug in avr-gdb? was:Re: [avr-gcc-list] AVR simulator and interrupts, Theodore A. Roth, 2004/07/19
- Re: Bug in avr-gdb? was:Re: [avr-gcc-list] AVR simulator and interrupts, Klaus Rudolph, 2004/07/20
- Re: Bug in avr-gdb? was:Re: [avr-gcc-list] AVR simulator and interrupts, jamesfit, 2004/07/20
- Re: Bug in avr-gdb? was:Re: [avr-gcc-list] AVR simulator and interrupts, James Fitzsimons, 2004/07/20
- [avr-gcc-list] Winavr / gcc include files, Steve @ Franks Development, LLC, 2004/07/21
- Re: [avr-gcc-list] Winavr / gcc include files, E. Weddington, 2004/07/21
- Re: [avr-gcc-list] Winavr / gcc include files, E. Weddington, 2004/07/21