Tool Command Language: 6.1 Coding: Swat Data Structure Commands

Up: GEOS SDK TechDocs | Up | Prev: 6 Coding | Next: 6.2 Examples
symbol, type, patient, handle, brk, cbrk, event, thread, src, cache, table

This section contains information about Swat's built-in data structures and the commands that access them. These commands examine and modify vital information about the state of GEOS while it is running under Swat.

brk

brk <addr> [<command>]
brk pset <addr> [<command>]
brk aset <addr> [<command>]
brk tset <addr> [<command>]
brk clear <break>*
brk delete <break>*
brk enable <break>*
brk disable <break>*
brk address <break>
brk list [<addr>]
brk debug [<flag>]
brk isset <addr>
brk cond <break> <condition>*
brk cmd <break> [<command>]
brk delcmd <break> [<command>]

Examples:

"brk WinOpen"
Sets the machine to stop unconditionally when any thread calls WinOpen.
"brk pset WinOpen"
Sets the machine to stop when any thread for the current patient calls WinOpen.
"brk tset WinOpen"
Sets the machine to stop when any thread for the current patient calls WinOpen, and deletes the breakpoint when the machine next stops.
"brk enable 1 3-5"
Re-enables breakpoints 1, 3, 4, and 5
"brk clear 2-"
Clears all breakpoints from number 2 onward.
"brk cond 3 cx=42"
Sets breakpoint 3 to be conditional, stopping when the machine reaches the breakpoint's address with CX being 42.
"brk cond 2 (ss:0)!=1b80h"
Sets breakpoint 2 to be conditional, stopping when the machine reaches the breakpoint's address with the word at ss:0 not being 1b80h. Note that the "ss" is the value of the ss register when the "brk cond" command is executed, not when the breakpoint is reached.

Allows you to specify that execution should stop when it reaches a particular point. These breakpoints can be conditional, and can execute an arbitrary Tcl command, which can say whether the machine is to remain stopped, or continue on its way.

cache

cache create (lru|fifo) <maxSize> [<flushProc>]
cache destroy <cache> [flush|noflush]
cache lookup <cache> <key>
cache enter <cache> <key>
cache invalone <cache> <entry>
cache invalall <cache> [flush|noflush]
cache key <cache> <entry>
cache size <cache>
cache maxsize <cache>
cache setmaxsize <cache> <maxSize>
cache getval <cache> <entry>
cache setval <cache> <entry> <value>

Examples:

"var cache [cache create lru 10]"
Creates a cache of 10 items that are flushed on a least-recently-used basis. The returned token is saved for later use.
"var entry [cache lookup $cache mom]"
Sees if an entry with the key "mom" is in the cache and saves its entry token if so.
"echo mom=[cache getval $cache $entry]"
Retrieves the value stored in the entry for "mom" and echoes it.
"cache invalone $cache $entry"
Flushes the entry just found from the cache.
"cache destroy $cache"
Destroys the cache.

The cache command, as the name implies, maintains a cache of data that is keyed by strings. When a new entry is added to an already-full cache, an existing entry is automatically flushed based on the usage message with which the cache was created: lru (last recently used) or fifo (first in, first out). If lru , the least-recently-used entry is flushed; if fifo , the oldest entry is flushed.

cbrk

cbrk <addr> <condition>*
cbrk aset <addr> <condition>*
cbrk tset <addr> <condition>*
cbrk clear <break>*
cbrk delete <break>*
cbrk enable <break>*
cbrk disable <break>*
cbrk address <break>
cbrk list [<addr>]
cbrk debug [<flag>]
cbrk isset <addr>
cbrk cond <break> <condition>*
cbrk cmd <break> [<command>]
cbrk delcmd <break> [<command>]

Examples:

"cbrk WinOpen di=1b80h"
Stops the machine when execution reaches WinOpen() with di set to 1b80h.

Allows you to set fast conditional breakpoints.

event

event <subcommand>

The event command provides access to Swat's internal events. The subcommands are as follows:

handle <eventName> <handler> [<data>]
The <handler> procedure is invoked each time an event of type <eventName> is dispatched. The handler receives two arguments: an event-specific piece of data, and the given <data>. A handler procedure should be declared
proc <handler> {arg data} {<body>}

