You are here

debugger starts in wrong code location | Cypress Semiconductor

debugger starts in wrong code location

Summary: 6 Replies, Latest post by Bob Marlowe on 01 Oct 2016 07:44 AM PDT
Verified Answers: 3
Last post
Log in to post new comments.
toneal30_1860441's picture
User
6 posts

Currently trying to debug a CYBLE-022001 using Kitprog CY8CKIT-024-BLE.  Programming the device works fine and the checksum is verified, however when starting a debug session the debugger halts in the wrong code location (it halts in some random bluetooth handling code, which is not even called) rather than main.c.  The debugger consistently halts in the wrong place even after multiple cleans and rebuilds so I'm thinking it's using the wrong symbols or something to find out where main is?  Or it's maybe getting confused as to which source file contains main?

When the debugger is launched, the "Call Stack" looks OK (has main() at the top), except for the "File" column, which is showing the wrong source file (should be main.c but it's a different file, the file that it's showing doesn't even have a main() method anywhere).

I should note that I'm trying to re-use some code files from another project (I edited the "additional include directories" of the compiler under "Build Settings" to include a folder from another project).  Perhaps this is messing up the compilation/symbol assimilation process?  If I use one of the example projects, the debugger halts in the correct location and everything appears to work fine.  Suggestions for getting this working?  I've already tried rebooting, cleaning, rebuilding both projects, etc.

 

 

HIMA's picture
Cypress Employee
320 posts

Hello ,

 

Can you check what is the Compiler optimization in "Build Settings"? Can you you set the optimization to "Debug" and check if you still faces the issue.

 

Thanks,

Hima

toneal30_1860441's picture
User
6 posts

Setting the Compiler optimization to "Debug" changed things a little bit, but did not fix the overall problem.  The debugger now starts in main(), but when I try to "step into" a function call, the debugger incorrectly jumps back to the random bluetooth code.  Strangely, when I set the Compiler optimization back to "None", it now starts in main() but still incorrectly jumps to a (different) wrong code location when "stepping into" a function call.

If I look in the output window I see "The target program has stopped at: file: BLEM.c line: 345 function: test_sanity address: 0x00000304".  test_sanity() is the correct function that I called, but test_sanity() is not inside BLEM.c.

toneal30_1860441's picture
User
6 posts

OK, so I've figured out a way to (seemingly) fix this, but it's very strange.  I took the offending file (BLEM.c in my case) and I removed it and its corresponding header BLEM.h from the project, then re-added it back in.  Rebuilt and now debugger works fine.

 Not sure if I ran into some weird bug in Visual Studio or something.  I'll update here if the problem reoccurs, or if I can find steps to reproduce it.

toneal30_1860441's picture
User
6 posts

So the problem reoccurs every once in a while after modifying some code and rebuilding.  Each time I am able to fix it by removing the offending .c and .h file and rebuilding, then readding them back.  This will be ok for the time being but it's quite an ugly workaround.

toneal30_1860441's picture
User
6 posts

In case anybody reads this, the problem seems to be related to breakpoints.  Leaving breakpoints from a previous debugging session seems to cause the problem.  Removing all breakpoints before building seems to cause it to work every time.

user_1377889's picture
User
10112 posts

Thank you for sharing your experiences with us!

 

Bob

Log in to post new comments.