nmos-cpp
nmos-cpp copied to clipboard
Question: linux debugger
What do people use as a debugger (or cross-debugger with gdbserver) on linux?
I have tried QtCreator 4.5.2 on a Ubuntu virtual machine debugging on a Raspberry Pi target and it has trouble displaying the nmos::resource objects. It can't show any data. It seems to be able to show the virtual function table but this is not of any value. Maybe this is an issue with the debugging information generated by the GCC compiler more than the debugger.
I initially started using nmos-cpp on a linux box but switched to a PC with Visual Studio 2017 because the debugger could show all the data. A bit of a pain with having to drill down several layers to get to the real data but at least it was available when it was needed.
Suggestions would be welcome.
Thanks.
Good question!
I tend to build and run unit tests and API tests on Linux, but develop and debug primarily on Windows.
I assume it's the web::json::value
member of the nmos::resource
that is hardest to visualize. With Visual Studio, a debugger visualizer might help. Here's one for web::json::value
that works in VS2015: https://gist.github.com/garethsb-sony/965a453c735eb277be8e205deb51a294.
If you're tied to Linux there's a GDB mechanism (though it requires some code to be written) that may be useful here and there's some scant documentation on the Qt site detailing how QtCreator exposes / integrates with it. GDB has an in-built Python interpreter that can be used to (amongst other things) create pretty printers for complex data types. The Qt link is here (https://doc.qt.io/qtcreator/creator-debugging-helpers.html) and there's a couple of links on writing GDB pretty printers here (https://stackoverflow.com/questions/12574253/c-gdb-python-pretty-printing-tutorial & https://interrupt.memfault.com/blog/automate-debugging-with-gdb-python-api).
For now I've made do digging through the layers of indirection in the template members to get at the data they hold but I've been tempted to spend a bit of time looking into this. If it works out, I'll post some snippets.
I tried the .natvis with VS 2017 and that works very nicely. Thank you for posting that. If I add others, I will post them.
I looked into the Linux issue a bit more and it looks like there isn't any debug info to make pretty. I stopped the debugger in a function which has a local variable named resource
. I opened the Debugger Log in QtCreator and entered a GDB command to print resource.data.m_value
. Here is the output:
&"p resource.data.m_value\n"
>~"$1 =
{
_M_t =
{
<std::_Tuple_impl<0u, web::json::details::_Value*, std::default_delete<web::json::details::_Value> >> =
{
<std::_Tuple_impl<1u, std::default_delete<web::json::details::_Value> >> =
{
<std::_Tuple_impl<2u>> =
{
<No data fields>
},
<std::_Head_base<1u, std::default_delete<web::json::details::_Value>, true>> =
{
<std::default_delete<web::json::details::_Value>> =
{
<No data fields>
}
, <No data fields>
},
<No data fields>
},
<std::_Head_base<0u, web::json::details::_Value*, false>> =
{
_M_head_impl = 0x75d01a60
},
<No data fields>
},
<No data fields>
}"
>~"}"
>~"\n"
I formatted the output a bit here but there seems to be a lot of No data fields
which is consistent with the debugger not showing any actual data. The debugger just shows [vptr]
and when this is expanded shows a list of virtual function pointers. Doesn't seem like a lot for a pretty print to work with.
Until there is a problem that only happens on Linux, I will stick with debugging on Windows.
Thanks for the feedback and the links.