Accessing the debug information (variables) while debugging with a plugin (Intellij)

Answered

Hi,

I was wondering if it is possible to access the debug information during a debugging session and show additional information in an IntelliJ plugin. I want to visualize the debugging process. I am looking for an API with the following capabilities:

  • Get the variables in the debug window, when a debug session is started.
  • Get the changes to the variables when the user steps forward while debugging.

Thanks in advance for any help and information!

6 comments
Comment actions Permalink

Can anyone help?

1
Comment actions Permalink

Sorry for delay, answer is being prepared.

1
Comment actions Permalink

Hi, you can start with

XDebuggerManager.getInstance(project).getCurrentSession()

it will return an instance of the current XDebugSession. Then

com.intellij.xdebugger.XDebugSession#getCurrentStackFrame

and computeChildren on the result will calculate the variables. Changes you'll have to compute yourself. A listener for

com.intellij.xdebugger.XDebugSessionListener#sessionPaused

will trigger on every debugger stop.

1
Comment actions Permalink

Thank you very much! I will try it out this weekend!

0
Comment actions Permalink

Thanks for the detailed information. It is working quite well for me!
There is one thing I was wondering about regarding the values of the objects in the XStackFrame.

How can I get the values of the fields of the objects? For example, if I have an object with a name field of type string. How can I read this value or in general the values of all fields?

With computeChildren() I obtain a XValueChildrenList. There I was looking through the attribute myValues and each particular XValue but I was not able to find the value for the fields yet. Maybe you can give me a tip.

 

Thanks in advance!

1

Please sign in to leave a comment.