kern_ktr.c (69880) | kern_ktr.c (70035) |
---|---|
1/* 2 * Copyright (c) 2000 3 * John Baldwin <jhb@FreeBSD.org>. 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 --- 12 unchanged lines hidden (view full) --- 21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * THE POSSIBILITY OF SUCH DAMAGE. 28 * | 1/* 2 * Copyright (c) 2000 3 * John Baldwin <jhb@FreeBSD.org>. 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 --- 12 unchanged lines hidden (view full) --- 21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * THE POSSIBILITY OF SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/kern/kern_ktr.c 69880 2000-12-12 00:43:50Z jhb $ | 29 * $FreeBSD: head/sys/kern/kern_ktr.c 70035 2000-12-15 00:01:20Z jhb $ |
30 */ 31 32/* 33 * This module holds the global variables used by KTR and the ktr_tracepoint() 34 * function that does the actual tracing. 35 */ 36 | 30 */ 31 32/* 33 * This module holds the global variables used by KTR and the ktr_tracepoint() 34 * function that does the actual tracing. 35 */ 36 |
37#include "opt_ddb.h" |
|
37#include "opt_ktr.h" 38 | 38#include "opt_ktr.h" 39 |
40#include <sys/param.h> |
|
39#include <sys/types.h> | 41#include <sys/types.h> |
42#include <sys/cons.h> |
|
40#include <sys/time.h> 41#include <sys/ktr.h> 42#include <sys/libkern.h> 43#include <sys/linker_set.h> 44#include <sys/sysctl.h> 45#include <sys/systm.h> 46#include <machine/globals.h> 47#include <machine/stdarg.h> 48 | 43#include <sys/time.h> 44#include <sys/ktr.h> 45#include <sys/libkern.h> 46#include <sys/linker_set.h> 47#include <sys/sysctl.h> 48#include <sys/systm.h> 49#include <machine/globals.h> 50#include <machine/stdarg.h> 51 |
52#include <ddb/ddb.h> 53 |
|
49#ifndef KTR_MASK 50#define KTR_MASK (KTR_GEN) 51#endif 52 53#ifndef KTR_CPUMASK 54#define KTR_CPUMASK (~0) 55#endif 56 --- 90 unchanged lines hidden (view full) --- 147 entry->ktr_desc = format; 148 entry->ktr_parm1 = arg1; 149 entry->ktr_parm2 = arg2; 150 entry->ktr_parm3 = arg3; 151 entry->ktr_parm4 = arg4; 152 entry->ktr_parm5 = arg5; 153#endif 154} | 54#ifndef KTR_MASK 55#define KTR_MASK (KTR_GEN) 56#endif 57 58#ifndef KTR_CPUMASK 59#define KTR_CPUMASK (~0) 60#endif 61 --- 90 unchanged lines hidden (view full) --- 152 entry->ktr_desc = format; 153 entry->ktr_parm1 = arg1; 154 entry->ktr_parm2 = arg2; 155 entry->ktr_parm3 = arg3; 156 entry->ktr_parm4 = arg4; 157 entry->ktr_parm5 = arg5; 158#endif 159} |
160 161#ifdef DDB 162 163struct tstate { 164 int cur; 165 int first; 166}; 167static struct tstate tstate; 168static int db_ktr_verbose; 169static int db_mach_vtrace(void); 170 171DB_COMMAND(tbuf, db_mach_tbuf) 172{ 173 174 tstate.cur = (ktr_idx - 1) & (KTR_ENTRIES - 1); 175 tstate.first = -1; 176 if (strcmp(modif, "v") == 0) 177 db_ktr_verbose = 1; 178 else 179 db_ktr_verbose = 0; 180 db_mach_vtrace(); 181 182 return; 183} 184 185DB_COMMAND(tall, db_mach_tall) 186{ 187 int c; 188 189 db_mach_tbuf(addr, have_addr, count, modif); 190 while (db_mach_vtrace()) { 191 c = cncheckc(); 192 if (c != -1) 193 break; 194 } 195 196 return; 197} 198 199DB_COMMAND(tnext, db_mach_tnext) 200{ 201 202 if (strcmp(modif, "v") == 0) 203 db_ktr_verbose ^= 1; 204 db_mach_vtrace(); 205} 206 207static int 208db_mach_vtrace(void) 209{ 210 struct ktr_entry *kp; 211 212 if (tstate.cur == tstate.first) { 213 db_printf("--- End of trace buffer ---\n"); 214 return (0); 215 } 216 kp = &ktr_buf[tstate.cur]; 217 218 /* Skip over unused entries. */ 219#ifdef KTR_EXTEND 220 if (kp->ktr_desc[0] != '\0') { 221#else 222 if (kp->ktr_desc != NULL) { 223#endif 224 db_printf("%d: ", tstate.cur); 225 if (db_ktr_verbose) 226 db_printf("%4ld.%06ld ", kp->ktr_tv.tv_sec, 227 kp->ktr_tv.tv_nsec / 1000); 228#ifdef KTR_EXTEND 229#ifdef SMP 230 db_printf("cpu%d ", kp->ktr_cpu); 231#endif 232 if (db_ktr_verbose) 233 db_printf("%s.%d\t", kp->ktr_filename, kp->ktr_line); 234 db_printf("%s", kp->ktr_desc); 235#else 236 db_printf(kp->ktr_desc, kp->ktr_parm1, kp->ktr_parm2, 237 kp->ktr_parm3, kp->ktr_parm4, kp->ktr_parm5); 238#endif 239 db_printf("\n"); 240 } 241 242 if (tstate.first == -1) 243 tstate.first = tstate.cur; 244 245 if (--tstate.cur < 0) 246 tstate.cur = KTR_ENTRIES - 1; 247 248 return (1); 249} 250 251#endif /* DDB */ |
|
155#endif /* KTR */ | 252#endif /* KTR */ |