<div dir="ltr">I couldnt find a way to load core files from python. Is there a way?<div><br></div><div style>The attached patch solves my problem. I tried it only on Linux and a elf-core.</div><div style><br></div><div style>
Thanks</div><div style>Samuel</div><div style><br></div><div style>Here is the test program</div><div style><div>$cat ./test.py</div><div>#!/usr/bin/env python</div><div><br></div><div>import lldb</div><div>import sys, os</div>
<div><br></div><div>exe = sys.argv[1]</div><div>core = sys.argv[2]</div><div><br></div><div># Create a new debugger instance</div><div>debugger = lldb.SBDebugger.Create()</div><div><br></div><div># Create a target from a file and arch</div>
<div>print "Creating a target for '%s'" % exe</div><div>target = debugger.CreateTarget(exe)</div><div>if target:</div><div> process = target.LoadCore(core)</div><div> if process:</div><div> state = process.GetState ()</div>
<div> thread = process.GetThreadAtIndex (0)</div><div> if thread:</div><div> for i in range(thread.GetNumFrames()):</div><div> frame = thread.GetFrameAtIndex (i)</div><div> if frame:</div>
<div> print frame</div><div><br></div><div style>And output</div><div style><br></div><div style><div>$./test.py ./test/a.out ./test/core</div><div>Creating a target for './test/a.out'</div><div>
Traceback (most recent call last):</div><div> File "<string>", line 1, in <module></div><div>ImportError: No module named embedded_interpreter</div><div>Traceback (most recent call last):</div><div>
File "<string>", line 1, in <module></div><div>NameError: name 'run_one_line' is not defined</div><div>Traceback (most recent call last):</div><div> File "<string>", line 1, in <module></div>
<div>NameError: name 'run_one_line' is not defined</div><div>Traceback (most recent call last):</div><div> File "<string>", line 1, in <module></div><div>NameError: name 'run_one_line' is not defined</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>frame #5: 0x00007fbcdfe6c76d libc.so.6`__libc_start_main + 237</div><div>frame #6: 0x00000000004003f9 a.out`_start + 41</div><div><br></div></div></div></div>