[Lldb-commits] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Fri Nov 17 10:19:50 PST 2023
================
@@ -260,6 +261,31 @@ SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) {
return sb_process;
}
+SBProcess SBTarget::LoadCore(const SBFile &file, lldb::SBError &error) {
+ LLDB_INSTRUMENT_VA(this, file, error);
+
+ SBProcess sb_process;
+ TargetSP target_sp(GetSP());
+ if (target_sp) {
+ FileSP file_sp = file.GetFile();
+ FileSpec filespec;
+ file_sp->GetFileSpec(filespec);
+ FileSystem::Instance().Resolve(filespec);
+ ProcessSP process_sp(target_sp->CreateProcess(
+ target_sp->GetDebugger().GetListener(), "", &filespec, false));
+ if (process_sp) {
+ error.SetError(process_sp->LoadCore());
+ if (error.Success())
+ sb_process.SetSP(process_sp);
+ } else {
+ error.SetErrorString("Failed to create the process");
+ }
+ } else {
+ error.SetErrorString("SBTarget is invalid");
+ }
+ return sb_process;
+}
----------------
JDevlieghere wrote:
This could be a lot simpler and easier to read with early returns, with the added advantage that the error message is closer to the condition it corresponds to. The function below is a good example of that.
https://github.com/llvm/llvm-project/pull/71769
More information about the lldb-commits
mailing list