Forums

not enough code space to debug

Started by Bill November 14, 2008
Hi,

I'm using Rowley Associates CrossStudio for ARM v1.7 build 4 (which
relies on GCC C++ compiler) to develop a C++ program for an LPC2103.
My problem is that I'm running out of code space (flash), mainly
because some of the .cpp files I wrote have many class definitions,
even though some of those classes are never instantiated from my
application. I need to debug, so I need to keep all code optimizations
off. Is there any way, keeping optimizations off, to tell the linker
NOT to include the code for those classes that are never used by my
application?

Thank you.
Bill

"Bill" <a@a.a> wrote in message 
news:ejtqh4lmrcc9b5j7qo5ouv7kluis4iouj8@4ax.com...
> Hi, > > I'm using Rowley Associates CrossStudio for ARM v1.7 build 4 (which > relies on GCC C++ compiler) to develop a C++ program for an LPC2103. > My problem is that I'm running out of code space (flash), mainly > because some of the .cpp files I wrote have many class definitions, > even though some of those classes are never instantiated from my > application. I need to debug, so I need to keep all code optimizations > off. Is there any way, keeping optimizations off, to tell the linker > NOT to include the code for those classes that are never used by my > application?
Firstly you would be better off to put each class in a separate file so that other humans can find them then completely unreference files won't contribute to code size. Secondly make sure you don't use exception handling or run-time type info (RTTI) because the take a lot of space. See -fno-rtti -fno-exceptions. Thirdly the compiler and linker can conspire to remove unused, which might not be everything you consider unused, but the object files need to be prepared. See -ffunction-sections -fdata-sections for the compiler and -Wl,--gc-sections for linker. Peter
Bill

> I'm using Rowley Associates CrossStudio for ARM v1.7 build 4 (which > relies on GCC C++ compiler) to develop a C++ program for an LPC2103. > My problem is that I'm running out of code space (flash), mainly > because some of the .cpp files I wrote have many class definitions, > even though some of those classes are never instantiated from my > application. I need to debug, so I need to keep all code optimizations > off. Is there any way, keeping optimizations off, to tell the linker > NOT to include the code for those classes that are never used by my > application?
You need to do a "garbage collected build" using gcc options: -ffunction-sections -fdata-sections and ld options: --gc-sections Andrew
I found exactly what I needed. In this environment, the option is
called "Enable Unused Symbol Removal" (I need to set it to Yes) under
"Build Options" of the properties of your solution. I have
significantly more free code space now. Using the sept-by-step
debugger, I see that some functions of several classes don't take now
space in the chip because now I don't see dots (to the left of their
lines) where I can put breakpoints.

At the lower level (at the calls to GCC), it must be doing what you
guys said. Thank you.