Comment 21 for bug 1325503

Revision history for this message
Matthias Klose (doko) wrote : Re: [Bug 1325503] Re: gdb reports 'corrupt stack' on armhf without symbols

On 17.05.2018 16:03, alamaral wrote:
> The problem is that most system library code is built
> without -g, so gdb doesn't have whatever information is necessary to
> unwind the stack properly.

this is wrong. every package is built with -g, however the debug symbols are
split out into separate -dbg or dbgsym packages.

> It seems that gcc, with the -g option, adds .cfi directives into the
> assembler code, and gdb needs that info. Remove the .cfi directives and
> you get the "Backtrace stopped: previous frame identical to this frame
> (corrupt stack?)" error.
>
> Even a very simple program with subroutine calls (similar to below) will
> exhibit this problem:
>
> void foo(int i)
> {
> if (i < 100) foo(i+1);
> printf("i=%d\n", i);
> }
>
> main()
> {
> foo(0);
> }
>
> When compiled without -g each time the program calls foo the stack looks
> to gdb like it's corrupted, and only the topmost level is shown, along
> with the error. Compile with -g and everything works, at least until
> you step into printf, which wasn't compiled with -g.
>
> Once you step out of printf you'll get your stack back.
>
> This feels like a compiler bug to me, i.e. gcc __SHOULD__ generate at
> least the minimal set of .cfi directives that are needed for gdb to
> generate a backtrace, regardless of whether -g is specified or not.

is gdb using the split out debug symbols for your use case?