This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[committed] avr: improve prologue scanner
- From: Tristan Gingold <gingold at adacore dot com>
- To: gdb-patches ml <gdb-patches at sourceware dot org>
- Date: Tue, 10 Nov 2009 11:13:41 +0100
- Subject: [committed] avr: improve prologue scanner
Hi,
this patch improves the avr prologue scanner by decoding instructions
that allocates a small amount of
stack.
Tristan.
2009-11-10 Tristan Gingold <gingold@adacore.com>
* avr-tdep.c (avr_scan_prologue): Decode instructions used for
small stack allocation.
Adjust code for prologue that don't write SP.
*** avr-tdep.c 10 Nov 2009 10:05:47 -0000 1.118
--- avr-tdep.c 10 Nov 2009 10:13:19 -0000
***************
*** 654,659 ****
--- 654,678 ----
fprintf_unfiltered (gdb_stderr,
_("Hit end of prologue while scanning
pushes\n"));
+ /* Handle static small stack allocation using rcall or push. */
+
+ while (scan_stage == 1 && vpc < len)
+ {
+ insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order);
+ if (insn == 0xd000) /* rcall .+0 */
+ {
+ info->size += gdbarch_tdep (gdbarch)->call_length;
+ vpc += 2;
+ }
+ else if (insn == 0x920f) /* push r0 */
+ {
+ info->size += 1;
+ vpc += 2;
+ }
+ else
+ break;
+ }
+
/* Second stage of the prologue scanning.
Scan:
in r28,__SP_L__
***************
*** 707,724 ****
};
insn = extract_unsigned_integer (&prologue[vpc], 2,
byte_order);
- vpc += 2;
if ((insn & 0xff30) == 0x9720) /* sbiw r28,XXX */
! locals_size = (insn & 0xf) | ((insn & 0xc0) >> 2);
else if ((insn & 0xf0f0) == 0x50c0) /* subi r28,lo8(XX) */
{
locals_size = (insn & 0xf) | ((insn & 0xf00) >> 4);
insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order);
vpc += 2;
! locals_size += ((insn & 0xf) | ((insn & 0xf00) >> 4) << 8);
}
else
! return pc_beg + vpc;
/* Scan the last part of the prologue. May not be present for
interrupt
or signal handler functions, which is why we set the
prologue type
--- 726,746 ----
};
insn = extract_unsigned_integer (&prologue[vpc], 2,
byte_order);
if ((insn & 0xff30) == 0x9720) /* sbiw r28,XXX */
! {
! locals_size = (insn & 0xf) | ((insn & 0xc0) >> 2);
! vpc += 2;
! }
else if ((insn & 0xf0f0) == 0x50c0) /* subi r28,lo8(XX) */
{
locals_size = (insn & 0xf) | ((insn & 0xf00) >> 4);
+ vpc += 2;
insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order);
vpc += 2;
! locals_size += ((insn & 0xf) | ((insn & 0xf00) >> 4)) << 8;
}
else
! return pc_beg + vpc;
/* Scan the last part of the prologue. May not be present for
interrupt
or signal handler functions, which is why we set the
prologue type