jaydeep created this revision. jaydeep added a reviewer: jingham. jaydeep added subscribers: lldb-commits, bhushan, sagar, mohit.bhakkad, nitesh.jain. jaydeep set the repository for this revision to rL LLVM.
The patch supports 'TAAwatch:addr' packet. The patch also sets m_watchpoints_trigger_after_instruction to eLazyBoolNo when qHostInfo or qWatchpointSupportInfo is not supported by the target. Repository: rL LLVM http://reviews.llvm.org/D11747 Files: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp =================================================================== --- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -24,6 +24,7 @@ #include <algorithm> #include <map> #include <mutex> +#include <sstream> #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Interpreter/Args.h" @@ -2483,6 +2484,21 @@ } } } + else if (key.compare("watch") == 0 || key.compare("rwatch") == 0 || key.compare("awatch") == 0) + { + // Support standard GDB remote stop reply packet 'TAAwatch:addr' + lldb::addr_t wp_addr = StringConvert::ToUInt64 (value.c_str(), LLDB_INVALID_ADDRESS, 16); + WatchpointSP wp_sp = GetTarget().GetWatchpointList().FindByAddress(wp_addr); + uint32_t wp_index = LLDB_INVALID_INDEX32; + + if (wp_sp) + wp_index = wp_sp->GetHardwareIndex(); + + reason = "watchpoint"; + std::ostringstream ostr; + ostr << wp_addr << " " << wp_index; + description = ostr.str(); + } else if (key.size() == 2 && ::isxdigit(key[0]) && ::isxdigit(key[1])) { uint32_t reg = StringConvert::ToUInt32 (key.c_str(), UINT32_MAX, 16); @@ -3084,7 +3100,8 @@ Error ProcessGDBRemote::GetWatchpointSupportInfo (uint32_t &num, bool& after) { - Error error (m_gdb_comm.GetWatchpointSupportInfo (num, after)); + const ArchSpec &target_arch = GetTarget().GetArchitecture(); + Error error (m_gdb_comm.GetWatchpointSupportInfo (num, after, target_arch.GetMachine())); return error; } Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -287,10 +287,10 @@ GetWatchpointSupportInfo (uint32_t &num); Error - GetWatchpointSupportInfo (uint32_t &num, bool& after); + GetWatchpointSupportInfo (uint32_t &num, bool& after, llvm::Triple::ArchType atype = llvm::Triple::UnknownArch); Error - GetWatchpointsTriggerAfterInstruction (bool &after); + GetWatchpointsTriggerAfterInstruction (bool &after, llvm::Triple::ArchType atype = llvm::Triple::UnknownArch); const ArchSpec & GetHostArchitecture (); Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -2473,26 +2473,44 @@ } lldb_private::Error -GDBRemoteCommunicationClient::GetWatchpointSupportInfo (uint32_t &num, bool& after) +GDBRemoteCommunicationClient::GetWatchpointSupportInfo (uint32_t &num, bool& after, llvm::Triple::ArchType atype) { Error error(GetWatchpointSupportInfo(num)); if (error.Success()) - error = GetWatchpointsTriggerAfterInstruction(after); + error = GetWatchpointsTriggerAfterInstruction(after, atype); return error; } lldb_private::Error -GDBRemoteCommunicationClient::GetWatchpointsTriggerAfterInstruction (bool &after) +GDBRemoteCommunicationClient::GetWatchpointsTriggerAfterInstruction (bool &after, llvm::Triple::ArchType atype) { Error error; // we assume watchpoints will happen after running the relevant opcode // and we only want to override this behavior if we have explicitly // received a qHostInfo telling us otherwise if (m_qHostInfo_is_valid != eLazyBoolYes) - after = true; + { + // On targets like MIPS, watchpoint exceptions are always generated + // before the instruction is executed. The connected target may not + // support qHostInfo or qWatchpointSupportInfo packets. + if (atype == llvm::Triple::mips || atype == llvm::Triple::mipsel + || atype == llvm::Triple::mips64 || atype == llvm::Triple::mips64el) + after = false; + else + after = true; + } else + { + // For MIPS, set m_watchpoints_trigger_after_instruction to eLazyBoolNo + // if it is not calculated before. + if (m_watchpoints_trigger_after_instruction == eLazyBoolCalculate && + (atype == llvm::Triple::mips || atype == llvm::Triple::mipsel + || atype == llvm::Triple::mips64 || atype == llvm::Triple::mips64el)) + m_watchpoints_trigger_after_instruction = eLazyBoolNo; + after = (m_watchpoints_trigger_after_instruction != eLazyBoolNo); + } return error; }
_______________________________________________ lldb-commits mailing list lldb-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits