Skip to content

Commit ab1a7f1

Browse files
committed
crashdump: add documentation on how to load a guest core dump in a gdb and lldb using vscode
Signed-off-by: Doru Blânzeanu <[email protected]>
1 parent 70f0486 commit ab1a7f1

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

docs/how-to-debug-a-hyperlight-guest.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,74 @@ involved in the gdb debugging of a Hyperlight guest running inside a **KVM** or
202202
└─┘ │ | | | │
203203
| └───────────────────────────────────────────────────────────────────────────────────────────────┘
204204
```
205+
206+
## Dumping the guest state to an ELF core dump when an unhandled crash occurs
207+
208+
When a guest crashes, the vCPU state is dumped to an `ELF` core dump file. This can be used to inspect the state of the guest at the time of the crash.
209+
210+
To dump the state of the vCPU (general purpose registers, registers) to an `ELF` core dump file set the feature `crashdump` and run a debug build. This will result in a dump file being created in the temporary directory.
211+
The name and location of the dump file will be printed to the console and logged as an error message.
212+
213+
### Inspecting the core dump
214+
215+
After the core dump has been created, to inspect the state of the guest, load the core dump file using `gdb` or `lldb`.
216+
A `gdb` version later than `15.0` and `lldb` version later than `17` have been used to test this feature.
217+
218+
To do this in vscode, the following configuration can be used to add debug configurations:
219+
220+
```vscode
221+
{
222+
"version": "0.2.0",
223+
"inputs": [
224+
{
225+
"id": "core_dump",
226+
"type": "promptString",
227+
"description": "Path to the core dump file",
228+
},
229+
{
230+
"id": "program",
231+
"type": "promptString",
232+
"description": "Path to the program to debug",
233+
}
234+
],
235+
"configurations": [
236+
{
237+
"name": "[GDB] Load core dump file",
238+
"type": "cppdbg",
239+
"request": "launch",
240+
"program": "${input:program}",
241+
"coreDumpPath": "${input:core_dump}",
242+
"cwd": "${workspaceFolder}",
243+
"MIMode": "gdb",
244+
"externalConsole": false,
245+
"miDebuggerPath": "/usr/bin/gdb",
246+
"setupCommands": [
247+
{
248+
"description": "Enable pretty-printing for gdb",
249+
"text": "-enable-pretty-printing",
250+
"ignoreFailures": true
251+
},
252+
{
253+
"description": "Set Disassembly Flavor to Intel",
254+
"text": "-gdb-set disassembly-flavor intel",
255+
"ignoreFailures": true
256+
}
257+
]
258+
},
259+
{
260+
"name": "[LLDB] Load core dump file",
261+
"type": "lldb",
262+
"request": "launch",
263+
"stopOnEntry": true,
264+
"processCreateCommands": [],
265+
"targetCreateCommands": [
266+
"target create -c ${input:core_dump} ${input:program}",
267+
],
268+
},
269+
]
270+
}
271+
```
272+
NOTE: The `CodeLldb` debug session does not stop after launching. To see the code, stack frames and registers you need to
273+
press the `pause` button. This is a known issue with the `CodeLldb` extension [#1245](https://github.com/vadimcn/codelldb/issues/1245).
274+
The `cppdbg` extension works as expected and stops at the entry point of the program.
275+

0 commit comments

Comments
 (0)