<div dir="ltr">Ok, I've attached a patch and inlined it below. Is git diff format ok?<div><br></div><div style>I'll probably need to do some more work on it as I need to be able to set the disposition before I even attach to a process. Any thoughts on how that can be accomplished?</div>
<div>--</div><div style>Russell Harmon</div><div style><br></div><div style><div>From 704f23ec6d1aedfd66b6cf066215c4b95321a7fe Mon Sep 17 00:00:00 2001</div><div>From: Russell Harmon <<a href="mailto:russ@eatnumber1.com">russ@eatnumber1.com</a>></div>
<div>Date: Tue, 25 Jun 2013 01:02:31 -0700</div><div>Subject: [PATCH] Add the ability to control the signal disposition via the</div><div> API.</div><div><br></div><div>---</div><div> include/lldb/API/LLDB.h | 1 +</div>
<div> include/lldb/API/SBDefines.h | 1 +</div><div> include/lldb/API/SBProcess.h | 3 +</div><div> include/lldb/API/SBUnixSignals.h | 81 +++++++++++++++++++</div><div> include/lldb/lldb-defines.h | 4 +</div>
<div> include/lldb/lldb-forward.h | 1 +</div><div> scripts/Python/build-swig-Python.sh | 6 +-</div><div> scripts/Python/interface/SBProcess.i | 3 +</div><div> scripts/Python/interface/SBUnixSignals.i | 73 +++++++++++++++++</div>
<div> scripts/lldb.swig | 5 ++</div><div> source/API/CMakeLists.txt | 1 +</div><div> source/API/SBProcess.cpp | 14 ++++</div><div> source/API/SBUnixSignals.cpp | 130 +++++++++++++++++++++++++++++++</div>
<div> 13 files changed, 321 insertions(+), 2 deletions(-)</div><div> create mode 100644 include/lldb/API/SBUnixSignals.h</div><div> create mode 100644 scripts/Python/interface/SBUnixSignals.i</div><div> create mode 100644 source/API/SBUnixSignals.cpp</div>
<div><br></div><div>diff --git a/include/lldb/API/LLDB.h b/include/lldb/API/LLDB.h</div><div>index 93bc3bc..4db60b0 100644</div><div>--- a/include/lldb/API/LLDB.h</div><div>+++ b/include/lldb/API/LLDB.h</div><div>@@ -50,5 +50,6 @@</div>
<div> #include "lldb/API/SBType.h"</div><div> #include "lldb/API/SBValue.h"</div><div> #include "lldb/API/SBValueList.h"</div><div>+#include "lldb/API/SBUnixSignals.h"</div><div> </div>
<div> #endif // LLDB_LLDB_h_</div><div>diff --git a/include/lldb/API/SBDefines.h b/include/lldb/API/SBDefines.h</div><div>index 2388c36..02742d3 100644</div><div>--- a/include/lldb/API/SBDefines.h</div><div>+++ b/include/lldb/API/SBDefines.h</div>
<div>@@ -76,6 +76,7 @@ class SBTypeList;</div><div> class SBValue;</div><div> class SBValueList;</div><div> class SBWatchpoint;</div><div>+class SBUnixSignals;</div><div> </div><div> }</div><div> </div><div>diff --git a/include/lldb/API/SBProcess.h b/include/lldb/API/SBProcess.h</div>
<div>index 784f362..a1e7353 100644</div><div>--- a/include/lldb/API/SBProcess.h</div><div>+++ b/include/lldb/API/SBProcess.h</div><div>@@ -211,6 +211,9 @@ public:</div><div> lldb::SBError</div><div> Signal (int signal);</div>
<div> </div><div>+ lldb::SBUnixSignals</div><div>+ GetUnixSignals();</div><div>+</div><div> void</div><div> SendAsyncInterrupt();</div><div> </div><div>diff --git a/include/lldb/API/SBUnixSignals.h b/include/lldb/API/SBUnixSignals.h</div>
<div>new file mode 100644</div><div>index 0000000..e738bb8</div><div>--- /dev/null</div><div>+++ b/include/lldb/API/SBUnixSignals.h</div><div>@@ -0,0 +1,81 @@</div><div>+//===-- SBUnixSignals.h -----------------------------------------------*- C++ -*-===//</div>
<div>+//</div><div>+// The LLVM Compiler Infrastructure</div><div>+//</div><div>+// This file is distributed under the University of Illinois Open Source</div><div>+// License. See LICENSE.TXT for details.</div>
<div>+//</div><div>+//===----------------------------------------------------------------------===//</div><div>+</div><div>+#ifndef LLDB_SBUnixSignals_h_</div><div>+#define LLDB_SBUnixSignals_h_</div><div>+</div><div>+#include "lldb/API/SBDefines.h"</div>
<div>+</div><div>+namespace lldb {</div><div>+</div><div>+class SBUnixSignals {</div><div>+public:</div><div>+ SBUnixSignals ();</div><div>+</div><div>+ SBUnixSignals (const lldb::SBUnixSignals &rhs);</div><div>
+</div><div>+ ~SBUnixSignals();</div><div>+</div><div>+ const SBUnixSignals &</div><div>+ operator =(const lldb::SBUnixSignals &rhs);</div><div>+</div><div>+ void</div><div>+ Clear ();</div><div>+</div>
<div>+ bool</div><div>+ IsValid () const;</div><div>+</div><div>+ int32_t</div><div>+ GetSignalNumberFromName (const char *name) const;</div><div>+</div><div>+ bool</div><div>+ GetShouldSuppress (int32_t signo) const;</div>
<div>+</div><div>+ bool</div><div>+ SetShouldSuppress (int32_t signo,</div><div>+ bool value);</div><div>+</div><div>+ bool</div><div>+ GetShouldStop (int32_t signo) const;</div><div>+</div>
<div>+ bool</div><div>+ SetShouldStop (int32_t signo,</div><div>+ bool value);</div><div>+</div><div>+ bool</div><div>+ GetShouldNotify (int32_t signo) const;</div><div>+</div><div>+ bool</div>
<div>+ SetShouldNotify (int32_t signo, bool value);</div><div>+</div><div>+ int32_t</div><div>+ GetFirstSignalNumber () const;</div><div>+</div><div>+ int32_t</div><div>+ GetNextSignalNumber (int32_t current_signal) const;</div>
<div>+</div><div>+protected:</div><div>+ friend class SBProcess;</div><div>+</div><div>+ SBUnixSignals (lldb_private::UnixSignals *unix_signals_ptr);</div><div>+</div><div>+ lldb_private::UnixSignals *</div><div>
+ GetPtr() const;</div><div>+</div><div>+ void</div><div>+ SetPtr (lldb_private::UnixSignals *unix_signals_ptr);</div><div>+</div><div>+private:</div><div>+ lldb_private::UnixSignals *m_opaque_ptr;</div><div>
+};</div>
<div>+</div><div>+</div><div>+} // namespace lldb</div><div>+</div><div>+#endif // LLDB_SBUnixSignals_h_</div><div>diff --git a/include/lldb/lldb-defines.h b/include/lldb/lldb-defines.h</div><div>index 3318aa1..a42ba3c 100644</div>
<div>--- a/include/lldb/lldb-defines.h</div><div>+++ b/include/lldb/lldb-defines.h</div><div>@@ -12,6 +12,10 @@</div><div> </div><div> #include "lldb/lldb-types.h"</div><div> </div><div>+#if !defined(INT32_MAX)</div>
<div>+ #define INT32_MAX 2147483647</div><div>+#endif</div><div>+</div><div> #if !defined(UINT32_MAX)</div><div> #define UINT32_MAX 4294967295U</div><div> #endif</div><div>diff --git a/include/lldb/lldb-forward.h b/include/lldb/lldb-forward.h</div>
<div>index 84af8b6..077d537 100644</div><div>--- a/include/lldb/lldb-forward.h</div><div>+++ b/include/lldb/lldb-forward.h</div><div>@@ -232,6 +232,7 @@ class TypeListImpl;</div><div> class TypeMemberImpl;</div><div>
class TypeNameSpecifierImpl;</div>
<div> class UUID;</div><div>+class UnixSignals;</div><div> class Unwind;</div><div> class UnwindAssembly;</div><div> class UnwindPlan;</div><div>diff --git a/scripts/Python/build-swig-Python.sh b/scripts/Python/build-swig-Python.sh</div>
<div>index 96c4b2b..4a111da 100755</div><div>--- a/scripts/Python/build-swig-Python.sh</div><div>+++ b/scripts/Python/build-swig-Python.sh</div><div>@@ -123,7 +123,8 @@ HEADER_FILES="${SRC_ROOT}/include/lldb/lldb.h"\</div>
<div> " ${SRC_ROOT}/include/lldb/API/SBTypeSynthetic.h"\</div><div> " ${SRC_ROOT}/include/lldb/API/SBValue.h"\</div><div> " ${SRC_ROOT}/include/lldb/API/SBValueList.h"\</div><div>-" ${SRC_ROOT}/include/lldb/API/SBWatchpoint.h"</div>
<div>+" ${SRC_ROOT}/include/lldb/API/SBWatchpoint.h"\</div><div>+" ${SRC_ROOT}/include/lldb/API/SBUnixSignals.h"</div><div> </div><div> INTERFACE_FILES="${SRC_ROOT}/scripts/Python/interface/SBAddress.i"\</div>
<div> " ${SRC_ROOT}/scripts/Python/interface/SBBlock.i"\</div><div>@@ -167,7 +168,8 @@ INTERFACE_FILES="${SRC_ROOT}/scripts/Python/interface/SBAddress.i"\</div><div> " ${SRC_ROOT}/scripts/Python/interface/SBTypeSynthetic.i"\</div>
<div> " ${SRC_ROOT}/scripts/Python/interface/SBValue.i"\</div><div> " ${SRC_ROOT}/scripts/Python/interface/SBValueList.i"\</div><div>-" ${SRC_ROOT}/scripts/Python/interface/SBWatchpoint.i"</div>
<div>+" ${SRC_ROOT}/scripts/Python/interface/SBWatchpoint.i"\</div><div>+" ${SRC_ROOT}/scripts/Python/interface/SBUnixSignals.i"</div><div> </div><div> if [ $Debug -eq 1 ]</div><div> then</div><div>diff --git a/scripts/Python/interface/SBProcess.i b/scripts/Python/interface/SBProcess.i</div>
<div>index 6f22d9a..7a03ac7 100644</div><div>--- a/scripts/Python/interface/SBProcess.i</div><div>+++ b/scripts/Python/interface/SBProcess.i</div><div>@@ -231,6 +231,9 @@ public:</div><div> lldb::SBError</div><div> Signal (int signal);</div>
<div> </div><div>+ lldb::SBUnixSignals</div><div>+ GetUnixSignals();</div><div>+</div><div> %feature("docstring", "</div><div> Returns a stop id that will increase every time the process executes. If</div>
<div> include_expression_stops is true, then stops caused by expression evaluation</div><div>diff --git a/scripts/Python/interface/SBUnixSignals.i b/scripts/Python/interface/SBUnixSignals.i</div><div>new file mode 100644</div>
<div>index 0000000..9972d1d</div><div>--- /dev/null</div><div>+++ b/scripts/Python/interface/SBUnixSignals.i</div><div>@@ -0,0 +1,73 @@</div><div>+//===-- SWIG Interface for SBProcess ----------------------------*- C++ -*-===//</div>
<div>+//</div><div>+// The LLVM Compiler Infrastructure</div><div>+//</div><div>+// This file is distributed under the University of Illinois Open Source</div><div>+// License. See LICENSE.TXT for details.</div>
<div>+//</div><div>+//===----------------------------------------------------------------------===//</div><div>+</div><div>+namespace lldb {</div><div>+</div><div>+%feature("docstring",</div><div>+"Allows you to manipulate LLDB's signal disposition"</div>
<div>+) SBUnixSignals;</div><div>+class SBUnixSignals</div><div>+{</div><div>+public:</div><div>+ SBUnixSignals ();</div><div>+</div><div>+ SBUnixSignals (const lldb::SBUnixSignals &rhs);</div><div>+</div><div>
+ ~SBUnixSignals();</div>
<div>+</div><div>+ void</div><div>+ Clear ();</div><div>+</div><div>+ bool</div><div>+ IsValid () const;</div><div>+</div><div>+ int32_t</div><div>+ GetSignalNumberFromName (const char *name) const;</div>
<div>+</div><div>+ bool</div><div>+ GetShouldSuppress (int32_t signo) const;</div><div>+</div><div>+ bool</div><div>+ SetShouldSuppress (int32_t signo,</div><div>+ bool value);</div><div>
+</div><div>+ bool</div><div>+ GetShouldStop (int32_t signo) const;</div><div>+</div><div>+ bool</div><div>+ SetShouldStop (int32_t signo,</div><div>+ bool value);</div><div>+</div><div>+ bool</div>
<div>+ GetShouldNotify (int32_t signo) const;</div><div>+</div><div>+ bool</div><div>+ SetShouldNotify (int32_t signo, bool value);</div><div>+</div><div>+ int32_t</div><div>+ GetFirstSignalNumber () const;</div>
<div>+</div><div>+ int32_t</div><div>+ GetNextSignalNumber (int32_t current_signal) const;</div><div>+</div><div>+ %pythoncode %{</div><div>+ def get_unix_signals_list(self):</div><div>+ signals = []</div>
<div>+ sig = self.GetFirstSignalNumber()</div><div>+ while sig != LLDB_INVALID_SIGNAL_NUMBER:</div><div>+ signals.append(sig)</div><div>+ sig = self.GetNextSignalNumber(sig)</div>
<div>+ return signals</div><div>+</div><div>+ __swig_getmethods__["signals"] = get_unix_signals_list</div><div>+ if _newclass: threads = property(get_unix_signals_list, None, doc='''A read only property that returns a list() of valid signal numbers for this platform.''')</div>
<div>+ %}</div><div>+};</div><div>+</div><div>+} // namespace lldb</div><div>diff --git a/scripts/lldb.swig b/scripts/lldb.swig</div><div>index b813f51..0a9a8ca 100644</div><div>--- a/scripts/lldb.swig</div><div>+++ b/scripts/lldb.swig</div>
<div>@@ -98,6 +98,7 @@ import os</div><div> #include "lldb/API/SBValue.h"</div><div> #include "lldb/API/SBValueList.h"</div><div> #include "lldb/API/SBWatchpoint.h"</div><div>+#include "lldb/API/SBUnixSignals.h"</div>
<div> </div><div> #include "../scripts/Python/python-swigsafecast.swig"</div><div> </div><div>@@ -105,6 +106,9 @@ import os</div><div> </div><div> /* Various liblldb typedefs that SWIG needs to know about. */</div>
<div> #define __extension__ /* Undefine GCC keyword to make Swig happy when processing glibc's stdint.h. */</div><div>+/* The ISO C99 standard specifies that in C++ implementations limit macros such</div><div>+ as INT32_MAX should only be defined if __STDC_LIMIT_MACROS is. */</div>
<div>+#define __STDC_LIMIT_MACROS</div><div> %include "stdint.i"</div><div> %include "lldb/lldb-defines.h"</div><div> %include "lldb/lldb-enumerations.h"</div><div>@@ -161,6 +165,7 @@ import os</div>
<div> %include "./Python/interface/SBValue.i"</div><div> %include "./Python/interface/SBValueList.i"</div><div> %include "./Python/interface/SBWatchpoint.i"</div><div>+%include "./Python/interface/SBUnixSignals.i"</div>
<div> </div><div> %include "./Python/python-extensions.swig"</div><div> </div><div>diff --git a/source/API/CMakeLists.txt b/source/API/CMakeLists.txt</div><div>index 3580b74..937a4c2 100644</div><div>--- a/source/API/CMakeLists.txt</div>
<div>+++ b/source/API/CMakeLists.txt</div><div>@@ -47,4 +47,5 @@ add_lldb_library(lldbAPI</div><div> SBValue.cpp</div><div> SBValueList.cpp</div><div> SBWatchpoint.cpp</div><div>+ SBUnixSignals.cpp</div><div> )</div>
<div>diff --git a/source/API/SBProcess.cpp b/source/API/SBProcess.cpp</div><div>index d41ad61..3215fe5 100644</div><div>--- a/source/API/SBProcess.cpp</div><div>+++ b/source/API/SBProcess.cpp</div><div>@@ -36,6 +36,7 @@</div>
<div> #include "lldb/API/SBThread.h"</div><div> #include "lldb/API/SBStream.h"</div><div> #include "lldb/API/SBStringList.h"</div><div>+#include "lldb/API/SBUnixSignals.h"</div><div>
</div><div> using namespace lldb;</div><div> using namespace lldb_private;</div><div>@@ -833,6 +834,19 @@ SBProcess::Signal (int signo)</div><div> return sb_error;</div><div> }</div><div> </div><div>+SBUnixSignals</div>
<div>+SBProcess::GetUnixSignals()</div><div>+{</div><div>+ SBUnixSignals sb_unix_signals;</div><div>+ ProcessSP process_sp(GetSP());</div><div>+ if (process_sp)</div><div>+ {</div><div>+ sb_unix_signals.SetPtr(&process_sp->GetUnixSignals());</div>
<div>+ }</div><div>+</div><div>+ return sb_unix_signals;</div><div>+}</div><div>+</div><div> void</div><div> SBProcess::SendAsyncInterrupt ()</div><div> {</div><div>diff --git a/source/API/SBUnixSignals.cpp b/source/API/SBUnixSignals.cpp</div>
<div>new file mode 100644</div><div>index 0000000..309a2fb</div><div>--- /dev/null</div><div>+++ b/source/API/SBUnixSignals.cpp</div><div>@@ -0,0 +1,130 @@</div><div>+//===-- SBUnixSignals.cpp -------------------------------------------*- C++ -*-===//</div>
<div>+//</div><div>+// The LLVM Compiler Infrastructure</div><div>+//</div><div>+// This file is distributed under the University of Illinois Open Source</div><div>+// License. See LICENSE.TXT for details.</div>
<div>+//</div><div>+//===----------------------------------------------------------------------===//</div><div>+</div><div>+#include "lldb/lldb-defines.h"</div><div>+#include "lldb/Target/UnixSignals.h"</div>
<div>+</div><div>+#include "lldb/API/SBUnixSignals.h"</div><div>+</div><div>+using namespace lldb;</div><div>+using namespace lldb_private;</div><div>+</div><div>+SBUnixSignals::SBUnixSignals () :</div><div>+ m_opaque_ptr(NULL)</div>
<div>+{</div><div>+}</div><div>+</div><div>+SBUnixSignals::SBUnixSignals (const SBUnixSignals &rhs) :</div><div>+ m_opaque_ptr(rhs.m_opaque_ptr)</div><div>+{</div><div>+}</div><div>+</div><div>+SBUnixSignals::SBUnixSignals (UnixSignals *unix_signals_ptr) :</div>
<div>+ m_opaque_ptr(unix_signals_ptr)</div><div>+{</div><div>+}</div><div>+</div><div>+const SBUnixSignals&</div><div>+SBUnixSignals::operator = (const SBUnixSignals& rhs)</div><div>+{</div><div>+ if (this != &rhs)</div>
<div>+ m_opaque_ptr = rhs.m_opaque_ptr;</div><div>+ return *this;</div><div>+}</div><div>+</div><div>+SBUnixSignals::~SBUnixSignals()</div><div>+{</div><div>+}</div><div>+</div><div>+UnixSignals *</div><div>+SBUnixSignals::GetPtr() const</div>
<div>+{</div><div>+ return m_opaque_ptr;</div><div>+}</div><div>+</div><div>+void</div><div>+SBUnixSignals::SetPtr (UnixSignals *unix_signals_ptr)</div><div>+{</div><div>+ m_opaque_ptr = unix_signals_ptr;</div><div>
+}</div><div>+</div><div>+void</div><div>+SBUnixSignals::Clear ()</div><div>+{</div><div>+ m_opaque_ptr = NULL;</div><div>+}</div><div>+</div><div>+bool</div><div>+SBUnixSignals::IsValid() const</div><div>+{</div><div>
+ return m_opaque_ptr != NULL;</div><div>+}</div><div>+</div><div>+int32_t</div><div>+SBUnixSignals::GetSignalNumberFromName (const char *name) const</div><div>+{</div><div>+ if (m_opaque_ptr) return m_opaque_ptr->GetSignalNumberFromName(name);</div>
<div>+ return -1;</div><div>+}</div><div>+</div><div>+bool</div><div>+SBUnixSignals::GetShouldSuppress (int32_t signo) const</div><div>+{</div><div>+ if (m_opaque_ptr) return m_opaque_ptr->GetShouldSuppress(signo);</div>
<div>+ return false;</div><div>+}</div><div>+</div><div>+bool</div><div>+SBUnixSignals::SetShouldSuppress (int32_t signo, bool value)</div><div>+{</div><div>+ if (m_opaque_ptr) return m_opaque_ptr->SetShouldSuppress(signo, value);</div>
<div>+ return false;</div><div>+}</div><div>+</div><div>+bool</div><div>+SBUnixSignals::GetShouldStop (int32_t signo) const</div><div>+{</div><div>+ if (m_opaque_ptr) return m_opaque_ptr->GetShouldStop(signo);</div>
<div>+ return false;</div><div>+}</div><div>+</div><div>+bool</div><div>+SBUnixSignals::SetShouldStop (int32_t signo, bool value)</div><div>+{</div><div>+ if (m_opaque_ptr) return m_opaque_ptr->SetShouldStop(signo, value);</div>
<div>+ return false;</div><div>+}</div><div>+</div><div>+bool</div><div>+SBUnixSignals::GetShouldNotify (int32_t signo) const</div><div>+{</div><div>+ if (m_opaque_ptr) return m_opaque_ptr->GetShouldNotify(signo);</div>
<div>+ return false;</div><div>+}</div><div>+</div><div>+bool</div><div>+SBUnixSignals::SetShouldNotify (int32_t signo, bool value)</div><div>+{</div><div>+ if (m_opaque_ptr) return m_opaque_ptr->SetShouldNotify(signo, value);</div>
<div>+ return false;</div><div>+}</div><div>+</div><div>+int32_t</div><div>+SBUnixSignals::GetFirstSignalNumber () const</div><div>+{</div><div>+ if (m_opaque_ptr) return m_opaque_ptr->GetFirstSignalNumber();</div>
<div>+ return LLDB_INVALID_SIGNAL_NUMBER;</div><div>+}</div><div>+</div><div>+int32_t</div><div>+SBUnixSignals::GetNextSignalNumber (int32_t current_signal) const</div><div>+{</div><div>+ if (m_opaque_ptr) return m_opaque_ptr->GetNextSignalNumber(current_signal);</div>
<div>+ return LLDB_INVALID_SIGNAL_NUMBER;</div><div>+}</div><div>-- </div><div>1.8.1.3</div><div><br></div></div></div>