From owner-freebsd-hackers@FreeBSD.ORG Sat Sep 18 18:26:38 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0798E1065673 for ; Sat, 18 Sep 2010 18:26:38 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id ACB4B8FC0A for ; Sat, 18 Sep 2010 18:26:37 +0000 (UTC) Received: by qwg5 with SMTP id 5so2998504qwg.13 for ; Sat, 18 Sep 2010 11:26:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=O06q6jKsHAn9hWr71J0lIm64cO/vjmlV00nTX8p5rRM=; b=cMUvxEpR7zZ0LIEGv5VpyhTjhEvIn9QvMQtVSw1pUxE4grBqU+JAtTSUjUi5rHRuZB OQrWKKlTIGreV9IPZSq1EriYQ2jXexq4vFMKWyUIfMxau8ThbphTa4JcUPklMI7BaTMw CAwFyAAoQgAiBEMRNKoCTv17LuPz0yOWpXyLE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=mOUDoK9yWEwiBaiyMTK+qMdpA/SObvX6JujEIsQOEu3wXf0IBVUE9DTamSLH43RgFk XPyUV/pKQ9/LlqGZiBWmWEg78+VjVSadScvUshSvhLMAlqlK3ppvhhzEYios8qy9xENe IONrda3j8MUjFjj+QtzWJ3LZUIEOkapHzIf90= MIME-Version: 1.0 Received: by 10.224.28.145 with SMTP id m17mr4477091qac.196.1284834396771; Sat, 18 Sep 2010 11:26:36 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.229.235.143 with HTTP; Sat, 18 Sep 2010 11:26:36 -0700 (PDT) In-Reply-To: <4C94A138.8050905@icyb.net.ua> References: <4C94A138.8050905@icyb.net.ua> Date: Sat, 18 Sep 2010 20:26:36 +0200 X-Google-Sender-Auth: 6GFItXLAkcVaIihHlDlIKx2a62U Message-ID: From: Attilio Rao To: Andriy Gapon Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org Subject: Re: KDB_TRACE and no backend X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Sep 2010 18:26:38 -0000 2010/9/18 Andriy Gapon : > > Here's a small patch that adds support for printing stack trace in form o= f frame > addresses when KDB_TRACE is enabled, but there is no debugger backend con= figured. > The patch is styled after "cheap" variant of stack_ktr. > > What do you think (useful/useless, correct, etc) ? > > --- a/sys/kern/subr_kdb.c > +++ b/sys/kern/subr_kdb.c > @@ -37,6 +37,7 @@ > =C2=A0#include > =C2=A0#include > =C2=A0#include > +#include > =C2=A0#include > > =C2=A0#include > @@ -295,10 +296,16 @@ > =C2=A0void > =C2=A0kdb_backtrace(void) > =C2=A0{ > + =C2=A0 =C2=A0 =C2=A0 struct stack st; > + =C2=A0 =C2=A0 =C2=A0 int i; > > - =C2=A0 =C2=A0 =C2=A0 if (kdb_dbbe !=3D NULL && kdb_dbbe->dbbe_trace != =3D NULL) { > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("KDB: stack bac= ktrace:\n"); > + =C2=A0 =C2=A0 =C2=A0 printf("KDB: stack backtrace:\n"); > + =C2=A0 =C2=A0 =C2=A0 if (kdb_dbbe !=3D NULL && kdb_dbbe->dbbe_trace != =3D NULL) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0kdb_dbbe->dbbe_tra= ce(); > + =C2=A0 =C2=A0 =C2=A0 else { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 stack_save(&st); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for (i =3D 0; i < st.d= epth; i++) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 printf("#%d %p\n", i, (void*)(uintptr_t)st.pcs[i]); > =C2=A0 =C2=A0 =C2=A0 =C2=A0} > =C2=A0} You have to eventually wrap this logic within the 'STACK' option (opt_stack.h for the check) because stack_save() will be uneffective otherwise. STACK should be mandatory for DDB I guess, but it is not for KDB. Thanks, Attilio --=20 Peace can only be achieved by understanding - A. Einstein