Python interface for loading core file

I couldnt find a way to load core files from python. Is there a way?

The attached patch solves my problem. I tried it only on Linux and a elf-core.

Thanks
Samuel

Here is the test program

$cat ./test.py
#!/usr/bin/env python

import lldb
import sys, os

exe = sys.argv[1]
core = sys.argv[2]

Create a new debugger instance

debugger = lldb.SBDebugger.Create()

Create a target from a file and arch

print “Creating a target for ‘%s’” % exe
target = debugger.CreateTarget(exe)
if target:
process = target.LoadCore(core)
if process:
state = process.GetState ()
thread = process.GetThreadAtIndex (0)
if thread:
for i in range(thread.GetNumFrames()):
frame = thread.GetFrameAtIndex (i)
if frame:
print frame

And output

$./test.py ./test/a.out ./test/core
Creating a target for ‘./test/a.out’
Traceback (most recent call last):
File “”, line 1, in
ImportError: No module named embedded_interpreter
Traceback (most recent call last):
File “”, line 1, in
NameError: name ‘run_one_line’ is not defined
Traceback (most recent call last):
File “”, line 1, in
NameError: name ‘run_one_line’ is not defined
Traceback (most recent call last):
File “”, line 1, in
NameError: name ‘run_one_line’ is not defined
frame #0: 0x00000000004004c4 a.outfunction4(arg=0) + 16 at test.c:4 frame #1: 0x00000000004004d7 a.outfunction3 + 11 at test.c:8
frame #2: 0x00000000004004e7 a.outfunction2(arg=4195559) + 11 at test.c:11 frame #3: 0x00000000004004f7 a.outfunction1(arg1=0, arg2=140736328348032, str=0x00000000004004e7) + 3 at test.c:15
frame #4: 0x0000000000400507 a.outfunction1(arg1=0, arg2=140736328348048, str=0x00000000004004f7) + 19 at test.c:15 frame #5: 0x00007fbcdfe6c76d libc.so.6__libc_start_main + 237
frame #6: 0x00000000004003f9 a.out`_start + 41

core-python.diff (2.11 KB)