[PATCH] D51445: Remove undefined behavior around the use of StateType
Shafik Yaghmour via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 11 09:09:41 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341957: Remove undefined behavior around the use of StateType (authored by shafik, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D51445?vs=163450&id=164905#toc
Repository:
rL LLVM
https://reviews.llvm.org/D51445
Files:
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/scripts/Python/python-typemaps.swig
lldb/trunk/unittests/Utility/StateTest.cpp
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());
+
}
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<lldb::StateType>(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/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
};
//----------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51445.164905.patch
Type: text/x-patch
Size: 3035 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180911/74b0a8a9/attachment.bin>
More information about the llvm-commits
mailing list