How to use gdb debugging in vscode

Linda Hamilton
Release: 2020-02-12 14:00:50
Original
10167 people have browsed it

How to use gdb debugging in vscode

1. vscode starts the debug window

Press Ctrl Shift D to open the Debug window

The default is "No configurations", click "F5", You will be prompted to configure GDB parameters (select gcc build and debug active file). The configuration file name is launch.json (Configuration Reference 3)

After the configuration is completed, press F5 again, you will be prompted to configure GCC, select "Configure Task", select "C/C: build and debug active file", the configuration file name is task.json (Configuration Reference 2)

2. GCC Configuration

{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "type": "shell", "label": "gcc build active file", "command": "/usr/share/mips-gcc-4.6/staging_dir/bin/mips-linux-gcc", "args": [ "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}" ], "options": { "cwd": "/usr/bin" }, "problemMatcher": [ "$gcc" ] } ] }
Copy after login

"command": Compile Chain address

3. GDB configuration

{ // 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": "gcc build and debug active file", "type": "cppdbg", "request": "launch", "miDebuggerServerAddress": "192.168.0.1:10000", "program": "/home/renyinshan/work/p53/apps/cmdlib/test", "args": [], "stopAtEntry": true, "cwd": "/home/renyinshan/work/p53/apps/cmdlib/", "environment": [], "externalConsole": false, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "gcc build active file", "miDebuggerPath": "/home/renyinshan/work/p53/apps/gdb/install/bin/mips-linux-gdb" } ] }
Copy after login

"program": The name of the program to be debugged (including the path, preferably an absolute path to avoid trouble)

"miDebuggerServerAddress" : The address and port of the server

"cwd": The path of the debugging level

"miDebuggerPath": The path of gdb

4. GDB server compilation and operation

1) Compile

When compiling P53, please turn on the following switch; P59 needs to copy one from the compilation chain directory.

scripts/tozedap-router_4g_industry/config.tozedap-router_4g_industry:564:export NO_CPP_LIB=0 GDB运行需要libstdc++.so.6的库,所以需要把此开关打开。
Copy after login
./cool 3 gdb_build 等待完成即可
Copy after login

The compiled files are as follows:

renyinshan@renyinshan:~/work/p53/build$ ls ../apps/gdb/install/* ../apps/gdb/install/bin: mips-linux-gdb mips-linux-gdb-add-index mips-linux-run ../apps/gdb/install/include: gdb ../apps/gdb/install/lib: libmips-linux-sim.a ../apps/gdb/install/share: gdb info locale man renyinshan@renyinshan:~/work/p53/build$ ls ../apps/gdb/installgdbserver/bin/ mips-linux-gdbserver renyinshan@renyinshan:~/work/p53/build$
Copy after login

Instructions:

The mips-linux-gdb in the install/bin directory is required for configuration in vscode;

installgdbserver/bin/ The mips-linux-gdbserver in the directory needs to be copied to the board;

2) Log in to the device via ssh, download gdbserver to the /tmp directory, and add x permissions

3) Log in to the device via ssh, download the executable program to the /tmp directory, and add x permissions

4) Run

/tmp # ./mips-linux-gdbserver :10000 ./test 调试输出: /tmp # ./mips-linux-gdbserver :10000 test Process /tmp/test created; pid = 22608 Listening on port 10000 Remote debugging from host 192.168.0.245 APP is running!
Copy after login

Remarks:
1) Download the executable program , it must be ensured that it is compiled with the compilation chain required by the device;
2) When pressing F5 to debug in vscode, refer to 1 and 2 for GCC compilation configuration and GDB;

5, debugging

Ready to complete, debug in VSCode.

Related recommendations:vscode tutorial

The above is the detailed content of How to use gdb debugging in vscode. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!