1

I am using Xcode on macOS Catalina which comes with lldb. I tried to print out an Armadillo matrix following the stack overflow post Is there a way to print an Armadillo matrix in gdb?, but I got the error:

error: 'print_matrix' does not name a template but is followed by template arguments
non-template declaration found by name lookup

I'm new to C++ so I'm not sure whether the error is due to the difference between gdb and lldb or due to current version of Armadillo using different data structure. (The cited post is from 8 years ago, so maybe how Armadillo works has changed since then).

I will appreciate any fix to this error or suggestion of alternative ways to print out Armadillo matrix during debugging.

statuser
  • 31
  • 2
  • Might also be a bug in lldb's expression evaluator. If you can package up a small test case, please file a bug with http://bugs.llvm.org including your example. – Jim Ingham Feb 21 '20 at 18:18
  • BTW, I don't know if the layout of these matrix objects is still the same as it was in the answer you cited, but if it is it would be pretty easy to write an lldb "synthetic child provider" along the lines of the gdb pretty printers given in the answer. That has the same advantages in lldb that are given for the pretty printers in gdb, plus they will show up as disclosable types in the Xcode Locals view, which is pretty handy. – Jim Ingham Feb 21 '20 at 18:21
  • Instructions on writing synthetic child providers in lldb are here: https://lldb.llvm.org/use/variable.html#id10 – Jim Ingham Feb 21 '20 at 18:22
  • @JimIngham Thank you for all the comments! As a quick workaround I am currently creating a pointer by const double * vector_pointer = vector.memptr() in the C++ code, and use lldb command parray 10 vector_pointer where 10 is the number of elements up to vector length that I want to inspect. – statuser Feb 21 '20 at 21:01
  • You might see if memptr is something lldb can call. If it is, you can do: `parray 10 vector.memptr()` and not have to add variables to your code... If it isn't it would be good to file a bug on this. Calling template functions in the debugger is tricky, but we're trying to make it work reliably. – Jim Ingham Feb 22 '20 at 00:13
  • @JimIngham I tried `parray 10 vector.memptr()` but I got `error: Couldn't lookup symbols: arma::Mat::memptr()`. I'm not sure whether I should call it a bug as I am new to lldb and don't know how it is supposed to work... – statuser Feb 22 '20 at 03:54
  • A lot of high performance packages will force inlining of all their little utility functions. But since the expression evaluator's compiler doesn't know how to compile all the header files in the package - tricky because we don't know the #define environment - it can't recreate the missing functions. That's generally the cause for this "couldn't look up symbols" error. Forward declaring template instantiations: `class arma::Mat` in your code will force the compiler to emit all these functions. But that's not sustainable. – Jim Ingham Feb 24 '20 at 18:22
  • lldb is working on reconstructing templates from C++ headers that are built into clang (and soon C++) modules. But that's still a work in progress, and if the C++ library isn't modularized we won't support this. – Jim Ingham Feb 24 '20 at 18:23
  • @JimIngham Thank you so much for the kind explanations! – statuser Feb 25 '20 at 07:59

0 Answers0