Discussion:
[PATCH] ARM: Do not use FP reg when on AAPCS
Marius Muench
2018-10-23 13:03:39 UTC
Permalink
Hi all,

GDB tries to dereference the frame pointer in arm_scan_prologue as a
last resort to create frame information.
However, the more recent AAPCS ABI does not make use of a frame pointer.

This patch checks whether the specified arm_abi is AAPCS before
dereferencing the "frame pointer". If so, just return as efforts to use
it for restoring frame information won't work.

Cheers,
Marius

gdb/ChangeLog
2018-10-23 Marius Muench <***@eurecom.fr>

* arm-tdeb.c (arm_scan_prologue): Don't dereference FP reg
when on aapcs.
---
gdb/arm-tdep.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 53eee76926..859ce71d6a 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -1801,6 +1801,10 @@ arm_scan_prologue (struct frame_info *this_frame,
CORE_ADDR frame_loc;
ULONGEST return_value;

+ /* AAPCS does not use a frame register, so we can abort here. */
+ if (gdbarch_tdep (gdbarch)->arm_abi == ARM_ABI_AAPCS)
+ return;
+
frame_loc = get_frame_register_unsigned (this_frame, ARM_FP_REGNUM);
if (!safe_read_memory_unsigned_integer (frame_loc, 4, byte_order,
&return_value))
Kevin Buettner
2018-10-23 17:16:49 UTC
Permalink
On Tue, 23 Oct 2018 15:03:39 +0200
Post by Marius Muench
Hi all,
GDB tries to dereference the frame pointer in arm_scan_prologue as a
last resort to create frame information.
However, the more recent AAPCS ABI does not make use of a frame pointer.
This patch checks whether the specified arm_abi is AAPCS before
dereferencing the "frame pointer". If so, just return as efforts to use
it for restoring frame information won't work.
Cheers,
Marius
gdb/ChangeLog
* arm-tdeb.c (arm_scan_prologue): Don't dereference FP reg
when on aapcs.
Typo on filename above. (s/tdeb/tdep/) While you're changing it,
please capitalize AAPCS too.

Otherwise, okay.

Kevin
Marius Muench
2018-10-24 11:40:09 UTC
Permalink
Post by Kevin Buettner
On Tue, 23 Oct 2018 15:03:39 +0200
Post by Marius Muench
gdb/ChangeLog
* arm-tdeb.c (arm_scan_prologue): Don't dereference FP reg
when on aapcs.
Typo on filename above. (s/tdeb/tdep/) While you're changing it,
please capitalize AAPCS too.
Otherwise, okay.
Kevin
Good catch, sorry for that. Here's the updated patch.

Thanks,
Marius

2018-10-24 Marius Muench <***@eurecom.fr>

* arm-tdep.c (arm_scan_prologue): Don't dereference FP reg
when on AAPCS.
---
gdb/arm-tdep.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 53eee76926..5cff22977d 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -1801,6 +1801,10 @@ arm_scan_prologue (struct frame_info *this_frame,
CORE_ADDR frame_loc;
ULONGEST return_value;

+ /* AAPCS does not use a frame register, so we can abort here. */
+ if (gdbarch_tdep (gdbarch)->arm_abi == ARM_ABI_AAPCS)
+ return;
+
frame_loc = get_frame_register_unsigned (this_frame, ARM_FP_REGNUM);
if (!safe_read_memory_unsigned_integer (frame_loc, 4, byte_order,
&return_value))
Kevin Buettner
2018-10-24 16:47:22 UTC
Permalink
Post by Marius Muench
* arm-tdep.c (arm_scan_prologue): Don't dereference FP reg
when on AAPCS.
Okay.

Kevin
Pedro Alves
2018-10-24 17:23:29 UTC
Permalink
Post by Marius Muench
+ /* AAPCS does not use a frame register, so we can abort here. */
There should be a double space after the period.
Post by Marius Muench
+ if (gdbarch_tdep (gdbarch)->arm_abi == ARM_ABI_AAPCS)
+ return;
Thanks,
Pedro Alves
Marius Muench
2018-10-24 19:37:07 UTC
Permalink
Post by Pedro Alves
Post by Marius Muench
+ /* AAPCS does not use a frame register, so we can abort here. */
There should be a double space after the period.
Post by Marius Muench
+ if (gdbarch_tdep (gdbarch)->arm_abi == ARM_ABI_AAPCS)
+ return;
Thanks,
Pedro Alves
Fair enough, updated version below.

gdb/ChangeLog:
2018-10-24 Marius Muench <***@eurecom.fr>

* arm-tdep.c (arm_scan_prologue): Don't dereference FP reg
when on AAPCS.
---
gdb/arm-tdep.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 53eee76926..0165e92527 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -1801,6 +1801,10 @@ arm_scan_prologue (struct frame_info *this_frame,
CORE_ADDR frame_loc;
ULONGEST return_value;

+ /* AAPCS does not use a frame register, so we can abort here. */
+ if (gdbarch_tdep (gdbarch)->arm_abi == ARM_ABI_AAPCS)
+ return;
+
frame_loc = get_frame_register_unsigned (this_frame, ARM_FP_REGNUM);
if (!safe_read_memory_unsigned_integer (frame_loc, 4, byte_order,
&return_value))
Kevin Buettner
2018-10-25 20:34:18 UTC
Permalink
On Wed, 24 Oct 2018 21:37:07 +0200
Post by Marius Muench
Fair enough, updated version below.
* arm-tdep.c (arm_scan_prologue): Don't dereference FP reg
when on AAPCS.
Looks good to me.

You can commit / push this now...

Kevin
Marius Muench
2018-10-26 12:13:37 UTC
Permalink
Thanks! I don't have push permissions, as it is my first contribution to
this project.
I can't find any documentation what to do in this case, scraping the ML,
I see three possible strategies:

(1) One of you push on my behalf.
(2) I send a new (clean) version of this patch, which gets pushed on my
behalf.
(3) Push permissions are set up.

What's your preferred strategy here?

Thanks a lot,
Marius
Post by Kevin Buettner
On Wed, 24 Oct 2018 21:37:07 +0200
Post by Marius Muench
Fair enough, updated version below.
* arm-tdep.c (arm_scan_prologue): Don't dereference FP reg
when on AAPCS.
Looks good to me.
You can commit / push this now...
Kevin
Tom Tromey
2018-11-06 17:53:35 UTC
Permalink
Marius> Thanks! I don't have push permissions, as it is my first contribution to
Marius> this project.
Marius> I can't find any documentation what to do in this case, scraping the ML,
Marius> I see three possible strategies:

Marius> (1) One of you push on my behalf.

Sorry about the delay on this.
I am pushing it now.

Marius> (2) I send a new (clean) version of this patch, which gets pushed on my
Marius> behalf.
Marius> (3) Push permissions are set up.

If you plan to do more work on gdb, you should consider getting
write-after-approval access. I think copyright paperwork is needed
first though.

Tom

Loading...