This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tdep/19401] AVR: gdb uses 2 byte breakpoints even for 4 byte insns which leads to illegal instruction


https://sourceware.org/bugzilla/show_bug.cgi?id=19401

Mike Frysinger <vapier at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |avr-elf
                 CC|vapier at gentoo dot org           |
          Component|sim                         |tdep
            Summary|AVR: simulator fails with   |AVR: gdb uses 2 byte
                   |illegal instruction when    |breakpoints even for 4 byte
                   |function call present as    |insns which leads to
                   |argument                    |illegal instruction

--- Comment #3 from Mike Frysinger <vapier at gentoo dot org> ---
when the breakpoint is hit, the $pc is 0x14a, but that's the middle of the
insn:
(gdb) disassemble main
Dump of assembler code for function main:
   0x00000148 <+0>:     call    0x11a   ;  0x11a <bar>
   0x0000014c <+4>:     call    0x132   ;  0x132 <foo>
so when execution resumes, you get an invalid insn.

this is because gdb uses a 2 byte breakpoint for all insns:
gdb/avr-tdep.c:
static const unsigned char *
avr_breakpoint_from_pc (struct gdbarch *gdbarch,
            CORE_ADDR *pcptr, int *lenptr)
{
    static const unsigned char avr_break_insn [] = { 0x98, 0x95 };
    *lenptr = sizeof (avr_break_insn);
    return avr_break_insn;
}

so it's a bug in gdb -- it shouldn't be splitting insns, or at least when it
does, it should rewind properly.

the sim is behaving correctly -- gdb told it to run an invalid insn :).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]