home *** CD-ROM | disk | FTP | other *** search
- /*
- Usage: ShowProcess [<task name> | 0xnnnnnnnn]
- Version 1.01 04-Nov-88
-
- Displays the process structure for the given task. If none is specified,
- the current task under debugger control is displayed. ShowProcess will
- verify that the indicated task is a valid process before displaying the
- information.
-
- Note that because of the Amiga Scheduling, ShowProcess may not always be
- able to find a task specified by name.
-
- Output is displayed in the form:
- --------------------------------
- 'RAW' in wait state at priority 5
- Type 13 Flags 00 IDNestCnt 0 TDNestCnt -1
- Signal: Alloc 0000FFFF Wait 00000100 Recvd 00000000 Except 00000000
- Trap: Data 00000000 Code 00FF47EA Alloc 8000 Able 0000
- Except: Data 00000000 Code 00FC2FF0
- Stack: Reg 0027368E Lower 00272BFC Upper 002736EC
- CPURegs: PC 00FC08F4 SR 0010
- D: 0023D158 00000000 002721CC 00272778 00000009 00000052 00000057 00272B9C
- A: 00FF4134 00272B40 00C04EC8 00FF9FF2 00FF4648 00C00240 00C00276
- Process Dependent ---------------------------------------------
- SegList 0x00200C6C StackSize 0x00000AF0 GlobVec0x00C04EC8
- TaskNum 0 StackBase 0x00272BFC Result2 0
- CurrentDir 0x00000000 CIS 0x00000000 COS 0x00000000
- ConsoleTask0x0022F264 FileSysTask0x00C00ADC CLI 0x00000000
- ReturnAddr 0x002736E8 PktWait 0x00000000
- */
-
- address 'COMMAND'
- 'version >nil: exec.library 36 '
- lrc = rc
-
- if (rc = 0) then
- check = addlib('rexxsupport.library',0,-30,0)
-
- address
-
- parse arg name '0x' tsk .
-
- NULL = "00000000"x
-
- if (name = '?') then
- do
- do i = 2 to 11
- 'd "'||strip(sourceline(i),'T',"0a"x) '"'
- end
- exit(0)
- end
- else if (name ~= '') then
- do
- taskbase = findtask(name)
- name = "'"||name||"'"
- end
- else if (tsk ~= '') then
- do
- name = right(tsk,8,'0')
- taskbase = x2c(name)
- name = '0x'||name
- end
- else
- do
- options results
- 'opt task'
- tasklist = result
- options
- tasklist = strip(tasklist)
- name = right(tasklist, 9)
- name = left(name,8)
- taskbase = x2c(name)
- name = '0x'||name
- end
-
- statenm.0 = 'invalid'
- statenm.1 = 'added'
- statenm.2 = 'run'
- statenm.3 = 'ready'
- statenm.4 = 'wait'
- statenm.5 = 'except'
- statenm.6 = 'removed'
-
- type = c2d(import(offset(taskbase,8),1))
- if (type ~= 13 & type ~= 1) then do
- 'd' '"'||name 'is not a valid process"'
- exit(0)
- end
-
- name = "'"||import(import(offset(taskbase,10),4))||"'"
- state = c2d(import(offset(taskbase,15),1))
- statename = statenm.state
- pri = c2d(import(offset(taskbase,9),1))
- 'd' '"'||name 'in' statename 'state at priority' pri '"'
-
- flags = c2x(import(offset(taskbase,14),1))
- idnest = c2d(import(offset(taskbase,16),1),1)
- tdnest = c2d(import(offset(taskbase,17),1),1)
- 'd' '"Type' type ' Flags' flags ' IDNestCnt' idnest ' TDNestCnt' tdnest '"'
-
- sigalloc = c2x(import(offset(taskbase,18),4))
- sigwait = c2x(import(offset(taskbase,22),4))
- sigrec = c2x(import(offset(taskbase,26),4))
- sigexcept = c2x(import(offset(taskbase,30),4))
- 'd' '"Signal: Alloc' sigalloc ' Wait ' sigwait ' Recvd' sigrec ' Except' sigexcept '"'
-
- trapdata = c2x(import(offset(taskbase,46),4))
- trapcode = c2x(import(offset(taskbase,50),4))
- trapalloc = c2x(import(offset(taskbase,34),2))
- trapable = c2x(import(offset(taskbase,36),2))
- 'd' '"Trap: Data ' trapdata ' Code ' trapcode ' Alloc' trapalloc ' Able' trapable '"'
-
- excptdata = c2x(import(offset(taskbase,38),4))
- excptcode = c2x(import(offset(taskbase,42),4))
- 'd' '"Except: Data ' excptdata ' Code ' excptcode '"'
-
- sp = import(offset(taskbase,54),4)
- spreg = c2x(sp)
- splower = c2x(import(offset(taskbase,58),4))
- spupper = c2x(import(offset(taskbase,62),4))
- 'd' '"Stack: Reg ' spreg ' Lower' splower ' Upper' spupper '"'
-
- if (state >= 3 & state <= 6) then do
- options results
- 'r pc'
- options
- pc = substr(strip(result),4,8)
- options results
- 'r sr'
- options
- sr = substr(strip(result),8,4)
- 'd' '"CPURegs: PC ' pc ' SR ' sr '"'
-
- options results
- 'regs'
- options
- regs = strip(result)
- dregs = substr(regs,4,8) || " " || substr(regs,17,8) || " " || substr(regs,30,8)
- dregs = dregs || " " || substr(regs,43,8) || " " || substr(regs,56,8)
- dregs = dregs || " " || substr(regs,69,8) || " " || substr(regs,83,8)
- dregs = dregs || " " || substr(regs,96,8)
- 'd' '"D:' dregs '"'
-
- aregs = substr(regs,109,8) || " " || substr(regs,122,8) || " " || substr(regs,135,8)
- aregs = aregs || " " || substr(regs,148,8) || " " || substr(regs,162,8)
- aregs = aregs || " " || substr(regs,175,8) || " " || substr(regs,188,8)
- 'd' '"A:' aregs '"'
- end
-
- if type = 13 then do
- 'd' '"Process Dependent ----------------------------------------------"'
-
- segarray = "0x"||c2x(d2c(c2d(import(offset(taskbase,128),4))*4,4))
- segptr = x2c(c2x(d2c(c2d(import(offset(taskbase,128),4))*4,4)))
- stacksize = right(c2d(import(offset(taskbase,132),4)), 9)
- globvec = "0x"||c2x(import(offset(taskbase,136),4))
- 'd' '"SegArray ' segarray ' StackSize ' stacksize ' GlobVec ' globvec '"'
-
- tasknum = right(c2d(import(offset(taskbase,140),4)), 9)
- stackbase = "0x"||c2x(d2c(c2d(import(offset(taskbase,144),4))*4,4))
- result2 = right(c2d(import(offset(taskbase,148),4)), 9)
- 'd' '"TaskNum ' tasknum ' StackBase ' stackbase ' Result2 ' result2 '"'
-
- curdir = "0x"||c2x(d2c(c2d(import(offset(taskbase,152),4))*4,4))
- cis = "0x"||c2x(d2c(c2d(import(offset(taskbase,156),4))*4,4))
- cos = "0x"||c2x(d2c(c2d(import(offset(taskbase,160),4))*4,4))
- 'd' '"CurrentDir ' curdir ' CIS ' cis ' COS ' cos '"'
-
- contask = "0x"||c2x(import(offset(taskbase,164),4))
- filesys = "0x"||c2x(import(offset(taskbase,168),4))
- cli = "0x"||c2x(d2c(c2d(import(offset(taskbase,172),4))*4,4))
- 'd' '"ConsoleTask' contask ' FileSysTask' filesys ' CLI ' cli '"'
-
- retaddr = "0x"||c2x(import(offset(taskbase,180),4))
- pktwait = "0x"||c2x(import(offset(taskbase,184),4))
- seglist = "0x"||c2x(d2c(c2d(import(offset(segptr,12),4))*4,4))
- 'd' '"ReturnAddr ' retaddr ' PktWait ' pktwait ' SegList ' seglist '"'
- end
-
- exit 0
-
- /* Locate a task in the system based upon the name */
- findtask:
- parse arg name
- execbase = next("00000004"x)
- liboff = 420
- nodebase = import(offset(execbase, liboff), 4)
-
- do while(import(nodebase,4) ~= NULL)
- if import(import(offset(nodebase,10),4)) = name then return nodebase
- nodebase = import(nodebase,4)
- end
-
- liboff = 406
- nodebase = import(offset(execbase, liboff), 4)
-
- do while(import(nodebase,4) ~= NULL)
- if import(import(offset(nodebase,10),4)) = name then return nodebase
- nodebase = import(nodebase,4)
- end
-
- 'd' '"Could not find process' name||'"'
- exit(0)
-