GDB调试方法


 

VS CODE

 (win10开启管理员权限,找到"C:\Program Files\Microsoft VS Code\Code.exe"  点击属性。选择兼容性,勾选 “以管理员身份运行此程序” 确定即可)

 

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/u-boot", "args": [], "stopAtEntry": true, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "targetArchitecture": "arm", "miDebuggerPath":"/usr/bin/gdb-multiarch", "miDebuggerServerAddress": "localhost:1234", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ] }

 -exec add-symbol-file u-boot 0x7ff7f000

[answered Y; input not from terminal]
-exec set confirm off

 

VS CODE 在程序汇编入口打断点

1VS Code启动gdbserver调试后会输出以下信息

=thread-group-added,id="i1"
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 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".
=cmd-param-changed,param="pagination",value="off"
system_vectors () at /home/user/workshop/rt-thread/libcpu/arm/cortex-a/vector_gcc.S:16
16	    ldr pc, _vector_reset

可以获取程序入口在 vector_gcc.S文件的16行,

 

【使用gdb-multiarch rtthread.elf 的target remote :1234 一样也可以获取程序入口】

$ gdb-multiarch rtthread.elf 
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 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 rtthread.elf...done.
(gdb) target remote :1234
Remote debugging using :1234
system_vectors () at /home/user/workshop/rt-thread/libcpu/arm/cortex-a/vector_gcc.S:16
16	    ldr pc, _vector_reset

 

分析 vector_gcc.S 文件

.globl system_vectors
system_vectors:
    ldr pc, _vector_reset
    ldr pc, _vector_undef
    ldr pc, _vector_swi
    ldr pc, _vector_pabt
    ldr pc, _vector_dabt
    ldr pc, _vector_resv
    ldr pc, _vector_irq
    ldr pc, _vector_fiq

.globl _reset
.globl vector_undef
.globl vector_swi
.globl vector_pabt
.globl vector_dabt
.globl vector_resv
.globl vector_irq
.globl vector_fiq

_vector_reset:
    .word _reset

分析可知,程序入口在_reset 处,

.text
/* reset entry */
.globl _reset
_reset: #ifdef ARCH_ARMV8 /* Check for HYP mode */ mrs r0, cpsr_all and r0, r0, #0x1F mov r8, #0x1A cmp r0, r8 beq overHyped b continue overHyped: /* Get out of HYP mode */ adr r1, continue msr ELR_hyp, r1 mrs r1, cpsr_all and r1, r1, #0x1f ;@ CPSR_MODE_MASK orr r1, r1, #0x13 ;@ CPSR_MODE_SUPERVISOR  msr SPSR_hyp, r1 eret continue: #endif /* set the cpu to SVC32 mode and disable interrupt */ cps #Mode_SVC

因此,将断点放在_reset的汇编label处

在VS CODE的 BREAKPOINTS 窗口中添加 _reset 断点

 

也可以自己添加label到汇编代码中

bss_loop:
    cmp     r1,r2                   /* check if data to clear           */
    strlo   r0,[r1],#4              /* clear 4 bytes */ blo bss_loop /* loop until done */

然后在 BREAKPOINTS 窗口中添加 bss_loop 断点

 

 

VS CODE 查看内存

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,可以自动执行这个命令(不需要再调试控制台窗口手动执行命令)

 

 

 

Affinic Debugger
http://www.affinic.com/

 

 

Code::Blocks 20.03

1.) Run command to add the PPA repository:

sudo add-apt-repository ppa:codeblocks-devs/release

sudo apt update 
#codeblocks-contrib 修改快捷键必须要安装 sudo apt install codeblocks codeblocks-contrib

nightly-build codeblocks (不建议安装,直接使用stable版本)
https://wxstuff.xaviou.fr/article/debian-repository.html


sudo -s

apt install apt-transport-https gvim /etc/apt/sources.list ##check version of Debian cat /etc/debian_version ##For Debian 9 (Stretch): deb https://apt.xaviou.fr/oldstable/ stretch main deb-src https://apt.xaviou.fr/oldstable/ stretch main  ##And for Debian 10 (Buster): deb https://apt.xaviou.fr/stable/ buster main deb-src https://apt.xaviou.fr/stable/ buster main wget -O- https://apt.xaviou.fr/key.asc | apt-key add - touch /etc/apt/preferences.d/codeblocks gvim codeblocks Package: * Pin: origin apt.xaviou.fr Pin-Priority: 999 apt update apt install codeblocks

 

