Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Richard Earnshaw (lists)" <Richard.Earnshaw@arm.com>
To: Alexander Fedotov <alfedotov@gmail.com>, newlib@sourceware.org
Cc: gdb@sourceware.org
Subject: Re: AArch64 calling convention in assembly code
Date: Wed, 01 Aug 2018 15:49:00 -0000	[thread overview]
Message-ID: <cc3376cb-0735-bff6-7417-77eb3f08675a@arm.com> (raw)
In-Reply-To: <CAN8C2CrGOT9GrV=AhY1JB_8A1owNA_3nBaMs8xUffwHALf3h2A@mail.gmail.com>

On 01/08/18 14:28, Alexander Fedotov wrote:
>>> Pushing LR on the stack resolves a problem
> FP of course, not LR.
> So the correct code must be like this:
> 
> _cpu_init_hook:
>     stp        x29, x30, [sp, #-16]!
>     mov        x29, sp
>     bl        _init_vectors
>     bl        _flat_map
>     ldp        x29, x30, [sp], #16
>     ret
> 
> But still my point is that GDB should catch such an error and do not hang.
> 
> Alex
> 
> On Tue, Jul 31, 2018 at 9:34 PM, Alexander Fedotov <alfedotov@gmail.com> wrote:
>> Hello dear AArch64 maintainers
>> Please look into code snippet below from newlib/libgloss/aarch64/rdimon-aem-el3.
>>
>> Seems to me this code violates AArch64 calling convention and actually
>> breaks debugging in GDB. GDB tries to unwind call stack and got
>> endless reentrancy...
>>
>> FUNCTION (_cpu_init_hook):
>>     sub    sp, sp, #16
>>     str    x30, [sp, xzr]
>>     bl    _init_vectors
>>     bl    _flat_map
>>     ldr    x30, [sp, xzr]
>>     add    sp, sp, #16
>>     ret
>>
>>
>> We have couple of calls there (_init_vectors, _flat_map). If you'll
>> try to step into any subroutine you will found that GDB hangs and
>> can't step anymore.
>>
>> Pushing LR on the stack resolves a problem.

X30 is LR.

All we really need is a CFI unwind record that GDB can understand.

R.

>>
>> So my message is that:
>> 1. Current code in _cpu_init_hook is incorrect
>> 2. GDB should handle this and do not hang
>>
>> Alex
> 
> 
> 


  reply	other threads:[~2018-08-01 15:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAN8C2CqGq4OUNXq5=ur87nqwVjYF-D6aAcVKGGB1pQT1S0b6Jg@mail.gmail.com>
2018-08-01 13:28 ` Alexander Fedotov
2018-08-01 15:49   ` Richard Earnshaw (lists) [this message]
2018-08-01 15:56     ` Alexander Fedotov
2018-08-01 16:19       ` Richard Earnshaw (lists)
2018-08-01 18:03         ` Jeff Johnston

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cc3376cb-0735-bff6-7417-77eb3f08675a@arm.com \
    --to=richard.earnshaw@arm.com \
    --cc=alfedotov@gmail.com \
    --cc=gdb@sourceware.org \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox