【1000个GDB技巧-003】-GDB如何设置变量以及使用变量 set $abc;p /x $abc

本文介绍了如何在VSC(VisualStudioCode)的配置文件如launch.json的setupCommands中设置和使用变量,如`set$abc=0x123456`,并以16进制形式打印。特别提到了gitinit的脚本和VSCode配置的相关链接.

设置变量:

    set $abc=0x123456

使用变量:

    p /x $abc 按照16进制打印

场景:可以设置一些变量地址

然后set命令放到~/.gitinit 的启动脚本中

或者如果是vsc放到配置文件的 setupCommands中加变量

"setupCommands":[
    {
        "description": "描述",
        "text": "set $abc=0x123456",
    }
]

更多vsc的配置参考:https://code.visualstudio.com/docs/cpp/launch-json-reference#_setupcommands

注意vscode中需要加-exec

x30076086@DESKTOP-3DUV7GS:~/openHarmony/standalone$ LD_LIBRARY_PATH=out/x64.debug/arkcompiler/ets_runtime x30076086@DESKTOP-3DUV7GS:~/openHarmony/standalone$ out/x64.debug/arkcompiler/ets_runtime/ark_js_vm helloworld.abc Hello world! x30076086@DESKTOP-3DUV7GS:~/openHarmony/standalone$ gdb --args out/x64.debug/arkcompiler/ets_runtime/ark_js_vm helloworld.abc GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.2) 9.2 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from out/x64.debug/arkcompiler/ets_runtime/ark_js_vm... (gdb) file arkcompiler/ets_runtime/ecmascript/runtime.cpp "/home/x30076086/openHarmony/standalone/arkcompiler/ets_runtime/ecmascript/runtime.cpp": not in executable format: file format not recognized (gdb) b 212 Breakpoint 1 at 0x6898: file ../../arkcompiler/ets_runtime/ecmascript/js_vm/main.cpp, line 215. (gdb) p g_isEnableCMCGC No symbol "g_isEnableCMCGC" in current context. (gdb) set args g_isEnableCMCGC (gdb) show args Argument list to give program being debugged when it is started is "g_isEnableCMCGC".这段命令哪有问题,要用gdb调试运行helloworld.abc查看runtime.cpp的g_isEnableCMCGC,可执行程序却只有ark_js_vm,怎么做呢
11-08
x30076086@DESKTOP-3DUV7GS:~/openHarmony/standalone$ gdb --args out/x64.debug/arkcompiler/ets_runtime/ark_js_vm helloworld.abc GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.2) 9.2 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from out/x64.debug/arkcompiler/ets_runtime/ark_js_vm... (gdb) directory /home/x30076086/openHarmony/standalone/arkcompiler/ets_runtime/ecmascript/ Source directories searched: /home/x30076086/openHarmony/standalone/arkcompiler/ets_runtime/ecmascript:$cdir:$cwd (gdb) b rutime.cpp:212 No source file named rutime.cpp. Make breakpoint pending on future shared library load? (y or [n]) n (gdb) run Starting program: /home/x30076086/openHarmony/standalone/out/x64.debug/arkcompiler/ets_runtime/ark_js_vm helloworld.abc [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff38dc700 (LWP 12714)] [New Thread 0x7ffff30db700 (LWP 12715)] [New Thread 0x7ffff28da700 (LWP 12716)] [New Thread 0x7ffff20d9700 (LWP 12717)] Hello world! [Thread 0x7ffff38dc700 (LWP 12714) exited] [Thread 0x7ffff20d9700 (LWP 12717) exited] [Thread 0x7ffff28da700 (LWP 12716) exited] [Thread 0x7ffff30db700 (LWP 12715) exited] [Inferior 1 (process 12710) exited normally] (gdb)照你说的为什么No source file named rutime.cpp.
11-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值