pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lldb-netbsd: Add initial code for watchpoints



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Sat Apr 8 23:52:33 2017 +0200
Changeset:	79a2549c7431e3b55d5cac9ba76e3d295b580d0e

Modified Files:
	lldb-netbsd/distinfo
Added Files:
	lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp
	lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h

Log Message:
lldb-netbsd: Add initial code for watchpoints

This code is based on the Linux Process Plugin.

Sponsored by <The NetBSD Foundation>

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=79a2549c7431e3b55d5cac9ba76e3d295b580d0e

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 lldb-netbsd/distinfo                               |  2 +
 ...e_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp | 70 ++++++++++++++++++++++
 ...rce_Plugins_Process_NetBSD_NativeThreadNetBSD.h | 24 ++++++++
 3 files changed, 96 insertions(+)

diffs:
diff --git a/lldb-netbsd/distinfo b/lldb-netbsd/distinfo
index f3629a33bb..3c6330ba55 100644
--- a/lldb-netbsd/distinfo
+++ b/lldb-netbsd/distinfo
@@ -13,4 +13,6 @@ SHA1 (llvm-3.6.2.src.tar.xz) = 7a00257eb2bc9431e4c77c3a36b033072c54bc7e
 RMD160 (llvm-3.6.2.src.tar.xz) = 521cbc5fe2925ea3c6e90c7a31f752a04045c972
 Size (llvm-3.6.2.src.tar.xz) = 12802380 bytes
 SHA1 (patch-source_Core_ArchSpec.cpp) = 1585f4ffa707bc69e96f7dd3b5137e00858ed7be
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp) = d19f2d0ef3957e20355d5864955ad869ec2ead2f
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h) = 8de6137551edc1747ad8d744cb456561214bd2d4
 SHA1 (patch-source_Plugins_Process_elf-core_ProcessElfCore.cpp) = 91575c49560da29d5d83c446012ed04ca957d99c
diff --git a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp
new file mode 100644
index 0000000000..33f75f702f
--- /dev/null
+++ b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp
@@ -0,0 +1,70 @@
+$NetBSD$
+
+--- source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp.orig	2017-03-30 22:14:30.000000000 +0000
++++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
+@@ -142,18 +142,61 @@ NativeRegisterContextSP NativeThreadNetB
+ 
+ Error NativeThreadNetBSD::SetWatchpoint(lldb::addr_t addr, size_t size,
+                                         uint32_t watch_flags, bool hardware) {
+-  return Error("Unimplemented");
++  if (!hardware)
++    return Error("not implemented");
++  if (m_state == eStateLaunching)
++    return Error();
++  Error error = RemoveWatchpoint(addr);
++  if (error.Fail())
++    return error;
++  NativeRegisterContextSP reg_ctx = GetRegisterContext();
++  uint32_t wp_index = reg_ctx->SetHardwareWatchpoint(addr, size, watch_flags);
++  if (wp_index == LLDB_INVALID_INDEX32)
++    return Error("Setting hardware watchpoint failed.");
++  m_watchpoint_index_map.insert({addr, wp_index});
++  return Error();
+ }
+ 
+ Error NativeThreadNetBSD::RemoveWatchpoint(lldb::addr_t addr) {
+-  return Error("Unimplemented");
++  auto wp = m_watchpoint_index_map.find(addr);
++  if (wp == m_watchpoint_index_map.end())
++    return Error();
++  uint32_t wp_index = wp->second;
++  m_watchpoint_index_map.erase(wp);
++  if (GetRegisterContext()->ClearHardwareWatchpoint(wp_index))
++    return Error();
++  return Error("Clearing hardware watchpoint failed.");
+ }
+ 
+ Error NativeThreadNetBSD::SetHardwareBreakpoint(lldb::addr_t addr,
+                                                 size_t size) {
+-  return Error("Unimplemented");
++  if (m_state == eStateLaunching)
++    return Error();
++
++  Error error = RemoveHardwareBreakpoint(addr);
++  if (error.Fail())
++    return error;
++
++  NativeRegisterContextSP reg_ctx = GetRegisterContext();
++  uint32_t bp_index = reg_ctx->SetHardwareBreakpoint(addr, size);
++
++  if (bp_index == LLDB_INVALID_INDEX32)
++    return Error("Setting hardware breakpoint failed.");
++
++  m_hw_break_index_map.insert({addr, bp_index});
++  return Error();
+ }
+ 
+ Error NativeThreadNetBSD::RemoveHardwareBreakpoint(lldb::addr_t addr) {
+-  return Error("Unimplemented");
++  auto bp = m_hw_break_index_map.find(addr);
++  if (bp == m_hw_break_index_map.end())
++    return Error();
++
++  uint32_t bp_index = bp->second;
++  if (GetRegisterContext()->ClearHardwareBreakpoint(bp_index)) {
++    m_hw_break_index_map.erase(bp);
++    return Error();
++  }
++
++  return Error("Clearing hardware breakpoint failed.");
+ }
diff --git a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h
new file mode 100644
index 0000000000..a7e2f5fc94
--- /dev/null
+++ b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h
@@ -0,0 +1,24 @@
+$NetBSD$
+
+--- source/Plugins/Process/NetBSD/NativeThreadNetBSD.h.orig	2017-03-30 22:14:30.000000000 +0000
++++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
+@@ -12,6 +12,9 @@
+ 
+ #include "lldb/Host/common/NativeThreadProtocol.h"
+ 
++#include <map>
++#include <string>
++
+ namespace lldb_private {
+ namespace process_netbsd {
+ 
+@@ -64,6 +67,9 @@ private:
+   ThreadStopInfo m_stop_info;
+   NativeRegisterContextSP m_reg_context_sp;
+   std::string m_stop_description;
++  using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>;
++  WatchpointIndexMap m_watchpoint_index_map;
++  WatchpointIndexMap m_hw_break_index_map;
+ };
+ 
+ typedef std::shared_ptr<NativeThreadNetBSD> NativeThreadNetBSDSP;


Home | Main Index | Thread Index | Old Index