[<<][davinci][>>][..]
Wed Jul 22 15:19:59 CEST 2009

Setting up gdb

The idea is that I'm going to grow an application by interacting with
a live app using gdb.

1. How to run gdb on the target?  Is it installed on the OSD2?

gdb is not installed..  Let's solve that first.  I should have a
arm-...-gdb binary.  Indeed.

tom@zni:~/davinci$ arm-linux-gdb 
GNU gdb 6.3 (MontaVista 6.3-20.0.22.0501131 2005-07-23)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=armv5tl-montavista-linuxeabi".
(gdb) 

Now, how does the target side work?  The first I can find is this[1].
They say I'm looking for arm-stub.c which handlers the client side.

Hmm.. I don't find anything in 5 minutes which makes me
suspicious.. Let's try [2].  Some more for ARM7[3] and some stuff from
the Neuros OSD[4].

Looks like I need to build from source[5].

tom@zni:/opt/src/gdb-6.8/gdb/gdbserver$ CC=arm-linux-gcc ./configure --host=arm-*-linux && make

After compiling, upload `gdbserver' to the target:/usr/bin/

To use, do this on the target:

# gdbserver x:12345 ./test 
Process ./test created; pid = 922
Listening on port 12345

An on the host (from gdb manual[6] and an article[7]):

tom@zni:~/davinci$ arm-linux-gdb test
GNU gdb 6.3 (MontaVista 6.3-20.0.22.0501131 2005-07-23)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=armv5tl-montavista-linuxeabi"...
(gdb) target remote neuros:12345
Remote debugging using neuros:12345
[New Thread 952]
0x40000790 in ?? ()
(gdb) break main
Breakpoint 1 at 0xa12c
(gdb) c
Continuing.

Program exited with code 01.
(gdb) 


That doesn't seem right.  The program is:

#include <xdc/std.h>
#include <ti/xdais/xdas.h>
#include <ti/xdais/dm/xdm.h>
#include <ti/sdo/ce/CERuntime.h>
#include <ti/sdo/ce/Engine.h>
#include <ti/sdo/ce/video/viddec.h>

void foo(void) {
    printf("foo!\n");
}

int main(int argc, char **argv){              
    foo();
    return 0;
}


Maybe try again with gdbserver from 6.3?  Or maybe first build my own
gdb from source..

tom@zni:/opt/src/gdb-6.8/build$ ../configure \
  --prefix=/opt/xc/arm9 \
  --target=arm-linux-gnu \
  && make && sudo make install

This seems to work:

tom@zni:~/davinci$ ./gdb
GNU gdb 6.8
Copyright (C) 2008 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-unknown-linux-gnu --target=arm-linux-gnu"...
[New Thread 989]
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
0x40000790 in ?? ()
Breakpoint 1 at 0xa18c: file test.c, line 20.
Error while mapping shared library sections:
"/lib/libpthread.so.0": not in executable format: File format not recognized.
Error while mapping shared library sections:
"/lib/libc.so.6": not in executable format: File format not recognized.
Error while mapping shared library sections:
/lib/ld-linux.so.3: No such file or directory.
Error while reading shared library symbols:
"/lib/libpthread.so.0": can't read symbols: File format not recognized.
Error while reading shared library symbols:
"/lib/libc.so.6": can't read symbols: File format not recognized.

Breakpoint 1, main (argc=1, argv=0xbec72e94) at test.c:20
20	    foo(3);
(gdb) break bar
Breakpoint 2 at 0xa11c: file test.c, line 10.
(gdb) c
Continuing.

Breakpoint 2, bar () at test.c:10
10	    printf("bar!\n");
(gdb) bt
#0  bar () at test.c:10
#1  0x0000a168 in foo (n=0) at test.c:16
#2  0x0000a160 in foo (n=1) at test.c:15
#3  0x0000a160 in foo (n=2) at test.c:15
#4  0x0000a160 in foo (n=3) at test.c:15
#5  0x0000a194 in main (argc=1, argv=0xbec72e94) at test.c:20
(gdb) c
Continuing.

Program exited normally.
(gdb) 


Next: emacs/gud.  OK.

These are the files.  Host side, can be run in emacs as M-x gdb:

#!/bin/bash
cd `dirname $0`
[ -z "$INSIDE_EMACS" ] || EMACS="--annotate=3"
. vars
CMD=gdb.cmd
GDB=/opt/xc/arm9/bin/arm-linux-gnu-gdb
exec $GDB $EMACS -command=$CMD test

The command file `gdb.cmd':

target remote neuros:12345
break main
continue



And the target file started once over telnet, and kept open in a
buffer to see the output:

#!/bin/sh
while sleep 1; do gdbserver x:12345 test; done





[1] http://www.builderau.com.au/architect/sdi/soa/Debug-embedded-systems-with-GDB/0,339024602,320283114,00.htm
[2] http://www.kegel.com/linux/gdbserver.html
[3] http://lists.busybox.net/pipermail/uclibc/2006-July/016001.html
[4] http://wiki.neurostechnology.com/index.php/Derobert%27s_Guide_to_the_On-Screen_Display:_Developing_for_the_OSD
[5] http://ftp.gnu.org/gnu/gdb/gdb-6.8.tar.bz2 
[6] http://sources.redhat.com/gdb/onlinedocs/gdb_17.html#SEC137
[7] http://www.linux.com/archive/feature/121735



[Reply][About]
[<<][davinci][>>][..]