Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] How to call existing C functions in executable file during debug session?

Hi,
Before DSF I was able to call functions and evaluate variable/array
values existing in executable program with a single code:
ICDITarget target;
ICDIStackFrame stackFrame;
....(wait on debug listener for suspend event and get target and stackFrame)...
String result = target.evaluateExpressionToString(stackFrame, "X");
where X can be variable, element of array, function, field in struct etc.

Now with DSF I'm able to read and set variables and array values with
following code, but not to call function:

IExpressionDMContext expression = expr.createExpression(dmContext,
"float_array[0]");
String formatId = IFormattedValues.NATURAL_FORMAT;
FormattedValueDMContext valueDmc =
service.getFormattedValueContext(expression, formatId);
final DataRequestMonitor<IExpressionDMData> drm = new
DataRequestMonitor<IExpressionDMData>(session.getExecutor(), null){
@Override
protected void handleCompleted() {
IExpressionDMData data = getData();
System.out.println("handleCompleted = " + getData());
}
};

final DataRequestMonitor<FormattedValueDMData> drmf = new
DataRequestMonitor<FormattedValueDMData>(session.getExecutor(), null){
@Override
protected void handleCompleted() {
FormattedValueDMData data = getData();
String formattedValue = data.getFormattedValue();
System.out.println("handleCompleted formattedValue = " + formattedValue);
}
};

service.getExpressionData(expression, drm);
service.writeExpression(expression, "42", formatId, drmf);

I tried to create function expression with :
IExpressionDMContext funcCall = expr.createExpression(dmContext,
"printX(\"5.5\")");
where printX is function in C source code (not mangled CPP function)
but getData() in DataRequestMonitor return null.

I tried to got answer from cdt/dsf plugins source but the only place
which I found uses DebugPlugin.getDefault().getExpressionManager();
But this code include my function in Expression view, where I don't
want to see it.

Can somebody give me a hint how I can do it?

BTW : I think that current DSF is much flexible then CDI and adding
new debuggers can increase popularity of Eclipse in embedded world.

--
Best Regards,
Krasimir Kostadinov


Back to the top