From owner-freebsd-current Tue Nov 5 13:15:53 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7460637B406; Tue, 5 Nov 2002 13:15:51 -0800 (PST) Received: from InterJet.dellroad.org (adsl-63-194-81-26.dsl.snfc21.pacbell.net [63.194.81.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id A73CD43E42; Tue, 5 Nov 2002 13:15:50 -0800 (PST) (envelope-from archie@dellroad.org) Received: from arch20m.dellroad.org (arch20m.dellroad.org [10.1.1.20]) by InterJet.dellroad.org (8.9.1a/8.9.1) with ESMTP id NAA36573; Tue, 5 Nov 2002 13:02:19 -0800 (PST) Received: from arch20m.dellroad.org (localhost [127.0.0.1]) by arch20m.dellroad.org (8.12.6/8.12.6) with ESMTP id gA5L1uZE039775; Tue, 5 Nov 2002 13:01:56 -0800 (PST) (envelope-from archie@arch20m.dellroad.org) Received: (from archie@localhost) by arch20m.dellroad.org (8.12.6/8.12.6/Submit) id gA5L1t3Y039774; Tue, 5 Nov 2002 13:01:55 -0800 (PST) From: Archie Cobbs Message-Id: <200211052101.gA5L1t3Y039774@arch20m.dellroad.org> Subject: Re: GDB auto enter/detach patch In-Reply-To: "from Nate Lawson at Nov 5, 2002 12:07:49 pm" To: Nate Lawson Date: Tue, 5 Nov 2002 13:01:55 -0800 (PST) Cc: current@FreeBSD.ORG, hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL88 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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-current" in the body of the message