Skip to content

Update GNU Makefiles to generate DEBUG binaries #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2014

Conversation

oliviermartin
Copy link
Contributor

  • '-g' has been added for all the build to produce debugging information. '-g' allows to get the symbols when debugging with GDB.
  • introduce the macro 'DEBUG' to enable/disable build optimization.

Limitations:

  • Support in non-Makefile projects has been added.

* '-g' has been added for all the build to produce debugging information. '-g' allows to get the symbols when debugging with GDB.
* introduce the macro 'DEBUG' to enable/disable build optimization.

Limitations:
* Support in non-Makefile projects has been added.
@bogdanm
Copy link
Contributor

bogdanm commented Mar 25, 2014

Hi,

Thanks for your contribution. The idea is good, but it needs a bit more work. What it does right now is simply remove the current optimization option (-Os) and add the debug flag instead (-g). This can easily introduce backward compatibility issues. The right way to do this is to add a new option to the export scripts (see for example '-o' in get_default_option_parser() from workspace_tools/options.py and the way that's used in various places). Also, you're using -g3 for disco_f407vg, but just -g for the rest of the targets. Is there a particular reason for this?

Thanks,
Bogdan

@oliviermartin
Copy link
Contributor Author

  • To answer the question about gcc_arm_disco_f407vg.tmpl .
    '-g3' was already present in the Makefile for this platform. I am only move it from the end of the line to the beginning of the line to match the other Makefile
-CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -g3
+CC_FLAGS = $(CPU) -c -g3 -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections
  • Thanks for pointing me to workspace_tools/options.py. Actually '-g' is already supported, workspace_tools/toolchains/gcc.py:
            if "debug-info" in self.options:
            common_flags.append("-g")

The point of this patch is to easily be able to debug binaries with CMSIS-DAP. Without '-g' you would not see the symbols in GDB.
Currently, there is no way to enable this 'workspace_tools' option when users export their project from the online compiler to their offline GCC project. They need to hack their Makefile to get it working.

With my change, the '-Os' is still the default optimization. By default DEBUG is not be set, so the build flags fall back on 'CC_FLAGS += -DNDEBUG -Os'.
The way to turn off optimization (-O0) is to build with make DEBUG=1.

This change would also help implementing this feature: https://mbed.org/forum/bugs-suggestions/topic/4356/

@bogdanm
Copy link
Contributor

bogdanm commented Mar 25, 2014

My bad, I've completely missed the the 'ifeq' part of your patches. Yes, that's perfect.
One last thing before I merge this: have you signed https://mbed.org/contributor_agreement/ ? It's a required step for all mbed contributors.

Thanks,
Bogdan

@oliviermartin
Copy link
Contributor Author

No problem ;-)

Yes I have signed the contributor agreement: "You accepted the Contributor Agreement on Tue 18 Feb 2014."

bogdanm added a commit that referenced this pull request Mar 25, 2014
Update GNU Makefiles to generate DEBUG binaries
@bogdanm bogdanm merged commit cb306a5 into ARMmbed:master Mar 25, 2014
@bogdanm
Copy link
Contributor

bogdanm commented Mar 25, 2014

Thanks!

pan- pushed a commit to pan-/mbed that referenced this pull request May 29, 2020
Define BLE BUTTON for NUCLEO_WB55RG ,and handles button pull-up direction variations for targets
ccli8 pushed a commit to ccli8/mbed-os that referenced this pull request Aug 13, 2024
* Fix USB instructions for Ubuntu, fix greentea compile failure for devices without TRNG

* Don't compile device key without COMPONENT_FLASHIAP

* Fix some upload issues for LPC1768

* Oops don't commit cmake variants

* Don't build connectivity-netsocket-tls without TRNG support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants