[llvm-dev] Exception handling support for a target

陳韋任 via llvm-dev llvm-dev at lists.llvm.org
Tue Jan 16 04:25:59 PST 2018


2018-01-16 18:39 GMT+08:00 David Chisnall <David.Chisnall at cl.cam.ac.uk>:

> On 16 Jan 2018, at 10:18, Tim Northover via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
> >
> >>  Is the above list complete? Do I understand their purpose correctly
> (sort
> >> of)?
> >
> > There are components in libunwind (especially) and compiler-rt you'll
> > also need to look at if you're not on top of an existing runtime.
>
> The libUnwind parts are relatively small.  You need to write two assembly
> functions, one which dumps all registers to memory and one which restores
> them.  Next you need to add enum values for all of your registers that
> correspond to their DWARF register numbres.  You then need to implement a
> C++ class that sets and gets register values from the in-memory structure
> based on the DWARF number.  This is usually quite small because the easiest
> way of dumping the registers is to store each register set contiguously in
> memory in the same order that as their DWARF numbers, so you end up with a
> struct something like this:
>
> struct MyArch_Regs
> {
>         int64_t GPRs[32];
> };
>
> And the get function is just doing GPRs[RegNo - MyArch_GPR0].
>
> LLVM’s libUnwind has a very clean structure.  Adding MIPS support took a
> couple of hours.  All of the unwinder support is generic other than the
> mapping from DWARF register numbers to some concrete mechanism for getting
> and setting them.


​Thanks for the hint, David. Right now I just leverage on existing runtime
(libstdc++ and libgcc). Your hint would help if I move to libUwind.​

-- 
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180116/5e8879cd/attachment.html>


More information about the llvm-dev mailing list