Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JDI: How to pause a Java application (JVM) like in the debugger

Tags:

java

jdi

jvmti

I am looking for potentially a JDI API to pause the JVM at any arbitrary point during its execution. Looking at the BreakPointRequest createBreakpointRequest method needs a specific location. Is there any other API that does not need a location or someway to get current Location that could be passed to create a breakpoint.

I am basically looking for a way to attach and pause the application, then use JVMTI agent to receive callback for the BreakPoint event to perform further processing. Thanks

like image 681
anurag Avatar asked Jan 15 '12 04:01

anurag


1 Answers

Breakpoints only make sense with a location in source. Arbitrary pausing your application is probably best done by suspending all the threads currently running in the JVM. Take a look at SuspendThreadList() or SuspendThread in jvmti. This mechanism would be the 'pause' you are looking for.

like image 122
linuxuser27 Avatar answered Sep 27 '22 21:09

linuxuser27