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" } ]