簡體   English   中英

如何打印完整的字符數組 gdb

[英]How to print full char array gdb

如何打印完整的aligned_depth.get_data()。 它應該是一個字符數組: https://gist.github.com/richardrl/224eb53d4bc1cedda36f5bda1d78ca18#file-realsense_multicam-cpp-L39

這些是我嘗試過的一些事情:

(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 '@'.

獲取數據在這里: https://intelrealsense.github.io/librealsense/doxygen/classrs2_1_1frame.html#a4b373fc81617be8831b691a97bf0

這應該有效:

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

考慮到這個測試,至少它對我使用 GDB-10.0 有效:

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"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM