Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12627 Discussions

Strange value while debugging in Eclipse

Altera_Forum
Honored Contributor II
1,253 Views

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 ---  

0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
349 Views

Maybe you need to turn off optimization for debugging.

0 Kudos
Altera_Forum
Honored Contributor II
349 Views

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 ...

0 Kudos
Altera_Forum
Honored Contributor II
349 Views

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.
0 Kudos
Altera_Forum
Honored Contributor II
349 Views

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
0 Kudos
Altera_Forum
Honored Contributor II
349 Views

<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.
0 Kudos
Altera_Forum
Honored Contributor II
349 Views

So, what is the workaround you are using now? To rely on the assembly code? 

 

Thanks, 

Neo
0 Kudos
Reply