This commit is contained in:
seta75D
2021-10-11 19:38:01 -03:00
commit 7c4988eac0
12567 changed files with 3198619 additions and 0 deletions

68
uts/sun4u/forthdebug/Makefile Executable file
View File

@@ -0,0 +1,68 @@
#
# uts/sun4u/forthdebug/Makefile
# Copyright (c) 1995 by Sun Microsystems, Inc.
#
#ident "@(#)Makefile 1.27 95/06/29 SMI"
#
# This makefile drives the production of the pci driver kernel module
#
# sun4u implementation architecture dependent
#
#
# Path to the base of the uts directory tree (usually /usr/src/uts).
#
#
UTSBASE = ../..
#
# Define the module and object file sets.
#
MODULE = forthdebug
ROOTMODULE = $(ROOT_PSM_MISC_DIR)/$(MODULE)
SUBDIRS = forthgen fdbg
#
# Include common rules.
#
include $(UTSBASE)/sun4u/Makefile.sun4u
# conditional assignments
all := TARGET= all
install := TARGET= all
clean := TARGET= clean
clean.lint := TARGET= clean.lint
clobber := TARGET= clobber
lint := TARGET= lint
.KEEP_STATE:
all clean clobber clean.lint lint: $(SUBDIRS)
modlintlib:
install: all $(ROOTMODULE)
$(ROOT_PSM_MISC_DIR)/%: % $(ROOT_PSM_MISC_DIR)
$(INS.file)
$(ROOT_PSM_MISC_DIR): $(ROOT_PSM_MOD_DIR)
-$(INS.dir.root.sys)
$(ROOT_PSM_MOD_DIR): $(ROOT_PSM_DIR)
-$(INS.dir.root.sys)
$(ROOT_PSM_DIR): $(ROOT_PLAT_DIR)
-$(INS.dir.root.sys)
$(ROOT_PLAT_DIR):
-$(INS.dir.root.sys)
$(SUBDIRS): FRC
@cd $@; pwd; $(MAKE) $(TARGET)
FRC:

297
uts/sun4u/forthdebug/README Executable file
View File