1)“File -> New -> Project”,选择“Empty Project”并创建。

2)选中 Project,右键,选择“Add files”,将 c/c++ 和 head files 加入工程。

3)选中 Project,右键,选择“Properties”,“Project settings”选项卡中的“Makefile”填入Makefile 文件名,并勾选“This is a custom Makefile”。

4)选中 Project,右键,选择“Properties”,“Build targets”选项卡中的“Output filename:”填入build后产生的elf文件 (bsp/qemu-vexpress-a9/rtthread.elf),不勾选    "Auto-generate filename prefix"     不勾选  "Auto-generate filename extension"  

5)选中 Project,右键,选择“Build options”,删除“"Make" command”选项卡中所有的“$target”。(可以修改为执行脚本 sh build.sh, 如rt-thread 使用scons编译,就可以直接写scons)

Selected compiler 需要选择系统已有的compiler(GNU GCC Compiler) 即使Makefile使用的是别的Compiler

6) 选中 Project,右键,选择“Properties”,在debugger标签下,配置下remote connection,debug选下中 填入type: TCP,      IP address: localhost    Port: 1234   即可 

7) 打开codeblocks,配置setting->debuger,指向gdb-multiarch,另外勾选下do not run the debugee,可以防止程序直接运行

 

codeblocks的Command中可以输入 stepi


如果Debugger log 窗口中提示:
No symbol table is loaded. Use the "file" command.
表示没有指定elf文件,(也就是 4)中配置错误 “Build targets”选项卡中的“Output filename),此时可以在Command中 输入 file ~/rt-thread/bsp/qemu-vexpress-a9/rtthread.elf (即file + elf路径)




http://bbs.eeworld.com.cn/thread-480542-1-1.html

然后打开codeblocks,配置settings->compiler(可不配置),指向arm-none-eabi-

配置setting->debuger,指向arm-none-eabi-gdb,另外勾选下do not run the debugee,可以防止程序直接运行

接下来新建一个空的工程,将u-boot目录下所有的.c;.h;.s;.S文件导入(有心情可以把没用的删掉,我是懒得烦了)

右击工程名,打开properties,在debugger标签下,配置下remote connection,填入localhost及1234即可。

这样之后,直接点击调试小图标就可以开始调试uboot了,默认暂停在b reset这儿,可以按F7单步。


三,Relocating之后的处理

relocation之后的断点需要重新定位symbols,可以参考http://www.denx.de/wiki/view/DULG/DebuggingUBoot

对于这块a9板,可以用这个命令add-symbol-file u-boot 0x6FF83000,然后就能对上relocating之后的代码了。

 

Code::Blocks自定义文件代码高亮和自动补全

代码高亮简单的步骤说明:

Settings --> Editor... --> Syntax hignlighting... --> Syntax hignlighting for: MASM Assembly --> Filemasks...;

在编辑框中加上你要高亮的代码后缀,比如我的就是*.s(中间逗号分割)。

 

 C/C++ 文件 自动补全简单的步骤说明:

Settings --> Editor... --> Code completion  --> C/C++ parser(adv.);

在“File extentions to parse as source files...”下面编辑框中加入你要代码自动完成的C/C++文件代码后缀。





Eclipse

远程手动运行方式

1、在目标板上运行 gdbserver,

 

2、配置CDT的Debug选项,步骤如下:

  1. 选中项目→菜单栏 ”Run“→Debug Configurations…
  2. 双击 C/C++ Remote Application 新建一个配置, Eclipse会根据当前选择的项目初始化大部分配置,这里只需修改Debugger配置页
  3. 在右下方点击“Select other”,选择“GDB(DSF) Manual Remote Debugging Launcher”,确认
  4. 选择进入Debugger配置页,在Main标签中,GDB debugger 填写 arm-linux-gdb,如果未加入PATH环境变量则应该填入绝对路径,  Stop on startup at  (调试uboot填reset, 调试linux_kernel填start_kernel)
  5. 在Debugger配置页的Shared Libraries标签中,可以添加库路径,比如调试过程中要步入外部函数,就必须在这里给出带调试信息的库文件路径,否则会找不到该函数的定义
  6. 在Debugger配置页的Connection标签中,Type选“TCP”,并填写目标板上gdbserver监听的IP和端口号
  7. 所有配置完成后,点 Debug调试

 

Eclipse 的DevStyle主题安装

https://www.genuitec.com/products/devstyle/download/

 

help---->install new software---->Add---->输入名字、输入网址:

http://www.genuitec.com/updates/devstyle/ci/

等待Eclipse右下角Installing Software 100%, 安装完毕后重启即可

 

 

 

 

Sublime + SublimeGDB 

安装Package Control

Package Control用来方便的管理各种插件,其实他自己也是一个插件。它的官网是 https://packagecontrol.io/

使用ctrl+` (键盘左上角)快捷键 或者菜单 View > Show Console 打开python控制台,然后执行下面的命令即可安装

  1. Click the Preferences > Browse Packages… menu
  2. Browse up a folder and then into the Installed Packages/ folder     【~/.config/sublime-text-3/Installed Packages】
  3. Download Package Control.sublime-package and copy it into the Installed Packages/ directory
  4. Restart Sublime Text

安装 SublimeGDB

菜单Preferneces -> Package Control打开, 选择 Install Package,  然后输入SublimeGDB,点击就可以安装了。

 

修改配置文件

依次选择Preferneces -> Package Settings -> SublimeGDB -> Settings – User

 

默认的快捷键(可以通过修改Default.sublime-keymap修改快捷键)

按键 功能
F5 开始调试
Ctrl+F5 停止调试
F9 设置断点
F10 Step over,执行一步,不进入函数
F11 Step into,进入函数
Shift+F11 Step out,跳出函数

 

{
    // All options in here can also be specified in your project settings
    // with a prepended "sublimegdb_". You probably want to
    // have something like this in your project settings:
    //
    // "settings":
    // {
    //      "sublimegdb_workingdir": "${folder:${project_path:your_executable_name}}",
    //      // NOTE: You MUST provide --interpreter=mi for the plugin to work
    //      "sublimegdb_commandline": "gdb --interpreter=mi ./your_executable_name"
    //
    // }
    // 
    // generalized pattern for using always the current open file with an executable name 
    // as the current file
    // "settings":
    // {
    //      "sublimegdb_workingdir": "${folder:${file}}",
    //      // put your arguments hear
    //      "sublimegdb_arguments": "",
    //      // NOTE: You MUST provide --interpreter=mi for the plugin to work
    //      "sublimegdb_commandline": "gdb --interpreter=mi --args ./${file_base_name}"
    //      
    //
    // }
    //
    // If you want to debug different executables as part of the same project, you can add something
    // like this to your project settings:
    //
    // "settings":
    // {
    //      "sublimegdb_executables":
    //      {
    //          "first_executable_name":
    //          {
    //              "workingdir": "${folder:${project_path:first_executable_name}}",
    //              "commandline": "gdb --interpreter=mi ./first_executable"
    //          },
    //          "second_executable_name":
    //          {
    //              "workingdir": "${folder:${project_path:second_executable_name}}",
    //              "commandline": "gdb --interpreter=mi ./second_executable"
    //          }
    //      }
    // }
    //
    // When you start debugging, you will be prompted to choose from one of your executables. Any
    // settings not specified for that project will be searched in your project settings (with a
    // sublimegdb_ prefix), then in your user settings, then in the default settings.
    //
    // (Note: if you have multiple executables, and you have a breakpoint set in a source file which
    // is not included in the current executable, you may have to set either debug_ext or
    // i_know_how_to_use_gdb_thank_you_very_much.)
    //
    // ${home}, ${project_path:}, ${folder:}, ${file} and ${file_base_name}
    // tokens can be used in 'workingdir', 'commandline', 'arguments' options.
    //
    // ${home} is replaced with the value of the HOME environment variable.
    //
    // ${project_path:} tries to find a file with the given name in all the registered project folders and
    // returns the first file found, or the original file name if none is found.
    // Example: ${project_path:main.cpp} tries to find a file named "main.cpp" relative
    // to the current project's folders. If none is found, it is replaced with "main.cpp".
    //
    // ${folder:} is replaced with the dirname of the given path.
    // Example: ${folder:/path/to/file} is replaced with "/path/to".
    // "workingdir": "/tmp",
    //
    // ${file} is replaced with absolute path to currently open file (if any)
    // Example: /home/user/main.cpp
    //
    // ${file_base_name} is replaced with name without extension of currently
    // open file (if any)
    // Example: replaced with "main" for file "/home/user/main.cpp"
    "workingdir": "/home/user/workshop/Demo2",

    // NOTE: You MUST provide --interpreter=mi for the plugin to work
    // "commandline": "gdb --interpreter=mi ./executable",
    "commandline": "cmake . && make && gdb --interpreter=mi --args ./Demo",

    // Environments for running gdb and gdb server
    // Example: "env": {"DISPLAY": ":100"}
    "env": {"DISPLAY": ":100"},

    // Arguments for the program.
    // Example: to run "./executable foo bar"
    // "arguments": "foo bar"
    // To provide user input (stdin) use
    // "arguments": "< input.dat"
    "arguments": "2 6",

    // GDB Server 
    // Specify a command and working dir for launching a GDB Server
    // This is useful for dealing with "remote" servers that are actually locally 
    // connected JTAG boxes
    "server_workingdir": "notset",
    "server_commandline": "notset",

    // The command to use to run the program.
    // If you are attaching to a remote program, you
    // probably want to change this to -exec-continue
    "exec_cmd": "-exec-run",

    // Load the image to the remote target
    "load_cmd": "-target-download",

    // Immediately run the target upload connecting
    // When attaching to a remote program, you
    // may want to set this to false 
    "run_after_init": false,

    // Attempt to update stack information while the program is running
    // If your remote target does not support non-stop, set this to false
    "update_while_running" : false,

    // Attach to a remote target?  This is needed here because "-gdb-set target-async 1" must be
    // done prior to attaching
    "attach_cmd" : "target remote 127.0.0.1:1234", 
    //"attach_cmd" : "-gdb-set target remote 127.0.0.1:1234",  error

    // For the larger binaries with lot of shared libraries
    // the loading within the gdb could take much longer.
    // Configure the thread wait timeout by setting gdb_timeout
    "gdb_timeout": 200,

    // Define debugging window layout (window split)
    // first define column/row separators, then refer to them to define cells
    "layout":
    {
        "cols": [0.0, 0.33, 0.66, 1.0],
        "rows": [0.0, 0.75, 1.0],
        "cells":
        [ // c1 r1 c2 r2
            [0, 0, 3, 1], // -> (0.00, 0.00), (1.00, 0.75)
            [0, 1, 1, 2], // -> (0.00, 0.75), (0.33, 1.00)
            [1, 1, 2, 2], // -> (0.33, 0.75), (0.66, 1.00)
            [2, 1, 3, 2]  // -> (0.66, 0.75), (1.00, 1.00)
        ]
    },

    // visual stuff
    "breakpoint_scope": "keyword.gdb",
    "breakpoint_icon": "circle",
    "position_scope": "entity.name.class",
    "position_icon": "bookmark",
    "changed_variable_scope": "entity.name.class",
    "changed_variable_icon": "",

    // The group used for opening files
    "file_group": 0,

    "session_group": 1,
    "session_open": true,

    "console_group": 1,
    "console_open": true,

    "variables_group": 1,
    "variables_open": true,

    "callstack_group": 2,
    "callstack_open": true,

    "registers_group": 2,
    "registers_open": false,

    "disassembly_group": 2,
    "disassembly_open": false,
    // Set to "intel" for intel disassembly flavor. All other
    // values default to using "att" flavor.
    "disassembly_flavor": "att",

    "threads_group": 3,
    "threads_open": true,

    "breakpoints_group": 3,
    "breakpoints_open": true,

    // If set to true will push the layout before debugging
    // and pop it when debugging ends
    "push_pop_layout": true,

    // If set to true will close the gdb views when the
    // debugging session ends
    "close_views": true,

    // File to optionally write all the raw data read from and written to the gdb session and the inferior program.
    // Setting it to "stdout" will write the output to the python console
    "debug_file": "stdout",

    // Add "pending breakpoints" for symbols that are dynamically loaded from
    // external shared libraries
    "debug_ext" : false,

    // Whether to log the raw data read from and written to the gdb session and the inferior program.
    "debug": true,

    // Disables showing the error message dialog when something goes wrong
    "i_know_how_to_use_gdb_thank_you_very_much": false
}

 

 

 

{
    // All options in here can also be specified in your project settings
    // with a prepended "sublimegdb_". You probably want to
    // have something like this in your project settings:
    //
    // "settings":
    // {
    //      "sublimegdb_workingdir": "${folder:${project_path:your_executable_name}}",
    //      // NOTE: You MUST provide --interpreter=mi for the plugin to work
    //      "sublimegdb_commandline": "gdb --interpreter=mi ./your_executable_name"
    //
    // }
    // 
    // generalized pattern for using always the current open file with an executable name 
    // as the current file
    // "settings":
    // {
    //      "sublimegdb_workingdir": "${folder:${file}}",
    //      // put your arguments hear
    //      "sublimegdb_arguments": "",
    //      // NOTE: You MUST provide --interpreter=mi for the plugin to work
    //      "sublimegdb_commandline": "gdb --interpreter=mi --args ./${file_base_name}"
    //      
    //
    // }
    //
    // If you want to debug different executables as part of the same project, you can add something
    // like this to your project settings:
    //
    // "settings":
    // {
    //      "sublimegdb_executables":
    //      {
    //          "first_executable_name":
    //          {
    //              "workingdir": "${folder:${project_path:first_executable_name}}",
    //              "commandline": "gdb --interpreter=mi ./first_executable"
    //          },
    //          "second_executable_name":
    //          {
    //              "workingdir": "${folder:${project_path:second_executable_name}}",
    //              "commandline": "gdb --interpreter=mi ./second_executable"
    //          }
    //      }
    // }
    //
    // When you start debugging, you will be prompted to choose from one of your executables. Any
    // settings not specified for that project will be searched in your project settings (with a
    // sublimegdb_ prefix), then in your user settings, then in the default settings.
    //
    // (Note: if you have multiple executables, and you have a breakpoint set in a source file which
    // is not included in the current executable, you may have to set either debug_ext or
    // i_know_how_to_use_gdb_thank_you_very_much.)
    //
    // ${home}, ${project_path:}, ${folder:}, ${file} and ${file_base_name}
    // tokens can be used in 'workingdir', 'commandline', 'arguments' options.
    //
    // ${home} is replaced with the value of the HOME environment variable.
    //
    // ${project_path:} tries to find a file with the given name in all the registered project folders and
    // returns the first file found, or the original file name if none is found.
    // Example: ${project_path:main.cpp} tries to find a file named "main.cpp" relative
    // to the current project's folders. If none is found, it is replaced with "main.cpp".
    //
    // ${folder:} is replaced with the dirname of the given path.
    // Example: ${folder:/path/to/file} is replaced with "/path/to".
    // "workingdir": "/tmp",
    //
    // ${file} is replaced with absolute path to currently open file (if any)
    // Example: /home/user/main.cpp
    //
    // ${file_base_name} is replaced with name without extension of currently
    // open file (if any)
    // Example: replaced with "main" for file "/home/user/main.cpp"
    "workingdir": "/home/user/workshop/rt-thread/bsp/qemu-vexpress-a9",

    // NOTE: You MUST provide --interpreter=mi for the plugin to work
    // "commandline": "gdb --interpreter=mi ./executable",
    "commandline": "gdb-multiarch --interpreter=mi --args ./rtthread.elf",

    // Environments for running gdb and gdb server
    // Example: "env": {"DISPLAY": ":100"}
    "env": {"DISPLAY": ":100"},

    // Arguments for the program.
    // Example: to run "./executable foo bar"
    // "arguments": "foo bar"
    // To provide user input (stdin) use
    // "arguments": "< input.dat"
    "arguments": "2 6",

    // GDB Server 
    // Specify a command and working dir for launching a GDB Server
    // This is useful for dealing with "remote" servers that are actually locally 
    // connected JTAG boxes
    "server_workingdir": "notset",
    "server_commandline": "notset",

    // The command to use to run the program.
    // If you are attaching to a remote program, you
    // probably want to change this to -exec-continue
    "exec_cmd": "-exec-run",

    // Load the image to the remote target
    "load_cmd": "-target-download",

    // Immediately run the target upload connecting
    // When attaching to a remote program, you
    // may want to set this to false 
    "run_after_init": false,

    // Attempt to update stack information while the program is running
    // If your remote target does not support non-stop, set this to false
    "update_while_running" : false,

    // Attach to a remote target?  This is needed here because "-gdb-set target-async 1" must be
    // done prior to attaching
    "attach_cmd" : "target remote 127.0.0.1:1234", 
    //"attach_cmd" : "-gdb-set target remote 127.0.0.1:1234",  error

    // For the larger binaries with lot of shared libraries
    // the loading within the gdb could take much longer.
    // Configure the thread wait timeout by setting gdb_timeout
    "gdb_timeout": 200,

    // Define debugging window layout (window split)
    // first define column/row separators, then refer to them to define cells
    "layout":
    {
        "cols": [0.0, 0.33, 0.66, 1.0],
        "rows": [0.0, 0.75, 1.0],
        "cells":
        [ // c1 r1 c2 r2
            [0, 0, 3, 1], // -> (0.00, 0.00), (1.00, 0.75)
            [0, 1, 1, 2], // -> (0.00, 0.75), (0.33, 1.00)
            [1, 1, 2, 2], // -> (0.33, 0.75), (0.66, 1.00)
            [2, 1, 3, 2]  // -> (0.66, 0.75), (1.00, 1.00)
        ]
    },

    // visual stuff
    "breakpoint_scope": "keyword.gdb",
    "breakpoint_icon": "circle",
    "position_scope": "entity.name.class",
    "position_icon": "bookmark",
    "changed_variable_scope": "entity.name.class",
    "changed_variable_icon": "",

    // The group used for opening files
    "file_group": 0,

    "session_group": 1,
    "session_open": true,

    "console_group": 1,
    "console_open": true,

    "variables_group": 1,
    "variables_open": true,

    "callstack_group": 2,
    "callstack_open": true,

    "registers_group": 2,
    "registers_open": false,

    "disassembly_group": 2,
    "disassembly_open": false,
    // Set to "intel" for intel disassembly flavor. All other
    // values default to using "att" flavor.
    "disassembly_flavor": "att",

    "threads_group": 3,
    "threads_open": true,

    "breakpoints_group": 3,
    "breakpoints_open": true,

    // If set to true will push the layout before debugging
    // and pop it when debugging ends
    "push_pop_layout": true,

    // If set to true will close the gdb views when the
    // debugging session ends
    "close_views": true,

    // File to optionally write all the raw data read from and written to the gdb session and the inferior program.
    // Setting it to "stdout" will write the output to the python console
    "debug_file": "stdout",

    // Add "pending breakpoints" for symbols that are dynamically loaded from
    // external shared libraries
    "debug_ext" : false,

    // Whether to log the raw data read from and written to the gdb session and the inferior program.
    "debug": true,

    // Disables showing the error message dialog when something goes wrong
    "i_know_how_to_use_gdb_thank_you_very_much": false
}

 

参考

https://williamlfang.github.io/post/2019-02-20-sublimegdb--%E6%9B%B4%E5%A5%BD%E7%94%A8%E7%9A%84%E8%BD%BB%E9%87%8F%E7%BA%A7-debugger/

{
    "workingdir":"${folder:${file}}",
    "commandline":"gcc -ggdb3 -std=c11 ${file} -o ${file_base_name} && gdb --interpreter=mi --args ./${file_base_name}",
    // 可以直接调试 cmake 下的 bin/run 可执行文件
    //"commandline":"gdb --interpreter=mi --args ../bin/run",
    "env": {"DISPLAY": ":100"},
    "close_views": true,

    // Define debugging window layout (window split)
    // first define column/row separators, then refer to them to define cells
    "layout":
    {
        "cols": [0.0, 0.5, 1.0],
        "rows": [0.0, 0.65, 1.0],
        "cells":
        [ // c1 r1 c2 r2
            [0, 0, 1, 1], // -> (0.0, 0.0), (0.5, 0.65)
            [1, 0, 2, 1], // -> (0.5, 0.0), (0.65, 1.0)
            [0, 1, 1, 2], // -> (0.0, 0.65), (1.0, 0.5)
            [1, 1, 2, 2]  // -> (0.5, 0.65), (1.0, 1.0)
        ]
        // 布局结构
        //
        //         | c0:0          | c1:0.5        | c2:1.0
        // r0:0.0  | ------------- | ------------- |
        // ------- | c0:r0          c1:r0
        // ------- |     =0#             =1#
        // ------- |          c1:r1            c2:r1
        // r1:0.65 | ------------- | ------------- |
        // ------  | c0:r1          c1:r1
        // ------  |     =2#             =3#
        // ------- |          c1:r2            c2:r2
        // r2:1.0  | ------------- | ------------- |
    },

    // The group used for opening files
    "file_group": 0,

    "console_group": 1,
    "console_open": true,

    "session_group": 2,
    "session_open": true,

    "variables_group": 2,
    "variables_open": true,

    "callstack_group": 3,
    "callstack_open": true,

    "registers_group": 3,
    "registers_open": false,

    "disassembly_group": 3,
    "disassembly_open": true,
    // Set to "intel" for intel disassembly flavor. All other
    // values default to using "att" flavor.
    "disassembly_flavor": "intel",

    "threads_group": 3,
    "threads_open": true,

    "breakpoints_group": 3,
    "breakpoints_open": true,

}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM