home *** CD-ROM | disk | FTP | other *** search
- Copyright (c) 1993 SAS Institute, Cary, NC USA
- All Rights Reserved
-
- This example demonstrates how to create a multitasking
- program, and how to use CPR to debug it.
-
- The example program starts a new process that executes
- in the same code hunk as the parent process. This is the
- simplest type of multitasking program to debug, because
- CPR has all the debugging information for both tasks when
- the parent process starts.
-
- Another type of multitasking situtation is demonstrated in
- the "example_device" example. In that example, a driver program
- calls OpenDevice(), which loads the device, and starts a new task
- running in a seperate code hunk from the original program.
-
-
- This example contains an Enforcer Hit in one function that
- will be executed as the child process. Listed below are
- instructions for finding the hit.
-
- To compile the example, double click on the Build Icon.
-
- Example 1. How to find an Enforcer hit in a child process.
-
- 1) Start Enforcer. You need a machine with an MMU to run enforcer.
- If you don't have an MMU, move to Example 2.
-
- 2) Start CPR in the TEST program.
- cpr test
-
- 3) Turn on catching new tasks.
- opt catch on
-
- 4) Run the program. CPR will stop at the Enforcer Hit.
- go
-
- 5) CPR should have stopped in the function process1(). You
- can now list the processes under CPR's control.
- tasks
-
- 6) Turn off catching of new tasks. The next line does an Open()
- on CON: which starts a new task. You don't want CPR to catch
- that task.
- opt catch off
-
- 7) Now let the program run to completion.
- go
-
-
- Note: Putting harmless enforcer hits (like the one in this example)
- in your program is a good trick to aid in debugging
- multitasking programs.
-
-
- Example 2. How to debug a child process.
-
- 1) Start CPR in the TEST program.
- cpr test
-
- 2) Turn on catching new tasks.
- opt catch on
-
- 3) Set a breakpoint at the function that will be executed
- as part of the child process.
- break process1
-
- 4) Run the program. CPR will stop at the Enforcer Hit.
- go
-
- 5) CPR should have stopped in the function process1(). You
- can now list the processes under CPR's control.
- tasks
-
- 6) Turn off catching of new tasks. The next line does an Open()
- on CON: which starts a new task. You don't want CPR to catch
- that task.
- opt catch off
-
- 7) Now let the program run to completion.
- go
-
-
- Other Hints.
-
- Whenever you do a GO, all tasks under CPR's control are run. Whenever
- any task hits a breakpoint or enforcer hit, all tasks are suspended.
-
- You can switch between tasks with the OPT TASK command. If you switch
- to a task and you don't seem to have debugging information, most likely
- the task is in an OS routine (probably Wait()).
-
-