<div dir="ltr">Hi Russell,<div><br></div><div>Can you put that on Phabricator (<a href="http://reviews.llvm.org/">http://reviews.llvm.org/</a>) and assign to me? Thanks!</div><div><br></div><div>-Todd</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, Jun 17, 2014 at 9:35 AM, Russell Harmon <span dir="ltr"><<a href="mailto:eatnumber1@google.com" target="_blank">eatnumber1@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Ping. Can someone take a look at this when they get a chance?<div class="HOEnZb"><div class="h5"><br><br><div>On Thu Jun 05 2014 at 6:17:00 PM, Russell Harmon <<a href="mailto:eatnumber1@google.com" target="_blank">eatnumber1@google.com</a>> wrote:</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This commit allows you to control the signals that lldb will suppress, stop or<br>
forward using the Python and C++ APIs.<br>
---<br>
include/lldb/API/SBDefines.h | 1 +<br>
include/lldb/API/SBProcess.h | 3 +<br>
include/lldb/API/<u></u>SBUnixSignals.h | 84 +++++++++++++<br>
include/lldb/lldb-defines.h | 4 +<br>
include/lldb/lldb-forward.h | 1 +<br>
scripts/Python/build-swig-<u></u>Python.sh | 6 +-<br>
scripts/Python/interface/<u></u>SBProcess.i | 3 +<br>
scripts/Python/interface/<u></u>SBUnixSignals.i | 74 ++++++++++++<br>
scripts/lldb.swig | 5 +<br>
source/API/CMakeLists.txt | 1 +<br>
source/API/SBProcess.cpp | 14 +++<br>
source/API/SBUnixSignals.cpp | 192 ++++++++++++++++++++++++++++++<br>
test/python_api/signals/<u></u>Makefile | 5 +<br>
test/python_api/signals/<u></u>TestSignalsAPI.py | 49 ++++++++<br>
test/python_api/signals/main.<u></u>cpp | 20 ++++<br>
15 files changed, 460 insertions(+), 2 deletions(-)<br>
create mode 100644 include/lldb/API/<u></u>SBUnixSignals.h<br>
create mode 100644 scripts/Python/interface/<u></u>SBUnixSignals.i<br>
create mode 100644 source/API/SBUnixSignals.cpp<br>
create mode 100644 test/python_api/signals/<u></u>Makefile<br>
create mode 100644 test/python_api/signals/<u></u>TestSignalsAPI.py<br>
create mode 100644 test/python_api/signals/main.<u></u>cpp<br>
<br>
diff --git a/include/lldb/API/SBDefines.h b/include/lldb/API/SBDefines.h<br>
index 15d8d1f..30ea0df 100644<br>
--- a/include/lldb/API/SBDefines.h<br>
+++ b/include/lldb/API/SBDefines.h<br>
@@ -85,6 +85,7 @@ class LLDB_API SBTypeList;<br>
class LLDB_API SBValue;<br>
class LLDB_API SBValueList;<br>
class LLDB_API SBWatchpoint;<br>
+class LLDB_API SBUnixSignals;<br>
<br>
}<br>
<br>
diff --git a/include/lldb/API/SBProcess.h b/include/lldb/API/SBProcess.h<br>
index 448e959..4b59462 100644<br>
--- a/include/lldb/API/SBProcess.h<br>
+++ b/include/lldb/API/SBProcess.h<br>
@@ -221,6 +221,9 @@ public:<br>
lldb::SBError<br>
Signal (int signal);<br>
<br>
+ lldb::SBUnixSignals<br>
+ GetUnixSignals();<br>
+<br>
void<br>
SendAsyncInterrupt();<br>
<br>
diff --git a/include/lldb/API/<u></u>SBUnixSignals.h b/include/lldb/API/<u></u>SBUnixSignals.h<br>
new file mode 100644<br>
index 0000000..d95453a<br>
--- /dev/null<br>
+++ b/include/lldb/API/<u></u>SBUnixSignals.h<br>
@@ -0,0 +1,84 @@<br>
+//===-- SBUnixSignals.h ------------------------------<u></u>-----------------*- C++ -*-===//<br>
+//<br>
+// The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<u></u>------------------------------<u></u>----------------===//<br>
+<br>
+#ifndef LLDB_SBUnixSignals_h_<br>
+#define LLDB_SBUnixSignals_h_<br>
+<br>
+#include "lldb/API/SBDefines.h"<br>
+<br>
+namespace lldb {<br>
+<br>
+class SBUnixSignals {<br>
+public:<br>
+ SBUnixSignals ();<br>
+<br>
+ SBUnixSignals (const lldb::SBUnixSignals &rhs);<br>
+<br>
+ ~SBUnixSignals();<br>
+<br>
+ const SBUnixSignals &<br>
+ operator =(const lldb::SBUnixSignals &rhs);<br>
+<br>
+ void<br>
+ Clear ();<br>
+<br>
+ bool<br>
+ IsValid () const;<br>
+<br>
+ const char *<br>
+ GetSignalAsCString (int32_t signo) const;<br>
+<br>
+ int32_t<br>
+ GetSignalNumberFromName (const char *name) const;<br>
+<br>
+ bool<br>
+ GetShouldSuppress (int32_t signo) const;<br>
+<br>
+ bool<br>
+ SetShouldSuppress (int32_t signo,<br>
+ bool value);<br>
+<br>
+ bool<br>
+ GetShouldStop (int32_t signo) const;<br>
+<br>
+ bool<br>
+ SetShouldStop (int32_t signo,<br>
+ bool value);<br>
+<br>
+ bool<br>
+ GetShouldNotify (int32_t signo) const;<br>
+<br>
+ bool<br>
+ SetShouldNotify (int32_t signo, bool value);<br>
+<br>
+ int32_t<br>
+ GetNumSignals () const;<br>
+<br>
+ int32_t<br>
+ GetSignalAtIndex (int32_t index) const;<br>
+<br>
+protected:<br>
+ friend class SBProcess;<br>
+<br>
+ SBUnixSignals (lldb_private::UnixSignals *unix_signals_ptr);<br>
+<br>
+ lldb_private::UnixSignals *<br>
+ GetPtr() const;<br>
+<br>
+ void<br>
+ SetPtr (lldb_private::UnixSignals *unix_signals_ptr);<br>
+<br>
+private:<br>
+ lldb_private::UnixSignals *m_opaque_ptr;<br>
+};<br>
+<br>
+<br>
+} // namespace lldb<br>
+<br>
+#endif // LLDB_SBUnixSignals_h_<br>
diff --git a/include/lldb/lldb-defines.h b/include/lldb/lldb-defines.h<br>
index 1cfbe4e..f8a0257 100644<br>
--- a/include/lldb/lldb-defines.h<br>
+++ b/include/lldb/lldb-defines.h<br>
@@ -24,6 +24,10 @@<br>
#define LLDB_API<br>
#endif<br>
<br>
+#if !defined(INT32_MAX)<br>
+ #define INT32_MAX <a href="tel:2147483647" value="+12147483647" target="_blank">2147483647</a><br>
+#endif<br>
+<br>
#if !defined(UINT32_MAX)<br>
#define UINT32_MAX 4294967295U<br>
#endif<br>
diff --git a/include/lldb/lldb-forward.h b/include/lldb/lldb-forward.h<br>
index 9cd6adb..e4db5a1 100644<br>
--- a/include/lldb/lldb-forward.h<br>
+++ b/include/lldb/lldb-forward.h<br>
@@ -249,6 +249,7 @@ class TypeEnumMemberListImpl;<br>
class TypeNameSpecifierImpl;<br>
class TypePair;<br>
class UUID;<br>
+class UnixSignals;<br>
class Unwind;<br>
class UnwindAssembly;<br>
class UnwindPlan;<br>
diff --git a/scripts/Python/build-swig-<u></u>Python.sh b/scripts/Python/build-swig-<u></u>Python.sh<br>
index 5f9b574..3e30a6a 100755<br>
--- a/scripts/Python/build-swig-<u></u>Python.sh<br>
+++ b/scripts/Python/build-swig-<u></u>Python.sh<br>
@@ -122,7 +122,8 @@ HEADER_FILES="${SRC_ROOT}/<u></u>include/lldb/lldb.h"\<br>
" ${SRC_ROOT}/include/lldb/API/<u></u>SBTypeSynthetic.h"\<br>
" ${SRC_ROOT}/include/lldb/API/<u></u>SBValue.h"\<br>
" ${SRC_ROOT}/include/lldb/API/<u></u>SBValueList.h"\<br>
-" ${SRC_ROOT}/include/lldb/API/<u></u>SBWatchpoint.h"<br>
+" ${SRC_ROOT}/include/lldb/API/<u></u>SBWatchpoint.h"\<br>
+" ${SRC_ROOT}/include/lldb/API/<u></u>SBUnixSignals.h"<br>
<br>
INTERFACE_FILES="${SRC_ROOT}/<u></u>scripts/Python/interface/<u></u>SBAddress.i"\<br>
" ${SRC_ROOT}/scripts/Python/<u></u>interface/SBBlock.i"\<br>
@@ -169,7 +170,8 @@ INTERFACE_FILES="${SRC_ROOT}/<u></u>scripts/Python/interface/<u></u>SBAddress.i"\<br>
" ${SRC_ROOT}/scripts/Python/<u></u>interface/SBTypeSynthetic.i"\<br>
" ${SRC_ROOT}/scripts/Python/<u></u>interface/SBValue.i"\<br>
" ${SRC_ROOT}/scripts/Python/<u></u>interface/SBValueList.i"\<br>
-" ${SRC_ROOT}/scripts/Python/<u></u>interface/SBWatchpoint.i"<br>
+" ${SRC_ROOT}/scripts/Python/<u></u>interface/SBWatchpoint.i"\<br>
+" ${SRC_ROOT}/scripts/Python/<u></u>interface/SBUnixSignals.i"<br>
<br>
if [ $Debug -eq 1 ]<br>
then<br>
diff --git a/scripts/Python/interface/<u></u>SBProcess.i b/scripts/Python/interface/<u></u>SBProcess.i<br>
index d023b24..5cd99c0 100644<br>
--- a/scripts/Python/interface/<u></u>SBProcess.i<br>
+++ b/scripts/Python/interface/<u></u>SBProcess.i<br>
@@ -240,6 +240,9 @@ public:<br>
lldb::SBError<br>
Signal (int signal);<br>
<br>
+ lldb::SBUnixSignals<br>
+ GetUnixSignals();<br>
+<br>
%feature("docstring", "<br>
Returns a stop id that will increase every time the process executes. If<br>
include_expression_stops is true, then stops caused by expression evaluation<br>
diff --git a/scripts/Python/interface/<u></u>SBUnixSignals.i b/scripts/Python/interface/<u></u>SBUnixSignals.i<br>
new file mode 100644<br>
index 0000000..2bd537a<br>
--- /dev/null<br>
+++ b/scripts/Python/interface/<u></u>SBUnixSignals.i<br>
@@ -0,0 +1,74 @@<br>
+//===-- SWIG Interface for SBProcess ----------------------------*- C++ -*-===//<br>
+//<br>
+// The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<u></u>------------------------------<u></u>----------------===//<br>
+<br>
+namespace lldb {<br>
+<br>
+%feature("docstring",<br>
+"Allows you to manipulate LLDB's signal disposition"<br>
+) SBUnixSignals;<br>
+class SBUnixSignals<br>
+{<br>
+public:<br>
+ SBUnixSignals ();<br>
+<br>
+ SBUnixSignals (const lldb::SBUnixSignals &rhs);<br>
+<br>
+ ~SBUnixSignals();<br>
+<br>
+ void<br>
+ Clear ();<br>
+<br>
+ bool<br>
+ IsValid () const;<br>
+<br>
+ const char *<br>
+ GetSignalAsCString (int32_t signo) const;<br>
+<br>
+ int32_t<br>
+ GetSignalNumberFromName (const char *name) const;<br>
+<br>
+ bool<br>
+ GetShouldSuppress (int32_t signo) const;<br>
+<br>
+ bool<br>
+ SetShouldSuppress (int32_t signo,<br>
+ bool value);<br>
+<br>
+ bool<br>
+ GetShouldStop (int32_t signo) const;<br>
+<br>
+ bool<br>
+ SetShouldStop (int32_t signo,<br>
+ bool value);<br>
+<br>
+ bool<br>
+ GetShouldNotify (int32_t signo) const;<br>
+<br>
+ bool<br>
+ SetShouldNotify (int32_t signo, bool value);<br>
+<br>
+ int32_t<br>
+ GetNumSignals () const;<br>
+<br>
+ int32_t<br>
+ GetSignalAtIndex (int32_t index) const;<br>
+<br>
+ %pythoncode %{<br>
+ def get_unix_signals_list(self):<br>
+ signals = []<br>
+ for idx in range(0, self.GetNumSignals()):<br>
+ signals.append(self.<u></u>GetSignalAtIndex(sig))<br>
+ return signals<br>
+<br>
+ __swig_getmethods__["signals"] = get_unix_signals_list<br>
+ if _newclass: threads = property(get_unix_signals_<u></u>list, None, doc='''A read only property that returns a list() of valid signal numbers for this platform.''')<br>
+ %}<br>
+};<br>
+<br>
+} // namespace lldb<br>
diff --git a/scripts/lldb.swig b/scripts/lldb.swig<br>
index 1a230d1..94392a1 100644<br>
--- a/scripts/lldb.swig<br>
+++ b/scripts/lldb.swig<br>
@@ -102,6 +102,7 @@ import os<br>
#include "lldb/API/SBValue.h"<br>
#include "lldb/API/SBValueList.h"<br>
#include "lldb/API/SBWatchpoint.h"<br>
+#include "lldb/API/SBUnixSignals.h"<br>
<br>
#include "../scripts/Python/python-<u></u>swigsafecast.swig"<br>
<br>
@@ -109,6 +110,9 @@ import os<br>
<br>
/* Various liblldb typedefs that SWIG needs to know about. */<br>
#define __extension__ /* Undefine GCC keyword to make Swig happy when processing glibc's stdint.h. */<br>
+/* The ISO C99 standard specifies that in C++ implementations limit macros such<br>
+ as INT32_MAX should only be defined if __STDC_LIMIT_MACROS is. */<br>
+#define __STDC_LIMIT_MACROS<br>
%include "stdint.i"<br>
%include "lldb/lldb-defines.h"<br>
%include "lldb/lldb-enumerations.h"<br>
@@ -169,6 +173,7 @@ import os<br>
%include "./Python/interface/SBValue.i"<br>
%include "./Python/interface/<u></u>SBValueList.i"<br>
%include "./Python/interface/<u></u>SBWatchpoint.i"<br>
+%include "./Python/interface/<u></u>SBUnixSignals.i"<br>
<br>
%include "./Python/python-extensions.<u></u>swig"<br>
<br>
diff --git a/source/API/CMakeLists.txt b/source/API/CMakeLists.txt<br>
index 63adb68..b903b4e 100644<br>
--- a/source/API/CMakeLists.txt<br>
+++ b/source/API/CMakeLists.txt<br>
@@ -51,4 +51,5 @@ add_lldb_library(lldbAPI<br>
SBValue.cpp<br>
SBValueList.cpp<br>
SBWatchpoint.cpp<br>
+ SBUnixSignals.cpp<br>
)<br>
diff --git a/source/API/SBProcess.cpp b/source/API/SBProcess.cpp<br>
index bb5b989..2f32f28 100644<br>
--- a/source/API/SBProcess.cpp<br>
+++ b/source/API/SBProcess.cpp<br>
@@ -40,6 +40,7 @@<br>
#include "lldb/API/SBThread.h"<br>
#include "lldb/API/SBStream.h"<br>
#include "lldb/API/SBStringList.h"<br>
+#include "lldb/API/SBUnixSignals.h"<br>
<br>
using namespace lldb;<br>
using namespace lldb_private;<br>
@@ -893,6 +894,19 @@ SBProcess::Signal (int signo)<br>
return sb_error;<br>
}<br>
<br>
+SBUnixSignals<br>
+SBProcess::GetUnixSignals()<br>
+{<br>
+ SBUnixSignals sb_unix_signals;<br>
+ ProcessSP process_sp(GetSP());<br>
+ if (process_sp)<br>
+ {<br>
+ sb_unix_signals.SetPtr(&<u></u>process_sp->GetUnixSignals());<br>
+ }<br>
+<br>
+ return sb_unix_signals;<br>
+}<br>
+<br>
void<br>
SBProcess::SendAsyncInterrupt ()<br>
{<br>
diff --git a/source/API/SBUnixSignals.cpp b/source/API/SBUnixSignals.cpp<br>
new file mode 100644<br>
index 0000000..21c508d<br>
--- /dev/null<br>
+++ b/source/API/SBUnixSignals.cpp<br>
@@ -0,0 +1,192 @@<br>
+//===-- SBUnixSignals.cpp ------------------------------<u></u>-------------*- C++ -*-===//<br>
+//<br>
+// The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<u></u>------------------------------<u></u>----------------===//<br>
+<br>
+#include "lldb/lldb-defines.h"<br>
+#include "lldb/Target/UnixSignals.h"<br>
+#include "lldb/Core/Log.h"<br>
+<br>
+#include "lldb/API/SBUnixSignals.h"<br>
+<br>
+using namespace lldb;<br>
+using namespace lldb_private;<br>
+<br>
+SBUnixSignals::SBUnixSignals () :<br>
+ m_opaque_ptr(NULL)<br>
+{<br>
+}<br>
+<br>
+SBUnixSignals::SBUnixSignals (const SBUnixSignals &rhs) :<br>
+ m_opaque_ptr(rhs.m_opaque_ptr)<br>
+{<br>
+}<br>
+<br>
+SBUnixSignals::SBUnixSignals (UnixSignals *unix_signals_ptr) :<br>
+ m_opaque_ptr(unix_signals_ptr)<br>
+{<br>
+}<br>
+<br>
+const SBUnixSignals&<br>
+SBUnixSignals::operator = (const SBUnixSignals& rhs)<br>
+{<br>
+ if (this != &rhs)<br>
+ m_opaque_ptr = rhs.m_opaque_ptr;<br>
+ return *this;<br>
+}<br>
+<br>
+SBUnixSignals::~<u></u>SBUnixSignals()<br>
+{<br>
+}<br>
+<br>
+UnixSignals *<br>
+SBUnixSignals::GetPtr() const<br>
+{<br>
+ return m_opaque_ptr;<br>
+}<br>
+<br>
+void<br>
+SBUnixSignals::SetPtr (UnixSignals *unix_signals_ptr)<br>
+{<br>
+ m_opaque_ptr = unix_signals_ptr;<br>
+}<br>
+<br>
+void<br>
+SBUnixSignals::Clear ()<br>
+{<br>
+ m_opaque_ptr = NULL;<br>
+}<br>
+<br>
+bool<br>
+SBUnixSignals::IsValid() const<br>
+{<br>
+ return m_opaque_ptr != NULL;<br>
+}<br>
+<br>
+const char *<br>
+SBUnixSignals::<u></u>GetSignalAsCString (int32_t signo) const<br>
+{<br>
+ if (m_opaque_ptr) return m_opaque_ptr-><u></u>GetSignalAsCString(signo);<br>
+ return NULL;<br>
+}<br>
+<br>
+int32_t<br>
+SBUnixSignals::<u></u>GetSignalNumberFromName (const char *name) const<br>
+{<br>
+ if (m_opaque_ptr) return m_opaque_ptr-><u></u>GetSignalNumberFromName(name);<br>
+ return -1;<br>
+}<br>
+<br>
+bool<br>
+SBUnixSignals::<u></u>GetShouldSuppress (int32_t signo) const<br>
+{<br>
+ if (m_opaque_ptr) return m_opaque_ptr-><u></u>GetShouldSuppress(signo);<br>
+ return false;<br>
+}<br>
+<br>
+bool<br>
+SBUnixSignals::<u></u>SetShouldSuppress (int32_t signo, bool value)<br>
+{<br>
+ Log *log(lldb_private::<u></u>GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));<br>
+<br>
+ if (log)<br>
+ {<br>
+ log->Printf ("SBUnixSignals(%p)::<u></u>SetShouldSuppress (signo=%d, value=%d)",<br>
+ m_opaque_ptr,<br>
+ signo,<br>
+ value);<br>
+ }<br>
+<br>
+ if (m_opaque_ptr) return m_opaque_ptr-><u></u>SetShouldSuppress(signo, value);<br>
+ return false;<br>
+}<br>
+<br>
+bool<br>
+SBUnixSignals::GetShouldStop (int32_t signo) const<br>
+{<br>
+ if (m_opaque_ptr) return m_opaque_ptr->GetShouldStop(<u></u>signo);<br>
+ return false;<br>
+}<br>
+<br>
+bool<br>
+SBUnixSignals::SetShouldStop (int32_t signo, bool value)<br>
+{<br>
+ Log *log(lldb_private::<u></u>GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));<br>
+<br>
+ if (log)<br>
+ {<br>
+ log->Printf ("SBUnixSignals(%p)::<u></u>SetShouldStop (signo=%d, value=%d)",<br>
+ m_opaque_ptr,<br>
+ signo,<br>
+ value);<br>
+ }<br>
+<br>
+ if (m_opaque_ptr) return m_opaque_ptr->SetShouldStop(<u></u>signo, value);<br>
+ return false;<br>
+}<br>
+<br>
+bool<br>
+SBUnixSignals::<u></u>GetShouldNotify (int32_t signo) const<br>
+{<br>
+ if (m_opaque_ptr) return m_opaque_ptr->GetShouldNotify(<u></u>signo);<br>
+ return false;<br>
+}<br>
+<br>
+bool<br>
+SBUnixSignals::<u></u>SetShouldNotify (int32_t signo, bool value)<br>
+{<br>
+ Log *log(lldb_private::<u></u>GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));<br>
+<br>
+ if (log)<br>
+ {<br>
+ log->Printf ("SBUnixSignals(%p)::<u></u>SetShouldNotify (signo=%d, value=%d)",<br>
+ m_opaque_ptr,<br>
+ signo,<br>
+ value);<br>
+ }<br>
+<br>
+ if (m_opaque_ptr) return m_opaque_ptr->SetShouldNotify(<u></u>signo, value);<br>
+ return false;<br>
+}<br>
+<br>
+int32_t<br>
+SBUnixSignals::GetNumSignals () const<br>
+{<br>
+ if (m_opaque_ptr)<br>
+ {<br>
+ int32_t num_signals = 0;<br>
+ for (<br>
+ int32_t signo = m_opaque_ptr-><u></u>GetFirstSignalNumber();<br>
+ signo != LLDB_INVALID_SIGNAL_NUMBER;<br>
+ signo = m_opaque_ptr-><u></u>GetNextSignalNumber(signo)<br>
+ )<br>
+ {<br>
+ num_signals++;<br>
+ }<br>
+ return num_signals;<br>
+ }<br>
+ return LLDB_INVALID_SIGNAL_NUMBER;<br>
+}<br>
+<br>
+int32_t<br>
+SBUnixSignals::<u></u>GetSignalAtIndex (int32_t index) const<br>
+{<br>
+ if (m_opaque_ptr)<br>
+ {<br>
+ int32_t idx = 0;<br>
+ for (<br>
+ int32_t signo = m_opaque_ptr-><u></u>GetFirstSignalNumber();<br>
+ signo != LLDB_INVALID_SIGNAL_NUMBER;<br>
+ signo = m_opaque_ptr-><u></u>GetNextSignalNumber(signo)<br>
+ )<br>
+ {<br>
+ if (index == idx) return signo;<br>
+ idx++;<br>
+ }<br>
+ }<br>
+ return LLDB_INVALID_SIGNAL_NUMBER;<br>
+}<br>
diff --git a/test/python_api/signals/<u></u>Makefile b/test/python_api/signals/<u></u>Makefile<br>
new file mode 100644<br>
index 0000000..8a7102e<br>
--- /dev/null<br>
+++ b/test/python_api/signals/<u></u>Makefile<br>
@@ -0,0 +1,5 @@<br>
+LEVEL = ../../make<br>
+<br>
+CXX_SOURCES := main.cpp<br>
+<br>
+include $(LEVEL)/Makefile.rules<br>
diff --git a/test/python_api/signals/<u></u>TestSignalsAPI.py b/test/python_api/signals/<u></u>TestSignalsAPI.py<br>
new file mode 100644<br>
index 0000000..9702284<br>
--- /dev/null<br>
+++ b/test/python_api/signals/<u></u>TestSignalsAPI.py<br>
@@ -0,0 +1,49 @@<br>
+"""<br>
+Test SBProcess APIs, including ReadMemory(), WriteMemory(), and others.<br>
+"""<br>
+<br>
+import os, time<br>
+import unittest2<br>
+import lldb<br>
+from lldbutil import get_stopped_thread, state_type_to_str<br>
+from lldbtest import *<br>
+<br>
+class SignalsAPITestCase(TestBase):<br>
+ mydir = os.path.join("python_api", "signals")<br>
+<br>
+ @python_api_test<br>
+ def test_ignore_signal(self):<br>
+ """Test Python SBUnixSignals.Suppress/Stop/<u></u>Notify() API."""<br>
+ self.buildDefault()<br>
+ exe = os.path.join(os.getcwd(), "a.out")<br>
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)<br>
+<br>
+ target = self.dbg.CreateTarget(exe)<br>
+ self.assertTrue(target, VALID_TARGET)<br>
+<br>
+ line = line_number("main.cpp", "// Set break point at this line and setup signal ignores.")<br>
+ breakpoint = target.<u></u>BreakpointCreateByLocation("<u></u>main.cpp", line)<br>
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)<br>
+<br>
+ # Launch the process, and do not stop at the entry point.<br>
+ process = target.LaunchSimple (None, None, self.get_process_working_<u></u>directory())<br>
+<br>
+ thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)<br>
+ self.assertTrue(thread.<u></u>IsValid(), "There should be a thread stopped due to breakpoint")<br>
+<br>
+ unix_signals = process.GetUnixSignals()<br>
+ sigint = unix_signals.<u></u>GetSignalNumberFromName("<u></u>SIGINT")<br>
+ unix_signals.<u></u>SetShouldSuppress(sigint, True)<br>
+ unix_signals.SetShouldStop(<u></u>sigint, False)<br>
+ unix_signals.SetShouldNotify(<u></u>sigint, False)<br>
+<br>
+ process.Continue()<br>
+ self.assertTrue(process.state == lldb.eStateExited, "The process should have exited")<br>
+ self.assertTrue(process.<u></u>GetExitStatus() == 0, "The process should have returned 0")<br>
+<br>
+<br>
+if __name__ == '__main__':<br>
+ import atexit<br>
+ lldb.SBDebugger.Initialize()<br>
+ atexit.register(lambda: lldb.SBDebugger.Terminate())<br>
+ unittest2.main()<br>
diff --git a/test/python_api/signals/<u></u>main.cpp b/test/python_api/signals/<u></u>main.cpp<br>
new file mode 100644<br>
index 0000000..ddd2ffe<br>
--- /dev/null<br>
+++ b/test/python_api/signals/<u></u>main.cpp<br>
@@ -0,0 +1,20 @@<br>
+//===-- main.c ------------------------------<u></u>--------------------*- C++ -*-===//<br>
+//<br>
+// The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<u></u>------------------------------<u></u>----------------===//<br>
+#include <stdio.h><br>
+#include <sys/types.h><br>
+#include <unistd.h><br>
+#include <signal.h><br>
+<br>
+// This simple program is to test the lldb Python API related to process.<br>
+<br>
+int main (int argc, char const *argv[])<br>
+{<br>
+ kill(getpid(), SIGINT); // Set break point at this line and setup signal ignores.<br>
+ return 0;<br>
+}<br>
--<br>
2.0.0.526.g5318336<br>
<br>
</blockquote>
</div></div><br>_______________________________________________<br>
lldb-dev mailing list<br>
<a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><table cellspacing="0" cellpadding="0" style="color:rgb(136,136,136);font-family:'Times New Roman'"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small">
<td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Todd Fiala |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tfiala@google.com" style="color:rgb(17,85,204)" target="_blank"><span style="background-color:rgb(255,255,204);color:rgb(34,34,34);background-repeat:initial initial">tfiala@google.com</span></a> |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"><font color="#1155cc"> <a>650-943-3180</a></font></td></tr></tbody></table><br></div>
</div>