Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Nov 2002 13:01:55 -0800 (PST)
From:      Archie Cobbs <archie@dellroad.org>
To:        Nate Lawson <nate@root.org>
Cc:        current@FreeBSD.ORG, hackers@FreeBSD.ORG
Subject:   Re: GDB auto enter/detach patch
Message-ID:  <200211052101.gA5L1t3Y039774@arch20m.dellroad.org>
In-Reply-To: <Pine.BSF.4.21.0211051202560.11551-100000@root.org> "from Nate Lawson at Nov 5, 2002 12:07:49 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
Nate Lawson writes:
> I've put together a patch that enables a kernel on the target machine to
> detect a GDB packet and automatically enter GDB mode.  When the debugger
> detaches, it also continues execution.  This speeds up debugging,
> especially when the target is in a remote location.  The patch plus more
> explanation is at:
> 
>    http://www.root.org/~nate/freebsd/

Neat. A couple of comments:

1. I think a better abstraction of the GDB packet protocol would
   be something like this:

     struct gdb_parse {
	int		state;		/* opaque state value */
	u_int		len;		/* current packet length */
	u_int		maxlen;		/* maximum packet length */
	u_char		data[0];	/* packet data */
     };

     extern void gdb_parse_init(struct gdb_parse *p);
     extern int  gdb_parse_byte(struct gdb_parse *p);

   That is, if you're doing the state machine, why not go ahead
   and decode the packet data as well?

2. You need to handle the escape mechanism for packets containing
   "raw" data.: '$', '#', and '~' are escaped with '~' characters
   in case the the 'X' command is used.

3. I think GDB_AUTO_DETACH should be mandatory, i.e., the current
   state of affairs is a bug IMHO.

4. Does FreeBSD use the 'O' command to send ordinary serial port output
   when GDB mode is active? Haven't looked but this would be nice to
   have if it's not already there.

5. Receipt of a '$' character should always reset the state, no?
   (modulo the '~' escape mechanism mentioned above).

-Archie

__________________________________________________________________________
Archie Cobbs     *     Packet Design     *     http://www.packetdesign.com

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200211052101.gA5L1t3Y039774>