Skip to content

Conversation

dkimitsa
Copy link
Contributor

background

debugger was able to suspend thread only when code was reaching software breakpoint -- hook callback. so hitting "pause" in debugger in general wasn't doing anything if there was no hook instrumented java code running (e.g. threads are waiting on lock/sleep or running native message loop).
Also debugger wasn't picking JDWP thread statuses like sleeping/monitor etc.
debugger-wrong-thread-state

thread status

thread status was not propagated from VM (hooks) to JDWP and was solved by extending the protocol.
debugger-proper-states

changes to suspend threads

interrupt any random thread is possible by sending a signal to it. There is already two signals dedicated to RoboVM and introducing another one would be wastefully.
Lucky for us one signal was used to capture thread stack trace. Last ones also good to have when you suspend the thread. So it was extended to provide a callback to hooks infrastructure and if thread was pending for suspend -- suspend loop was running there. Debugger code was updated to support these changes in debugger-hooks protocol.

debugger-sleeping-with-stack-trace

# background: debugger was able to suspend thread only when code was reaching software breakpoint -- hook callback. so hitting "pause" in debugger in general wasn't doing anything if there was no hook instrumented java code running (e.g. threads are waiting on lock/sleep or running native message loop).
Also debugger wasn't picking JDWP thread statuses like sleeping/monitor etc.

# changes to suspend threads
interrupt any random thread is possible by sending a signal to it. There is already two signals dedicated to RoboVM and introducing another one would be wastefully.
Lucky for us one signal was used to capture thread stack trace. Last ones also good to have when you suspend the thread. So it was extended to provide a callback to hooks infrastructure and if thread was pending for suspend -- suspend loop was running there.
Debugger code was updated to support these changes in debugger-hooks protocol.
@Tom-Ski Tom-Ski added this to the 2.3.17 milestone Apr 4, 2022
@Tom-Ski Tom-Ski merged commit 7ad29fd into MobiVM:master Apr 7, 2022
@dkimitsa dkimitsa deleted the debugger/suspend_threads branch April 16, 2022 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants