Code Monkey home page Code Monkey logo

hprofdap's Introduction

hprofdap

CLI and debug adapter (DAP) that allows to inspect Java heap dumps (.hprof files) via OQL

See a demo

Build

Requires Java 22

mvn package

DAP Installation/Configuration

hprofdap communicates via stdio.

Configure a debug-adapter client to spawn:

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

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:

select file from java.io.File file
select file.path from java.io.File file
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

-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005

hprofdap's People

Contributors

mfussenegger avatar

Stargazers

 avatar

Watchers

 avatar

hprofdap's Issues

TODO for initial release

  • jlink/native image?
  • Get more complex queries to work
  • Add missing/requires protocol handlers
  • Make errors more verbose - "Internal error" is not helpful
  • Tweak variable output formatting for various types
  • Maybe add some predefined queries or special expressions like summary, dominators, gc_roots
  • Add license

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.