Forum Discussion
Strange value while debugging in Eclipse
All,
I encountered a very strange problem while debugging my application (KVM) on NiosII with uclinux from Eclipse. The value of some variable is not correct while showed from the Eclipse, when the cursor is on it or I check its expression. I even explicitly print out those variable, the result is correct. Is it a bug for Eclipse with uclinux? If yes, is there any workaround? Thanks, Neo <div class='quotetop'>QUOTE </div> --- Quote Start --- JamEnabled = FALSE; JamRepeat = FALSE; RequestedHeapSize = DEFAULTHEAPSIZE; /* --[ Neo Adding ]------------------------------------------------------- * * Debugging purpose, opps, useless code ... * * -------------------------------------------------------------------- */ printf("JamEnabled = %d\n", JamEnabled); printf("JamRepeat = %d\n", JamRepeat); printf("RequestedHeapSize = %08X\n", RequestedHeapSize);[/b] --- Quote End ---6 Replies
- Altera_Forum
Honored Contributor
Maybe you need to turn off optimization for debugging.
- Altera_Forum
Honored Contributor
I turn off optimization for debugging in fact. And the problem is still there. The variabile which is defined as enum (FALSE or TRUE) has a very huge value when I watch its value by NiosII IDE. But in fact, it has the correct value ...
- Altera_Forum
Honored Contributor
well, I also have this kind of problem. If you have a look at the assembly code, you will find the variable is assigned later (but before it is first used). If you watch its value before the actual instructions for the assignment are executed, the debug client will give you whatever in the memory location allocated to this variable, which is invalid at that point.
I thought turning off optimization can get rid of some of this kind problems, but have never bothered to try it. - Altera_Forum
Honored Contributor
So you mean the source code in .C does not match the assembly well? But some variables have the correct value, such as "argc".
Can I solve this problem if using the gdb directly? Could you show me how to debug application by gdb instead of using the GUI? May I debug the application locally by gdb, which I once tried on Linux PowerPC? Thanks, Neo - Altera_Forum
Honored Contributor
<div class='quotetop'>QUOTE </div>
--- Quote Start --- But some variables have the correct value, such as "argc"[/b] --- Quote End --- argc is different. It is an argument passed in on stack, and that memory location has the valid value as long as the main function does not return. <div class='quotetop'>QUOTE </div> --- Quote Start --- Can I solve this problem if using the gdb directly?[/b] --- Quote End --- no. I have the same problem with gdb. Besides, debuging application using gdb is a very painful manual process right now, better to stick to the GUI. - Altera_Forum
Honored Contributor
So, what is the workaround you are using now? To rely on the assembly code?
Thanks, Neo