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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to