Author Topic: debug vs release  (Read 1842 times)

0 Members and 1 Guest are viewing this topic.

Offline A2

  • Contributor
  • Posts: 44
debug vs release
« on: July 15, 2014, 03:49:34 pm »
I know the basic difference like debug has debug information & release have better opt settings.

1. But in embedded, debug info always remains with host, only hex files gets burned to target MCU. So what difference it made.

2. I have tried many different codes with debug or release. In both, code generated is always same. I never find it different.

3. Is there any parameter/token/macro defined in compiler settings for deug?
 

Offline Matje

  • Regular Contributor
  • *
  • Posts: 128
Re: debug vs release
« Reply #1 on: July 15, 2014, 10:53:58 pm »
I know the basic difference like debug has debug information & release have better opt settings.

1. But in embedded, debug info always remains with host, only hex files gets burned to target MCU. So what difference it made.

2. I have tried many different codes with debug or release. In both, code generated is always same. I never find it different.

3. Is there any parameter/token/macro defined in compiler settings for deug?

For 1.: Having debug info vs. not having it, but see 2. below.

For 2.: You get to (meaning "have to" if you actually care about how stuff is build) define the compiler options for a debug/release build. If you define both to use the same options there will be no difference. Your IDE may not use different code generation options by default, for it has no magic knowledge about your requirements/intentions. Easy enough, no?

For 3.: Probably yes, the documentation should describe it. A standard define (as in mentioned by the ANSI C standard) would be "NDEBUG" (meaning No Debug) for release builds.
 

Offline mazurov

  • Frequent Contributor
  • **
  • Posts: 448
  • Country: us
Re: debug vs release
« Reply #2 on: July 16, 2014, 01:01:15 am »
When you select debug build a DEBUG symbol gets defined (by default, you can find it in the IDE config and change it if you'd like).  What happens after that depends on a particular project - for example, some files may or may not be generated  or you may want to do conditional compiling depending on DEBUG being defined or not.
 

Offline AlfBaz

  • Super Contributor
  • ***
  • Posts: 2006
  • Country: au
Re: debug vs release
« Reply #3 on: July 16, 2014, 03:31:02 am »
It also depends on the target platform and your IDE. Some targets employ built in debugging hardware which can consume target resources. I've also seen people who's code works in debug mode but not in release due to this.

As has been mentioned, debug mode also prevents some optimisations which can make it very difficult to debug if they're enabled. This can also be a source for headaches, for example software delays using "for" or "while" loops that get optimised away

 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: debug vs release
« Reply #4 on: July 16, 2014, 03:33:32 am »
It also depends on the target platform and your IDE. Some targets employ built in debugging hardware which can consume target resources. I've also seen people who's code works in debug mode but not in release due to this.

As has been mentioned, debug mode also prevents some optimisations which can make it very difficult to debug if they're enabled. This can also be a source for headaches, for example software delays using "for" or "while" loops that get optimised away

And don't forget that some compilers will zero out uninitialized variables while release will have undetermined values. So your program could run fine under debug but not under release.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf