[Lldb-commits] [PATCH] D114157: [lldb/test] Make it possible to run the mock gdb server on a single thread
This revision was automatically updated to reflect the committed changes. Closed by commit rG7c8ae65f2c3d: [lldb/test] Make it possible to run the mock gdb server on a single thread (authored by labath). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114157/new/ https://reviews.llvm.org/D114157 Files: lldb/packages/Python/lldbsuite/test/gdbclientutils.py lldb/packages/Python/lldbsuite/test/lldbgdbclient.py Index: lldb/packages/Python/lldbsuite/test/lldbgdbclient.py === --- lldb/packages/Python/lldbsuite/test/lldbgdbclient.py +++ lldb/packages/Python/lldbsuite/test/lldbgdbclient.py @@ -19,7 +19,7 @@ def setUp(self): TestBase.setUp(self) -self.server = MockGDBServer(socket_class=self.server_socket_class) +self.server = MockGDBServer(self.server_socket_class()) self.server.start() def tearDown(self): Index: lldb/packages/Python/lldbsuite/test/gdbclientutils.py === --- lldb/packages/Python/lldbsuite/test/gdbclientutils.py +++ lldb/packages/Python/lldbsuite/test/gdbclientutils.py @@ -461,18 +461,16 @@ _receivedDataOffset = None _shouldSendAck = True -def __init__(self, socket_class): -self._socket_class = socket_class +def __init__(self, socket): +self._socket = socket self.responder = MockGDBServerResponder() def start(self): -self._socket = self._socket_class() # Start a thread that waits for a client connection. -self._thread = threading.Thread(target=self._run) +self._thread = threading.Thread(target=self.run) self._thread.start() def stop(self): -self._socket.close_server() self._thread.join() self._thread = None @@ -482,7 +480,7 @@ def get_connect_url(self): return self._socket.get_connect_url() -def _run(self): +def run(self): # For testing purposes, we only need to worry about one client # connecting just one time. try: Index: lldb/packages/Python/lldbsuite/test/lldbgdbclient.py === --- lldb/packages/Python/lldbsuite/test/lldbgdbclient.py +++ lldb/packages/Python/lldbsuite/test/lldbgdbclient.py @@ -19,7 +19,7 @@ def setUp(self): TestBase.setUp(self) -self.server = MockGDBServer(socket_class=self.server_socket_class) +self.server = MockGDBServer(self.server_socket_class()) self.server.start() def tearDown(self): Index: lldb/packages/Python/lldbsuite/test/gdbclientutils.py === --- lldb/packages/Python/lldbsuite/test/gdbclientutils.py +++ lldb/packages/Python/lldbsuite/test/gdbclientutils.py @@ -461,18 +461,16 @@ _receivedDataOffset = None _shouldSendAck = True -def __init__(self, socket_class): -self._socket_class = socket_class +def __init__(self, socket): +self._socket = socket self.responder = MockGDBServerResponder() def start(self): -self._socket = self._socket_class() # Start a thread that waits for a client connection. -self._thread = threading.Thread(target=self._run) +self._thread = threading.Thread(target=self.run) self._thread.start() def stop(self): -self._socket.close_server() self._thread.join() self._thread = None @@ -482,7 +480,7 @@ def get_connect_url(self): return self._socket.get_connect_url() -def _run(self): +def run(self): # For testing purposes, we only need to worry about one client # connecting just one time. try: ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7c8ae65 - [lldb/test] Make it possible to run the mock gdb server on a single thread
Author: Pavel Labath Date: 2021-11-22T15:14:50+01:00 New Revision: 7c8ae65f2c3d5c1a6aba2f7ee7588f9f76f94f84 URL: https://github.com/llvm/llvm-project/commit/7c8ae65f2c3d5c1a6aba2f7ee7588f9f76f94f84 DIFF: https://github.com/llvm/llvm-project/commit/7c8ae65f2c3d5c1a6aba2f7ee7588f9f76f94f84.diff LOG: [lldb/test] Make it possible to run the mock gdb server on a single thread This is a preparatory commit to enable mocking of qemu startup. That will involve running the mock server in a separate process, so there's no need for multithreading. Initialization is moved from the start function into the constructor (which can then take an actual socket instead of a class), and the run method is made public. Depends on D114156. Differential Revision: https://reviews.llvm.org/D114157 Added: Modified: lldb/packages/Python/lldbsuite/test/gdbclientutils.py lldb/packages/Python/lldbsuite/test/lldbgdbclient.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py index 7fdf18e38b385..6b4650eda0735 100644 --- a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py +++ b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py @@ -461,18 +461,16 @@ class MockGDBServer: _receivedDataOffset = None _shouldSendAck = True -def __init__(self, socket_class): -self._socket_class = socket_class +def __init__(self, socket): +self._socket = socket self.responder = MockGDBServerResponder() def start(self): -self._socket = self._socket_class() # Start a thread that waits for a client connection. -self._thread = threading.Thread(target=self._run) +self._thread = threading.Thread(target=self.run) self._thread.start() def stop(self): -self._socket.close_server() self._thread.join() self._thread = None @@ -482,7 +480,7 @@ def get_connect_address(self): def get_connect_url(self): return self._socket.get_connect_url() -def _run(self): +def run(self): # For testing purposes, we only need to worry about one client # connecting just one time. try: diff --git a/lldb/packages/Python/lldbsuite/test/lldbgdbclient.py b/lldb/packages/Python/lldbsuite/test/lldbgdbclient.py index 28ccb1db95583..dd5b044dfc4d9 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbgdbclient.py +++ b/lldb/packages/Python/lldbsuite/test/lldbgdbclient.py @@ -19,7 +19,7 @@ class GDBRemoteTestBase(TestBase): def setUp(self): TestBase.setUp(self) -self.server = MockGDBServer(socket_class=self.server_socket_class) +self.server = MockGDBServer(self.server_socket_class()) self.server.start() def tearDown(self): ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7f09ab0 - [lldb] Fix [some] leaks in python bindings
Author: Pavel Labath Date: 2021-11-22T15:14:52+01:00 New Revision: 7f09ab08de5ae8f8bd77f5c02c70b991277eb1ae URL: https://github.com/llvm/llvm-project/commit/7f09ab08de5ae8f8bd77f5c02c70b991277eb1ae DIFF: https://github.com/llvm/llvm-project/commit/7f09ab08de5ae8f8bd77f5c02c70b991277eb1ae.diff LOG: [lldb] Fix [some] leaks in python bindings Using an lldb_private object in the bindings involves three steps - wrapping the object in it's lldb::SB variant - using swig to convert/wrap that to a PyObject - wrapping *that* in a lldb_private::python::PythonObject Our SBTypeToSWIGWrapper was only handling the middle part. This doesn't just result in increased boilerplate in the callers, but is also a functionality problem, as it's very hard to get the lifetime of of all of these objects right. Most of the callers are creating the SB object (step 1) on the stack, which means that we end up with dangling python objects after the function terminates. Most of the time this isn't a problem, because the python code does not need to persist the objects. However, there are legitimate cases where they can do it (and even if the use case is not completely legitimate, crashing is not the best response to that). For this reason, some of our code creates the SB object on the heap, but it has another problem -- it never gets cleaned up. This patch begins to add a new function (ToSWIGWrapper), which does all of the three steps, while properly taking care of ownership. In the first step, I have converted most of the leaky code (except for SBStructuredData, which needs a bit more work). Differential Revision: https://reviews.llvm.org/D114259 Added: Modified: lldb/bindings/python/python-swigsafecast.swig lldb/bindings/python/python-wrapper.swig lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp Removed: diff --git a/lldb/bindings/python/python-swigsafecast.swig b/lldb/bindings/python/python-swigsafecast.swig index aa2bcfb8c8ae9..fdd3b4e62c102 100644 --- a/lldb/bindings/python/python-swigsafecast.swig +++ b/lldb/bindings/python/python-swigsafecast.swig @@ -1,23 +1,14 @@ +namespace lldb_private { +namespace python { + PyObject *SBTypeToSWIGWrapper(lldb::SBEvent &event_sb) { return SWIG_NewPointerObj(&event_sb, SWIGTYPE_p_lldb__SBEvent, 0); } -PyObject *SBTypeToSWIGWrapper(lldb::SBProcess &process_sb) { - return SWIG_NewPointerObj(&process_sb, SWIGTYPE_p_lldb__SBProcess, 0); -} - PyObject *SBTypeToSWIGWrapper(lldb::SBThread &thread_sb) { return SWIG_NewPointerObj(&thread_sb, SWIGTYPE_p_lldb__SBThread, 0); } -PyObject *SBTypeToSWIGWrapper(lldb::SBThreadPlan &thread_plan_sb) { - return SWIG_NewPointerObj(&thread_plan_sb, SWIGTYPE_p_lldb__SBThreadPlan, 0); -} - -PyObject *SBTypeToSWIGWrapper(lldb::SBTarget &target_sb) { - return SWIG_NewPointerObj(&target_sb, SWIGTYPE_p_lldb__SBTarget, 0); -} - PyObject *SBTypeToSWIGWrapper(lldb::SBFrame &frame_sb) { return SWIG_NewPointerObj(&frame_sb, SWIGTYPE_p_lldb__SBFrame, 0); } @@ -26,10 +17,6 @@ PyObject *SBTypeToSWIGWrapper(lldb::SBDebugger &debugger_sb) { return SWIG_NewPointerObj(&debugger_sb, SWIGTYPE_p_lldb__SBDebugger, 0); } -PyObject *SBTypeToSWIGWrapper(lldb::SBBreakpoint &breakpoint_sb) { - return SWIG_NewPointerObj(&breakpoint_sb, SWIGTYPE_p_lldb__SBBreakpoint, 0); -} - PyObject *SBTypeToSWIGWrapper(lldb::SBWatchpoint &watchpoint_sb) { return SWIG_NewPointerObj(&watchpoint_sb, SWIGTYPE_p_lldb__SBWatchpoint, 0); } @@ -40,10 +27,6 @@ SBTypeToSWIGWrapper(lldb::SBBreakpointLocation &breakpoint_location_sb) { SWIGTYPE_p_lldb__SBBreakpointLocation, 0); } -PyObject *SBTypeToSWIGWrapper(lldb::SBValue &value_sb) { - return SWIG_NewPointerObj(&value_sb, SWIGTYPE_p_lldb__SBValue, 0); -} - PyObject *SBTypeToSWIGWrapper(lldb::SBCommandReturnObject &cmd_ret_obj_sb) { return SWIG_NewPointerObj(&cmd_ret_obj_sb, SWIGTYPE_p_lldb__SBCommandReturnObject, 0); @@ -70,3 +53,38 @@ PyObject *SBTypeToSWIGWrapper(lldb::SBSymbolContext &sym_ctx_sb) { PyObject *SBTypeToSWIGWrapper(lldb::SBStream &stream_sb) { return SWIG_NewPointerObj(&stream_sb, SWIGTYPE_p_lldb__SBStream, 0); } + +PythonObject ToSWIGHelper(void *obj, swig_type_info *info) { + return {PyRefType::Owned, SWIG_NewPointerObj(obj, info, SWIG_POINTER_OWN)}; +} + +PythonObject ToSWIGWrapper(std::unique_ptr value_sb) { + return ToSWIGHelper(value_sb.release(), SWIGTYPE_p_lldb__SBValue); +} + +PythonObject ToSWIGWrapper(lldb::ValueObjectSP value_sp) { + return ToSWIGWrapper(std::make_unique(std::move(value_sp))); +} + +PythonObject ToSWIGWrapper(lldb::TargetSP target_sp) { + return ToSWIGHelper(new lldb::SBTarget(std::move(target_sp)), + SWIGTYPE_p_lldb__SBTarget); +} + +PythonObject ToSWIGWrapper(lldb::ProcessSP process_sp
[Lldb-commits] [PATCH] D114259: [lldb] Fix [some] leaks in python bindings
This revision was automatically updated to reflect the committed changes. Closed by commit rG7f09ab08de5a: [lldb] Fix [some] leaks in python bindings (authored by labath). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114259/new/ https://reviews.llvm.org/D114259 Files: lldb/bindings/python/python-swigsafecast.swig lldb/bindings/python/python-wrapper.swig lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp === --- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp +++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp @@ -129,7 +129,7 @@ extern "C" void *LLDBSwigPythonCreateScriptedBreakpointResolver( const char *python_class_name, const char *session_dictionary_name, -lldb_private::StructuredDataImpl *args, lldb::BreakpointSP &bkpt_sp) { +lldb_private::StructuredDataImpl *args, const lldb::BreakpointSP &bkpt_sp) { return nullptr; } @@ -248,7 +248,7 @@ extern "C" bool LLDBSWIGPythonRunScriptKeywordProcess( const char *python_function_name, const char *session_dictionary_name, -lldb::ProcessSP &process, std::string &output) { +const lldb::ProcessSP &process, std::string &output) { return false; } @@ -260,7 +260,7 @@ extern "C" bool LLDBSWIGPythonRunScriptKeywordTarget( const char *python_function_name, const char *session_dictionary_name, -lldb::TargetSP &target, std::string &output) { +const lldb::TargetSP &target, std::string &output) { return false; } @@ -272,7 +272,7 @@ extern "C" bool LLDBSWIGPythonRunScriptKeywordValue( const char *python_function_name, const char *session_dictionary_name, -lldb::ValueObjectSP &value, std::string &output) { +const lldb::ValueObjectSP &value, std::string &output) { return false; } Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp === --- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -127,7 +127,7 @@ extern "C" void *LLDBSwigPythonCreateScriptedBreakpointResolver( const char *python_class_name, const char *session_dictionary_name, -lldb_private::StructuredDataImpl *args, lldb::BreakpointSP &bkpt_sp); +lldb_private::StructuredDataImpl *args, const lldb::BreakpointSP &bkpt_sp); extern "C" unsigned int LLDBSwigPythonCallBreakpointResolver(void *implementor, const char *method_name, @@ -196,7 +196,7 @@ extern "C" bool LLDBSWIGPythonRunScriptKeywordProcess( const char *python_function_name, const char *session_dictionary_name, -lldb::ProcessSP &process, std::string &output); +const lldb::ProcessSP &process, std::string &output); extern "C" bool LLDBSWIGPythonRunScriptKeywordThread( const char *python_function_name, const char *session_dictionary_name, @@ -204,7 +204,7 @@ extern "C" bool LLDBSWIGPythonRunScriptKeywordTarget( const char *python_function_name, const char *session_dictionary_name, -lldb::TargetSP &target, std::string &output); +const lldb::TargetSP &target, std::string &output); extern "C" bool LLDBSWIGPythonRunScriptKeywordFrame( const char *python_function_name, const char *session_dictionary_name, @@ -212,7 +212,7 @@ extern "C" bool LLDBSWIGPythonRunScriptKeywordValue( const char *python_function_name, const char *session_dictionary_name, -lldb::ValueObjectSP &value, std::string &output); +const lldb::ValueObjectSP &value, std::string &output); extern "C" void * LLDBSWIGPython_GetDynamicSetting(void *module, const char *setting, @@ -2653,11 +2653,11 @@ } { -ProcessSP process_sp(process->shared_from_this()); Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); ret_val = LLDBSWIGPythonRunScriptKeywordProcess( -impl_function, m_dictionary_name.c_str(), process_sp, output); +impl_function, m_dictionary_name.c_str(), process->shared_from_this(), +output); if (!ret_val) error.SetErrorString("python script evaluation failed"); } @@ -2753,11 +2753,10 @@ } { -ValueObjectSP value_sp(value->GetSP()); Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); ret_val = LLDBSWIGPythonRunScriptKeywordValue( -impl_function, m_dictionary_name.c_str(), value_sp, output); +impl_function, m_dictionary_name.c_str(), value->GetSP(), output); if (!ret_val) error.SetErrorString("python script evaluation failed"); } Index: lldb/bindings/python/python-wrapper.swig ===
[Lldb-commits] [PATCH] D114369: [lldb] Remove 'extern "C"' from the lldb-swig-python interface
labath created this revision. labath added reviewers: JDevlieghere, jingham. labath requested review of this revision. Herald added a project: LLDB. The LLDBSWIGPython functions had (at least) two problems: - There wasn't a single source of truth (a header file) for the prototypes of these functions. This meant that subtle differences in copies of function declarations could go by undetected. And not-so-subtle differences would result in strange runtime failures. - All of the declarations had to have an extern "C" interface, because the function definitions were being placed inside and extert "C" block generated by swig. This patch fixes both problems by moving the function definitions to the %header block of the swig files. This block is not surrounded by extern "C", and seems more appropriate anyway, as swig docs say it is meant for "user-defined support code" (whereas the previous %wrapper code was for automatically-generated wrappers). It also puts the declarations into the SWIGPythonBridge header file (which seems to have been created for this purpose), and ensures it is included by all code wishing to define or use these functions. This means that any differences in the declaration become a compiler error instead of a runtime failure. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D114369 Files: lldb/bindings/python/python-wrapper.swig lldb/bindings/python/python.swig lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp === --- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp +++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp @@ -8,10 +8,10 @@ #include "gtest/gtest.h" -#include "Plugins/ScriptInterpreter/Python/lldb-python.h" - +#include "Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h" #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h" #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h" +#include "Plugins/ScriptInterpreter/Python/lldb-python.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" @@ -55,24 +55,11 @@ #if PY_MAJOR_VERSION >= 3 extern "C" PyObject *PyInit__lldb(void) { return nullptr; } -#define LLDBSwigPyInit PyInit__lldb #else extern "C" void init_lldb(void) {} -#define LLDBSwigPyInit init_lldb -#endif - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wreturn-type-c-linkage" - -// Disable warning C4190: 'LLDBSwigPythonBreakpointCallbackFunction' has -// C-linkage specified, but returns UDT 'llvm::Expected' which is -// incompatible with C -#if _MSC_VER -#pragma warning (push) -#pragma warning (disable : 4190) #endif -extern "C" llvm::Expected LLDBSwigPythonBreakpointCallbackFunction( +llvm::Expected lldb_private::LLDBSwigPythonBreakpointCallbackFunction( const char *python_function_name, const char *session_dictionary_name, const lldb::StackFrameSP &sb_frame, const lldb::BreakpointLocationSP &sb_bp_loc, @@ -80,218 +67,205 @@ return false; } -#if _MSC_VER -#pragma warning (pop) -#endif - -#pragma clang diagnostic pop - -extern "C" bool LLDBSwigPythonWatchpointCallbackFunction( +bool lldb_private::LLDBSwigPythonWatchpointCallbackFunction( const char *python_function_name, const char *session_dictionary_name, const lldb::StackFrameSP &sb_frame, const lldb::WatchpointSP &sb_wp) { return false; } -extern "C" bool LLDBSwigPythonCallTypeScript( -const char *python_function_name, void *session_dictionary, +bool lldb_private::LLDBSwigPythonCallTypeScript( +const char *python_function_name, const void *session_dictionary, const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper, const lldb::TypeSummaryOptionsSP &options_sp, std::string &retval) { return false; } -extern "C" void * -LLDBSwigPythonCreateSyntheticProvider(const char *python_class_name, - const char *session_dictionary_name, - const lldb::ValueObjectSP &valobj_sp) { +void *lldb_private::LLDBSwigPythonCreateSyntheticProvider( +const char *python_class_name, const char *session_dictionary_name, +const lldb::ValueObjectSP &valobj_sp) { return nullptr; } -extern "C" void * -LLDBSwigPythonCreateCommandObject(const char *python_class_name, - const char *session_dictionary_name, - const lldb::DebuggerSP debugger_sp) { +void *lldb_private::LLDBSwigPythonCreateCommandObject( +const char *python_class_name, const char *session_dictionary_name, +const lldb::DebuggerSP debugger_sp) { return nullptr; } -extern "C" void *LLDBSwigPythonCreateScriptedThreadPlan( +void *lldb_private::LLDBSwi
[Lldb-commits] [PATCH] D114369: [lldb] Remove 'extern "C"' from the lldb-swig-python interface
labath updated this revision to Diff 388935. labath added a comment. Revert the PyInit_lldb changes. They fail on windows due to declspec(dllexport) mistmatches, and this function is kinda special anyway. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114369/new/ https://reviews.llvm.org/D114369 Files: lldb/bindings/python/python-wrapper.swig lldb/bindings/python/python.swig lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp === --- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp +++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp @@ -8,10 +8,10 @@ #include "gtest/gtest.h" -#include "Plugins/ScriptInterpreter/Python/lldb-python.h" - +#include "Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h" #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h" #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h" +#include "Plugins/ScriptInterpreter/Python/lldb-python.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" @@ -55,24 +55,11 @@ #if PY_MAJOR_VERSION >= 3 extern "C" PyObject *PyInit__lldb(void) { return nullptr; } -#define LLDBSwigPyInit PyInit__lldb #else extern "C" void init_lldb(void) {} -#define LLDBSwigPyInit init_lldb -#endif - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wreturn-type-c-linkage" - -// Disable warning C4190: 'LLDBSwigPythonBreakpointCallbackFunction' has -// C-linkage specified, but returns UDT 'llvm::Expected' which is -// incompatible with C -#if _MSC_VER -#pragma warning (push) -#pragma warning (disable : 4190) #endif -extern "C" llvm::Expected LLDBSwigPythonBreakpointCallbackFunction( +llvm::Expected lldb_private::LLDBSwigPythonBreakpointCallbackFunction( const char *python_function_name, const char *session_dictionary_name, const lldb::StackFrameSP &sb_frame, const lldb::BreakpointLocationSP &sb_bp_loc, @@ -80,218 +67,205 @@ return false; } -#if _MSC_VER -#pragma warning (pop) -#endif - -#pragma clang diagnostic pop - -extern "C" bool LLDBSwigPythonWatchpointCallbackFunction( +bool lldb_private::LLDBSwigPythonWatchpointCallbackFunction( const char *python_function_name, const char *session_dictionary_name, const lldb::StackFrameSP &sb_frame, const lldb::WatchpointSP &sb_wp) { return false; } -extern "C" bool LLDBSwigPythonCallTypeScript( -const char *python_function_name, void *session_dictionary, +bool lldb_private::LLDBSwigPythonCallTypeScript( +const char *python_function_name, const void *session_dictionary, const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper, const lldb::TypeSummaryOptionsSP &options_sp, std::string &retval) { return false; } -extern "C" void * -LLDBSwigPythonCreateSyntheticProvider(const char *python_class_name, - const char *session_dictionary_name, - const lldb::ValueObjectSP &valobj_sp) { +void *lldb_private::LLDBSwigPythonCreateSyntheticProvider( +const char *python_class_name, const char *session_dictionary_name, +const lldb::ValueObjectSP &valobj_sp) { return nullptr; } -extern "C" void * -LLDBSwigPythonCreateCommandObject(const char *python_class_name, - const char *session_dictionary_name, - const lldb::DebuggerSP debugger_sp) { +void *lldb_private::LLDBSwigPythonCreateCommandObject( +const char *python_class_name, const char *session_dictionary_name, +const lldb::DebuggerSP debugger_sp) { return nullptr; } -extern "C" void *LLDBSwigPythonCreateScriptedThreadPlan( +void *lldb_private::LLDBSwigPythonCreateScriptedThreadPlan( const char *python_class_name, const char *session_dictionary_name, -StructuredDataImpl *args_data, -std::string &error_string, +StructuredDataImpl *args_data, std::string &error_string, const lldb::ThreadPlanSP &thread_plan_sp) { return nullptr; } -extern "C" bool LLDBSWIGPythonCallThreadPlan(void *implementor, - const char *method_name, - Event *event_sp, bool &got_error) { +bool lldb_private::LLDBSWIGPythonCallThreadPlan(void *implementor, +const char *method_name, +Event *event_sp, +bool &got_error) { return false; } -extern "C" void *LLDBSwigPythonCreateScriptedBreakpointResolver( +void *lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver( const char *python_class_name,
[Lldb-commits] [PATCH] D112147: [lldb] Fix lookup for global constants in namespaces
tonkosi updated this revision to Diff 388958. tonkosi added a comment. - Use scope context parent DIE instead of the direct parent - Add tests for constants in anonymous namespace Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112147/new/ https://reviews.llvm.org/D112147 Files: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/test/API/lang/cpp/global_variables/TestCPPGlobalVariables.py lldb/test/API/lang/cpp/global_variables/main.cpp Index: lldb/test/API/lang/cpp/global_variables/main.cpp === --- lldb/test/API/lang/cpp/global_variables/main.cpp +++ lldb/test/API/lang/cpp/global_variables/main.cpp @@ -1,10 +1,17 @@ #include namespace abc { - int g_file_global_int = 42; +int g_file_global_int = 42; +const int g_file_global_const_int = 1337; + +namespace { +const int g_anon_namespace_const_int = 100; +} } int main (int argc, char const *argv[]) { -return abc::g_file_global_int; // Set break point at this line. + int unused = abc::g_file_global_const_int; + int unused2 = abc::g_anon_namespace_const_int; + return abc::g_file_global_int; // Set break point at this line. } Index: lldb/test/API/lang/cpp/global_variables/TestCPPGlobalVariables.py === --- lldb/test/API/lang/cpp/global_variables/TestCPPGlobalVariables.py +++ lldb/test/API/lang/cpp/global_variables/TestCPPGlobalVariables.py @@ -15,12 +15,11 @@ TestBase.setUp(self) self.source = lldb.SBFileSpec('main.cpp') -@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") def test(self): self.build() (target, _, _, _) = lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", self.source) - + # Check that we can access g_file_global_int by its name self.expect("target variable g_file_global_int", VARIABLES_DISPLAYED_CORRECTLY, substrs=['42']) @@ -29,6 +28,30 @@ self.expect("target variable xyz::g_file_global_int", VARIABLES_DISPLAYED_CORRECTLY, error=True, substrs=['can\'t find global variable']) +# Check that we can access g_file_global_const_int by its name +self.expect("target variable g_file_global_const_int", VARIABLES_DISPLAYED_CORRECTLY, +substrs=['1337']) +self.expect("target variable abc::g_file_global_const_int", VARIABLES_DISPLAYED_CORRECTLY, +substrs=['1337']) +self.expect("target variable xyz::g_file_global_const_int", VARIABLES_DISPLAYED_CORRECTLY, +error=True, substrs=['can\'t find global variable']) + +# Try accessing a global variable in anonymous namespace. +self.expect("target variable g_anon_namespace_const_int", VARIABLES_DISPLAYED_CORRECTLY, +substrs=['100']) +self.expect("target variable abc::g_anon_namespace_const_int", VARIABLES_DISPLAYED_CORRECTLY, +error=True, substrs=['can\'t find global variable']) +var = target.FindFirstGlobalVariable("abc::(anonymous namespace)::g_anon_namespace_const_int") +self.assertTrue(var.IsValid()) +self.assertEqual(var.GetName(), "abc::(anonymous namespace)::g_anon_namespace_const_int") +self.assertEqual(var.GetValue(), "100") + +@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") +def test_access_by_mangled_name(self): +self.build() + +(target, _, _, _) = lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", self.source) + # Check that we can access g_file_global_int by its mangled name addr = target.EvaluateExpression("&abc::g_file_global_int").GetValueAsUnsigned() self.assertNotEqual(addr, 0) Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp === --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3271,15 +3271,14 @@ } const DWARFDIE parent_context_die = GetDeclContextDIEContainingDIE(die); - const dw_tag_t parent_tag = die.GetParent().Tag(); + const DWARFDIE sc_parent_die = GetParentSymbolContextDIE(die); + const dw_tag_t parent_tag = sc_parent_die.Tag(); bool is_static_member = (parent_tag == DW_TAG_compile_unit || parent_tag == DW_TAG_partial_unit) && (parent_context_die.Tag() == DW_TAG_class_type || parent_context_die.Tag() == DW_TAG_structure_type); ValueType scope = eValueTypeInvalid; - - const DWARFDIE sc_parent_die = GetParentSymbolContextDIE(die); SymbolContextScope *symbol_context_scope = nullptr; bool has_explicit_mangled = mangled != nullptr; Index: lldb/test/API/lang/cp
[Lldb-commits] [PATCH] D112147: [lldb] Fix lookup for global constants in namespaces
tonkosi added inline comments. Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:3281-3282 if ((parent_tag == DW_TAG_compile_unit || - parent_tag == DW_TAG_partial_unit) && + parent_tag == DW_TAG_partial_unit || + parent_tag == DW_TAG_namespace) && Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU( shafik wrote: > clayborg wrote: > > tonkosi wrote: > > > clayborg wrote: > > > > I think we should just always call this function in regardless of what > > > > the parent variable tag is since what happens if the parent tag is > > > > another value decl context like DW_TAG_class_type, > > > > DW_TAG_structure_type? > > > > > > > > The call to GetDWARFDeclContext(die) below will calculate the > > > > DWARFDeclContext for a DIE and then construct an appropriate qualified > > > > name, so we can just always do this so I would suggest just making this: > > > > > > > > ``` > > > > if (Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU( > > > > mangled = > > > > GetDWARFDeclContext(die).GetQualifiedNameAsConstString().GetCString(); > > > > ``` > > > > Then we should always get this right all the time. It doesn't actually > > > > make sense to call this if the parent is the DW_TAG_compile_unit or > > > > DW_TAG_partial_unit because then there is no decl context to add to the > > > > variable name. > > > I tried to call `GetDWARFDeclContext(die)` in a general case, but it > > > seems that `GetQualifiedName` will append `::` > > > ([source](https://github.com/llvm/llvm-project/blob/5015f250894d3d97917d858850fae7960923a4ae/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp#L22)) > > > in front of the variable name if there's no other declaration context. > > > > > > As a result, LLDB will display local variables and function arguments as > > > `::var`. Any suggestion to deal with that? > > > > > > I also noticed that with the current change it would be possible to get > > > variables in anonymous namespaces, e.g. for the following source > > > > > > ``` > > > namespace ns { > > > namespace { > > > const int var = 1; > > > } > > > } > > > ``` > > > > > > call to `SBTarget::FindGlobalVariables("ns::(anonymous namespace)::var")` > > > will succeed. Is that OK? > > GetQualifiedNameAsConstString could take an extra argument that specifies > > if we should prepend the "::" to the root namespace. > > > > I am fine with a lookup of "ns::(anonymous namespace)::var" succeeding. > You should document the anonymous namespace case in a test. Seems that prepended `::` was not the only issue, local variables and arguments that were part of functions in a namespace were also formatted as `ns::local_var`. So my conclusion was that this check shouldn't be performed for local scope anyway. I noticed there's a variable `sc_parent_die` which gives the first parent that is one of these: `DW_TAG_compile_unit`, `DW_TAG_partial_unit`, `DW_TAG_subprogram`, `DW_TAG_inline_subroutine`, `DW_TAG_lexical_block`. Since the last three probably refer to local scope, I thought it would make sense to check compile/partial unit for global scope (could it be that `sc_parent_die` was meant to be used originally instead of the direct parent?). I updated the diff by setting `parent_tag` to `sc_parent_die.Tag()` instead of `die.GetParent().Tag()`. That fixed the issue with global constants in namespace and didn't cause other issues when running `ninja check-lldb`. Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:3281-3282 if ((parent_tag == DW_TAG_compile_unit || - parent_tag == DW_TAG_partial_unit) && + parent_tag == DW_TAG_partial_unit || + parent_tag == DW_TAG_namespace) && Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU( tonkosi wrote: > shafik wrote: > > clayborg wrote: > > > tonkosi wrote: > > > > clayborg wrote: > > > > > I think we should just always call this function in regardless of > > > > > what the parent variable tag is since what happens if the parent tag > > > > > is another value decl context like DW_TAG_class_type, > > > > > DW_TAG_structure_type? > > > > > > > > > > The call to GetDWARFDeclContext(die) below will calculate the > > > > > DWARFDeclContext for a DIE and then construct an appropriate > > > > > qualified name, so we can just always do this so I would suggest just > > > > > making this: > > > > > > > > > > ``` > > > > > if (Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU( > > > > > mangled = > > > > > GetDWARFDeclContext(die).GetQualifiedNameAsConstString().GetCString(); > > > > > ``` > > > > > Then we should always get this right all the time. It doesn't > > > > > actually make sense to call this if the parent is the > > > > > DW_TAG_compile_unit or DW_TAG_partial_unit because then there is no > > > > > decl context to add to the variable name. > > > > I trie
[Lldb-commits] [PATCH] D112147: [lldb] Fix lookup for global constants in namespaces
clayborg accepted this revision. clayborg added a comment. This revision is now accepted and ready to land. LGTM! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112147/new/ https://reviews.llvm.org/D112147 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 2e6a0a8 - [lldb] Load the fblldb module automatically
Author: Walter Erquinigo Date: 2021-11-22T13:08:36-08:00 New Revision: 2e6a0a8b81d7be948491ce39d241695dc1385429 URL: https://github.com/llvm/llvm-project/commit/2e6a0a8b81d7be948491ce39d241695dc1385429 DIFF: https://github.com/llvm/llvm-project/commit/2e6a0a8b81d7be948491ce39d241695dc1385429.diff LOG: [lldb] Load the fblldb module automatically Summary: ``` // Facebook only: // We want to load automatically the fblldb python module as soon as lldb or // lldb-vscode start. This will ensure that logging and formatters are enabled // by default. // // As we want to have a mechanism for not triggering this by default, if the // user is starting lldb disabling .lldbinit support, then we also don't load // this module. This is equivalent to appending this line to all .lldbinit // files. // // We don't have the fblldb module on windows, so we don't include it for that // build. ``` Test Plan: the fbsymbols module is loaded automatically ``` ./bin/lldb (lldb) help fbsymbols Facebook {mini,core}dump utility. Expects 'raw' input (see 'help raw-input'.) ``` Reviewers: wanyi Reviewed By: wanyi Subscribers: mnovakovic, serhiyr, phabricatorlinter Differential Revision: https://phabricator.intern.facebook.com/D29372804 Tags: accept2ship Signature: 29372804:1624567770:07836e50e576bd809124ed80a6bc01082190e48f [lldb] Load fblldbinit instead of fblldb Summary: Once accepted, it'll merge it with the existing commit in our branch so that we keep the commit list as short as possible. Test Plan: https://www.internalfb.com/diff/D30293094 Reviewers: aadsm, wanyi Reviewed By: aadsm Subscribers: mnovakovic, serhiyr Differential Revision: https://phabricator.intern.facebook.com/D30293211 Tags: accept2ship Signature: 30293211:1628880953:423e2e543cade107df69da0ebf458e581e54ae3a Added: Modified: lldb/source/Interpreter/CommandInterpreter.cpp Removed: diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 301bf949feef4..1df74f9656357 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -2352,6 +2352,20 @@ void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result, result.SetStatus(eReturnStatusSuccessFinishNoResult); return; } +#if !defined(_WIN32) + // Facebook only: + // + // The 'fblldbinit' module will set up the python support specific to FB. + // + // As we want to have a mechanism for not triggering this by default, if the + // user is starting lldb disabling .lldbinit support, then we also don't load + // this module. This is equivalent to preppending the following line to all + // .lldbinit files. + // + // We don't have the fblldbinit module on windows, so we don't include it for + // that build. + HandleCommand("script import fblldbinit", eLazyBoolNo, result); +#endif llvm::SmallString<128> init_file; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] fcd288b - [formatters] Add a libstdcpp formatter for for unordered_map, unordered_set, unordered_multimap, unordered_multiset
Author: Danil Stefaniuc Date: 2021-11-22T13:08:36-08:00 New Revision: fcd288b52aa708e061ad633c8efa1183a7e6b926 URL: https://github.com/llvm/llvm-project/commit/fcd288b52aa708e061ad633c8efa1183a7e6b926 DIFF: https://github.com/llvm/llvm-project/commit/fcd288b52aa708e061ad633c8efa1183a7e6b926.diff LOG: [formatters] Add a libstdcpp formatter for for unordered_map, unordered_set, unordered_multimap, unordered_multiset This diff adds a data formatter and tests for libstdcpp's unordered_map, unordered_set, unordered_multimap, unordered_multiset Reviewed By: wallace Differential Revision: https://reviews.llvm.org/D113760 Added: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp Modified: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Removed: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp diff --git a/lldb/examples/synthetic/gnu_libstdcpp.py b/lldb/examples/synthetic/gnu_libstdcpp.py index a5b24273489f2..9272b814f78d8 100644 --- a/lldb/examples/synthetic/gnu_libstdcpp.py +++ b/lldb/examples/synthetic/gnu_libstdcpp.py @@ -9,6 +9,86 @@ # before relying on these formatters to do the right thing for your setup +""" + This formatter can be applied to all + unordered map-like structures (unordered_map, unordered_multimap, unordered_set, unordered_multiset) +""" +class StdUnorderedMapSynthProvider: +def __init__(self, valobj, dict): +self.valobj = valobj +self.count = None +self.kind = self.get_object_kind(valobj) + +def get_object_kind(self, valobj): +type_name = valobj.GetTypeName() +return "set" if "set" in type_name else "map" + +def extract_type(self): +type = self.valobj.GetType() +# type of std::pair is the first template +# argument type of the 4th template argument to std::map and +# 3rd template argument for std::set. That's why +# we need to know kind of the object +template_arg_num = 4 if self.kind == "map" else 3 +allocator_type = type.GetTemplateArgumentType(template_arg_num) +data_type = allocator_type.GetTemplateArgumentType(0) +return data_type + +def update(self): +# preemptively setting this to None - we might end up changing our mind +# later +self.count = None +try: +self.head = self.valobj.GetChildMemberWithName('_M_h') +self.before_begin = self.head.GetChildMemberWithName('_M_before_begin') +self.next = self.before_begin.GetChildMemberWithName('_M_nxt') +self.data_type = self.extract_type() +self.skip_size = self.next.GetType().GetByteSize() +self.data_size = self.data_type.GetByteSize() +except: +pass +return False + +def get_child_index(self, name): +try: +return int(name.lstrip('[').rstrip(']')) +except: +return -1 + +def get_child_at_index(self, index): +logger = lldb.formatters.Logger.Logger() +logger >> "Being asked to fetch child[" + str(index) + "]" +if index < 0: +return None +if index >= self.num_children(): +return None +try: +offset = index +current = self.next +while offset > 0: +current = current.GetChildMemberWithName('_M_nxt') +offset = offset - 1 +return current.CreateChildAtOffset( '[' + str(index) + ']', self.skip_size, self.data_type) + +except: +logger >> "Cannot get child" +return None + +def num_children(self): +if self.count is None: +self.count = self.num_children_impl() +return self.count + +def num_children_impl(self): +logger = lldb.formatters.Logger.Logger() +try: +count = self.head.GetChildMemberWithName('_M_element_count').GetValueAsUnsigned(0) +return count +except: +logger >> "Could not determine the size" +return 0 + + class AbstractListSynthProvider: def __init__(self, valobj, dict, has_prev): ''' diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 83e8e52b86f26..3182294abd44
[Lldb-commits] [PATCH] D113760: [formatters] Add a libstdcpp formatter for for unordered_map, unordered_set, unordered_multimap, unordered_multiset
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGfcd288b52aa7: [formatters] Add a libstdcpp formatter for for unordered_map, unordered_set… (authored by danilashtefan, committed by Walter Erquinigo). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113760/new/ https://reviews.llvm.org/D113760 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include - -using std::string; - -#define intstr_map std::unordered_map -#define intstr_mmap std::unordered_multimap - -#define int_set std::unordered_set -#define str_set std::unordered_set -#define int_mset std::unordered_multiset -#define str_mset std::unordered_multiset - -int g_the_foo = 0; - -int thefoo_rw(int arg = 1) -{ - if (arg < 0) - arg = 0; - if (!arg) - arg = 1; - g_the_foo += arg; - return g_the_foo; -} - -int main() -{ - intstr_map map; - map.emplace(1,"hello"); - map.emplace(2,"world"); - map.emplace(3,"this"); - map.emplace(4,"is"); - map.emplace(5,"me"); - thefoo_rw(); // Set break point at this line. - - intstr_mmap mmap; - mmap.emplace(1,"hello"); - mmap.emplace(2,"hello"); - mmap.emplace(2,"world"); - mmap.emplace(3,"this"); - mmap.emplace(3,"this"); - mmap.emplace(3,"this"); - thefoo_rw(); // Set break point at this line. - - int_set iset; - iset.emplace(1); - iset.emplace(2); - iset.emplace(3); - iset.emplace(4); - iset.emplace(5); - thefoo_rw(); // Set break point at this line. - - str_set sset; - sset.emplace("hello"); - sset.emplace("world"); - sset.emplace("this"); - sset.emplace("is"); - sset.emplace("me"); - thefoo_rw(); // Set break point at this line. - - int_mset imset; - imset.emplace(1); - imset.emplace(2); - imset.emplace(2); - imset.emplace(3); - imset.emplace(3); - imset.emplace(3); - thefoo_rw(); // Set break point at this line. - - str_mset smset; - smset.emplace("hello"); - smset.emplace("world"); - smset.emplace("world"); - smset.emplace("is"); - smset.emplace("is"); - thefoo_rw(); // Set break point at this line. - -return 0; -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -CXX_SOURCES := main.cpp - -# Work around "exception specification in declaration does not match previous -# declaration" errors present in older libc++ releases. This error was fixed in -# the 3.8 release. -CFLAGS_EXTRAS := -fno-exceptions - -USE_LIBCPP := 1 -include Makefile.rules Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp @@ -0,0 +1,68 @@ +#include +#include +#include + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +int main() { + std::unordered_map map; + map.emplace(1, "hello"); + map.emplace(2, "world"); + map.emplace(3, "this"); + map.emplace(4, "is"); + map.emplace(5, "me"); + thefoo_rw(); // Set break point at this line. + + std::unordered_multimap mmap; + mmap.emplace(1, "hello"); + mmap.emplace(2, "hello"); + mmap.emplace(2, "world"); + mmap.emplace(3, "this"); + mmap.emplace(3, "this"); + mmap.emplace(3, "this"); + thefoo_rw(); // Set break point at this line. + + std::unordered_set iset; + iset.emplace(1); + iset.emplace(2); + iset.emplace(3); + iset.emplace(4); + iset.emplace(5); + thefoo_rw(); // Set break point at this line. + + std::unordered_set sset; + sset.emplace("hello"); + sset.emplace("world"); + sset.emplace("this"); + sset.emplace("is"); + sset.emplace("me"); + thefoo_rw
[Lldb-commits] [lldb] 91f78eb - Revert "[lldb] Load the fblldb module automatically"
Author: Walter Erquinigo Date: 2021-11-22T13:13:43-08:00 New Revision: 91f78eb5cf93e80a0e9679b98bca81291e97e1e1 URL: https://github.com/llvm/llvm-project/commit/91f78eb5cf93e80a0e9679b98bca81291e97e1e1 DIFF: https://github.com/llvm/llvm-project/commit/91f78eb5cf93e80a0e9679b98bca81291e97e1e1.diff LOG: Revert "[lldb] Load the fblldb module automatically" This reverts commit 2e6a0a8b81d7be948491ce39d241695dc1385429. It was pushed by mistake.. Added: Modified: lldb/source/Interpreter/CommandInterpreter.cpp Removed: diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 1df74f9656357..301bf949feef4 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -2352,20 +2352,6 @@ void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result, result.SetStatus(eReturnStatusSuccessFinishNoResult); return; } -#if !defined(_WIN32) - // Facebook only: - // - // The 'fblldbinit' module will set up the python support specific to FB. - // - // As we want to have a mechanism for not triggering this by default, if the - // user is starting lldb disabling .lldbinit support, then we also don't load - // this module. This is equivalent to preppending the following line to all - // .lldbinit files. - // - // We don't have the fblldbinit module on windows, so we don't include it for - // that build. - HandleCommand("script import fblldbinit", eLazyBoolNo, result); -#endif llvm::SmallString<128> init_file; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D111409: proposed support for Java interface to Scripting Bridge
d-millar updated this revision to Diff 389021. d-millar added a comment. minor fixes re unnecessary requirement and ConstString->StringRef Repository: rLLDB LLDB CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111409/new/ https://reviews.llvm.org/D111409 Files: lldb/CMakeLists.txt lldb/bindings/CMakeLists.txt lldb/bindings/java/CMakeLists.txt lldb/bindings/java/SWIG/LldbScriptInterpreter.java lldb/bindings/java/java-typemaps.swig lldb/bindings/java/java-wrapper.swig lldb/bindings/java/java.swig lldb/cmake/modules/FindJavaAndSwig.cmake lldb/cmake/modules/LLDBConfig.cmake lldb/docs/resources/build.rst lldb/include/lldb/Core/IOHandler.h lldb/include/lldb/Host/Config.h.cmake lldb/include/lldb/lldb-enumerations.h lldb/source/API/CMakeLists.txt lldb/source/API/SBDebugger.cpp lldb/source/API/liblldb-private.exports lldb/source/API/liblldb.exports lldb/source/Commands/CommandObjectBreakpointCommand.cpp lldb/source/Commands/CommandObjectScript.cpp lldb/source/Commands/CommandObjectWatchpointCommand.cpp lldb/source/Interpreter/OptionArgParser.cpp lldb/source/Interpreter/ScriptInterpreter.cpp lldb/source/Plugins/ScriptInterpreter/CMakeLists.txt lldb/source/Plugins/ScriptInterpreter/Java/CMakeLists.txt lldb/source/Plugins/ScriptInterpreter/Java/Java.cpp lldb/source/Plugins/ScriptInterpreter/Java/Java.h lldb/source/Plugins/ScriptInterpreter/Java/ScriptInterpreterJava.cpp lldb/source/Plugins/ScriptInterpreter/Java/ScriptInterpreterJava.h lldb/test/CMakeLists.txt lldb/test/Shell/ScriptInterpreter/Java/Inputs/independent_state.in lldb/test/Shell/ScriptInterpreter/Java/Inputs/nested_sessions.in lldb/test/Shell/ScriptInterpreter/Java/Inputs/nested_sessions_2.in lldb/test/Shell/ScriptInterpreter/Java/Inputs/testmodule.java lldb/test/Shell/ScriptInterpreter/Java/bindings.test lldb/test/Shell/ScriptInterpreter/Java/breakpoint_callback.test lldb/test/Shell/ScriptInterpreter/Java/breakpoint_function_callback.test lldb/test/Shell/ScriptInterpreter/Java/breakpoint_oneline_callback.test lldb/test/Shell/ScriptInterpreter/Java/command_script_import.test lldb/test/Shell/ScriptInterpreter/Java/convenience_variables.test lldb/test/Shell/ScriptInterpreter/Java/fail_breakpoint_oneline.test lldb/test/Shell/ScriptInterpreter/Java/independent_state.test lldb/test/Shell/ScriptInterpreter/Java/io.test lldb/test/Shell/ScriptInterpreter/Java/java-python.test lldb/test/Shell/ScriptInterpreter/Java/java.test lldb/test/Shell/ScriptInterpreter/Java/lit.local.cfg lldb/test/Shell/ScriptInterpreter/Java/nested_sessions.test lldb/test/Shell/ScriptInterpreter/Java/partial_statements.test lldb/test/Shell/ScriptInterpreter/Java/persistent_state.test lldb/test/Shell/ScriptInterpreter/Java/print.test lldb/test/Shell/ScriptInterpreter/Java/quit.test lldb/test/Shell/ScriptInterpreter/Java/watchpoint_callback.test lldb/test/Shell/lit.cfg.py lldb/test/Shell/lit.site.cfg.py.in lldb/test/Unit/lit.cfg.py lldb/unittests/ScriptInterpreter/CMakeLists.txt lldb/unittests/ScriptInterpreter/Java/CMakeLists.txt lldb/unittests/ScriptInterpreter/Java/JavaTests.cpp lldb/unittests/ScriptInterpreter/Java/ScriptInterpreterTests.cpp Index: lldb/unittests/ScriptInterpreter/Java/ScriptInterpreterTests.cpp === --- /dev/null +++ lldb/unittests/ScriptInterpreter/Java/ScriptInterpreterTests.cpp @@ -0,0 +1,59 @@ +//===-- JavaTests.cpp --===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "Plugins/Platform/Linux/PlatformLinux.h" +#include "Plugins/ScriptInterpreter/Java/ScriptInterpreterJava.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Target/Platform.h" +#include "lldb/Utility/Reproducer.h" +#include "gtest/gtest.h" + +using namespace lldb_private; +using namespace lldb_private::repro; +using namespace lldb; + +namespace { +class ScriptInterpreterTest : public ::testing::Test { +public: + void SetUp() override { +llvm::cantFail(Reproducer::Initialize(ReproducerMode::Off, llvm::None)); +FileSystem::Initialize(); +HostInfo::Initialize(); + +// Pretend Linux is the host platform. +platform_linux::PlatformLinux::Initialize(); +ArchSpec arch("powerpc64-pc-linux"); +Platform::SetHostPlatform( +platform_linux::PlatformLinux::CreateInstance(true, &arch)); + } + void TearDown() override { +platform_linux::PlatformLinux::Terminate(); +HostInfo::Terminate(); +FileSystem::Terminate(); +Reproducer::Terminate(); + } +}; +} /
[Lldb-commits] [PATCH] D114403: [formatters] Add a formatter for libstdc++ optional
wallace created this revision. wallace requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Besides adding the formatter and the summary, this makes the libcxx tests also work for this case. This is the polished version of https://reviews.llvm.org/D114266, authored by Danil Stefaniuc. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D114403 Files: lldb/bindings/interface/SBValue.i lldb/examples/synthetic/gnu_libstdcpp.py lldb/include/lldb/API/SBValue.h lldb/source/API/SBValue.cpp lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/TestDataFormatterLibcxxOptional.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/main.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -#include - -// If we have libc++ 4.0 or greater we should have -// According to libc++ C++1z status page https://libcxx.llvm.org/cxx1z_status.html -#if _LIBCPP_VERSION >= 4000 -#include -#define HAVE_OPTIONAL 1 -#else -#define HAVE_OPTIONAL 0 -#endif - - -int main() -{ -bool has_optional = HAVE_OPTIONAL ; - -printf( "%d\n", has_optional ) ; // break here - -#if HAVE_OPTIONAL == 1 -using int_vect = std::vector ; -using optional_int = std::optional ; -using optional_int_vect = std::optional ; -using optional_string = std::optional ; - -optional_int number_not_engaged ; -optional_int number_engaged = 42 ; - -printf( "%d\n", *number_engaged) ; - -optional_int_vect numbers{{1,2,3,4}} ; - -printf( "%d %d\n", numbers.value()[0], numbers.value()[1] ) ; - -optional_string ostring = "hello" ; - -printf( "%s\n", ostring->c_str() ) ; -#endif - -return 0; // break here -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/main.cpp @@ -0,0 +1,41 @@ +#include +#include +#include + +// If we have libc++ 4.0 or greater we should have +// According to libc++ C++1z status page +// https://libcxx.llvm.org/cxx1z_status.html +#if !defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 4000 +#include +#define HAVE_OPTIONAL 1 +#else +#define HAVE_OPTIONAL 0 +#endif + +int main() { + bool has_optional = HAVE_OPTIONAL; + + printf("%d\n", has_optional); // break here + +#if HAVE_OPTIONAL == 1 + using int_vect = std::vector; + using optional_int = std::optional; + using optional_int_vect = std::optional; + using optional_string = std::optional; + + optional_int number_not_engaged; + optional_int number_engaged = 42; + + printf("%d\n", *number_engaged); + + optional_int_vect numbers{{1, 2, 3, 4}}; + + printf("%d %d\n", numbers.value()[0], numbers.value()[1]); + + optional_string ostring = "hello"; + + printf("%s\n", ostring->c_str()); +#endif + + return 0; // break here +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py @@ -1,29 +1,18 @@ -""" -Test lldb data formatter subsystem. -""" - - - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" -class LibcxxOptionalDataFormatterTestCase(TestBase): +class GenericOptionalDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) -@add_test_categories(["libc++"]) -## Clang 7.0 is the oldest Clang that can reliably parse newer libc++ versions -## with -std=c++17. -@skipIf(oslist=no_match(["macosx"]), compiler="clang", compiler_version=['<', '7.0']) -## We are skipping gcc version less that 5.1 since this test requires -std=c++17 -@skipIf(compiler="gcc", compiler_version=['<', '5.1']) - -def test_with_run_command(self): +def
[Lldb-commits] [PATCH] D114403: [formatters] Add a formatter for libstdc++ optional
wallace updated this revision to Diff 389058. wallace added a comment. nit Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114403/new/ https://reviews.llvm.org/D114403 Files: lldb/bindings/interface/SBValue.i lldb/examples/synthetic/gnu_libstdcpp.py lldb/include/lldb/API/SBValue.h lldb/source/API/SBValue.cpp lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/TestDataFormatterLibcxxOptional.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/main.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -#include - -// If we have libc++ 4.0 or greater we should have -// According to libc++ C++1z status page https://libcxx.llvm.org/cxx1z_status.html -#if _LIBCPP_VERSION >= 4000 -#include -#define HAVE_OPTIONAL 1 -#else -#define HAVE_OPTIONAL 0 -#endif - - -int main() -{ -bool has_optional = HAVE_OPTIONAL ; - -printf( "%d\n", has_optional ) ; // break here - -#if HAVE_OPTIONAL == 1 -using int_vect = std::vector ; -using optional_int = std::optional ; -using optional_int_vect = std::optional ; -using optional_string = std::optional ; - -optional_int number_not_engaged ; -optional_int number_engaged = 42 ; - -printf( "%d\n", *number_engaged) ; - -optional_int_vect numbers{{1,2,3,4}} ; - -printf( "%d %d\n", numbers.value()[0], numbers.value()[1] ) ; - -optional_string ostring = "hello" ; - -printf( "%s\n", ostring->c_str() ) ; -#endif - -return 0; // break here -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/main.cpp @@ -0,0 +1,41 @@ +#include +#include +#include + +// If we have libc++ 4.0 or greater we should have +// According to libc++ C++1z status page +// https://libcxx.llvm.org/cxx1z_status.html +#if !defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 4000 +#include +#define HAVE_OPTIONAL 1 +#else +#define HAVE_OPTIONAL 0 +#endif + +int main() { + bool has_optional = HAVE_OPTIONAL; + + printf("%d\n", has_optional); // break here + +#if HAVE_OPTIONAL == 1 + using int_vect = std::vector; + using optional_int = std::optional; + using optional_int_vect = std::optional; + using optional_string = std::optional; + + optional_int number_not_engaged; + optional_int number_engaged = 42; + + printf("%d\n", *number_engaged); + + optional_int_vect numbers{{1, 2, 3, 4}}; + + printf("%d %d\n", numbers.value()[0], numbers.value()[1]); + + optional_string ostring = "hello"; + + printf("%s\n", ostring->c_str()); +#endif + + return 0; // break here +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py @@ -1,29 +1,18 @@ -""" -Test lldb data formatter subsystem. -""" - - - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" -class LibcxxOptionalDataFormatterTestCase(TestBase): +class GenericOptionalDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) -@add_test_categories(["libc++"]) -## Clang 7.0 is the oldest Clang that can reliably parse newer libc++ versions -## with -std=c++17. -@skipIf(oslist=no_match(["macosx"]), compiler="clang", compiler_version=['<', '7.0']) -## We are skipping gcc version less that 5.1 since this test requires -std=c++17 -@skipIf(compiler="gcc", compiler_version=['<', '5.1']) - -def test_with_run_command(self): +def do_test_with_run_command(self, stdlib_type): """Test that that file and class static variables display correctly.""" -self.build() +self.build(dictionary={stdlib_type: "1"}
[Lldb-commits] [PATCH] D114403: [formatters] Add a formatter for libstdc++ optional
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGe3dea5cf0e32: [formatters] Add a formatter for libstdc++ optional (authored by Walter Erquinigo). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114403/new/ https://reviews.llvm.org/D114403 Files: lldb/bindings/interface/SBValue.i lldb/examples/synthetic/gnu_libstdcpp.py lldb/include/lldb/API/SBValue.h lldb/source/API/SBValue.cpp lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/TestDataFormatterLibcxxOptional.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/main.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -#include - -// If we have libc++ 4.0 or greater we should have -// According to libc++ C++1z status page https://libcxx.llvm.org/cxx1z_status.html -#if _LIBCPP_VERSION >= 4000 -#include -#define HAVE_OPTIONAL 1 -#else -#define HAVE_OPTIONAL 0 -#endif - - -int main() -{ -bool has_optional = HAVE_OPTIONAL ; - -printf( "%d\n", has_optional ) ; // break here - -#if HAVE_OPTIONAL == 1 -using int_vect = std::vector ; -using optional_int = std::optional ; -using optional_int_vect = std::optional ; -using optional_string = std::optional ; - -optional_int number_not_engaged ; -optional_int number_engaged = 42 ; - -printf( "%d\n", *number_engaged) ; - -optional_int_vect numbers{{1,2,3,4}} ; - -printf( "%d %d\n", numbers.value()[0], numbers.value()[1] ) ; - -optional_string ostring = "hello" ; - -printf( "%s\n", ostring->c_str() ) ; -#endif - -return 0; // break here -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/main.cpp @@ -0,0 +1,41 @@ +#include +#include +#include + +// If we have libc++ 4.0 or greater we should have +// According to libc++ C++1z status page +// https://libcxx.llvm.org/cxx1z_status.html +#if !defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 4000 +#include +#define HAVE_OPTIONAL 1 +#else +#define HAVE_OPTIONAL 0 +#endif + +int main() { + bool has_optional = HAVE_OPTIONAL; + + printf("%d\n", has_optional); // break here + +#if HAVE_OPTIONAL == 1 + using int_vect = std::vector; + using optional_int = std::optional; + using optional_int_vect = std::optional; + using optional_string = std::optional; + + optional_int number_not_engaged; + optional_int number_engaged = 42; + + printf("%d\n", *number_engaged); + + optional_int_vect numbers{{1, 2, 3, 4}}; + + printf("%d %d\n", numbers.value()[0], numbers.value()[1]); + + optional_string ostring = "hello"; + + printf("%s\n", ostring->c_str()); +#endif + + return 0; // break here +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py @@ -1,29 +1,18 @@ -""" -Test lldb data formatter subsystem. -""" - - - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" -class LibcxxOptionalDataFormatterTestCase(TestBase): +class GenericOptionalDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) -@add_test_categories(["libc++"]) -## Clang 7.0 is the oldest Clang that can reliably parse newer libc++ versions -## with -std=c++17. -@skipIf(oslist=no_match(["macosx"]), compiler="clang", compiler_version=['<', '7.0']) -## We are skipping gcc version less that 5.1 since this test requires -std=c++17 -@skipIf(compiler="gcc", compiler_version=['<', '5.1']) - -def test_with_run_command(self): +def do_test_w
[Lldb-commits] [lldb] e3dea5c - [formatters] Add a formatter for libstdc++ optional
Author: Walter Erquinigo Date: 2021-11-22T15:36:46-08:00 New Revision: e3dea5cf0e326366ab95a49d167fde8b0816e292 URL: https://github.com/llvm/llvm-project/commit/e3dea5cf0e326366ab95a49d167fde8b0816e292 DIFF: https://github.com/llvm/llvm-project/commit/e3dea5cf0e326366ab95a49d167fde8b0816e292.diff LOG: [formatters] Add a formatter for libstdc++ optional Besides adding the formatter and the summary, this makes the libcxx tests also work for this case. This is the polished version of https://reviews.llvm.org/D114266, authored by Danil Stefaniuc. Differential Revision: https://reviews.llvm.org/D114403 Added: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/main.cpp Modified: lldb/bindings/interface/SBValue.i lldb/examples/synthetic/gnu_libstdcpp.py lldb/include/lldb/API/SBValue.h lldb/source/API/SBValue.cpp lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Removed: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/TestDataFormatterLibcxxOptional.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/main.cpp diff --git a/lldb/bindings/interface/SBValue.i b/lldb/bindings/interface/SBValue.i index dd012e667a20c..bc66a4ae28f82 100644 --- a/lldb/bindings/interface/SBValue.i +++ b/lldb/bindings/interface/SBValue.i @@ -410,6 +410,9 @@ public: bool SetData (lldb::SBData &data, lldb::SBError& error); +lldb::SBValue +Clone(const char *new_name); + lldb::addr_t GetLoadAddress(); diff --git a/lldb/examples/synthetic/gnu_libstdcpp.py b/lldb/examples/synthetic/gnu_libstdcpp.py index 9272b814f78d8..27fca0a5d3271 100644 --- a/lldb/examples/synthetic/gnu_libstdcpp.py +++ b/lldb/examples/synthetic/gnu_libstdcpp.py @@ -8,6 +8,34 @@ # You are encouraged to look at the STL implementation for your platform # before relying on these formatters to do the right thing for your setup +def StdOptionalSummaryProvider(valobj, dict): +has_value = valobj.GetNumChildren() > 0 +# We add wrapping spaces for consistency with the libcxx formatter +return " Has Value=" + ("true" if has_value else "false") + " " + + +class StdOptionalSynthProvider: +def __init__(self, valobj, dict): +self.valobj = valobj + +def update(self): +try: +self.payload = self.valobj.GetChildMemberWithName('_M_payload') +self.value = self.payload.GetChildMemberWithName('_M_payload') +self.count = self.payload.GetChildMemberWithName('_M_engaged').GetValueAsUnsigned(0) +except: +self.count = 0 +return False + + +def num_children(self): +return self.count + +def get_child_index(self, name): +return 0 + +def get_child_at_index(self, index): +return self.value.Clone('Value') """ This formatter can be applied to all @@ -26,15 +54,15 @@ def get_object_kind(self, valobj): def extract_type(self): type = self.valobj.GetType() # type of std::pair is the first template -# argument type of the 4th template argument to std::map and -# 3rd template argument for std::set. That's why +# argument type of the 4th template argument to std::map and +# 3rd template argument for std::set. That's why # we need to know kind of the object template_arg_num = 4 if self.kind == "map" else 3 allocator_type = type.GetTemplateArgumentType(template_arg_num) data_type = allocator_type.GetTemplateArgumentType(0) return data_type -def update(self): +def update(self): # preemptively setting this to None - we might end up changing our mind # later self.count = None @@ -64,12 +92,12 @@ def get_child_at_index(self, index): return None try: offset = index -current = self.next +current = self.next while offset > 0: current = current.GetChildMemberWithName('_M_nxt') offset = offset - 1 return current.CreateChildAtOffset( '[' + str(index) + ']', self.skip_size, self.data_type) - + except: logger >> "Cannot get child" return None @@ -115,7 +143,7 @@ def is_valid(self, node): else: logger >> "synthetic value is not valid" return valid - + def value(self, node): logger = lldb.formatters.Logger.Logger() value = node.GetValueAsUnsigned() @@ -161,7 +189,
[Lldb-commits] [lldb] a2c7631 - Attempt to fix e3dea5cf0e326366ab95a49d167fde8b0816e292
Author: Walter Erquinigo Date: 2021-11-22T16:33:40-08:00 New Revision: a2c76312ed0acd9cb8a1ac03c94c1464a2dbb208 URL: https://github.com/llvm/llvm-project/commit/a2c76312ed0acd9cb8a1ac03c94c1464a2dbb208 DIFF: https://github.com/llvm/llvm-project/commit/a2c76312ed0acd9cb8a1ac03c94c1464a2dbb208.diff LOG: Attempt to fix e3dea5cf0e326366ab95a49d167fde8b0816e292 https://lab.llvm.org/buildbot/#/builders/17/builds/13728 found an issue in the optional formatter. Added: Modified: lldb/examples/synthetic/gnu_libstdcpp.py Removed: diff --git a/lldb/examples/synthetic/gnu_libstdcpp.py b/lldb/examples/synthetic/gnu_libstdcpp.py index 27fca0a5d327..9f1ba29ae126 100644 --- a/lldb/examples/synthetic/gnu_libstdcpp.py +++ b/lldb/examples/synthetic/gnu_libstdcpp.py @@ -35,6 +35,10 @@ def get_child_index(self, name): return 0 def get_child_at_index(self, index): +# some versions of libstdcpp have an additional _M_value child with the actual value +possible_value = self.value.GetChildMemberWithName('_M_value') +if possible_value.IsValid(): +return possible_value.Clone('Value') return self.value.Clone('Value') """ ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits