EmbDev.net

Forum: ARM programming with GCC/GNU tools -gc-sections breaking debugger


von Alfredo C. (tequilaguru)


Rate this post
useful
not useful
Hi,

I been working on a set of tools for a lpc2387 board I developed,

I built openocd(trunk), gcc(4.3.2) and insight(6.8) under Cygwin, those
work very well, I have scrips to download code and to debug the target.
Those work great as well, but I have a problem.

If a build the code with:

LINKER_FLAGS=-nostartfiles -Xlinker -o$(BUILDDIR)/lpc2387.elf -Xlinker
-M -Wl,-Map=$(BUILDDIR)/lpc2387.map,--cref,--gc-sections

and

CFLAGS= $(DEBUG) \
    $(OPTIM) \
    -T$(LDSCRIPT) \
    -mcpu=arm7tdmi \
    -I$(INCLUDEPATH)\
    -D PACK_STRUCT_END=__attribute\(\(packed\)\) \
    -D ALIGN_STRUCT_END=__attribute\(\(aligned\(4\)\)\) \
    -fomit-frame-pointer \
    -mthumb-interwork  \
          -ffreestanding    \
          -ffunction-sections     \
         -fdata-sections    \

The debugger won't allow me to step over to the next line of code, if I
remove the -gc-sections parameter (thus removing dead code elimination)
the debugger will work as expected.

Although the debugger is working, is very annoying to have to step line
per line of code, I can set temporal breakpoints but may be someone had
this problem before?

von Alfredo C. (tequilaguru)


Rate this post
useful
not useful
Alfredo Cabral wrote:

Further examination reveals, it was only with the first function.

The rest of the debugging session works as expected.

von Spencer O. (ntfreak)


Rate this post
useful
not useful
Alfredo Cabral wrote:
> Alfredo Cabral wrote:
>
> Further examination reveals, it was only with the first function.
>
> The rest of the debugging session works as expected.

generally if using -gc-sections breaks your code then you need to check
the linker script.

Do you have the KEEP sections correctly defined (usually on the reset
vector)?

Cheers
Spen

von Alfredo C. (tequilaguru)


Rate this post
useful
not useful
Spencer Oliver wrote:
> Alfredo Cabral wrote:
>> Alfredo Cabral wrote:
>>
>> Further examination reveals, it was only with the first function.
>>
>> The rest of the debugging session works as expected.
>
> generally if using -gc-sections breaks your code then you need to check
> the linker script.
>
> Do you have the KEEP sections correctly defined (usually on the reset
> vector)?
>
> Cheers
> Spen

Spen,

The code compiled and linked fine, the thing is, while debugging it was
impossible to step over a function, Insight jumped into everytime,
however this only happened on a very specific binary, most compiles work
ok, and those that exhibit anomalies, only do so on the very first
function. It drove me nuts at some point because I thought this wasn't
an isolated case, but as I explained above, turns out it was.

Cheers
Alfredo

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.