Re: [eigen] gdb Eigen Pretty printers

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


Hi


Benoit Jacob wrote:
> 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?
>   
I just tested your file here and got that:
bschindl@hundertwasser /local/bschindler/projects/test/build $ gdb ./test

(gdb) start
Temporary breakpoint 1 at 0x4007fa: file a.cpp, line 12.
Starting program: /local/bschindler/projects/test/build/test

Temporary breakpoint 1, main () at a.cpp:12
12        Matrix2d m, n;
(gdb) n
13        f(m,n);
(gdb) p m
$1 = Eigen::Matrix<double,2,2> = {
  [0, 0] = 2.0747911307212309e-317,
  [1, 0] = 0,
  [0, 1] = 6.9533558073425197e-310,
  [1, 1] = 0
}
(gdb) p n
$2 = Eigen::Matrix<double,2,2> = {
  [0, 0] = 6.9533486693516308e-310,
  [1, 0] = 2.0748148458722313e-317,
  [0, 1] = 6.9533558073429149e-310,
  [1, 1] = 6.9533491761380836e-310
}
(gdb)

In your output I don't really see what produced the output you got there
- did you try to print a variable or did you do something else?

I assume this problem has to do with the fact you are on eigen-devel
(You include <Eigen/Eigen> which is not available with stable).
I'll retry with unstable in a sec
>   
>> 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" ?
>   
Sorry - I typed too fast. They want that the scripts are packaged with
the respective libraries and not included in gdb as i.e. cmake does it.
> 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?
>   
Sounds good to me

Benjamin
> Benoit
>   




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