Hi,

I've made some progress getting Insight, gdb, and gdbserver to compile and actually work! Though with some issues, of course...

Here's the thing. I've been using the 01302007 uClinux setup on M5329EVB evaluation board from Freescale/LogicPD using the ColdFire 5329 microcontroller. I did the setup starting with Freescale's AN3408 application note, along with the supplied patches. uClinux was up and running in no time, with little actual pain. Getting remote debugging, however, has been extremely painful for me.

Here's what works, at least basic functionality. I grabbed insight-6.6.tar.bz2 from http://sourceware.org/insight/downloads.php. I create a new userland application directory (e.g. user/rsg/insight) and unpack the sources there (e.g. user/rsg/insight/insight-6.6). I make the usual modifications to config.in and Configure.help. For a Makefile, I modified something I found on the mailing list from Per Hallsmark (a "glue makefile") as per the attached file. Finally, I needed to patch one file to make breakpoints work, again from something I found (and sadly, lost) on the web. Specifically, one definition in the file insight-6.6/gdb/config/m68k/tm-monitor.h needs to be changed - look for the following:

   --#define DECR_PC_AFTER_BREAK 0
   ++#define DECR_PC_AFTER_BREAK 2   /* RSG - was 0 */

This should give you a uClinux build with gdbserver on it, and host-side Insight/gdb executables - you will have to go to the insight-6.6 build directory and do a "make install", of course ;-). I can now debug remotely using either gdb or Insight! Cool! Breakpoints work (thanks to the tm-monitor.h patch). I can inspect simple variables, such as integers. However, when I attempt to view a local string, the target crashes:

   Bad page state in process 'gdbserver'
   page:41b36fe0 flags:0x00000000 mapping:00000000 mapcount:1 count:0
   Trying to fix it up, but a reboot is needed
   Backtrace:
   Stack from 4160dec8:<0>
          <0> 00000000<0> 4160ded8<0> 4004328c<0> 00000000<0>
   4160defc<0> 40043ab4<0> 41b36fe0<0> 00000004<0>
          <0> 00000004<0> fffffffc<0> 00000000<0> 40048d04<0>
   41b36fe0<0> 4160df0c<0> 40043b4e<0> 41b36fe0<0>
          <0> 00000000<0> 4160df28<0> 40046130<0> 41b36fe0<0>
   00000000<0> 40048d04<0> 4160df70<0> 4160df74<0>
          <0> 4160df34<0> 4004656c<0> 41b36fe0<0> 4160df78<0>
   4002f554<0> 41b36fe0<0> fffffffc<0> 41c00610<0>
          <0> 41623e3e<0> fffffffc<0> 00000000<0> 0000001a<0>
   00000000<0> 41c00610<0> 41620eac<0> 41620004<0>
          <0> 401f41d0<0> 401f4204<0> 41b36fe0<0> 4020734e<0>
   4160dfa4<0> 4002117a<0> 41c00610<0> fffffffc<0>
   Call Trace:<0>
          <0> [<4002f978>]<0> [<4002f91e>]<0> [<40023c7e>]<0>

The attached files "host.txt" and "target.txt" contain the host and target side transcripts of such a crash.

Are there additional patches I need to make this work better?

Also, assuming I can get this figured out, what is the best way for sharing my experiences with the community at large? I've spent too much time on this, and would like to save someone else at least some of the grief!

Thanks!
-Bob
adman uClinux-dist # m68k-uclinux-gdb user/rsg/hello/hello.gdb
GNU gdb 6.6
Copyright (C) 2006 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=m68k-uclinux"...
(gdb) set debug remote 1
(gdb) target remote 192.168.1.27:3000
Remote debugging using 192.168.1.27:3000
Sending packet: $qSupported#37...Ack
Packet received: PacketSize=7cf;qXfer:auxv:read+
Packet qSupported (supported-packets) is supported
Sending packet: $Hc-1#09...Ack
Packet received: E01
Sending packet: $qC#b4...Ack
Packet received:
Sending packet: $qOffsets#4b...Ack
Packet received: Text=41630040;Data=416346E4;Bss=416346E4
Sending packet: $?#3f...Ack
Packet received: T050f:4163bf88;0e:00000000;11:41630048;
0x41630048 in _start ()
Sending packet: $qSymbol::#5b...Ack
Packet received: OK
Packet qSymbol (symbol-lookup) is supported
(gdb) l
Sending packet: $m4163005c,2#91...Ack
Packet received: 4e56
Sending packet: $m4163005e,2#93...Ack
Packet received: fff0
Sending packet: $m41630060,2#5f...Ack
Packet received: 48d7
Sending packet: $m41630060,4#61...Ack
Packet received: 48d72c00
13      #include <stdint.h>
14      #include <getopt.h>
15
16      #define MAX_NAME_SIZE   32
17
18      int main(int argc, char *argv[]) {
19        char* name;
20        int len;
21
22        printf("Hello, world!\n");
(gdb) l
23        printf("Can I be more specific?  Enter your name: ");
24        fflush(stdout);
25        name = malloc(MAX_NAME_SIZE);
26        getline(&name, MAX_NAME_SIZE, stdin);
27        len = strlen(name);
28        name[--len] = 0;
29        printf("\n\nWell, hello %s!\n", name);
30        printf("  (Len = %d\n", len);
31        return 0;
32      }
(gdb) go 30
Undefined command: "go".  Try "help".
(gdb) until 30
Sending packet: $Z0,416300ec,2#0a...Ack
Packet received:
Packet Z0 (software-breakpoint) is NOT supported
Sending packet: $m416300ec,2#c1...Ack
Packet received: 4fef
Sending packet: $X416300ec,0:#e4...Ack
Packet received: OK
binary downloading suppported by target
Sending packet: $X416300ec,2:NO#83...Ack
Packet received: OK
Sending packet: $vCont?#49...Ack
Packet received: vCont;c;C;s;S
Packet vCont (verbose-resume) is supported
Sending packet: $vCont;c#a8...Ack
Packet received: T050f:4163bf0c;0e:4163bf40;11:416300ee;
Sending packet: $Hg0#df...Ack
Packet received: E01
Sending packet: $p0#a0...Ack
Packet received:
Sending packet: $g#67...Ack
Packet received: 
00000013000000014163bf9c41623f884039f9c14163a00400000031000000004163a2d800000001415afc00000000034039fb884163a0044163bf404163bf0c00000000416300ee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Sending packet: $P11=416300ec#e5...Ack
Packet received:
Sending packet: 
$G00000013000000014163bf9c41623f884039f9c14163a00400000031000000004163a2d800000001415afc00000000034039fb884163a0044163bf404163bf0c00000000416300ec000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000#27...Ack
Packet received: OK
Sending packet: $X416300ec,2:O�#24...Ack
Packet received: OK
Sending packet: $m4163bf48,4#cf...Ack
Packet received: 00000001
Sending packet: $m4163bf4c,4#fa...Ack
Packet received: 4163bf94
main (argc=1, argv=0x4163bf94) at hello.c:30
30        printf("  (Len = %d\n", len);
(gdb) print len
$1 = 3
(gdb) print name
Sending packet: $mfffffffd,4#fb...Ack
Timed out.
Timed out.
Timed out.
Ignoring packet error, continuing...
Reply contains invalid hex digit 116
(gdb)

