home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / SASC6571.LZX / examples / catching_tasks / READ.ME < prev    next >
Encoding:
Text File  |  1996-12-24  |  4.3 KB  |  133 lines

  1. Example of debugging tasks
  2. Copyright (c) 1993 SAS Institute, Inc, Cary, NC USA
  3. All Rights Reserved
  4.  
  5. This example demonstrates the CPR debugger's ability to debug a task
  6. that is already running, possibly in an infinite loop.
  7.  
  8. There are two series of steps listed below. The first is for debugging
  9. a process that has been started from a Shell, and the second is for
  10. debugging a task started from the Workbench.
  11.  
  12. Before going through the examples, first double click on 
  13. the Build icon to build the two small example programs 
  14. necessary for this demo.
  15.  
  16. ==================================================
  17. Catching a process that was started from the Shell
  18. ==================================================
  19.  
  20.  
  21. 1) Start a Shell, change directories to sc:examples/catching_tasks,
  22.    and run the program "loop". The program loop is a small program 
  23.    that just prints out "looping..." over and over. It does set
  24.    its priority to -1 though, so that it won't monopolize the CPU.
  25.    
  26.       cd sc:examples/catching_tasks
  27.       loop
  28.       
  29. 2) Start the debugger on the "dummy" program, by clicking once on
  30.    the debug icon, and holding down shift and double-clicking on
  31.    the "dummy" icon.  (You can also run the debugger from the 
  32.    Shell by typing "cpr dummy".)
  33.    
  34. 3) Tell CPR to list all the tasks in the system.
  35.  
  36.       tasks all
  37.       
  38. 4) Find the task with the priority of -1. If you are running the 
  39.    standard Shell under 2.0, the name of the process will be 
  40.    "Shell Process". If the name is unique, you can use the name
  41.    to identify the process. If not, use the address in the first column
  42.    to identify the process.
  43.    
  44.    To catch the process by name, type
  45.    
  46.       catch "Shell Process"
  47.  
  48.    Note that "Shell Process" must be in quotes. To catch the process
  49.    by address, type
  50.    
  51.       catch 0xnnnnnnn
  52.       
  53.    where nnnnnnn is the address of the process.
  54.  
  55. 5) Now list the tasks under CPR's control.
  56.  
  57.      tasks
  58.         
  59. 6) Since we're not interested in debugging the "dummy" process, we
  60.    can let it go. Use the address in the first column to identify
  61.    the task.
  62.    
  63.      detach 0xnnnnnnn
  64.      
  65.    where nnnnnnn is the address of the process.
  66.  
  67. 7) CPR should now display assembly lines for the loop program.
  68.    Most likely, CPR stopped the program in a system call. Load the
  69.    debugging information for the loop program. Use the form of SYMLOAD
  70.    that uses the seglist from the CLI structure.
  71.    
  72.       symload "loop"
  73.       
  74. 8) You can now set a breakpoint in the loop program. 
  75.  
  76.       break loop:main 18
  77.       
  78. 9) Run the program.
  79.   
  80.       go
  81.       
  82. 10) CPR should stop the program on line 18 and display the source.
  83.     At this point you can set 'i' to 1 and step out of the loop.
  84.     
  85.       set i = 1
  86.       proceed
  87.       proceed
  88.       proceed
  89.       
  90. 11) Quit Cpr.
  91.       
  92.       quit
  93.       
  94. NOTE. When you type quit in CPR, all tasks that have been caught are
  95.       "let go", and they run as normal until completion. The main
  96.       task (dummy in this case) will be forced to call exit (unless
  97.       you specify "quit -abort" or started cpr with -s), and are then
  98.       terminated.
  99.       
  100.       If instead of doing a quit on step 11, you did a "GO" to let the
  101.       program "loop" run to completion, you will notice that CPR does
  102.       not return to user control. That is because the "Shell Process"
  103.       did not terminate, only the loop command did. The "Shell Process"
  104.       process is now running the Shell, and CPR is actually debugging the
  105.       Shell. At this point you can hit CTRL-C in CPR and type quit. The
  106.       Shell will now run as normal.
  107.        
  108.      
  109.  
  110. ==================================================
  111. Catching a process that was started from Workbench
  112. ==================================================
  113.    
  114. The only difference between catching a process started from
  115. the CLI and one started from Workbench, is finding the name
  116. of the process. The name will generally be the name of the
  117. executable.
  118.  
  119. 1) Double click on the loop icon. 
  120.  
  121. 2) Click on Debug, and shift double-click on Dummy.
  122.  
  123. 3) Catch the loop program.
  124.    
  125.      catch "loop"
  126.      
  127.        
  128. From here, all is the same as the CLI method starting at
  129. step 5, until you get to step 11, quitting CPR. Since the
  130. "loop" program was not run from a shell, its process will die
  131. whel the loop program finishes. Therefore, you can do a "GO", 
  132. and CPR will report back that the program has finished.
  133.