#!/usr/local/rexx/rxx /* * dbxw * * dbxw is a uni-REXX macro that invokes 'dbx' in one window on a * program running in another window. * * 'dbx' is a utility for source-level debugging and execution of * programs written in C or other supported languages. Refer to * your operating system manuals for more information on the * 'dbx' command. * * This version of the macro works in the most popular Unix * environments. You should probably 'cd' to the directory in which * the program you want to debug resides before executing dbxw. * * Execute the dbxw macro by typing * * dbxw * * * Modification history: * * 4/14/93 twg Modified version supporting multiple Unix environments * */ parse arg programname traceopt trace value traceopt /* * Try finding the program to 'dbx -a' on a System V platform... */ rc=popen("ps -u" userid() "2> /dev/null | grep" programname) if rc=0 then do /* Found one or more processes running */ select when queued()=1 then do parse pull processid . /* get the Process ID */ "dbx -a" processid /* run 'dbx -a' on that process */ end when queued()>1 then say "There are multiple ->" programname "<- programs running!" otherwise say "An unknown error condition has occurred" end end else do /* * Try finding the program to 'dbx' on a Berkeley platform... */ rc=popen("ps -u 2>/dev/null | grep" userid() "| grep" programname) if rc=1 then do /* special handling for System V platforms... */ say "Unable to find any processes named:" programname end else do select when queued()=1 then say "Unable to find any processes named:" programname when queued()=2 then do queued() parse pull . processid . . . . . . . . what . /* discard grep */ if what <> 'grep' then "dbx" programname processid else nop end when queued()>2 then say "There are multiple ->" programname "<- programs running!" otherwise say "An unknown error condition has occurred" end end end exit