- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I started to use the IDE debug environment on Tuesday. So far it looks cool, however I had some problems last night. When I did multiple single steps, the PC was executing lines of C code at random (so it seemed). It was not sequential. I even pulled out of the IDE and ran the nios2-debug (GNU) and it did the same thing. Looks like the assembly is not in sync with the C code. Breakpoints worked, but when I modified variables the program did not behave as I expected. Is there some option that I accidentaly enabled? I had it working before without this issue....
RickLink Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Classic debug problem: compiler optimization... makes things act very strange when debugging and appear to "jump around". I suggest you go into your source & syslib project's "properties" in the IDE and locate C/C++ build options, turn optimization off (-O0).
You should also be able to just selet "Debug" (vs. "Release") in the same part of the GUI to do this, then re-compile. Note: you should do this for BOTH your application and the syslib project.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi guys,
What if there is a need to debug with optimized code? How can things be kept in sync? Rob http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/huh.gif- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Keeping it in sync. as in debugging it in the linear fashion instead of jumping around? I think that would be even more confusing since that is not what the compiled optimized code is doing.
It is good practice to debug everything with no optimization first (if possible) and work out the bugs functionally then you optimize it to get some extra speed/smaller memory footprint. If there is problems there then you take a look at the debugger with the optimized code to see what the compiler did to break your previously working functionality.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Perhaps this is the wrong place to post this, but as a software engineer, I do not trust all compiler's optimization without running in the debug environment first. They can sometimes do wierd stuff to your code. If the optimization doen't work, but the non-optimized does, how are you supposed to debug it? The Nios2 debugger is the first debugger that I have ever used that does not debug optimized code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As a hard- and software engineer, I do not trust compilers at all ;-) I have seen strange behavior with optimized code with different debuggers, I suppose that is in the nature of the optimization (how can you step e.g. through a for-loop that was simply optimized away?). And I have spent hours of searching errors that turned out to be compiler-bugs...
Thomas- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by rppolicy@Jan 3 2005, 12:07 PM perhaps this is the wrong place to post this, but as a software engineer, i do not trust all compiler's optimization without running in the debug environment first. they can sometimes do wierd stuff to your code. if the optimization doen't work, but the non-optimized does, how are you supposed to debug it? the nios2 debugger is the first debugger that i have ever used that does not debug optimized code. --- Quote End --- rpppolicy, The Nios2 debugger does debug optimised code. Your original complaint was that the debugger jumps around the C code. This is simply because the compiler has re-orderred the code for optimal efficiency, so the debugger follows the code sequence which is executed. This is in common with many debuggers
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page