Closed jipuwang closed 6 years ago
Thanks! @slayoo I can see that'd work for C++ arrays, but is that also true for Blitz++ Arrays?
While there might be some ways of achieving higher-level understanding of Blitz++ arrays from gdb, here the low-level one should be enough, i.e.:
#include <blitz/array.h>
using T = blitz::Array<float,2>;
void fun(T &arg)
{
arg = 3;
}
int main()
{
T a(3,3);
a = 1,2,3,
4,5,6,
7,8,9;
fun(a);
}
$ g++ -g -std=c++11 test.cpp
$ gdb a.out
(gdb) break fun
Breakpoint 1 at 0x4008a2: file test.cpp, line 7.
(gdb) run
Breakpoint 1, fun (arg=...) at test.cpp:7
7 arg = 3;
(gdb) print arg.data()
$1 = (const blitz::Array<float, 2>::T_numtype * restrict) 0x619eb8
(gdb) print *arg.data()
$2 = 1
(gdb) print *(arg.data()+1)
$3 = 2
(gdb) print *(arg.data()+2)
$4 = 3
(gdb) print *(arg.data()+3)
$5 = 4
So from NumPy perspective, there would be no difference between Blitz++ or any other array that uses contiguous memory as storage (non-contiguous cases can likely also be handled as NumPy offers similar flexibility as Blitz when it comes to defining memory ordering, strides, etc).
Note that the referenced gdb_numpy module is Python 2 code hence will likely not be compatible out of the box with current gdb installation.
HTH
let me close this one - please reopen if needed
Does anyone know how to use GDB to print Blitz++ Array?
Thanks!