Index: lldb/trunk/include/lldb/lldb-enumerations.h =================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h +++ lldb/trunk/include/lldb/lldb-enumerations.h @@ -54,9 +54,10 @@ eStateCrashed, ///< Process or thread has crashed and can be examined. eStateDetached, ///< Process has been detached and can't be examined. eStateExited, ///< Process has exited and can't be examined. - eStateSuspended ///< Process or thread is in a suspended state as far + eStateSuspended, ///< Process or thread is in a suspended state as far ///< as the debugger is concerned while other processes ///< or threads get the chance to run. + kLastStateType = eStateSuspended }; //---------------------------------------------------------------------- Index: lldb/trunk/scripts/Python/python-typemaps.swig =================================================================== --- lldb/trunk/scripts/Python/python-typemaps.swig +++ lldb/trunk/scripts/Python/python-typemaps.swig @@ -77,6 +77,26 @@ } } +%typemap(in) lldb::StateType { + using namespace lldb_private; + if (PythonInteger::Check($input)) + { + PythonInteger py_int(PyRefType::Borrowed, $input); + int64_t state_type_value = py_int.GetInteger() ; + + if (state_type_value > lldb::StateType::kLastStateType) { + PyErr_SetString(PyExc_ValueError, "Not a valid StateType value"); + return nullptr; + } + $1 = static_cast(state_type_value); + } + else + { + PyErr_SetString(PyExc_ValueError, "Expecting an integer"); + return nullptr; + } +} + /* Typemap definitions to allow SWIG to properly handle char buffer. */ // typemap for a char buffer Index: lldb/trunk/unittests/Utility/StateTest.cpp =================================================================== --- lldb/trunk/unittests/Utility/StateTest.cpp +++ lldb/trunk/unittests/Utility/StateTest.cpp @@ -15,7 +15,17 @@ using namespace lldb_private; TEST(StateTest, Formatv) { - EXPECT_EQ("exited", llvm::formatv("{0}", eStateExited).str()); + EXPECT_EQ("invalid", llvm::formatv("{0}", eStateInvalid).str()); + EXPECT_EQ("unloaded", llvm::formatv("{0}", eStateUnloaded).str()); + EXPECT_EQ("connected", llvm::formatv("{0}", eStateConnected).str()); + EXPECT_EQ("attaching", llvm::formatv("{0}", eStateAttaching).str()); + EXPECT_EQ("launching", llvm::formatv("{0}", eStateLaunching).str()); EXPECT_EQ("stopped", llvm::formatv("{0}", eStateStopped).str()); - EXPECT_EQ("unknown", llvm::formatv("{0}", StateType(-1)).str()); + EXPECT_EQ("running", llvm::formatv("{0}", eStateRunning).str()); + EXPECT_EQ("stepping", llvm::formatv("{0}", eStateStepping).str()); + EXPECT_EQ("crashed", llvm::formatv("{0}", eStateCrashed).str()); + EXPECT_EQ("detached", llvm::formatv("{0}", eStateDetached).str()); + EXPECT_EQ("exited", llvm::formatv("{0}", eStateExited).str()); + EXPECT_EQ("suspended", llvm::formatv("{0}", eStateSuspended).str()); + }