Skip to content

Breakpoints in already-loaded classes don't work #139

@fancypantalons

Description

@fancypantalons

I'm not sure if this is new behaviour in ADB, but it appears that the classprepare event doesn't get triggered if the JVM has already loaded a class.

The trouble is that the plugin relies on those events to learn about classes when setting breakpoints. So if you set a breakpoint before you start the debugger, then the event is registered before the class is loaded and everything works fine.

But if you set a breakpoint after the application has started in an already-loaded class, the plugin is never notified that the class exists and so the breakpoint can never be enabled.

I've thrown together a PR that changes this behaviour so that the plugin calls getAllClasses (which doesn't actually appear to be that slow?) if a class isn't known, and only after that fails does it then register for a classprepare event so that the JVM will notify the plugin when the class finally loads.

It all seems to work, both for BPs set before the debugger is started and after its already loaded. Feel free to take a look. To be honest it feels a little hacky, and I'm sure there's a more elegant approach possible, but I'm low on sleep and pretty far outta my depth!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions