3 * stacksize.d - measure stack size for running threads.
4 * Written using DTrace (Solaris 10 3/05).
6 * $Id: stacksize.d 3 2007-08-01 10:50:08Z brendan $
8 * USAGE: stacksize.d # hit Ctrl-C to end sample
11 * value size of the user stack
12 * count number of samples at this size
16 * COPYRIGHT: Copyright (c) 2006 Jonathan Adams
20 * The contents of this file are subject to the terms of the
21 * Common Development and Distribution License, Version 1.0 only
22 * (the "License"). You may not use this file except in compliance
25 * You can obtain a copy of the license at Docs/cddl1.txt
26 * or http://www.opensolaris.org/os/licensing.
27 * See the License for the specific language governing permissions
28 * and limitations under the License.
32 * 16-Feb-2006 Jonathan Adams Created this.
33 * 16-Feb-2006 " " Last update.
36 #pragma D option quiet
38 this uintptr_t stkinfoptr;
39 this uintptr_t stkptr;
43 trace("Sampling... Hit Ctrl-C to end\n");
46 sched:::on-cpu, profile:::profile-997
52 sched:::on-cpu, profile:::profile-997
55 this->stkinfoptr = curthread->t_lwp->lwp_ustack;
56 this->stkptr = (uintptr_t)0;
59 sched:::on-cpu, profile:::profile-997
60 /this->stkinfoptr != 0 && curpsinfo->pr_dmodel == PR_MODEL_ILP32/
62 this->stkinfo32 = (stack32_t *)copyin(this->stkinfoptr,
64 this->stktop = (uintptr_t)this->stkinfo32->ss_sp +
65 this->stkinfo32->ss_size;
66 this->stkptr = (uintptr_t)uregs[R_SP];
69 sched:::on-cpu, profile:::profile-997
70 /this->stkinfoptr != 0 && curpsinfo->pr_dmodel == PR_MODEL_LP64/
72 this->stkinfo = (stack_t *)copyin(this->stkinfoptr,
74 this->stktop = (uintptr_t)this->stkinfo->ss_sp +
75 this->stkinfo->ss_size;
76 this->stkptr = (uintptr_t)uregs[R_SP];
79 sched:::on-cpu, profile:::profile-997
82 @sizes[execname] = quantize(this->stktop - this->stkptr);
87 @errors[execname] = count();
93 printf("\nErrors:\n");
94 printa(" %@d %s\n", @errors);