[llvm-dev] Exceptions not getting caught on bare-metal target (original) (raw)

Dominik Montada via llvm-dev llvm-dev at lists.llvm.org
Fri Jul 3 03:22:11 PDT 2020


Hi,

We're working on adding exception handling support for a downstream bare-metal target. I read through the LLVM exception handling docs [1] and went through some patches from other backends to understand what parts we need to implement.

We're now at a point were it feels like it should work, but unfortunately exceptions are still not getting caught. Our target uses DWARF unwinding.

The problem seems to be that findFDE cannot find a CIE which covers the given PC. We're not sure why this is though. From [2] and other backend implementations we gathered that unw_getcontext saves the PC of the call-site, i.e. the return address of unw_getcontext and that is that we are doing as well.

Is there some other target hook in LLVM or libunwind that we need to implement in order to get this to work? Or are we not emitting enough/correct CFI instructions (currently we only emit .cfi_def_cfa in the prolog, we don't have any callee-saved registers).

Speaking of calling conventions: our target is special in that registers are automatically pushed to a special save area upon executing a call, and automatically restored when executing a return instruction. I assume we need to implement some target specific code in stepWithDwarf to handle this?

Any help in this regard would be highly appreciated!

Cheers,

Dominik

[1] https://llvm.org/docs/ExceptionHandling.html [2] https://www.nongnu.org/libunwind/man/unw_getcontext(3).html

--

Dominik Montada Email: dominik.montada at hightec-rt.com HighTec EDV-Systeme GmbH Phone: +49 681 92613 19 Europaallee 19 Fax: +49-681-92613-26 D-66113 Saarbrücken WWW: http://www.hightec-rt.com

Managing Director: Vera Strothmann Register Court: Saarbrücken, HRB 10445, VAT ID: DE 138344222

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

-------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 6822 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200703/b05bfe3e/attachment.bin>



More information about the llvm-dev mailing list