You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: scripts/docs/en/userver/gdb_debugging.md
+28-7Lines changed: 28 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,16 @@
1
1
# Debugging with GDB
2
2
3
-
In the most cases writing extensive logs and running profilers is sufficient for debugging. But in the most complex cases it may be useful to do interactive debugging with GDB. Additionally, GDB is the only option for debugging coredumps. Userver provides the capability to perform such debugging.
3
+
In the most cases writing extensive logs and running profilers is sufficient for debugging. But in the most complex
4
+
cases it may be useful to do interactive debugging with GDB. Additionally, GDB is the only option for debugging
5
+
coredumps. 🐙 userver provides the capability to perform such debugging.
6
+
7
+
First of all, you can use GDB on your service based on userver just like any other binary (debug symbols are included
8
+
by default in all build types).
4
9
5
-
First of all, you can use GDB on your service based on Userver just like any other binary (debug symbols are included by default in all build types).
6
10
7
11
## Userver-specific debug features
8
12
9
-
To use Userver-specific debug features, you need to allow execution of debug scripts, linked into your binary.
13
+
To use userver-specific debug features, you need to allow execution of debug scripts, linked into your binary.
10
14
It can be done by adding the following line to your ~/.gdbinit file
11
15
```
12
16
add-auto-load-safe-path <path-to-your-binary>
@@ -17,9 +21,11 @@ add-auto-load-safe-path /
17
21
```
18
22
See [GDB manual](https://www.sourceware.org/gdb/current/onlinedocs/gdb.html/Auto_002dloading-safe-path.html) for more details.
19
23
24
+
20
25
### Custom pretty-printers
21
26
22
-
The simplest extentions for GDB, that Userver provides, are pretty-printers for certain data stuctures. Below is an example comparing the output for a `formats::json::Value` with and without pretty-printers:
27
+
The simplest extentions for GDB, that userver provides, are pretty-printers for certain data stuctures. Below is an
28
+
example comparing the output for a `formats::json::Value` with and without pretty-printers:
In addition, the output has a hierarchical structure that is displayed correctly when debugging from the IDE.
41
47
48
+
42
49
### Coroutines exploration
43
50
44
-
Userver provides GDB command `utask`, which mimics `thread` command and allows you to explore all coroutines (Userver Tasks), including running and suspended ones, in a manner similar to threads.
51
+
🐙 userver provides GDB command `utask`, which mimics `thread` command and allows you to explore all coroutines
52
+
(userver tasks), including running and suspended ones, in a manner similar to threads.
53
+
45
54
46
55
#### Commands
47
56
@@ -57,7 +66,10 @@ Task State Span
57
66
0x10f27fc42000 Running task_4
58
67
```
59
68
60
-
*`utask apply <task> <cmd...>`: Executes `<cmd...>` in the context of selected `<task>`. The `<task>` may be specified by its ID ("Task") or name ("Span") (as shown in `utask list`), or set to "all" to apply the command to all tasks. `<cmd...>` can be any GDB command, including Python scripts.
69
+
*`utask apply <task> <cmd...>`: Executes `<cmd...>` in the context of selected `<task>`. The `<task>` may be
70
+
specified by its ID ("Task") or name ("Span") (as shown in `utask list`), or set to "all" to apply the command to all
71
+
tasks. `<cmd...>` can be any GDB command, including Python scripts.
72
+
61
73
62
74
#### Examples:
63
75
@@ -108,6 +120,15 @@ For now `utask` commands are implemented for only linux x86 platforms, but can b
108
120
109
121
In addition, all of the above functionality works for debugging both a live process and coredumps.
110
122
123
+
111
124
## Adding new pretty-printers and commands
112
125
113
-
If you need a new pretty-printer or a GDB command, you can always implement it yourself in `userver/scripts/gdb` and bring us a PR!
126
+
If you need a new pretty-printer or a GDB command, you can always implement it yourself in `userver/scripts/gdb` and
0 commit comments