user3180
user3180

Reputation: 1487

How to print full char array gdb

How do I print the full aligned_depth.get_data(). It should be a char array: https://gist.github.com/richardrl/224eb53d4bc1cedda36f5bda1d78ca18#file-realsense_multicam-cpp-L390

These are a few things I tried:

(gdb) print *aligned_depth.get_data()@depth_size
Attempt to dereference a generic pointer.
(gdb) print (char*) aligned_depth.get_data()@depth_size
Only values in memory can be extended with '@'.
(gdb) print (char*)aligned_depth.get_data()@depth_size
Only values in memory can be extended with '@'.

get_data is here: https://intelrealsense.github.io/librealsense/doxygen/classrs2_1_1frame.html#a4b373fc81617be881b691a97b0f8358c

Upvotes: 1

Views: 831

Answers (1)

Employed Russian
Employed Russian

Reputation: 213754

This should work:

(gdb) p *((char*)aligned_depth.get_data())@depth_size

At least it does work for me using GDB-10.0 given this test:

const char p[] = "abcd\0efgh";
const int  data_size = sizeof(p);
const void* get_data() { return p; }

int main() { return 0; }
gcc -g -w x.c && gdb -ex start -q ./a.out

Reading symbols from ./a.out...
Temporary breakpoint 1 at 0x113a: file x.c, line 5.
Starting program: /tmp/a.out

Temporary breakpoint 1, main () at x.c:5
5       int main() { return 0; }

(gdb) p *((char*)get_data())@data_size
$1 = "abcd\000efgh"

Upvotes: 1

Related Questions