diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index 7985da218ac8..1f6595ba0892 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -366,6 +366,9 @@ public: SBProcess Launch (SBLaunchInfo &launch_info, SBError& error); + + SBProcess + LoadCore (const char *core_file); SBProcess Attach (SBAttachInfo &attach_info, SBError& error); diff --git a/lldb/scripts/Python/interface/SBTarget.i b/lldb/scripts/Python/interface/SBTarget.i index 8f9ea2ee6396..b60a8dba84f7 100644 --- a/lldb/scripts/Python/interface/SBTarget.i +++ b/lldb/scripts/Python/interface/SBTarget.i @@ -389,6 +389,26 @@ public: lldb::SBProcess Launch (lldb::SBLaunchInfo &launch_info, lldb::SBError& error); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Load a core file + /// + /// @param[in] core_file + /// File path of the core dump. + /// + /// @return + /// A process object for the newly created core file. + //------------------------------------------------------------------ + + For example, + + process = target.LoadCore('./a.out.core') + + loads a new core file and returns the process object. + ") LoadCore; + lldb::SBProcess + LoadCore(const char *core_file); lldb::SBProcess Attach (lldb::SBAttachInfo &attach_info, lldb::SBError& error); diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 8cddd0968b9c..383f7012bca6 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -556,6 +556,26 @@ SBTarget::GetDebugger () const return debugger; } +SBProcess +SBTarget::LoadCore (const char *core_file) +{ + SBProcess sb_process; + TargetSP target_sp(GetSP()); + if (target_sp) + { + FileSpec filespec(core_file, true); + ProcessSP process_sp (target_sp->CreateProcess(target_sp->GetDebugger().GetListener(), + NULL, + &filespec)); + if (process_sp) + { + process_sp->LoadCore(); + sb_process.SetSP (process_sp); + } + } + return sb_process; +} + SBProcess SBTarget::LaunchSimple (