summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-07-24 17:56:10 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-07-24 17:56:10 +0000
commit63e5fb76ecfed3434252868d8cf07d676f979f2f (patch)
tree349d6bd303f53aa57b988dee284c7f264404a8fc /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
parent2bf871be4c35d70db080dde789cf9bb334c04057 (diff)
downloadbcm5719-llvm-63e5fb76ecfed3434252868d8cf07d676f979f2f.tar.gz
bcm5719-llvm-63e5fb76ecfed3434252868d8cf07d676f979f2f.zip
[Logging] Replace Log::Printf with LLDB_LOG macro (NFC)
This patch replaces explicit calls to log::Printf with the new LLDB_LOGF macro. The macro is similar to LLDB_LOG but supports printf-style format strings, instead of formatv-style format strings. So instead of writing: if (log) log->Printf("%s\n", str); You'd write: LLDB_LOG(log, "%s\n", str); This change was done mechanically with the command below. I replaced the spurious if-checks with vim, since I know how to do multi-line replacements with it. find . -type f -name '*.cpp' -exec \ sed -i '' -E 's/log->Printf\(/LLDB_LOGF\(log, /g' "{}" + Differential revision: https://reviews.llvm.org/D65128 llvm-svn: 366936
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp500
1 files changed, 246 insertions, 254 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 190db341ae0..6bdbbd24fdb 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -249,18 +249,18 @@ Status GDBRemoteCommunicationServerLLGS::LaunchProcess() {
// Setup stdout/stderr mapping from inferior to $O
auto terminal_fd = m_debugged_process_up->GetTerminalFileDescriptor();
if (terminal_fd >= 0) {
- if (log)
- log->Printf("ProcessGDBRemoteCommunicationServerLLGS::%s setting "
- "inferior STDIO fd to %d",
- __FUNCTION__, terminal_fd);
+ LLDB_LOGF(log,
+ "ProcessGDBRemoteCommunicationServerLLGS::%s setting "
+ "inferior STDIO fd to %d",
+ __FUNCTION__, terminal_fd);
Status status = SetSTDIOFileDescriptor(terminal_fd);
if (status.Fail())
return status;
} else {
- if (log)
- log->Printf("ProcessGDBRemoteCommunicationServerLLGS::%s ignoring "
- "inferior STDIO since terminal fd reported as %d",
- __FUNCTION__, terminal_fd);
+ LLDB_LOGF(log,
+ "ProcessGDBRemoteCommunicationServerLLGS::%s ignoring "
+ "inferior STDIO since terminal fd reported as %d",
+ __FUNCTION__, terminal_fd);
}
} else {
LLDB_LOG(log,
@@ -278,9 +278,8 @@ Status GDBRemoteCommunicationServerLLGS::LaunchProcess() {
Status GDBRemoteCommunicationServerLLGS::AttachToProcess(lldb::pid_t pid) {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64,
- __FUNCTION__, pid);
+ LLDB_LOGF(log, "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64,
+ __FUNCTION__, pid);
// Before we try to attach, make sure we aren't already monitoring something
// else.
@@ -304,18 +303,18 @@ Status GDBRemoteCommunicationServerLLGS::AttachToProcess(lldb::pid_t pid) {
// Setup stdout/stderr mapping from inferior.
auto terminal_fd = m_debugged_process_up->GetTerminalFileDescriptor();
if (terminal_fd >= 0) {
- if (log)
- log->Printf("ProcessGDBRemoteCommunicationServerLLGS::%s setting "
- "inferior STDIO fd to %d",
- __FUNCTION__, terminal_fd);
+ LLDB_LOGF(log,
+ "ProcessGDBRemoteCommunicationServerLLGS::%s setting "
+ "inferior STDIO fd to %d",
+ __FUNCTION__, terminal_fd);
Status status = SetSTDIOFileDescriptor(terminal_fd);
if (status.Fail())
return status;
} else {
- if (log)
- log->Printf("ProcessGDBRemoteCommunicationServerLLGS::%s ignoring "
- "inferior STDIO since terminal fd reported as %d",
- __FUNCTION__, terminal_fd);
+ LLDB_LOGF(log,
+ "ProcessGDBRemoteCommunicationServerLLGS::%s ignoring "
+ "inferior STDIO since terminal fd reported as %d",
+ __FUNCTION__, terminal_fd);
}
printf("Attached to process %" PRIu64 "...\n", pid);
@@ -327,10 +326,11 @@ void GDBRemoteCommunicationServerLLGS::InitializeDelegate(
assert(process && "process cannot be NULL");
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
if (log) {
- log->Printf("GDBRemoteCommunicationServerLLGS::%s called with "
- "NativeProcessProtocol pid %" PRIu64 ", current state: %s",
- __FUNCTION__, process->GetID(),
- StateAsCString(process->GetState()));
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s called with "
+ "NativeProcessProtocol pid %" PRIu64 ", current state: %s",
+ __FUNCTION__, process->GetID(),
+ StateAsCString(process->GetState()));
}
}
@@ -431,10 +431,9 @@ static JSONObject::SP GetRegistersAsJSON(NativeThreadProtocol &thread) {
const RegisterInfo *const reg_info_p =
reg_ctx.GetRegisterInfoAtIndex(reg_num);
if (reg_info_p == nullptr) {
- if (log)
- log->Printf(
- "%s failed to get register info for register index %" PRIu32,
- __FUNCTION__, reg_num);
+ LLDB_LOGF(log,
+ "%s failed to get register info for register index %" PRIu32,
+ __FUNCTION__, reg_num);
continue;
}
@@ -445,11 +444,10 @@ static JSONObject::SP GetRegistersAsJSON(NativeThreadProtocol &thread) {
RegisterValue reg_value;
Status error = reg_ctx.ReadRegister(reg_info_p, reg_value);
if (error.Fail()) {
- if (log)
- log->Printf("%s failed to read register '%s' index %" PRIu32 ": %s",
- __FUNCTION__,
- reg_info_p->name ? reg_info_p->name : "<unnamed-register>",
- reg_num, error.AsCString());
+ LLDB_LOGF(log, "%s failed to read register '%s' index %" PRIu32 ": %s",
+ __FUNCTION__,
+ reg_info_p->name ? reg_info_p->name : "<unnamed-register>",
+ reg_num, error.AsCString());
continue;
}
@@ -511,11 +509,12 @@ static JSONArray::SP GetJSONThreadsInfo(NativeProcessProtocol &process,
const 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__, process.GetID(), tid, signum,
- tid_stop_info.reason, tid_stop_info.details.exception.type);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
+ " tid %" PRIu64
+ " got signal signo = %d, reason = %d, exc_type = %" PRIu64,
+ __FUNCTION__, process.GetID(), tid, signum,
+ tid_stop_info.reason, tid_stop_info.details.exception.type);
}
JSONObject::SP thread_obj_sp = std::make_shared<JSONObject>();
@@ -684,12 +683,10 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
RegisterValue reg_value;
Status error = reg_ctx.ReadRegister(reg_info_p, reg_value);
if (error.Fail()) {
- if (log)
- log->Printf("%s failed to read register '%s' index %" PRIu32 ": %s",
- __FUNCTION__,
- reg_info_p->name ? reg_info_p->name
- : "<unnamed-register>",
- reg_to_read, error.AsCString());
+ LLDB_LOGF(log, "%s failed to read register '%s' index %" PRIu32 ": %s",
+ __FUNCTION__,
+ reg_info_p->name ? reg_info_p->name : "<unnamed-register>",
+ reg_to_read, error.AsCString());
continue;
}
@@ -713,25 +710,24 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
const RegisterSet *reg_set_p;
if (reg_ctx.GetRegisterSetCount() > 0 &&
((reg_set_p = reg_ctx.GetRegisterSet(0)) != nullptr)) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s expediting registers "
- "from set '%s' (registers set count: %zu)",
- __FUNCTION__,
- reg_set_p->name ? reg_set_p->name : "<unnamed-set>",
- reg_set_p->num_registers);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s expediting registers "
+ "from set '%s' (registers set count: %zu)",
+ __FUNCTION__, reg_set_p->name ? reg_set_p->name : "<unnamed-set>",
+ reg_set_p->num_registers);
for (const uint32_t *reg_num_p = reg_set_p->registers;
*reg_num_p != LLDB_INVALID_REGNUM; ++reg_num_p) {
const RegisterInfo *const reg_info_p =
reg_ctx.GetRegisterInfoAtIndex(*reg_num_p);
if (reg_info_p == nullptr) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to get "
- "register info for register set '%s', register index "
- "%" PRIu32,
- __FUNCTION__,
- reg_set_p->name ? reg_set_p->name : "<unnamed-set>",
- *reg_num_p);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed to get "
+ "register info for register set '%s', register index "
+ "%" PRIu32,
+ __FUNCTION__,
+ reg_set_p->name ? reg_set_p->name : "<unnamed-set>",
+ *reg_num_p);
} else if (reg_info_p->value_regs == nullptr) {
// Only expediate registers that are not contained in other registers.
RegisterValue reg_value;
@@ -742,13 +738,12 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
&reg_value, lldb::eByteOrderBig);
response.PutChar(';');
} else {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to read "
- "register '%s' index %" PRIu32 ": %s",
- __FUNCTION__,
- reg_info_p->name ? reg_info_p->name
- : "<unnamed-register>",
- *reg_num_p, error.AsCString());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed to read "
+ "register '%s' index %" PRIu32 ": %s",
+ __FUNCTION__,
+ reg_info_p->name ? reg_info_p->name : "<unnamed-register>",
+ *reg_num_p, error.AsCString());
}
}
}
@@ -787,15 +782,14 @@ void GDBRemoteCommunicationServerLLGS::HandleInferiorState_Exited(
assert(process && "process cannot be NULL");
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
+ LLDB_LOGF(log, "GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
PacketResult result = SendStopReasonForState(StateType::eStateExited);
if (result != PacketResult::Success) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to send stop "
- "notification for PID %" PRIu64 ", state: eStateExited",
- __FUNCTION__, process->GetID());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed to send stop "
+ "notification for PID %" PRIu64 ", state: eStateExited",
+ __FUNCTION__, process->GetID());
}
// Close the pipe to the inferior terminal i/o if we launched it and set one
@@ -812,8 +806,7 @@ void GDBRemoteCommunicationServerLLGS::HandleInferiorState_Stopped(
assert(process && "process cannot be NULL");
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
+ LLDB_LOGF(log, "GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
// Send the stop reason unless this is the stop after the launch or attach.
switch (m_inferior_prev_state) {
@@ -825,10 +818,10 @@ void GDBRemoteCommunicationServerLLGS::HandleInferiorState_Stopped(
// In all other cases, send the stop reason.
PacketResult result = SendStopReasonForState(StateType::eStateStopped);
if (result != PacketResult::Success) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to send stop "
- "notification for PID %" PRIu64 ", state: eStateExited",
- __FUNCTION__, process->GetID());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed to send stop "
+ "notification for PID %" PRIu64 ", state: eStateExited",
+ __FUNCTION__, process->GetID());
}
break;
}
@@ -839,9 +832,10 @@ void GDBRemoteCommunicationServerLLGS::ProcessStateChanged(
assert(process && "process cannot be NULL");
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
if (log) {
- log->Printf("GDBRemoteCommunicationServerLLGS::%s called with "
- "NativeProcessProtocol pid %" PRIu64 ", state: %s",
- __FUNCTION__, process->GetID(), StateAsCString(state));
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s called with "
+ "NativeProcessProtocol pid %" PRIu64 ", state: %s",
+ __FUNCTION__, process->GetID(), StateAsCString(state));
}
switch (state) {
@@ -868,9 +862,10 @@ void GDBRemoteCommunicationServerLLGS::ProcessStateChanged(
default:
if (log) {
- log->Printf("GDBRemoteCommunicationServerLLGS::%s didn't handle state "
- "change for pid %" PRIu64 ", new state: %s",
- __FUNCTION__, process->GetID(), StateAsCString(state));
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s didn't handle state "
+ "change for pid %" PRIu64 ", new state: %s",
+ __FUNCTION__, process->GetID(), StateAsCString(state));
}
break;
}
@@ -888,10 +883,10 @@ void GDBRemoteCommunicationServerLLGS::DataAvailableCallback() {
if (!m_handshake_completed) {
if (!HandshakeWithClient()) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s handshake with "
- "client failed, exiting",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s handshake with "
+ "client failed, exiting",
+ __FUNCTION__);
m_mainloop.RequestTermination();
return;
}
@@ -908,10 +903,10 @@ void GDBRemoteCommunicationServerLLGS::DataAvailableCallback() {
break; // No more packets in the queue
if ((result != PacketResult::Success)) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s processing a packet "
- "failed: %s",
- __FUNCTION__, error.AsCString());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s processing a packet "
+ "failed: %s",
+ __FUNCTION__, error.AsCString());
m_mainloop.RequestTermination();
break;
}
@@ -982,9 +977,10 @@ void GDBRemoteCommunicationServerLLGS::StartSTDIOForwarding() {
// Not much we can do about the failure. Log it and continue without
// forwarding.
if (Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS))
- log->Printf("GDBRemoteCommunicationServerLLGS::%s Failed to set up stdio "
- "forwarding: %s",
- __FUNCTION__, error.AsCString());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s Failed to set up stdio "
+ "forwarding: %s",
+ __FUNCTION__, error.AsCString());
}
}
@@ -1008,10 +1004,11 @@ void GDBRemoteCommunicationServerLLGS::SendProcessOutput() {
case eConnectionStatusError:
case eConnectionStatusNoConnection:
if (Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS))
- log->Printf("GDBRemoteCommunicationServerLLGS::%s Stopping stdio "
- "forwarding as communication returned status %d (error: "
- "%s)",
- __FUNCTION__, status, error.AsCString());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s Stopping stdio "
+ "forwarding as communication returned status %d (error: "
+ "%s)",
+ __FUNCTION__, status, error.AsCString());
m_stdio_handle_up.reset();
return;
@@ -1349,15 +1346,14 @@ GDBRemoteCommunicationServerLLGS::Handle_qGetWorkingDir(
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerLLGS::Handle_C(StringExtractorGDBRemote &packet) {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD));
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
+ LLDB_LOGF(log, "GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
// Ensure we have a native process.
if (!m_debugged_process_up) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s no debugged process "
- "shared pointer",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s no debugged process "
+ "shared pointer",
+ __FUNCTION__);
return SendErrorResponse(0x36);
}
@@ -1430,8 +1426,7 @@ GDBRemoteCommunicationServerLLGS::Handle_C(StringExtractorGDBRemote &packet) {
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerLLGS::Handle_c(StringExtractorGDBRemote &packet) {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD));
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
+ LLDB_LOGF(log, "GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
packet.SetFilePos(packet.GetFilePos() + ::strlen("c"));
@@ -1445,10 +1440,10 @@ GDBRemoteCommunicationServerLLGS::Handle_c(StringExtractorGDBRemote &packet) {
// Ensure we have a native process.
if (!m_debugged_process_up) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s no debugged process "
- "shared pointer",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s no debugged process "
+ "shared pointer",
+ __FUNCTION__);
return SendErrorResponse(0x36);
}
@@ -1480,17 +1475,16 @@ GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerLLGS::Handle_vCont(
StringExtractorGDBRemote &packet) {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s handling vCont packet",
- __FUNCTION__);
+ LLDB_LOGF(log, "GDBRemoteCommunicationServerLLGS::%s handling vCont packet",
+ __FUNCTION__);
packet.SetFilePos(::strlen("vCont"));
if (packet.GetBytesLeft() == 0) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s missing action from "
- "vCont package",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s missing action from "
+ "vCont package",
+ __FUNCTION__);
return SendIllFormedResponse(packet, "Missing action from vCont package");
}
@@ -1958,10 +1952,10 @@ GDBRemoteCommunicationServerLLGS::Handle_p(StringExtractorGDBRemote &packet) {
const uint32_t reg_index =
packet.GetHexMaxU32(false, std::numeric_limits<uint32_t>::max());
if (reg_index == std::numeric_limits<uint32_t>::max()) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, could not "
- "parse register number from request \"%s\"",
- __FUNCTION__, packet.GetStringRef().c_str());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, could not "
+ "parse register number from request \"%s\"",
+ __FUNCTION__, packet.GetStringRef().c_str());
return SendErrorResponse(0x15);
}
@@ -1978,20 +1972,19 @@ GDBRemoteCommunicationServerLLGS::Handle_p(StringExtractorGDBRemote &packet) {
// Return the end of registers response if we've iterated one past the end of
// the register set.
if (reg_index >= reg_context.GetUserRegisterCount()) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, requested "
- "register %" PRIu32 " beyond register count %" PRIu32,
- __FUNCTION__, reg_index,
- reg_context.GetUserRegisterCount());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, requested "
+ "register %" PRIu32 " beyond register count %" PRIu32,
+ __FUNCTION__, reg_index, reg_context.GetUserRegisterCount());
return SendErrorResponse(0x15);
}
const RegisterInfo *reg_info = reg_context.GetRegisterInfoAtIndex(reg_index);
if (!reg_info) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, requested "
- "register %" PRIu32 " returned NULL",
- __FUNCTION__, reg_index);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, requested "
+ "register %" PRIu32 " returned NULL",
+ __FUNCTION__, reg_index);
return SendErrorResponse(0x15);
}
@@ -2002,20 +1995,20 @@ GDBRemoteCommunicationServerLLGS::Handle_p(StringExtractorGDBRemote &packet) {
RegisterValue reg_value;
Status error = reg_context.ReadRegister(reg_info, reg_value);
if (error.Fail()) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, read of "
- "requested register %" PRIu32 " (%s) failed: %s",
- __FUNCTION__, reg_index, reg_info->name, error.AsCString());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, read of "
+ "requested register %" PRIu32 " (%s) failed: %s",
+ __FUNCTION__, reg_index, reg_info->name, error.AsCString());
return SendErrorResponse(0x15);
}
const uint8_t *const data =
reinterpret_cast<const uint8_t *>(reg_value.GetBytes());
if (!data) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to get data "
- "bytes from requested register %" PRIu32,
- __FUNCTION__, reg_index);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed to get data "
+ "bytes from requested register %" PRIu32,
+ __FUNCTION__, reg_index);
return SendErrorResponse(0x15);
}
@@ -2039,10 +2032,10 @@ GDBRemoteCommunicationServerLLGS::Handle_P(StringExtractorGDBRemote &packet) {
const uint32_t reg_index =
packet.GetHexMaxU32(false, std::numeric_limits<uint32_t>::max());
if (reg_index == std::numeric_limits<uint32_t>::max()) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, could not "
- "parse register number from request \"%s\"",
- __FUNCTION__, packet.GetStringRef().c_str());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, could not "
+ "parse register number from request \"%s\"",
+ __FUNCTION__, packet.GetStringRef().c_str());
return SendErrorResponse(0x29);
}
@@ -2058,10 +2051,10 @@ GDBRemoteCommunicationServerLLGS::Handle_P(StringExtractorGDBRemote &packet) {
// Get the thread to use.
NativeThreadProtocol *thread = GetThreadFromSuffix(packet);
if (!thread) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, no thread "
- "available (thread index 0)",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, no thread "
+ "available (thread index 0)",
+ __FUNCTION__);
return SendErrorResponse(0x28);
}
@@ -2069,20 +2062,20 @@ GDBRemoteCommunicationServerLLGS::Handle_P(StringExtractorGDBRemote &packet) {
NativeRegisterContext &reg_context = thread->GetRegisterContext();
const RegisterInfo *reg_info = reg_context.GetRegisterInfoAtIndex(reg_index);
if (!reg_info) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, requested "
- "register %" PRIu32 " returned NULL",
- __FUNCTION__, reg_index);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, requested "
+ "register %" PRIu32 " returned NULL",
+ __FUNCTION__, reg_index);
return SendErrorResponse(0x48);
}
// Return the end of registers response if we've iterated one past the end of
// the register set.
if (reg_index >= reg_context.GetUserRegisterCount()) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, requested "
- "register %" PRIu32 " beyond register count %" PRIu32,
- __FUNCTION__, reg_index, reg_context.GetUserRegisterCount());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, requested "
+ "register %" PRIu32 " beyond register count %" PRIu32,
+ __FUNCTION__, reg_index, reg_context.GetUserRegisterCount());
return SendErrorResponse(0x47);
}
@@ -2101,10 +2094,10 @@ GDBRemoteCommunicationServerLLGS::Handle_P(StringExtractorGDBRemote &packet) {
m_debugged_process_up->GetArchitecture().GetByteOrder());
Status error = reg_context.WriteRegister(reg_info, reg_value);
if (error.Fail()) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, write of "
- "requested register %" PRIu32 " (%s) failed: %s",
- __FUNCTION__, reg_index, reg_info->name, error.AsCString());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, write of "
+ "requested register %" PRIu32 " (%s) failed: %s",
+ __FUNCTION__, reg_index, reg_info->name, error.AsCString());
return SendErrorResponse(0x32);
}
@@ -2118,20 +2111,20 @@ GDBRemoteCommunicationServerLLGS::Handle_H(StringExtractorGDBRemote &packet) {
// Fail if we don't have a current process.
if (!m_debugged_process_up ||
(m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
- __FUNCTION__);
+ LLDB_LOGF(
+ log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
+ __FUNCTION__);
return SendErrorResponse(0x15);
}
// Parse out which variant of $H is requested.
packet.SetFilePos(strlen("H"));
if (packet.GetBytesLeft() < 1) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, H command "
- "missing {g,c} variant",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, H command "
+ "missing {g,c} variant",
+ __FUNCTION__);
return SendIllFormedResponse(packet, "H command missing {g,c} variant");
}
@@ -2144,10 +2137,10 @@ GDBRemoteCommunicationServerLLGS::Handle_H(StringExtractorGDBRemote &packet) {
break;
default:
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s failed, invalid $H variant %c",
- __FUNCTION__, h_variant);
+ LLDB_LOGF(
+ log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, invalid $H variant %c",
+ __FUNCTION__, h_variant);
return SendIllFormedResponse(packet,
"H variant unsupported, should be c or g");
}
@@ -2162,10 +2155,10 @@ GDBRemoteCommunicationServerLLGS::Handle_H(StringExtractorGDBRemote &packet) {
if (tid != LLDB_INVALID_THREAD_ID && tid != 0) {
NativeThreadProtocol *thread = m_debugged_process_up->GetThreadByID(tid);
if (!thread) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, tid %" PRIu64
- " not found",
- __FUNCTION__, tid);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, tid %" PRIu64
+ " not found",
+ __FUNCTION__, tid);
return SendErrorResponse(0x15);
}
}
@@ -2196,10 +2189,10 @@ GDBRemoteCommunicationServerLLGS::Handle_I(StringExtractorGDBRemote &packet) {
// Fail if we don't have a current process.
if (!m_debugged_process_up ||
(m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
- __FUNCTION__);
+ LLDB_LOGF(
+ log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
+ __FUNCTION__);
return SendErrorResponse(0x15);
}
@@ -2257,10 +2250,10 @@ GDBRemoteCommunicationServerLLGS::Handle_memory_read(
if (!m_debugged_process_up ||
(m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
- __FUNCTION__);
+ LLDB_LOGF(
+ log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
+ __FUNCTION__);
return SendErrorResponse(0x15);
}
@@ -2284,10 +2277,10 @@ GDBRemoteCommunicationServerLLGS::Handle_memory_read(
const uint64_t byte_count = packet.GetHexMaxU64(false, 0);
if (byte_count == 0) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s nothing to read: "
- "zero-length packet",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s nothing to read: "
+ "zero-length packet",
+ __FUNCTION__);
return SendOKResponse();
}
@@ -2301,20 +2294,20 @@ GDBRemoteCommunicationServerLLGS::Handle_memory_read(
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_up->GetID(), read_addr,
- error.AsCString());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
+ " mem 0x%" PRIx64 ": failed to read. Error: %s",
+ __FUNCTION__, m_debugged_process_up->GetID(), read_addr,
+ error.AsCString());
return SendErrorResponse(0x08);
}
if (bytes_read == 0) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
- " mem 0x%" PRIx64 ": read 0 of %" PRIu64 " requested bytes",
- __FUNCTION__, m_debugged_process_up->GetID(), read_addr,
- byte_count);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
+ " mem 0x%" PRIx64 ": read 0 of %" PRIu64 " requested bytes",
+ __FUNCTION__, m_debugged_process_up->GetID(), read_addr,
+ byte_count);
return SendErrorResponse(0x08);
}
@@ -2338,10 +2331,10 @@ GDBRemoteCommunicationServerLLGS::Handle_M(StringExtractorGDBRemote &packet) {
if (!m_debugged_process_up ||
(m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
- __FUNCTION__);
+ LLDB_LOGF(
+ log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
+ __FUNCTION__);
return SendErrorResponse(0x15);
}
@@ -2426,10 +2419,10 @@ GDBRemoteCommunicationServerLLGS::Handle_qMemoryRegionInfoSupported(
// since we won't have a NativeProcessProtocol.
if (!m_debugged_process_up ||
(m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
- __FUNCTION__);
+ LLDB_LOGF(
+ log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
+ __FUNCTION__);
return SendErrorResponse(0x15);
}
@@ -2454,10 +2447,10 @@ GDBRemoteCommunicationServerLLGS::Handle_qMemoryRegionInfo(
// Ensure we have a process.
if (!m_debugged_process_up ||
(m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
- __FUNCTION__);
+ LLDB_LOGF(
+ log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
+ __FUNCTION__);
return SendErrorResponse(0x15);
}
@@ -2703,10 +2696,10 @@ GDBRemoteCommunicationServerLLGS::Handle_s(StringExtractorGDBRemote &packet) {
// Ensure we have a process.
if (!m_debugged_process_up ||
(m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
- __FUNCTION__);
+ LLDB_LOGF(
+ log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
+ __FUNCTION__);
return SendErrorResponse(0x32);
}
@@ -2735,11 +2728,11 @@ GDBRemoteCommunicationServerLLGS::Handle_s(StringExtractorGDBRemote &packet) {
actions.SetDefaultThreadActionIfNeeded(eStateStopped, 0);
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_up->GetID(), tid,
- error.AsCString());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
+ " tid %" PRIu64 " Resume() failed with error: %s",
+ __FUNCTION__, m_debugged_process_up->GetID(), tid,
+ error.AsCString());
return SendErrorResponse(0x49);
}
@@ -2986,18 +2979,18 @@ GDBRemoteCommunicationServerLLGS::Handle_vAttach(
"vAttach failed to parse the process id");
// Attempt to attach.
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s attempting to attach to "
- "pid %" PRIu64,
- __FUNCTION__, pid);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s attempting to attach to "
+ "pid %" PRIu64,
+ __FUNCTION__, pid);
Status error = AttachToProcess(pid);
if (error.Fail()) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to attach to "
- "pid %" PRIu64 ": %s\n",
- __FUNCTION__, pid, error.AsCString());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed to attach to "
+ "pid %" PRIu64 ": %s\n",
+ __FUNCTION__, pid, error.AsCString());
return SendErrorResponse(error);
}
@@ -3014,10 +3007,10 @@ GDBRemoteCommunicationServerLLGS::Handle_D(StringExtractorGDBRemote &packet) {
// Fail if we don't have a current process.
if (!m_debugged_process_up ||
(m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
- __FUNCTION__);
+ LLDB_LOGF(
+ log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
+ __FUNCTION__);
return SendErrorResponse(0x15);
}
@@ -3041,11 +3034,10 @@ GDBRemoteCommunicationServerLLGS::Handle_D(StringExtractorGDBRemote &packet) {
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_up->GetID(),
- error.AsCString());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed to detach from "
+ "pid %" PRIu64 ": %s\n",
+ __FUNCTION__, m_debugged_process_up->GetID(), error.AsCString());
return SendErrorResponse(0x01);
}
@@ -3060,10 +3052,10 @@ GDBRemoteCommunicationServerLLGS::Handle_qThreadStopInfo(
packet.SetFilePos(strlen("qThreadStopInfo"));
const lldb::tid_t tid = packet.GetHexMaxU32(false, LLDB_INVALID_THREAD_ID);
if (tid == LLDB_INVALID_THREAD_ID) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, could not "
- "parse thread id from request \"%s\"",
- __FUNCTION__, packet.GetStringRef().c_str());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s failed, could not "
+ "parse thread id from request \"%s\"",
+ __FUNCTION__, packet.GetStringRef().c_str());
return SendErrorResponse(0x15);
}
return SendStopReplyPacketForThread(tid);
@@ -3195,15 +3187,15 @@ void GDBRemoteCommunicationServerLLGS::MaybeCloseInferiorTerminalConnection() {
connection->Disconnect(&error);
if (error.Success()) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s disconnect process "
- "terminal stdio - SUCCESS",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s disconnect process "
+ "terminal stdio - SUCCESS",
+ __FUNCTION__);
} else {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s disconnect process "
- "terminal stdio - FAIL: %s",
- __FUNCTION__, error.AsCString());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s disconnect process "
+ "terminal stdio - FAIL: %s",
+ __FUNCTION__, error.AsCString());
}
}
}
@@ -3233,11 +3225,11 @@ NativeThreadProtocol *GDBRemoteCommunicationServerLLGS::GetThreadFromSuffix(
// Parse out the ';'.
if (packet.GetBytesLeft() < 1 || packet.GetChar() != ';') {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s gdb-remote parse "
- "error: expected ';' prior to start of thread suffix: packet "
- "contents = '%s'",
- __FUNCTION__, packet.GetStringRef().c_str());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s gdb-remote parse "
+ "error: expected ';' prior to start of thread suffix: packet "
+ "contents = '%s'",
+ __FUNCTION__, packet.GetStringRef().c_str());
return nullptr;
}
@@ -3246,11 +3238,11 @@ NativeThreadProtocol *GDBRemoteCommunicationServerLLGS::GetThreadFromSuffix(
// Parse out thread: portion.
if (strncmp(packet.Peek(), "thread:", strlen("thread:")) != 0) {
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s gdb-remote parse "
- "error: expected 'thread:' but not found, packet contents = "
- "'%s'",
- __FUNCTION__, packet.GetStringRef().c_str());
+ LLDB_LOGF(log,
+ "GDBRemoteCommunicationServerLLGS::%s gdb-remote parse "
+ "error: expected 'thread:' but not found, packet contents = "
+ "'%s'",
+ __FUNCTION__, packet.GetStringRef().c_str());
return nullptr;
}
packet.SetFilePos(packet.GetFilePos() + strlen("thread:"));
OpenPOWER on IntegriCloud