Deleted Added
full compact
procstat_kstack.c (174230) procstat_kstack.c (176107)
1/*-
2 * Copyright (c) 2007 Robert N. M. Watson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2007 Robert N. M. Watson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/usr.bin/procstat/procstat_kstack.c 174230 2007-12-03 21:21:15Z rwatson $
26 * $FreeBSD: head/usr.bin/procstat/procstat_kstack.c 176107 2008-02-08 11:03:05Z dwmalone $
27 */
28
29#include <sys/types.h>
30#include <sys/sysctl.h>
31#include <sys/user.h>
32
33#include <err.h>
34#include <errno.h>

--- 71 unchanged lines hidden (view full) ---

106
107/*
108 * Sort threads by tid.
109 */
110static int
111kinfo_kstack_compare(const void *a, const void *b)
112{
113
27 */
28
29#include <sys/types.h>
30#include <sys/sysctl.h>
31#include <sys/user.h>
32
33#include <err.h>
34#include <errno.h>

--- 71 unchanged lines hidden (view full) ---

106
107/*
108 * Sort threads by tid.
109 */
110static int
111kinfo_kstack_compare(const void *a, const void *b)
112{
113
114 return ((struct kinfo_kstack *)a)->kkst_tid -
115 ((struct kinfo_kstack *)b)->kkst_tid;
114 return ((const struct kinfo_kstack *)a)->kkst_tid -
115 ((const struct kinfo_kstack *)b)->kkst_tid;
116}
117
118static void
119kinfo_kstack_sort(struct kinfo_kstack *kkstp, int count)
120{
121
122 qsort(kkstp, count, sizeof(*kkstp), kinfo_kstack_compare);
123}
124
125
126void
127procstat_kstack(pid_t pid, struct kinfo_proc *kipp, int kflag)
128{
129 struct kinfo_kstack *kkstp, *kkstp_free;
130 struct kinfo_proc *kip, *kip_free;
131 char trace[KKST_MAXLEN];
116}
117
118static void
119kinfo_kstack_sort(struct kinfo_kstack *kkstp, int count)
120{
121
122 qsort(kkstp, count, sizeof(*kkstp), kinfo_kstack_compare);
123}
124
125
126void
127procstat_kstack(pid_t pid, struct kinfo_proc *kipp, int kflag)
128{
129 struct kinfo_kstack *kkstp, *kkstp_free;
130 struct kinfo_proc *kip, *kip_free;
131 char trace[KKST_MAXLEN];
132 int error, i, j, name[4];
132 int error, name[4];
133 unsigned int i, j;
133 size_t kip_len, kstk_len;
134
135 if (!hflag)
136 printf("%5s %6s %-16s %-16s %-29s\n", "PID", "TID", "COMM",
137 "TDNAME", "KSTACK");
138
139 name[0] = CTL_KERN;
140 name[1] = KERN_PROC;

--- 105 unchanged lines hidden ---
134 size_t kip_len, kstk_len;
135
136 if (!hflag)
137 printf("%5s %6s %-16s %-16s %-29s\n", "PID", "TID", "COMM",
138 "TDNAME", "KSTACK");
139
140 name[0] = CTL_KERN;
141 name[1] = KERN_PROC;

--- 105 unchanged lines hidden ---