Skip to content

Instantly share code, notes, and snippets.

@coder543
Created August 18, 2015 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coder543/632a2aa965946a5c25b3 to your computer and use it in GitHub Desktop.
Save coder543/632a2aa965946a5c25b3 to your computer and use it in GitHub Desktop.

I had been writing code happily throughout the summer without any need for gdb, thanks to the helpful nature of my digital logic analyzer, and some serial printf statements. However, those methods only work when C++ is operating within expected standards. What I experienced Friday was inconsistent with the code I had written -- function arguments that held nothing in common with the values passed to them, local variables more complex than a simple float unable to retain meaningful values, and a variety of other oddities that were extremely localized within the update_Qstate function. A few hours of data collection on Friday, and the analysis of said data, allowed me to isolate the issues to a single function.

It is highly unlikely that GCC is to blame. My code is far more likely to be faulty in a situation like this, but I've been able to find no evidence of a fault in my code that would cause the results mentioned above. So, today I configured a proper debug environment, and I can now use GDB to step through code execution. One thing I noticed is that the issues I had Friday could not be reproduced. Three primary variables have changed since then:

  • The code was compiled with the DEBUG flag enabled, which for this code means it should have had zero optimizations applied.
  • The compiler is now running on an x86 laptop, instead of an ARM SBC.
  • The compiler is likely a different version (I haven't checked, but there's a high probability).

Those are the only significant things that have changed that I'm aware of. I will be testing without the DEBUG flag tomorrow to see if I can reproduce and fix the issues.

I also plan to write some more documentation on the code, and hopefully see about that Kalman filter if I can.

This summer has certainly been an adventure.

@BartMassey
Copy link

Probably a structure layout thing. I can look at it if you like.

Adventures are what PSU GSoC is for. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment