VS CODE 查看内存
MemoryView - Visual Studio Marketplace
第一步:Add new memory view...
第二步:输入变量地址 &array
第三步:需要手动刷新内存
1、在程序中增加dump函数,如下
2、VScode的监视(WATCH)窗口,是可以调用函数的, 在监视窗口 Add Expression,
memory_dump(argv, 32) memory_dump(0x7fffffffdb58, 32)
void memory_dump(void *ptr, int len)
{ int i; for (i = 0; i < len; i+=4) { if (i % 16 == 0 && i != 0) printf(" "); if (i % 64 == 0 && i != 0) printf("\n"); printf("%08x ", *((uint32_t *)(ptr + i))); } printf("\n"); }
其他方法
在“调试控制台 debug console”下用命令 “-exec x/8x argv "可以查看数组内容,那么在监视(watch)窗口下也可以添加"-exec x/8x argv", 调试的时候随着单步F10,可以自动执行这个命令(不需要再调试控制台窗口手动执行命令)
https://stackoverflow.com/questions/42645761/vscode-display-hex-values-for-variables-in-debug-mode
Suffixes used in VSCode's Watch pane:
var, h
var, d
var, b
var, o
From the (GDB) Debug Console use -exec set output-radix 16
for hex, set it to 10 for decimal.
his answer applies to GDB debugging.
For an active debug session, type the following in the debug console:
-exec set output-radix 16
To apply this every time the debugger runs, add text "set output-radix 16" in the "setupCommands" section of launch.json
"setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true }, { "text": "set output-radix 16" } ]