@@ -0,0 +1,297 @@
#ident "@(#)README 1.6 95/06/13 SMI"
FILES
Makefile - compiles the header files and also the interpreter.
It also runs forthgen on your *.fdbg files and
creates the forthdebug file. It will also install the
forthdebug file in kernel/drv.
parser.c - source file
stabs.c - source file
stabs.h - header file
*.fdbg - a file specifying a struct you are interested in and
the necessary header files
*.fth - generated by forthgen from *.fdbg
kdbg.fth - It has the forth program.
forthgen - It is the program that generates the words in *.fth files
for the structs whose names are specified in *.fdbg files.
forthdebug - is the concatenation of kdbg.fth and and all *fth files. This file
gets installed in kernel/drv and will be read in by the
kernel during boot up (if obpdebug or fortdebug are set).
Ques: How do I create a word for a struct I am interested in?
Ans:
1) Look in fdbg/*.fdbg files to make sure that it isn't already in the
debugger.
2) If not, then edit one of the existing *.fdbg files or create a new
file called somename.fdbg - if you think the existing ones don't satisfy
your needs. Just add the names of the structs you are interested in. If
you want only certain members of the structs to be printed then add the
member names and the format wanted below the struct name. Look at the
*.fdbg files to see how this is done. Remember to check in to SCCS.
3) Add the somename file where the struct is defined to the Makefile
4) Now do a "make". Look in the file forthdebug to see if words for
your structs have been created. If not, go back to step 2.
5) Install(1) will pick up forthdebug and install in kernel/misc
Ques: How do I add forth words?
Ans: In the .fdbg file - of your choice - type in the following
forth_start
type words here
forth_end
All lines between the forth_start and forth_end will be
copied over to the forthdebug file without any modifications.
Ques: How do I run it?
Ans: Here is a sample session. Comments are in ()s.
ok kdbg-words
( enter the debugger )
ok words
( list debugging words available )
( not all these are in the gate yet, but the most-requested
( .threadlist is )
( the printing words start with '.' e.g. .thread .tte )
( I will move the non-printing words to a separate vocabulary )
( soon )
.machcpu machcpu-words .intr_vector intr_vector-words
.tte tte-words .sfmmu sfmmu-words
.sf_hment sf_hment-words .hmehash_bucket
hmehash_bucket-words .hme_blk hme_blk-words .ctx
ctx-words .threadlist .stacktrace i7 i6
i5 i4 i3 i2 i1
i0 l7 l6 l5 l4
l3 l2 l1 l0 i7x
i6x i5x i4x i3x i2x
i1x i0x l7x l6x l5x
l4x l3x l2x l1x l0x
v9bias .lwp .thread ._kthread
_kthread-words .memlistlist .memlist
memlist-words ._klwp _klwp-words .mstate
mstate-words .k_siginfo k_siginfo-words
.kmem_cache kmem_cache-words .kmem_slab
kmem_slab-words .hment hment-words .hat
hat-words .dev_info dev_info-words .cred
cred-words .cpulist .cpun .cpu
cpu-words .callout callout-words .buf
buf-words .as as-words .rwlock .label
.disp .mutex ._rwlock_impl _rwlock_impl-words
._label_t
_label_t-words .itimerval itimerval-words
.timeval timeval-words ._disp _disp-words
.adaptive_mutex adaptive_mutex-words .dev_t
c-struct bits-field array-field struct-field
ptr-field byte-field short-field long-field
ext-field voc-print name-print 0plevel -plevel
+plevel plevel sizeof index print
.str .o another? next-word
ok .threadlist
( .threadlist prints threads 1 page at a time )
( try that with kadb )
thread e0402000 pc: e0094e98 sp: e0401aa8
call e008b254 genunix:main from e00069d8 _start+108
( 0 2 3c 2 e0428290 e0411840 )
call e00531a0 krtld:exitto from e0053e84 krtld:kobj_init+128
( e00068d0 e0425400 e04604f0 e0425000 e005829c e0437800 )
thread e0891ec0 free
thread e0895ec0 free
thread e0899ec0 free
thread e089dec0 free
thread e08a1ec0 free
thread e08a5ec0 free
thread e08a9ec0 free
thread e08adec0 free
thread e08b1ec0 free
thread e08b9ec0 pc: e002ec3c sp: e08b9e00
jmpl e00074b0 client_handler+38 from e001ef80 thread_start+4
( e0423c00 0 e0428290 e0428290 0 e0423c48 )
???? from e002ebfc idle
( 0 0 0 0 0 0 )
thread e08bdec0 pc: e005dd9c sp: e08bdda0
call e005dd38 genunix:cv_wait from e006bdd4 genunix:callout_thread+1c
( e045d890 e045d890 80000000 e045da3c e045da3c e045da3c )
jmpl e00074b0 client_handler+38 from e001ef80 thread_start+4
( 0 0 e0428290 e0428290 e045d8a4 e045d890 )
???? from e006bdb8 genunix:callout_thread
( 0 0 0 0 0 0 )
thread e08c1ec0 pc: e005dd9c sp: e08c1da0
call e005dd38 genunix:cv_wait from e006bdd4 genunix:callout_thread+1c
( e045d890 e045d890 80000000 e045db68 e045db68 e045db68 )
jmpl e00074b0 client_handler+38 from e001ef80 thread_start+4
( 0 0 e0428290 e0428290 e045d8a4 e045d890 )
???? from e006bdb8 genunix:callout_thread
( 0 0 0 0 0 0 )
thread e08c5ec0 free
thread e08cbec0 pc: e005dd9c sp: e08cbd90
call e005dd38 genunix:cv_wait from e00b9c24 genunix:background+158
( e046000c e046000c 0 10000 0 0 )
jmpl e00074b0 client_handler+38 from e001ef80 thread_start+4
( 0 fffffffe 10000 fc408734 0 e046000c )
???? from e00b9acc genunix:background
( 0 0 0 0 0 0 )
thread e08d1ec0 pc: e005dd9c sp: e08d1d90
call e005dd38 genunix:cv_wait from e00b9d8c genunix:freebs+c8
( e045f040 e045f040 2 e044dca0 2 0 )
jmpl e00074b0 client_handler+38 from e001ef80 thread_start+4
( e044dca8 e045fd1c e0428290 e045fe04 0 e045f040 )
???? from e00b9cc4 genunix:freebs
( 0 0 0 0 0 0 )
thread e08d7ec0 pc: e005dd9c sp: e08d7d90
call e005dd38 genunix:cv_wait from e00bdb08 genunix:qwriter_outer_thread+c4
( e045f078 e045f078 0 e044f4b8 e00080f0 fc14b580 )
jmpl e00074b0 client_handler+38 from e001ef80 thread_start+4
( e044f4bc 0 e045c2d8 0 e045f078 0 )
???? from e00bda44 genunix:qwriter_outer_thread
( 0 0 0 0 0 0 )
thread e08dbec0 pc: e005dd9c sp: e08dbd40
call e005dd38 genunix:cv_wait from fc2620f4 ufs:ufs_thread_run+6c
( fc13ca78 fc13ca78 0 456 0 fc14b5a8 )
call fc262088 ufs:ufs_thread_run from fc262868 ufs:ufs_thread_idle+1c
( fc13ca64 fffd fc13ca78 fc13ca68 fc13ca72 fc13ca70 )
jmpl e00074b0 client_handler+38 from e001ef80 thread_start+4
( 0 fc13ca64 fc13ca78 e0428290 0 0 )
???? from fc26284c ufs:ufs_thread_idle
( 0 0 7b60c 0 239b8 7b609 )
thread e08dfec0 pc: e005dd9c sp: e08dfd40
call e005dd38 genunix:cv_wait from fc2620f4 ufs:ufs_thread_run+6c
( fc13caf0 fc13caf0 0 1 0 ffffffd8 )
call fc262088 ufs:ufs_thread_run from fc262ccc ufs:ufs_thread_hlock+20
( fc13cadc fffd fc13caf0 fc13cae0 fc13caea fc13cae8 )
jmpl e00074b0 client_handler+38 from e001ef80 thread_start+4
( 0 0 fc13cadc fc13caea fc13caf0 0 )
???? from fc262cac ufs:ufs_thread_hlock
( 0 0 0 32540 16a09 0 )
thread e08e3ec0 pc: e005dd9c sp: e08e3d80
call e005dd38 genunix:cv_wait from fc30236c esp:esp_callback+1e4
( fc14b66c fc14b66c 2 19 fc14b674 0 )
jmpl e00074b0 client_handler+38 from e001ef80 thread_start+4
( 0 fc14b682 0 1 0 0 )
???? from fc302188 esp:esp_callback
( fc17f008 0 78278 c3c09 0 78284 )
thread fc44b480 pc: e005e4b0 sp: e0a1b7d0
call e005e358 genunix:cv_wait_sig_swap from e00b896c genunix:strwaitq+280
( 0 fc40b6e4 fc5eb028 0 fc44ee20 fc44b480 )
call e00b86ec genunix:strwaitq from e00b36d0 genunix:strgetmsg+2a8
( fc40b698 fc408246 0 3 e0a1b9b0 fc408200 )
call e00b3428 genunix:strgetmsg from e00a6508 genunix:msgio+254
( 0 e0a1ba18 0 fc40b6a8 fc40b6e4 0 )
call e00a62b4 genunix:msgio from e00a60d8 genunix:getmsg+88
( e0a1ba90 e0a1bb10 1 e0a1baab e0a1baac fc3209dc )
jmpl 0 from e00656c8 genunix:syscall_ap+70
( fc44ee88 e0a1bb10 0 0 e043e9c4 0 )
jmpl ffbf0000 from e0025824 syscall_trap+194
( 3 0 dffffd88 dffffd68 e00a6050 fc44ee20 )
XXXXXXX from df7876a4
( 3 dffffd7c dffffd88 dffffd68 84 27b18 )
thread fc44b5c0 pc: e005e4b0 sp: e0a17980
call e005e358 genunix:cv_wait_sig_swap from e00903e8 genunix:poll+cb8
( 0 fc14a950 fc5eb698 800 fc44f008 fc44b5c0 )
( at this point I got bored )
( and printed a single thread )
ok fc44b480 .thread
t_ts = NULL
t_prioinv = NULL
t_rprof = NULL
t_mstate = 9
t_waitrq = 0
t_kpri_req = 0
t_disp_time = 14976
t_disp_cpu = e0423c00
t_oldspl = 0
t_lockp = e045a310
t_pctcpu = 10
t_lbolt = 6ef
t_cred = fc19ff90
t_pollstate = NULL
t_sysnum = 85
t_whatstop = 0
t_whystop = 0
t_trace = NULL
t_prev = e08e3ec0
t_next = fc44b5c0
t_procp = fc5eb028
t_lwp = fc44ee20
t_back = fc44b480
t_forw = fc44b480
t_sigqueue = NULL
t_itimerid = 0
t_realitimer =
it_value =
tv_usec = 0 i = 110
disp_lock = 0
cpu_prev_onln = e0423c00
cpu_next_onln = e0423c00
cpu_prev = e0423c00
cpu_next = e0423c00
cpu_fpowner = fc44fd60
cpu_callo = NULL
cpu_lwp = NULL
cpu_pause_thread = e09fbec0
cpu_idle_thread = e08b9ec0
cpu_thread = e08b9ec0
cpu_flags = 1b
cpu_seqid = 0
cpu_id = 0
( and here's the phys installed list )
ok :phys_install l@ .memlistlist
prev = NULL
next = fc004168
size = 2000000
address = 0
prev = fc004150
next = NULL
size = 2000000
address = 10000000
NOTE: note the . (period) in front of the name of the struct. You need to add
that to the name so that it does not clash with variables with same names.

View File

@@ -0,0 +1,63 @@
#
# uts/sun4u/forthdebug/Makefile
# Copyright (c) 1991 by Sun Microsystems, Inc.
#
#ident "@(#)Makefile 1.3 95/08/28 SMI"
#
# Path to the base of the uts directory tree (usually /usr/src/uts).
#
UTSBASE = ../../..
MODULE = $(UTSBASE)/sun4u/forthdebug/forthdebug
FORTHGEN = $(UTSBASE)/sun4u/forthdebug/forthgen/forthgen
#
# Include common rules.
#
include $(UTSBASE)/sun4u/Makefile.sun4u
# Noted: fas.fth is taken out
SUN4U_FTH_FILES = \
common.fth scsi.fth sfmmu.fth fas.fth \
esp.fth isp.fth sd.fth sparc.fth \
st.fth sun4u.fth
KDBG = ./kdbg.fth
.SUFFIXES: .o .c .fdbg .fth
#
# Default build targets.
#
.KEEP_STATE:
all: $(MODULE)
install: $(MODULE)
lint:
clean:
$(RM) $(SUN4U_FTH_FILES)
clobber: clean
$(RM) $(MODULE)
clean.lint:
$(MODULE): $(KDBG) $(SUN4U_FTH_FILES)
cat $(KDBG) $(SUN4U_FTH_FILES) > fth.tmp
@wc -c fth.tmp | \
awk '{size = $$1 + 32; printf("\ %d\n", size)}' > $(MODULE)
cat fth.tmp >> $(MODULE)
@rm fth.tmp
.fdbg.fth: $(FORTHGEN)
@grep "^#" $< > ${*F}.c
$(CC) $(CPPFLAGS) -g -S -o ${*F}.s ${*F}.c
@grep -v "^#" $< > ${*F}.tmp
$(FORTHGEN) ${*F}.tmp < ${*F}.s > ${*F}.fth
@rm ${*F}.s ${*F}.c ${*F}.tmp

View File

@@ -0,0 +1,812 @@
#ident "@(#)common.fdbg 1.11 95/06/13 SMI"
#include <sys/param.h>
#include <sys/types.h>
#include <sys/user.h>
#include <sys/cred.h>
#include <sys/proc.h>
#include <sys/cpuvar.h>
#include <sys/thread.h>
#include <sys/sysinfo.h>
#include <sys/vfs.h>
#include <sys/time.h>
#include <sys/vnode.h>
#include <sys/disp.h>
#include <sys/var.h>
#include <sys/ts.h>
#include <sys/kstat.h>
#if defined(sun4) || defined(sun4c) || defined(sun4e)
#include <vm/hat_sunm.h>
#endif
#if defined(sun4m) || defined(sun4d)
#include <vm/hat_srmmu.h>
#endif
#if defined(sun4u)
#include <vm/hat_sfmmu.h>
#endif
#include <sys/ivintr.h>
#include <sys/intr.h>
#include <sys/machcpuvar.h>
#include <sys/sysiosbus.h>
#include <sys/iommu.h>
#include <sys/iocache.h>
#include <vm/anon.h>
#include <vm/as.h>
#include <vm/hat.h>
#include <vm/page.h>
#include <vm/pvn.h>
#include <vm/seg.h>
#include <vm/seg_dev.h>
#include <vm/seg_enum.h>
#include <vm/seg_kp.h>
#include <vm/seg_map.h>
#include <vm/seg_vn.h>
#include <sys/mutex_impl.h>
#include <sys/rwlock_impl.h>
#include <sys/callo.h>
#include <sys/ddi_impldefs.h>
#include <sys/kmem_impl.h>
#include <sys/siginfo.h>
#include <sys/memlist.h>
#include <sys/modctl.h>
#include <sys/kobj.h>
#include <sys/privregs.h>
#include <sys/machpcb.h>
#include <sys/traptrace.h>
\ basic type printing routines
forth_start
: .dev_t ( dev -- ) dup d# 18 >> .d h# 3ffff and .d ;
forth_end
\
\ lock information
\
adaptive_mutex
_rwlock_impl
type x
waiters x
owner x
forth_start
alias .mutex .adaptive_mutex
alias .rwlock ._rwlock_impl
forth_end
\
\ vm information
\
seg_next
list x
as
a_contents .mutex
a_vbits x
a_cv x
a_hat x
a_rss x
a_cache x
a_lock .rwlock
a_segs .seg_next
a_size x
a_tail x
a_nsegs d
a_lrep x
a_hilevel x
seg
s_base x
s_size x
s_as x
s_prev x
s_next .seg_next
s_ops .adr
s_data x
page
hat
hat_op .adr
hat_next x
hat_as x
hat_data x
hment
hme_page x
hme_next x
hme_hat x
hme_impl x
hme_prev x
memseg
memlist
forth_start
: .seg-list ( seg -- )
[ also seg-words ]
[ also seg_next-words ]
begin ?dup while ( seg )
dup .seg cr s_next list ( seg' )
repeat ( )
[ previous ]
[ previous ]
;
: .seg-addr ( as addr -- )
[ also as-words ]
[ also seg-words ]
[ also seg_next-words ]
swap a_segs list
begin ?dup while ( addr seg )
2dup dup s_base swap ( addr seg addr base seg )
s_size over + ( addr seg addr base end )
within if ( addr seg )
.seg drop exit ( )
then ( addr seg )
s_next list ( addr seg' )
repeat ( addr )
. ." not found" ( )
[ previous ]
[ previous ]
[ previous ]
;
: .page-n ( n -- )
[ also page-words ]
[ also memseg-words ]
symbol memsegs l@ ( n memseg )
begin ?dup while ( n memseg )
2dup ( n memseg n memseg )
dup pages_base swap pages_end ( n memseg n base end )
within if ( n memseg )
2dup pages_base - ( n memseg noff )
['] .page sizeof * swap ( n poff memseg )
pages + .page drop exit ( )
then ( n memseg )
next ( n memseg' )
repeat ( n )
. ." not found" ( )
[ previous ]
[ previous ]
;
: .memseg-list ( -- )
[ also memseg-words ]
symbol memsegs l@ ( memseg )
begin ?dup while ( memseg )
dup .memseg cr next ( memseg' )
repeat
[ previous ]
;
: .memlist-list ( memlist -- )
[ also memlist-words ]
begin ?dup while ( memlist )
dup .memlist cr next ( memlist' )
repeat ( )
[ previous ]
;
forth_end
\
\ thread information
\
_label_t
timeval
itimerval
it_interval .timeval
it_value .timeval
k_sigset_t
k_siginfo
si_signo x
si_code x
si_errno d
_kthread
t_link x
t_stk x
t_bound_cpu x
t_affinitycnt d
t_bind_cpu d
t_flag x
t_proc_flag x
t_schedflag x
t_pre_sys x
t_preempt d
t_state x
t_pri d
t_epri d
t_pcb ._label_t
t_wchan0 x
t_wchan x
t_sobj_ops .adr
t_cid x
t_clfuncs x
t_cldata x
t_ctx x
t_lofault x
t_onfault x
t_nofault x
t_swap x
t_lock x
t_delay_cv x
t_cpu x
t_intr x
t_did d
t_tid d
t_alarmid x
t_realitimer .itimerval
t_itimerid x
t_sigqueue x
t_sig .k_sigset_t
t_hold .k_sigset_t
t_forw x
t_back x
t_lwp x
t_procp x
t_next x
t_prev x
t_trace x
t_whystop d
t_whatstop d
t_sysnum d
t_pollstate x
t_cred x
t_lbolt x
t_pctcpu x
t_lockp x
t_oldspl x
t_disp_cpu x
t_disp_time d
t_kpri_req d
t_waitrq x
t_mstate d
t_rprof x
t_prioinv x
t_ts x
mstate
ms_prev x
ms_start x
ms_term x
ms_state_start x
_klwp
lwp_oldcontext x
lwp_ap x
lwp_errno d
lwp_error x
lwp_eosys x
lwp_arg x
lwp_regs x
lwp_fpu x
lwp_qsav ._label_t
lwp_cursig x
lwp_curflt x
lwp_sysabort x
lwp_asleep x
lwp_curinfo x
lwp_sigoldmask .k_sigset_t
lwp_prof x
lwp_mstate .mstate
lwp_lastfault d
lwp_lastfaddr x
lwp_oweupc x
lwp_state x
lwp_nostop x
lwp_cv x
lwp_utime x
lwp_stime x
lwp_thread x
lwp_procp x
proc
p_exec x
p_as x
p_lock .mutex
p_crlock .mutex
p_cred x
p_swapcnt d
p_stat d
p_ppid d
p_link x
p_parent x
p_child x
p_sibling x
p_psibling x
p_sibling_ns x
p_child_ns x
p_next x
p_prev x
p_nextofkin x
p_orphan x
p_nextorph x
p_pglink x
p_sessp x
p_pidp x
p_pgidp x
p_cv x
p_flag_cv x
p_lwpexit x
p_holdlwps x
p_flag x
p_utime x
p_stime x
p_cutime x
p_cstime x
p_segacct x
p_brkbase x
p_brksize x
p_sig .k_sigset_t
p_ignore .k_sigset_t
p_siginfo .k_sigset_t
p_sigqueue x
p_stopsig d
p_lwptotal d
p_lwpcnt d
p_lwprcnt d
p_lwpblocked d
p_zombcnt d
p_tlist x
p_zomblist x
p_sigmask .k_sigset_t
p_trace x
p_plist x
p_rlink x
p_srwchan_cv x
p_stksize x
p_user x
forth_start
alias .thread ._kthread
alias .lwp ._klwp
h# 7ff constant v9bias
: l0x ( sp -- sp l0 ) dup v9bias + d# 0 + x@ ;
: l1x ( sp -- sp l1 ) dup v9bias + d# 8 + x@ ;
: l2x ( sp -- sp l2 ) dup v9bias + d# 16 + x@ ;
: l3x ( sp -- sp l3 ) dup v9bias + d# 24 + x@ ;
: l4x ( sp -- sp l4 ) dup v9bias + d# 32 + x@ ;
: l5x ( sp -- sp l5 ) dup v9bias + d# 40 + x@ ;
: l6x ( sp -- sp l6 ) dup v9bias + d# 48 + x@ ;
: l7x ( sp -- sp l7 ) dup v9bias + d# 56 + x@ ;
: i0x ( sp -- sp i0 ) dup v9bias + d# 64 + x@ ;
: i1x ( sp -- sp i1 ) dup v9bias + d# 72 + x@ ;
: i2x ( sp -- sp i2 ) dup v9bias + d# 80 + x@ ;
: i3x ( sp -- sp i3 ) dup v9bias + d# 88 + x@ ;
: i4x ( sp -- sp i4 ) dup v9bias + d# 96 + x@ ;
: i5x ( sp -- sp i5 ) dup v9bias + d# 104 + x@ ;
: i6x ( sp -- sp i6 ) dup v9bias + d# 112 + x@ ;
: i7x ( sp -- sp i7 ) dup v9bias + h# 120 + x@ ;
: l0 ( sp -- sp l0 ) dup d# 0 + l@ ;
: l1 ( sp -- sp l1 ) dup d# 4 + l@ ;
: l2 ( sp -- sp l2 ) dup d# 8 + l@ ;
: l3 ( sp -- sp l3 ) dup d# 12 + l@ ;
: l4 ( sp -- sp l4 ) dup d# 16 + l@ ;
: l5 ( sp -- sp l5 ) dup d# 20 + l@ ;
: l6 ( sp -- sp l6 ) dup d# 24 + l@ ;
: l7 ( sp -- sp l7 ) dup d# 28 + l@ ;
: i0 ( sp -- sp i0 ) dup d# 32 + l@ ;
: i1 ( sp -- sp i1 ) dup d# 36 + l@ ;
: i2 ( sp -- sp i2 ) dup d# 40 + l@ ;
: i3 ( sp -- sp i3 ) dup d# 44 + l@ ;
: i4 ( sp -- sp i4 ) dup d# 48 + l@ ;
: i5 ( sp -- sp i5 ) dup d# 52 + l@ ;
: i6 ( sp -- sp i6 ) dup d# 56 + l@ ;
: i7 ( sp -- sp i7 ) dup d# 60 + l@ ;
: .stacktrace ( sp -- )
begin dup pointer-bad? 0= over and while
dup 1 and if
i7x .subroutine ." from " i7x .subname cr
." ( " i0x .h i1x .h i2x .h i3x .h i4x .h i5x .h ." )" cr
i6x
else
i7 .subroutine ." from " i7 .subname cr
." ( " i0 .h i1 .h i2 .h i3 .h i4 .h i5 .h ." )" cr
i6
then
exit? throw nip
repeat
drop
;
: .threadtrace ( t -- )
[ also _kthread-words ]
[ also _label_t-words ]
t_pcb ( pcb )
." pc: " dup 0 ['] val index .x ( pcb )
." sp: " 1 ['] val index dup .x ( sp )
cr .stacktrace cr ( )
[ previous ]
[ previous ]
;
: .proctlist ( p -- )
[ also proc-words ]
[ also _kthread-words ]
p_tlist dup ( t0 t0 )
begin ( t0 t )
." thread " dup .x ( t0 t )
dup t_forw swap ( t0 t' t )
.threadtrace ( t0 t' )
2dup = until ( t0 t )
2drop ( )
[ previous ]
[ previous ]
;
: .threadlist ( -- )
[ also _kthread-words ]
symbol genunix:allthreads l@ ?dup if ( t )
dup ( t t )
begin ( t0 t )
." thread " dup .x ( t0 t )
dup t_next swap ( t0 t' t )
dup t_state if ( t0 t' t )
.threadtrace false ( t0 t false )
else ( t0 t' t )
." free" cr cr drop exit? ( t0 t' done? )
then ( t0 t' done? )
dup 2over = or nip until ( t0 t )
2drop ( )
then ( )
[ previous ]
;
forth_end
\
\ cpu information
\
_disp
disp_lock x
disp_npri d
disp_q x
disp_q_limit x
disp_qactmap x
disp_maxrunpri d
disp_max_unbound_pri d
disp_nrunnable d
cpu
cpu_id d
cpu_seqid d
cpu_flags x
cpu_thread x
cpu_idle_thread x
cpu_pause_thread x
cpu_lwp x
cpu_callo x
cpu_fpowner x
cpu_next x
cpu_prev x
cpu_next_onln x
cpu_prev_onln x
cpu_disp ._disp
cpu_runrun x
cpu_kprunrun x
cpu_dispthread x
cpu_thread_lock x
cpu_intr_stack x
cpu_on_intr x
cpu_intr_thread x
cpu_intr_actv x
cpu_base_spl d
cpu_m x
forth_start
alias .disp ._disp
: .cpu-n ( n -- )
dup 4 * symbol cpu + l@ ( n cpu )
?dup if ( n cpu )
.cpu drop ( )
else ( n )
." cpu[ " .d ." ] is NULL" ( )
then ( )
;
: .cpu-list ( -- )
[ also cpu-words ]
symbol cpu_list l@ ?dup if ( cpu0 )
dup ( cpu0 cpu0 )
begin ( cpu0 cpu )
dup .cpu cpu_next cr ( cpu0 cpu' )
2dup = until ( cpu0 cpu )
2drop ( )
then ( )
[ previous ]
;
forth_end
\
\ io information
\
dev_info
devi_parent x
devi_child x
devi_sibling x
devi_name .str
devi_addr .str
devi_nodeid x
devi_instance x
devi_ops .adr
devi_parent_data x
devi_driver_data x
devi_drv_prop_ptr x
devi_sys_prop_ptr x
devi_minor x
devi_next x
lldaddr_t
_f x
buf.b_un
b_addr x
buf
b_flags x
b_forw x
b_back x
av_forw x
av_back x
b_bcount d
b_un .buf.b_un
_b_blkno .lldaddr_t
b_resid d
b_proc .adr
b_pages x
b_bufsize d
b_iodone x
b_vp x
b_error d
b_edev .dev_t
forth_start
: .devinfo-tree ( dip -- ) recursive
[ also dev_info-words ]
dup .dev_info cr ( dip )
dup devi_child ?dup if ( dip child )
.devinfo-tree cr ( dip )
then ( dip )
dup devi_sibling ?dup if ( dip sibling )
.devinfo-tree cr ( dip )
then ( dip )
drop ( )
[ previous ]
;
: .devinfo-inst ( dip -- )
[ also dev_info-words ]
begin ?dup while ( dip )
.dev_info cr devi_next ( dip )
repeat ( )
[ previous ]
;
: .devinfo-level ( dip -- )
[ also dev_info-words ]
begin ?dup while ( dip )
.dev_info cr devi_sibling ( dip )
repeat ( )
[ previous ]
;
forth_end
\
\ module information
\
modctl
mod_next x
mod_prev x
mod_id d
mod_mp x
mod_inprogress_thread x
mod_modinfo x
mod_linkage x
mod_filename .str
mod_modname .str
mod_busy x
mod_stub x
mod_loaded x
mod_installed x
mod_noautounload x
mod_want x
mod_loadcnt d
module
syminfo x
total_allocated d
shdrs x
symhdr x
strhdr x
depends .str
symsize d
symspace x
flags x
text_size d
data_size d
text x
data x
symtbl_section d
symtbl x
strings x
hashsize d
buckets x
chains x
nsyms d
bss_align d
bss_size d
bss x
filename .str
forth_start
: .module-list ( -- )
[ also modctl-words ]
symbol modules dup ( mod0 mod0 )
begin ( mod0 mod )
dup mod_next swap ( mod0 mod' mod )
mod_mp ?dup if ( mod0 mod' mp )
.module cr ( mod0 mod' )
then ( mod0 mod' )
2dup = until ( mod0 mod' )
2drop ( )
[ previous ]
;
forth_end
\
\ kmem information
\
kmem_slab
kmem_cache
cache_lock .mutex
cache_flags x
cache_freelist x
cache_offset d
cache_alloc d
cache_alloc_fail d
cache_hash_shift x
cache_hash_mask x
cache_hash_table x
cache_nullslab .kmem_slab
cache_constructor .adr
cache_destructor .adr
cache_reclaim .adr
cache_bufsize d
cache_align d
cache_chunksize d
cache_slabsize d
cache_color d
cache_maxcolor d
cache_slab_create d
cache_slab_destroy d
cache_buftotal d
cache_bufmax d
cache_rescale d
cache_lookup_depth d
cache_kstat x
cache_cv x
cache_next x
cache_prev x
cache_name emit
cache_magazine_cache x
cache_magazine_size d
cache_magazine_maxsize d
cache_depot_lock .mutex
cache_cpu_rotor d
cache_ncpus d
cache_depot_contention d
cache_depot_contention_last d
cache_depot_alloc d
cache_depot_free d
cache_fmag_list x
cache_fmag_total d
cache_fmag_min d
cache_fmag_reaplimit d
cache_emag_list x
cache_emag_total d
cache_emag_min d
cache_emag_reaplimit d
\
\ fs information
\
vtype
vnode
v_flag x
v_count d
v_vfsmountedhere x
v_op .adr
v_vfsp x
v_stream x
v_pages x
v_type .vtype
v_rdev .dev_t
v_data x
v_filocks x
vfs
vfs_next x
vfs_op .adr
vfs_vnodecovered x
vfs_flag x
vfs_fstype d
vfs_data x
vfs_dev .dev_t
vfs_nsubmounts x
vfs_list x
vfs_hash x
\
\ misc information
\
callout
cred
cr_ref d
cr_uid d
cr_gid d
cr_ruid d
cr_rgid d
cr_suid d
cr_sgid d
cr_ngroups d
kstat_named.value
ul x
kstat_named
name emit
value .kstat_named.value

View File

@@ -0,0 +1,19 @@
#ident "@(#)esp.fdbg 1.1 95/06/13 SMI"
#include <sys/scsi/scsi.h>
#include <sys/scsi/adapters/espcmd.h>
#include <sys/scsi/adapters/espvar.h>
\
\ hba driver structures
\ esp driver
esp
callback_info
esp_cmd
t_slots

View File

@@ -0,0 +1,21 @@
#ident "@(#)fas.fdbg 1.1 95/06/13 SMI"
#include <sys/scsi/scsi.h>
#include <sys/scsi/adapters/fasreg.h>
#include <sys/scsi/adapters/fasvar.h>
#include <sys/scsi/adapters/fascmd.h>
#include <sys/scsi/adapters/fasdma.h>
\ fas driver
fas
fasreg
fas_cmd
f_slots
dma

View File

@@ -0,0 +1,16 @@
#ident "@(#)isp.fdbg 1.1 95/06/13 SMI"
#include <sys/scsi/scsi.h>
#include <sys/scsi/adapters/ispmail.h>
#include <sys/scsi/adapters/ispvar.h>
#include <sys/scsi/adapters/ispcmd.h>
\ isp driver
isp
isp_cmd
isp_request
isp_response

View File

@@ -0,0 +1,209 @@
\ "@(#)kdbg.fth 1.8 95/06/13 SMI"
hex
only forth also definitions
vocabulary kdbg-words
also kdbg-words definitions
: next-word ( alf voc-acf -- false | alf' true )
over if drop else nip >threads then
another-link? if >link true else false then
;
\ another? that allows nesting
: another? ( alf voc-acf -- false | alf' voc-acf anf true )
dup >r next-word if ( alf' ) ( r: voc-acf )
r> over l>name true ( alf' voc-acf anf true )
else ( ) ( r: voc-acf )
r> drop false ( false )
then
;
create err-no-sym ," symbol not found"
\ guard against bad symbols
: symbol ( -- n ) \ symbol-name
parse-word $handle-literal? 0= if
+level compile err-no-sym compile throw -level
then
; immediate
\ print in octal
: .o ( n -- ) base @ >r octal . r> base ! ;
\ print string
: .str ( str -- )
?dup if
cscount type
else
." NULL"
then
;
\ new actions
: print 2 perform-action ;
: index 3 perform-action ;
: sizeof 1 perform-action ;
\ indent control
-8 value plevel
: +plevel ( -- ) plevel 8 + to plevel ;
: -plevel ( -- ) plevel 8 - to plevel ;
: 0plevel ( -- ) -8 to plevel ;
\ new print words
: name-print ( apf -- apf ) plevel spaces dup body> .name ." = " ;
: voc-print ( addr acf -- )
??cr +plevel
0 swap ( addr 0 acf )
begin another? while ( addr alf acf anf )
3 pick swap name> print ( addr alf acf )
exit? if ( addr alf acf )
0plevel true throw ( )
then ( addr alf acf )
repeat ( addr )
drop -plevel ( )
;
3 actions ( offset print-acf )
action: ( addr apf -- x ) @ + x@ ; \ get
action: ( addr x apf -- ) @ rot + x! ; \ set
action: ( addr apf -- )
name-print
dup @ rot + x@ swap ( x apf )
na1+ @ execute cr ; \ print
: ext-field ( acf offset -- ) create , , use-actions ;
3 actions ( offset print-acf )
action: ( addr apf -- l ) @ + l@ ; \ get
action: ( addr l apf -- ) @ rot + l! ; \ set
action: ( addr apf -- )
name-print
dup @ rot + l@ swap ( l apf )
na1+ @ execute cr ; \ print
: long-field ( acf offset -- ) create , , use-actions ;
3 actions ( offset print-acf )
action: ( addr apf -- w ) @ + w@ ; \ get
action: ( addr w apf -- ) @ rot + w! ; \ set
action: ( addr apf -- )
name-print
dup @ rot + w@ swap ( w apf )
na1+ @ execute cr ; \ print
: short-field ( acf offset -- ) create , , use-actions ;
3 actions ( offset print-acf )
action: ( addr apf -- c ) @ + c@ ; \ get
action: ( addr c apf -- ) @ rot + c! ; \ set
action: ( addr apf -- )
name-print
dup @ rot + c@ swap ( c apf )
na1+ @ execute cr ; \ print
: byte-field ( acf offset -- ) create , , use-actions ;
3 actions ( offset print-acf )
action: ( addr apf -- ptr ) @ + l@ ; \ get
action: ( addr l apf -- ) @ rot + l! ; \ set
action: ( addr apf -- )
name-print
dup @ rot + l@ ?dup if ( apf ptr )
swap na1+ @ execute ( )
else ( apf )
drop ." NULL" ( )
then ( )
cr ; \ print
: ptr-field ( acf offset -- ) create , , use-actions ;
3 actions ( offset print-acf )
action: ( addr apf -- saddr ) @ + ; \ get
action: ( -- ) quit ; \ error
action: ( addr apf -- )
name-print
dup @ rot + swap ( saddr apf )
na1+ @ execute ??cr ; \ print
: struct-field ( acf offset -- ) create , , use-actions ;
4 actions ( offset inc limit print-acf fetch-acf )
action: ( addr apf -- araddr ) @ + ; \ get
action: ( -- ) quit ; \ set
action: ( addr apf -- )
name-print
dup @ rot + swap ( base apf )
na1+ dup @ -rot ( inc base apf' )
na1+ dup @ swap ( inc base limit apf' )
na1+ dup @ swap ( inc base limit p-acf apf' )
na1+ @ 2swap ( inc p-acf f-acf base limit )
bounds do ( inc p-acf f-acf )
3dup ( inc p-acf f-acf inc p-acf f-acf )
i swap execute ( inc f-acf p-acf inc p-acf n )
swap execute ( inc f-acf p-acf inc )
+loop ( inc f-acf p-acf )
3drop ??cr ; \ print
action: ( addr index apf -- ith-item )
rot swap ( index addr apf )
dup @ rot + swap ( index base apf )
na1+ dup @ 3 roll * ( base apf' ioff )
rot + swap 3 na+ @ ( iaddr f-acf )
execute ; \ index
: array-field ( f-acf p-acf limit inc offset -- ) create , , , , , use-actions ;
3 actions ( offset mask shift print-acf )
action: ( addr apf -- bits )
dup @ rot + l@ swap ( b-word apf )
na1+ dup @ rot and swap ( b-masked apf' )
na1+ @ >> ; \ get
action: ( addr bits apf -- )
rot over @ + dup l@ 2swap ( b-addr b-word nbits apf )
na1+ dup @ -rot ( b-addr b-word mask nbits apf' )
na1+ @ << over and ( b-addr b-word mask nb-masked )
-rot invert and or swap l! ; \ set
action: ( addr apf -- )
name-print
dup @ rot + l@ swap ( b-word apf )
na1+ dup @ rot and swap ( b-mask apf' )
na1+ dup @ rot swap >> swap ( bits apf' )
na1+ @ execute cr ; \ print
: bits-field ( acf shift mask offset -- ) create , , , , use-actions ;
2 actions ( voc-acf size )
action: ( apf -- ) @ voc-print ; \ print vocabulary
action: ( apf -- size ) na1+ @ ; \ sizeof
: c-struct ( size acf -- ) create , , use-actions ;
: c-enum ( {str value}+ n-values -- )
create ( n-values {value str}+ )
dup 2* 1+ 0 do , loop
does> ( enum apf -- )
dup @ 0 do ( enum apf' )
na1+ 2dup @ = if ( enum apf' )
na1+ @ .str ( enum )
drop unloop exit ( )
then ( enum apf' )
na1+ ( enum apf' )
loop ( enum apf' )
drop .d cr ( )
;
\ end kdbg section

View File

@@ -0,0 +1,17 @@
#ident "@(#)scsi.fdbg 1.1 95/06/13 SMI"
#include <sys/scsi/scsi.h>
\ generic scsi structures
scsi_address
scsi_arq_status
scsi_device
scsi_hba_tran
scsi_pkt

View File

@@ -0,0 +1,18 @@
#ident "@(#)sd.fdbg 1.1 95/06/13 SMI"
#include <sys/scsi/scsi.h>
#include <sys/dkio.h>
#include <sys/scsi/targets/sddef.h>
\
\ scsi disk
scsi_disk
dk_geom
dk_label
dk_vtoc

View File

@@ -0,0 +1,238 @@
#ident "@(#)sfmmu.fdbg 1.9 95/07/10 SMI"
#include <sys/param.h>
#include <sys/types.h>
#include <sys/user.h>
#include <sys/cred.h>
#include <sys/proc.h>
#include <sys/cpuvar.h>
#include <sys/thread.h>
#include <sys/sysinfo.h>
#include <sys/vfs.h>
#include <sys/time.h>
#include <sys/vnode.h>
#include <sys/disp.h>
#include <sys/var.h>
#include <sys/ts.h>
#include <sys/kstat.h>
#if defined(sun4) || defined(sun4c) || defined(sun4e)
#include <vm/hat_sunm.h>
#endif
#if defined(sun4m) || defined(sun4d)
#include <vm/hat_srmmu.h>
#endif
#if defined(sun4u)
#include <vm/hat_sfmmu.h>
#endif
#include <sys/ivintr.h>
#include <sys/intr.h>
#include <sys/machcpuvar.h>
#include <sys/sysiosbus.h>
#include <sys/iommu.h>
#include <sys/iocache.h>
#include <vm/anon.h>
#include <vm/as.h>
#include <vm/hat.h>
#include <vm/page.h>
#include <vm/pvn.h>
#include <vm/seg.h>
#include <vm/seg_dev.h>
#include <vm/seg_enum.h>
#include <vm/seg_kp.h>
#include <vm/seg_map.h>
#include <vm/seg_vn.h>
#include <sys/mutex_impl.h>
#include <sys/rwlock_impl.h>
#include <sys/callo.h>
#include <sys/ddi_impldefs.h>
#include <sys/kmem_impl.h>
#include <sys/siginfo.h>
#include <sys/memlist.h>
#include <sys/modctl.h>
#include <sys/kobj.h>
#include <sys/privregs.h>
#include <sys/machpcb.h>
#include <sys/traptrace.h>
tte
v x
sz x
nfo x
ie x
hmenum x
lockcnt x
pahi x
palo x
ref x
wr_perm x
no_sync x
l x
cp x
cv x
e x
p x
w x
g x
hmehash_bucket
hmehash_mutex .mutex
hmeh_nextpa x
hmeblkp x
hmeblk_tag
htag_tag x
hme_blk.hblk_misc
hme_blk.hblk_un
hme_blk
hblk_nextpa x
hblk_tag .hmeblk_tag
hblk_next x
hblk_shadow x
hblk_span d
hblk_misc .hme_blk.hblk_misc
hblk_un .hme_blk.hblk_un
sf_hment
gen_hme .hment
hme_tte .tte
sfmmu
ctx.c_un
c_sfmmup .x
ctx
c_un .ctx.c_un
c_flags .x
c_refcnt .x
c_ismblkpa .x
vmhatstat
forth_start
: .sfmmu-cnum ( cnum -- )
[ also ctx-words ]
[ also ctx.c_un-words ]
['] .ctx sizeof * ( coff )
symbol ctxs + c_sfmmup ( sfmmu )
." sfmmu " dup .x cr ( sfmmu )
?dup if .sfmmu then ( )
[ previous ]
;
: .hmeb-shift ( sfmmu addr shift -- )
>> over xor swap ( hash sfmmu )
symbol ksfmmup l@ <> if ( hash )
symbol uhmehash_num l@ and ( bucket )
['] .hmehash_bucket sizeof * ( index )
symbol uhme_hash l@ + ( hmeb )
else ( hash )
symbol khmehash_num l@ and ( bucket )
['] .hmehash_bucket sizeof * ( index )
symbol khme_hash l@ + ( hmeb )
then ( hmeb )
." hmeb " dup .x cr ( hmeb )
.hmehash_bucket ( )
;
: .hmeb-8k ( sfmmup addr -- ) d# 16 .hmeb-shift ;
alias .hmeb-64k .hmeb-8k
: .hmeb-512k ( sfmmup addr -- ) d# 19 .hmeb-shift ;
: .hmeb-4m ( sfmmup addr -- ) d# 22 .hmeb-shift ;
: .hmeblk-list ( hmeblk -- )
[ also hme_blk-words ]
begin ?dup while ( hmeblk )
dup .hme_blk cr hblk_next ( hmeblk' )
repeat ( )
[ previous ]
;
: .pmap-list ( sfhme -- )
[ also hment-words ]
begin ?dup while ( sfhme )
dup .sf_hment cr hme_next ( sfhme' )
repeat ( )
[ previous ]
;
: clr_mmustats ( -- )
[ also vmhatstat-words ]
[ also kstat_named-words ]
[ also kstat_named.value-words ]
symbol vmhatstat
dup vh_ctxfree value 0 to ul
dup vh_ctxsteal value 0 to ul
dup vh_tteload value 0 to ul
dup vh_hblk_hit value 0 to ul
dup vh_hblk_dalloc value 0 to ul
dup vh_hblk_nalloc value 0 to ul
dup vh_pgcolor_conflict value 0 to ul
dup vh_uncache_conflict value 0 to ul
dup vh_unload_conflict value 0 to ul
dup vh_mlist_enter value 0 to ul
dup vh_mlist_exit value 0 to ul
dup vh_pagesync value 0 to ul
dup vh_pagesync_invalid value 0 to ul
dup vh_itlb_misses value 0 to ul
dup vh_dtlb_misses value 0 to ul
dup vh_utsb_misses value 0 to ul
dup vh_ktsb_misses value 0 to ul
dup vh_tsb_hits value 0 to ul
dup vh_umod_faults value 0 to ul
dup vh_kmod_faults value 0 to ul
dup vh_slow_tsbmiss value 0 to ul
dup vh_pagefaults value 0 to ul
dup vh_uhash_searches value 0 to ul
dup vh_uhash_links value 0 to ul
dup vh_khash_searches value 0 to ul
dup vh_khash_links value 0 to ul
[ previous ]
[ previous ]
[ previous ]
;
: prt_mmustats ( -- )
[ also vmhatstat-words ]
[ also kstat_named-words ]
[ also kstat_named.value-words ]
symbol vmhatstat
dup vh_ctxfree dup name .cstr ." = " value L@ . cr
dup vh_ctxsteal dup name .cstr ." = " value L@ . cr
dup vh_tteload dup name .cstr ." = " value L@ . cr
dup vh_hblk_hit dup name .cstr ." = " value L@ . cr
dup vh_hblk_dalloc dup name .cstr ." = " value L@ . cr
dup vh_hblk_nalloc dup name .cstr ." = " value L@ . cr
dup vh_pgcolor_conflict dup name .cstr ." = " value L@ . cr
dup vh_uncache_conflict dup name .cstr ." = " value L@ . cr
dup vh_unload_conflict dup name .cstr ." = " value L@ . cr
dup vh_mlist_enter dup name .cstr ." = " value L@ . cr
dup vh_mlist_exit dup name .cstr ." = " value L@ . cr
dup vh_pagesync dup name .cstr ." = " value L@ . cr
dup vh_pagesync_invalid dup name .cstr ." = " value L@ . cr
dup vh_itlb_misses dup name .cstr ." = " value L@ . cr
dup vh_dtlb_misses dup name .cstr ." = " value L@ . cr
dup vh_utsb_misses dup name .cstr ." = " value L@ . cr
dup vh_ktsb_misses dup name .cstr ." = " value L@ . cr
dup vh_tsb_hits dup name .cstr ." = " value L@ . cr
dup vh_umod_faults dup name .cstr ." = " value L@ . cr
dup vh_kmod_faults dup name .cstr ." = " value L@ . cr
dup vh_slow_tsbmiss dup name .cstr ." = " value L@ . cr
dup vh_pagefaults dup name .cstr ." = " value L@ . cr
dup vh_uhash_searches dup name .cstr ." = " value L@ . cr
dup vh_uhash_links dup name .cstr ." = " value L@ . cr
dup vh_khash_searches dup name .cstr ." = " value L@ . cr
dup vh_khash_links dup name .cstr ." = " value L@ . cr
[ previous ]
[ previous ]
[ previous ]
;

View File

@@ -0,0 +1,74 @@
#ident "@(#)sparc.fdbg 1.4 95/06/13 SMI"
#include <sys/param.h>
#include <sys/types.h>
#include <sys/user.h>
#include <sys/cred.h>
#include <sys/proc.h>
#include <sys/cpuvar.h>
#include <sys/thread.h>
#include <sys/sysinfo.h>
#include <sys/vfs.h>
#include <sys/time.h>
#include <sys/vnode.h>
#include <sys/disp.h>
#include <sys/var.h>
#include <sys/ts.h>
#include <sys/kstat.h>
#if defined(sun4) || defined(sun4c) || defined(sun4e)
#include <vm/hat_sunm.h>
#endif
#if defined(sun4m) || defined(sun4d)
#include <vm/hat_srmmu.h>
#endif
#if defined(sun4u)
#include <vm/hat_sfmmu.h>
#endif
#include <sys/ivintr.h>
#include <sys/intr.h>
#include <sys/machcpuvar.h>
#include <sys/sysiosbus.h>
#include <sys/iommu.h>
#include <sys/iocache.h>
#include <vm/anon.h>
#include <vm/as.h>
#include <vm/hat.h>
#include <vm/page.h>
#include <vm/pvn.h>
#include <vm/seg.h>
#include <vm/seg_dev.h>
#include <vm/seg_enum.h>
#include <vm/seg_kp.h>
#include <vm/seg_map.h>
#include <vm/seg_vn.h>
#include <sys/mutex_impl.h>
#include <sys/rwlock_impl.h>
#include <sys/callo.h>
#include <sys/ddi_impldefs.h>
#include <sys/kmem_impl.h>
#include <sys/siginfo.h>
#include <sys/memlist.h>
#include <sys/modctl.h>
#include <sys/kobj.h>
#include <sys/privregs.h>
#include <sys/machpcb.h>
#include <sys/traptrace.h>
\
\ regs information
\
regs
v9_fpu.fpu_fr
fpu_dregs x
v9_fpu
fpu_fr .v9_fpu.fpu_fr
fpu_fsr x
fpu_fprs x
fpu_q x
fpu_qcnt d
fpu_q_entrysize d
fpu_en x

View File

@@ -0,0 +1,12 @@
#ident "@(#)st.fdbg 1.1 95/06/13 SMI"
#include <sys/scsi/scsi.h>
#include <sys/mtio.h>
#include <sys/scsi/targets/stdef.h>
\ scsi tape driver
scsi_tape
st_drivetype

View File

@@ -0,0 +1,230 @@
#ident "@(#)sun4u.fdbg 1.8 95/07/12 SMI"
#include <sys/param.h>
#include <sys/types.h>
#include <sys/user.h>
#include <sys/cred.h>
#include <sys/proc.h>
#include <sys/cpuvar.h>
#include <sys/thread.h>
#include <sys/sysinfo.h>
#include <sys/vfs.h>
#include <sys/time.h>
#include <sys/vnode.h>
#include <sys/disp.h>
#include <sys/var.h>
#include <sys/ts.h>
#include <sys/kstat.h>
#if defined(sun4) || defined(sun4c) || defined(sun4e)
#include <vm/hat_sunm.h>
#endif
#if defined(sun4m) || defined(sun4d)
#include <vm/hat_srmmu.h>
#endif
#if defined(sun4u)
#include <vm/hat_sfmmu.h>
#endif
#include <sys/ivintr.h>
#include <sys/intr.h>
#include <sys/machcpuvar.h>
#include <sys/sysiosbus.h>
#include <sys/iommu.h>
#include <sys/iocache.h>
#include <vm/anon.h>
#include <vm/as.h>
#include <vm/hat.h>
#include <vm/page.h>
#include <vm/pvn.h>
#include <vm/seg.h>
#include <vm/seg_dev.h>
#include <vm/seg_enum.h>
#include <vm/seg_kp.h>
#include <vm/seg_map.h>
#include <vm/seg_vn.h>
#include <sys/mutex_impl.h>
#include <sys/rwlock_impl.h>
#include <sys/callo.h>
#include <sys/ddi_impldefs.h>
#include <sys/kmem_impl.h>
#include <sys/siginfo.h>
#include <sys/memlist.h>
#include <sys/modctl.h>
#include <sys/kobj.h>
#include <sys/privregs.h>
#include <sys/machpcb.h>
#include <sys/traptrace.h>
intr_vector
iv_handler .adr
iv_arg x
iv_pil d
iv_mutex .mutex
machcpu
mpcb x
in_prom d
cpu_info .str
intr_head x
machpcb
mpcb_regs .regs
mpcb_wbcnt d
mpcb_fpu x
mpcb_flags x
mpcb_thread x
TRAP_TRACE_CTL.d
forth_start
alias .ttc .TRAP_TRACE_CTL.d
: cpu-ttc ( n -- )
8 to-column ." cpuid = " dup .x cr ( n )
['] .ttc sizeof * symbol trap_trace_ctl + ( trace-hdr )
.ttc ( )
;
\ Trap Trace Macros
\ print record subroutine (short)
: .sttr-hdr ( n -- n )
." cpuid = " dup .x cr
6 to-column ." tick"
d# 24 to-column ." type"
d# 32 to-column ." level"
d# 40 to-column ." trap PC" cr
;
: .sttr ( ptr -- )
dup 10 + x@ .x \ tick
d# 24 to-column dup 2 + w@ .x \ trap_type
d# 32 to-column dup w@ .x \ trap_level
d# 40 to-column 4 + l@ .adr cr \ tpc
;
\ print record subroutine (long)
: .lttr-hdr ( n -- n )
8 to-column ." cpuid = " dup .x cr
;
: .lttr ( ptr -- )
." tick = " dup 10 + x@ .x cr \ tick
." trap type = " dup 2 + w@ .x cr \ trap_type
." trap level = " dup w@ .x cr \ trap_level
." trap pc = " dup 4 + l@ .adr cr \ tpc
." tstate = " dup 8 + x@ .x cr \ tstate
." trap sp = " dup 18 + l@ .x cr \ sp
." trap tr = " dup 1c + l@ .x cr \ tr
." trap f1 = " dup 20 + l@ .x cr \ f1
." trap f2 = " dup 24 + l@ .x cr \ f2
." trap f3 = " dup 28 + l@ .x cr \ f3
." trap f4 = " 2c + l@ .x cr cr \ f4
;
: ttr-loop ( print-acf screen-acf end start -- )
do ( p-acf s-acf )
2dup i swap execute if ( p-acf s-acf p-acf addr )
swap execute ( p-acf s-acf )
exit? throw ( p-acf s-acf )
else ( p-acf s-acf p-acf addr )
2drop ( p-acf s-acf )
then ( p-acf s-acf )
-30 +loop ( p-acf s-acf )
2drop ( )
;
: ttr-bounds1 ( trace-hdr -- vaddr_base vaddr_base+last_offset )
[ also TRAP_TRACE_CTL.d-words ]
dup vaddr_base swap last_offset over +
[ previous ]
;
: ttr-bounds2 ( trace-hdr -- vaddr_base+offset vaddr_base+limit )
[ also TRAP_TRACE_CTL.d-words ]
dup vaddr_base over offset bounds ( hdr v+o v )
rot limit + ( v+o v+l )
[ previous ]
;
: do-ttr ( n print-acf screen-acf -- )
rot 40 * symbol trap_trace_ctl + ( p-acf s-acf trace-hdr )
3dup ttr-bounds1 ttr-loop ( p-acf s-acf trace-hdr )
ttr-bounds2 ttr-loop ( )
;
\ print cpu's traces in short format
: cpu-ttr ( n -- )
.sttr-hdr ['] .sttr ['] true do-ttr
;
\ print cpu's traces in long format
: cpu-xttr ( n -- )
.lttr-hdr ['] .lttr ['] true do-ttr
;
\ execute acf for each cpu
: ncpu-acf ( acf -- )
symbol cpu symbol _ncpu l@ 0 do ( acf cpu )
dup i 4 * + l@ 0<> if ( acf cpu )
over i swap execute cr ( acf cpu )
then ( acf cpu )
loop ( acf cpu )
2drop ( )
;
: ncpu-ttr ( -- ) ['] cpu-ttr ncpu-acf ;
: ncpu-xttr ( -- ) ['] cpu-xttr ncpu-acf ;
: ncpu-ttc ( -- ) ['] cpu-ttc ncpu-acf ;
forth_end
sbus_soft_state
forth_start
: .uintarray ( array-addr -- )
dup if ( array-addr )
begin dup l@ ?dup while ( array-addr item )
.x la1+ ( array-addr' )
repeat ( array-addr )
then ( array-addr )
drop
;
forth_end
io_mem_list
rdip x
ioaddr x
addr x
npages d
pfn .uintarray
next x
forth_start
: .io_mem_list_list
[ also io_mem_list-words ]
begin ?dup while
dup .io_mem_list cr next
repeat
[ previous ]
;
forth_end
forth_start
: clr_pagecol_stats
symbol sys_req_bins
200 4 *
0 fill
symbol sys_nak_bins
200 4 *
0 fill
;
forth_end

View File

@@ -0,0 +1,63 @@
#
# Copyright (c) 1991 by Sun Microsystems, Inc.
#
#ident "@(#)Makefile 1.2 95/06/14 SMI"
#
# uts/sun4u/forthdebug/forthgen/Makefile
UTSBASE = ../../..
#
# Define the module and object file sets.
#
FORTHGEN = $(OBJS_DIR)/forthgen
FORTHGEN_OBJS = parser.o stabs.o
OBJECTS = $(FORTHGEN_OBJS:%=$(OBJS_DIR)/%)
LINTS = $(FORTHGEN_OBJS:%.o=$(LINTS_DIR)/%.ln)
SRCS_DIR = $(UTSBASE)/sun4u/forthdebug/forthgen
#
# Include common rules.
#
CLEANFILES = $(OBJECTS)
FILEMODE = 755
OWNER = bin
GROUP = bin
include $(UTSBASE)/sun4u/Makefile.sun4u
NATIVECFLAGS = -c
#
# Default build targets.
#
.KEEP_STATE:
all: $(FORTHGEN)
install: all
lint: $(SRCS_DIR)/parser.c $(SRCS_DIR)/stabs.c
@$(LINT) $(LINTFLAGS) $(SRCS_DIR)/parser.c $(SRCS_DIR)/stabs.c
clean:
$(RM) $(CLEANFILES)
clobber: clean
$(RM) $(FORTHGEN)
clean.lint:
$(RM) $(LINTS)
$(FORTHGEN): $(FORTHGEN_OBJS)
$(NATIVECC) -o $@ $(FORTHGEN_OBJS) -lm
$(OBJS_DIR)/parser.o: $(SRCS_DIR)/parser.c
$(NATIVECC) $(NATIVECFLAGS) $(SRCS_DIR)/parser.c -o $@
$(OBJS_DIR)/stabs.o: $(SRCS_DIR)/stabs.c
$(NATIVECC) $(NATIVECFLAGS) $(SRCS_DIR)/stabs.c -o $@

View File

@@ -0,0 +1,504 @@
#include "stabs.h"
jmp_buf resetbuf;
char *whitesp(), *name(), *id(), *decl(), *number(), *offsize();
char *tdefdecl(), *intrinsic(), *arraydef();
void addhash();
parse_input()
{
char *cp;
int i = 0;
static char linebuf[MAXLINE];
while (i++ < BUCKETS) {
hash_table[i] = NULL;
name_table[i] = NULL;
}
/*
* get a line at a time from the .s stabs file and parse.
*/
while (cp = fgets(linebuf, MAXLINE, stdin))
parseline(cp);
}
/*
* Parse each line of the .s file (stabs entry) gather meaningful information
* like name of type, size, offsets of fields etc.
*/
parseline(cp)
char *cp;
{
struct tdesc *tdp;
char c, *w;
int h, tagdef;
int debug;
/*
* setup for reset()
*/
if (setjmp(resetbuf))
return;
/*
* Look for lines of the form
* .stabs "str",n,n,n,n
* The part in '"' is then parsed.
*/
cp = whitesp(cp);
#define STLEN 6
if (strncmp(cp, ".stabs", STLEN) != 0)
reset();
cp += STLEN;
#undef STLEN
cp = whitesp(cp);
if (*cp++ != '"')
reset();
/*
* name:type variable (ignored)
* name:ttype typedef
* name:Ttype struct tag define
*/
cp = name(cp, &w);
switch (c = *cp++) {
case 't': /* type */
tagdef = 0;
break;
case 'T': /* struct, union, enum */
tagdef = 1;
break;
default:
reset();
}
/*
* The type id and definition follow.
*/
cp = id(cp, &h);
if (*cp++ != '=')
reset();
if (tagdef) {
tagdecl(cp, &tdp, h, w);
} else {
tdefdecl(cp, &tdp);
tagadd(w, h, tdp);
}
}
/*
* Check if we have this node in the hash table already
*/
struct tdesc *
lookup(int h)
{
int hash = HASH(h);
struct tdesc *tdp = hash_table[hash];
while (tdp != NULL) {
if (tdp->id == h)
return (tdp);
tdp = tdp->hash;
}
return (NULL);
}
char *
whitesp(cp)
char *cp;
{
char *orig, c;
orig = cp;
for (c = *cp++; isspace(c); c = *cp++)
;
if (--cp == orig)
reset();
return (cp);
}
char *
name(cp, w)
char *cp, **w;
{
char *new, *orig, c;
int len;
orig = cp;
c = *cp++;
if (c == ':')
*w = NULL;
else if (isalpha(c) || c == '_') {
for (c = *cp++; isalnum(c) || c == ' ' || c == '_'; c = *cp++)
;
if (c != ':')
reset();
len = cp - orig;
new = (char *)malloc(len);
while (orig < cp - 1)
*new++ = *orig++;
*new = '\0';
*w = new - (len - 1);
} else
reset();
return (cp);
}
char *
number(cp, n)
char *cp;
long *n;
{
char *next;
*n = strtol(cp, &next, 10);
if (next == cp)
reset();
return (next);
}
char *
id(cp, h)
char *cp;
int *h;
{
long n1, n2;
if (*cp++ != '(')
reset();
cp = number(cp, &n1);
if (*cp++ != ',')
reset();
cp = number(cp, &n2);
if (*cp++ != ')')
reset();
*h = n1 * 1000 + n2;
return (cp);
}
tagadd(char *w, int h, struct tdesc *tdp)
{
struct tdesc *otdp, *hash;
tdp->name = w;
if (!(otdp = lookup(h)))
addhash(tdp, h);
else if (otdp != tdp) {
fprintf(stderr, "duplicate entry\n");
fprintf(stderr, "old: %s %d %d %d\n",
otdp->name ? otdp->name : "NULL",
otdp->type, otdp->id / 1000, otdp->id % 1000);
fprintf(stderr, "new: %s %d %d %d\n",
tdp->name ? tdp->name : "NULL",
tdp->type, tdp->id / 1000, tdp->id % 1000);
}
}
tagdecl(cp, rtdp, h, w)
char *cp;
struct tdesc **rtdp;
int h;
char *w;
{
if (*rtdp = lookup(h)) {
if ((*rtdp)->type != FORWARD)
fprintf(stderr, "found but not forward: %s \n", cp);
} else {
*rtdp = ALLOC(struct tdesc);
(*rtdp)->name = w;
addhash(*rtdp, h);
}
switch (*cp++) {
case 's':
soudef(cp, STRUCT, rtdp);
break;
case 'u':
soudef(cp, UNION, rtdp);
break;
case 'e':
enumdef(cp, rtdp);
break;
default:
reset();
}
}
char *
tdefdecl(cp, rtdp)
char *cp;
struct tdesc **rtdp;
{
struct tdesc *tdp, *ntdp;
char *w;
int c, h;
/* Type codes */
switch (*cp) {
case 'b': /* integer */
c = *++cp;
if (c != 's' && c != 'u')
reset();
c = *++cp;
if (c == 'c')
cp++;
cp = intrinsic(cp, rtdp);
break;
case 'R': /* fp */
cp += 3;
cp = intrinsic(cp, rtdp);
break;
case '(': /* equiv to another type */
cp = id(cp, &h);
ntdp = lookup(h);
if (ntdp == NULL) {
if (*cp++ != '=')
reset();
cp = tdefdecl(cp, rtdp);
addhash(*rtdp, h); /* for *(x,y) types */
} else {
*rtdp = ALLOC(struct tdesc);
(*rtdp)->type = TYPEOF;
(*rtdp)->data.tdesc = ntdp;
}
break;
case '*':
cp = tdefdecl(cp + 1, &ntdp);
*rtdp = ALLOC(struct tdesc);
(*rtdp)->type = POINTER;
(*rtdp)->size = sizeof (void *);
(*rtdp)->name = "pointer";
(*rtdp)->data.tdesc = ntdp;
break;
case 'f':
cp = tdefdecl(cp + 1, &ntdp);
*rtdp = ALLOC(struct tdesc);
(*rtdp)->type = FUNCTION;
(*rtdp)->size = sizeof (void *);
(*rtdp)->name = "function";
(*rtdp)->data.tdesc = ntdp;
break;
case 'a':
cp++;
if (*cp++ != 'r')
reset();
*rtdp = ALLOC(struct tdesc);
(*rtdp)->type = ARRAY;
(*rtdp)->name = "array";
cp = arraydef(cp, rtdp);
break;
case 'x':
c = *++cp;
if (c != 's' && c != 'u' && c != 'e')
reset();
cp = name(cp + 1, &w);
*rtdp = ALLOC(struct tdesc);
(*rtdp)->type = FORWARD;
(*rtdp)->name = w;
break;
default:
reset();
}
return (cp);
}
char *
intrinsic(cp, rtdp)
char *cp;
struct tdesc **rtdp;
{
struct tdesc *tdp;
long size;
cp = number(cp, &size);
tdp = ALLOC(struct tdesc);
tdp->type = INTRINSIC;
tdp->size = size;
tdp->name = NULL;
*rtdp = tdp;
return (cp);
}
soudef(cp, type, rtdp)
char *cp;
enum type type;
struct tdesc **rtdp;
{
struct mlist *mlp, **prev;
char *w;
int h, i = 0;
long size;
struct tdesc *tdp;
char linebuf[MAXLINE];
cp = number(cp, &size);
(*rtdp)->size = size;
(*rtdp)->type = type; /* s or u */
prev = &((*rtdp)->data.members);
/* now fill up the fields */
while ((*cp != '"') && (*cp != ';')) { /* signifies end of fields */
mlp = ALLOC(struct mlist);
*prev = mlp;
cp = name(cp, &w);
mlp->name = w;
cp = id(cp, &h);
/*
* find the tdesc struct in the hash table for this type
* and stick a ptr in here
*/
tdp = lookup(h);
if (tdp == NULL) { /* not in hash list */
if (*cp++ != '=')
reset();
cp = tdefdecl(cp, &tdp);
addhash(tdp, h);
}
mlp->fdesc = tdp;
cp = offsize(cp, mlp);
/* cp is now pointing to next field */
prev = &mlp->next;
/* could be a continuation */
if (*cp == '\\') {
/* get next line */
cp = fgets(linebuf, MAXLINE, stdin);
while (*cp++ != '"')
;
}
}
}
char *
offsize(cp, mlp)
char *cp;
struct mlist *mlp;
{
long offset, size;
if (*cp++ != ',')
reset();
cp = number(cp, &offset);
if (*cp++ != ',')
reset();
cp = number(cp, &size);
if (*cp++ != ';')
reset();
mlp->offset = offset;
mlp->size = size;
return (cp);
}
char *
arraydef(char *cp, struct tdesc **rtdp)
{
int h;
long start, end;
cp = id(cp, &h);
if (*cp++ != ';')
reset();
(*rtdp)->data.ardef = ALLOC(struct ardef);
(*rtdp)->data.ardef->indices = ALLOC(struct element);
(*rtdp)->data.ardef->indices->index_type = lookup(h);
cp = number(cp, &start);
if (*cp++ != ';')
reset();
cp = number(cp, &end);
if (*cp++ != ';')
reset();
(*rtdp)->data.ardef->indices->range_start = start;
(*rtdp)->data.ardef->indices->range_end = end;
cp = tdefdecl(cp, &((*rtdp)->data.ardef->contents));
return (cp);
}
enumdef(char *cp, struct tdesc **rtdp)
{
char *next;
struct elist *elp, **prev;
char *w;
char linebuf[MAXLINE];
(*rtdp)->type = ENUM;
prev = &((*rtdp)->data.emem);
while (*cp != ';') {
elp = ALLOC(struct elist);
*prev = elp;
cp = name(cp, &w);
elp->name = w;
cp = number(cp, &elp->number);
prev = &elp->next;
if (*cp++ != ',')
reset();
if (*cp == '\\') {
cp = fgets(linebuf, MAXLINE, stdin);
while (*cp++ != '"')
;
}
}
}
/*
* Add a node to the hash queues.
*/
void
addhash(tdp, num)
struct tdesc *tdp;
int num;
{
int hash = HASH(num);
tdp->id = num;
tdp->hash = hash_table[hash];
hash_table[hash] = tdp;
if (tdp->name) {
hash = compute_sum(tdp->name);
tdp->next = name_table[hash];
name_table[hash] = tdp;
}
}
struct tdesc *
lookupname(name)
char *name;
{
int hash = compute_sum(name);
struct tdesc *tdp, *ttdp = NULL;
for (tdp = name_table[hash]; tdp != NULL; tdp = tdp->next) {
if (tdp->name != NULL && strcmp(tdp->name, name) == 0) {
if (tdp->type == STRUCT || tdp->type == UNION ||
tdp->type == ENUM)
return (tdp);
if (tdp->type == TYPEOF)
ttdp = tdp;
}
}
return (ttdp);
}
int
compute_sum(char *w)
{
char c;
int sum;
for (sum = 0; c = *w; sum += c, w++)
;
return (HASH(sum));
}
reset()
{
longjmp(resetbuf, 1);
/* NOTREACHED */
}

View File

@@ -0,0 +1,435 @@
#include <math.h>
#include "stabs.h"
char *convert_format();
int line;
main(int argc, char **argv)
{
parse_input();
get_dbgs(argc, argv);
exit(0);
}
/*
* This routine will read the .dbg files and build a list of the structures
* and fields that user is interested in. Any struct specified will get all
* its fields included. If nested struct needs to be printed - then the
* field name and name of struct type needs to be included in the next line.
*/
get_dbgs(int argc, char **argv)
{
FILE *fp;
for (argc--, argv++; argc != 0; argc--, argv++) {
if ((fp = fopen(*argv, "r")) == NULL)
fprintf(stderr, "Cannot open %s\n", *argv);
/* add all types in this file to our table */
parse_dbg(fp);
}
}
char *
namex(char *cp, char **w)
{
char *new, *orig, c;
int len;
for (c = *cp++; isspace(c); c = *cp++)
;
orig = --cp;
c = *cp++;
if (isalpha(c) || ispunct(c)) {
for (c = *cp++; isalnum(c) || ispunct(c); c = *cp++)
;
len = cp - orig;
new = (char *)malloc(len);
while (orig < cp - 1)
*new++ = *orig++;
*new = '\0';
*w = new - (len - 1);
} else
fprintf(stderr, "line %d has bad character %c\n", line, c);
return (cp);
}
/*
* checks to see if this field in the struct was requested for by user
* in the .dbg file.
*/
struct child *
find_child(struct node *np, char *w)
{
struct child *chp;
for (chp = np->child; chp != NULL; chp = chp->next) {
if (strcmp(chp->name, w) == 0)
return (chp);
}
return (NULL);
}
struct tdesc *
find_member(struct tdesc *tdp, char *name)
{
struct mlist *mlp;
while (tdp->type == TYPEOF)
tdp = tdp->data.tdesc;
if (tdp->type != STRUCT && tdp->type != UNION)
return (NULL);
for (mlp = tdp->data.members; mlp != NULL; mlp = mlp->next)
if (strcmp(mlp->name, name) == 0)
return (mlp->fdesc);
return (NULL);
}
/*
* add this field to our table of structs/fields that the user has
* requested in the .dbg files
*/
addchild(char *cp, struct node *np)
{
struct child *chp;
char *w;
chp = ALLOC(struct child);
cp = namex(cp, &w);
chp->name = w;
cp = namex(cp, &w);
chp->format = w;
chp->next = np->child;
np->child = chp;
}
/*
* add this struct to our table of structs/fields that the user has
* requested in the .dbg files
*/
struct node *
getnode(char *cp)
{
char *w;
struct node *np;
int sum = 0;
cp = namex(cp, &w);
np = ALLOC(struct node);
np->name = w;
np->child = NULL;
return (np);
}
/*
* Format for .dbg files should be
* Ex:
* seg
* as s_as
* if you wanted the contents of "s_as" (a pointer) to be printed in
* the format of a "as"
*/
parse_dbg(FILE *sp)
{
char *cp;
struct node *np;
static char linebuf[MAXLINE];
int copy_flag = 0;
/* grab each line and add them to our table */
for (line = 1; cp = fgets(linebuf, MAXLINE, sp); line++) {
if (*cp == '\n') {
if (copy_flag)
printf("\n");
continue;
}
if (*cp == '\\')
continue;
if (strcmp(cp, "forth_start\n") == 0) {
copy_flag = 1;
continue;
}
if (strcmp(cp, "forth_end\n") == 0) {
copy_flag = 0;
continue;
}
if (copy_flag) {
printf("%s", cp);
continue;
}
np = getnode(cp);
for (line++;
(cp = fgets(linebuf, MAXLINE, sp)) && *cp != '\n';
line++) {
/* members of struct, union or enum */
addchild(cp, np);
}
printnode(np);
}
}
printnode(struct node *np)
{
struct tdesc *tdp;
tdp = lookupname(np->name);
if (tdp == NULL) {
char *member;
struct tdesc *ptdp;
if (member = strchr(np->name, '.')) {
*member = '\0';
ptdp = lookupname(np->name);
if (ptdp != NULL)
tdp = find_member(ptdp, member + 1);
*member = '.';
}
if (tdp == NULL) {
fprintf(stderr, "Can't find %s\n", np->name);
return;
}
}
again:
switch (tdp->type) {
case STRUCT:
case UNION:
do_sou(tdp, np);
break;
case ENUM:
do_enum(tdp, np);
break;
case TYPEOF:
tdp = tdp->data.tdesc;
goto again;
default:
fprintf(stderr, "%s isn't aggregate\n", np->name);
break;
}
}
do_sou(struct tdesc *tdp, struct node *np)
{
struct mlist *mlp;
struct child *chp;
char *name, *format;
printf("\n");
printf("vocabulary %s-words\n", np->name);
printf("%x ' %s-words c-struct .%s\n",
tdp->size, np->name, np->name);
printf("also %s-words definitions\n\n", np->name);
/*
* Run thru all the fields of a struct and print them out
*/
for (mlp = tdp->data.members; mlp != NULL; mlp = mlp->next) {
/*
* If there's a child list, only print those members.
*/
if (np->child) {
chp = find_child(np, mlp->name);
if (chp == NULL)
continue;
format = chp->format;
} else
format = NULL;
switch_on_type(mlp, mlp->fdesc, format, 0);
}
printf("\nkdbg-words definitions\n");
printf("previous\n\n");
printf("\\ end %s section\n\n", np->name);
}
do_enum(struct tdesc *tdp, struct node *np)
{
int nelem = 0;
struct elist *elp;
printf("\n");
for (elp = tdp->data.emem; elp != NULL; elp = elp->next) {
printf("here ,\" %s\" %x\n", elp->name, elp->number);
nelem++;
}
printf("%x c-enum .%s\n", nelem, np->name);
}
switch_on_type(struct mlist *mlp, struct tdesc *tdp, char *format, int level)
{
switch (tdp->type) {
case INTRINSIC:
print_intrinsic(mlp, tdp, format, level);
break;
case POINTER:
print_pointer(mlp, tdp, format, level);
break;
case ARRAY:
print_array(mlp, tdp, format, level);
break;
case FUNCTION:
print_function(mlp, tdp, format, level);
break;
case UNION:
print_union(mlp, tdp, format, level);
break;
case ENUM:
print_enum(mlp, tdp, format, level);
break;
case FORWARD:
print_forward(mlp, tdp, format, level);
break;
case TYPEOF:
print_typeof(mlp, tdp, format, level);
break;
case STRUCT:
print_struct(mlp, tdp, format, level);
break;
default:
fprintf(stderr, "Switch to Unknown type\n");
break;
}
}
print_forward(struct mlist *mlp, struct tdesc *tdp, char *format, int level)
{
fprintf(stderr, "%s never defined\n", mlp->name);
}
print_typeof(struct mlist *mlp, struct tdesc *tdp, char *format, int level)
{
switch_on_type(mlp, tdp->data.tdesc, format, level);
}
print_intrinsic(struct mlist *mlp, struct tdesc *tdp, char *format, int level)
{
format = convert_format(format, ".x");
if (level != 0)
switch (tdp->size) {
case 1:
printf("' c@ ' %s", format);
break;
case 2:
printf("' w@ ' %s", format);
break;
case 4:
printf("' l@ ' %s", format);
break;
case 8:
printf("' x@ ' %s", format);
break;
}
/*
* Check for bit field.
*/
else if ((mlp->size % 8) != 0 || (mlp->offset % mlp->size) != 0) {
int offset, shift, mask;
offset = (mlp->offset / 32) * 4;
shift = 32 - ((mlp->offset % 32) + mlp->size);
mask = ((int)pow(2, mlp->size) - 1) << shift;
printf("' %s %x %x %x bits-field %s\n",
format, shift, mask, offset, mlp->name);
} else {
switch (tdp->size) {
case 1:
printf("' %s %x byte-field %s\n",
format, mlp->offset / 8, mlp->name);
break;
case 2:
printf("' %s %x short-field %s\n",
format, mlp->offset / 8, mlp->name);
break;
case 4:
printf("' %s %x long-field %s\n",
format, mlp->offset / 8, mlp->name);
break;
case 8:
printf("' %s %x ext-field %s\n",
format, mlp->offset / 8, mlp->name);
break;
}
}
}
print_pointer(struct mlist *mlp, struct tdesc *tdp, char *format, int level)
{
format = convert_format(format, ".x");
if (level != 0)
printf("' l@ ' %s", format);
else {
printf("' %s %x ptr-field %s\n",
format, mlp->offset / 8, mlp->name);
}
}
print_array(struct mlist *mlp, struct tdesc *tdp, char *format, int level)
{
struct ardef *ap = tdp->data.ardef;
int items, inc, limit;
if (level != 0)
fprintf(stderr, "");
else {
items = ap->indices->range_end - ap->indices->range_start + 1;
inc = (mlp->size / items) / 8;
limit = mlp->size / 8;
switch_on_type(mlp, ap->contents, format, level + 1);
printf(" %x %x %x", limit, inc, mlp->offset / 8);
printf(" array-field %s\n", mlp->name);
}
}
print_function(struct mlist *mlp, struct tdesc *tdp, char *format, int level)
{
fprintf(stderr, "function in struct %s\n", tdp->name);
}
print_struct(struct mlist *mlp, struct tdesc *tdp, char *format, int level)
{
format = convert_format(format, ".x");
if (level != 0)
printf("' noop ' %s", format);
else {
printf("' %s %x struct-field %s\n",
format, mlp->offset / 8, mlp->name);
}
}
print_union(struct mlist *mlp, struct tdesc *tdp, char *format, int level)
{
format = convert_format(format, ".x");
if (level != 0)
printf("' noop ' %s", format);
else {
printf("' %s %x struct-field %s\n",
format, mlp->offset / 8, mlp->name);
}
}
print_enum(struct mlist *mlp, struct tdesc *tdp, char *format, int level)
{
format = convert_format(format, ".d");
if (level != 0)
printf("' l@ ' %s", format);
else
printf("' %s %x long-field %s\n",
format, mlp->offset / 8, mlp->name);
}
char *
convert_format(char *format, char *dfault)
{
static char dot[3] = ".";
if (format == NULL)
return (dfault);
else if (strlen(format) == 1) {
dot[1] = *format;
return (dot);
} else
return (format);
}

View File

@@ -0,0 +1,101 @@
/*
* Copyright (c) 1994, by Sun Microsystems, Inc.
* All rights reserved.
*/
#ifndef _SYS_STABS_H
#define _SYS_STABS_H
#pragma ident "@(#)stabs.h 1.7 95/03/16 SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <setjmp.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#define MAXLINE 1024
#define BUCKETS 128
struct tdesc *hash_table[BUCKETS];
struct tdesc *name_table[BUCKETS];
struct node {
char *name;
struct child *child;
};
struct child {
char *name;
char *format;
struct child *next;
};
#define HASH(NUM) ((int)(NUM & (BUCKETS - 1)))
enum type {
INTRINSIC,
POINTER,
ARRAY,
FUNCTION,
STRUCT,
UNION,
ENUM,
FORWARD,
TYPEOF,
};
struct tdesc {
char *name;
struct tdesc *next;
enum type type;
int size;
union {
struct tdesc *tdesc; /* *, f , to */
struct ardef *ardef; /* ar */
struct mlist *members; /* s, u */
struct elist *emem; /* e */
} data;
int id;
struct tdesc *hash;
};
struct elist {
char *name;
int number;
struct elist *next;
};
struct element {
struct tdesc *index_type;
int range_start;
int range_end;
};
struct ardef {
struct tdesc *contents;
struct element *indices;
};
struct mlist {
int offset;
int size;
char *name;
struct mlist *next;
struct tdesc *fdesc; /* s, u */
};
#define ALLOC(t) ((t *)malloc(sizeof (t)))
struct tdesc *lookupname();
#ifdef __cplusplus
}
#endif
#endif /* _SYS_STABS_H */