Skip to content

Commit c7296f7

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 4b55039 commit c7296f7

File tree

1 file changed

+67
-4
lines changed

1 file changed

+67
-4
lines changed

docs/debugging-hyperlight.md

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,74 @@ Alternatively, this can be enabled when running a test from the command line:
3737
cargo test --package hyperlight-host --test integration_test --features print_debug -- static_stack_allocate --exact --show-output
3838
```
3939

40-
## Dumping the memory configuration, virtual processor register state and memory contents on a crash or unexpected VM Exit
41-
42-
To dump the details of the memory configuration, the virtual processors register state and the contents of the VM memory set the feature `crashdump` and run a debug build. This will result in a dump file being created in the temporary directory. The name and location of the dump file will be printed to the console and logged as an error message.
40+
## Dumping the guest state to an ELF core dump
41+
42+
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.
43+
The name and location of the dump file will be printed to the console and logged as an error message.
44+
45+
### Inspecting the core dump
46+
47+
After the core dump has been created, to inspect the state of the guest, load the core dump file using `gdb` or `lldb`.
48+
A `gdb` version later than `15.0` and `lldb` version later than `17` have been used to test this feature.
49+
50+
To do this in vscode, the following configuration can be used to add debug configurations:
51+
52+
```vscode
53+
{
54+
"version": "0.2.0",
55+
"inputs": [
56+
{
57+
"id": "core_dump",
58+
"type": "promptString",
59+
"description": "Path to the core dump file",
60+
},
61+
{
62+
"id": "program",
63+
"type": "promptString",
64+
"description": "Path to the program to debug",
65+
}
66+
],
67+
"configurations": [
68+
{
69+
"name": "[GDB] Load core dump file",
70+
"type": "cppdbg",
71+
"request": "launch",
72+
"program": "${input:program}",
73+
"coreDumpPath": "${input:core_dump}",
74+
"cwd": "${workspaceFolder}",
75+
"MIMode": "gdb",
76+
"externalConsole": false,
77+
"miDebuggerPath": "/usr/bin/gdb",
78+
"setupCommands": [
79+
{
80+
"description": "Enable pretty-printing for gdb",
81+
"text": "-enable-pretty-printing",
82+
"ignoreFailures": true
83+
},
84+
{
85+
"description": "Set Disassembly Flavor to Intel",
86+
"text": "-gdb-set disassembly-flavor intel",
87+
"ignoreFailures": true
88+
}
89+
]
90+
},
91+
{
92+
"name": "[LLDB] Load core dump file",
93+
"type": "lldb",
94+
"request": "launch",
95+
"stopOnEntry": true,
96+
"processCreateCommands": [],
97+
"targetCreateCommands": [
98+
"target create -c ${input:core_dump} ${input:program}",
99+
],
100+
},
101+
]
102+
}
103+
```
104+
NOTE: The `CodeLldb` debug session does not stop after launching. To see the code, stack frames and registers you need to
105+
press the `pause` button. This is a known issue with the `CodeLldb` extension [#1245](https://github.com/vadimcn/codelldb/issues/1245).
106+
The `cppdbg` extension works as expected and stops at the entry point of the program.
43107

44-
There are no tools at this time to analyze the dump file, but it can be useful for debugging.
45108

46109
## Debugging guests
47110

0 commit comments

Comments
 (0)