EmbDev.net

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


Author: Alfredo Cabral (tequilaguru)
Posted on:

Rate this post
0 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?

Author: Alfredo Cabral (tequilaguru)
Posted on:

Rate this post
0 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.

Author: Spencer Oliver (ntfreak)
Posted on:

Rate this post
0 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

Author: Alfredo Cabral (tequilaguru)
Posted on:

Rate this post
0 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

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.