Re: [eigen] gdb Eigen Pretty printers

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi,

2009/12/8 Benjamin Schindler <bschindler@xxxxxxxxxxx>:
> Hi
>
> Finally a real contribution to eigen - it was about time. I just wrote a
> pretty printer for Eigen::Matrix gdb-7.0 and later.

Very nice!

>
> To use it:
>
> * create a directory and put the file as well as an empty __init__.py in
> that directory
> * Create a ~/.gdbinit file, that contains the following:
>
> python
> import sys
> sys.path.insert(0, '/path/to/eigen/printer/directory')
> from printers import register_eigen_printers
> register_eigen_printers (None)
> end

I tried it on the attached file a.cpp,

  $ g++ a.cpp -I ../eigen -o a -g3
  $ gdb ./a
  > start
  > step
  (then press Enter several times)

But eventually I get this python error message:

(gdb)
main () at a.cpp:13
13        f(m,n);
(gdb)
f (m=Traceback (most recent call last):
  File "/home/bjacob/cuisine/printers.py", line 105, in lookup_function
    return pretty_printers_dict[function](val)
  File "/home/bjacob/cuisine/printers.py", line 80, in <lambda>
    pretty_printers_dict[re.compile('^Eigen::Matrix<.*>$')] = lambda
val: EigenMatrixPrinter(val)
  File "/home/bjacob/cuisine/printers.py", line 24, in __init__
    m = regex.findall(tag)[0][1:-1]
TypeError: expected string or buffer
...., n=Traceback (most recent call last):
  File "/home/bjacob/cuisine/printers.py", line 105, in lookup_function
    return pretty_printers_dict[function](val)
  File "/home/bjacob/cuisine/printers.py", line 80, in <lambda>
    pretty_printers_dict[re.compile('^Eigen::Matrix<.*>$')] = lambda
val: EigenMatrixPrinter(val)
  File "/home/bjacob/cuisine/printers.py", line 24, in __init__
    m = regex.findall(tag)[0][1:-1]
TypeError: expected string or buffer
....) at a.cpp:7
7         m = m * n;


Any idea?

> Notes:
>
> - It currently only supports Eigen::Matrix and no other type (such as
> quaternions etc). Patches welcome :)
> - I wrote it using the stable branch of eigen. I don't know whether it
> works with hg
> - It's still kind of hacky, mostly because of the limitations of the
> gdb.python framework

OK

>
> It seems that the gdb hackers want the pretty printer scripts included
> in the respective patches, so my final goal would be to have it in eigen-hg

I don't understand what you mean by "in the respective patches" ?

I agree that this is worth having in Hg. Maybe we should create a
top-level directory "debug" with a subdirectory "gdb" containing your
stuff. Then Hauke's work would go into another subdirectory "msvc".
Each would have a short README file, so Hauke's documentation on the
wiki could go there, or could be linked to from there. Opinions?

Benoit
#include <Eigen/Eigen>

using namespace Eigen;

void f(Matrix2d& m, Matrix2d& n)
{
  m = m * n;
}

int main()
{
  Matrix2d m, n;
  f(m,n);
}



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/