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?

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1325503

Title:
  gdb reports 'corrupt stack' on armhf without symbols

To manage notifications about this bug go to:
https://bugs.launchpad.net/gdb-linaro/+bug/1325503/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to