# Glue Makefile for Insight/GDB
#
# Author: Robert S. Grimes
#
# Note: This is borrowed HEAVILY from work by Per Hallsmark.  All credit should
#       be directed towards Per - Thanks!  
#         - Bob
#

PKG=insight-6.6

HOST=
HOST_ENV=CC= CFLAGS=

TGT=m68k-uclinux
TGT_ENV=

all: build_host build_target
#all: build_target

$(PKG)/build/Makefile:
        mkdir $(PKG)/build
        cd $(PKG)/build && $(HOST_ENV) ../configure --target=$(TGT) 
--with-sysroot

build_host: $(PKG)/build/Makefile
        $(MAKE) -C $(PKG)/build

$(PKG)/build-$(TGT)/gdbserver/Makefile:
        mkdir -p $(PKG)/build-$(TGT)/gdbserver
        cd $(PKG)/build-$(TGT)/gdbserver && $(TGT_ENV) 
../../gdb/gdbserver/configure --host=$(TGT)
        
build_target: $(PKG)/build-$(TGT)/gdbserver/Makefile
        $(MAKE) -C $(PKG)/build-$(TGT)/gdbserver

romfs:
        $(ROMFSINST) $(PKG)/build-$(TGT)/gdbserver/gdbserver /bin/gdbserver

clean:
        $(RM) -r $(PKG)/build $(PKG)/build-$(TGT)
/> gdbserver :3000 /bin/hello
Process /bin/hello created; pid = 26
Listening on port 3000
Remote debugging from host 192.168.1.107
Hello, world!
Can I be more specific?  Enter your name: Bob


Well, hello Bob!
Bad page state in process 'gdbserver'
page:41b36fe0 flags:0x00000000 mapping:00000000 mapcount:1 count:0
Trying to fix it up, but a reboot is needed
Backtrace:
Stack from 4160dec8:<0>
       <0> 00000000<0> 4160ded8<0> 4004328c<0> 00000000<0> 4160defc<0> 
40043ab4<0> 41b36fe0<0> 00000004<0>
       <0> 00000004<0> fffffffc<0> 00000000<0> 40048d04<0> 41b36fe0<0> 
4160df0c<0> 40043b4e<0> 41b36fe0<0>
       <0> 00000000<0> 4160df28<0> 40046130<0> 41b36fe0<0> 00000000<0> 
40048d04<0> 4160df70<0> 4160df74<0>
       <0> 4160df34<0> 4004656c<0> 41b36fe0<0> 4160df78<0> 4002f554<0> 
41b36fe0<0> fffffffc<0> 41c00610<0>
       <0> 41623e3e<0> fffffffc<0> 00000000<0> 0000001a<0> 00000000<0> 
41c00610<0> 41620eac<0> 41620004<0>
       <0> 401f41d0<0> 401f4204<0> 41b36fe0<0> 4020734e<0> 4160dfa4<0> 
4002117a<0> 41c00610<0> fffffffc<0>
Call Trace:<0>
       <0> [<4002f978>]<0> [<4002f91e>]<0> [<40023c7e>]<0>

/* Target machine definitions for a generic m68k monitor/emulator.
   Copyright 1986, 1987, 1989, 1993, 1994, 1995, 1996, 1998, 1999, 2003
   Free Software Foundation, Inc.

   This file is part of GDB.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

/* The definitions here are appropriate for several embedded m68k-based
   targets, including IDP (rom68k), BCC (cpu32bug), and EST's emulator.  */

/* GCC is probably the only compiler used on this configuration.  So
   get this right even if the code which detects gcc2_compiled. is
   still broken.  */

#define BELIEVE_PCC_PROMOTION 1

/* The target system handles breakpoints.  */

#define DECR_PC_AFTER_BREAK 2   /* RSG - was 0*/

/* No float registers.  */

/*#define NUM_REGS 18 */

/* FIXME, should do GET_LONGJMP_TARGET for newlib.  */
_______________________________________________
uClinux-dev mailing list
[email protected]
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by [email protected]
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to