Skip to content

Commit

Permalink
lldb-netbsd: Introduce SetStoppedByBreakpoint() kill SingleStep()
Browse files Browse the repository at this point in the history
Stop on breakpoint and resume from breakpoint works.

$ lldb ./int3
(lldb) target create "./int3"
Current executable set to './int3' (x86_64).
(lldb) r
Hello world!
Process 29578 launched: './int3' (x86_64)
Process 29578 stopped
* thread #1, stop reason = signal SIGTRAP
    frame #0:
(lldb) c
Process 29578 resuming
Process 29578 exited with status = 0 (0x00000000)
(lldb)

Sponsored by <The NetBSD Foundation>
  • Loading branch information
krytarowski committed Jan 21, 2017
1 parent 31a00d3 commit efe5087
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
6 changes: 3 additions & 3 deletions lldb-netbsd/distinfo
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ SHA1 (patch-source_Plugins_Platform_NetBSD_PlatformNetBSD.cpp) = 129e853c1f93f06
SHA1 (patch-source_Plugins_Platform_NetBSD_PlatformNetBSD.h) = 4327a21e79378b8f35adb07614adb41c37bbaf61
SHA1 (patch-source_Plugins_Process_CMakeLists.txt) = c0168f81da56d9896eb414e6b8bb7262de04ac33
SHA1 (patch-source_Plugins_Process_NetBSD_CMakeLists.txt) = df17afdf71c29d945c887e318718904793cd48ad
SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp) = 82352e295c00c6fe810aa88e9b92eea556adf544
SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp) = f2ed22a7b37a07fc89160760cd8c03fdb5b154cb
SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.h) = bdd9fe37e47de8fa626c7eacf81e07d47a76787c
SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp) = 9fd955c9d472531e2d6293d0fa4ff237af4be405
SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h) = 52686c2b13e9de5be9818668750b27b5c37843a7
SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp) = a92c655c447cc0829fdb48786f474929f09e1a71
SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h) = d251c4f1b52089f96d435a99f45353aa3992924a
SHA1 (patch-tools_lldb-mi_MICmnBase.cpp) = 851c82ac61e1241018755fbd7236af00379ac986
SHA1 (patch-tools_lldb-mi_MICmnBase.h) = f550d5e10bcf02fb46472733acdbb820791f22e5
SHA1 (patch-tools_lldb-mi_MIDriver.cpp) = bf1b5399e82bcfe54d6d852f64ed155328f2064d
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

--- source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp.orig 2017-01-20 20:30:48.330267591 +0000
+++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -0,0 +1,1384 @@
@@ -0,0 +1,1387 @@
+//===-- NativeProcessNetBSD.cpp -------------------------------- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
Expand Down Expand Up @@ -538,7 +538,10 @@
+ case SIGTRAP:
+ switch (info.psi_siginfo.si_code) {
+ case TRAP_BRKPT:
+ printf("Breakpoint reported\n");
+ for (const auto &thread_sp : m_threads) {
+ static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStoppedByBreakpoint();
+ }
+ SetState(StateType::eStateStopped, true);
+ break;
+ case TRAP_TRACE:
+ for (const auto &thread_sp : m_threads) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

--- source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp.orig 2017-01-20 20:30:48.343442890 +0000
+++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
@@ -0,0 +1,391 @@
@@ -0,0 +1,388 @@
+//===-- NativeThreadNetBSD.cpp --------------------------------- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
Expand Down Expand Up @@ -150,18 +150,6 @@
+ return Error();
+}
+
+Error NativeThreadNetBSD::SingleStep(uint32_t signo) {
+ const StateType new_state = StateType::eStateStepping;
+ m_state = new_state;
+ m_stop_info.reason = StopReason::eStopReasonNone;
+
+ intptr_t data = 0;
+ if (signo != LLDB_INVALID_SIGNAL_NUMBER)
+ data = signo;
+
+ return NativeProcessNetBSD::PtraceWrapper(PT_STEP, GetID(), (void *)1, data);
+}
+
+void NativeThreadNetBSD::SetStoppedBySignal(uint32_t signo,
+ const siginfo_t *info) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
Expand Down Expand Up @@ -388,6 +376,15 @@
+ m_stop_info.details.signal.signo = SIGTRAP;
+}
+
+void NativeThreadNetBSD::SetStoppedByBreakpoint() {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+ if (log)
+ log->Printf("NativeThreadNetBSD::%s()", __FUNCTION__);
+ SetStopped();
+ m_stop_info.reason = StopReason::eStopReasonBreakpoint;
+ m_stop_info.details.signal.signo = SIGTRAP;
+}
+
+NativeProcessNetBSD &NativeThreadNetBSD::GetProcess() {
+ auto process_sp = std::static_pointer_cast<NativeProcessNetBSD>(
+ NativeThreadProtocol::GetProcess());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

--- source/Plugins/Process/NetBSD/NativeThreadNetBSD.h.orig 2017-01-20 20:30:48.349697339 +0000
+++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
@@ -0,0 +1,89 @@
@@ -0,0 +1,87 @@
+//===-- NativeThreadNetBSD.h ----------------------------------- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
Expand Down Expand Up @@ -57,16 +57,14 @@
+ // Interface for friend classes
+ // ---------------------------------------------------------------------
+
+ /// Single steps the thread. If @p signo is anything but
+ /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
+ Error SingleStep(uint32_t signo);
+
+ void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr);
+
+ void SetStoppedByExec();
+
+ void SetStoppedByTrace();
+
+ void SetStoppedByBreakpoint();
+
+ void SetRunning();
+
+ void SetStepping();
Expand Down

0 comments on commit efe5087

Please sign in to comment.