The handle subcommand returns an <event> for later use in deleting it. The <handler> should return one of event_handled , event_not_handled , or event_stop_handling . If it returns event_stop_handling , the event will not be dispatched to any other handlers of the event.

delete <event>
Deletes the given event handler given by the event handle command.
dispatch <eventName> <arg>
Dispatches the given event with the given <arg> to all handlers of that event. If <eventName> is a pre-defined event type, <arg> will be converted to the appropriate type before being dispatched. Otherwise it is passed as a string.
create
Returns a number that represents a new event type. Handlers may then be defined for and events dispatched of the new type.
list
Lists all Tcl-registered events by event-name and handler function.

The events which are currently defined are:

FULLSTOP
Generated when patient stops for a while. Argument is string telling why the patient stopped.
CONTINUE
Generated just before the patient is continued. The argument is non-zero if going to single-step.
TRACE
Generated when the execution of a source line completes and the patient is in line-trace mode.
START
Generated when a new patient/thread is created. Argument is patient token of the patient involved.
STACK
Current stack frame has changed. The argument is non-zero if the stack change comes from a change in patients/threads or zero if the change comes from actually going up or down the stack in the current patient.
DETACH
Detaching from the PC. The argument is always zero.
RESET
Returning to the top level. The argument is always zero.
ATTACH
Attached to the PC. The argument is always zero.
RELOAD
Kernel was reloaded. The argument is always zero.
CHANGE
Current patient has changed. The argument is the token for the previous patient.
STEP
Machine has stepped a single instruction. The argument is the value to pass to patient stop if you wish the machine to stay stopped.
STOP
Machine has hit a breakpoint. The argument is the value to pass to patient stop if you wish the machine to stay stopped.
INT
Machine has hit some other interrupt that's being caught. The argument is the interrupt number. The machine will remain stopped unless it is continued with continue-patient.

handle

handle lookup <id>
handle find <address>
handle all
handle nointerest <interest-record>
handle interest <handle> <proc> [<data>+]
handle segment <handle>
handle size <handle>
handle state <handle>
handle owner <handle>
handle patient <handle>
handle other <handle>
handle id <handle>
handle isthread <handle>
handle iskernel <handle>
handle isfile <handle>
handle isvm <handle>
handle ismem <handle>

Examples:

"handle lookup [read-reg bx]"
get the handle token for the handle whose ID is in the BX register.
"handle interest $h ob-interest-proc [concat si=$chunk $message]"
call ob-interest-proc, passing the list {si=$chunk $message}, whenever the state of the handle whose token is in $h changes.
"handle patient $h"
get the token for the patient that owns the handle whose token is in $h
"handle all"
get the list of the ID's of all handles currently in Swat's handle table.

The "handle" command provides access to the structures Swat uses to track memory and thread allocation on the PC.

patient

patient find <name>
patient name [<patient>]
patient fullname [<patient>]
patient data [<patient>]
patient threads [<patient>]
patient resources [<patient>] 
patient libs [<patient>]
patient path [<patient>]
patient all
patient stop [<addr>]

Examples:

"patient find geos"
Returns the patient token for the kernel, if it's been loaded yet.
"patient fullname $p"
Returns the permanent name for the patient whose token is stored in the variable p.
"patient stop $data"
Tells the dispatcher of the STEP event that it should keep the machine stopped when the STEP event has been handled by everyone.

This command provides access to the various pieces of information that are maintained for each patient (geode) loaded by GEOS.

src

src line <addr>
src read <file> <line>
src cache [<max>]
src addr <file> <line> [<patient>]

Examples:

"src line cs:ip"
Returns a two-list holding the source-line number, and the absolute path of the file in which it lies (not in this order), that encompasses CS:IP.
"src read /pcgeos/appl/sdk_c/hello/hello.goc 64"
Reads the single given source line from the given file.
"src addr icdecode.c 279"
Returns an address-list for the start of the code produced for the given line.
"src cache 10"
Allow 10 source files to be open at a time. This is the default.

The "src" command allows the Tcl programmer to manipulate the source- line maps contained in all the geodes' symbol files.

symbol

symbol find <class> <name> [<scope>]
symbol faddr <class> <addr>
symbol match <class> <pattern>
symbol scope <symbol>
symbol name <symbol>
symbol fullname <symbol>
symbol class <symbol>
symbol type <symbol>
symbol get <symbol>
symbol patient <symbol>
symbol tget <symbol>
symbol addr <symbol>
symbol foreach <scope> <class> <callback> [<data>]

