[PATCH] ARM: Do not use FP reg when on AAPCS

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] ARM: Do not use FP reg when on AAPCS

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
2018-10-23  Marius Muench  <[hidden email]>

       * 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))
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ARM: Do not use FP reg when on AAPCS

Kevin Buettner
On Tue, 23 Oct 2018 15:03:39 +0200
Marius Muench <[hidden email]> wrote:

> 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  <[hidden email]>
>
>        * 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
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ARM: Do not use FP reg when on AAPCS

Marius Muench
On 10/23/18 7:16 PM, Kevin Buettner wrote:

> On Tue, 23 Oct 2018 15:03:39 +0200
> Marius Muench <[hidden email]> wrote:
>> gdb/ChangeLog
>> 2018-10-23  Marius Muench  <[hidden email]>
>>
>>        * 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  <[hidden email]>

       * 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))
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ARM: Do not use FP reg when on AAPCS

Kevin Buettner
> 2018-10-24  Marius Muench  <[hidden email]>
>
>        * arm-tdep.c (arm_scan_prologue): Don't dereference FP reg
>        when on AAPCS.

Okay.

Kevin
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ARM: Do not use FP reg when on AAPCS

Pedro Alves-7
In reply to this post by Marius Muench
Tiny nit:

On 10/24/2018 12:40 PM, Marius Muench wrote:
>
> +      /* AAPCS does not use a frame register, so we can abort here. */

There should be a double space after the period.

> +      if (gdbarch_tdep (gdbarch)->arm_abi == ARM_ABI_AAPCS)
> +        return;

Thanks,
Pedro Alves
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ARM: Do not use FP reg when on AAPCS

Marius Muench-2
On 10/24/2018 07:23 PM, Pedro Alves wrote:

> Tiny nit:
>
> On 10/24/2018 12:40 PM, Marius Muench wrote:
>>
>> +      /* AAPCS does not use a frame register, so we can abort here. */
>
> There should be a double space after the period.
>
>> +      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  <[hidden email]>

       * 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))

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ARM: Do not use FP reg when on AAPCS

Kevin Buettner
On Wed, 24 Oct 2018 21:37:07 +0200
Marius Muench <[hidden email]> wrote:

> Fair enough, updated version below.
>
> gdb/ChangeLog:
> 2018-10-24  Marius Muench  <[hidden email]>
>
>        * 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
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ARM: Do not use FP reg when on AAPCS

Marius Muench
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


On 10/25/18 10:34 PM, Kevin Buettner wrote:

> On Wed, 24 Oct 2018 21:37:07 +0200
> Marius Muench <[hidden email]> wrote:
>
>> Fair enough, updated version below.
>>
>> gdb/ChangeLog:
>> 2018-10-24  Marius Muench  <[hidden email]>
>>
>>        * 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
>
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ARM: Do not use FP reg when on AAPCS

Tom Tromey-2
>>>>> "Marius" == Marius Muench <[hidden email]> writes:

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