Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using GDB to print Blitz++ Array #43

Closed
jipuwang opened this issue Jun 27, 2018 · 4 comments
Closed

Using GDB to print Blitz++ Array #43

jipuwang opened this issue Jun 27, 2018 · 4 comments

Comments

@jipuwang
Copy link

Does anyone know how to use GDB to print Blitz++ Array?

Thanks!

@jipuwang jipuwang reopened this Jun 27, 2018
@slayoo
Copy link
Member

slayoo commented Jun 27, 2018

@jipuwang
Copy link
Author

Thanks! @slayoo
I can see that'd work for C++ arrays, but is that also true for Blitz++ Arrays?

@slayoo
Copy link
Member

slayoo commented Jun 27, 2018

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

@slayoo
Copy link
Member

slayoo commented Aug 17, 2018

let me close this one - please reopen if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants