Download HP-UX KWDB Kernel Debugger Guide
Transcript
KWDB PERL Programming Reference
Writing Scripts
$dpta = 0;
} else {
$dpta = 1;
}
#
#
#
#
the kernel global, dpta_supported, was added so only the
linked list version of the kernel has this variable and we
can use it to differentiate between the two types of kernel
at debug-time.
if ($dpta == 0 ) {
$aplr = &Load(’struct proc from proc max nproc’);
if($aplr <= 0) {
printf( “Fatal error, no processes to load!\n”);
die;
} else {
# keep only the used ones
$aplr = &Keep(’p_stat != 0’);
&Forget(-1);
}
} else { # This is DPTA
$aplr = &Load(’struct proc from proc_list max nproc next
p_global_proc’);
if($aplr <= 0) {
printf( “Fatal error, no processes to load!\n”);
die;
} else {
# keep only the used ones
$aplr = &Keep(’p_stat != 0’);
&Forget(-1);
}
} # end DPTA case
By isolating this knowledge of the data structure in a single routine make the rest of the library of debugging
routines independent of the navigation required to get the data structures. This will pay off down the road
when the data structures change again and have less debugging code to change when the schedule can least
afford it.
234
Chapter 7