OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 1:49 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: CPP Exception Support
PostPosted: Sun Feb 04, 2018 8:03 am 
Offline

Joined: Sun Nov 08, 2015 1:20 pm
Posts: 6
Hi Guys,

I working on CPP exception support in my Kernel since a couple of weeks. I was able to write an Stack Unwinder based on the dwarf information in the eh_debug section. Now I'm working on the ABI specific parts for the actual exception support.

My current code is able to find the landingpad of the exception and return to that position. I have a basic implementation of __cxa_allocate_exception that deals with my memory management, __cxa_throw calls the _Unwind_RaiseException routine that searches for the landing pad in the search phase and then in the second phase actually installs the found context.
This is the point where I'm a little bit stuck. If my catch is defined as catch(...) (so no type information just catch everything) this works fine. As soon as I try to catch a specific exception (catch(int a)) it gets more complicated. My understanding is that __cxa_begin_catch returns a void* pointer to the memory where __cxa_allocate_exception has reserved memory. If I just hard code specific address I can catch the exception with the actual exception information.
What I don't understand is how I can pass the input parameter to __cxa_begin_catch. I digged through the gcc code and found the __builtin_eh_return function which I use to install the new Instruction Pointer and Stack Pointer. Which works as __cxa_begin_catch is called and as soon as I return from that function I'm in the correct landingpad.
Does anyone has any insight on where __cxa_begin_catch gets his parameter? I already tried pushing it onto the stack before calling __builtin_eh_return but that gcc build in function seems to pop this.

Thanks for your help. This is a very specific topic where not much information exist around the web.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 96 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group