Add default Process::GetWatchpointSupportInfo() impl which returns an error of "not supported".
Add "qWatchpointSupportInfo" packet to the gdb communication layer to support this, and modify TestWatchpointCommands.py to test it.
llvm-svn: 157345
return error;
}
+ virtual Error
+ GetWatchpointSupportInfo (uint32_t &num)
+ {
+ Error error;
+ error.SetErrorString ("Process::GetWatchpointSupportInfo() not supported");
+ return error;
+ }
+
lldb::ModuleSP
ReadModuleFromMemory (const FileSpec& file_spec,
lldb::addr_t header_addr,
return true;
}
+ if (target->GetProcessSP() && target->GetProcessSP()->IsAlive())
+ {
+ uint32_t num_supported_hardware_watchpoints;
+ Error error = target->GetProcessSP()->GetWatchpointSupportInfo(num_supported_hardware_watchpoints);
+ if (error.Success())
+ result.AppendMessageWithFormat("Number of supported hardware watchpoints: %u\n",
+ num_supported_hardware_watchpoints);
+ }
+
const WatchpointList &watchpoints = target->GetWatchpointList();
Mutex::Locker locker;
target->GetWatchpointList().GetListMutex(locker);
m_qHostInfo_is_valid (eLazyBoolCalculate),
m_supports_alloc_dealloc_memory (eLazyBoolCalculate),
m_supports_memory_region_info (eLazyBoolCalculate),
+ m_supports_watchpoint_support_info (eLazyBoolCalculate),
m_supports_qProcessInfoPID (true),
m_supports_qfProcessInfo (true),
m_supports_qUserName (true),
m_supports_z4 (true),
m_curr_tid (LLDB_INVALID_THREAD_ID),
m_curr_tid_run (LLDB_INVALID_THREAD_ID),
+ m_num_supported_hardware_watchpoints (0),
m_async_mutex (Mutex::eMutexTypeRecursive),
m_async_packet_predicate (false),
m_async_packet (),
}
+Error
+GDBRemoteCommunicationClient::GetWatchpointSupportInfo (uint32_t &num)
+{
+ Error error;
+
+ if (m_supports_watchpoint_support_info == eLazyBoolYes)
+ {
+ num = m_num_supported_hardware_watchpoints;
+ return error;
+ }
+
+ // Set num to 0 first.
+ num = 0;
+ if (m_supports_watchpoint_support_info != eLazyBoolNo)
+ {
+ char packet[64];
+ const int packet_len = ::snprintf(packet, sizeof(packet), "qWatchpointSupportInfo:");
+ assert (packet_len < sizeof(packet));
+ StringExtractorGDBRemote response;
+ if (SendPacketAndWaitForResponse (packet, packet_len, response, false))
+ {
+ m_supports_watchpoint_support_info = eLazyBoolYes;
+ std::string name;
+ std::string value;
+ while (response.GetNameColonValue(name, value))
+ {
+ if (name.compare ("num") == 0)
+ {
+ num = Args::StringToUInt32(value.c_str(), 0, 0);
+ m_num_supported_hardware_watchpoints = num;
+ }
+ }
+ }
+ else
+ {
+ m_supports_watchpoint_support_info = eLazyBoolNo;
+ }
+ }
+
+ if (m_supports_watchpoint_support_info == eLazyBoolNo)
+ {
+ error.SetErrorString("qWatchpointSupportInfo is not supported");
+ }
+ return error;
+
+}
int
GDBRemoteCommunicationClient::SetSTDIN (char const *path)
GetMemoryRegionInfo (lldb::addr_t addr,
lldb_private::MemoryRegionInfo &range_info);
+ lldb_private::Error
+ GetWatchpointSupportInfo (uint32_t &num);
+
const lldb_private::ArchSpec &
GetHostArchitecture ();
lldb_private::LazyBool m_qHostInfo_is_valid;
lldb_private::LazyBool m_supports_alloc_dealloc_memory;
lldb_private::LazyBool m_supports_memory_region_info;
+ lldb_private::LazyBool m_supports_watchpoint_support_info;
bool
m_supports_qProcessInfoPID:1,
lldb::tid_t m_curr_tid_run; // Current gdb remote protocol thread index for continue, step, etc
+ uint32_t m_num_supported_hardware_watchpoints;
+
// If we need to send a packet while the target is running, the m_async_XXX
// member variables take care of making this happen.
lldb_private::Mutex m_async_mutex;
}
Error
+ProcessGDBRemote::GetWatchpointSupportInfo (uint32_t &num)
+{
+
+ Error error (m_gdb_comm.GetWatchpointSupportInfo (num));
+ return error;
+}
+
+Error
ProcessGDBRemote::DoDeallocateMemory (lldb::addr_t addr)
{
Error error;
virtual lldb_private::Error
DisableWatchpoint (lldb_private::Watchpoint *wp);
+ virtual lldb_private::Error
+ GetWatchpointSupportInfo (uint32_t &num);
+
virtual bool
StartNoticingNewThreads();
# Use the '-v' option to do verbose listing of the watchpoint.
# The hit count should be 0 initially.
self.expect("watchpoint list -v",
- substrs = ['hit_count = 0'])
+ substrs = ['Number of supported hardware watchpoints:',
+ 'hit_count = 0'])
self.runCmd("process continue")
}
//----------------------------------------------------------------------
+// Return the number of supported hardware watchpoints.
+//----------------------------------------------------------------------
+uint32_t
+DNBWatchpointGetNumSupportedHWP (nub_process_t pid)
+{
+ MachProcessSP procSP;
+ if (GetProcessSP (pid, procSP))
+ return procSP->GetNumSupportedHardwareWatchpoints();
+ return 0;
+}
+
+//----------------------------------------------------------------------
// Read memory in the address space of process PID. This call will take
// care of setting and restoring permissions and breaking up the memory
// read into multiple chunks as required.
nub_bool_t DNBWatchpointSetIgnoreCount (nub_process_t pid, nub_watch_t watchID, nub_size_t ignore_count) DNB_EXPORT;
nub_bool_t DNBWatchpointSetCallback (nub_process_t pid, nub_watch_t watchID, DNBCallbackBreakpointHit callback, void *baton) DNB_EXPORT;
void DNBWatchpointPrint (nub_process_t pid, nub_watch_t watchID) DNB_EXPORT;
+uint32_t DNBWatchpointGetNumSupportedHWP (nub_process_t pid) DNB_EXPORT;
const DNBRegisterSetInfo *
DNBGetRegisterSetInfo (nub_size_t *num_reg_sets) DNB_EXPORT;
}
}
+uint32_t
+MachProcess::GetNumSupportedHardwareWatchpoints () const
+{
+ return m_thread_list.NumSupportedHardwareWatchpoints();
+}
+
bool
MachProcess::EnableBreakpoint(nub_break_t breakID)
{
nub_size_t DisableAllWatchpoints (bool remove);
bool EnableWatchpoint (nub_watch_t watchID);
void DumpWatchpoint(nub_watch_t watchID) const;
+ uint32_t GetNumSupportedHardwareWatchpoints () const;
DNBBreakpointList& Watchpoints() { return m_watchpoints; }
const DNBBreakpointList& Watchpoints() const { return m_watchpoints; }
return false;
}
+uint32_t
+MachThread::NumSupportedHardwareWatchpoints () const
+{
+ return m_arch_ap->NumSupportedHardwareWatchpoints();
+}
+
bool
MachThread::GetIdentifierInfo ()
{
uint32_t EnableHardwareWatchpoint (const DNBBreakpoint *watchpoint);
bool DisableHardwareBreakpoint (const DNBBreakpoint *breakpoint);
bool DisableHardwareWatchpoint (const DNBBreakpoint *watchpoint);
+ uint32_t NumSupportedHardwareWatchpoints () const;
nub_state_t GetState();
void SetState(nub_state_t state);
}
uint32_t
+MachThreadList::NumSupportedHardwareWatchpoints () const
+{
+ PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
+ const uint32_t num_threads = m_threads.size();
+ // Use an arbitrary thread to retrieve the number of supported hardware watchpoints.
+ if (num_threads)
+ return m_threads[0]->NumSupportedHardwareWatchpoints();
+ return 0;
+}
+
+uint32_t
MachThreadList::GetThreadIndexForThreadStoppedWithSignal (const int signo) const
{
PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
bool DisableHardwareBreakpoint (const DNBBreakpoint *bp) const;
uint32_t EnableHardwareWatchpoint (const DNBBreakpoint *wp) const;
bool DisableHardwareWatchpoint (const DNBBreakpoint *wp) const;
+ uint32_t NumSupportedHardwareWatchpoints () const;
+
uint32_t GetThreadIndexForThreadStoppedWithSignal (const int signo) const;
MachThreadSP GetThreadByID (nub_thread_t tid) const;
t.push_back (Packet (allocate_memory, &RNBRemote::HandlePacket_AllocateMemory, NULL, "_M", "Allocate memory in the inferior process."));
t.push_back (Packet (deallocate_memory, &RNBRemote::HandlePacket_DeallocateMemory, NULL, "_m", "Deallocate memory in the inferior process."));
t.push_back (Packet (memory_region_info, &RNBRemote::HandlePacket_MemoryRegionInfo, NULL, "qMemoryRegionInfo", "Return size and attributes of a memory region that contains the given address"));
+ t.push_back (Packet (watchpoint_support_info, &RNBRemote::HandlePacket_WatchpointSupportInfo, NULL, "qWatchpointSupportInfo", "Return the number of supported hardware watchpoints"));
}
return SendPacket (ostrm.str());
}
+rnb_err_t
+RNBRemote::HandlePacket_WatchpointSupportInfo (const char *p)
+{
+ /* This packet simply returns the number of supported hardware watchpoints.
+
+ Examples of use:
+ qWatchpointSupportInfo:
+ num:4
+
+ qWatchpointSupportInfo
+ OK // this packet is implemented by the remote nub
+ */
+
+ p += sizeof ("qWatchpointSupportInfo") - 1;
+ if (*p == '\0')
+ return SendPacket ("OK");
+ if (*p++ != ':')
+ return SendPacket ("E67");
+
+ errno = 0;
+ uint32_t num = DNBWatchpointGetNumSupportedHWP (m_ctx.ProcessID());
+ std::ostringstream ostrm;
+
+ // size:4
+ ostrm << "num:" << std::dec << num << ';';
+ return SendPacket (ostrm.str());
+}
/* 'C sig [;addr]'
Resume with signal sig, optionally at address addr. */
set_working_dir, // 'QSetWorkingDir:'
set_list_threads_in_stop_reply, // 'QListThreadsInStopReply:'
memory_region_info, // 'qMemoryRegionInfo:'
+ watchpoint_support_info, // 'qWatchpointSupportInfo:'
allocate_memory, // '_M'
deallocate_memory, // '_m'
rnb_err_t HandlePacket_AllocateMemory (const char *p);
rnb_err_t HandlePacket_DeallocateMemory (const char *p);
rnb_err_t HandlePacket_MemoryRegionInfo (const char *p);
+ rnb_err_t HandlePacket_WatchpointSupportInfo (const char *p);
rnb_err_t HandlePacket_stop_process (const char *p);