Examples:

"symbol find type LMemType"
Locate a type definition named LMemType
"symbol faddr proc cs:ip"
Locate the procedure in which CS:IP lies.
"symbol faddr {proc label} cs:ip"
Locate the procedure or label just before cs:ip.
"symbol fullname $sym"
Fetch the full name of the symbol whose token is in the $sym variable.
"symbol scope $sym"
Fetch the token of the scope containing the passed symbol. This will give the structure containing a structure field, or the procedure containing a local variable, for example.

Provides information on the symbols for all currently-loaded patients. Like many of Swat's commands, this operates by using a lookup function (the "find", "faddr", "match", or "foreach" subcommands) to obtain a token for a piece of data that's internal to Swat. Given this token, you then use the other subcommands (such as "name" or "get") to obtain information about the symbol you looked up.

See Also: type.

table

table create [<initBuckets>]
table destroy <table>
table enter <table> <key> <value>
table lookup <table> <key>
table remove <table> <key>

Examples:

"var kitchen [table create 32]"
Create a new table with 32 hash buckets initially.
"table enter $t tbrk3 {1 2 3}"
Enter the value "1 2 3" under the key "tbrk3" in the table whose token is stored in the variable t.
"table lookup $t tbrk4"
Fetch the value, if any, stored under the key "tbrk4" in the table whose token is stored in the variable t.
"table remove $t tbrk3"
Remove the data stored in the table, whose token is stored in the variable t, under the key "tbrk3"
"table destroy $t"
Destroy the table $t and all the data stored in it.
(mess1:0) 159 => var yearTable [table create]
(mess1:0) 160 => table enter $yearTable synclavier 1979
(mess1:0) 161 => table enter $yearTable moog 1966
(mess1:0) 162 => table lookup $yearTable synclavier
1979
(mess1:0) 163 => var yearTable
1403188
(mess1:0) 164 => table lookup 1403188 moog
1966
(mess1:0) 165 => table remove $yearTable synclavier
(mess1:0) 166 => table lookup $yearTable synclavier
nil
(mess1:0) 167 => table destroy $yearTable

The "table" command is used to create, manipulate and destroy hash tables. The entries in the table are keyed on strings and contain strings, as you'd expect from Tcl.

thread

thread id <thread>
thread register <thread> <regName>
thread handle <thread>
thread endstack <thread>
thread number <thread>
thread all

Examples:

"thread register $t cx"
Fetches the value for the CX register for the given thread.
"thread number $t"
Fetches number swat assigned to thread when it was first encountered.
(mess1:0) 145 => patient threads
2667104
(mess1:0) 146 => thread id 2667104
11184
(mess1:0) 147 => thread all
767532 756068 1348520 1348868 1349216 1349748 1350236 1402096 1079392 2667104
(mess1:0) 148 => thread handle 756068
880428
(mess1:0) 149 => thread number 756068
0

Returns information about a thread, given its thread token. Thread tokens can be obtained via the "patient threads" command, or the "handle other" command applied to a thread handle's token.

type

type <basic-type-name> 
type make array <length> <base-type>
type make pstruct (<field> <type>)+
type make struct (<field> <type> <bit-offset> <bit-length>)+
type make union (<field> <type>)+
type make <ptr-type> <base-type>
type delete <type>
type size <type>
type class <type>
type name <type> <var-name> <expand>
type aget <array-type>
type fields <struct-type>
type members <enum-type>
type pget <ptr-type>
type emap <num> <enum-type>
type signed <type>
type field <struct-type> <offset>
type bfget <bitfield-type> 

Examples:

"type word"
Returns a type token for a word (2-byte unsigned quantity).
"type make array 10 [type char]"
Returns a type token for a 10-character array.
"type make optr [symbol find type GenBase]"
Returns a type token for an optr (4-byte global/local handle pair) to a "GenBase" structure.

Provides access to the type descriptions by which all PC-based data are manipulated in Swat, and allows a Tcl procedure to obtain information about a type for display to the user, or for its own purposes. As with other Swat commands, this works by calling one subcommand to obtain an opaque "type token", which you then pass to other commands.

See Also: gc, symbol, value.


Up: GEOS SDK TechDocs | Up | Prev: 6 Coding | Next: 6.2 Examples