diff options
author | Pavel Labath <pavel@labath.sk> | 2018-10-03 12:29:33 +0000 |
---|---|---|
committer | Pavel Labath <pavel@labath.sk> | 2018-10-03 12:29:33 +0000 |
commit | aef7908f6eb060b928f4aa820e4ba5e316ee5e00 (patch) | |
tree | d2f6ba18a4b314b91337e84f03e2da1030ef19ed /lldb/source/Plugins/Process/Linux | |
parent | af50a5b85fe82d8b965142ddf5bfd843efed67d0 (diff) | |
download | bcm5719-llvm-aef7908f6eb060b928f4aa820e4ba5e316ee5e00.tar.gz bcm5719-llvm-aef7908f6eb060b928f4aa820e4ba5e316ee5e00.zip |
Pull FixupBreakpointPCAsNeeded into base class
Summary:
This function existed (with identical code) in both NativeProcessLinux
and NativeProcessNetBSD, and it is likely that it would be useful to any
future implementation of NativeProcessProtocol.
Therefore I move it to the base class.
Reviewers: krytarowski
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D52719
llvm-svn: 343683
Diffstat (limited to 'lldb/source/Plugins/Process/Linux')
-rw-r--r-- | lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp | 76 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/Linux/NativeProcessLinux.h | 2 |
2 files changed, 1 insertions, 77 deletions
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index f1d3becb0a4..4f36fba5fc9 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -759,9 +759,7 @@ void NativeProcessLinux::MonitorBreakpoint(NativeThreadLinux &thread) { // Mark the thread as stopped at breakpoint. thread.SetStoppedByBreakpoint(); - Status error = FixupBreakpointPCAsNeeded(thread); - if (error.Fail()) - LLDB_LOG(log, "pid = {0} fixup: {1}", thread.GetID(), error); + FixupBreakpointPCAsNeeded(thread); if (m_threads_stepping_with_breakpoint.find(thread.GetID()) != m_threads_stepping_with_breakpoint.end()) @@ -1719,78 +1717,6 @@ NativeThreadLinux &NativeProcessLinux::AddThread(lldb::tid_t thread_id) { return static_cast<NativeThreadLinux &>(*m_threads.back()); } -Status -NativeProcessLinux::FixupBreakpointPCAsNeeded(NativeThreadLinux &thread) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS)); - - Status error; - - // Find out the size of a breakpoint (might depend on where we are in the - // code). - NativeRegisterContext &context = thread.GetRegisterContext(); - - uint32_t breakpoint_size = GetSoftwareBreakpointPCOffset(); - LLDB_LOG(log, "breakpoint size: {0}", breakpoint_size); - - // First try probing for a breakpoint at a software breakpoint location: PC - - // breakpoint size. - const lldb::addr_t initial_pc_addr = context.GetPCfromBreakpointLocation(); - lldb::addr_t breakpoint_addr = initial_pc_addr; - if (breakpoint_size > 0) { - // Do not allow breakpoint probe to wrap around. - if (breakpoint_addr >= breakpoint_size) - breakpoint_addr -= breakpoint_size; - } - - // Check if we stopped because of a breakpoint. - NativeBreakpointSP breakpoint_sp; - error = m_breakpoint_list.GetBreakpoint(breakpoint_addr, breakpoint_sp); - if (!error.Success() || !breakpoint_sp) { - // We didn't find one at a software probe location. Nothing to do. - LLDB_LOG(log, - "pid {0} no lldb breakpoint found at current pc with " - "adjustment: {1}", - GetID(), breakpoint_addr); - return Status(); - } - - // If the breakpoint is not a software breakpoint, nothing to do. - if (!breakpoint_sp->IsSoftwareBreakpoint()) { - LLDB_LOG( - log, - "pid {0} breakpoint found at {1:x}, not software, nothing to adjust", - GetID(), breakpoint_addr); - return Status(); - } - - // - // We have a software breakpoint and need to adjust the PC. - // - - // Sanity check. - if (breakpoint_size == 0) { - // Nothing to do! How did we get here? - LLDB_LOG(log, - "pid {0} breakpoint found at {1:x}, it is software, but the " - "size is zero, nothing to do (unexpected)", - GetID(), breakpoint_addr); - return Status(); - } - - // Change the program counter. - LLDB_LOG(log, "pid {0} tid {1}: changing PC from {2:x} to {3:x}", GetID(), - thread.GetID(), initial_pc_addr, breakpoint_addr); - - error = context.SetPC(breakpoint_addr); - if (error.Fail()) { - LLDB_LOG(log, "pid {0} tid {1}: failed to set PC: {2}", GetID(), - thread.GetID(), error); - return error; - } - - return error; -} - Status NativeProcessLinux::GetLoadedModuleFileSpec(const char *module_path, FileSpec &file_spec) { Status error = PopulateMemoryRegionCache(); diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.h b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.h index 5147c361b11..69f2b528d33 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.h +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.h @@ -182,8 +182,6 @@ private: NativeThreadLinux &AddThread(lldb::tid_t thread_id); - Status FixupBreakpointPCAsNeeded(NativeThreadLinux &thread); - /// Writes a siginfo_t structure corresponding to the given thread ID to the /// memory region pointed to by @p siginfo. Status GetSignalInfo(lldb::tid_t tid, void *siginfo); |