version 1.66, 2012/03/31 18:59:14 |
version 1.67, 2012/04/10 20:39:37 |
|
|
#include "kdump_subr.h" |
#include "kdump_subr.h" |
#include "extern.h" |
#include "extern.h" |
|
|
int timestamp, decimal, iohex, fancy = 1, tail, maxdata = INT_MAX, resolv; |
int timestamp, decimal, iohex, fancy = 1, maxdata = INT_MAX; |
|
int needtid, resolv, tail; |
char *tracefile = DEF_TRACEFILE; |
char *tracefile = DEF_TRACEFILE; |
struct ktr_header ktr_header; |
struct ktr_header ktr_header; |
pid_t pid = -1; |
pid_t pid = -1; |
|
|
|
|
def_emul = current = &emulations[0]; /* native */ |
def_emul = current = &emulations[0]; /* native */ |
|
|
while ((ch = getopt(argc, argv, "e:f:dlm:nrRp:Tt:xX")) != -1) |
while ((ch = getopt(argc, argv, "e:f:dHlm:nrRp:Tt:xX")) != -1) |
switch (ch) { |
switch (ch) { |
case 'e': |
case 'e': |
setemul(optarg); |
setemul(optarg); |
|
|
case 'd': |
case 'd': |
decimal = 1; |
decimal = 1; |
break; |
break; |
|
case 'H': |
|
needtid = 1; |
|
break; |
case 'l': |
case 'l': |
tail = 1; |
tail = 1; |
break; |
break; |
|
|
err(1, NULL); |
err(1, NULL); |
if (!freopen(tracefile, "r", stdin)) |
if (!freopen(tracefile, "r", stdin)) |
err(1, "%s", tracefile); |
err(1, "%s", tracefile); |
|
if (fread_tail(&ktr_header, sizeof(struct ktr_header), 1) == 0 || |
|
ktr_header.ktr_type != htobe32(KTR_START)) |
|
errx(1, "%s: not a dump", tracefile); |
while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) { |
while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) { |
silent = 0; |
silent = 0; |
if (pe_size == 0) |
if (pe_size == 0) |
|
|
static void |
static void |
dumpheader(struct ktr_header *kth) |
dumpheader(struct ktr_header *kth) |
{ |
{ |
static struct timeval prevtime; |
static struct timespec prevtime; |
char unknown[64], *type; |
char unknown[64], *type; |
struct timeval temp; |
struct timespec temp; |
|
|
switch (kth->ktr_type) { |
switch (kth->ktr_type) { |
case KTR_SYSCALL: |
case KTR_SYSCALL: |
|
|
type = unknown; |
type = unknown; |
} |
} |
|
|
(void)printf("%6ld %-8.*s ", (long)kth->ktr_pid, MAXCOMLEN, |
(void)printf("%6ld", (long)kth->ktr_pid); |
kth->ktr_comm); |
if (needtid) |
|
(void)printf("/%-5ld", (long)kth->ktr_tid - THREAD_PID_OFFSET); |
|
(void)printf(" %-8.*s ", MAXCOMLEN, kth->ktr_comm); |
if (timestamp) { |
if (timestamp) { |
if (timestamp == 2) { |
if (timestamp == 2) { |
timersub(&kth->ktr_time, &prevtime, &temp); |
timespecsub(&kth->ktr_time, &prevtime, &temp); |
prevtime = kth->ktr_time; |
prevtime = kth->ktr_time; |
} else |
} else |
temp = kth->ktr_time; |
temp = kth->ktr_time; |
(void)printf("%ld.%06ld ", temp.tv_sec, temp.tv_usec); |
(void)printf("%ld.%06ld ", temp.tv_sec, temp.tv_nsec / 1000); |
} |
} |
(void)printf("%s ", type); |
(void)printf("%s ", type); |
} |
} |