英文:
How to put non-blocking breakpoint in JDI (Java Debug Interface)?
问题
当您在JDI(Java Debug Interface)中有一个BreakpointEvent
或StepEvent
时,发生的情况是当前正在执行的程序(被调试程序)被暂停,直到调试器处理完断点事件并恢复被调试程序。但是,如果有很多断点,即使调试器每次收到断点事件后立即恢复被调试程序(调试器和被调试程序之间的通信是通过套接字或共享内存进行的,这不是即时的),这会变得很慢。
但是,如果您想要构建一个工具,只需获取事件信息并稍后处理它们(例如,在构建分析器时等),您如何设置这些断点以不暂停程序?或换句话说,如何以异步方式从运行中的程序中提取堆栈跟踪和变量信息?
英文:
When you have a BreakpointEvent
or StepEvent
in JDI (Java Debug Interface), what happens is that the currently executing program(debugee) is suspended until the debugger processes the breakpoint event and resumes the debugee.
But if you have many breakpoints this becomes slow, even if the debugger resumes the debugee immediately each time it receives a breakpoint event (communication between debugger and debugee is over sockets or shared memory which is not instant).
But if you'd like to build a tool where you just need the events' information to store them and process them later (e.g. when building a profiler etc.) how can you set these breakpoints not to suspend the program? Or in other words, how can stack traces and variable information be extracted from the running program in an asynchronous way?
专注分享java语言的经验与见解,让所有开发者获益!
评论