================ @@ -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 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits