From owner-svn-src-all@freebsd.org Fri Sep 11 03:56:05 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 62E8B9CCFBE; Fri, 11 Sep 2015 03:56:05 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3A0AA1C4A; Fri, 11 Sep 2015 03:56:05 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t8B3u53t083865; Fri, 11 Sep 2015 03:56:05 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t8B3u5pQ083864; Fri, 11 Sep 2015 03:56:05 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201509110356.t8B3u5pQ083864@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 11 Sep 2015 03:56:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287646 - head/share/man/man9 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 03:56:05 -0000 Author: markj Date: Fri Sep 11 03:56:04 2015 New Revision: 287646 URL: https://svnweb.freebsd.org/changeset/base/287646 Log: Document stack_save_td(9) and stack_save_td_running(9). Reviewed by: wblock Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D3243 Modified: head/share/man/man9/stack.9 Modified: head/share/man/man9/stack.9 ============================================================================== --- head/share/man/man9/stack.9 Fri Sep 11 03:54:37 2015 (r287645) +++ head/share/man/man9/stack.9 Fri Sep 11 03:56:04 2015 (r287646) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 16, 2011 +.Dd September 10, 2015 .Dt STACK 9 .Os .Sh NAME @@ -36,9 +36,11 @@ .Sh SYNOPSIS .In sys/param.h .In sys/stack.h +.Pp In the kernel configuration file: .Cd "options DDB" .Cd "options STACK" +.Pp .Ft struct stack * .Fn stack_create "void" .Ft void @@ -63,6 +65,10 @@ In the kernel configuration file: .Fn stack_sbuf_print_ddb "struct sbuf sb*" "const struct stack *st" .Ft void .Fn stack_save "struct stack *st" +.Ft void +.Fn stack_save_td "struct stack *st" "struct thread *td" +.Ft int +.Fn stack_save_td_running "struct stack *st" "struct thread *td" .Sh DESCRIPTION The .Nm @@ -86,6 +92,16 @@ Memory associated with a trace is freed .Pp A trace of the current kernel thread's call stack may be captured using .Fn stack_save . +.Fn stack_save_td +and +.Fn stack_save_td_running +can also be used to capture the stack of a caller-specified thread. +Callers of these functions must own the thread lock of the specified thread. +.Fn stack_save_td +can capture the stack of a kernel thread that is not running or +swapped out at the time of the call. +.Fn stack_save_td_running +can capture the stack of a running kernel thread. .Pp .Fn stack_print and @@ -130,6 +146,23 @@ The utility functions and .Nm stack_put may be used to manipulate stack data structures directly. +.Sh RETURN VALUES +.Fn stack_put +returns 0 on success. +Otherwise the +.Dv struct stack +does not contain space to record additional frames, and a non-zero value is +returned. +.Pp +.Fn stack_save_td_running +returns 0 when the stack capture was successful and a non-zero error number +otherwise. +In particular, +.Er EAGAIN +is returned if the thread was running in user mode at the time that the +capture was attempted, and +.Er EOPNOTSUPP +is returned if the operation is not implemented. .Sh SEE ALSO .Xr ddb 4 , .Xr printf 9 ,