kernel_utils.tcl
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#
# Copyright (C) 1996-1998 by the Board of Trustees
# of Leland Stanford Junior University.
#
# This file is part of the SimOS distribution.
# See LICENSE file for terms of the license.
#
# kernel_utils.tcl
# various little helpful utilities...
#
# tracking process fork, exec, and exit
annotation set osEvent procstart {
log "PFORK $CYCLES cpu=$CPU $PID($CPU)-$PROCESS($CPU)\n"
}
annotation set pc kernel::exece {
set argv [symbol read "kernel:exec.c:((struct execa*)$a0)->argp"]
log "PEXEC $CYCLES cpu=$CPU "
# print out the whole command line
set arg 1
while {$arg != 0} {
set arg [symbol read kernel::((int*)$argv)<0>]
if {$arg != 0} {
set arg [symbol read kernel::((char**)$argv)<0>]
log " $arg"
set argv [expr $argv + 4]
}
}
log "\n"
}
annotation set osEvent procexit {
log "PEXIT $CYCLES cpu=$CPU $PID($CPU)-$PROCESS($CPU)\n"
}
# reads the process table and prints all the processes and their status
proc dumpProcesses {} {
set proctbl "((proc_t*)[symbol read kernel::proc])"
set numprocs [symbol read kernel::v.v_proc]
for {set i 0} {$i < $numprocs} {incr i} {
set stat [symbol read kernel:proc.h:$proctbl<$i>.p_stat]
if $stat {
console "pid [symbol read kernel:proc.h:$proctbl<$i>.p_pid] "
set upte [symbol read kernel:proc.h:$proctbl<$i>.p_upgs<0>.pgi]
set user "((user_t*)[expr (($upte & 0xFFFFFE00) << 3) + 0x80000000])"
console "\"[symbol read kernel:proc.h:$user->u_comm]\" "
switch $stat {
1 {
console "sleeping "
set semapp [symbol read kernel:proc.h:&$proctbl<$i>.p_wchan]
set sema [hex [symbol read kernel::*((int*)$semapp)]]
if {$sema != 0} {
console "on [symbol find kernel $sema] "
}
}
2 { console "running " }
3 { console "zombie " }
4 { console "stoped " }
5 { console "creating " }
6 { console "sxbrk " }
}
console "\n"
}
}
}