<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_extra"><br><div class="gmail_quote">2018-01-16 18:39 GMT+08:00 David Chisnall <span dir="ltr"><<a href="mailto:David.Chisnall@cl.cam.ac.uk" target="_blank">David.Chisnall@cl.cam.ac.uk</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 16 Jan 2018, at 10:18, Tim Northover via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
><br>
>>  Is the above list complete? Do I understand their purpose correctly (sort<br>
>> of)?<br>
><br>
> There are components in libunwind (especially) and compiler-rt you'll<br>
> also need to look at if you're not on top of an existing runtime.<br>
<br>
</span>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:<br>
<br>
struct MyArch_Regs<br>
{<br>
        int64_t GPRs[32];<br>
};<br>
<br>
And the get function is just doing GPRs[RegNo - MyArch_GPR0].<br>
<br>
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.</blockquote><div><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">​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.​</div></div><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Wei-Ren Chen (陳韋任)<br>Homepage: <a href="https://people.cs.nctu.edu.tw/~chenwj" target="_blank">https://people.cs.nctu.edu.tw/~chenwj</a></div></div></div>
</div></div>