DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Using SCODB

Calling functions

Arbitrary functions can be called, by using the C syntax for calling functions; a function call may occur anywhere in an expression. For example, to call the function ps (which is built into SCODB):

   debug0:18> ps()
   FLAGS S UID  PID PPID CPU PRI  NI  WAITCHAN     CMD
    2019 S   0    0    0   0   0  14  runout       sched
   ...
Arguments can be passed to functions:
   debug0:19> outb($port, $value)
   0
Any function in the kernel can be called from within SCODB. In addition SCODB includes some functions that may be useful. A full list can be obtained by typing ? at the command line):

hexdump(addr, mode, len)
dump memory; useful from breakpoint commands

dgdt( )
dump global descriptor table

ddt(addr, nentries)
dump descriptor table, nentries long

ltop(addr)
convert a linear address to a physical address

ptol(addr)
convert a physical address to a linear address

patch_call(addr, func)
patch a call instruction to call a new function

patch_nop(addr)
patch out an instruction with nops

pkill(pid, signal)
send pid a signal

ps( )
show process table similar to ps(C) or crash(ADM) proc

The output format of the ps( ) function can be modified by changing the contents of an internal SCODB variable called scodb_options. The default style is to output the process slot number in the first column. By setting bit 1 (the value 2) in the scodb_options variable, the process flags are displayed in the first column instead (this is the original style):

   debug0:19> scodb_options=2
   2
   debug0:20> ps()
   FLAGS S UID  PID PPID CPU PRI  NI  WAITCHAN     CMD
    2019 S   0    0    0   0   0  14  F01F47C4     sched
   ...
The ``waitchan'' field can be displayed numerically rather than symbolically by setting bit 2 (the value 4) in scodb_options:
   debug0:19> scodb_options=4
   4
   debug0:20> ps()
   SLOT  S UID  PID PPID CPU PRI  NI  WAITCHAN     CMD
     0   S   0    0    0   0   0  14  F01F47C4     sched
   ...

reboot( )
reboot machine

pidtoproc(pid)
return the proc structure for the PID of a process that is displayed in a ps( ) listing

dpt(addr)
dump out a page table

db_search_pt(addr, pfn)
search a page table for a page frame

db_search_region(pfn)
check if a page frame belongs to any region

dbtty(n)
switch the debugger between screen (0) and sio (1). The dbtty( ) function deals with the situation where a machine has panicked and is in the debugger, but the console is in graphics mode. Note that SCODB does not initialize the serial port.

eps( )
similar to ps( ), but shows which processes are running on which processors in a multiprocessor configuration.

vuifile(&var, cpuindex)
display per-CPU variables for another CPU on a multiprocessor configuration

saveu(N)
save N swapped-out u-areas for stack backtrace

regions(pid_or_proc_adr)
display pregion and region info for process

Be careful when calling functions because SCODB does not check the argument type or value.

Note that, on multiprocessing configuration, calling the inb(K) and outb(K) family of functions from SCODB on a processor that does not have access to the I/O bus has unpredictable results. Character strings enclosed in double-quotes are placed in temporary memory, and are valid for the duration of the expression in which they occur, and have the type char *. Note that a string used in one expression should not be used in another expression, since the memory may have been reused for another string since then, so debugger variables should not be assigned string values:

   debug0:20> var s1 "string 1"
   debug0:21> var s2 "string 2"
   debug0:22> $s1 == $s2
   1
An example of proper use of string literals is in breakpoint commands, to use the printf( ) function:
   debug0:23> bp mod open
   Enter commands to execute at breakpoint:
   [1] {>}printf("open(%s, %o, %o)\n", u.u_arg[0], u.u_arg[1], u.u_arg[2])
   [2] q
   [3] <Esc>
   :q
In the above breakpoint example, each time open( ) is called, its arguments are printed, and control returned to the kernel.

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003