When I run my executable outside of the debugger I get this assertion which triggers a trap:
Apr 29 08:25:21 ./xmlpgtest_doccopy[39308] <Error>: <Error>: Assert:[/Users/davidbien/dv/xmlp/xmlpinc/xml_tag.h:49],void ns_xmlp::xml_tag<ns_xmlp::xml_traits<ns_lxo::_l_transport_file<char8_t>, false, false>>::AssertValid(const ns_xmlp::xml_tag::_TyThis *) const [t_TyXmlTraits = ns_xmlp::xml_traits<ns_lxo::_l_transport_file<char8_t>, false, false>](): _ptagParent == m_ptagParent.
[1] 39308 trace trap ./xmlpgtest_doccopy ~/dv/xmlp/unittests/unittest1.xml
However when I run inside of LLDB inside of Visual Studio Code the debugger just hangs and doesn't catch the TRAP signal. If I press the "PAUSE" button it just stops debugging with the message:
The program '/Users/davidbien/dv/xmlp/build/xmlpgtest_doccopy' has exited with code 0 (0x00000000).
So I am having quite a hard time debugging this. This doesn't happen (for instance) when debugging under Visual Studio Code with GDB under Linux and of course I can debug under MSVC in Windows.
Any help would be appreciated. Please no ridicule, I am a C++ developer for the last 28 years, I know what I am doing.
I looked at various potential solutions on here, including one where someone suggests to send a TRAP signal from a command window to the inferior LLDB process (the one being debugged) and that doesn't have any effect whatsoever.
Here is how I am breaking into the debugger in various OS/compiler combinations:
#ifdef _MSC_VER
#define DEBUG_BREAK __debugbreak()
#elif defined( __clang__ )
#if __has_builtin(__builtin_debugtrap)
#define DEBUG_BREAK __builtin_debugtrap()
#else
#define DEBUG_BREAK __builtin_trap()
#endif
#elif defined( __GNUC__ )
#define DEBUG_BREAK __builtin_trap()
#else
#error Need to know the OS/compiler for breaking into the debugger.
#endif
I am compiling using clang12 from the latest Xcode release and the latest lldb from the same release.
EDIT: I do break on an AV (access violation) so perhaps I should just AV instead of raising a TRAP signal?
EDIT: I did as Ben suggested below (thanks Ben) and the result is no change in behavior.
-exec process handle -p TRUE -s TRUE SIGTRAP
NAME PASS STOP NOTIFY
=========== ===== ===== ======
SIGTRAP true true true
It still hangs when the SIGTRAP is sent.
EDIT: I inserted:
*((volatile char*)0) = 0xba;
DEBUG_BREAK;
in the hopes that I could just have an AV break into the debugger. The debugger still hangs.
EDIT: The VisualStudioCode extension CodeLLDB works and gets to my assertion and has some other really awesome things - like tells you the active type of a variant. The bug is apparently in lldb-mi which is released by Microsoft. I may give them a bug.
SUMMARY: This is due to a bug in lldb-mi.
User contributions licensed under CC BY-SA 3.0