public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@acm.org>
To: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Debian m68k <debian-68k@lists.debian.org>,
	linux-m68k <linux-m68k@lists.linux-m68k.org>,
	"gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: Fwd: Re: Registers used for exception handling on Linux/m68k?
Date: Thu, 1 Oct 2020 08:27:48 -0400	[thread overview]
Message-ID: <e4191f44-74ff-c4bc-6824-f2425ff403ef@acm.org> (raw)
In-Reply-To: <d17cc651-6b81-5e79-8fb4-243d8d4e9033@physik.fu-berlin.de>

On 10/1/20 5:49 AM, John Paul Adrian Glaubitz wrote:
> Hi Nathan!
> 
> On 9/29/20 7:58 PM, Nathan Sidwell wrote:
>> On 9/29/20 11:22 AM, John Paul Adrian Glaubitz wrote:
>>>
>>> I'm looking for an information regarding exception handling on Linux/m68k, in particular
>>> I need to know what registers are used by the ABI in order to implement the functions
>>> "getExceptionPointerRegister" and "getExceptionSelectorRegister" in the M680x0 backend
>>> in LLVM [1], [2].
>>
>> I don;t know what those functions are, but from their names they seem to be related to figuring out the exception object and type?
> 
> I think so. I'm not a compiler expert hence my questions :-).
> 
>> Do you understand the itanium ABI's unwinding mechanism --
>> 1) follow stack to get to landing pad.
>> 2) invoke landing pad to see if it wants to catch
>> 3) if not, continue following stack
>> 4) once we've found one to catch it, we need to unwind properly, which involves invoking cleanups. and eventually getting to the catcher
>>
>> invoking the landing pad means passing (a) an integer telling it what's happening, and (b) a pointer to data.
> 
> This seems to be the data that I need. I just need to understand how that works.

I realized I'd got some details confused (it's been quite a while since 
I've dealt with this code).

When locating a landing pad to catch the exception the unwinder uses a 
personality routine, and passes it some data from the unwind table. 
That's a regular call in the context of the unwinder.  (It's called a 
personality routine, because it's keyed to the language trying to catch 
the exception.)  The landing pads are not called in this case.

The landing pad executes in the context of the function it's a landing 
pad for.  So the SP must be the expected one, all the (callee-save) 
registers must be as they were at the point of calling the function that 
threw, and everything below the SP is dead.  Of course the unwinder's 
frame is somewhere down the stack, and now dead.  eh_return is the thing 
that (a) adjusts the SP and (b) indirect jumps to the landing pad.  That 
is what the EH_Return macro is.  That code is in the unwinder, and is 
compiler-specific.


> 
>>> I looked into the GCC source code to find the corresponding parts but I could only find
>>> the macros prefixed with "EH_" [4] which I didn't fully understand.
>>
>> Those are the bits you want.  one of those is the selector (0?) and the other is the data pointer (1?).
> 
> OK. But aren't they passed through particular registers on m68k? Or is this something specific
> to LLVM?

Sorry, I think I confused the issue by conflating the eh_return 
(compiler-specific) with the passing of eh objects to the landing pad 
(ABI-specified).

do you know what those 2 functions you mention provide on say x86?  Then 
it might be easier to map onto 68k.

nathan

-- 
Nathan Sidwell

  reply	other threads:[~2020-10-01 12:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <f9732b0d-9b7d-ba90-7897-1353d6912e24@acm.org>
     [not found] ` <c8c4ef5a-e4bc-f9e5-7a76-74f32f084bd6@acm.org>
2020-10-01  9:49   ` Fwd: Re: Registers used for exception handling on Linux/m68k? John Paul Adrian Glaubitz
2020-10-01 12:27     ` Nathan Sidwell [this message]
2020-10-01 12:32       ` John Paul Adrian Glaubitz
2020-10-01 12:46         ` Nathan Sidwell
2020-10-01 12:51           ` John Paul Adrian Glaubitz

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=e4191f44-74ff-c4bc-6824-f2425ff403ef@acm.org \
    --to=nathan@acm.org \
    --cc=debian-68k@lists.debian.org \
    --cc=gcc@gcc.gnu.org \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=linux-m68k@lists.linux-m68k.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