Remove shared pointer from NativeProcessProtocol
Summary:
The usage of shared_from_this forces us to separate construction and
initialization phases, because shared_from_this() is not available in
the constructor (or destructor). The shared semantics are not necessary,
as we always have a clear owner of the native process class
(GDBRemoteCommunicationServerLLDB object). Even if we need shared
semantics in the future (which I think we should strongly avoid),
reverting this will not be necessary -- the owners can still easily
store the native process object in a shared pointer if they really want
to -- this just prevents the knowledge of that from leaking into the
class implementation.
After this a NativeThread object will hold a reference to the parent
process (instead of a weak_ptr) -- having a process instance always
available allows us to simplify some logic in this class (some of it was
already simplified because we were asserting that the process is
available, but this makes it obvious).
Reviewers: krytarowski, eugene, zturner
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D35123
llvm-svn: 308282
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index a7fe4ee..dddda31 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -239,7 +239,7 @@
{
std::lock_guard<std::recursive_mutex> guard(m_debugged_process_mutex);
- assert(!m_debugged_process_sp && "lldb-server creating debugged "
+ assert(!m_debugged_process_up && "lldb-server creating debugged "
"process but one already exists");
auto process_or =
m_process_factory.Launch(m_process_launch_info, *this, m_mainloop);
@@ -250,7 +250,7 @@
m_process_launch_info.GetArguments().GetArgumentAtIndex(0), status);
return status;
}
- m_debugged_process_sp = *process_or;
+ m_debugged_process_up = std::move(*process_or);
}
// Handle mirroring of inferior stdout/stderr over the gdb-remote protocol
@@ -263,14 +263,13 @@
// nullptr means it's not redirected to file or pty (in case of LLGS local)
// at least one of stdio will be transferred pty<->gdb-remote
// we need to give the pty master handle to this object to read and/or write
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
- " setting up stdout/stderr redirection via $O gdb-remote commands",
- __FUNCTION__, m_debugged_process_sp->GetID());
+ LLDB_LOG(log,
+ "pid = {0}: setting up stdout/stderr redirection via $O "
+ "gdb-remote commands",
+ m_debugged_process_up->GetID());
// Setup stdout/stderr mapping from inferior to $O
- auto terminal_fd = m_debugged_process_sp->GetTerminalFileDescriptor();
+ auto terminal_fd = m_debugged_process_up->GetTerminalFileDescriptor();
if (terminal_fd >= 0) {
if (log)
log->Printf("ProcessGDBRemoteCommunicationServerLLGS::%s setting "
@@ -286,16 +285,15 @@
__FUNCTION__, terminal_fd);
}
} else {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
- " skipping stdout/stderr redirection via $O: inferior will "
- "communicate over client-provided file descriptors",
- __FUNCTION__, m_debugged_process_sp->GetID());
+ LLDB_LOG(log,
+ "pid = {0} skipping stdout/stderr redirection via $O: inferior "
+ "will communicate over client-provided file descriptors",
+ m_debugged_process_up->GetID());
}
printf("Launched '%s' as process %" PRIu64 "...\n",
m_process_launch_info.GetArguments().GetArgumentAtIndex(0),
- m_debugged_process_sp->GetID());
+ m_debugged_process_up->GetID());
return Status();
}
@@ -308,12 +306,12 @@
// Before we try to attach, make sure we aren't already monitoring something
// else.
- if (m_debugged_process_sp &&
- m_debugged_process_sp->GetID() != LLDB_INVALID_PROCESS_ID)
+ if (m_debugged_process_up &&
+ m_debugged_process_up->GetID() != LLDB_INVALID_PROCESS_ID)
return Status("cannot attach to a process %" PRIu64
" when another process with pid %" PRIu64
" is being debugged.",
- pid, m_debugged_process_sp->GetID());
+ pid, m_debugged_process_up->GetID());
// Try to attach.
auto process_or = m_process_factory.Attach(pid, *this, m_mainloop);
@@ -323,10 +321,10 @@
status);
return status;
}
- m_debugged_process_sp = *process_or;
+ m_debugged_process_up = std::move(*process_or);
// Setup stdout/stderr mapping from inferior.
- auto terminal_fd = m_debugged_process_sp->GetTerminalFileDescriptor();
+ auto terminal_fd = m_debugged_process_up->GetTerminalFileDescriptor();
if (terminal_fd >= 0) {
if (log)
log->Printf("ProcessGDBRemoteCommunicationServerLLGS::%s setting "
@@ -597,18 +595,15 @@
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD));
// Ensure we have a debugged process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID))
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID))
return SendErrorResponse(50);
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s preparing packet for pid %" PRIu64
- " tid %" PRIu64,
- __FUNCTION__, m_debugged_process_sp->GetID(), tid);
+ LLDB_LOG(log, "preparing packet for pid {0} tid {1}",
+ m_debugged_process_up->GetID(), tid);
// Ensure we can get info on the given thread.
- NativeThreadProtocolSP thread_sp(m_debugged_process_sp->GetThreadByID(tid));
+ NativeThreadProtocolSP thread_sp(m_debugged_process_up->GetThreadByID(tid));
if (!thread_sp)
return SendErrorResponse(51);
@@ -629,13 +624,11 @@
// Output the T packet with the thread
response.PutChar('T');
int signum = tid_stop_info.details.signal.signo;
- if (log) {
- log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
- " tid %" PRIu64
- " got signal signo = %d, reason = %d, exc_type = %" PRIu64,
- __FUNCTION__, m_debugged_process_sp->GetID(), tid, signum,
- tid_stop_info.reason, tid_stop_info.details.exception.type);
- }
+ LLDB_LOG(
+ log,
+ "pid {0}, tid {1}, got signal signo = {2}, reason = {3}, exc_type = {4}",
+ m_debugged_process_up->GetID(), tid, signum, int(tid_stop_info.reason),
+ tid_stop_info.details.exception.type);
// Print the signal number.
response.PutHex8(signum & 0xff);
@@ -673,9 +666,9 @@
uint32_t thread_index = 0;
NativeThreadProtocolSP listed_thread_sp;
for (listed_thread_sp =
- m_debugged_process_sp->GetThreadAtIndex(thread_index);
+ m_debugged_process_up->GetThreadAtIndex(thread_index);
listed_thread_sp; ++thread_index,
- listed_thread_sp = m_debugged_process_sp->GetThreadAtIndex(
+ listed_thread_sp = m_debugged_process_up->GetThreadAtIndex(
thread_index)) {
if (thread_index > 0)
response.PutChar(',');
@@ -692,24 +685,23 @@
if (thread_index > 0) {
const bool threads_with_valid_stop_info_only = true;
JSONArray::SP threads_info_sp = GetJSONThreadsInfo(
- *m_debugged_process_sp, threads_with_valid_stop_info_only);
+ *m_debugged_process_up, threads_with_valid_stop_info_only);
if (threads_info_sp) {
response.PutCString("jstopinfo:");
StreamString unescaped_response;
threads_info_sp->Write(unescaped_response);
response.PutCStringAsRawHex8(unescaped_response.GetData());
response.PutChar(';');
- } else if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to prepare a "
- "jstopinfo field for pid %" PRIu64,
- __FUNCTION__, m_debugged_process_sp->GetID());
+ } else
+ LLDB_LOG(log, "failed to prepare a jstopinfo field for pid {0}",
+ m_debugged_process_up->GetID());
}
uint32_t i = 0;
response.PutCString("thread-pcs");
char delimiter = ':';
for (NativeThreadProtocolSP thread_sp;
- (thread_sp = m_debugged_process_sp->GetThreadAtIndex(i)) != nullptr;
+ (thread_sp = m_debugged_process_up->GetThreadAtIndex(i)) != nullptr;
++i) {
NativeRegisterContextSP reg_ctx_sp = thread_sp->GetRegisterContext();
if (!reg_ctx_sp)
@@ -1069,8 +1061,8 @@
StringExtractorGDBRemote &packet) {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
// Fail if we don't have a current process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID))
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID))
return SendErrorResponse(68);
if (!packet.ConsumeFront("jTraceStart:"))
@@ -1120,7 +1112,7 @@
Status error;
lldb::user_id_t uid = LLDB_INVALID_UID;
- uid = m_debugged_process_sp->StartTrace(options, error);
+ uid = m_debugged_process_up->StartTrace(options, error);
LLDB_LOG(log, "uid is {0} , error is {1}", uid, error.GetError());
if (error.Fail())
return SendErrorResponse(error);
@@ -1134,8 +1126,8 @@
GDBRemoteCommunicationServerLLGS::Handle_jTraceStop(
StringExtractorGDBRemote &packet) {
// Fail if we don't have a current process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID))
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID))
return SendErrorResponse(68);
if (!packet.ConsumeFront("jTraceStop:"))
@@ -1157,7 +1149,7 @@
json_dict->GetValueForKeyAsInteger("threadid", tid);
- Status error = m_debugged_process_sp->StopTrace(uid, tid);
+ Status error = m_debugged_process_up->StopTrace(uid, tid);
if (error.Fail())
return SendErrorResponse(error);
@@ -1170,8 +1162,8 @@
StringExtractorGDBRemote &packet) {
// Fail if we don't have a current process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID))
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID))
return SendErrorResponse(68);
if (!packet.ConsumeFront("jTraceConfigRead:"))
@@ -1200,7 +1192,7 @@
StreamGDBRemote response;
options.setThreadID(threadid);
- Status error = m_debugged_process_sp->GetTraceConfig(uid, options);
+ Status error = m_debugged_process_up->GetTraceConfig(uid, options);
if (error.Fail())
return SendErrorResponse(error);
@@ -1228,8 +1220,8 @@
StringExtractorGDBRemote &packet) {
// Fail if we don't have a current process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID))
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID))
return SendErrorResponse(68);
enum PacketType { MetaData, BufferData };
@@ -1274,9 +1266,9 @@
llvm::MutableArrayRef<uint8_t> buf(buffer.get(), byte_count);
if (tracetype == BufferData)
- error = m_debugged_process_sp->GetData(uid, tid, buf, offset);
+ error = m_debugged_process_up->GetData(uid, tid, buf, offset);
else if (tracetype == MetaData)
- error = m_debugged_process_sp->GetMetaData(uid, tid, buf, offset);
+ error = m_debugged_process_up->GetMetaData(uid, tid, buf, offset);
if (error.Fail())
return SendErrorResponse(error);
@@ -1293,11 +1285,11 @@
GDBRemoteCommunicationServerLLGS::Handle_qProcessInfo(
StringExtractorGDBRemote &packet) {
// Fail if we don't have a current process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID))
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID))
return SendErrorResponse(68);
- lldb::pid_t pid = m_debugged_process_sp->GetID();
+ lldb::pid_t pid = m_debugged_process_up->GetID();
if (pid == LLDB_INVALID_PROCESS_ID)
return SendErrorResponse(1);
@@ -1314,16 +1306,16 @@
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerLLGS::Handle_qC(StringExtractorGDBRemote &packet) {
// Fail if we don't have a current process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID))
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID))
return SendErrorResponse(68);
// Make sure we set the current thread so g and p packets return
// the data the gdb will expect.
- lldb::tid_t tid = m_debugged_process_sp->GetCurrentThreadID();
+ lldb::tid_t tid = m_debugged_process_up->GetCurrentThreadID();
SetCurrentThreadID(tid);
- NativeThreadProtocolSP thread_sp = m_debugged_process_sp->GetCurrentThread();
+ NativeThreadProtocolSP thread_sp = m_debugged_process_up->GetCurrentThread();
if (!thread_sp)
return SendErrorResponse(69);
@@ -1339,20 +1331,15 @@
StopSTDIOForwarding();
- if (!m_debugged_process_sp) {
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s No debugged process found.",
- __FUNCTION__);
+ if (!m_debugged_process_up) {
+ LLDB_LOG(log, "No debugged process found.");
return PacketResult::Success;
}
- Status error = m_debugged_process_sp->Kill();
- if (error.Fail() && log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s Failed to kill debugged "
- "process %" PRIu64 ": %s",
- __FUNCTION__, m_debugged_process_sp->GetID(),
- error.AsCString());
+ Status error = m_debugged_process_up->Kill();
+ if (error.Fail())
+ LLDB_LOG(log, "Failed to kill debugged process {0}: {1}",
+ m_debugged_process_up->GetID(), error);
// No OK response for kill packet.
// return SendOKResponse ();
@@ -1400,7 +1387,7 @@
log->Printf("GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
// Ensure we have a native process.
- if (!m_debugged_process_sp) {
+ if (!m_debugged_process_up) {
if (log)
log->Printf("GDBRemoteCommunicationServerLLGS::%s no debugged process "
"shared pointer",
@@ -1453,26 +1440,20 @@
} else {
// Send the signal to the process since we weren't targeting a specific
// continue thread with the signal.
- error = m_debugged_process_sp->Signal(signo);
+ error = m_debugged_process_up->Signal(signo);
if (error.Fail()) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to send "
- "signal for process %" PRIu64 ": %s",
- __FUNCTION__, m_debugged_process_sp->GetID(),
- error.AsCString());
+ LLDB_LOG(log, "failed to send signal for process {0}: {1}",
+ m_debugged_process_up->GetID(), error);
return SendErrorResponse(0x52);
}
}
// Resume the threads.
- error = m_debugged_process_sp->Resume(resume_actions);
+ error = m_debugged_process_up->Resume(resume_actions);
if (error.Fail()) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to resume "
- "threads for process %" PRIu64 ": %s",
- __FUNCTION__, m_debugged_process_sp->GetID(),
- error.AsCString());
+ LLDB_LOG(log, "failed to resume threads for process {0}: {1}",
+ m_debugged_process_up->GetID(), error);
return SendErrorResponse(0x38);
}
@@ -1492,15 +1473,13 @@
// For now just support all continue.
const bool has_continue_address = (packet.GetBytesLeft() > 0);
if (has_continue_address) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s not implemented for "
- "c{address} variant [%s remains]",
- __FUNCTION__, packet.Peek());
+ LLDB_LOG(log, "not implemented for c[address] variant [{0} remains]",
+ packet.Peek());
return SendUnimplementedResponse(packet.GetStringRef().c_str());
}
// Ensure we have a native process.
- if (!m_debugged_process_sp) {
+ if (!m_debugged_process_up) {
if (log)
log->Printf("GDBRemoteCommunicationServerLLGS::%s no debugged process "
"shared pointer",
@@ -1511,22 +1490,14 @@
// Build the ResumeActionList
ResumeActionList actions(StateType::eStateRunning, 0);
- Status error = m_debugged_process_sp->Resume(actions);
+ Status error = m_debugged_process_up->Resume(actions);
if (error.Fail()) {
- if (log) {
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s c failed for process %" PRIu64
- ": %s",
- __FUNCTION__, m_debugged_process_sp->GetID(), error.AsCString());
- }
+ LLDB_LOG(log, "c failed for process {0}: {1}",
+ m_debugged_process_up->GetID(), error);
return SendErrorResponse(GDBRemoteServerError::eErrorResume);
}
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s continued process %" PRIu64,
- __FUNCTION__, m_debugged_process_sp->GetID());
-
+ LLDB_LOG(log, "continued process {0}", m_debugged_process_up->GetID());
// No response required from continue.
return PacketResult::Success;
}
@@ -1570,11 +1541,8 @@
}
// Ensure we have a native process.
- if (!m_debugged_process_sp) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s no debugged process "
- "shared pointer",
- __FUNCTION__);
+ if (!m_debugged_process_up) {
+ LLDB_LOG(log, "no debugged process");
return SendErrorResponse(0x36);
}
@@ -1635,44 +1603,30 @@
thread_actions.Append(thread_action);
}
- Status error = m_debugged_process_sp->Resume(thread_actions);
+ Status error = m_debugged_process_up->Resume(thread_actions);
if (error.Fail()) {
- if (log) {
- log->Printf("GDBRemoteCommunicationServerLLGS::%s vCont failed for "
- "process %" PRIu64 ": %s",
- __FUNCTION__, m_debugged_process_sp->GetID(),
- error.AsCString());
- }
+ LLDB_LOG(log, "vCont failed for process {0}: {1}",
+ m_debugged_process_up->GetID(), error);
return SendErrorResponse(GDBRemoteServerError::eErrorResume);
}
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s continued process %" PRIu64,
- __FUNCTION__, m_debugged_process_sp->GetID());
-
+ LLDB_LOG(log, "continued process {0}", m_debugged_process_up->GetID());
// No response required from vCont.
return PacketResult::Success;
}
void GDBRemoteCommunicationServerLLGS::SetCurrentThreadID(lldb::tid_t tid) {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD));
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s setting current thread "
- "id to %" PRIu64,
- __FUNCTION__, tid);
+ LLDB_LOG(log, "setting current thread id to {0}", tid);
m_current_tid = tid;
- if (m_debugged_process_sp)
- m_debugged_process_sp->SetCurrentThreadID(m_current_tid);
+ if (m_debugged_process_up)
+ m_debugged_process_up->SetCurrentThreadID(m_current_tid);
}
void GDBRemoteCommunicationServerLLGS::SetContinueThreadID(lldb::tid_t tid) {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD));
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s setting continue thread "
- "id to %" PRIu64,
- __FUNCTION__, tid);
+ LLDB_LOG(log, "setting continue thread id to {0}", tid);
m_continue_tid = tid;
}
@@ -1683,10 +1637,10 @@
// Handle the $? gdbremote command.
// If no process, indicate error
- if (!m_debugged_process_sp)
+ if (!m_debugged_process_up)
return SendErrorResponse(02);
- return SendStopReasonForState(m_debugged_process_sp->GetState());
+ return SendStopReasonForState(m_debugged_process_up->GetState());
}
GDBRemoteCommunication::PacketResult
@@ -1707,7 +1661,7 @@
case eStateSuspended:
case eStateStopped:
case eStateCrashed: {
- lldb::tid_t tid = m_debugged_process_sp->GetCurrentThreadID();
+ lldb::tid_t tid = m_debugged_process_up->GetCurrentThreadID();
// Make sure we set the current thread so g and p packets return
// the data the gdb will expect.
SetCurrentThreadID(tid);
@@ -1717,15 +1671,11 @@
case eStateInvalid:
case eStateUnloaded:
case eStateExited:
- return SendWResponse(m_debugged_process_sp.get());
+ return SendWResponse(m_debugged_process_up.get());
default:
- if (log) {
- log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
- ", current state reporting not handled: %s",
- __FUNCTION__, m_debugged_process_sp->GetID(),
- StateAsCString(process_state));
- }
+ LLDB_LOG(log, "pid {0}, current state reporting not handled: {1}",
+ m_debugged_process_up->GetID(), process_state);
break;
}
@@ -1736,12 +1686,12 @@
GDBRemoteCommunicationServerLLGS::Handle_qRegisterInfo(
StringExtractorGDBRemote &packet) {
// Fail if we don't have a current process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID))
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID))
return SendErrorResponse(68);
// Ensure we have a thread.
- NativeThreadProtocolSP thread_sp(m_debugged_process_sp->GetThreadAtIndex(0));
+ NativeThreadProtocolSP thread_sp(m_debugged_process_up->GetThreadAtIndex(0));
if (!thread_sp)
return SendErrorResponse(69);
@@ -1945,47 +1895,33 @@
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD));
// Fail if we don't have a current process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s() no process (%s), "
- "returning OK",
- __FUNCTION__,
- m_debugged_process_sp ? "invalid process id"
- : "null m_debugged_process_sp");
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
+ LLDB_LOG(log, "no process ({0}), returning OK",
+ m_debugged_process_up ? "invalid process id"
+ : "null m_debugged_process_up");
return SendOKResponse();
}
StreamGDBRemote response;
response.PutChar('m');
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s() starting thread iteration",
- __FUNCTION__);
-
+ LLDB_LOG(log, "starting thread iteration");
NativeThreadProtocolSP thread_sp;
uint32_t thread_index;
for (thread_index = 0,
- thread_sp = m_debugged_process_sp->GetThreadAtIndex(thread_index);
+ thread_sp = m_debugged_process_up->GetThreadAtIndex(thread_index);
thread_sp; ++thread_index,
- thread_sp = m_debugged_process_sp->GetThreadAtIndex(thread_index)) {
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s() iterated thread %" PRIu32
- "(%s, tid=0x%" PRIx64 ")",
- __FUNCTION__, thread_index, thread_sp ? "is not null" : "null",
- thread_sp ? thread_sp->GetID() : LLDB_INVALID_THREAD_ID);
+ thread_sp = m_debugged_process_up->GetThreadAtIndex(thread_index)) {
+ LLDB_LOG(log, "iterated thread {0}({1}, tid={2})", thread_index,
+ thread_sp ? "is not null" : "null",
+ thread_sp ? thread_sp->GetID() : LLDB_INVALID_THREAD_ID);
if (thread_index > 0)
response.PutChar(',');
response.Printf("%" PRIx64, thread_sp->GetID());
}
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s() finished thread iteration",
- __FUNCTION__);
-
+ LLDB_LOG(log, "finished thread iteration");
return SendPacketNoLock(response.GetString());
}
@@ -2026,11 +1962,10 @@
// Get the thread's register context.
NativeRegisterContextSP reg_context_sp(thread_sp->GetRegisterContext());
if (!reg_context_sp) {
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64 " tid %" PRIu64
- " failed, no register context available for the thread",
- __FUNCTION__, m_debugged_process_sp->GetID(), thread_sp->GetID());
+ LLDB_LOG(
+ log,
+ "pid {0} tid {1} failed, no register context available for the thread",
+ m_debugged_process_up->GetID(), thread_sp->GetID());
return SendErrorResponse(0x15);
}
@@ -2113,8 +2048,8 @@
// Get process architecture.
ArchSpec process_arch;
- if (!m_debugged_process_sp ||
- !m_debugged_process_sp->GetArchitecture(process_arch)) {
+ if (!m_debugged_process_up ||
+ !m_debugged_process_up->GetArchitecture(process_arch)) {
if (log)
log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to retrieve "
"inferior architecture",
@@ -2143,7 +2078,7 @@
log->Printf(
"GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64 " tid %" PRIu64
" failed, no register context available for the thread",
- __FUNCTION__, m_debugged_process_sp->GetID(), thread_sp->GetID());
+ __FUNCTION__, m_debugged_process_up->GetID(), thread_sp->GetID());
return SendErrorResponse(0x15);
}
@@ -2197,8 +2132,8 @@
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD));
// Fail if we don't have a current process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)) {
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
if (log)
log->Printf(
"GDBRemoteCommunicationServerLLGS::%s failed, no process available",
@@ -2241,7 +2176,7 @@
// Ensure we have the given thread when not specifying -1 (all threads) or 0
// (any thread).
if (tid != LLDB_INVALID_THREAD_ID && tid != 0) {
- NativeThreadProtocolSP thread_sp(m_debugged_process_sp->GetThreadByID(tid));
+ NativeThreadProtocolSP thread_sp(m_debugged_process_up->GetThreadByID(tid));
if (!thread_sp) {
if (log)
log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, tid %" PRIu64
@@ -2275,8 +2210,8 @@
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD));
// Fail if we don't have a current process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)) {
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
if (log)
log->Printf(
"GDBRemoteCommunicationServerLLGS::%s failed, no process available",
@@ -2311,30 +2246,21 @@
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD));
// Fail if we don't have a current process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)) {
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
- __FUNCTION__);
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
+ LLDB_LOG(log, "failed, no process available");
return SendErrorResponse(0x15);
}
// Interrupt the process.
- Status error = m_debugged_process_sp->Interrupt();
+ Status error = m_debugged_process_up->Interrupt();
if (error.Fail()) {
- if (log) {
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s failed for process %" PRIu64
- ": %s",
- __FUNCTION__, m_debugged_process_sp->GetID(), error.AsCString());
- }
+ LLDB_LOG(log, "failed for process {0}: {1}", m_debugged_process_up->GetID(),
+ error);
return SendErrorResponse(GDBRemoteServerError::eErrorResume);
}
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s stopped process %" PRIu64,
- __FUNCTION__, m_debugged_process_sp->GetID());
+ LLDB_LOG(log, "stopped process {0}", m_debugged_process_up->GetID());
// No response required from stop all.
return PacketResult::Success;
@@ -2345,8 +2271,8 @@
StringExtractorGDBRemote &packet) {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)) {
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
if (log)
log->Printf(
"GDBRemoteCommunicationServerLLGS::%s failed, no process available",
@@ -2388,13 +2314,13 @@
// Retrieve the process memory.
size_t bytes_read = 0;
- Status error = m_debugged_process_sp->ReadMemoryWithoutTrap(
+ Status error = m_debugged_process_up->ReadMemoryWithoutTrap(
read_addr, &buf[0], byte_count, bytes_read);
if (error.Fail()) {
if (log)
log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
" mem 0x%" PRIx64 ": failed to read. Error: %s",
- __FUNCTION__, m_debugged_process_sp->GetID(), read_addr,
+ __FUNCTION__, m_debugged_process_up->GetID(), read_addr,
error.AsCString());
return SendErrorResponse(0x08);
}
@@ -2403,7 +2329,7 @@
if (log)
log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
" mem 0x%" PRIx64 ": read 0 of %" PRIu64 " requested bytes",
- __FUNCTION__, m_debugged_process_sp->GetID(), read_addr,
+ __FUNCTION__, m_debugged_process_up->GetID(), read_addr,
byte_count);
return SendErrorResponse(0x08);
}
@@ -2426,8 +2352,8 @@
GDBRemoteCommunicationServerLLGS::Handle_M(StringExtractorGDBRemote &packet) {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)) {
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
if (log)
log->Printf(
"GDBRemoteCommunicationServerLLGS::%s failed, no process available",
@@ -2455,10 +2381,7 @@
const uint64_t byte_count = packet.GetHexMaxU64(false, 0);
if (byte_count == 0) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s nothing to write: "
- "zero-length packet",
- __FUNCTION__);
+ LLDB_LOG(log, "nothing to write: zero-length packet");
return PacketResult::Success;
}
@@ -2476,12 +2399,11 @@
StreamGDBRemote response;
const uint64_t convert_count = packet.GetHexBytes(buf, 0);
if (convert_count != byte_count) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
- " mem 0x%" PRIx64 ": asked to write %" PRIu64
- " bytes, but only found %" PRIu64 " to convert.",
- __FUNCTION__, m_debugged_process_sp->GetID(), write_addr,
- byte_count, convert_count);
+ LLDB_LOG(log,
+ "pid {0} mem {1:x}: asked to write {2} bytes, but only found {3} "
+ "to convert.",
+ m_debugged_process_up->GetID(), write_addr, byte_count,
+ convert_count);
return SendIllFormedResponse(packet, "M content byte length specified did "
"not match hex-encoded content "
"length");
@@ -2489,23 +2411,17 @@
// Write the process memory.
size_t bytes_written = 0;
- Status error = m_debugged_process_sp->WriteMemory(write_addr, &buf[0],
+ Status error = m_debugged_process_up->WriteMemory(write_addr, &buf[0],
byte_count, bytes_written);
if (error.Fail()) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
- " mem 0x%" PRIx64 ": failed to write. Error: %s",
- __FUNCTION__, m_debugged_process_sp->GetID(), write_addr,
- error.AsCString());
+ LLDB_LOG(log, "pid {0} mem {1:x}: failed to write. Error: {2}",
+ m_debugged_process_up->GetID(), write_addr, error);
return SendErrorResponse(0x09);
}
if (bytes_written == 0) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
- " mem 0x%" PRIx64 ": wrote 0 of %" PRIu64 " requested bytes",
- __FUNCTION__, m_debugged_process_sp->GetID(), write_addr,
- byte_count);
+ LLDB_LOG(log, "pid {0} mem {1:x}: wrote 0 of {2} requested bytes",
+ m_debugged_process_up->GetID(), write_addr, byte_count);
return SendErrorResponse(0x09);
}
@@ -2525,8 +2441,8 @@
// Ensure we have a process running; otherwise, we can't figure this out
// since we won't have a NativeProcessProtocol.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)) {
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
if (log)
log->Printf(
"GDBRemoteCommunicationServerLLGS::%s failed, no process available",
@@ -2537,7 +2453,7 @@
// Test if we can get any region back when asking for the region around NULL.
MemoryRegionInfo region_info;
const Status error =
- m_debugged_process_sp->GetMemoryRegionInfo(0, region_info);
+ m_debugged_process_up->GetMemoryRegionInfo(0, region_info);
if (error.Fail()) {
// We don't support memory region info collection for this
// NativeProcessProtocol.
@@ -2553,8 +2469,8 @@
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
// Ensure we have a process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)) {
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
if (log)
log->Printf(
"GDBRemoteCommunicationServerLLGS::%s failed, no process available",
@@ -2575,7 +2491,7 @@
// Get the memory region info for the target address.
MemoryRegionInfo region_info;
const Status error =
- m_debugged_process_sp->GetMemoryRegionInfo(read_addr, region_info);
+ m_debugged_process_up->GetMemoryRegionInfo(read_addr, region_info);
if (error.Fail()) {
// Return the error message.
@@ -2619,13 +2535,10 @@
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerLLGS::Handle_Z(StringExtractorGDBRemote &packet) {
// Ensure we have a process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)) {
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
- __FUNCTION__);
+ LLDB_LOG(log, "failed, no process available");
return SendErrorResponse(0x15);
}
@@ -2693,28 +2606,22 @@
if (want_breakpoint) {
// Try to set the breakpoint.
const Status error =
- m_debugged_process_sp->SetBreakpoint(addr, size, want_hardware);
+ m_debugged_process_up->SetBreakpoint(addr, size, want_hardware);
if (error.Success())
return SendOKResponse();
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
- " failed to set breakpoint: %s",
- __FUNCTION__, m_debugged_process_sp->GetID(),
- error.AsCString());
+ LLDB_LOG(log, "pid {0} failed to set breakpoint: {1}",
+ m_debugged_process_up->GetID(), error);
return SendErrorResponse(0x09);
} else {
// Try to set the watchpoint.
- const Status error = m_debugged_process_sp->SetWatchpoint(
+ const Status error = m_debugged_process_up->SetWatchpoint(
addr, size, watch_flags, want_hardware);
if (error.Success())
return SendOKResponse();
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
- " failed to set watchpoint: %s",
- __FUNCTION__, m_debugged_process_sp->GetID(),
- error.AsCString());
+ LLDB_LOG(log, "pid {0} failed to set watchpoint: {1}",
+ m_debugged_process_up->GetID(), error);
return SendErrorResponse(0x09);
}
}
@@ -2722,13 +2629,10 @@
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerLLGS::Handle_z(StringExtractorGDBRemote &packet) {
// Ensure we have a process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)) {
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
- __FUNCTION__);
+ LLDB_LOG(log, "failed, no process available");
return SendErrorResponse(0x15);
}
@@ -2790,27 +2694,21 @@
if (want_breakpoint) {
// Try to clear the breakpoint.
const Status error =
- m_debugged_process_sp->RemoveBreakpoint(addr, want_hardware);
+ m_debugged_process_up->RemoveBreakpoint(addr, want_hardware);
if (error.Success())
return SendOKResponse();
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
- " failed to remove breakpoint: %s",
- __FUNCTION__, m_debugged_process_sp->GetID(),
- error.AsCString());
+ LLDB_LOG(log, "pid {0} failed to remove breakpoint: {1}",
+ m_debugged_process_up->GetID(), error);
return SendErrorResponse(0x09);
} else {
// Try to clear the watchpoint.
- const Status error = m_debugged_process_sp->RemoveWatchpoint(addr);
+ const Status error = m_debugged_process_up->RemoveWatchpoint(addr);
if (error.Success())
return SendOKResponse();
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
- " failed to remove watchpoint: %s",
- __FUNCTION__, m_debugged_process_sp->GetID(),
- error.AsCString());
+ LLDB_LOG(log, "pid {0} failed to remove watchpoint: {1}",
+ m_debugged_process_up->GetID(), error);
return SendErrorResponse(0x09);
}
}
@@ -2820,8 +2718,8 @@
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD));
// Ensure we have a process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)) {
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
if (log)
log->Printf(
"GDBRemoteCommunicationServerLLGS::%s failed, no process available",
@@ -2840,7 +2738,7 @@
// Double check that we have such a thread.
// TODO investigate: on MacOSX we might need to do an UpdateThreads () here.
- NativeThreadProtocolSP thread_sp = m_debugged_process_sp->GetThreadByID(tid);
+ NativeThreadProtocolSP thread_sp = m_debugged_process_up->GetThreadByID(tid);
if (!thread_sp || thread_sp->GetID() != tid)
return SendErrorResponse(0x33);
@@ -2853,12 +2751,12 @@
// All other threads stop while we're single stepping a thread.
actions.SetDefaultThreadActionIfNeeded(eStateStopped, 0);
- Status error = m_debugged_process_sp->Resume(actions);
+ Status error = m_debugged_process_up->Resume(actions);
if (error.Fail()) {
if (log)
log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
" tid %" PRIu64 " Resume() failed with error: %s",
- __FUNCTION__, m_debugged_process_sp->GetID(), tid,
+ __FUNCTION__, m_debugged_process_up->GetID(), tid,
error.AsCString());
return SendErrorResponse(0x49);
}
@@ -2901,8 +2799,8 @@
// Grab the auxv data if we need it.
if (!m_active_auxv_buffer_up) {
// Make sure we have a valid process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)) {
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
if (log)
log->Printf(
"GDBRemoteCommunicationServerLLGS::%s failed, no process available",
@@ -2911,7 +2809,7 @@
}
// Grab the auxv data.
- auto buffer_or_error = m_debugged_process_sp->GetAuxvData();
+ auto buffer_or_error = m_debugged_process_up->GetAuxvData();
if (!buffer_or_error) {
std::error_code ec = buffer_or_error.getError();
LLDB_LOG(log, "no auxv data retrieved: {0}", ec.message());
@@ -2979,11 +2877,10 @@
// Grab the register context for the thread.
NativeRegisterContextSP reg_context_sp(thread_sp->GetRegisterContext());
if (!reg_context_sp) {
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64 " tid %" PRIu64
- " failed, no register context available for the thread",
- __FUNCTION__, m_debugged_process_sp->GetID(), thread_sp->GetID());
+ LLDB_LOG(
+ log,
+ "pid {0} tid {1} failed, no register context available for the thread",
+ m_debugged_process_up->GetID(), thread_sp->GetID());
return SendErrorResponse(0x15);
}
@@ -2991,11 +2888,8 @@
DataBufferSP register_data_sp;
Status error = reg_context_sp->ReadAllRegisterValues(register_data_sp);
if (error.Fail()) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
- " failed to save all register values: %s",
- __FUNCTION__, m_debugged_process_sp->GetID(),
- error.AsCString());
+ LLDB_LOG(log, "pid {0} failed to save all register values: {1}",
+ m_debugged_process_up->GetID(), error);
return SendErrorResponse(0x75);
}
@@ -3029,10 +2923,8 @@
const uint32_t save_id = packet.GetU32(0);
if (save_id == 0) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s QRestoreRegisterState "
- "packet has malformed save id, expecting decimal uint32_t",
- __FUNCTION__);
+ LLDB_LOG(log, "QRestoreRegisterState packet has malformed save id, "
+ "expecting decimal uint32_t");
return SendErrorResponse(0x76);
}
@@ -3050,11 +2942,10 @@
// Grab the register context for the thread.
NativeRegisterContextSP reg_context_sp(thread_sp->GetRegisterContext());
if (!reg_context_sp) {
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64 " tid %" PRIu64
- " failed, no register context available for the thread",
- __FUNCTION__, m_debugged_process_sp->GetID(), thread_sp->GetID());
+ LLDB_LOG(
+ log,
+ "pid {0} tid {1} failed, no register context available for the thread",
+ m_debugged_process_up->GetID(), thread_sp->GetID());
return SendErrorResponse(0x15);
}
@@ -3066,10 +2957,9 @@
// Find the register set buffer for the given save id.
auto it = m_saved_registers_map.find(save_id);
if (it == m_saved_registers_map.end()) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
- " does not have a register set save buffer for id %" PRIu32,
- __FUNCTION__, m_debugged_process_sp->GetID(), save_id);
+ LLDB_LOG(log,
+ "pid {0} does not have a register set save buffer for id {1}",
+ m_debugged_process_up->GetID(), save_id);
return SendErrorResponse(0x77);
}
register_data_sp = it->second;
@@ -3080,11 +2970,8 @@
Status error = reg_context_sp->WriteAllRegisterValues(register_data_sp);
if (error.Fail()) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
- " failed to restore all register values: %s",
- __FUNCTION__, m_debugged_process_sp->GetID(),
- error.AsCString());
+ LLDB_LOG(log, "pid {0} failed to restore all register values: {1}",
+ m_debugged_process_up->GetID(), error);
return SendErrorResponse(0x77);
}
@@ -3124,7 +3011,7 @@
}
// Notify we attached by sending a stop packet.
- return SendStopReasonForState(m_debugged_process_sp->GetState());
+ return SendStopReasonForState(m_debugged_process_up->GetState());
}
GDBRemoteCommunication::PacketResult
@@ -3134,8 +3021,8 @@
StopSTDIOForwarding();
// Fail if we don't have a current process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)) {
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
if (log)
log->Printf(
"GDBRemoteCommunicationServerLLGS::%s failed, no process available",
@@ -3157,16 +3044,16 @@
return SendIllFormedResponse(packet, "D failed to parse the process id");
}
- if (pid != LLDB_INVALID_PROCESS_ID && m_debugged_process_sp->GetID() != pid) {
+ if (pid != LLDB_INVALID_PROCESS_ID && m_debugged_process_up->GetID() != pid) {
return SendIllFormedResponse(packet, "Invalid pid");
}
- const Status error = m_debugged_process_sp->Detach();
+ const Status error = m_debugged_process_up->Detach();
if (error.Fail()) {
if (log)
log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to detach from "
"pid %" PRIu64 ": %s\n",
- __FUNCTION__, m_debugged_process_sp->GetID(),
+ __FUNCTION__, m_debugged_process_up->GetID(),
error.AsCString());
return SendErrorResponse(0x01);
}
@@ -3197,24 +3084,18 @@
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD));
// Ensure we have a debugged process.
- if (!m_debugged_process_sp ||
- (m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID))
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID))
return SendErrorResponse(50);
-
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s preparing packet for pid "
- "%" PRIu64,
- __FUNCTION__, m_debugged_process_sp->GetID());
+ LLDB_LOG(log, "preparing packet for pid {0}", m_debugged_process_up->GetID());
StreamString response;
const bool threads_with_valid_stop_info_only = false;
JSONArray::SP threads_array_sp = GetJSONThreadsInfo(
- *m_debugged_process_sp, threads_with_valid_stop_info_only);
+ *m_debugged_process_up, threads_with_valid_stop_info_only);
if (!threads_array_sp) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to prepare a "
- "packet for pid %" PRIu64,
- __FUNCTION__, m_debugged_process_sp->GetID());
+ LLDB_LOG(log, "failed to prepare a packet for pid {0}",
+ m_debugged_process_up->GetID());
return SendErrorResponse(52);
}
@@ -3228,8 +3109,8 @@
GDBRemoteCommunicationServerLLGS::Handle_qWatchpointSupportInfo(
StringExtractorGDBRemote &packet) {
// Fail if we don't have a current process.
- if (!m_debugged_process_sp ||
- m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)
+ if (!m_debugged_process_up ||
+ m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)
return SendErrorResponse(68);
packet.SetFilePos(strlen("qWatchpointSupportInfo"));
@@ -3238,7 +3119,7 @@
if (packet.GetChar() != ':')
return SendErrorResponse(67);
- auto hw_debug_cap = m_debugged_process_sp->GetHardwareDebugSupportInfo();
+ auto hw_debug_cap = m_debugged_process_up->GetHardwareDebugSupportInfo();
StreamGDBRemote response;
if (hw_debug_cap == llvm::None)
@@ -3253,8 +3134,8 @@
GDBRemoteCommunicationServerLLGS::Handle_qFileLoadAddress(
StringExtractorGDBRemote &packet) {
// Fail if we don't have a current process.
- if (!m_debugged_process_sp ||
- m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)
+ if (!m_debugged_process_up ||
+ m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)
return SendErrorResponse(67);
packet.SetFilePos(strlen("qFileLoadAddress:"));
@@ -3266,7 +3147,7 @@
lldb::addr_t file_load_address = LLDB_INVALID_ADDRESS;
Status error =
- m_debugged_process_sp->GetFileLoadAddress(file_name, file_load_address);
+ m_debugged_process_up->GetFileLoadAddress(file_name, file_load_address);
if (error.Fail())
return SendErrorResponse(69);
@@ -3302,10 +3183,10 @@
}
// Fail if we don't have a current process.
- if (!m_debugged_process_sp)
+ if (!m_debugged_process_up)
return SendErrorResponse(68);
- Status error = m_debugged_process_sp->IgnoreSignals(signals);
+ Status error = m_debugged_process_up->IgnoreSignals(signals);
if (error.Fail())
return SendErrorResponse(69);
@@ -3342,8 +3223,8 @@
NativeThreadProtocolSP thread_sp;
// We have no thread if we don't have a process.
- if (!m_debugged_process_sp ||
- m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)
+ if (!m_debugged_process_up ||
+ m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)
return thread_sp;
// If the client hasn't asked for thread suffix support, there will not be a
@@ -3355,9 +3236,9 @@
return thread_sp;
else if (current_tid == 0) {
// Pick a thread.
- return m_debugged_process_sp->GetThreadAtIndex(0);
+ return m_debugged_process_up->GetThreadAtIndex(0);
} else
- return m_debugged_process_sp->GetThreadByID(current_tid);
+ return m_debugged_process_up->GetThreadByID(current_tid);
}
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD));
@@ -3387,7 +3268,7 @@
packet.SetFilePos(packet.GetFilePos() + strlen("thread:"));
const lldb::tid_t tid = packet.GetHexMaxU64(false, 0);
if (tid != 0)
- return m_debugged_process_sp->GetThreadByID(tid);
+ return m_debugged_process_up->GetThreadByID(tid);
return thread_sp;
}
@@ -3397,9 +3278,9 @@
// Use whatever the debug process says is the current thread id
// since the protocol either didn't specify or specified we want
// any/all threads marked as the current thread.
- if (!m_debugged_process_sp)
+ if (!m_debugged_process_up)
return LLDB_INVALID_THREAD_ID;
- return m_debugged_process_sp->GetCurrentThreadID();
+ return m_debugged_process_up->GetCurrentThreadID();
}
// Use the specific current thread id set by the gdb remote protocol.
return m_current_tid;
@@ -3420,9 +3301,9 @@
FileSpec
GDBRemoteCommunicationServerLLGS::FindModuleFile(const std::string &module_path,
const ArchSpec &arch) {
- if (m_debugged_process_sp) {
+ if (m_debugged_process_up) {
FileSpec file_spec;
- if (m_debugged_process_sp
+ if (m_debugged_process_up
->GetLoadedModuleFileSpec(module_path.c_str(), file_spec)
.Success()) {
if (file_spec.Exists())