This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Source file does not match PC when debugging in uVision3

Hello,

I am trying to debug some code using uVision 3.23. The code is in C++ and compiled with the version of GCC that is shipped by Keil.

When I load the image onto the target and "run to main()", the code appears to run correctly, but the debugger shows the current execution point to be in some completely unrelated header file.

Optimisation is disabled (ie. set to none). It appears to me that the debugger is incorrectly interpreting the symbol table.

I have searched the website but have not found any mention of this problem.

Any help would be appreciated.

Kind Regards,

Parents
  • "the debugger shows the current execution point to be in some completely unrelated header file."

    Normally, one would never put executable code or symbol definitions in a header; headers should contain declarations only.

    Maybe you are confusing the compiler and/or debugger by having executable code and/or symbol definitions in your header?

    Remember, the Compiler itself never actually sees header files - all it sees is the single, combined source file generated by the preprocessor...

Reply
  • "the debugger shows the current execution point to be in some completely unrelated header file."

    Normally, one would never put executable code or symbol definitions in a header; headers should contain declarations only.

    Maybe you are confusing the compiler and/or debugger by having executable code and/or symbol definitions in your header?

    Remember, the Compiler itself never actually sees header files - all it sees is the single, combined source file generated by the preprocessor...

Children
  • Normally, one would never put executable code or symbol definitions in a header; headers should contain declarations only.

    Couldn't agree more.

    Maybe you are confusing the compiler and/or debugger by having executable code and/or symbol definitions in your header?

    Absolutely not. The only exception might be a simple inline method in a class but that isn't even the case here.

    Remember, the Compiler itself never actually sees header files - all it sees is the single, combined source file generated by the preprocessor...

    Agreed. More accurately, the compiler has little concept of header or source files (because of the preprocessor). It simply knows about "the input file".

    The debugging symbols however, should provide enough information to correlate a single program memory address with a single line of source.

    This is not working.

    At times, this can be complicated by optimisation performed by the compiler. That is not an issue here as the optimiser is turned off.

    I have been writing embedded C++ for about 10 years now and embedded code in general for longer. I can assure you that the coding style is quite reasonable. This same code compiles correctly for two other processors. We are also able to debug this code for those processors however we are not using the Keil tools for those.

    The problem is in regards to correlating memory addresses on the target with the relevant source line. An example is where I download to the target and select "run". At a random time, I direct the uVision debugger to stop. It shows the current PC to be in the middle of some completely unrelated file. In one instance, the debugger indicated that the corresponding source line was a blank line at the end of a header file.

    Andy, I appreciate you taking the time to reply. Any further insight would be gratefully received.

    Kind Regards,

    Scott Finneran