---- CUT HERE -------------------------------------------------------------
The REXX command of GDB invokes the OS/2 REXX interpreter. The
argument of the REXX command is interpreted as REXX program. RX is an
alias for the REXX command. Important: use single quotes instead of
double quotes in REXX commands as GDB treats double quotes specially.
Example:
(gdb) rx say 'Hello World!'
Hello World!
Once the REXX interpreter has been invoked, the default subcommand
handler is GDBRX. This means that any commands REXX doesn't
understand get passed back to gdb for processing. Any output from gdb
gets passed back to REXX through the standard result variable
RC. Example:
(gdb) rx do i = 2 to 4; 'p 'i; say rc; end
$1 = 2
$2 = 3
$3 = 4
This is where the real power of the REXX command lies. It makes it
really easy to hack together quick and dirty debugging functions. For
instance, \emx\bin\logargs.cmd is a REXX program that logs all
parameters used in calls to a given function. You invoke it with
(gdb) rx call logargs
logargs.cmd assumes that you have loaded the program, and have breaked
somewhere in it (since it starts off with a 'continue').
When you run it you get something like this:
cd \emx\test
gdb version.exe
(gdb) b main
(gdb) set sw off
(gdb) set cl on
(gdb) run
(gdb) rx call logargs
logargs 1.1
Enter function name:
bit
Running...
And you end up with a very useful loginfo.txt file:
*** logargs 1.1 --- 20:02:33 02 Jul 1993 ***
s=0x100b7 "VCPI ", n=1
s=0x100c1 "XMS ", n=2
s=0x100cb "VDISK 3.3", n=4
s=0x100d5 "DESQview ", n=8
s=0x100df "287 ", n=16
s=0x100e9 "387 ", n=32
s=0x100f3 "OS/2 2.x ", n=512
s=0x100fd "-t ", n=1024
s=0x10107 "-ac ", n=2048
where each line represents the parameters passed to bit().
When analyzing RC, note that newlines are represented by two
characters, CR and LF.
---- CUT HERE -------------------------------------------------------------
Here is the logargs program mentioned above..
---- CUT HERE -------------------------------------------------------------
/* logargs.cmd -- for GDB */
version = '1.1'
say "logargs" version
say "Enter function name:"
parse pull functionName
'break' functionName
parse var RC 'Breakpoint 'breakNumber' at 'breakAddress':' remainder
if breakNumber = '' then do
say RC
return
end
say 'Running...'
done = FALSE
call lineout 'logargs.txt', '*** logargs 'version' --- 'time()' 'date()' ***'
do while (done == FALSE)
'continue'
if (substr(RC, 3, 10) \= 'Breakpoint') then
done = TRUE
else do
parse var RC prejunk '('args')' postjunk
call lineout 'logargs.txt', args
end
end
say RC
---- CUT HERE -------------------------------------------------------------
Anthony
Note: reply to "roboco!gr...@utai.toronto.edu".
--
Anthony T. Green 343D St. Clair Ave W, Toronto, Ontario M5P 1N3
Home (416) 968-0817 Internet: roboco!gr...@utai.toronto.edu
Office (416) 340-0887 UUCP : ...!uunet!utai!roboco!green