AnsweredAssumed Answered

Unable to step using gdb/gdbserver with QorIQ-SDK v1.9

Question asked by Amit Chaudhuri on Oct 19, 2016

I have hit a problem using gdbserver/gdb on our QorIQ p1020 based system.
A simple C application (see below) cross compiles and runs on the target,
exiting with the expected exit status, but dies in the debugger if I try
and step past a breakpoint.

The toolchain being used is from QorIQ-SDK-V1.9-20151210-yocto.

I'm aware of a GDB faq entry that implies that this could be due to
the stripping of libpthread on target, but have tried replacing this
with the unstripped version. Behaviour is unchanged. Also, gdb shows
that it is aware of the .debug directory when it looks for symbols for
ld-2-20.so.

I ran gdb with set debug infrun=1 and see:

infrun: clear_proceed_status_thread (Thread 5921)
infrun: proceed (addr=0xffffffff, signal=GDB_SIGNAL_DEFAULT, step=1)
infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=1, current thread [Thread 5921] at 0x100004c4
infrun: target_wait (-1, status) =
infrun: 5921 [process 5921],
infrun: status->kind = signalled, signal = GDB_SIGNAL_TRAP
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_SIGNALLED

The last line of the above apparently means "that the proram has
been terminated". And the code path goes on to close things down
and tell me so.


/* the application */

#include <stdio.h>

int
main(void)
{
int i = 10;
printf ("Value of i is %d\n", i);

return 0;
}

/* compiled as follows */

powerpc-fsl-linux-gnuspe-gcc -m32 -mcpu=8548 -mabi=spe -mspe -mfloat-gprs=double \
--sysroot=/opt/fsl-qoriq/1.9/sysroots/ppce500v2-fsl-linux-gnuspe -ggdb -o hello main.c

/* view from gdb/gdbserver */

GNU gdb (GDB) 7.8.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-fslsdk-linux --target=powerpc-fsl-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Pretty formatting of structures is on.
Currently logging to "gdb.txt".
Logs will be appended to the log file.
Output is being logged and displayed.
GDB's data directory is "/dlicu/home/chaudhak/pygdb".
Reading symbols from ./hello...done.
The current system root is "/opt/fsl-qoriq/1.9/sysroots/ppce500v2-fsl-linux-gnuspe".
Breakpoint 1 at 0x100004c4: file main.c, line 6.
(gdb) conti
The program is not being run.
(gdb) info target
Symbols from "/dlicu/home/chaudhak/prog/cross/qoriqfsl/hello/hello".
Local exec file:
`/dlicu/home/chaudhak/prog/cross/qoriqfsl/hello/hello', file type elf32-powerpc.
Entry point: 0x100002e4
0x10000114 - 0x10000121 is .interp
0x10000124 - 0x10000144 is .note.ABI-tag
0x10000144 - 0x10000168 is .note.gnu.build-id
0x10000168 - 0x10000188 is .gnu.hash
0x10000188 - 0x100001d8 is .dynsym
0x100001d8 - 0x1000022e is .dynstr
0x1000022e - 0x10000238 is .gnu.version
0x10000238 - 0x10000268 is .gnu.version_r
0x10000268 - 0x10000274 is .rela.dyn
0x10000274 - 0x10000298 is .rela.plt
0x10000298 - 0x100002e4 is .init
0x100002e4 - 0x10000624 is .text
0x10000624 - 0x10000654 is .fini
0x10000654 - 0x1000067a is .rodata
0x1000067c - 0x10000680 is .eh_frame
0x10010680 - 0x10010688 is .ctors
0x10010688 - 0x10010690 is .dtors
0x10010690 - 0x10010694 is .jcr
0x10010694 - 0x1001069c is .got2
0x1001069c - 0x10010764 is .dynamic
0x10010764 - 0x1001076c is .data
0x1001076c - 0x10010780 is .got
0x10010780 - 0x100107ec is .plt
0x100107ec - 0x100107f4 is .bss
(gdb) target rem <ip addr removed>
Remote debugging using <ip addr removed>
Reading symbols from /opt/fsl-qoriq/1.9/sysroots/ppce500v2-fsl-linux-gnuspe/lib/ld.so.1...Reading symbols from /opt/fsl-qoriq/1.9/sysroots/ppce500v2-fsl-linux-gnuspe/lib/.debug/ld-2.20.so...done.
done.
Loaded symbols for /opt/fsl-qoriq/1.9/sysroots/ppce500v2-fsl-linux-gnuspe/lib/ld.so.1
0x0ffd872c in ?? ()
(gdb) conti
Continuing.

Breakpoint 1, main () at main.c:6
6 int i = 10;
(gdb) n

Program terminated with signal SIGTRAP, Trace/breakpoint trap.
The program no longer exists.
(gdb)


root@BTHiTouchDevIss3-21:/opt/bt/bin# ./hello
Value of i is 10
root@BTHiTouchDevIss3-21:/opt/bt/bin# gdbserver host:2347 ./hello
Process ./hello created; pid = 7573
Listening on port 2347
Remote debugging from host <IP addr removed>

Child terminated with signal = 0x5 (SIGTRAP)
GDBserver exiting

Outcomes