17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5346799e8SJonathan W Adams * Common Development and Distribution License (the "License"). 6346799e8SJonathan W Adams * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*c9a6ea2eSBryan Cantrill 227c478bd9Sstevel@tonic-gate /* 23*c9a6ea2eSBryan Cantrill * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _MDB_FINDSTACK_H 277c478bd9Sstevel@tonic-gate #define _MDB_FINDSTACK_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <mdb/mdb_modapi.h> 30*c9a6ea2eSBryan Cantrill #include <sys/param.h> 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 337c478bd9Sstevel@tonic-gate extern "C" { 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 36*c9a6ea2eSBryan Cantrill typedef struct findstack_info { 37*c9a6ea2eSBryan Cantrill uintptr_t *fsi_stack; /* place to record frames */ 38*c9a6ea2eSBryan Cantrill uintptr_t fsi_sp; /* stack pointer */ 39*c9a6ea2eSBryan Cantrill uintptr_t fsi_pc; /* pc */ 40*c9a6ea2eSBryan Cantrill uintptr_t fsi_sobj_ops; /* sobj_ops */ 41*c9a6ea2eSBryan Cantrill uint_t fsi_tstate; /* t_state */ 42*c9a6ea2eSBryan Cantrill uchar_t fsi_depth; /* stack depth */ 43*c9a6ea2eSBryan Cantrill uchar_t fsi_failed; /* search failed */ 44*c9a6ea2eSBryan Cantrill uchar_t fsi_overflow; /* stack was deeper than max_depth */ 45*c9a6ea2eSBryan Cantrill uchar_t fsi_panic; /* thread called panic() */ 46*c9a6ea2eSBryan Cantrill uchar_t fsi_max_depth; /* stack frames available */ 47*c9a6ea2eSBryan Cantrill } findstack_info_t; 48*c9a6ea2eSBryan Cantrill 49*c9a6ea2eSBryan Cantrill #define FSI_FAIL_BADTHREAD 1 50*c9a6ea2eSBryan Cantrill #define FSI_FAIL_NOTINMEMORY 2 51*c9a6ea2eSBryan Cantrill #define FSI_FAIL_THREADCORRUPT 3 52*c9a6ea2eSBryan Cantrill #define FSI_FAIL_STACKNOTFOUND 4 53*c9a6ea2eSBryan Cantrill 54*c9a6ea2eSBryan Cantrill typedef struct stacks_module { 55*c9a6ea2eSBryan Cantrill char sm_name[MAXPATHLEN]; /* name of module */ 56*c9a6ea2eSBryan Cantrill uintptr_t sm_text; /* base address of text in module */ 57*c9a6ea2eSBryan Cantrill size_t sm_size; /* size of text in module */ 58*c9a6ea2eSBryan Cantrill } stacks_module_t; 59*c9a6ea2eSBryan Cantrill 607c478bd9Sstevel@tonic-gate extern int findstack(uintptr_t, uint_t, int, const mdb_arg_t *); 617c478bd9Sstevel@tonic-gate extern int findstack_debug(uintptr_t, uint_t, int, const mdb_arg_t *); 62346799e8SJonathan W Adams 63*c9a6ea2eSBryan Cantrill /* 64*c9a6ea2eSBryan Cantrill * The following routines are implemented in findstack.c, shared across both 65*c9a6ea2eSBryan Cantrill * genunix and libc. 66*c9a6ea2eSBryan Cantrill */ 67346799e8SJonathan W Adams extern int stacks(uintptr_t, uint_t, int, const mdb_arg_t *); 68346799e8SJonathan W Adams extern void stacks_cleanup(int); 697c478bd9Sstevel@tonic-gate 70*c9a6ea2eSBryan Cantrill /* 71*c9a6ea2eSBryan Cantrill * The following routines are specific to their context (kernel vs. user-land) 72*c9a6ea2eSBryan Cantrill * and are therefore implemented in findstack_subr.c (of which each of genunix 73*c9a6ea2eSBryan Cantrill * and libc have their own copy). 74*c9a6ea2eSBryan Cantrill */ 75*c9a6ea2eSBryan Cantrill extern void stacks_help(void); 76*c9a6ea2eSBryan Cantrill extern int stacks_findstack(uintptr_t, findstack_info_t *, uint_t); 77*c9a6ea2eSBryan Cantrill extern void stacks_findstack_cleanup(); 78*c9a6ea2eSBryan Cantrill extern int stacks_module(stacks_module_t *); 79*c9a6ea2eSBryan Cantrill 80*c9a6ea2eSBryan Cantrill extern int findstack_debug_on; 81*c9a6ea2eSBryan Cantrill 82*c9a6ea2eSBryan Cantrill #define fs_dprintf(x) \ 83*c9a6ea2eSBryan Cantrill if (findstack_debug_on) { \ 84*c9a6ea2eSBryan Cantrill mdb_printf("findstack debug: "); \ 85*c9a6ea2eSBryan Cantrill /*CSTYLED*/ \ 86*c9a6ea2eSBryan Cantrill mdb_printf x ; \ 87*c9a6ea2eSBryan Cantrill } 88*c9a6ea2eSBryan Cantrill 897c478bd9Sstevel@tonic-gate #ifdef __cplusplus 907c478bd9Sstevel@tonic-gate } 917c478bd9Sstevel@tonic-gate #endif 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate #endif /* _MDB_FINDSTACK_H */ 94