<div dir="ltr"><div style>Greg and others,</div><div style><br></div><div style>Update on the Linux coredump:</div><div style>It works if use "image load --file xxx .text yyyy".</div><div style><br></div><div style>
$ Release+Asserts/bin/lldb<br></div><div>(lldb) target create -c ~/test/core</div><div>Core file '/mts/home3/jacobs/test/core' (x86_64) was loaded.</div><div>Process 0 stopped</div><div>* thread #1: tid = 0x0000, 0x00000000004004c4, stop reason = signal SIGCONT</div>
<div> frame #0: 0x00000000004004c4</div><div>-> 0x4004c4: movb $0, (%rax)</div><div> 0x4004c7: popq %rbp</div><div> 0x4004c8: ret</div><div> 0x4004c9: pushq %rbp</div><div>(lldb) target modules add ~/test/a.out</div>
<div>(lldb) image load --file ~/test/a.out .text 0x4003d0<br></div><div>section '.text' loaded at 0x4003d0</div><div>(lldb) bt</div><div>* thread #1: tid = 0x0000, 0x00000000004004c4 a.out`function4(arg=0) + 16 at test.c:4, stop reason = signal SIGCONT</div>
<div> frame #0: 0x00000000004004c4 a.out`function4(arg=0) + 16 at test.c:4</div><div> frame #1: 0x00000000004004d7 a.out`function3 + 11 at test.c:8</div><div> frame #2: 0x00000000004004e7 a.out`function2(arg=4195559) + 11 at test.c:11</div>
<div> frame #3: 0x00000000004004f7 a.out`function1(arg1=0, arg2=140736328348032, str=0x00000000004004e7) + 3 at test.c:15</div><div> frame #4: 0x0000000000400507 a.out`function1(arg1=0, arg2=140736328348048, str=0x00000000004004f7) + 19 at test.c:15</div>
<div><br></div><div>I didnt try this previously since I thought AUXV->AT_ENTRY processing is needed only if the load address is different.<br></div><div style>Is there a reason why lldb is not using the symbol files virtual address as load address if load is not provided?</div>
<div style><br></div><div style><div>$eu-readelf -S ~/test/a.out | grep .text</div><div>[13] .text PROGBITS 00000000004003d0 000003d0 00000238 0 AX 0 0 16</div><div><br></div><div><div>$eu-readelf -n ~/test/core | grep ENTRY</div>
<div> ENTRY: 0x4003d0</div></div><div><br></div><div style>I tried running lldb on few core files and all worked fine.</div><div style>I will send the patch once I complete the following</div><div style>1) Insert thread name, signal values</div>
<div style>2) Insert AT_ENTRY</div><div style>3) Add comments to the code</div><div style>4) More testing</div><div><br></div><div style>Thanks</div></div><div style>Samuel</div><div><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, Feb 8, 2013 at 3:00 PM, Samuel Jacob <span dir="ltr"><<a href="mailto:samueldotj@gmail.com" target="_blank">samueldotj@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi,<div><br></div><div>I am new to lldb and creating a patch to support Linux coredumps.</div><div>This plugin is based on mach-core plugin.</div><div>Currently it can parss the NOTE segments and loads all the threads found in the corefile(x86_64).</div>
<div>That is "thread list" works fine.</div><div><br></div><div>It also reads the PRSTATUS structure and populates the register infromation.</div><div>That is "register read" works fine.</div>
<div><br></div><div>However lldb is not using the symbol files while using the core file. Because of this it is not using DWARF structures while creating frames. That is frame variables and arguments are not available. Also lldb not resolving address to symbols.<br>
</div><div><br></div><div><div>$lldb</div><div>(lldb) target create -c ./core</div><div>Core file '/mts/home3/jacobs/test/core' (x86_64) was loaded.</div><div>Process 0 stopped</div><div>* thread #1: tid = 0x0000, 0x00000000004004c4, stop reason = signal SIGCONT</div>
<div> frame #0: 0x00000000004004c4</div><div>error: core file does not contain 0x4004c4</div><div>(lldb) target modules add ./a.out</div><div>(lldb) image lookup --address 0x4004c4</div><div> Address: a.out[0x00000000004004c4] (a.out..text + 244)</div>
<div> Summary: a.out`function4 + 16 at test.c:4</div><div>(lldb) bt</div><div>* thread #1: tid = 0x0000, 0x00000000004004c4, stop reason = signal SIGCONT</div><div> frame #0: 0x00000000004004c4</div><div> frame #1: 0x00000000004004d7</div>
<div> frame #2: 0x00000000004004e7</div><div> frame #3: 0x00000000004004f7</div><div> frame #4: 0x0000000000400507</div><div>(lldb) image lookup --address 0x00000000004004d7</div><div> Address: a.out[0x00000000004004d7] (a.out..text + 263)</div>
<div> Summary: a.out`function3 + 11 at test.c:8</div><div><br></div></div><div>In the above example the IP's are not resolved to symbol in "bt" although lldb is able to resolve the addresses using "image lookukp" . What command should be used to link a target with symbol file?</div>
<div><br></div><div>Here is the program that I used which compiled with "gcc -O0 -g3"<br></div><div><div>$cat test.c</div><div>void function4(unsigned int arg)</div><div>{</div><div> char *local = 0;</div>
<div> *local = 0;</div><div>}</div><div>void function3()</div><div>{</div><div> function4(-1);</div><div>}</div><div>void function2(long arg)</div><div>{</div><div> function3();</div><div>}</div><div>void function1(int arg1, long arg2, char *str)</div>
<div>{</div><div> function2(1);</div><div>}</div><div>void main()</div><div>{</div><div> function1(0, 1L, "Test\n");</div><div>}</div><div><br></div><div>GDB output</div><div><br></div><div>
<div>$gdb --quiet a.out core</div><div>Reading symbols from /mts/home3/jacobs/test/a.out...done.</div><div><br></div><div>warning: exec file is newer than core file.</div><div>[New LWP 26718]</div><div><br></div><div>warning: Can't read pathname for load map: Input/output error.</div>
<div>Core was generated by `./a.out'.</div><div>Program terminated with signal 11, Segmentation fault.</div><div>#0 0x00000000004004c4 in function4 (arg=0) at test.c:4</div><div>4 *local = 0;</div><div>(gdb) bt</div>
<div>#0 0x00000000004004c4 in function4 (arg=0) at test.c:4</div><div>#1 0x00000000004004d7 in function3 () at test.c:8</div><div>#2 0x00000000004004e7 in function2 (arg=4195559) at test.c:11</div><div>#3 0x00000000004004f7 in function1 (arg1=0, arg2=140736328348032, str=0x4004e7 <incomplete sequence \370\270>) at test.c:15</div>
<div>#4 0x0000000000400507 in function1 (arg1=0, arg2=140736328348048, str=0x4004f7 "\345H\203\354\030\211}\374H\211u\360H\211U\350\277\001") at test.c:15</div><div>#5 0x00007fbcdfe6c76d in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6</div>
<div>#6 0x00000000004003f9 in _start ()</div><div><br></div><div>I can post the patch if anyone interested(but it needs to be cleaned up).</div></div></div><div><br></div><div>Thanks</div><span class="HOEnZb"><font color="#888888"><div>
Samuel </div>
</font></span></div>
</blockquote></div><br></div>