Skip to content

Support ELF core dump creation on guest crash #417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 62 additions & 4 deletions docs/debugging-hyperlight.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,69 @@ Alternatively, this can be enabled when running a test from the command line:
cargo test --package hyperlight-host --test integration_test --features print_debug -- static_stack_allocate --exact --show-output
```

## Dumping the memory configuration, virtual processor register state and memory contents on a crash or unexpected VM Exit

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.
## Dumping the guest state to an ELF core dump

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.
The name and location of the dump file will be printed to the console and logged as an error message.

After the core dump has been created, to inspect the state of the guest, load the core dump file using `gdb` or `lldb`.
To do this in vscode, the following configuration can be used to add debug configurations:
```vscode
{
"version": "0.2.0",
"inputs": [
{
"id": "core_dump",
"type": "promptString",
"description": "Path to the core dump file",
},
{
"id": "program",
"type": "promptString",
"description": "Path to the program to debug",
}
],
"configurations": [
{
"name": "[GDB] Load core dump file",
"type": "cppdbg",
"request": "launch",
"program": "${input:program}",
"coreDumpPath": "${input:core_dump}",
"cwd": "${workspaceFolder}",
"MIMode": "gdb",
"externalConsole": false,
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
},
{
"name": "[LLDB] Load core dump file",
"type": "lldb",
"request": "launch",
"stopOnEntry": true,
"processCreateCommands": [],
"targetCreateCommands": [
"target create -c ${input:core_dump} ${input:program}",
],
},
]
}
```
NOTE: The `CodeLldb` debug session does not stop after launching. To see the code, stack frames and registers you need to
press the `pause` button. This is a known issue with the `CodeLldb` extension [#1245](https://github.com/vadimcn/codelldb/issues/1245).
The `cppdbg` extension works as expected and stops at the entry point of the program.

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

## Debugging guests

Expand Down
1 change: 1 addition & 0 deletions src/hyperlight_host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ tempfile = { version = "3.19", optional = true }
serde_yaml = "0.9"
anyhow = "1.0"
metrics = "0.24.2"
elfcore = { git = "https://github.com/dblnz/elfcore.git", branch = "split-linux-impl-from-elfcore" }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be change after the elfcore PR is merged


[target.'cfg(windows)'.dependencies]
windows = { version = "0.61", features = [
Expand Down
Loading