PatriosTheGreat created this revision. PatriosTheGreat added reviewers: clayborg, labath. Herald added a project: All. PatriosTheGreat requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
This CL allows to use minidump save-core functionality (https://reviews.llvm.org/D108233) via SBProcess interface. After adding a support from gdb-remote client (https://reviews.llvm.org/D101329) if the plugin name is empty the plugin manager will try to save the core directly from the process plugin. See https://github.com/llvm/llvm-project/blob/main/lldb/source/Core/PluginManager.cpp#L696 To have an ability to save the core with minidump plugin I added plugin name as a parameter in SBProcess::SaveCore. See the usage in TestProcessSaveCoreMinidump.py Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D125325 Files: lldb/bindings/interface/SBProcess.i lldb/include/lldb/API/SBProcess.h lldb/source/API/SBProcess.cpp lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py 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( @@ -42,7 +43,10 @@ # save core and, kill process and verify corefile existence self.runCmd("process save-core --plugin-name=minidump --style=stack " + core) + # validate savinig via SBProcess + lldb.SBProcess().SaveCore(core_sb, "minidump") self.assertTrue(os.path.isfile(core)) + self.assertTrue(os.path.isfile(core_sb)) self.assertSuccess(process.Kill()) # To verify, we'll launch with the mini dump @@ -77,3 +81,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) Index: lldb/source/API/SBProcess.cpp =================================================================== --- lldb/source/API/SBProcess.cpp +++ lldb/source/API/SBProcess.cpp @@ -1136,8 +1136,9 @@ return runtime_sp->IsActive(); } -lldb::SBError SBProcess::SaveCore(const char *file_name) { - LLDB_INSTRUMENT_VA(this, file_name); +lldb::SBError SBProcess::SaveCore(const char *file_name, + const char *plugin_name) { + LLDB_INSTRUMENT_VA(this, file_name, plugin_name); lldb::SBError error; ProcessSP process_sp(GetSP()); @@ -1156,7 +1157,8 @@ 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, + plugin_name); return error; } Index: lldb/include/lldb/API/SBProcess.h =================================================================== --- lldb/include/lldb/API/SBProcess.h +++ lldb/include/lldb/API/SBProcess.h @@ -338,7 +338,8 @@ bool IsInstrumentationRuntimePresent(InstrumentationRuntimeType type); /// Save the state of the process in a core file (or mini dump on Windows). - lldb::SBError SaveCore(const char *file_name); + lldb::SBError SaveCore(const char *file_name, + const char *plugin_name = ""); /// Query the address load_addr and store the details of the memory /// region that contains it in the supplied SBMemoryRegionInfo object. Index: lldb/bindings/interface/SBProcess.i =================================================================== --- lldb/bindings/interface/SBProcess.i +++ lldb/bindings/interface/SBProcess.i @@ -398,7 +398,7 @@ IsInstrumentationRuntimePresent(lldb::InstrumentationRuntimeType type); lldb::SBError - SaveCore(const char *file_name); + SaveCore(const char *file_name, const char *plugin_name); lldb::SBError GetMemoryRegionInfo(lldb::addr_t load_addr, lldb::SBMemoryRegionInfo ®ion_info);
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( @@ -42,7 +43,10 @@ # save core and, kill process and verify corefile existence self.runCmd("process save-core --plugin-name=minidump --style=stack " + core) + # validate savinig via SBProcess + lldb.SBProcess().SaveCore(core_sb, "minidump") self.assertTrue(os.path.isfile(core)) + self.assertTrue(os.path.isfile(core_sb)) self.assertSuccess(process.Kill()) # To verify, we'll launch with the mini dump @@ -77,3 +81,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) Index: lldb/source/API/SBProcess.cpp =================================================================== --- lldb/source/API/SBProcess.cpp +++ lldb/source/API/SBProcess.cpp @@ -1136,8 +1136,9 @@ return runtime_sp->IsActive(); } -lldb::SBError SBProcess::SaveCore(const char *file_name) { - LLDB_INSTRUMENT_VA(this, file_name); +lldb::SBError SBProcess::SaveCore(const char *file_name, + const char *plugin_name) { + LLDB_INSTRUMENT_VA(this, file_name, plugin_name); lldb::SBError error; ProcessSP process_sp(GetSP()); @@ -1156,7 +1157,8 @@ 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, + plugin_name); return error; } Index: lldb/include/lldb/API/SBProcess.h =================================================================== --- lldb/include/lldb/API/SBProcess.h +++ lldb/include/lldb/API/SBProcess.h @@ -338,7 +338,8 @@ bool IsInstrumentationRuntimePresent(InstrumentationRuntimeType type); /// Save the state of the process in a core file (or mini dump on Windows). - lldb::SBError SaveCore(const char *file_name); + lldb::SBError SaveCore(const char *file_name, + const char *plugin_name = ""); /// Query the address load_addr and store the details of the memory /// region that contains it in the supplied SBMemoryRegionInfo object. Index: lldb/bindings/interface/SBProcess.i =================================================================== --- lldb/bindings/interface/SBProcess.i +++ lldb/bindings/interface/SBProcess.i @@ -398,7 +398,7 @@ IsInstrumentationRuntimePresent(lldb::InstrumentationRuntimeType type); lldb::SBError - SaveCore(const char *file_name); + SaveCore(const char *file_name, const char *plugin_name); lldb::SBError GetMemoryRegionInfo(lldb::addr_t load_addr, lldb::SBMemoryRegionInfo ®ion_info);
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits