Debugger and Optimization

Running e2 and newest supplied GCC (4.9 something).  SSP 1.2.0B1

Debugging here is really interesting.   Either the optimizer is screwing things up or the breakpoints are being placed in screwy places.


Note this snippet:

I've got a breakpoint on line 126 and 130 (sequential lines of code) -- attempting to catch things before and right after the FetchDirectory() call.  Note the addresses of these (says these are in sequential spots as shown in code).

FetchDirectory is in another file which calls a function in yet another file.  If this is an optimization thing, the optimizer is doing code analysis across multiple files to do it.

When I run this, the second breakpoint triggers first (!) and THEN the first breakpoint on the line prior.

If this is the actual code execution, then (since AudioBusy is a global variable), this could well be changing behaviour of code execution.  As it turns out, this doesn't in this particular case because the downstream code in FetchDirectory doesn't use that variable, but it certain could be without an optimizer knowing about it.

  • Hi rlj,

    You can adjust optimization settings in Project > Properties > C/C++ Build > Settings > Tool Settings tab > Optimization. For debugging, you can choose -Og or -O0 optimization level. Available options are listed here:

  • In reply to adboc:

    According to that document, -O0 is default. Looks like this project of mine (which got created from scratch) is -O2 so the toolset is making -O2 default which then makes debugging more than a little interesting.

    Might want to make -Og or -O0 default when creating a project.
  • In reply to rjl:

    -O0 is default for GCC in general, however -O2 is default for Synergy. When the application works with -O2, then it will work with -O0 as well. This is default setting to show high quality of the SSP. You might easily change this setting, as for now it's not possible to make -Og or -O0 default when creating a project.