aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r--contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp76
1 files changed, 33 insertions, 43 deletions
diff --git a/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 5f3c1ad9c1e1..df927fe68b4f 100644
--- a/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -271,7 +271,7 @@ ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp,
m_gdb_comm.SetPacketRecorder(provider.GetNewPacketRecorder());
}
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_ASYNC));
+ Log *log = GetLog(GDBRLog::Async);
const uint32_t async_event_mask =
eBroadcastBitAsyncContinue | eBroadcastBitAsyncThreadShouldExit;
@@ -707,7 +707,7 @@ Status ProcessGDBRemote::WillLaunchOrAttach() {
// Process Control
Status ProcessGDBRemote::DoLaunch(lldb_private::Module *exe_module,
ProcessLaunchInfo &launch_info) {
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
Status error;
LLDB_LOGF(log, "ProcessGDBRemote::%s() entered", __FUNCTION__);
@@ -899,7 +899,7 @@ Status ProcessGDBRemote::DoLaunch(lldb_private::Module *exe_module,
Status ProcessGDBRemote::ConnectToDebugserver(llvm::StringRef connect_url) {
Status error;
// Only connect if we have a valid connect URL
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
if (!connect_url.empty()) {
LLDB_LOGF(log, "ProcessGDBRemote::%s Connecting to %s", __FUNCTION__,
@@ -960,7 +960,7 @@ Status ProcessGDBRemote::ConnectToDebugserver(llvm::StringRef connect_url) {
}
void ProcessGDBRemote::DidLaunchOrAttach(ArchSpec &process_arch) {
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
BuildDynamicRegisterInfo(false);
// See if the GDB server supports qHostInfo or qProcessInfo packets. Prefer
@@ -1096,7 +1096,7 @@ void ProcessGDBRemote::DidLaunch() {
Status ProcessGDBRemote::DoAttachToProcessWithID(
lldb::pid_t attach_pid, const ProcessAttachInfo &attach_info) {
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
Status error;
LLDB_LOGF(log, "ProcessGDBRemote::%s()", __FUNCTION__);
@@ -1205,7 +1205,7 @@ Status ProcessGDBRemote::WillResume() {
Status ProcessGDBRemote::DoResume() {
Status error;
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
LLDB_LOGF(log, "ProcessGDBRemote::Resume()");
ListenerSP listener_sp(
@@ -1515,7 +1515,7 @@ bool ProcessGDBRemote::UpdateThreadIDList() {
bool ProcessGDBRemote::DoUpdateThreadList(ThreadList &old_thread_list,
ThreadList &new_thread_list) {
// locker will keep a mutex locked until it goes out of scope
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_THREAD));
+ Log *log = GetLog(GDBRLog::Thread);
LLDB_LOGV(log, "pid = {0}", GetID());
size_t num_thread_ids = m_thread_ids.size();
@@ -1795,8 +1795,7 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
}
}
if (watch_id == LLDB_INVALID_WATCH_ID) {
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(
- GDBR_LOG_WATCHPOINTS));
+ Log *log(GetLog(GDBRLog::Watchpoints));
LLDB_LOGF(log, "failed to find watchpoint");
}
thread_sp->SetStopInfo(StopInfo::CreateStopReasonWithWatchpointID(
@@ -2238,8 +2237,7 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) {
} else if (key.compare("library") == 0) {
auto error = LoadModules();
if (error) {
- Log *log(
- ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log(GetLog(GDBRLog::Process));
LLDB_LOG_ERROR(log, std::move(error), "Failed to load modules: {0}");
}
} else if (key.compare("fork") == 0 || key.compare("vfork") == 0) {
@@ -2247,8 +2245,7 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) {
StringExtractorGDBRemote thread_id{value};
auto pid_tid = thread_id.GetPidTid(LLDB_INVALID_PROCESS_ID);
if (!pid_tid) {
- Log *log(
- ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log(GetLog(GDBRLog::Process));
LLDB_LOG(log, "Invalid PID/TID to fork: {0}", value);
pid_tid = {{LLDB_INVALID_PROCESS_ID, LLDB_INVALID_THREAD_ID}};
}
@@ -2265,7 +2262,7 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) {
}
if (stop_pid != LLDB_INVALID_PROCESS_ID && stop_pid != pid) {
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
LLDB_LOG(log,
"Received stop for incorrect PID = {0} (inferior PID = {1})",
stop_pid, pid);
@@ -2352,7 +2349,7 @@ Status ProcessGDBRemote::DoHalt(bool &caused_stop) {
Status ProcessGDBRemote::DoDetach(bool keep_stopped) {
Status error;
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
LLDB_LOGF(log, "ProcessGDBRemote::DoDetach(keep_stopped: %i)", keep_stopped);
error = m_gdb_comm.Detach(keep_stopped);
@@ -2381,7 +2378,7 @@ Status ProcessGDBRemote::DoDetach(bool keep_stopped) {
Status ProcessGDBRemote::DoDestroy() {
Status error;
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
LLDB_LOGF(log, "ProcessGDBRemote::DoDestroy()");
#ifdef LLDB_ENABLE_ALL // XXX Currently no iOS target support on FreeBSD
@@ -2565,7 +2562,7 @@ void ProcessGDBRemote::SetLastStopPacket(
const bool did_exec =
response.GetStringRef().find(";reason:exec;") != std::string::npos;
if (did_exec) {
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
LLDB_LOGF(log, "ProcessGDBRemote::SetLastStopPacket () - detected exec");
m_thread_list_real.Clear();
@@ -2595,7 +2592,7 @@ addr_t ProcessGDBRemote::GetImageInfoAddress() {
if (addr == LLDB_INVALID_ADDRESS) {
llvm::Expected<LoadedModuleInfoList> list = GetLoadedModuleList();
if (!list) {
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
LLDB_LOG_ERROR(log, list.takeError(), "Failed to read module list: {0}.");
} else {
addr = list->m_link_map;
@@ -3040,7 +3037,7 @@ Status ProcessGDBRemote::EnableBreakpointSite(BreakpointSite *bp_site) {
assert(bp_site != nullptr);
// Get logging info
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_BREAKPOINTS));
+ Log *log = GetLog(GDBRLog::Breakpoints);
user_id_t site_id = bp_site->GetID();
// Get the breakpoint address
@@ -3164,7 +3161,7 @@ Status ProcessGDBRemote::DisableBreakpointSite(BreakpointSite *bp_site) {
assert(bp_site != nullptr);
addr_t addr = bp_site->GetLoadAddress();
user_id_t site_id = bp_site->GetID();
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_BREAKPOINTS));
+ Log *log = GetLog(GDBRLog::Breakpoints);
LLDB_LOGF(log,
"ProcessGDBRemote::DisableBreakpointSite (site_id = %" PRIu64
") addr = 0x%8.8" PRIx64,
@@ -3229,8 +3226,7 @@ Status ProcessGDBRemote::EnableWatchpoint(Watchpoint *wp, bool notify) {
if (wp) {
user_id_t watchID = wp->GetID();
addr_t addr = wp->GetLoadAddress();
- Log *log(
- ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_WATCHPOINTS));
+ Log *log(GetLog(GDBRLog::Watchpoints));
LLDB_LOGF(log, "ProcessGDBRemote::EnableWatchpoint(watchID = %" PRIu64 ")",
watchID);
if (wp->IsEnabled()) {
@@ -3266,8 +3262,7 @@ Status ProcessGDBRemote::DisableWatchpoint(Watchpoint *wp, bool notify) {
if (wp) {
user_id_t watchID = wp->GetID();
- Log *log(
- ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_WATCHPOINTS));
+ Log *log(GetLog(GDBRLog::Watchpoints));
addr_t addr = wp->GetLoadAddress();
@@ -3315,7 +3310,7 @@ void ProcessGDBRemote::Clear() {
Status ProcessGDBRemote::DoSignal(int signo) {
Status error;
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
LLDB_LOGF(log, "ProcessGDBRemote::DoSignal (signal = %d)", signo);
if (!m_gdb_comm.SendAsyncSignal(signo, GetInterruptTimeout()))
@@ -3436,7 +3431,7 @@ Status ProcessGDBRemote::LaunchAndConnectToDebugserver(
}
if (error.Fail()) {
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
LLDB_LOGF(log, "failed to start debugserver process: %s",
error.AsCString());
@@ -3462,7 +3457,7 @@ bool ProcessGDBRemote::MonitorDebugserverProcess(
) {
// "debugserver_pid" argument passed in is the process ID for debugserver
// that we are tracking...
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
const bool handled = true;
LLDB_LOGF(log,
@@ -3541,7 +3536,7 @@ void ProcessGDBRemote::DebuggerInitialize(Debugger &debugger) {
}
bool ProcessGDBRemote::StartAsyncThread() {
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
LLDB_LOGF(log, "ProcessGDBRemote::%s ()", __FUNCTION__);
@@ -3569,7 +3564,7 @@ bool ProcessGDBRemote::StartAsyncThread() {
}
void ProcessGDBRemote::StopAsyncThread() {
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
LLDB_LOGF(log, "ProcessGDBRemote::%s ()", __FUNCTION__);
@@ -3593,7 +3588,7 @@ void ProcessGDBRemote::StopAsyncThread() {
thread_result_t ProcessGDBRemote::AsyncThread(void *arg) {
ProcessGDBRemote *process = (ProcessGDBRemote *)arg;
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
LLDB_LOGF(log,
"ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
") thread starting...",
@@ -3796,7 +3791,7 @@ bool ProcessGDBRemote::NewThreadNotifyBreakpointHit(
}
Status ProcessGDBRemote::UpdateAutomaticSignalFiltering() {
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
LLDB_LOG(log, "Check if need to update ignored signals");
// QPassSignals package is not supported by the server, there is no way we
@@ -3900,9 +3895,7 @@ DataExtractor ProcessGDBRemote::GetAuxvData() {
buf = std::make_shared<DataBufferHeap>(response->c_str(),
response->length());
else
- LLDB_LOG_ERROR(
- ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS),
- response.takeError(), "{0}");
+ LLDB_LOG_ERROR(GetLog(GDBRLog::Process), response.takeError(), "{0}");
}
return DataExtractor(buf, GetByteOrder(), GetAddressByteSize());
}
@@ -4090,8 +4083,7 @@ void ProcessGDBRemote::GetMaxMemorySize() {
else {
// In unlikely scenario that max packet size is less then 70, we will
// hope that data being written is small enough to fit.
- Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(
- GDBR_LOG_COMM | GDBR_LOG_MEMORY));
+ Log *log(GetLog(GDBRLog::Comm | GDBRLog::Memory));
if (log)
log->Warning("Packet size is too small. "
"LLDB may face problems while writing memory");
@@ -4270,8 +4262,7 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,
SplitCommaSeparatedRegisterNumberString(
value, reg_info.invalidate_regs, 0);
} else {
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(
- GDBR_LOG_PROCESS));
+ Log *log(GetLog(GDBRLog::Process));
LLDB_LOGF(log,
"ProcessGDBRemote::%s unhandled reg attribute %s = %s",
__FUNCTION__, name.data(), value.data());
@@ -4313,8 +4304,7 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,
}
if (reg_info.byte_size == 0) {
- Log *log(
- ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log(GetLog(GDBRLog::Process));
LLDB_LOGF(log,
"ProcessGDBRemote::%s Skipping zero bitsize register %s",
__FUNCTION__, reg_info.name.AsCString());
@@ -4986,7 +4976,7 @@ static const char *const s_async_json_packet_prefix = "JSON-async:";
static StructuredData::ObjectSP
ParseStructuredDataPacket(llvm::StringRef packet) {
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
if (!packet.consume_front(s_async_json_packet_prefix)) {
if (log) {
@@ -5359,7 +5349,7 @@ void ProcessGDBRemote::DidForkSwitchHardwareTraps(bool enable) {
}
void ProcessGDBRemote::DidFork(lldb::pid_t child_pid, lldb::tid_t child_tid) {
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
lldb::pid_t parent_pid = m_gdb_comm.GetCurrentProcessID();
// Any valid TID will suffice, thread-relevant actions will set a proper TID
@@ -5421,7 +5411,7 @@ void ProcessGDBRemote::DidFork(lldb::pid_t child_pid, lldb::tid_t child_tid) {
}
void ProcessGDBRemote::DidVFork(lldb::pid_t child_pid, lldb::tid_t child_tid) {
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ Log *log = GetLog(GDBRLog::Process);
assert(!m_vfork_in_progress);
m_vfork_in_progress = true;