<div dir="ltr"><div><div><span style="font-family:arial,sans-serif;font-size:13px">>Each object file format, like ELF, should know how the registers contexts for core files are saved and should be able to reproduce a register context for a thread. So I would modify ObjectFileELF to contain a virtual >instance of:</span><br>

</div><div><font face="arial, sans-serif">ELF core file's register arrangement is depends on OS, so defining it </font><span style="font-family:arial,sans-serif;font-size:13px">ObjectFileELF has the same problem.</span></div>

</div><div><font face="arial, sans-serif"><br></font></div>From quick look at the code, modifying "source/Plugins/Process/POSIX/RegisterContext_x86_64.cpp" to have both FreeBSD and Linux RegiserInfo structures should solve this.<div>

However this modification would touch lot of places and I prefer this modification go as separate patch.<div><br></div><div>Another approach is copying RegisterContext_x86_64.cpp:g_register_infos and related macros to elf-core plugin but I dont want to go in this route.</div>

<div><br></div><div style>So if you agree I will modify the current patch to include elf-core plugin only on Linux and FreeBSD platform.</div></div><div style>In the 2nd phase I will send patch to include elf-core in all platforms by modifying "POSIX/RegisterContext_x86_64.cpp".</div>

<div style><br></div><div style>Thanks<br></div><div style>Samuel</div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Feb 25, 2013 at 12:13 PM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">That is great that this works, but this doesn't compile on MacOSX. The main issue is that in RegisterContext_x86_64.h you are conditionally compiling in the GPR structure definition with:<br>


<br>
#ifdef __FreeBSD__<br>
#include "Plugins/Process/FreeBSD/RegisterContextFreeBSD_x86_64.h"<br>
#endif<br>
<br>
#ifdef __linux__<br>
#include "Plugins/Process/Linux/RegisterContextLinux_x86_64.h"<br>
#endif<br>
<br>
This ELF core plug-in should not be tied to the system on which it is compiled. We will need to make it more flexible so it can handle a core from either system.<br>
<br>
The Mach Core plug-in makes the ObjectFileMachO produce the thread register context in:<br>
<br>
lldb::RegisterContextSP<br>
ThreadMachCore::CreateRegisterContextForFrame (StackFrame *frame)<br>
{<br>
    lldb::RegisterContextSP reg_ctx_sp;<br>
    uint32_t concrete_frame_idx = 0;<br>
<br>
    if (frame)<br>
        concrete_frame_idx = frame->GetConcreteFrameIndex ();<br>
<br>
    if (concrete_frame_idx == 0)<br>
    {<br>
        if (!m_thread_reg_ctx_sp)<br>
        {<br>
            ProcessSP process_sp (GetProcess());<br>
<br>
            ObjectFile *core_objfile = static_cast<ProcessMachCore *>(process_sp.get())->GetCoreObjectFile ();<br>
            if (core_objfile)<br>
                m_thread_reg_ctx_sp = core_objfile->GetThreadContextAtIndex (GetID(), *this);<br>
        }<br>
        reg_ctx_sp = m_thread_reg_ctx_sp;<br>
    }<br>
    else if (m_unwinder_ap.get())<br>
    {<br>
        reg_ctx_sp = m_unwinder_ap->CreateRegisterContextForFrame (frame);<br>
    }<br>
    return reg_ctx_sp;<br>
}<br>
<br>
Note that at frame zero (concrete_frame_idx == 0) it asks the object file create the registers with: GetThreadContextAtIndex().<br>
<br>
Each object file format, like ELF, should know how the registers contexts for core files are saved and should be able to reproduce a register context for a thread. So I would modify ObjectFileELF to contain a virtual instance of:<br>


<br>
lldb::RegisterContextSP<br>
ObjectFileELF::CreateRegisterContextForFrame (StackFrame *frame);<br>
<div><div class="h5"><br>
<br>
<br>
<br>
On Feb 24, 2013, at 6:37 AM, Samuel Jacob <<a href="mailto:samueldotj@gmail.com">samueldotj@gmail.com</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> I herewith attached a patch to support ELF coredumps.<br>
> Currently it works for Linux X86-64 core files.<br>
> Please commit it.<br>
><br>
> Here is the output of a test program<br>
><br>
> $Debug+Asserts/bin/lldb ~/test/a.out -c ~/test/core<br>
> Core file '/mts/home3/jacobs/test/core' (x86_64) was loaded.<br>
> Process 0 stopped<br>
> * thread #1: tid = 0x0000, 0x00000000004004c4 a.out`function4(arg=0) + 16 at test.c:4, stop reason = signal SIGSEGV<br>
>     frame #0: 0x00000000004004c4 a.out`function4(arg=0) + 16 at test.c:4<br>
>    1    void function4(unsigned int arg)<br>
>    2    {<br>
>    3        char *local = 0;<br>
> -> 4        *local = 0;<br>
>    5    }<br>
>    6    void function3()<br>
>    7    {<br>
> bt<br>
> * thread #1: tid = 0x0000, 0x00000000004004c4 a.out`function4(arg=0) + 16 at test.c:4, stop reason = signal SIGSEGV<br>
>     frame #0: 0x00000000004004c4 a.out`function4(arg=0) + 16 at test.c:4<br>
>     frame #1: 0x00000000004004d7 a.out`function3 + 11 at test.c:8<br>
>     frame #2: 0x00000000004004e7 a.out`function2(arg=4195559) + 11 at test.c:11<br>
>     frame #3: 0x00000000004004f7 a.out`function1(arg1=0, arg2=140736328348032, str=0x00000000004004e7) + 3 at test.c:15<br>
>     frame #4: 0x0000000000400507 a.out`function1(arg1=0, arg2=140736328348048, str=0x00000000004004f7) + 19 at test.c:15<br>
>     frame #5: 0x00007fbcdfe6c76d libc.so.6`__libc_start_main + 237<br>
>     frame #6: 0x00000000004003f9 a.out`_start + 41<br>
><br>
> The following may be used as commit log:<br>
><br>
> Added Process plugin to support ELF coredump files.<br>
> Added member functions in ObjectFileELF to access segment headers and data.<br>
> Modified POSIX dynamic loader plugin to get AUXV data from core files if core-file is used.<br>
> Modified Linux Process plugin so that it will skip handling core files(CanDebug()).<br>
><br>
> Regards,<br>
> Samuel<br>
</div></div>> <elf-core.diff><br>
<br>
</blockquote></div><br></div>