mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 05:32:28 +08:00
[lldb] Turn lldb_private::Status into a value type. (#106163)
This patch removes all of the Set.* methods from Status. This cleanup is part of a series of patches that make it harder use the anti-pattern of keeping a long-lives Status object around and updating it while dropping any errors it contains on the floor. This patch is largely NFC, the more interesting next steps this enables is to: 1. remove Status.Clear() 2. assert that Status::operator=() never overwrites an error 3. remove Status::operator=() Note that step (2) will bring 90% of the benefits for users, and step (3) will dramatically clean up the error handling code in various places. In the end my goal is to convert all APIs that are of the form ` ResultTy DoFoo(Status& error) ` to ` llvm::Expected<ResultTy> DoFoo() ` How to read this patch? The interesting changes are in Status.h and Status.cpp, all other changes are mostly ` perl -pi -e 's/\.SetErrorString/ = Status::FromErrorString/g' $(git grep -l SetErrorString lldb/source) ` plus the occasional manual cleanup.
This commit is contained in:
@@ -1383,10 +1383,10 @@ Status Process::Resume() {
|
||||
Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
|
||||
LLDB_LOGF(log, "(plugin = %s) -- locking run lock", GetPluginName().data());
|
||||
if (!m_public_run_lock.TrySetRunning()) {
|
||||
Status error("Resume request failed - process still running.");
|
||||
LLDB_LOGF(log, "(plugin = %s) -- TrySetRunning failed, not resuming.",
|
||||
GetPluginName().data());
|
||||
return error;
|
||||
return Status::FromErrorString(
|
||||
"Resume request failed - process still running.");
|
||||
}
|
||||
Status error = PrivateResume();
|
||||
if (!error.Success()) {
|
||||
@@ -1400,9 +1400,9 @@ Status Process::ResumeSynchronous(Stream *stream) {
|
||||
Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
|
||||
LLDB_LOGF(log, "Process::ResumeSynchronous -- locking run lock");
|
||||
if (!m_public_run_lock.TrySetRunning()) {
|
||||
Status error("Resume request failed - process still running.");
|
||||
LLDB_LOGF(log, "Process::Resume: -- TrySetRunning failed, not resuming.");
|
||||
return error;
|
||||
return Status::FromErrorString(
|
||||
"Resume request failed - process still running.");
|
||||
}
|
||||
|
||||
ListenerSP listener_sp(
|
||||
@@ -1417,7 +1417,7 @@ Status Process::ResumeSynchronous(Stream *stream) {
|
||||
const bool must_be_alive =
|
||||
false; // eStateExited is ok, so this must be false
|
||||
if (!StateIsStoppedState(state, must_be_alive))
|
||||
error.SetErrorStringWithFormat(
|
||||
error = Status::FromErrorStringWithFormat(
|
||||
"process not in stopped state after synchronous resume: %s",
|
||||
StateAsCString(state));
|
||||
} else {
|
||||
@@ -1639,8 +1639,8 @@ Status Process::DisableBreakpointSiteByID(lldb::user_id_t break_id) {
|
||||
if (bp_site_sp->IsEnabled())
|
||||
error = DisableBreakpointSite(bp_site_sp.get());
|
||||
} else {
|
||||
error.SetErrorStringWithFormat("invalid breakpoint site ID: %" PRIu64,
|
||||
break_id);
|
||||
error = Status::FromErrorStringWithFormat(
|
||||
"invalid breakpoint site ID: %" PRIu64, break_id);
|
||||
}
|
||||
|
||||
return error;
|
||||
@@ -1653,8 +1653,8 @@ Status Process::EnableBreakpointSiteByID(lldb::user_id_t break_id) {
|
||||
if (!bp_site_sp->IsEnabled())
|
||||
error = EnableBreakpointSite(bp_site_sp.get());
|
||||
} else {
|
||||
error.SetErrorStringWithFormat("invalid breakpoint site ID: %" PRIu64,
|
||||
break_id);
|
||||
error = Status::FromErrorStringWithFormat(
|
||||
"invalid breakpoint site ID: %" PRIu64, break_id);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
@@ -1818,7 +1818,8 @@ Status Process::EnableSoftwareBreakpoint(BreakpointSite *bp_site) {
|
||||
}
|
||||
|
||||
if (bp_addr == LLDB_INVALID_ADDRESS) {
|
||||
error.SetErrorString("BreakpointSite contains an invalid load address.");
|
||||
error = Status::FromErrorString(
|
||||
"BreakpointSite contains an invalid load address.");
|
||||
return error;
|
||||
}
|
||||
// Ask the lldb::Process subclass to fill in the correct software breakpoint
|
||||
@@ -1826,15 +1827,16 @@ Status Process::EnableSoftwareBreakpoint(BreakpointSite *bp_site) {
|
||||
const size_t bp_opcode_size = GetSoftwareBreakpointTrapOpcode(bp_site);
|
||||
|
||||
if (bp_opcode_size == 0) {
|
||||
error.SetErrorStringWithFormat("Process::GetSoftwareBreakpointTrapOpcode() "
|
||||
"returned zero, unable to get breakpoint "
|
||||
"trap for address 0x%" PRIx64,
|
||||
bp_addr);
|
||||
error = Status::FromErrorStringWithFormat(
|
||||
"Process::GetSoftwareBreakpointTrapOpcode() "
|
||||
"returned zero, unable to get breakpoint "
|
||||
"trap for address 0x%" PRIx64,
|
||||
bp_addr);
|
||||
} else {
|
||||
const uint8_t *const bp_opcode_bytes = bp_site->GetTrapOpcodeBytes();
|
||||
|
||||
if (bp_opcode_bytes == nullptr) {
|
||||
error.SetErrorString(
|
||||
error = Status::FromErrorString(
|
||||
"BreakpointSite doesn't contain a valid breakpoint trap opcode.");
|
||||
return error;
|
||||
}
|
||||
@@ -1857,15 +1859,17 @@ Status Process::EnableSoftwareBreakpoint(BreakpointSite *bp_site) {
|
||||
"addr = 0x%" PRIx64 " -- SUCCESS",
|
||||
bp_site->GetID(), (uint64_t)bp_addr);
|
||||
} else
|
||||
error.SetErrorString(
|
||||
error = Status::FromErrorString(
|
||||
"failed to verify the breakpoint trap in memory.");
|
||||
} else
|
||||
error.SetErrorString(
|
||||
error = Status::FromErrorString(
|
||||
"Unable to read memory to verify breakpoint trap.");
|
||||
} else
|
||||
error.SetErrorString("Unable to write breakpoint trap to memory.");
|
||||
error = Status::FromErrorString(
|
||||
"Unable to write breakpoint trap to memory.");
|
||||
} else
|
||||
error.SetErrorString("Unable to read memory at breakpoint address.");
|
||||
error = Status::FromErrorString(
|
||||
"Unable to read memory at breakpoint address.");
|
||||
}
|
||||
if (log && error.Fail())
|
||||
LLDB_LOGF(
|
||||
@@ -1888,7 +1892,8 @@ Status Process::DisableSoftwareBreakpoint(BreakpointSite *bp_site) {
|
||||
breakID, (uint64_t)bp_addr);
|
||||
|
||||
if (bp_site->IsHardware()) {
|
||||
error.SetErrorString("Breakpoint site is a hardware breakpoint.");
|
||||
error =
|
||||
Status::FromErrorString("Breakpoint site is a hardware breakpoint.");
|
||||
} else if (bp_site->IsEnabled()) {
|
||||
const size_t break_op_size = bp_site->GetByteSize();
|
||||
const uint8_t *const break_op = bp_site->GetTrapOpcodeBytes();
|
||||
@@ -1911,10 +1916,10 @@ Status Process::DisableSoftwareBreakpoint(BreakpointSite *bp_site) {
|
||||
break_op_size, error) == break_op_size) {
|
||||
verify = true;
|
||||
} else
|
||||
error.SetErrorString(
|
||||
error = Status::FromErrorString(
|
||||
"Memory write failed when restoring original opcode.");
|
||||
} else {
|
||||
error.SetErrorString(
|
||||
error = Status::FromErrorString(
|
||||
"Original breakpoint trap is no longer in memory.");
|
||||
// Set verify to true and so we can check if the original opcode has
|
||||
// already been restored
|
||||
@@ -1939,14 +1944,16 @@ Status Process::DisableSoftwareBreakpoint(BreakpointSite *bp_site) {
|
||||
return error;
|
||||
} else {
|
||||
if (break_op_found)
|
||||
error.SetErrorString("Failed to restore original opcode.");
|
||||
error = Status::FromErrorString(
|
||||
"Failed to restore original opcode.");
|
||||
}
|
||||
} else
|
||||
error.SetErrorString("Failed to read memory to verify that "
|
||||
"breakpoint trap was restored.");
|
||||
error =
|
||||
Status::FromErrorString("Failed to read memory to verify that "
|
||||
"breakpoint trap was restored.");
|
||||
}
|
||||
} else
|
||||
error.SetErrorString(
|
||||
error = Status::FromErrorString(
|
||||
"Unable to read memory that should contain the breakpoint trap.");
|
||||
}
|
||||
} else {
|
||||
@@ -2051,23 +2058,23 @@ AddressRanges Process::FindRangesInMemory(const uint8_t *buf, uint64_t size,
|
||||
Status &error) {
|
||||
AddressRanges matches;
|
||||
if (buf == nullptr) {
|
||||
error.SetErrorString("buffer is null");
|
||||
error = Status::FromErrorString("buffer is null");
|
||||
return matches;
|
||||
}
|
||||
if (size == 0) {
|
||||
error.SetErrorString("buffer size is zero");
|
||||
error = Status::FromErrorString("buffer size is zero");
|
||||
return matches;
|
||||
}
|
||||
if (ranges.empty()) {
|
||||
error.SetErrorString("empty ranges");
|
||||
error = Status::FromErrorString("empty ranges");
|
||||
return matches;
|
||||
}
|
||||
if (alignment == 0) {
|
||||
error.SetErrorString("alignment must be greater than zero");
|
||||
error = Status::FromErrorString("alignment must be greater than zero");
|
||||
return matches;
|
||||
}
|
||||
if (max_matches == 0) {
|
||||
error.SetErrorString("max_matches must be greater than zero");
|
||||
error = Status::FromErrorString("max_matches must be greater than zero");
|
||||
return matches;
|
||||
}
|
||||
|
||||
@@ -2094,7 +2101,7 @@ AddressRanges Process::FindRangesInMemory(const uint8_t *buf, uint64_t size,
|
||||
if (resolved_ranges > 0)
|
||||
error.Clear();
|
||||
else
|
||||
error.SetErrorString("unable to resolve any ranges");
|
||||
error = Status::FromErrorString("unable to resolve any ranges");
|
||||
|
||||
return matches;
|
||||
}
|
||||
@@ -2103,19 +2110,19 @@ lldb::addr_t Process::FindInMemory(const uint8_t *buf, uint64_t size,
|
||||
const AddressRange &range, size_t alignment,
|
||||
Status &error) {
|
||||
if (buf == nullptr) {
|
||||
error.SetErrorString("buffer is null");
|
||||
error = Status::FromErrorString("buffer is null");
|
||||
return LLDB_INVALID_ADDRESS;
|
||||
}
|
||||
if (size == 0) {
|
||||
error.SetErrorString("buffer size is zero");
|
||||
error = Status::FromErrorString("buffer size is zero");
|
||||
return LLDB_INVALID_ADDRESS;
|
||||
}
|
||||
if (!range.IsValid()) {
|
||||
error.SetErrorString("range is invalid");
|
||||
error = Status::FromErrorString("range is invalid");
|
||||
return LLDB_INVALID_ADDRESS;
|
||||
}
|
||||
if (alignment == 0) {
|
||||
error.SetErrorString("alignment must be greater than zero");
|
||||
error = Status::FromErrorString("alignment must be greater than zero");
|
||||
return LLDB_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
@@ -2123,7 +2130,7 @@ lldb::addr_t Process::FindInMemory(const uint8_t *buf, uint64_t size,
|
||||
const lldb::addr_t start_addr =
|
||||
range.GetBaseAddress().GetLoadAddress(&target);
|
||||
if (start_addr == LLDB_INVALID_ADDRESS) {
|
||||
error.SetErrorString("range load address is invalid");
|
||||
error = Status::FromErrorString("range load address is invalid");
|
||||
return LLDB_INVALID_ADDRESS;
|
||||
}
|
||||
const lldb::addr_t end_addr = start_addr + range.GetByteSize();
|
||||
@@ -2198,7 +2205,7 @@ size_t Process::ReadCStringFromMemory(addr_t addr, char *dst,
|
||||
}
|
||||
} else {
|
||||
if (dst == nullptr)
|
||||
result_error.SetErrorString("invalid arguments");
|
||||
result_error = Status::FromErrorString("invalid arguments");
|
||||
else
|
||||
result_error.Clear();
|
||||
}
|
||||
@@ -2355,7 +2362,7 @@ size_t Process::WriteMemory(addr_t addr, const void *buf, size_t size,
|
||||
// done looping and will return the number of bytes that we have
|
||||
// written so far.
|
||||
if (error.Success())
|
||||
error.SetErrorToGenericError();
|
||||
error = Status::FromErrorString("could not write all bytes");
|
||||
}
|
||||
}
|
||||
// Now write any bytes that would cover up any software breakpoints
|
||||
@@ -2385,9 +2392,9 @@ size_t Process::WriteScalarToMemory(addr_t addr, const Scalar &scalar,
|
||||
if (mem_size > 0)
|
||||
return WriteMemory(addr, buf, mem_size, error);
|
||||
else
|
||||
error.SetErrorString("failed to get scalar as memory data");
|
||||
error = Status::FromErrorString("failed to get scalar as memory data");
|
||||
} else {
|
||||
error.SetErrorString("invalid scalar value");
|
||||
error = Status::FromErrorString("invalid scalar value");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -2397,10 +2404,10 @@ size_t Process::ReadScalarIntegerFromMemory(addr_t addr, uint32_t byte_size,
|
||||
Status &error) {
|
||||
uint64_t uval = 0;
|
||||
if (byte_size == 0) {
|
||||
error.SetErrorString("byte size is zero");
|
||||
error = Status::FromErrorString("byte size is zero");
|
||||
} else if (byte_size & (byte_size - 1)) {
|
||||
error.SetErrorStringWithFormat("byte size %u is not a power of 2",
|
||||
byte_size);
|
||||
error = Status::FromErrorStringWithFormat(
|
||||
"byte size %u is not a power of 2", byte_size);
|
||||
} else if (byte_size <= sizeof(uval)) {
|
||||
const size_t bytes_read = ReadMemory(addr, &uval, byte_size, error);
|
||||
if (bytes_read == byte_size) {
|
||||
@@ -2416,7 +2423,7 @@ size_t Process::ReadScalarIntegerFromMemory(addr_t addr, uint32_t byte_size,
|
||||
return bytes_read;
|
||||
}
|
||||
} else {
|
||||
error.SetErrorStringWithFormat(
|
||||
error = Status::FromErrorStringWithFormat(
|
||||
"byte size of %u is too large for integer scalar type", byte_size);
|
||||
}
|
||||
return 0;
|
||||
@@ -2437,7 +2444,8 @@ Status Process::WriteObjectFile(std::vector<ObjectFile::LoadableData> entries) {
|
||||
addr_t Process::AllocateMemory(size_t size, uint32_t permissions,
|
||||
Status &error) {
|
||||
if (GetPrivateState() != eStateStopped) {
|
||||
error.SetErrorToGenericError();
|
||||
error = Status::FromErrorString(
|
||||
"cannot allocate memory while process is running");
|
||||
return LLDB_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
@@ -2509,7 +2517,7 @@ Status Process::DeallocateMemory(addr_t ptr) {
|
||||
Status error;
|
||||
#if defined(USE_ALLOCATE_MEMORY_CACHE)
|
||||
if (!m_allocated_memory_cache.DeallocateMemory(ptr)) {
|
||||
error.SetErrorStringWithFormat(
|
||||
error = Status::FromErrorStringWithFormat(
|
||||
"deallocation of memory at 0x%" PRIx64 " failed.", (uint64_t)ptr);
|
||||
}
|
||||
#else
|
||||
@@ -2588,13 +2596,13 @@ bool Process::GetLoadAddressPermissions(lldb::addr_t load_addr,
|
||||
|
||||
Status Process::EnableWatchpoint(WatchpointSP wp_sp, bool notify) {
|
||||
Status error;
|
||||
error.SetErrorString("watchpoints are not supported");
|
||||
error = Status::FromErrorString("watchpoints are not supported");
|
||||
return error;
|
||||
}
|
||||
|
||||
Status Process::DisableWatchpoint(WatchpointSP wp_sp, bool notify) {
|
||||
Status error;
|
||||
error.SetErrorString("watchpoints are not supported");
|
||||
error = Status::FromErrorString("watchpoints are not supported");
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -2687,7 +2695,7 @@ Status Process::LaunchPrivate(ProcessLaunchInfo &launch_info, StateType &state,
|
||||
FileSpec exe_spec_to_use;
|
||||
if (!exe_module) {
|
||||
if (!launch_info.GetExecutableFile() && !launch_info.IsScriptedProcess()) {
|
||||
error.SetErrorString("executable module does not exist");
|
||||
error = Status::FromErrorString("executable module does not exist");
|
||||
return error;
|
||||
}
|
||||
exe_spec_to_use = launch_info.GetExecutableFile();
|
||||
@@ -2714,7 +2722,8 @@ Status Process::LaunchPrivate(ProcessLaunchInfo &launch_info, StateType &state,
|
||||
error = WillLaunch(exe_module);
|
||||
if (error.Fail()) {
|
||||
std::string local_exec_file_path = exe_spec_to_use.GetPath();
|
||||
return Status("file doesn't exist: '%s'", local_exec_file_path.c_str());
|
||||
return Status::FromErrorStringWithFormat("file doesn't exist: '%s'",
|
||||
local_exec_file_path.c_str());
|
||||
}
|
||||
|
||||
const bool restarted = false;
|
||||
@@ -2726,7 +2735,7 @@ Status Process::LaunchPrivate(ProcessLaunchInfo &launch_info, StateType &state,
|
||||
error = DoLaunch(exe_module, launch_info);
|
||||
} else {
|
||||
// This shouldn't happen
|
||||
error.SetErrorString("failed to acquire process run lock");
|
||||
error = Status::FromErrorString("failed to acquire process run lock");
|
||||
}
|
||||
|
||||
if (error.Fail()) {
|
||||
@@ -2747,7 +2756,7 @@ Status Process::LaunchPrivate(ProcessLaunchInfo &launch_info, StateType &state,
|
||||
if (state == eStateInvalid || !event_sp) {
|
||||
// We were able to launch the process, but we failed to catch the
|
||||
// initial stop.
|
||||
error.SetErrorString("failed to catch stop after launch");
|
||||
error = Status::FromErrorString("failed to catch stop after launch");
|
||||
SetExitStatus(0, error.AsCString());
|
||||
Destroy(false);
|
||||
return error;
|
||||
@@ -2789,11 +2798,12 @@ Status Process::LaunchPrivate(ProcessLaunchInfo &launch_info, StateType &state,
|
||||
return Status();
|
||||
}
|
||||
|
||||
return Status("Unexpected process state after the launch: %s, expected %s, "
|
||||
"%s, %s or %s",
|
||||
StateAsCString(state), StateAsCString(eStateInvalid),
|
||||
StateAsCString(eStateExited), StateAsCString(eStateStopped),
|
||||
StateAsCString(eStateCrashed));
|
||||
return Status::FromErrorStringWithFormat(
|
||||
"Unexpected process state after the launch: %s, expected %s, "
|
||||
"%s, %s or %s",
|
||||
StateAsCString(state), StateAsCString(eStateInvalid),
|
||||
StateAsCString(eStateExited), StateAsCString(eStateStopped),
|
||||
StateAsCString(eStateCrashed));
|
||||
}
|
||||
|
||||
Status Process::LoadCore() {
|
||||
@@ -2835,7 +2845,7 @@ Status Process::LoadCore() {
|
||||
Log *log = GetLog(LLDBLog::Process);
|
||||
LLDB_LOGF(log, "Process::Halt() failed to stop, state is: %s",
|
||||
StateAsCString(state));
|
||||
error.SetErrorString(
|
||||
error = Status::FromErrorString(
|
||||
"Did not get stopped event after loading the core file.");
|
||||
}
|
||||
RestoreProcessEvents();
|
||||
@@ -3000,14 +3010,15 @@ Status Process::Attach(ProcessAttachInfo &attach_info) {
|
||||
error = DoAttachToProcessWithName(process_name, attach_info);
|
||||
} else {
|
||||
// This shouldn't happen
|
||||
error.SetErrorString("failed to acquire process run lock");
|
||||
error =
|
||||
Status::FromErrorString("failed to acquire process run lock");
|
||||
}
|
||||
|
||||
if (error.Fail()) {
|
||||
if (GetID() != LLDB_INVALID_PROCESS_ID) {
|
||||
SetID(LLDB_INVALID_PROCESS_ID);
|
||||
if (error.AsCString() == nullptr)
|
||||
error.SetErrorString("attach failed");
|
||||
error = Status::FromErrorString("attach failed");
|
||||
|
||||
SetExitStatus(-1, error.AsCString());
|
||||
}
|
||||
@@ -3041,21 +3052,21 @@ Status Process::Attach(ProcessAttachInfo &attach_info) {
|
||||
process_infos[i].DumpAsTableRow(
|
||||
s, platform_sp->GetUserIDResolver(), true, false);
|
||||
}
|
||||
error.SetErrorStringWithFormat(
|
||||
error = Status::FromErrorStringWithFormat(
|
||||
"more than one process named %s:\n%s", process_name,
|
||||
s.GetData());
|
||||
} else
|
||||
error.SetErrorStringWithFormat(
|
||||
error = Status::FromErrorStringWithFormat(
|
||||
"could not find a process named %s", process_name);
|
||||
}
|
||||
} else {
|
||||
error.SetErrorString(
|
||||
error = Status::FromErrorString(
|
||||
"invalid platform, can't find processes by name");
|
||||
return error;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error.SetErrorString("invalid process name");
|
||||
error = Status::FromErrorString("invalid process name");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3071,7 +3082,7 @@ Status Process::Attach(ProcessAttachInfo &attach_info) {
|
||||
error = DoAttachToProcessWithID(attach_pid, attach_info);
|
||||
} else {
|
||||
// This shouldn't happen
|
||||
error.SetErrorString("failed to acquire process run lock");
|
||||
error = Status::FromErrorString("failed to acquire process run lock");
|
||||
}
|
||||
|
||||
if (error.Success()) {
|
||||
@@ -3284,7 +3295,7 @@ Status Process::PrivateResume() {
|
||||
if (m_thread_list.WillResume()) {
|
||||
// Last thing, do the PreResumeActions.
|
||||
if (!RunPreResumeActions()) {
|
||||
error.SetErrorString(
|
||||
error = Status::FromErrorString(
|
||||
"Process::PrivateResume PreResumeActions failed, not resuming.");
|
||||
} else {
|
||||
m_mod_id.BumpResumeID();
|
||||
@@ -3317,7 +3328,7 @@ Status Process::PrivateResume() {
|
||||
|
||||
Status Process::Halt(bool clear_thread_plans, bool use_run_lock) {
|
||||
if (!StateIsRunningState(m_public_state.GetValue()))
|
||||
return Status("Process is not running.");
|
||||
return Status::FromErrorString("Process is not running.");
|
||||
|
||||
// Don't clear the m_clear_thread_plans_on_stop, only set it to true if in
|
||||
// case it was already set and some thread plan logic calls halt on its own.
|
||||
@@ -3352,7 +3363,8 @@ Status Process::Halt(bool clear_thread_plans, bool use_run_lock) {
|
||||
|
||||
if (state == eStateInvalid || !event_sp) {
|
||||
// We timed out and didn't get a stop event...
|
||||
return Status("Halt timed out. State = %s", StateAsCString(GetState()));
|
||||
return Status::FromErrorStringWithFormat("Halt timed out. State = %s",
|
||||
StateAsCString(GetState()));
|
||||
}
|
||||
|
||||
BroadcastEvent(event_sp);
|
||||
@@ -3430,7 +3442,7 @@ Status Process::StopForDestroyOrDetach(lldb::EventSP &exit_event_sp) {
|
||||
// really are stopped, then continue on.
|
||||
StateType private_state = m_private_state.GetValue();
|
||||
if (private_state != eStateStopped) {
|
||||
return Status(
|
||||
return Status::FromErrorStringWithFormat(
|
||||
"Attempt to stop the target in order to detach timed out. "
|
||||
"State = %s",
|
||||
StateAsCString(GetState()));
|
||||
@@ -6005,7 +6017,7 @@ void Process::DidExec() {
|
||||
|
||||
addr_t Process::ResolveIndirectFunction(const Address *address, Status &error) {
|
||||
if (address == nullptr) {
|
||||
error.SetErrorString("Invalid address argument");
|
||||
error = Status::FromErrorString("Invalid address argument");
|
||||
return LLDB_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
@@ -6019,7 +6031,7 @@ addr_t Process::ResolveIndirectFunction(const Address *address, Status &error) {
|
||||
} else {
|
||||
if (!CallVoidArgVoidPtrReturn(address, function_addr)) {
|
||||
Symbol *symbol = address->CalculateSymbolContextSymbol();
|
||||
error.SetErrorStringWithFormat(
|
||||
error = Status::FromErrorStringWithFormat(
|
||||
"Unable to call resolver for indirect function %s",
|
||||
symbol ? symbol->GetName().AsCString() : "<UNKNOWN>");
|
||||
function_addr = LLDB_INVALID_ADDRESS;
|
||||
@@ -6249,7 +6261,7 @@ Process::ConfigureStructuredData(llvm::StringRef type_name,
|
||||
// If you get this, the Process-derived class needs to implement a method to
|
||||
// enable an already-reported asynchronous structured data feature. See
|
||||
// ProcessGDBRemote for an example implementation over gdb-remote.
|
||||
return Status("unimplemented");
|
||||
return Status::FromErrorString("unimplemented");
|
||||
}
|
||||
|
||||
void Process::MapSupportedStructuredDataPlugins(
|
||||
@@ -6687,8 +6699,9 @@ FinalizeCoreFileSaveRanges(Process::CoreFileMemoryRanges &ranges) {
|
||||
next_region->SetRangeBase(base);
|
||||
next_region->SetByteSize(byte_size);
|
||||
if (!ranges.Erase(i, i + 1)) {
|
||||
error.SetErrorString("Core file memory ranges mutated outside of "
|
||||
"CalculateCoreFileSaveRanges");
|
||||
error = Status::FromErrorString(
|
||||
"Core file memory ranges mutated outside of "
|
||||
"CalculateCoreFileSaveRanges");
|
||||
return error;
|
||||
}
|
||||
}
|
||||
@@ -6704,10 +6717,12 @@ Status Process::CalculateCoreFileSaveRanges(const SaveCoreOptions &options,
|
||||
if (err.Fail())
|
||||
return err;
|
||||
if (regions.empty())
|
||||
return Status("failed to get any valid memory regions from the process");
|
||||
return Status::FromErrorString(
|
||||
"failed to get any valid memory regions from the process");
|
||||
if (core_style == eSaveCoreUnspecified)
|
||||
return Status("callers must set the core_style to something other than "
|
||||
"eSaveCoreUnspecified");
|
||||
return Status::FromErrorString(
|
||||
"callers must set the core_style to something other than "
|
||||
"eSaveCoreUnspecified");
|
||||
|
||||
GetUserSpecifiedCoreFileSaveRanges(*this, regions, options, ranges);
|
||||
|
||||
@@ -6740,7 +6755,8 @@ Status Process::CalculateCoreFileSaveRanges(const SaveCoreOptions &options,
|
||||
return err;
|
||||
|
||||
if (ranges.IsEmpty())
|
||||
return Status("no valid address ranges found for core style");
|
||||
return Status::FromErrorString(
|
||||
"no valid address ranges found for core style");
|
||||
|
||||
return FinalizeCoreFileSaveRanges(ranges);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user