From owner-freebsd-current@FreeBSD.ORG Wed Apr 6 12:45:14 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 998191065673; Wed, 6 Apr 2011 12:45:14 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 5730C8FC15; Wed, 6 Apr 2011 12:45:14 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id DF36646B4C; Wed, 6 Apr 2011 08:45:13 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 7BE5C8A02C; Wed, 6 Apr 2011 08:45:13 -0400 (EDT) From: John Baldwin To: freebsd-current@freebsd.org Date: Wed, 6 Apr 2011 08:45:11 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <4D9A4CE5.5090900@freebsd.org> <4D9B7C92.6030901@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201104060845.11771.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Wed, 06 Apr 2011 08:45:13 -0400 (EDT) Cc: Justin Hibbits , Navdeep Parhar , FreeBSD Current Subject: Re: KGDB stack traces in the kernel. X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Apr 2011 12:45:14 -0000 On Tuesday, April 05, 2011 4:35:44 pm Navdeep Parhar wrote: > On Tue, Apr 5, 2011 at 1:33 PM, Julian Elischer wrote: > > On 4/4/11 6:04 PM, Justin Hibbits wrote: > >> > >> On Apr 4, 2011, at 6:57 PM, Julian Elischer wrote: > >>> > >>> is there anyone here with enough gdb/kgdb source experience to know what > >>> we would need to put on the stack at fork_exit() to make it stop when it > >>> gets there? > >>> > >>> not only is it annoying but it slows down debugging because kgdb and the > >>> ddd > >>> front end ask for stacks a LOT. sometimes it actually just hangs as the > >>> stack > >>> goes into a loop and never ends. > >>> > >>> I had a quick look but didn't spot how gdb decides it has reached the end > >>> of a stack. > >>> > >>> Julian > >> > >> From my experience, it checks for a NULL stack chain pointer. Once that > >> reaches NULL, it's the end of the stack. > >> > >> - Justin > >> > > I'll try adding NULL when we build the intial stack up. > > :-) > > What does ddb do? It always seems to get this stuff correct. ddb knows to stop when it gets to a non-kernel address, and it uses string compares on function names to identify trap frames. For example in sys/amd64/amd64/db_trace.c: if (strcmp(name, "calltrap") == 0 || strcmp(name, "fork_trampoline") == 0 || strcmp(name, "nmi_calltrap") == 0 || strcmp(name, "Xdblfault") == 0) frame_type = TRAP; Hah, kgdb just needs to be updated (this is from trgt_amd64.c): const struct frame_unwind * kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame) { char *pname; CORE_ADDR pc; pc = frame_pc_unwind(next_frame); pname = NULL; find_pc_partial_function(pc, &pname, NULL, NULL); if (pname == NULL) return (NULL); if (strcmp(pname, "calltrap") == 0 || strcmp(pname, "nmi_calltrap") == 0 || (pname[0] == 'X' && pname[1] != '_')) return (&kgdb_trgt_trapframe_unwind); /* printf("%s: %lx =%s\n", __func__, pc, pname); */ return (NULL); } Can probably just add 'fork_trampoline' to that conditional. I think i386 needs a similar fix in kgdb. Not sure about other architectures: Index: trgt_amd64.c =================================================================== --- trgt_amd64.c (revision 220190) +++ trgt_amd64.c (working copy) @@ -184,6 +184,7 @@ if (pname == NULL) return (NULL); if (strcmp(pname, "calltrap") == 0 || + strcmp(pname, "fork_trampoline") == 0 || strcmp(pname, "nmi_calltrap") == 0 || (pname[0] == 'X' && pname[1] != '_')) return (&kgdb_trgt_trapframe_unwind); Index: trgt_i386.c =================================================================== --- trgt_i386.c (revision 220190) +++ trgt_i386.c (working copy) @@ -374,6 +374,7 @@ if (strcmp(pname, "dblfault_handler") == 0) return (&kgdb_trgt_dblfault_unwind); if (strcmp(pname, "calltrap") == 0 || + strcmp(pname, "fork_trampoline") == 0 || (pname[0] == 'X' && pname[1] != '_')) return (&kgdb_trgt_trapframe_unwind); /* printf("%s: %llx =%s\n", __func__, pc, pname); */ -- John Baldwin