Skip to main content

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

Hi Marc,
Thanks for quick answer, I will try it!
Regards,
Krasi

On Wed, Jun 22, 2011 at 4:20 PM, Marc Khouzam <marc.khouzam@xxxxxxxxxxxx> wrote:
>> -----Original Message-----
>> From: cdt-dev-bounces@xxxxxxxxxxx
>> [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Krasimir Kostadinov
>> Sent: Wednesday, June 22, 2011 7:22 AM
>> To: cdt-dev@xxxxxxxxxxx
>> Subject: [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);
>
>
> To get the value of an expression you should use
> IExpressions.getFormattedExpressionValue(...)
>
> I tried calling a method in the Expressions view and it works
> so I believe the above should fix your problem.
>
> Marc
>
>>
>> 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
>> _______________________________________________
>> cdt-dev mailing list
>> cdt-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>>
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>



-- 
Best Regards,
Krasimir Kostadinov

Contact info:
Skype Krasimir.K
mobile:
+359 893 549 105


Back to the top