Skip to content

Commit 562c6ec

Browse files
committed
add gdb-commands.md file
1 parent cb1e09f commit 562c6ec

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/cpp/gdb-commands.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
Order:
3+
Area: cpp
4+
TOCTitle: Setup Help for GDB-COMMANDS
5+
ContentId: 1097b015-54b7-4e87-afc9-25a36e7357e8
6+
PageTitle: The execution order of GDB commands to set up GDB
7+
DateApproved: 1/22/2024
8+
MetaDescription: The execution order of GDB commands
9+
---
10+
11+
# The execution order of GDB commands to set up GDB
12+
13+
In the VS code environment, there are some ways to set up GDB when debugging C/C++ applications:
14+
15+
1. `.gdbinit` file in the directory indicated by the `"cwd"` field in the `launch.json`
16+
2. `"setupCommands"` filed in `launch.json`
17+
3. `"postRemoteConnectCommands"` filed in `launch.json`
18+
19+
When starting debugging, the working directory for gdb is specified by the "cwd" field in `launch.json`. When gdb is launched, it automatically searches for the `.gdbinit` file in the working directory and executes the commands from `.gdbinit`. And then, GDB will execute the commands from `"setupCommands"` filed and `"postRemoteConnectCommands"` filed. The difference between `setupCommands` and `postRemoteConnectCommands` is that `setupCommands` are executed before loading the debug target, while `postRemoteConnectCommands` are executed after loading the debug target.

0 commit comments

Comments
 (0)