Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mfussenegger/hprofdap
CLI and debug adapter (DAP) that allows to inspect Java heap dumps (.hprof files) via OQL
https://github.com/mfussenegger/hprofdap
dap debug-adapter debug-adapter-protocol hprof java oql
Last synced: 11 days ago
JSON representation
CLI and debug adapter (DAP) that allows to inspect Java heap dumps (.hprof files) via OQL
- Host: GitHub
- URL: https://github.com/mfussenegger/hprofdap
- Owner: mfussenegger
- Created: 2024-05-26T17:20:45.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-05-27T20:14:52.000Z (7 months ago)
- Last Synced: 2024-12-24T15:58:25.585Z (12 days ago)
- Topics: dap, debug-adapter, debug-adapter-protocol, hprof, java, oql
- Language: Java
- Homepage:
- Size: 11.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `hprofdap`
CLI and debug adapter (DAP) that allows to inspect Java heap dumps (.hprof files) via OQL
[See a demo](https://social.fussenegger.pro/system/media_attachments/files/112/506/312/700/884/993/original/f231c3535e15f3b9.mp4)
## Build
Requires Java 22
```bash
mvn package
```## DAP Installation/Configuration
`hprofdap` communicates via stdio.
Configure a debug-adapter client to spawn:
```bash
java \
-Dpolyglot.engine.WarnInterpreterOnly=false \
-jar path/to/repo/target/hprofdap-0.1.0-jar-with-dependencies.jar
```Currently only the `launch` type is supported with one additional configuration
property: `filepath`, which is expected to be a absolute path to the `.hprof` file
you want to analyze.### nvim-dap example
```lua
dap.adapters.hprof = {
type = "executable",
command = os.getenv("JDK22") .. "/bin/java", -- or just "java"
args = {
"-Dpolyglot.engine.WarnInterpreterOnly=false",
"-jar",
vim.fn.expand("~/path/to/hprofdap/target/hprofdap-1.0-jar-with-dependencies.jar"),
}
}
dap.configurations.java = {
{
name = "hprof",
request = "launch",
type = "hprof",
filepath = function()
return require("dap.utils").pick_file({
executables = false,
filter = "%.hprof$"
})
end,
},
}
```## Usage
A `.hprof` file cannot be executed, therefore most of the functionality
available during a regular debug session won't work. There are no breakpoints
to hit, no stopped events, or anything like that.Instead you can query the heap dump via `OQL` via the debug adapter's client's
evaluate functionality.Some examples of `OQL` queries:
```oql
select file from java.io.File file
``````oql
select file.path from java.io.File file
``````oql
select s from int[] s where s.length > 4000
```## Development
### Debugging
Start `hprofdap` with `jdwp` enabled and use the bundled `.vscode/launch.json`
attach configuration```text
-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
```