Index: lldb/bindings/interface/SBProcess.i =================================================================== --- lldb/bindings/interface/SBProcess.i +++ lldb/bindings/interface/SBProcess.i @@ -397,6 +397,9 @@ bool IsInstrumentationRuntimePresent(lldb::InstrumentationRuntimeType type); + lldb::SBError + SaveCore(const char *file_name, const char *flavor, lldb::SaveCoreStyle core_style); + lldb::SBError SaveCore(const char *file_name); Index: lldb/include/lldb/API/SBProcess.h =================================================================== --- lldb/include/lldb/API/SBProcess.h +++ lldb/include/lldb/API/SBProcess.h @@ -337,7 +337,21 @@ bool IsInstrumentationRuntimePresent(InstrumentationRuntimeType type); - /// Save the state of the process in a core file (or mini dump on Windows). + /// Save the state of the process in a core file. + /// + /// \param[in] file_name - The name of the file to save the core file to. + /// + /// \param[in] flavor - Specify the flavor of a core file plug-in to save. + /// Currently supported flavors include "mach-o" and "minidump" + /// + /// \param[in] core_style - Specify the style of a core file to save. + lldb::SBError SaveCore(const char *file_name, const char *flavor, + SaveCoreStyle core_style); + + /// Save the state of the process with the a flavor that matches the + /// current process' main executable (if supported). + /// + /// \param[in] file_name - The name of the file to save the core file to. lldb::SBError SaveCore(const char *file_name); /// Query the address load_addr and store the details of the memory Index: lldb/source/API/SBProcess.cpp =================================================================== --- lldb/source/API/SBProcess.cpp +++ lldb/source/API/SBProcess.cpp @@ -1138,6 +1138,13 @@ lldb::SBError SBProcess::SaveCore(const char *file_name) { LLDB_INSTRUMENT_VA(this, file_name); + return SaveCore(file_name, "", SaveCoreStyle::eSaveCoreFull); +} + +lldb::SBError SBProcess::SaveCore(const char *file_name, + const char *flavor, + SaveCoreStyle core_style) { + LLDB_INSTRUMENT_VA(this, file_name, flavor, core_style); lldb::SBError error; ProcessSP process_sp(GetSP()); @@ -1155,8 +1162,9 @@ } FileSpec core_file(file_name); - SaveCoreStyle core_style = SaveCoreStyle::eSaveCoreFull; - error.ref() = PluginManager::SaveCore(process_sp, core_file, core_style, ""); + error.ref() = PluginManager::SaveCore(process_sp, core_file, core_style, + flavor); + return error; } Index: lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py =================================================================== --- lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py +++ lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py @@ -21,6 +21,7 @@ self.build() exe = self.getBuildArtifact("a.out") core = self.getBuildArtifact("core.dmp") + core_sb = self.getBuildArtifact("core_sb.dmp") try: target = self.dbg.CreateTarget(exe) process = target.LaunchSimple( @@ -43,6 +44,17 @@ # save core and, kill process and verify corefile existence self.runCmd("process save-core --plugin-name=minidump --style=stack " + core) self.assertTrue(os.path.isfile(core)) + + # validate savinig via SBProcess + error = process.SaveCore(core_sb, "minidump", lldb.eSaveCoreStackOnly) + self.assertTrue(error.Success()) + self.assertTrue(os.path.isfile(core_sb)) + + error = process.SaveCore(core_sb, "minidump", lldb.eSaveCoreFull) + self.assertTrue(error.Fail()) + error = process.SaveCore(core_sb, "minidump", lldb.eSaveCoreDirtyOnly) + self.assertTrue(error.Fail()) + self.assertSuccess(process.Kill()) # To verify, we'll launch with the mini dump @@ -77,3 +89,5 @@ self.assertTrue(self.dbg.DeleteTarget(target)) if (os.path.isfile(core)): os.unlink(core) + if (os.path.isfile(core_sb)): + os.unlink(core_sb)