I develop a plugin to visualization C/C++ programs during debug in Eclipse. I try to use DSF (Debugger Services Framework). I studied a lot of documentation about DSF, but I ran into problem with understanding, how to work with DSF contexts.
For beggining I open project org.eclipse.cdt.examples.dsf.gdb and start to modify it. My goal is on each debug step extract information about all stack frames (activation records), local variables, variables in heap, and global/static variables.
What I've done. I subclass service MIStack and add in its constructor event listener.
package org.eclipse.cdt.examples.dsf.gdb.service;
import org.eclipse.cdt.dsf.mi.service.MIStack;
import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.cdt.example.dsf.gdb.listener.Listener;
public class NewlMIStack extends MIStack {
public NewMIStack(DsfSession session) {
super(session);
getSession().addServiceEventListener(new Listener(), null);
}
}
By this way I realy can handle each event when user hit button "next step", "step forward", etc. In order to do it I use the following method from my class Listener:
@DsfServiceEventHandler
public void eventDispatched(MISteppingRangeEvent e) {
MIFrame frame = e.getFrame();
System.out.println(frame.getFullname()); // Same as getFile()
System.out.println("Function: " + frame.getFunction());
System.out.println("File: " + frame.getFile());
System.out.println("Frame level: " + frame.getLevel()); // Always equals zero
System.out.println("Line: " + frame.getLine());
System.out.println("Address: " + frame.getAddress());
MIArg[] args = frame.getArgs();
if (args.length > 0) {
System.out.println("Arguments:");
for (MIArg arg : args) {
System.out.println("Name: " + arg.getName());
System.out.println("Value: " + arg.getValue());
}
}
}
The problem is that it is only a little part of information that I need to extract. As I understood, other part of information (such as state of variables, types of variables, etc.) I can extract using service IExpression, and may be GDBMemory. But I don't understand how to use these services. May I some how invoke their methods from my method eventDispatched?
Also I tried to add in my event hanle method the following code:
IExpressionDMContext expressionDMC = DMContexts.getAncestorOfType(e.getDMContext(), IExpressionDMContext.class);
// getAncestorOfType always returns null
IExpressions expressionService = getServicesTracker().getService(IExpressions.class);
DataRequestMonitor<IExpressionDMData> drm = new DataRequestMonitor<>(getExecutor(), null);
expressionService.getExpressionData(expressionDMC, drm);
But due to I can't fully understand hot to work with contexts, this code didn't help me to solve my problem.
I really put in a lot of time to solve this problem, sadly without success, so I will very glad to see any comments!
May I some how invoke their methods from my method eventDispatched?
I cannot help much about the details of your implementation, but I can try to help for the following point:
But due to I can't fully understand hot to work with contexts,
I am myself trying to understand how to work with GDB contexts from the CDT DSF session. I need to read data from a different physical memory in each thread, so I need to switch the thread context to switch the memory space. What I found is the following implementation for the MI session of the DSF, and it seems to provide what we both need. MIProcesses.java on github
It is pretty hard to find a good documentation about usage! Please tell me if you have found any.
PS: I am new to SO so I don't exactly know if this is correct as an answer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.