using float throws error message while debugging

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

using float throws error message while debugging

481 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by RA1981 on Sat Jun 04 00:33:21 MST 2011
Hi,

next pitfall for me :(

I use float variables in a function. Builds successfully and program seems to work, however single stepping through the code shows up the following message when execution is done on a instruction accessing a float variable:

Quote:
Can't find a source file at "../src/float.c"
Locate the file or edit the source lookup path to include its location.

So, what is it this time what I'm missing? :confused:

Regards,

Ralf
6 Replies

456 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by RA1981 on Tue Jun 07 04:45:37 MST 2011
Hi CodeRedSupport,


Quote:
It appears that the library object containing __aebi_fadd() has been  built with the debug information enabled (whereas we would normally  remove the debug information from the C library). Thus the debugger  tries to display the source - which doesn't exist in your system (as we  don't provide the library sources).


Ah, okay, so I didn't make anything wrong :)


Quote:
There are two simple workarounds here - use the "step over" rather than  "step in" operation when you step the return statement. Or else if you  end up with the error you are seeing in the debugger, then simply click  "step out".


Okay, I'll use 'step over' when stepping through single instructions.


Quote:
Anyway, sorry for the confusion this has caused you. This issue will be resolved in the next LPCXPresso release.


No problem, glad to help finding issues and improving products ;)

Regards,

Ralf
0 Kudos

454 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Tue Jun 07 02:51:45 MST 2011
Thanks for the test case.

As you may be aware, the LPC11xx does not contain floating point hardware, and so floating point operations are implemented via a software library function. Thus if we look at the disassembly for TestFloat() we can see a call to [FONT=Courier New][SIZE=1]__aeabi_fadd()[/SIZE][/FONT]:

    b = 4.5;
0x0000031a <TestFloat+10>: ldr  r3, [pc, #28]    ; (0x338 <TestFloat+40>)
0x0000031c <TestFloat+12>: str  r3, [r7, #4]
    return(a+b);
0x0000031e <TestFloat+14>: ldr  r3, [r7, #0]
0x00000320 <TestFloat+16>: ldr  r2, [r7, #4]
0x00000322 <TestFloat+18>: adds r0, r3, #0
0x00000324 <TestFloat+20>: adds r1, r2, #0
0x00000326 <TestFloat+22>: bl   0x8ec <__aeabi_fadd>
0x0000032a <TestFloat+26>: adds r3, r0, #0
}
0x0000032c <TestFloat+28>: adds r0, r3, #0
0x0000032e <TestFloat+30>: mov  sp, r7
0x00000330 <TestFloat+32>: add  sp, #8
0x00000332 <TestFloat+34>: pop  {r7, pc}
When you are stepping, you are actually using the "step in" operation. If you try to step into a function for which the image contains debug information, then the debugger will try to display the source code.

It appears that the library object containing __aebi_fadd() has been built with the debug information enabled (whereas we would normally remove the debug information from the C library). Thus the debugger tries to display the source - which doesn't exist in your system (as we don't provide the library sources).

There are two simple workarounds here - use the "step over" rather than "step in" operation when you step the return statement. Or else if you end up with the error you are seeing in the debugger, then simply click "step out".

Anyway, sorry for the confusion this has caused you. This issue will be resolved in the next LPCXPresso release.

Regards,
CodeRedSupport.

456 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by RA1981 on Mon Jun 06 23:46:50 MST 2011
Hi CodeRedSupport,


Quote:
Can you post an example that shows the problem? Zip up your project and attach it to you post.    

Attached is a ZIP file with a example.
IDE version is LPCXpresso v3.6.2 [Build 279] [29/01/2011] on WinXP 32-Bit
Test is done on a LPCXpresso LPC1114 rev.A evaluation board
Project setup is with CMSIS, no modifications (like changing used libs etc.).

This is the source code:
int main(void) {
    float fTest;

    fTest = TestFloat();
    while(1);

    return(0);
}

// test function
float TestFloat(void) {
    float a, b;

    a = 1.3;
    b = 4.5;
    return(a+b);
}
I tested it with debug configuration and single stepping through the code [F5].
In function TestFloat() the variables a and b get's the values assigned  without error, but on 'return(a+b);' the error message shows up. The  variable fTest get's the correct value 5.8.
Hope you can reproduce this on your machine.
[B]Note:[/B] This behaviour is a little different from the project where  this error message showed up. In the original project the error message  showed up on the first assignment of a value to a float variable.  Setting a breakpoint behind the float variable accesses and running to  breakpoint shows correct values when hovering the mouse over the  variable.

So, I wonder if I'm simply missing something regarding using floats  (like including some neccessary headers or libs) or have a wrong project  configuration. Since I've used other IDEs, compilers and MCUs in the  past I assume that they've done something hidden regarding C and floats.

Regards,

Ralf
0 Kudos

456 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Sun Jun 05 02:11:14 MST 2011
Can you post an example that shows the problem? Zip up your project and attach it to you post.
0 Kudos

456 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by RA1981 on Sun Jun 05 02:07:26 MST 2011
Hi StephenHawkings,


Quote:
Seems to me you need to copy "float.h" into your project's src folder.

I searched float.h and copied it from GCC newllib folder into src folder, doesn't help. I also searched float.c, but there are only small_printf_float.c and small_printf_nofloat.c available in LPCXpresso subfolders.
I don't understand why float.c is needed when simply using float variables. I assume float.c contains some special functions for float support. I don't know if it's simply a false project setting.

Regards,

Ralf
0 Kudos

456 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by StephenHawkings on Sat Jun 04 01:45:49 MST 2011
Seems to me you need to copy "float.h" into your project's src folder.
Best regards!
StephenHawkings
0 Kudos