home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / HELP / DDE4TMST.INF (.txt) < prev    next >
OS/2 Help File  |  1993-10-05  |  96KB  |  2,691 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Special Notices ΓòÉΓòÉΓòÉ
  3.  
  4. References in this tutorial to IBM products, programs, or services do not imply 
  5. that IBM intends to make these available in all countries in which IBM 
  6. operates. 
  7.  
  8. Any reference to an IBM licensed program in this online information is not 
  9. intended to state or imply that only IBM's licensed program may be used.  Any 
  10. functionally equivalent product, program or service that does not infringe any 
  11. of IBM's intellectual property rights may be used instead of the IBM product, 
  12. program, or service. 
  13.  
  14. Evaluation and verification of operation in conjunction with other products, 
  15. except those expressly designated by IBM, is the user's responsibility. 
  16.  
  17. IBM may have patents or pending patent applications covering subject matter in 
  18. this document.  The furnishing of this document does not give you any license 
  19. to these patents. You can send license inquiries, in writing, to the IBM 
  20. Director of Commercial Relations, IBM Corporation, Purchase, NY 10577. 
  21.  
  22. This online information could contain technical inaccuracies or typographical 
  23. errors. 
  24.  
  25. This tutorial may contain examples of data and reports used in daily business 
  26. operations.  To illustrate them as completely as possible, the examples may 
  27. include names of individuals, companies, brands, and products.  All of these 
  28. names are fictitious and any similarity to the names and addresses used by an 
  29. actual business enterprise is entirely coincidental. 
  30.  
  31.  
  32. ΓòÉΓòÉΓòÉ 1.1. Trademarks and Service Marks ΓòÉΓòÉΓòÉ
  33.  
  34. The following terms, denoted by an asterisk (*) in this online information, are 
  35. trademarks of the IBM Corporation in the United States and/or other countries: 
  36.  
  37.  C Set ++ 
  38.  IBM 
  39.  OS/2 
  40.  Operating System/2 
  41.  Presentation Manager 
  42.  WorkFrame/2. 
  43.  
  44.  
  45. ΓòÉΓòÉΓòÉ 2. Start Here ΓòÉΓòÉΓòÉ
  46.  
  47. The IBM* C/C++ Debugger uses Presentation Manager* (PM) window services to help 
  48. detect and diagnose errors in code developed in IBM 32-bit C/C++.  The debugger 
  49. has a graphical user interface and debugs PM and non-PM (single or 
  50. multi-threaded) applications.  It also features a number of C++-related 
  51. debugging features. 
  52.  
  53. You will interact directly with the debugger while viewing this tutorial. 
  54.  
  55. To continue, click on the Forward push button. 
  56.  
  57.  
  58. ΓòÉΓòÉΓòÉ 2.1. About This Tutorial ΓòÉΓòÉΓòÉ
  59.  
  60. This tutorial guides you through three sample debugging sessions. The series of 
  61. steps in these debugging sessions do not necessarily represent the most 
  62. efficient way to debug any of the sample programs. However, the main objective 
  63. of this tutorial is to show you how to use as many of the debugger features as 
  64. possible. 
  65.  
  66. Work through the lessons in the tutorial in the correct order.  Do not skip any 
  67. steps; each step builds on the work you do in the previous steps. 
  68.  
  69. This tutorial is organized into two main parts: 
  70.  
  71. Debugger Features for C Programming 
  72.           This part contains Lesson 1, which takes you through a sample 
  73.           debugging session using the program DPMLINES. The code in this 
  74.           program has an error.  You will use the debugger tutorial to locate 
  75.           the error in the program. 
  76.  
  77. Debugger Features for C++ Programming 
  78.           This part contains Lesson 2 and is used to introduce you to the C++ 
  79.           features. Lesson 2 uses the sample programs MCELCV and NEST. There is 
  80.           one error in NEST that you will learn how to fix. 
  81.  
  82. This tutorial takes approximately 2 hours to complete. 
  83.  
  84. Select Navigating in the Tutorial for information on how to navigate through 
  85. the tutorial, 
  86.  
  87.  
  88. ΓòÉΓòÉΓòÉ <hidden> Navigating in the Tutorial ΓòÉΓòÉΓòÉ
  89.  
  90. There are several ways to navigate through the tutorial.  You can use the push 
  91. buttons, scroll bars, and keyboard keys. 
  92.  
  93. The push buttons at the bottom of this window allow you to navigate within the 
  94. tutorial. 
  95.  
  96. Previous 
  97.      Takes you to the window you saw before the current one. You may have 
  98.      gotten here by pressing Forward, Backward, or you may have gotten there 
  99.      from a link, such as an index entry. You can also do this with the Esc 
  100.      key. 
  101.  
  102. Print 
  103.      Prints the tutorial if your system is attached to a printer. 
  104.  
  105. Back 
  106.      Moves backward one page in sequential order, regardless of how you got to 
  107.      the current page. 
  108.  
  109. Forward 
  110.      Moves forward one page in sequential order. 
  111.  
  112. For more information on using this Help facility, select Using Help from the 
  113. Help menu in this window. 
  114.  
  115.  
  116. ΓòÉΓòÉΓòÉ 2.2. Finding the Sample Programs ΓòÉΓòÉΓòÉ
  117.  
  118. You can find the sample programs in the following subdirectories: 
  119.  
  120.           DPMLINES 
  121.                     IBMCPP\TUTORIAL\DEBUGGER\DPMLINES 
  122.  
  123.           MCELCV 
  124.                     IBMCPP\TUTORIAL\DEBUGGER\MCELCV 
  125.  
  126.           NEST 
  127.                     IBMCPP\TUTORIAL\DEBUGGER\NEST 
  128.  
  129.  
  130. ΓòÉΓòÉΓòÉ 2.3. What Is New in Version 2.0 ΓòÉΓòÉΓòÉ
  131.  
  132. If you are already familiar with the previous version of the debugger, you may 
  133. be interested in a quick overview of what is new in this version. 
  134.  
  135. The debugger now supports the C++ language. A summary of the new features added 
  136. to support C++ are as follows: 
  137.  
  138.  Template support 
  139.            Allows you to debug template functions.  When an action is 
  140.            ambiguous, the IBM C/C++ Debugger prompts you for the correct 
  141.            instance of a function. 
  142.  
  143.  Inheritance view 
  144.            Displays class hierarchy in a graphical format. 
  145.  
  146.  Class details view 
  147.            Displays information about a class.  This information includes type 
  148.            information for data members, member functions and parameters, 
  149.            access information and relationship data. 
  150.  
  151.  Expression evaluation 
  152.            Evaluates expressions that use the new C++ operators for reference 
  153.            and scope. Full casting is supported for C++. 
  154.  
  155.  In addition to the features supporting C++, there are also many other new and 
  156.  enhanced features. Descriptions of these features are as follows: 
  157.  
  158.  Window analysis 
  159.            Displays PM windows in a three-dimensional view. Window 
  160.            characteristics and window relationship data are also displayed. 
  161.  
  162.  Message queue monitor 
  163.            Monitors PM messages that are related to specific PM windows. 
  164.  
  165.  Include file support 
  166.            Debugs include files that contain executable code.  You can browse 
  167.            the source code of an include file and set breakpoints. 
  168.  
  169.  Exception handling 
  170.            Displays options when an exception occurs during execution of your 
  171.            program. 
  172.  
  173.  Jump to location 
  174.            Resets the extended instruction pointer (EIP) to a location in your 
  175.            program without executing any statements. 
  176.  
  177.  Buttons in the title bar 
  178.            Provides quick access to step commands and various utility windows. 
  179.  
  180.  Breakpoints 
  181.            Manipulates breakpoints using a notebook format. This allows easier 
  182.            access to different types of breakpoints. 
  183.  
  184.  Stack 
  185.            Views a more complete picture of the stack. 
  186.  
  187.  Debug Session Control 
  188.            Displays a hierarchical representation of the relationships among 
  189.            all components, such as executable files, object files, and 
  190.            functions. 
  191.  
  192.  Default data representation 
  193.            Allows you to change the default representation of data. For 
  194.            example, integers can be displayed as either decimal or hexadecimal. 
  195.  
  196.  Locate function 
  197.            Displays source code for a given function.  The IBM C/C++ Debugger 
  198.            lists overloaded functions and lets you choose the correct function. 
  199.  
  200.  Register 
  201.            Views and alters the individual flags in the processor's EFLAGS 
  202.            register, coprocessor floating point control word, and floating 
  203.            point status word registers. 
  204.  
  205.  
  206. ΓòÉΓòÉΓòÉ 2.4. Using Help in the Debugger ΓòÉΓòÉΓòÉ
  207.  
  208. There are several ways to get help within the debugger. 
  209.  
  210.  Tutorial 
  211.            You can access this tutorial from the Help menu in the Debug Session 
  212.            Control window or from the Help menu in any of the program view 
  213.            windows (Source, Disassembly, or Mixed). 
  214.  
  215.  Help on a Window 
  216.            To see help for a particular debugger window, select General Help 
  217.            from the Help menu (Help  General Help) or press the F1 key in any 
  218.            window. Some windows also have a Help push button. 
  219.  
  220.  Help on a Menu Choice 
  221.            While a menu is displayed, use the arrow keys to select a choice and 
  222.            press the F1 key. 
  223.  
  224.  
  225. ΓòÉΓòÉΓòÉ 2.5. Using the Default Session Settings ΓòÉΓòÉΓòÉ
  226.  
  227. The tutorial assumes that all of your debugger session settings are set to 
  228. their default values. Otherwise, some events may not happen exactly as stated. 
  229.  
  230.      To reset all your session settings to their default values, delete the 
  231.      IPMD.@2S file from the debugger directory. 
  232.  
  233.  Note:  This step is mandatory if any of the defaults have been changed. 
  234.  
  235.  See Customizing the Debugger Environment to explore the options you can change 
  236.  in the debugger session settings. 
  237.  
  238.  
  239. ΓòÉΓòÉΓòÉ 2.6. Customizing the Debugger Environment ΓòÉΓòÉΓòÉ
  240.  
  241. Before you begin a debugging session, you can select the options (session 
  242. settings) that define your debugging environment. 
  243.  
  244. If you have not changed any of the debugger default session settings, then the 
  245. steps outlined in the next two panels are optional and are included only to 
  246. show you the different session settings that are available. 
  247.  
  248.  
  249. ΓòÉΓòÉΓòÉ 2.6.1. Setting Source Window Properties ΓòÉΓòÉΓòÉ
  250.  
  251. Note:  These steps are mandatory if any of the defaults have been changed, or 
  252. if the IPMD.@2S debugger settings file has not been deleted. 
  253.  
  254. You can set the New view priority to control how your program view windows are 
  255. initially displayed, and how they are handled when they halt or are no longer 
  256. active. 
  257.  
  258. To set a new view priority: 
  259.  
  260.   1. From the Options menu in the Source window, select Session settings 
  261.      Source window properties. 
  262.  
  263.   2. At the bottom of the New view priority group heading, select the Icon push 
  264.      button to set the views in the list to icons. This is the default. 
  265.  
  266.   3. To change the order of the icons, use mouse button two to press and drag 
  267.      the disassembly icon above the source icon and then release mouse button 
  268.      two. The icons are displayed in a new order with the disassembly icon 
  269.      first and the source icon second. 
  270.  
  271.   4. Press and drag the source icon over the disassembly icon and release mouse 
  272.      button two. 
  273.  
  274.      The icons are reordered so that the source icon is first and the 
  275.      disassembly icon is second. When the program starts, it is displayed in 
  276.      the Source window. 
  277.  
  278.      Note:  For the tutorial, the Source window should be the first view opened 
  279.      for new programs. 
  280.  
  281.      Several other settings involving the program view windows can be set from 
  282.      this window as well.  For example: 
  283.  
  284.   5. From the Old source disposition group heading, enable the Discard radio 
  285.      button. 
  286.  
  287.   6. From the Display at stop entry field, enable the Only stopping thread 
  288.      radio button. 
  289.  
  290.   7. To save these selections for the next debugging session, select Save 
  291.      session settings. This is the default. 
  292.  
  293.   8. Select the OK push button to accept the information that you entered and 
  294.      to close the Source Window Properties action window. 
  295.  
  296.  For more information about these settings or any of the other settings you can 
  297.  choose from this window, select the General help choice from the Help 
  298.  pull-down in the Debug Session Control window. 
  299.  
  300.  
  301. ΓòÉΓòÉΓòÉ 2.6.2. Setting Monitor Properties ΓòÉΓòÉΓòÉ
  302.  
  303. You can set the default options for the variable monitors, and save them with 
  304. the session settings. This feature allows you to use the same monitor settings 
  305. for each debugging session. 
  306.  
  307. When you double-click on a variable name in your source file, that variable and 
  308. its current value are added to a Monitor window, and the value is updated as 
  309. needed. The Monitor Properties action window lets you choose which type of 
  310. monitor window is used to hold the value for those variables: 
  311.  
  312.  o A data pop-up, a single small window for each variable monitored. 
  313.  
  314.  o One of the monitor windows, such as Program Monitor or Private Monitor, 
  315.    which gathers several variables to monitor in the same place. 
  316.  
  317.  The next few steps show you how you can change the default so that variables 
  318.  are monitored in various monitor windows. 
  319.  
  320.  Note:  This tutorial assumes you have the default condition of having the 
  321.  variables added to the Program Monitor action window in effect. 
  322.  
  323.   1. From the Options menu in the Source window, select Session settings  
  324.      Monitor properties. The Monitor Properties action window is displayed. 
  325.  
  326.   2. Under the Monitor location group heading, select Program monitor. 
  327.  
  328.   3. Select Save session settings to save your selections for the next 
  329.      debugging session. This is the default. 
  330.  
  331.   4. Select the OK push button to save your selections for the next debugging 
  332.      session and to close the Monitor Properties action window. 
  333.  
  334.  If you would like to change to a different monitor location, you may want to 
  335.  try selecting Popup. You may then see the results by double-clicking on a 
  336.  variable in the Source window. It appears in a data pop-up instead of in the 
  337.  Program Monitor action window. Be sure to change back to the Program monitor 
  338.  window to monitor variables for the rest of the tutorial. 
  339.  
  340.  
  341. ΓòÉΓòÉΓòÉ 3. Before You Begin ΓòÉΓòÉΓòÉ
  342.  
  343. This topic is divided as follows: 
  344.  
  345.  Getting Ready to Use the Debugger 
  346.            Explains how to prepare your program for use with the debugger. 
  347.  
  348.  Starting the C/C++ Debugger 
  349.            Explains how to start the debugger from WorkFrame/2* and the OS/2* 
  350.            prompt. 
  351.  
  352.  Introducing the Main Debugger Windows 
  353.            Introduces the main debugger windows and the buttons on the title 
  354.            bar. 
  355.  
  356.  Customizing Your Environment 
  357.            Instructs you to resize the Tutorial window and change the PM 
  358.            debugging mode to asynchronous. 
  359.  
  360.  
  361. ΓòÉΓòÉΓòÉ 3.1. Getting Ready to Use the Debugger ΓòÉΓòÉΓòÉ
  362.  
  363. Before you can run the debugger on your program, you will need to know: 
  364.  
  365.  o How to writing code that the IBM* C/C++ Tools Debugger supports 
  366.  
  367.  o How to compile and link your program to generate debugging information 
  368.  
  369.  o How to set debugger search path information. 
  370.  
  371.  Click on the Forward pushbutton to learn how to perform these tasks. 
  372.  
  373.  
  374. ΓòÉΓòÉΓòÉ 3.1.1. Writing Code that the IBM C/C++ Debugger Supports ΓòÉΓòÉΓòÉ
  375.  
  376. When you write your code, put each statement on a separate line.  Multiple C 
  377. statements on the same line are difficult to debug. These multiple statements 
  378. cannot be accessed easily when you set breakpoints and do not allow you to 
  379. single-step through each statement. 
  380.  
  381.  
  382. ΓòÉΓòÉΓòÉ 3.1.2. Compiling and Linking Your Program ΓòÉΓòÉΓòÉ
  383.  
  384. When you compile and link your program, you will need to specify options so 
  385. that debugging information is generated.  Optimized or inlined code cannot be 
  386. debugged, so do not set options that turn optimization and inlining on. 
  387.  
  388. Use the following options when compiling and linking code to be debugged: 
  389.  
  390. Compile Options: 
  391.  
  392.  /Ti+      Compiles your program with debugging information (same as /Ti). 
  393.  
  394.  /O-       Compiles your program with optimization off (this is the default). 
  395.  
  396.  /Oi-      Compiles your program with inlining off (this is the default). 
  397.  
  398.  Link Options: 
  399.  
  400.  /Debug or /De 
  401.            Links your program to produce an executable file that includes line 
  402.            number information and a symbol table, in addition to the executable 
  403.            code. 
  404.  
  405.  For example, to compile a file for debugging, type: 
  406.  
  407.       icc /Ti myfile.c
  408.  
  409.  When this option is turned on, the compiler and linker generates debugging 
  410.  information that the debugger is able to access. 
  411.  
  412.  
  413. ΓòÉΓòÉΓòÉ 3.1.3. Search Path Information ΓòÉΓòÉΓòÉ
  414.  
  415. The search path tells the debugger where to find the source file. The debugger 
  416. searches for the source files in the following order: 
  417.  
  418.   1. The path where the object file was compiled. 
  419.   2. The path where the executable file is located. 
  420.   3. The path defined by the PMDPATH environment variable, if specified. 
  421.   4. The current path. 
  422.   5. The path defined in the INCLUDE environment variable. 
  423.  
  424.  Using the Environment Variables 
  425.  
  426.  The debugger uses two environment variables: PMDPATH and PMDOVERRIDE. 
  427.  
  428.  To set the PMDPATH environment variable, do the following: 
  429.  
  430.        Set PMDPATH=path;path
  431.  
  432.  where path is the location of your source files. 
  433.  
  434.  To override the normal search order, use the PMDOVERRIDE environment variable, 
  435.  as follows: 
  436.  
  437.        Set PMDOVERRIDE=path;path
  438.  
  439.  where path is the location of your source files. If the source file is not 
  440.  found in the defined override path, the debugger uses the normal search order. 
  441.  
  442.  
  443. ΓòÉΓòÉΓòÉ 3.2. Starting the C/C++ Debugger ΓòÉΓòÉΓòÉ
  444.  
  445. There are two ways to start the debugger, from WorkFrame/2* or from the OS/2* 
  446. prompt. 
  447.  
  448.  
  449. ΓòÉΓòÉΓòÉ 3.2.1. Starting the Debugger from WorkFrame/2 ΓòÉΓòÉΓòÉ
  450.  
  451. Before you start the debugger from the WorkFrame/2* environment, you need to 
  452. create a project for the program you want to debug. To be able to compile and 
  453. link a target program with debugging information, you need to set the debugger 
  454. options that the WorkFrame/2 environment uses for creating a project. For 
  455. information on creating a project, setting options, and starting the debugger, 
  456. refer to the IBM WorkFrame/2: Introduction. or the WorkFrame/2 online help. 
  457.  
  458.  
  459. ΓòÉΓòÉΓòÉ 3.2.2. Starting the Debugger from the OS/2 Prompt ΓòÉΓòÉΓòÉ
  460.  
  461. To start the debugger from an OS/2* prompt, type the following command and 
  462. parameters, in the order they are listed: 
  463.  
  464.    ipmd myprog <program parameters>
  465.  
  466. You may want to specify debugger parameters (/n, /i) when you start up the 
  467. debugger. 
  468.  
  469.  
  470. ΓòÉΓòÉΓòÉ <hidden> Using Debugger Parameters ΓòÉΓòÉΓòÉ
  471.  
  472. When you start the debugger from an OS/2* prompt, you can specify debugger 
  473. parameters to specify information that would otherwise be entered in the 
  474. Startup Information window: 
  475.  
  476.  /n  Do not use any restart information that was saved from a previous 
  477.      debugging session for this program. 
  478.  
  479.  /i  Start the debugger in the system initialization routine so that you can 
  480.      debug initialization code. 
  481.  
  482.  Place these parameters before your program name. For example, 
  483.  
  484.      ipmd /n myprog <program parameters>
  485.  
  486.  You can also start the debugger by simply typing 
  487.  
  488.     ipmd
  489.  Then once the debugger has started, you can load a program by selecting 
  490.  Startup from the File pull-down in the Debug Session Control window, the first 
  491.  window that appears when you start the debugger. 
  492.  
  493.  
  494. ΓòÉΓòÉΓòÉ 3.3. Introducing the Main Debugger Windows ΓòÉΓòÉΓòÉ
  495.  
  496. This topic covers the Debug Session Control window and the various program view 
  497. windows.  These are the main debugger windows. 
  498.  
  499. From these windows you control the debugger and have access to all of the 
  500. debugging features. 
  501.  
  502. A new feature of the debugger is the buttons in the title bar.  These buttons 
  503. allow you to quickly access often-used menu choices. You will use these buttons 
  504. to access debugger features later on in the tutorial. 
  505.  
  506.  
  507. ΓòÉΓòÉΓòÉ 3.3.1. Introducing the Debug Session Control Window ΓòÉΓòÉΓòÉ
  508.  
  509. The Debug Session Control window is the control window of the debugger and is 
  510. displayed during the entire debugging session. This window displays the threads 
  511. and components for the program you are debugging.  From this window, you can 
  512. enable or disable threads and select program components for viewing.  Selecting 
  513. program components for viewing provides you with the capability to access any 
  514. part of your program. 
  515.  
  516. This window is divided in two list boxes: 
  517.  
  518.  o The Threads list box shows the state of the threads in your program. 
  519.  
  520.  o The Components list box contains executable files (EXEs) or dynamic-link 
  521.    libraries (DLLs) for the program you are debugging. 
  522.  
  523.    Use the Components list box to: 
  524.  
  525.     - Generate a list of object files for an executable file (select the plus 
  526.       icon to the left of the executable file name). 
  527.  
  528.     - Open a program view of an object file (double-click on the object file 
  529.       name). 
  530.  
  531.     - Generate a list of functions for a specific object file (select the plus 
  532.       icon to the left of the object file name). 
  533.  
  534.     - Open a program view for the object file that contains the function 
  535.       (double-click on the function name). The program view window is opened to 
  536.       the first line of the function that you selected. 
  537.  
  538.    Note:  For C++ programs, the function name includes the class name and 
  539.    parameters. 
  540.  
  541.  
  542. ΓòÉΓòÉΓòÉ 3.3.2. Introducing the Program View Windows ΓòÉΓòÉΓòÉ
  543.  
  544. Using the program view windows, you can monitor the execution of your program, 
  545. among other things.  There are three program view windows: 
  546.  
  547.  Source 
  548.       The original source file. 
  549.  
  550.  Disassembly 
  551.       The assembler instructions produced by the compiler. 
  552.  
  553.  Mixed 
  554.       Source lines and the corresponding assembler instructions. 
  555.  
  556.  As you run or step through the program, the program view window of the 
  557.  component that is currently executing is displayed. During stepping, the 
  558.  executing line is highlighted. 
  559.  
  560.  If your program has include files, those source files are available for 
  561.  debugging in the notebook format of the Source window. You can disable the 
  562.  notebook format by selecting View  Notebook from the File pull-down in the 
  563.  program view window to toggle the Notebook option. 
  564.  
  565.  Each program view window has buttons in the title bar. 
  566.  
  567.  
  568. ΓòÉΓòÉΓòÉ 3.3.3. Introducing the Buttons on the Title Bar ΓòÉΓòÉΓòÉ
  569.  
  570. The buttons on the title bar in all of the program view windows give you quick 
  571. access to often-used functions. The step and run buttons appear in the title 
  572. bar in the same order as the step and run functions in the Run menu to make it 
  573. easier for you to remember. 
  574.  
  575.          Step over 
  576.  
  577.          Executes the current or highlighted line in the program, but the 
  578.          debugger does not enter any called function, even though the code is 
  579.          executed. Thus you step to the next sequential instruction in the 
  580.          source file you are viewing without jumping to the source for a called 
  581.          function. 
  582.  
  583.          Step into 
  584.  
  585.          Executes the current or highlighted line in the program. The debugger 
  586.          steps into any called program or function as well. 
  587.  
  588.          Step debug 
  589.  
  590.          Executes the current or highlighted line in the program. The debugger 
  591.          steps over any function for which debugging information is not 
  592.          available (for example, library and system routines), and steps into 
  593.          any function for which debugging information is available. 
  594.  
  595.          Step return 
  596.  
  597.          Automatically executes the lines of code up to, and including, the 
  598.          return statement of the current function. 
  599.  
  600.          Run 
  601.  
  602.          Runs the program, executing all enabled threads. While running, the 
  603.          button turns red. Pushing the button again stops the program and the 
  604.          button turns green. 
  605.  
  606.          View 
  607.  
  608.          Changes the current view to one of the other windows: Source, 
  609.          Disassembly, or Mixed windows. 
  610.  
  611.          Stack 
  612.  
  613.          Displays the Stack window, which lists all of the active functions for 
  614.          a thread in the order that they were called. 
  615.  
  616.          Register 
  617.  
  618.          Displays the Register window, which lists all the processor and 
  619.          coprocessor registers for a thread. 
  620.  
  621.          Program monitor 
  622.  
  623.          Displays the Program Monitor action window for viewing and changing 
  624.          your program variables. 
  625.  
  626.          Storage 
  627.  
  628.          Displays the Storage window, which shows the addresses and contents of 
  629.          a portion of memory. 
  630.  
  631.          Debug session control 
  632.  
  633.          Displays the Debug Session Control window. 
  634.  
  635.  
  636. ΓòÉΓòÉΓòÉ 3.4. Customizing Your Environment ΓòÉΓòÉΓòÉ
  637.  
  638. Before continuing with the tutorial, you may want to resize the tutorial window 
  639. and set the debugging mode. The following panels explain how to do these tasks. 
  640.  
  641.  
  642. ΓòÉΓòÉΓòÉ 3.4.1. Resizing the Tutorial Window ΓòÉΓòÉΓòÉ
  643.  
  644. If you plan to work with the debugger while viewing this tutorial, you may want 
  645. to resize the IBM C/C++ Debugger Tutorial window to occupy about half of your 
  646. screen, saving the other half for performing the debugger tasks. 
  647.  
  648. A good size is just wide enough so that the push buttons at the bottom of the 
  649. tutorial window fit on a single line. 
  650.  
  651. You may also need to re-organize the screen locations when you open new windows 
  652. so that both the tutorial and the debugger windows are visible. 
  653.  
  654.  
  655. ΓòÉΓòÉΓòÉ 3.4.2. Selecting the PM Debugging Mode ΓòÉΓòÉΓòÉ
  656.  
  657. Note:  This step is mandatory to insure uninterrupted viewing of the tutorial. 
  658.  
  659. When you set the mode of the debugger to asynchronous or synchronous, you 
  660. determine how PM messages are processed while the debugger has control.  In 
  661. asynchronous mode, you are allowed to do other things on your desktop while the 
  662. debugger is running, such as viewing the tutorial. 
  663.  
  664. In synchronous mode, only the debugger windows are active. If your program uses 
  665. PM messages, some PM messages may not be answered correctly. 
  666.  
  667. To set the debugging mode to asynchronous: 
  668.  
  669.   1. From the Options menu in the Source window, select Session settings  PM 
  670.      debugging mode. 
  671.  
  672.   2. Under Debugging mode, select the Asynchronous radio button. 
  673.  
  674.   3. Select Save session settings to save the mode you have selected for the 
  675.      next debugging session. 
  676.  
  677.   4. Select the OK push button. 
  678.  
  679.  
  680. ΓòÉΓòÉΓòÉ 4. Debugger Features for C Programming ΓòÉΓòÉΓòÉ
  681.  
  682. This section guides you through a sample debugging session using the sample 
  683. program DPMLINES. 
  684.  
  685. In this section, you will learn how to: 
  686.  
  687.  o Load and run the DPMLINES program 
  688.  o Use the step commands 
  689.  o Manipulate breakpoints 
  690.  o Monitor the stack and registers 
  691.  o Locate functions and search for text strings 
  692.  o Use the monitor windows 
  693.  o Change the storage address 
  694.  o Monitor messages 
  695.  o Use the window analysis windows. 
  696.  
  697.  
  698. ΓòÉΓòÉΓòÉ 4.1. Lesson 1: Loading DPMLINES ΓòÉΓòÉΓòÉ
  699.  
  700. To start this lesson, you will need to load the DPMLINES program: 
  701.  
  702.   1. Select Startup from the File pull-down in the Debug Session Control 
  703.      window. 
  704.  
  705.   2. In the Program entry field, type: 
  706.       IBMCPP\TUTORIAL\DEBUGGER\DPMLINES\DPMLINES.EXE 
  707.  
  708.      Ensure that the Debug program initialization check box is not selected, 
  709.      otherwise, the next window to display is the DOSCALL program in the 
  710.      Disassembly window. 
  711.  
  712.   3. Select the OK push button.  The program view window appears showing the 
  713.      source file. 
  714.  
  715.  Note:  If you are starting the debugger for the first time, you may see the 
  716.  Change Location window.  See the Debug Session Control window for more 
  717.  information on this. 
  718.  
  719.  
  720. ΓòÉΓòÉΓòÉ 4.2. About the DPMLINES Program ΓòÉΓòÉΓòÉ
  721.  
  722.      Before beginning the debugging process, run the program to verify that the 
  723.      error exists. 
  724.  
  725.  DPMLINES is a PM program that runs in the first thread and displays a PM 
  726.  window with simple menus.  It creates the second thread to draw lines in the 
  727.  window.  The color or the line changes every few seconds.  You can change the 
  728.  background color by double-clicking with mouse button 2 anywhere in the 
  729.  window. 
  730.  
  731.  This program was modified to display text that names the active line color in 
  732.  the lower left-hand corner of the window after the first color change.  The 
  733.  displayed text should be: 
  734.  
  735.     Color Value: active_line_color_code 
  736.  
  737.  The code that was added to modify the program, however, has an error in it, 
  738.  and the active_line_color_code (which is a number) does not display. 
  739.  
  740.  
  741. ΓòÉΓòÉΓòÉ 4.2.1. Running the DPMLINES Program ΓòÉΓòÉΓòÉ
  742.  
  743. To start the debugging process at the beginning of the DPMLINES program, you 
  744. need to restart the program from the debugger: 
  745.  
  746. Note:  If you have not set the debugging mode to asynchronous, you need to do 
  747. this now. 
  748.  
  749.   1. Select the Run button  in the title bar. The DPMLINES window is opened 
  750.      behind the debugger windows. 
  751.  
  752.      Run executes the program, including all enabled threads, from the current 
  753.      line until a breakpoint is reached or the program is terminated. 
  754.  
  755.   2. Select the DPMLINES window to make it active and display it in front of 
  756.      the debugger windows. 
  757.  
  758.      You can see that the DPMLINES program continually draws lines in the 
  759.      DPMLINES window. The color of these lines changes every few seconds. 
  760.  
  761.   3. Look at the lower left-hand corner of the DPMLINES window. The text 
  762.  
  763.              Color value:
  764.  
  765.      is displayed, but the 
  766.  
  767.         active_line_color_code 
  768.  
  769.      is not. 
  770.  
  771.   4. From the Exit menu in the DPMLINES window, select Exit DPMLINES. 
  772.  
  773.      The DPMLINES window is closed and the Program Terminated window is 
  774.      displayed. 
  775.  
  776.   5. In the Program Terminated window, answer No to the prompt: 
  777.  
  778.           Do you want to save restart information?
  779.  
  780.      The DPMLINES program is ended, the Source window closes, and the Debug 
  781.      Session Control window is left as the only debugger window. 
  782.  
  783.  
  784. ΓòÉΓòÉΓòÉ 4.2.2. Starting the DPMLINES Again ΓòÉΓòÉΓòÉ
  785.  
  786. To continue with the debugging session, start the DPMLINES program again as 
  787. follows: 
  788.  
  789.   1. From the File menu in the Debug Session Control window, select Startup. 
  790.      The Startup Information action window is displayed. 
  791.  
  792.   2. In the Program entry field, leave the default program path name. The 
  793.      default path name is the path name of the DPMLINES program. 
  794.  
  795.   3. Select the OK push button to accept the information and to close the 
  796.      Startup Information window. The DPMLINES program is started for debugging 
  797.      and the Source window is displayed. 
  798.  
  799.  
  800. ΓòÉΓòÉΓòÉ 4.3. Stepping through the Program ΓòÉΓòÉΓòÉ
  801.  
  802. You can step through the program, a line at a time, in several different ways. 
  803. This lesson explains basic stepping and introduces the step buttons, the first 
  804. four buttons in the title bar. 
  805.  
  806.  
  807. ΓòÉΓòÉΓòÉ 4.3.1. Understanding Basic Stepping ΓòÉΓòÉΓòÉ
  808.  
  809. The easiest way to single-step your program is to press mouse button two 
  810. anywhere in the Source window. This does a step over, which executes the 
  811. current, highlighted line of code.  However, the debugger does not step into 
  812. any called function, although the code is executed. 
  813.  
  814. Step over can also be executed by: 
  815.  
  816.  o Selecting Step over from the Run menu in the program view windows. 
  817.  
  818.  o Pressing the O key. 
  819.  
  820.  o Pressing the Step over button in the title bar. 
  821.  
  822.  Try it now.  You should be at the top of the DPMLINES program and stepping a 
  823.  few lines does not affect the next activity. 
  824.  
  825.  The other stepping commands are described next. 
  826.  
  827.  
  828. ΓòÉΓòÉΓòÉ 4.3.2. Using the Step Commands ΓòÉΓòÉΓòÉ
  829.  
  830. The following summarizes the 4 step commands. 
  831.  
  832.   Step over 
  833.            Executes the current or highlighted line of code, but the debugger 
  834.            does not step into a called function. The called program, if any, is 
  835.            executed and execution stops at the next line in the current 
  836.            program. 
  837.  
  838.            The debugger stops in a called function if it encounters a 
  839.            breakpoint there. 
  840.  
  841.   Step into 
  842.            Executes the current or highlighted line of code, but the debugger 
  843.            does step into a called function if necessary. 
  844.  
  845.   Step debug 
  846.            Executes the current or highlighted line of code. The debugger steps 
  847.            over any function for which debugging information is not available, 
  848.            such as library and system routines, and steps into any function for 
  849.            which debugging information is available. 
  850.  
  851.   Step return 
  852.            Automatically executes the lines of code up to, and including, the 
  853.            return statement of the current function. 
  854.  
  855.  
  856. ΓòÉΓòÉΓòÉ 4.4. Setting Breakpoints ΓòÉΓòÉΓòÉ
  857.  
  858. Breakpoints stop the execution of your program at preset points. During a 
  859. debugging session, you can set as many breakpoints as you want. Breakpoints can 
  860. be set in the Source window, the Disassembly window, or the Mixed window. When 
  861. you set a breakpoint in one program view window, it is shown in all program 
  862. view windows. 
  863.  
  864. When the program encounters the breakpoint, it stops before the line is 
  865. executed and highlights the line. 
  866.  
  867. Breakpoints set in the Source window stop execution before the line of source 
  868. code is executed. 
  869.  
  870. Breakpoints set in the Disassembly window or the Mixed window stop execution 
  871. before the assembler instruction is executed. 
  872.  
  873.  
  874. ΓòÉΓòÉΓòÉ 4.4.1. Setting a Simple Line Breakpoint ΓòÉΓòÉΓòÉ
  875.  
  876. The simplest breakpoint is a line breakpoint.  A line breakpoint is set by 
  877. double-clicking in the prefix area or on the line number of the source 
  878. statement.  This area turns red, indicating that the breakpoint has been set. 
  879.  
  880. Double-clicking on the area again turns off the breakpoint. Breakpoints can 
  881. only be set on executable lines, which are shown in blue. Non-executable lines, 
  882. such as comments, are shown in black. 
  883.  
  884. Clicking on or selecting the prefix area highlights it or turns it gray. 
  885.  
  886.      Try it on one or more lines now, watching the prefix area turn red. Be 
  887.      sure to turn the breakpoints off when you are finished. 
  888.  
  889.  
  890. ΓòÉΓòÉΓòÉ 4.4.2. Using the Breakpoints Action Window ΓòÉΓòÉΓòÉ
  891.  
  892. The Breakpoints window is used to set and list several kinds of breakpoints in 
  893. a program. From the Breakpoints window, you can: 
  894.  
  895.  o Set a line breakpoint. 
  896.  o Set a function breakpoint. 
  897.  o Set an address breakpoint. 
  898.  o Set a change address breakpoint. 
  899.  o Set a load occurrence breakpoint. 
  900.  o List the breakpoints that have been set. 
  901.  o Delete one or all of the breakpoints that have been set. 
  902.  
  903.  You can set five types of breakpoints in all or one of the active threads. The 
  904.  execution of the program halts at a breakpoint when the conditions you have 
  905.  specified (in this window) are met. By setting a breakpoint, you can work with 
  906.  the section of code that contains the error. 
  907.  
  908.  The section of code that was added to the DPMLINES program starts at line 564. 
  909.  
  910.  To set a line breakpoint at line 567, which contains the 
  911.  ptlt.x = 1: expression: 
  912.  
  913.   1. Scroll to line 567 in the Source window. 
  914.  
  915.   2. Highlight line 567 by selecting the prefix area. The prefix area turns 
  916.      gray. 
  917.  
  918.   3. From the Breakpoints menu, select Line. This displays the Breakpoints 
  919.      action window, which is in a notebook format. 
  920.  
  921.   4. In the Line number entry field, 567 should already be filled in for you. 
  922.  
  923.   5. Set the Frequency entry fields as follows: 
  924.  
  925.      a. Change the From entry field to 100. 
  926.  
  927.      b. In the To entry field, replace the current value with 200. 
  928.  
  929.      c. In the Every entry field, change the current value to 10. 
  930.  
  931.      d. Select the Set push button to set the breakpoint at line 567 of the 
  932.         DPMLINES program. 
  933.  
  934.  The following appears at the bottom of the notebook page: 
  935.  
  936.  Breakpoint has been set. 
  937.  
  938.  The Breakpoints action window is left open. 
  939.  
  940.  
  941. ΓòÉΓòÉΓòÉ 4.4.3. Listing the Breakpoint ΓòÉΓòÉΓòÉ
  942.  
  943. The breakpoints that have been set in a program can be listed. To list the 
  944. breakpoints, do the following: 
  945.  
  946.   1. Select the List tab at the bottom of the Breakpoints action window. 
  947.  
  948.      Each breakpoint entry displayed in the List Breakpoint window includes 
  949.      information on the type, location, and any conditions under which the 
  950.      breakpoint is activated. You can modify, delete, or sort the list of 
  951.      breakpoints from this window. 
  952.  
  953.   2. View the breakpoint entries in the List action window. You may need to use 
  954.      the scroll bars to view all the information. 
  955.  
  956.   3. If you set any additional breakpoints earlier, you need to delete them 
  957.      now. To delete the additional breakpoints, highlight the line and then 
  958.      select the Delete push button. 
  959.  
  960.      Note:  Be sure to leave only the breakpoint on line 567. 
  961.  
  962.   4. Select the OK push button to close the Breakpoint action window. 
  963.  
  964.  
  965. ΓòÉΓòÉΓòÉ 4.4.4. Running the Program to Reach the Breakpoint ΓòÉΓòÉΓòÉ
  966.  
  967. Note:  If you have not set the PM debugging mode to asynchronous, you will 
  968. receive unpredictable results. 
  969.  
  970. To run the program and reach the breakpoint you have just set, select the Run 
  971. button in the title bar. 
  972.  
  973. When the breakpoint is encountered, the program stops and the Source window for 
  974. thread 2 is opened. The current line, which is where the breakpoint was set, is 
  975. displayed at the top of the Source window for thread 2. The section of code 
  976. that contains the error is in thread 2. 
  977.  
  978.  
  979. ΓòÉΓòÉΓòÉ 4.5. Monitoring the Stack ΓòÉΓòÉΓòÉ
  980.  
  981. You can monitor the stack to find the function name that started thread 2, 
  982. which is where the error is located. 
  983.  
  984. The Stack window lists all of the functions in the call stack for a particular 
  985. thread. Any calls that have been made are included in the stack and each thread 
  986. has a call stack. 
  987.  
  988. You can use the Display Style action window to select the parameters that 
  989. control how items on the stack are displayed. 
  990.  
  991. From this action window, you can select the descriptive information you want 
  992. displayed for all of the call stack items and whether you want the active 
  993. function to be displayed at the top or the bottom of the stack. By default, 
  994. active functions are displayed at the top of the stack. 
  995.  
  996.  
  997. ΓòÉΓòÉΓòÉ 4.5.1. Select the Display Style Format for the Stack Items ΓòÉΓòÉΓòÉ
  998.  
  999. To select the display style for the stack items: 
  1000.  
  1001.   1. To open the Stack window, select the Stack button in the title bar. The 
  1002.      Stack window is displayed. 
  1003.  
  1004.   2. From the Options menu in the Stack window, select Window settings  
  1005.      Display style. The Display Style window is displayed. 
  1006.  
  1007.   3. Under the Items group heading, enable the Entry number, Function, Source, 
  1008.      and Recursion level check boxes to display all of the available 
  1009.      information for each stack entry. 
  1010.  
  1011.   4. For Growth direction , select the Up radio button to display the most 
  1012.      recently called items at the top of the stack. This is the default. 
  1013.  
  1014.   5. The Save window settings check box should be checked, so your selections 
  1015.      are saved for the next debugging session. This is the default. 
  1016.  
  1017.   6. Select the OK push button to accept the information you have entered and 
  1018.      to close the Display Style window. 
  1019.  
  1020.   7. Resize the Stack window, if necessary, to display the four columns of 
  1021.      information. 
  1022.  
  1023.  
  1024. ΓòÉΓòÉΓòÉ 4.5.2. Review the Items in the Stack Window ΓòÉΓòÉΓòÉ
  1025.  
  1026.      Review the items in the Stack window. 
  1027.  
  1028.  The first entry in the Function column is DrawingThread.  The DrawingThread 
  1029.  function started thread 2 and is used to find the source for this function in 
  1030.  the next step. 
  1031.  
  1032.      Close the Stack window after you have examined the information. 
  1033.  
  1034.  
  1035. ΓòÉΓòÉΓòÉ 4.6. Locating Functions ΓòÉΓòÉΓòÉ
  1036.  
  1037. Now that you have set a breakpoint, you can step through the code to see what 
  1038. happens when the next few statements execute. Here, you will learn how to find 
  1039. the section of code that starts thread 2.  You can then review the logic of the 
  1040. function that starts thread 2 up to where the new section of code was added. 
  1041.  
  1042. There are several ways to find the DrawingThread function, which starts thread 
  1043. 2: 
  1044.  
  1045.  o Using the Components list box in the Debug Session Control window 
  1046.  
  1047.  o Using Locate Function option. 
  1048.  
  1049.  Click on the Forward push button to learn how to locate a function using these 
  1050.  methods. 
  1051.  
  1052.  
  1053. ΓòÉΓòÉΓòÉ 4.6.1. Using the Components List Box ΓòÉΓòÉΓòÉ
  1054.  
  1055. These steps demonstrate the usage of the Components list box to locate a 
  1056. function: 
  1057.  
  1058.   1. From the Debug Session Control window, select 2 from the Threads list box 
  1059.      to highlight thread 2. 
  1060.  
  1061.   2. Expand DPMLINES.EXE from the Components list box by selecting the plus 
  1062.      icon. 
  1063.  
  1064.   3. To find the DrawingThread function, double-click on the plus icon next to 
  1065.      the DPMLINES object file to expand it. 
  1066.  
  1067.   4. Double-click on the DrawingThread function to open the Source window. The 
  1068.      Source window displays the DrawingThread function. 
  1069.  
  1070.      A separate Source window can be displayed for each thread created by your 
  1071.      program, so more than one view of the same source file may be displayed. 
  1072.  
  1073.  
  1074. ΓòÉΓòÉΓòÉ 4.6.2. Using the Locate Function Action Window ΓòÉΓòÉΓòÉ
  1075.  
  1076. The DrawingThread function is a static function, which means it is local to the 
  1077. DPMLINES.EXE. 
  1078.  
  1079. The debugger needs more information when searching for static functions than is 
  1080. needed to find global functions. 
  1081.  
  1082. To demonstrate: 
  1083.  
  1084.   1. In the Source window, select Where from the File menu to locate the 
  1085.      current execution line. 
  1086.  
  1087.   2. Select Locate function from the File menu. The Locate Function action 
  1088.      window is displayed. 
  1089.  
  1090.   3. Type the following in the Function entry field and press the OK push 
  1091.      button. 
  1092.  
  1093.                DrawingThread
  1094.  
  1095.      Since this is a static function, the following message is displayed: 
  1096.  
  1097.                No matching functions found.
  1098.                Desired function could be static.
  1099.  
  1100.      If you want to use Locate Function to find a static function, you need to 
  1101.      specify which executable file and object file to search. 
  1102.  
  1103.   4. Select OK to remove the message box. 
  1104.  
  1105.   5. Disable the All executables check box and select DPMLINES.EXE from the 
  1106.      Executable drop-down list box. 
  1107.  
  1108.   6. Ensure that the Debug data only check box is enabled (restricting the 
  1109.      search to only files that were compiled with debugging information) and 
  1110.      select DPMLINES from the Source list box.  DPMLINES should appear in this 
  1111.      entry field now. 
  1112.  
  1113.   7. In the Function entry field, ensure that the following is displayed: 
  1114.  
  1115.         DrawingThread 
  1116.  
  1117.      Note:  Disable the Case sensitive check box if you want it to search 
  1118.      without sensitivity to upper and lower case characters. 
  1119.  
  1120.   8. Select the OK push button to find the function. This tells the debugger to 
  1121.      search for the function within a certain executable and object file. 
  1122.  
  1123.  Now you can review the lines of the code that lead up to the new section of 
  1124.  code by scrolling in the Source window. The first line in the new section of 
  1125.  code can be identified by the breakpoint that you set earlier at line 567. The 
  1126.  prefix area is highlighted in red where breakpoints are set. 
  1127.  
  1128.  
  1129. ΓòÉΓòÉΓòÉ 4.6.3. Searching for a Text String ΓòÉΓòÉΓòÉ
  1130.  
  1131. You can also search for text strings in a source file. For example, to search 
  1132. for the occurrence of the Fcolour text string, do the following: 
  1133.  
  1134.   1. From the Edit menu in the Source window, select Search. The Search action 
  1135.      window is displayed. 
  1136.  
  1137.   2. In the Enter search text entry field, type the following: 
  1138.  
  1139.         Fcolour 
  1140.  
  1141.      Note:  The search is not case sensitive unless you enable the Case 
  1142.      sensitive check box. 
  1143.  
  1144.   3. Select the OK push button to accept the information that you entered and 
  1145.      to close the Search action window. 
  1146.  
  1147.      The text in the Source window scrolls to the first occurrence of the text 
  1148.      string and highlights Fcolour in gray. 
  1149.  
  1150.   4. To find the next occurrence of Fcolour, select Find next from the Edit 
  1151.      menu in the Source window while the Source window is selected. 
  1152.  
  1153.      The next occurrence of the text string is highlighted. 
  1154.  
  1155.  When you are finished using Search, go to the Debug Session Control window and 
  1156.  double-click on the DrawingThread function to return to its definition in the 
  1157.  Source window. 
  1158.  
  1159.  
  1160. ΓòÉΓòÉΓòÉ 4.6.4. Using Where To Locate the Next Line ΓòÉΓòÉΓòÉ
  1161.  
  1162. Use the Where choice to locate the next line in your program to be executed. 
  1163. To do this, complete the following: 
  1164.  
  1165.   1. In the Source window for thread 2, select Where from the File menu to 
  1166.      quickly locate line 567, the next line to be executed in the thread.  This 
  1167.      is where you set the breakpoint, and where the program is currently 
  1168.      stopped. 
  1169.  
  1170.   2. Select the Step over button to execute the current line. 
  1171.  
  1172.      Line number 567 is executed, and the current line moves from line 567 to 
  1173.      line 568. 
  1174.  
  1175.   3. Select Step over two more times. The current line should now be 570. 
  1176.  
  1177.   4. Double-click on line 571 to set a line breakpoint. 
  1178.  
  1179.   5. Notice that the line that executes next depends on the result of the 
  1180.      expression in line 571. Line 571 displays as: 
  1181.  
  1182.              if (oldFcolour != lFcolour) {
  1183.  
  1184.      The code between lines 571 and 594 is executed only if the oldFcolour 
  1185.      variable is not equal to the lFcolour variable. 
  1186.  
  1187.   6. Select the Run button to reach line 571. 
  1188.  
  1189.  
  1190. ΓòÉΓòÉΓòÉ 4.6.5. Monitoring an Expression ΓòÉΓòÉΓòÉ
  1191.  
  1192. You can monitor expressions from your program, or expressions that are not in 
  1193. your program. 
  1194.  
  1195. To verify that the oldFcolour variable is equal to the lFcolour variable: 
  1196.  
  1197.   1. Highlight the expression on line 571 by pressing and dragging the mouse 
  1198.      pointer over the following expression: 
  1199.  
  1200.                (oldFcolour != lFcolour)
  1201.  
  1202.   2. From the Variable pull-down, select Monitor expression. 
  1203.  
  1204.      The Monitor Expression action window is displayed and the expression you 
  1205.      highlighted is inserted in the Expression entry field. 
  1206.  
  1207.   3. Select the Monitor properties push button. The Monitor Properties action 
  1208.      window is displayed. This shows information about the Monitor Expression 
  1209.      action window.  Its location is in the Program Monitor action window by 
  1210.      default. 
  1211.  
  1212.   4. Select the Cancel push button to exit the Monitor Properties action 
  1213.      window, since you do not want to make any changes at this time. 
  1214.  
  1215.   5. Select the OK push button to close the Monitor Expression action window. 
  1216.  
  1217.      The (oldFcolour != lFcolour) expression is displayed in the Program 
  1218.      Monitor action window. You may have to resize this window to see the 
  1219.      entire expression. 
  1220.  
  1221.      Note:  A plus icon at the end of the expression indicates that there is 
  1222.      more of the expression to display than fits in the window. 
  1223.  
  1224.      The value of the expression is 0, which means that these variables are 
  1225.      equal. A value of 1 would indicate that the expression was true and that 
  1226.      the variables were not equal. 
  1227.  
  1228.   6. To close the Program Monitor action window, select Close from its system 
  1229.      menu. 
  1230.  
  1231.  
  1232. ΓòÉΓòÉΓòÉ 4.6.6. Locating the Error ΓòÉΓòÉΓòÉ
  1233.  
  1234. The program error may be apparent to you if you read the next few lines of code 
  1235. after line 571. 
  1236.  
  1237. The DPMLINES program periodically changes the color of the lines that are being 
  1238. drawn.  The lFcolour variable is updated with the new color only when the color 
  1239. of the line changes. When we reach line 571, the lFcolour and oldFcolour 
  1240. variables are equal, so the section of code between lines 571 and 594 is not 
  1241. executed.  This is why the color number is never written on the screen. 
  1242.  
  1243.  
  1244. ΓòÉΓòÉΓòÉ 4.7. Monitoring the Registers ΓòÉΓòÉΓòÉ
  1245.  
  1246. The Register window displays the processor registers and flags,  including the 
  1247. coprocessor information. 
  1248.  
  1249. You will learn how to change the EAX register contents in the next few panels. 
  1250.  
  1251. To display the contents of EAX register: 
  1252.  
  1253.   1. Select the Register button in the title bar. 
  1254.  
  1255.      The Register window is displayed. 
  1256.  
  1257.   2. Review the contents of the EAX register. 
  1258.  
  1259.  
  1260. ΓòÉΓòÉΓòÉ 4.7.1. Executing the Current Line to Update the EAX Register ΓòÉΓòÉΓòÉ
  1261.  
  1262. To execute the current line: 
  1263.  
  1264.   1. Select the View button in the title bar of the Source window twice. The 
  1265.      Mixed window is displayed. 
  1266.  
  1267.      The first assembler instruction for the current line is highlighted in 
  1268.      black in the Mixed window. 
  1269.  
  1270.      You can see the instruction that loads the EAX register with the contents 
  1271.      of one of the variables in line 571. 
  1272.  
  1273.   2. Place your mouse pointer inside the Mixed window and press mouse button 
  1274.      two. The debugger executes the current line of code, which is the MOV 
  1275.      instruction and is the first assembler statement for line 571. 
  1276.  
  1277.   3. Review the contents of the EAX register. The EAX register has been updated 
  1278.      with the contents of the lFcolour variable. 
  1279.  
  1280.  
  1281. ΓòÉΓòÉΓòÉ 4.7.2. Changing the Contents on the EAX Register ΓòÉΓòÉΓòÉ
  1282.  
  1283. You can change the contents of the EAX register before executing line 571. 
  1284. However, when you execute 571, the contents returns to 00000001. 
  1285.  
  1286. To do this, complete the following: 
  1287.  
  1288.   1. Delete the breakpoint on the assembler instruction that follows the source 
  1289.      instruction on line 571. 
  1290.  
  1291.   2. Return to the MOV instruction after line 571 by highlighting the prefix 
  1292.      area of the line. 
  1293.  
  1294.   3. Select Jump to Location from the Run menu. 
  1295.  
  1296.   4. Typeover the current EAX register contents, 00000001, with the following 
  1297.      and press Enter: 
  1298.  
  1299.         00000000 
  1300.  
  1301.   5. Step over the MOV instruction by selecting the  button to execute it 
  1302.      again. The EAX register value is set back to 1. 
  1303.  
  1304.   6. Close the Register window. 
  1305.  
  1306.  
  1307. ΓòÉΓòÉΓòÉ 4.8. Using the Monitor Windows ΓòÉΓòÉΓòÉ
  1308.  
  1309. There are two monitor windows: Private Monitor and Program Monitor. 
  1310.  
  1311. The Private Monitor window displays the variables or expressions that are 
  1312. relative to a component or thread. This window closes when its associated 
  1313. program view window closes. 
  1314.  
  1315.      You can bring up this window by selecting Private monitor from the Windows 
  1316.      pull-down in the program view windows. Close the Private Monitor window 
  1317.      before continuing. 
  1318.  
  1319.  The Program Monitor action window is usually used to display the global 
  1320.  variables used in your program.  This next panel shows you how to change the 
  1321.  value of a variable and monitor their values as they change. 
  1322.  
  1323.  
  1324. ΓòÉΓòÉΓòÉ 4.8.1. Changing the Value of a Variable ΓòÉΓòÉΓòÉ
  1325.  
  1326. You can influence the way your program executes by changing the value of a 
  1327. variable. 
  1328.  
  1329. For example, if you change the value of oldFcolour to make it the same as 
  1330. lFcolour, then the IF statement on line 571 will not cause the section of code 
  1331. between lines 571 and 594 to be skipped. 
  1332.  
  1333.      If you were viewing assembler instructions in the Mixed window, return to 
  1334.      the Source window by pressing the View button . now. 
  1335.  
  1336.  To view the values of those variables in a monitor window: 
  1337.  
  1338.   1. To display the Program Monitor action window, select Program monitor from 
  1339.      the Windows pull-down in the program view windows or the Debug Session 
  1340.      Control window. 
  1341.  
  1342.   2. Double-click on the oldFcolour and lFcolour variables to place them in the 
  1343.      Program Monitor action window. 
  1344.  
  1345.   3. Change one of the values so that they are not equal.  For example, change 
  1346.      the value of oldFcolour to 2 by typing over the old value. 
  1347.  
  1348.   4. If you are not already there, step or run to line 571. If you step one 
  1349.      more time, line 572 becomes the current line because the expression in 571 
  1350.      is true. 
  1351.  
  1352.  
  1353. ΓòÉΓòÉΓòÉ 4.8.2. Monitoring More Variables ΓòÉΓòÉΓòÉ
  1354.  
  1355. You probably already have at least oldFcolour and lFcolour displayed in the 
  1356. Program Monitor action window. These variables were placed in the Program 
  1357. Monitor action window when you double-clicked on their names in the Source 
  1358. window. 
  1359.  
  1360. The value of a variable as shown in the monitor window changes as the value of 
  1361. the variable changes.  If you want to have the value of oldFcolour displayed 
  1362. but not changed, do the following: 
  1363.  
  1364.   1. Select the oldFcolour variable in the monitor window. 
  1365.  
  1366.   2. From the Options menu in the monitor window, select Disable to disable the 
  1367.      monitored variable. The displayed value of this variable is not updated as 
  1368.      the program executes. 
  1369.  
  1370.  Now you can learn how to display an expression in a monitor window. 
  1371.  
  1372.      Highlight the expression &ptlt on line 586 by dragging the mouse to 
  1373.      include the &, then double-clicking on it. 
  1374.  
  1375.  This adds the expression to the monitor window. 
  1376.  
  1377.  
  1378. ΓòÉΓòÉΓòÉ 4.8.3. Using the Local Variables Monitor Window ΓòÉΓòÉΓòÉ
  1379.  
  1380. You can also monitor all the local variables in your program with the Local 
  1381. Variables window. 
  1382.  
  1383.      Select Local variables from the Windows menu to display the Local 
  1384.      Variables window. It contains all the variables local to the currently 
  1385.      executing program. 
  1386.  
  1387.  If you have many local variables, this window may take more room to display 
  1388.  than the Program Monitor action window.  However, this window shows all the 
  1389.  variables from the current stack frame. 
  1390.  
  1391.      Close the Local Variables window. 
  1392.  
  1393.  
  1394. ΓòÉΓòÉΓòÉ 4.8.4. Displaying Contextual Information for Monitored Variables ΓòÉΓòÉΓòÉ
  1395.  
  1396. The same variable can be used in many places in a program. The value of a 
  1397. variable shown in a monitor is specific to the location in which it is selected 
  1398. for monitoring. 
  1399.  
  1400. Since it is easy to forget where the variable that you are monitoring is 
  1401. located.  You should display the contextual information. Contextual information 
  1402. consists of the source file, line number, and thread. 
  1403.  
  1404. To display the contextual information: 
  1405.  
  1406.   1. Select one or more of the variable monitors in the Program Monitor action 
  1407.      window, by clicking on the names (not the area containing the values). 
  1408.  
  1409.   2. From the Options menu in the Program Monitor action window, select Show 
  1410.      context. 
  1411.  
  1412.   3. If all the contextual information is not displayed, resize the Program 
  1413.      Monitor action window. 
  1414.  
  1415.  
  1416. ΓòÉΓòÉΓòÉ 4.8.5. Changing the Representation of a Variable in the Monitor ΓòÉΓòÉΓòÉ
  1417.  
  1418. In any of the monitor windows, you can also change how a particular variable is 
  1419. displayed. 
  1420.  
  1421. To change how a variable is displayed: 
  1422.  
  1423.   1. Select one of the variable monitors in the Program Monitor action window, 
  1424.      by clicking on the name (not the area containing the value). When a 
  1425.      monitor is selected, it is highlighted. 
  1426.  
  1427.   2. From the Options menu in the Program Monitor action window, select 
  1428.      Representation and select one of the valid representations listed. For 
  1429.      example, for an integer you can pick either Decimal or Hexadecimal. 
  1430.  
  1431.   3. The representation of the selected variable is changed. 
  1432.  
  1433.   4. Close the Program Monitor action window. 
  1434.  
  1435.  
  1436. ΓòÉΓòÉΓòÉ 4.8.6. Reviewing the Contents of the Variables ΓòÉΓòÉΓòÉ
  1437.  
  1438.      Review the contents of the variables you have displayed, and any others 
  1439.      you like, to see if you can determine the location of the error. 
  1440.  
  1441.  Your review of the contents of the variables could lead you along several 
  1442.  paths of investigation. 
  1443.  
  1444.  The following information is important at this point: 
  1445.  
  1446.  o The values of oldFcolour and lFcolour are equal at line 571. 
  1447.  
  1448.    You already knew these variables were equal from a previous step. Because 
  1449.    the variables are equal, the line color does not change during this pass 
  1450.    through thread 2.  If you had not run the program in Run the Program, you 
  1451.    might think this is the reason that the text is not displayed. In fact, the 
  1452.    text is never displayed. 
  1453.  
  1454.  o The value of the lBcolour variable on line 575 and line 585 is the same. 
  1455.    The contents of the lBcolour variable does not change between these lines. 
  1456.  
  1457.    The fact that the value of the lBcolour variable does not change is not 
  1458.    surprising since the background color changes only when you double-click 
  1459.    mouse button two in the DPMLINES window.  If you understand the PM function 
  1460.    calls, however, you may realize at this point that the statement on line 585 
  1461.    sets the color in which the text string is to be written. 
  1462.  
  1463.  o The p variable is a pointer that points to the contents of the buffer 
  1464.    variable. The value of the buffer variable. is an ASCII character string 
  1465.    with the value of 1. 
  1466.  
  1467.    Monitoring the value of the p variable shows that the contents of the 
  1468.    variable lFcolour has been successfully converted to an ASCII text string by 
  1469.    the program. 
  1470.  
  1471.    The next panel shows you how to find the contents of the buffer variable by 
  1472.    monitoring storage. 
  1473.  
  1474.  
  1475. ΓòÉΓòÉΓòÉ 4.9. Monitoring Storage ΓòÉΓòÉΓòÉ
  1476.  
  1477. The Storage window monitors the storage being used by your program. You can 
  1478. open several windows to monitor different areas of storage at the same time. 
  1479. As the program state changes (when it executes and data is updated), the data 
  1480. displayed in the storage windows is updated to reflect these changes. 
  1481.  
  1482. You can change data in storage by typing over the storage values.  Data in 
  1483. other affected windows, such as variable monitors, changes to reflect the new 
  1484. value. 
  1485.  
  1486. You can also change the data that is displayed in the Storage window by typing 
  1487. over the address of a variable.  The Storage window is updated with the data at 
  1488. the new address. 
  1489.  
  1490. This part of the tutorial shows you how to check the contents of storage for 
  1491. the value of the buffer variable.  The buffer variable holds the number of the 
  1492. current color of the line being drawn as a text string. 
  1493.  
  1494.  
  1495. ΓòÉΓòÉΓòÉ 4.9.1. Locating the Address of a Variable ΓòÉΓòÉΓòÉ
  1496.  
  1497. These steps show you how to use the address to view the contents of buffer 
  1498. variable in storage. 
  1499.  
  1500. To locate the address of the buffer variable: 
  1501.  
  1502.   1. From the Variable menu in the Source window, select Monitor expression. 
  1503.      The Monitor Expression action window is displayed. 
  1504.  
  1505.   2. In the Expression entry field, type the following: 
  1506.  
  1507.         &buffer 
  1508.  
  1509.   3. Select the OK push button to accept the information you have entered and 
  1510.      to close the Monitor Expression action window. 
  1511.  
  1512.      The buffer variable address appears in the monitor window. 
  1513.  
  1514.   4. To monitor the value of the buffer variable as well, double-click on the 
  1515.      buffer variable in line 578. 
  1516.  
  1517.  Now you are monitoring both the value and the address of the buffer variable. 
  1518.  
  1519.  
  1520. ΓòÉΓòÉΓòÉ 4.9.2. Changing the Storage Address Style ΓòÉΓòÉΓòÉ
  1521.  
  1522. To change the storage address style: 
  1523.  
  1524.   1. Open the Storage window by selecting Storage from the Windows menu in the 
  1525.      Source window. 
  1526.  
  1527.      The Storage window is displayed. 
  1528.  
  1529.   2. Select Window settings  Address style from the Options menu in the 
  1530.      Storage window. The Storage Address Style action window is displayed. 
  1531.  
  1532.   3. Select the arrow to the right of the Style list box to display a list of 
  1533.      address styles. 
  1534.  
  1535.   4. Select the Flat address style from the list box. The Style list box 
  1536.      closes. 
  1537.  
  1538.   5. Select the OK push button to accept this selection and to close the 
  1539.      Storage Address Style action window. 
  1540.  
  1541.  
  1542. ΓòÉΓòÉΓòÉ 4.9.3. Verifying the Contents of a Variable in Storage ΓòÉΓòÉΓòÉ
  1543.  
  1544. To verify the contents of the buffer variable in storage: 
  1545.  
  1546.   1. Make sure you can see all of the information in the Storage window. Resize 
  1547.      it if necessary. 
  1548.  
  1549.   2. Type over the Flat address field and enter the address of the &buffer 
  1550.      variable shown by the pointer in the monitor window. 
  1551.  
  1552.      The contents of the window are updated one second after the last 
  1553.      keystroke.  The the display is updated incrementally as you type. When you 
  1554.      are finished, the contents of the address is updated and the Storage 
  1555.      window is scrolled to the appropriate address. 
  1556.  
  1557.   3. Review the first line of characters in the Character column. 
  1558.  
  1559.      The first character is a 1, which is the value of the buffer variable. 
  1560.  
  1561.   4. Review the first line of hexadecimal values displayed in the HEX field. 
  1562.  
  1563.      The first two numbers are the hexadecimal representation of 1 in the ASCII 
  1564.      character set. 
  1565.  
  1566.   5. Close the Storage window and Program Monitor window. 
  1567.  
  1568.  
  1569. ΓòÉΓòÉΓòÉ 4.10. Understanding Window Analysis ΓòÉΓòÉΓòÉ
  1570.  
  1571. The Window Analysis window gives you an understanding of PM application 
  1572. windows. It presents both graphical and textual information about your 
  1573. application windows and lets you observe the relationship between windows. 
  1574.  
  1575. You can view an image of your desktop with each of your program windows 
  1576. outlined. This helps to visually distinguish the different windows in your 
  1577. application. You can select any one of these windows and view another 
  1578. three-dimensional breakdown of that individual program window and the windows 
  1579. that make it up. 
  1580.  
  1581. These three-dimensional views also have an added benefit in that hidden details 
  1582. of a window structure can be revealed. For example, windows may exist that are 
  1583. not visible because they are obscured by other windows. 
  1584.  
  1585. By highlighting any of the representations of your program windows in any of 
  1586. these three Window Analysis windows, you can immediately see the related 
  1587. information in the other windows. 
  1588.  
  1589.  
  1590. ΓòÉΓòÉΓòÉ 4.10.1. Viewing the Window Analysis Window ΓòÉΓòÉΓòÉ
  1591.  
  1592. You will need to stop your program before the Window Analysis windows can be 
  1593. displayed. 
  1594.  
  1595.      To display the main Window Analysis window, select Windows  Window 
  1596.      Analysis from the Source window or Debug Session Control window. 
  1597.  
  1598.  The Window Analysis window is displayed. 
  1599.  
  1600.  
  1601. ΓòÉΓòÉΓòÉ 4.10.2. About the Window Analysis Window ΓòÉΓòÉΓòÉ
  1602.  
  1603. The Window Analysis window is shown in a notebook format. You are viewing the 
  1604. primary page, which is a view of the desktop window, with an outline of your 
  1605. programs windows shown. This primary page has a large notebook tab at the 
  1606. bottom of the notebook window named Desktop. 
  1607.  
  1608. The other tabs, along the right side of the Window Analysis window, represent 
  1609. the regular pages. Each regular page shows an image of one of your program 
  1610. windows. 
  1611.  
  1612.      To select one of your program windows, double-click on its image on the 
  1613.      desktop page. 
  1614.  
  1615.  The regular page showing this window is displayed.  Notice that you can also 
  1616.  select it with the notebook tab, once you know which tab corresponds to each 
  1617.  window. 
  1618.  
  1619.  
  1620. ΓòÉΓòÉΓòÉ 4.10.3. Selecting Pages and Windows in the Window Analysis Window ΓòÉΓòÉΓòÉ
  1621.  
  1622. You can select individual windows with the mouse or with the Tab key. 
  1623.  
  1624. Selecting a window makes it available for other analysis functions, which will 
  1625. be described in the next few panels of the tutorial. For example, you can see 
  1626. the names and attributes of each selected window in another window. 
  1627.  
  1628.      Select a window by clicking with the mouse.  The window is highlighted. 
  1629.  
  1630.  You can also select a window by pressing the Tab key. Repeatedly pressing the 
  1631.  Tab key cycles through the windows; the Back-Tab key cycles through the 
  1632.  windows in the opposite direction. 
  1633.  
  1634.  In cases where there are many windows that are difficult to visually separate, 
  1635.  the Tab keys can be helpful to individually select the windows. 
  1636.  
  1637.  
  1638. ΓòÉΓòÉΓòÉ 4.10.4. Rotating Images ΓòÉΓòÉΓòÉ
  1639.  
  1640. Another way to visually separate the different windows in your program is to 
  1641. rotate the windows in the Window Analysis window. 
  1642.  
  1643. This makes the windows easier to see and select individually, often allowing 
  1644. you to see details that might be obscured by other windows from other 
  1645. perspectives.  This is especially useful when there are a large number of 
  1646. overlapping windows. 
  1647.  
  1648. To rotate the windows, use one or both of the: 
  1649.  
  1650.  o Horizontal scroll bar to rotate around the y-axis. 
  1651.  o Vertical scroll bar to rotate around the x-axis. 
  1652.  
  1653.  Note:  You can see a sideways view of your program by scrolling all the way to 
  1654.  the left or right with the horizontal scroll bar. 
  1655.  
  1656.  In addition, two options from the Options menu allow you to rotate windows to 
  1657.  predetermined positions: 
  1658.  
  1659.  Rotate to center 
  1660.            Shows a face-on view as your window appears to the program. 
  1661.  
  1662.  Rotate to default 
  1663.            Places the window at a convenient three dimensional angle for 
  1664.            viewing the separate windows within your programs window, at 
  1665.            approximately a 30-45 degree angle. 
  1666.  
  1667.  
  1668. ΓòÉΓòÉΓòÉ 4.10.5. Using Window Characteristics ΓòÉΓòÉΓòÉ
  1669.  
  1670. Use the Window Characteristics to see a list of textual information about a 
  1671. particular window.  This includes all the names and attributes within that 
  1672. window.  Selecting them visually with the mouse highlights the corresponding 
  1673. items in the Window Characteristics window. 
  1674.  
  1675. Now that you can select individual windows in several different ways, you can 
  1676. view information about each of the windows selected: 
  1677.  
  1678.   1. Select the image of the main DPMLINES window in the Window Analysis 
  1679.      window. 
  1680.  
  1681.   2. Select the tab D1 directly. 
  1682.  
  1683.      If you do not see D1, you need to disable the Bitmaps choice from the 
  1684.      Options menu in the Window Analysis window. 
  1685.  
  1686.   3. Select Window Characteristics from the Details menu in the Window Analysis 
  1687.      window. 
  1688.  
  1689.      Note that this window is a secondary window to the Window Analysis window, 
  1690.      and thus always displays in front of the Window Analysis window. It is 
  1691.      also automatically closed if the Window Analysis window is closed. 
  1692.  
  1693.      As you select the individual windows in the Window Analysis window, note 
  1694.      how the class names and other information is highlighted in the Window 
  1695.      Characteristics window. 
  1696.  
  1697.      Each row in the Window Characteristics window represents one window in the 
  1698.      Window Analysis window. 
  1699.  
  1700.  
  1701. ΓòÉΓòÉΓòÉ 4.10.6. Adding Additional Window Characteristics ΓòÉΓòÉΓòÉ
  1702.  
  1703. To add a column of information to the Window Characteristics window and show 
  1704. more information for each window, use the Display style choice.  To do this: 
  1705.  
  1706.   1. Select Options  Display style from the Window Characteristics window. 
  1707.  
  1708.   2. Choose Text and Visible by selecting these keywords from the Visible 
  1709.      characteristics scroll box. 
  1710.  
  1711.   3. Select the OK push button to return to the Window Characteristics window 
  1712.      with your selections. 
  1713.  
  1714.  Two columns, entitled Text and Visible, are added to the window.  You may have 
  1715.  to resize the window to see the additional columns and information. 
  1716.  
  1717.  The text displayed in the Text column shows the relationship of your program 
  1718.  windows and how your program windows are displayed when the program is 
  1719.  running. 
  1720.  
  1721.  The Visible column should also show you why the Window Analysis windows show 
  1722.  more buttons defined in this window than the OK push button that you can see. 
  1723.  The other buttons are not visible. 
  1724.  
  1725.  
  1726. ΓòÉΓòÉΓòÉ 4.10.7. Displaying the Parent and Z-Order tree ΓòÉΓòÉΓòÉ
  1727.  
  1728. The Parent and Z-Order Tree window displays a list of the parents and children 
  1729. of each window in your program, in a hierarchical tree. It also indicates the 
  1730. Z-order, which windows are displayed in front of or behind other windows. 
  1731.  
  1732. This window shows a list of the parents and children of the window displayed, 
  1733. as well as the Z-order.  The Z-Order is the back-to-front stacking of the 
  1734. windows, which indicates which windows are displayed in front of other windows. 
  1735.  
  1736.      To display the Parent and Z-Order Tree window, select Details  Parent and 
  1737.      Z-Order Tree from the Window Analysis window. 
  1738.  
  1739.  Like the Window Characteristics window, the Parent and Z-Order Tree window is 
  1740.  a secondary window to the Window Analysis window, so it always displays in 
  1741.  front of it, and is closed when the Window Analysis window is closed. 
  1742.  
  1743.  Within the Parent and Z-Order Tree window, you can expand and collapse the 
  1744.  tree that shows the parent-child relationships among the windows using the 
  1745.  plus and minus icons, respectively. 
  1746.  
  1747.  
  1748. ΓòÉΓòÉΓòÉ 4.10.8. Reflecting Window Information ΓòÉΓòÉΓòÉ
  1749.  
  1750. Notice than whenever you select a window in any of the three window analysis 
  1751. windows, it is reflected, or highlighted in the other two windows as well. 
  1752.  
  1753. By using the three window analysis windows, you can see the graphical placement 
  1754. of a window while seeing the names of its parts and its relationship to the 
  1755. other views. 
  1756.  
  1757.      Now close the Window Analysis window. 
  1758.  
  1759.  The other two windows close also. 
  1760.  
  1761.  
  1762. ΓòÉΓòÉΓòÉ 4.11. Monitoring Messages in the Message Queue Monitor Window ΓòÉΓòÉΓòÉ
  1763.  
  1764. The Message Queue Monitor window displays PM messages associated with a PM 
  1765. program.  It presents the messages in a list as they occur.  Using the message 
  1766. queue monitor, you can control: 
  1767.  
  1768.  o What is displayed for each message 
  1769.  o How the message parameters are formatted 
  1770.  o Which messages are monitored 
  1771.  o Which windows have their messages monitored 
  1772.  o Which message queues have their messages monitored 
  1773.  o New messages that you define. 
  1774.  
  1775.  
  1776. ΓòÉΓòÉΓòÉ 4.11.1. Selecting Messages to Monitor ΓòÉΓòÉΓòÉ
  1777.  
  1778. To select the messages you want to have monitored: 
  1779.  
  1780.   1. Select Message queue monitor from the Windows pull-down in the program 
  1781.      view window or Debug Session Control window.  The Message Queue Monitor 
  1782.      window appears. 
  1783.  
  1784.   2. In the Message Queue Monitor window, select Monitor messages from the 
  1785.      Options pull-down. 
  1786.  
  1787.   3. In the Monitor Messages action window, scroll within the Defined Message 
  1788.      IDs list box. 
  1789.  
  1790.   4. Highlight only the WM_COMMAND message. 
  1791.  
  1792.      You need to deselect any other messge IDs that are highlighted, such as 
  1793.      WM_CHAR and WM_CLOSE. 
  1794.  
  1795.   5. Select the highlighted IDs to remove the highlighting. Leave the 
  1796.      WM_COMMAND message highlighted.  This is the only message that is 
  1797.      monitored. 
  1798.  
  1799.   6. Scroll to the end and remove the highlighting from the rest of the WM_ 
  1800.      messages. 
  1801.  
  1802.   7. Select the OK push button to accept the information you have entered and 
  1803.      close this window. 
  1804.  
  1805.  
  1806. ΓòÉΓòÉΓòÉ 4.11.2. Selecting the Message Display Style ΓòÉΓòÉΓòÉ
  1807.  
  1808. Select a PM message parameter to monitor: 
  1809.  
  1810.   1. Select Display Style from the Options pull-down. 
  1811.  
  1812.   2. Highlight MP 1 in the Columns list box. (Make sure that only three items 
  1813.      are highlighted in this list box: CLASS, MESSAGE, and the MP 1 that you 
  1814.      added.) 
  1815.  
  1816.   3. Select the OK push button to accept the information you have entered and 
  1817.      close this window. 
  1818.  
  1819.  
  1820. ΓòÉΓòÉΓòÉ 4.11.3. Selecting the Format of Message Parameters ΓòÉΓòÉΓòÉ
  1821.  
  1822. You can select the format of the MP 1 messages by doing the following: 
  1823.  
  1824.   1. Select Format Parameters from the Options pull-down to display the Format 
  1825.      Parameters window. 
  1826.  
  1827.   2. Within this window, find WM_COMMAND in the Message list box, and highlight 
  1828.      it. 
  1829.  
  1830.   3. Under the Parameter formatting group heading, 2 16-bit unsigned integers 
  1831.      is selected by default for the MP 1 entry field.  Open the MP1 entry field 
  1832.      by selecting the down arrow and select 32-bit unsigned integer from the 
  1833.      list box. You may have to scroll up in the list box to find it. 
  1834.  
  1835.      (The format for MP 2 does not matter since you are not monitoring that 
  1836.      message parameter). 
  1837.  
  1838.   4. Select the OK push button to accept the information you have entered and 
  1839.      close this window. 
  1840.  
  1841.  
  1842. ΓòÉΓòÉΓòÉ 4.11.4. Selecting Which Windows to Monitor ΓòÉΓòÉΓòÉ
  1843.  
  1844. To set the debugger to monitor the messages from the DPMLINES windows: 
  1845.  
  1846.   1. In the Message Queue Monitor window, select Monitor Windows from the 
  1847.      Options pull-down. 
  1848.  
  1849.   2. Enable the Monitor all windows check box. 
  1850.  
  1851.   3. Select the OK push button to accept the information you have entered and 
  1852.      close this window. 
  1853.  
  1854.  
  1855. ΓòÉΓòÉΓòÉ 4.11.5. Run the Program and Watch the Monitored Messages ΓòÉΓòÉΓòÉ
  1856.  
  1857. Run the program to see the messages that are displayed in the Message Queue 
  1858. Monitor window. 
  1859.  
  1860.   1. Run the program by selecting the Run button  in the title bar of the 
  1861.      Source window. 
  1862.  
  1863.      While it waits for input, it displays a clock icon in place of the mouse 
  1864.      pointer. 
  1865.  
  1866.   2. In the program window, you can see the program continually draws lines in 
  1867.      DPMLINES window.  The color of these lines changes every few seconds. 
  1868.  
  1869.   3. In the Message Queue Monitor window, you may have to expand the window to 
  1870.      see all the columns. 
  1871.  
  1872.   4. In the DPMLINES window, select Help  Instructions to observe which 
  1873.      messages are monitored. 
  1874.  
  1875.   5. From the Exit menu in the DPMLINES window, select Exit DPMLINES. 
  1876.  
  1877.   6. Close the Message Queue Monitor window. 
  1878.  
  1879.  
  1880. ΓòÉΓòÉΓòÉ 4.12. Fixing DPMLINES ΓòÉΓòÉΓòÉ
  1881.  
  1882. Note:  Before you edit the DPMLINES program to correct the error, copy it to a 
  1883. new directory so others can use the tutorial after you are finished. Do not 
  1884. edit the copy of the DPMLINES program that is shipped with the product. 
  1885.  
  1886.  
  1887. ΓòÉΓòÉΓòÉ 4.12.1. Correcting the Error ΓòÉΓòÉΓòÉ
  1888.  
  1889. The error in the DPMLINES code occurs at line 585, which appears as 
  1890. GpiSetColor ( hps, lBcolour); 
  1891.  
  1892. This statement sets the color of the text that is to be displayed when the 
  1893. color changes.  The text string is correctly written by the statement in line 
  1894. 586, but it is invisible since it is set to be written in the same color as the 
  1895. background. 
  1896.  
  1897. Now, edit the DPMLINES program to correct the error: 
  1898.  
  1899.      Change the lBcolour variable in line 585 with the color CLR_BLACK. 
  1900.  
  1901.      After you have edited the program, compile and link it, then run the 
  1902.      program as described under Run the Program. 
  1903.  
  1904.  Notice that the active_line_color_code is now visible in the lower left-hand 
  1905.  corner of the DPMLINES window. 
  1906.  
  1907.  
  1908. ΓòÉΓòÉΓòÉ 4.13. Closing the DPMLINES Program ΓòÉΓòÉΓòÉ
  1909.  
  1910. Now that you have completed Lesson 1, you'll need to close the DPMLINES 
  1911. program.  To close the program, do the following: 
  1912.  
  1913.   1. From the Exit menu in the DPMLINES window, select Exit DPMLINES. 
  1914.  
  1915.      The DPMLINES window is closed and the Program Terminated window is 
  1916.      displayed. 
  1917.  
  1918.   2. In the Program Terminated window, answer No to the prompt: 
  1919.  
  1920.           Do you want to save restart information?
  1921.  
  1922.      The DPMLINES program is ended, the Source window closes, and the Debug 
  1923.      Session Control window is left as the only debugger window. 
  1924.  
  1925.  
  1926. ΓòÉΓòÉΓòÉ 5. Debugger Features for C++ Programming ΓòÉΓòÉΓòÉ
  1927.  
  1928. This part of the tutorial contains two lessons that show you how to perform 
  1929. debugging tasks specific to C++ programs. 
  1930.  
  1931. These lessons repeat some information from Lesson 1 of this tutorial, but also 
  1932. shows you how the debugger displays and handles C++ classes and templates. 
  1933.  
  1934. If you have not already done so, resize the Tutorial window to occupy about 
  1935. half of your screen, allowing the other half to perform the following debugging 
  1936. lessons: 
  1937.  
  1938.  o The First C++ Sample Program: MCELCV introduces the debugger features that 
  1939.    show class inheritance, class details, overloaded functions, and C++ 
  1940.    expressions. This program does not contain an error. 
  1941.  
  1942.  o The  Second C++ Sample Program: NEST introduces the debugger features that 
  1943.    show template functions. This program contains an exception handling error. 
  1944.  
  1945.  
  1946. ΓòÉΓòÉΓòÉ 5.1. Lesson 2: Loading MCELCV ΓòÉΓòÉΓòÉ
  1947.  
  1948. This lesson shows you how to: 
  1949.  
  1950.  o Set function breakpoints 
  1951.  o Locate the source for a particular function 
  1952.  o Find overloaded functions 
  1953.  o Use breakpoints 
  1954.  o Use the Inheritance View and Class Details windows. 
  1955.  
  1956.  The C++ program, MCELCV, includes classes, static data members, and reference 
  1957.  variables.  To load MCELCV, do the following: 
  1958.  
  1959.   1. From the Debug Session Control window, select Startup from the File menu. 
  1960.  
  1961.   2. In the Program entry field, type the following: 
  1962.  
  1963.             IBMCPP\TUTORIAL\DEBUGGER\MCELCV\MCELCV.EXE
  1964.  
  1965.      Note:  Make sure the Debug program initialization check box is not 
  1966.      enabled. 
  1967.  
  1968.   3. Select OK to load the program. 
  1969.  
  1970.      The Debug Session Control window and the Source window are displayed.  You 
  1971.      can monitor the execution of your program from the Source window. 
  1972.  
  1973.  
  1974. ΓòÉΓòÉΓòÉ 5.1.1. Setting Function Breakpoints ΓòÉΓòÉΓòÉ
  1975.  
  1976. In the next few steps, you can learn how to do use the Debug Session Control 
  1977. window to set function breakpoints: 
  1978.  
  1979.   1. Go to the Debug Session Control window and expand the MCELCV.EXE 
  1980.      executable by selecting the plus icon.  The object files that make up the 
  1981.      executable are displayed. 
  1982.  
  1983.   2. Select the plus icon beside the AMCELCV.OBJ object file to expand it. 
  1984.  
  1985.   3. Double-click on the following function: 
  1986.  
  1987.       ApushButtonHandler::command(ICommandEvent&) 
  1988.  
  1989.      The source code at that entry point is displayed. 
  1990.  
  1991.   4. Set a function breakpoint by highlighting the following line in the Debug 
  1992.      Session Control window: 
  1993.  
  1994.        ApushButtonHandler::command(ICommandEvent&) 
  1995.  
  1996.   5. Select the Breakpoints menu and then select the Function choice.  The 
  1997.      Breakpoints action window is displayed with the function name already 
  1998.      filled in for you. 
  1999.  
  2000.   6. In the Breakpoints action window, disable the All executables check box in 
  2001.      the Executable entry field. This causes the following to be displayed in 
  2002.      the Executable entry field: 
  2003.  
  2004.                MCELCV.EXE
  2005.  
  2006.      and the following to display in the Source entry field: 
  2007.  
  2008.                AMCELCV
  2009.  
  2010.      The Source entry field indicates the object file. 
  2011.  
  2012.   7. Select OK to set the breakpoint at the function in AMCELCV. The 
  2013.      Breakpoints action window closes. 
  2014.  
  2015.      Note:  If you want to confirm that the breakpoint is set, look at the 
  2016.      ApushButtonHandler::Command(ICommandEvent&) line of the AMCELCV.CPP source 
  2017.      file, which is highlighted red. 
  2018.  
  2019.   8. In the Source window, select Where from the File menu to locate the 
  2020.      current execution line. 
  2021.  
  2022.  
  2023. ΓòÉΓòÉΓòÉ 5.1.2. Locating Source Code for a Function ΓòÉΓòÉΓòÉ
  2024.  
  2025. This step shows you how to locate the source code for a function. Here, you 
  2026. will find the command function: 
  2027.  
  2028.   1. Select the Debug Session Control window. 
  2029.  
  2030.   2. From the File pull-down, select Locate Function. The Locate Function 
  2031.      window is displayed. 
  2032.  
  2033.   3. Disable the All executables check box. 
  2034.  
  2035.   4. Type the following in the Executable entry field or select it from the 
  2036.      Executable list box: 
  2037.  
  2038.                MCELCV.EXE
  2039.  
  2040.   5. Type the following in the Source entry field or select it from the Source 
  2041.      list box: 
  2042.  
  2043.                AMCELCV
  2044.  
  2045.   6. Type the following in the Function entry field: 
  2046.  
  2047.                Command
  2048.  
  2049.   7. Select OK to accept the changes. 
  2050.  
  2051.      The Source window is displayed at the same point of the source code before 
  2052.      you used the Where choice. 
  2053.  
  2054.  
  2055. ΓòÉΓòÉΓòÉ 5.1.3. Finding Overloaded Functions ΓòÉΓòÉΓòÉ
  2056.  
  2057. In this panel, you can learn how to locate overloaded functions and select the 
  2058. appropriate function. To do this: 
  2059.  
  2060.   1. Go to the Debug Session Control window. 
  2061.  
  2062.   2. Highlight the following function: 
  2063.  
  2064.       IMessageBox::Style::Style(unsigned long) 
  2065.  
  2066.   3. Fron the Breakpoints menu, select the Function choice.  The Breakpoints 
  2067.      window is displayed with the function name already filled in. 
  2068.  
  2069.   4. In the Breakpoints action window, disable the All executables box in the 
  2070.      Executable entry field.  This causes the following to be displayed in the 
  2071.      Executable entry field: 
  2072.  
  2073.                MCELCV.EXE
  2074.  
  2075.      and the following to be displayed in the Source entry field: 
  2076.  
  2077.                AMCELCV
  2078.  
  2079.   5. Select the OK push button. The Overloaded Function action window is 
  2080.      displayed with two functions. 
  2081.  
  2082.   6. Highlight the following function: 
  2083.  
  2084.       IMessageBox::Style::Style(unsigned long) 
  2085.  
  2086.      This causes a function breakpoint to be set for that function. 
  2087.  
  2088.   7. Select OK to accept the changes and close the window. 
  2089.  
  2090.   8. To confirm that the breakpoint is set, select the Breakpoints menu and 
  2091.      then the List choice. 
  2092.  
  2093.      The IMessageBox::Style::Style(unsigned long) function is displayed. 
  2094.  
  2095.   9. Select the Delete button to delete this function breakpoint. 
  2096.  
  2097.  10. Select OK to accept the changes and close the window. 
  2098.  
  2099.  
  2100. ΓòÉΓòÉΓòÉ 5.1.4. Using Breakpoints and Stepping through the Program ΓòÉΓòÉΓòÉ
  2101.  
  2102. In this step, you will learn how to expand objects to see what they contain. 
  2103. To expand the objects: 
  2104.  
  2105. Note:  If you have not set the debugging mode to asynchronous, you'll need to 
  2106. do so now. 
  2107.  
  2108.   1. In the Source window, double-click on line 124 in AMCELCV.CPP. The line 
  2109.      prefix area turns red to indicate that the breakpoint was set. 
  2110.  
  2111.   2. Single-step using mouse button two until the program reaches line 45. You 
  2112.      have not encountered the breakpoint yet. 
  2113.  
  2114.   3. Select the Run button in the title bar. 
  2115.  
  2116.      The Debug Appl window is displayed. 
  2117.  
  2118.   4. Select the Read push button. 
  2119.  
  2120.   5. Select the Run button to run the program again. The next breakpoint should 
  2121.      be encountered at line 134. 
  2122.  
  2123.   6. Select the Run button again. The next breakpoint should be encountered at 
  2124.      line 124. 
  2125.  
  2126.   7. Double-click on line 123 on the str1 object. The Program Monitor action 
  2127.      window for the object displays. The str1 object is displayed. 
  2128.  
  2129.   8. Close the Monitor window. 
  2130.  
  2131.  
  2132. ΓòÉΓòÉΓòÉ 5.1.5. Viewing the Inheritance View and Class Details Windows ΓòÉΓòÉΓòÉ
  2133.  
  2134. The Inheritance View is a graphical picture of the relationship of the classes 
  2135. in an object file (OBJ). In this case, the graphical picture shows the 
  2136. inheritance relationships between the classes in MCELCV. To do this: 
  2137.  
  2138.   1. From the Windows pull-down in the Source window, select Inheritance view 
  2139.      to show the Inheritance View window for the classes in the MCELCV program. 
  2140.      Use the scroll bars in the Inheritance View window to scroll within it. 
  2141.  
  2142.      A list on the right side of the picture lists the classes; you may select 
  2143.      a class name either in this list or in the graphical picture. You can also 
  2144.      display a hierarchical tree of the derived and base classes in this class 
  2145.      list. 
  2146.  
  2147.   2. Use the Options menu option to control the Classes box: 
  2148.  
  2149.      a. Select Derived to base class tree from the Options pull-down to display 
  2150.         the classes box in a hierarchical tree listing the classes 
  2151.         alphabetically.  Click on the plus icon next to any class name to 
  2152.         expand it into its base classes. 
  2153.  
  2154.      b. Select Base to derived class tree from the Options pull-down to display 
  2155.         the classes box as a hierarchical tree listing the classes 
  2156.         alphabetically.  Click on the plus icon next to any class name to 
  2157.         expand it into its derived classes. 
  2158.  
  2159.      c. Select Class list from the Options pull-down to return to the simple or 
  2160.         non-expandable class list display. 
  2161.  
  2162.   3. To display class details for any class, select the IHandler class by 
  2163.      double-clicking on the box for IHandler in either the graph or the list 
  2164.      box. This displays the Class Details window for the IHandler class. 
  2165.  
  2166.   4. To show the class information, such as data members, member functions, 
  2167.      base classes, derived classes, class friends, and friend functions, scroll 
  2168.      through the pages of the Class Details window. 
  2169.  
  2170.   5. Close the Class Details window. 
  2171.  
  2172.  
  2173. ΓòÉΓòÉΓòÉ 5.1.6. Viewing the Inheritance Overview ΓòÉΓòÉΓòÉ
  2174.  
  2175.      From the File pull-down in the Inheritance View window, select Overview. 
  2176.  
  2177.  The Overview window, which appears, gives a small view of the portion of the 
  2178.  class hierarchy that is shown in the Inheritance View window within the 
  2179.  overall Inheritance View. 
  2180.  
  2181.      To create a smaller or larger view in the Inheritance View window, use 
  2182.      mouse button 2 to drag an edge of the box in the Overview window. For 
  2183.      example, you can make a larger window to include more classes in the 
  2184.      Inheritance View window. Move the Overview window by dragging the center 
  2185.      of the box with mouse button two. 
  2186.  
  2187.  This moves the portion of the Inheritance View window within the other window. 
  2188.  
  2189.      Close the Inheritance View window. 
  2190.  
  2191.  The Overview window closes as well. 
  2192.  
  2193.  
  2194. ΓòÉΓòÉΓòÉ 5.1.7. Summary of Lesson 2 ΓòÉΓòÉΓòÉ
  2195.  
  2196. This lesson showed you how to: 
  2197.  
  2198.  o Set function breakpoints 
  2199.  
  2200.  o Locate the source for a particular function 
  2201.  
  2202.  o Find overloaded functions 
  2203.  
  2204.  o Use breakpoints 
  2205.  
  2206.  o Use the Inheritance View and Class Details windows. 
  2207.  
  2208.  
  2209. ΓòÉΓòÉΓòÉ 5.2. Lesson 3: Loading NEST ΓòÉΓòÉΓòÉ
  2210.  
  2211. In this lesson the debugger is used to: 
  2212.  
  2213.  o Examine template functions 
  2214.  o Set ambiguous breakpoints for overloaded entries 
  2215.  o Handle exceptions 
  2216.  
  2217.  It uses the sample program NEST.  To load the NEST program: 
  2218.  
  2219.   1. Select Startup from the File pull-down in the Debug Session Control 
  2220.      window. 
  2221.  
  2222.   2. In the Program entry field of the Startup window, type: 
  2223.  
  2224.      IBMCPP\TUTORIAL\DEBUGGER\NEST\NEST.EXE 
  2225.  
  2226.   3. Select the OK push button to load the program. 
  2227.  
  2228.      The Source window is displayed. 
  2229.  
  2230.  
  2231. ΓòÉΓòÉΓòÉ 5.2.1. Showing Include Files in the Source Window ΓòÉΓòÉΓòÉ
  2232.  
  2233. The Source window contains the source for the executable file you are 
  2234. debugging. 
  2235.  
  2236. Note that the notebook format is available whenever there is executable code in 
  2237. include files, such as in our NEST program. The notebook format is useful for 
  2238. quick access to other files that contain source for the object file (OBJ), such 
  2239. as include files. 
  2240.  
  2241.  
  2242. ΓòÉΓòÉΓòÉ 5.2.2. Displaying the Include Files ΓòÉΓòÉΓòÉ
  2243.  
  2244. To display an include file from one of the program view windows, select a 
  2245. notebook tab at the bottom of the notebook. 
  2246.  
  2247.      For example, select the NESTTPL.CPP tab to see the source code. 
  2248.  
  2249.  
  2250. ΓòÉΓòÉΓòÉ 5.2.3. Setting Breakpoints for all Template Functions ΓòÉΓòÉΓòÉ
  2251.  
  2252. Now you will learn how to set breakpoints for all instances of a template 
  2253. function, and for a specific instance of a template function. 
  2254.  
  2255.      To set a breakpoint for all instances of a template function, double-click 
  2256.      on the line 3. 
  2257.  
  2258.  The prefix area turns red, indicating that the breakpoint has been set. 
  2259.  
  2260.  There are several ways to see where the breakpoints have been set: 
  2261.  
  2262.   1. Select List from the Breakpoints pull-down in the Source window.  The List 
  2263.      action window shows that the breakpoint is set in two places, once for 
  2264.      each instance of the template function. Close the List action window. 
  2265.  
  2266.   2. Select the View button  from the title bar until the Mixed window is 
  2267.      displayed.  In the Mixed window, the template function disassembled code 
  2268.      is listed twice, once for each instance of the template function. 
  2269.  
  2270.  
  2271. ΓòÉΓòÉΓòÉ 5.2.4. Setting a Breakpoint for one Template Function ΓòÉΓòÉΓòÉ
  2272.  
  2273. To set a breakpoint for a specific instance of a template function: 
  2274.  
  2275.   1. Set a breakpoint at line 9 by highlighting the prefix area. The prefix 
  2276.      area turns gray. 
  2277.  
  2278.      Note:  If you double-click on the line number prefix, as in the previous 
  2279.      example, a breakpoint is set for all instances of the template function. 
  2280.  
  2281.   2. From the Breakpoints pull-down, select Line. 
  2282.  
  2283.      The Breakpoints notebook is displayed for a Line Breakpoint, with the Line 
  2284.      tab already selected, and Line 9 already filled in. 
  2285.  
  2286.   3. Select the OK push button to set the breakpoint on line 9. 
  2287.  
  2288.      The Ambiguous Line action window appears, allowing you to select which 
  2289.      template function to set a breakpoint for. 
  2290.  
  2291.   4. Select the function for outer<int,char*>::inner::hello(int,char*). 
  2292.  
  2293.      You can select the Set push button to set more breakpoints. 
  2294.  
  2295.   5. Press the OK push button in the Ambiguous Line window to set the 
  2296.      breakpoint and exit the Ambiguous Line and Breakpoints windows. 
  2297.  
  2298.      In the Source window, you can see that the prefix area on line 9 is now 
  2299.      red, indicating that a breakpoint has been set there. 
  2300.  
  2301.  
  2302. ΓòÉΓòÉΓòÉ 5.2.5. Listing Breakpoints ΓòÉΓòÉΓòÉ
  2303.  
  2304. To view the breakpoints you have just set: 
  2305.  
  2306.   1. From the Breakpoints pull-down in the Source window, select List. 
  2307.  
  2308.      Note that the breakpoint on line 3 is set in two places for each of the 
  2309.      function entries.  The breakpoint on line 9 is set for the single function 
  2310.      that you selected. 
  2311.  
  2312.   2. Press the OK push button to exit the Breakpoints list. 
  2313.  
  2314.  
  2315. ΓòÉΓòÉΓòÉ 5.2.6. Using a Variable Monitor within a Template Function ΓòÉΓòÉΓòÉ
  2316.  
  2317. This step teaches you how to monitor a variable within a template function. 
  2318.  
  2319.   1. From the Source window, double-click on the e variable on line 6. A 
  2320.      Program Monitor action window is opened for the e variable. 
  2321.  
  2322.      Note:  If you have a qualified variable name, such as one of the 
  2323.      following: 
  2324.  
  2325.                abc::xyz
  2326.                a.b
  2327.                a[5]
  2328.  
  2329.      you will need to highlight the specific variable name and then 
  2330.      double-click on it.  The highlighted variable is the on that is used. 
  2331.  
  2332.      After you double-click on the e variable, the Select Function for 
  2333.      Expression action window is displayed, showing a list of template 
  2334.      functions. 
  2335.  
  2336.   2. Select the following entry: 
  2337.  
  2338.                outer<int,int>::hello(int)
  2339.  
  2340.   3. Select the OK push button. 
  2341.  
  2342.      The Program Monitor action window for e appears with the value Not 
  2343.      Allocated. 
  2344.  
  2345.   4. Close the Program Monitor window. 
  2346.  
  2347.  
  2348. ΓòÉΓòÉΓòÉ 5.2.7. Using Where to Find the Current Line ΓòÉΓòÉΓòÉ
  2349.  
  2350. You can run the program from the beginning of the NESTTPL.CPP source file, or 
  2351. you can go back to the current line and start it from there. 
  2352.  
  2353.   1. To find the current execution point in the thread, select Where from the 
  2354.      File menu in the Source window.  The current line is highlighted. 
  2355.  
  2356.   2. Run the program by selecting the Run button in the title bar. 
  2357.  
  2358.      The breakpoint is encountered at line 3 in the NESTTPL.CPP include file. 
  2359.      This line is highlighted. 
  2360.  
  2361.  
  2362. ΓòÉΓòÉΓòÉ 5.2.8. Looking at the Stack ΓòÉΓòÉΓòÉ
  2363.  
  2364. To verify that the correct breakpoint was encountered: 
  2365.  
  2366.      Select the Stack button in the title bar of the Source window. 
  2367.  
  2368.  The top item should be the outer<int,int>::hello(int) function.  The 
  2369.  breakpoint was encountered at line 3 in NESTTPL.CPP. 
  2370.  
  2371.      Select the Run button twice. 
  2372.  
  2373.  The breakpoint on line 9 is encountered in file NESTTPL.C. You are now at the 
  2374.  outer<int,char*>::inner::hello(int,char*) instance of the template function 
  2375.  shown at the top of the Stack window. 
  2376.  
  2377.      Now close the Stack window. 
  2378.  
  2379.  
  2380. ΓòÉΓòÉΓòÉ 5.2.9. Viewing Template Functions in the Mixed Window ΓòÉΓòÉΓòÉ
  2381.  
  2382. To see how the different template functions display in the assembler code, 
  2383. change to the Mixed window: 
  2384.  
  2385.      Select the View button in the title bar until the Mixed window is 
  2386.      displayed. 
  2387.  
  2388.  In the Mixed window you can see how the different template functions are 
  2389.  implemented in machine code.  The source line for each template function is 
  2390.  listed with the disassembled code beneath it.  Then, the source is duplicated, 
  2391.  along with the associated disassembled code for each instance of the template. 
  2392.  
  2393.      To change the view to Source window, select the View button in the title 
  2394.      bar until the Source window is displayed. 
  2395.  
  2396.  
  2397. ΓòÉΓòÉΓòÉ 5.3. Handling Exceptions ΓòÉΓòÉΓòÉ
  2398.  
  2399. This step demonstrates how the debugger deals with exception handling and shows 
  2400. you how to fix the error in the NEST program: 
  2401.  
  2402.   1. Select the NEST.CPP tab at the bottom of the notebook. 
  2403.  
  2404.      Notice that the NEST program at line 22 attempts to divide by zero. 
  2405.  
  2406.   2. Select the Run button to continue the running of the NEST program. 
  2407.  
  2408.   3. Select Run until it causes the program to run to the error. 
  2409.  
  2410.      The OS/2 Application Exception Action window appears. indicating that the 
  2411.      exception that occurred was an integer divide by zero error. 
  2412.  
  2413.      You can select from the following options: 
  2414.  
  2415.     o Examine/Retry 
  2416.     o Step Exception 
  2417.     o Run Exception 
  2418.  
  2419.   4. Select Examine/Retry to examine the source code that caused the exception. 
  2420.  
  2421.      The Source window is displays at the line containing the error. 
  2422.  
  2423.   5. To continue past the error, change the value of j to a nonzero value, so 
  2424.      that a divide-by-zero error does not occur. 
  2425.  
  2426.      To do this, double-click on the variable j in the Source window, to bring 
  2427.      up the Program Monitor action window. Change the value for j to another 
  2428.      value, such as 1. 
  2429.  
  2430.   6. Continue to step or run.  The program terminates normally. 
  2431.  
  2432.  
  2433. ΓòÉΓòÉΓòÉ 5.3.1. Summary of Lesson 3 ΓòÉΓòÉΓòÉ
  2434.  
  2435. This concludes lesson 3 of the tutorial. 
  2436.  
  2437. You have learned how to: 
  2438.  
  2439.  o Set breakpoints in template functions and indicate which instance of a 
  2440.    template function to set the breakpoint at. 
  2441.  
  2442.  o Display the stack to see which instance of a template function is being 
  2443.    executed. 
  2444.  
  2445.  o View the assembler instructions for the different instances of a template 
  2446.    function in the Mixed window. 
  2447.  
  2448.  This concludes the portion of the debugger tutorial that deals with debugging 
  2449.  tasks specific to C++ programming. 
  2450.  
  2451.  
  2452. ΓòÉΓòÉΓòÉ 6. Customizing a Debugger Session ΓòÉΓòÉΓòÉ
  2453.  
  2454. This section shows you how to set the debugger session settings to customize 
  2455. your debugger sessions.  You will learn how to: 
  2456.  
  2457.  o Set the default data representation 
  2458.  
  2459.  o Set the animation rate 
  2460.  
  2461.  o Set initial window placement and size 
  2462.  
  2463.  o Select the font for the source window. 
  2464.  
  2465.  
  2466. ΓòÉΓòÉΓòÉ 6.1. Setting Default Data Representation ΓòÉΓòÉΓòÉ
  2467.  
  2468. You can change the way certain types of variables are displayed in the monitor 
  2469. windows.  For example, you might want integers to display as hexadecimal. 
  2470.  
  2471. To do this: 
  2472.  
  2473.   1. From the Options menu, select Session settings  Default data 
  2474.      representation  C. The Default Representation window is displayed. 
  2475.  
  2476.   2. From Integer, select Hexadecimal. 
  2477.  
  2478.   3. Select the OK push button. 
  2479.  
  2480.  Default data representation changes only take effect for variables put in 
  2481.  monitor windows after the default is changed. 
  2482.  
  2483.  
  2484. ΓòÉΓòÉΓòÉ 6.2. Set the Animation Rate ΓòÉΓòÉΓòÉ
  2485.  
  2486. When you select Animate, either from the Run menu, or by pressing the A key, 
  2487. the debugger automatically steps over commands to execute your code one line at 
  2488. a time.  The animation rate specifies the rate at which the debugger 
  2489. automatically executes the commands.  To change the animation rate: 
  2490.  
  2491.   1. From the Options menu, select Session settings  Animation rate. 
  2492.  
  2493.      Note:  You can select this from the Source view window or the Debug 
  2494.      Session Control window. 
  2495.  
  2496.   2. Set the speed of execution by positioning the slider bar between the slow 
  2497.      and fast limits, or by entering a number in the entry field.  For example, 
  2498.      you might move the slider bar to the right or select the arrow on the 
  2499.      right until 16 is displayed in the entry field. 
  2500.  
  2501.      The numbers 1 to 20 are for reference purposes only.  The true speed of 
  2502.      animation depends on the processor speed, the number of open windows, and 
  2503.      the type of instruction being executed. 
  2504.  
  2505.   3. Select the Save session settings check box to save your selection for the 
  2506.      next debugging session. 
  2507.  
  2508.   4. Select the OK push button to continue. 
  2509.  
  2510.  To stop the animation, select Animate using the A key or pressing the SysRq 
  2511.  key. 
  2512.  
  2513.  
  2514. ΓòÉΓòÉΓòÉ 6.3. Set Initial Window Placement and Size ΓòÉΓòÉΓòÉ
  2515.  
  2516. The debugger has an Initial Window Placement action window that you can use to 
  2517. set the position and size of the debugger windows when they are first opened. 
  2518. The windows that you can edit in this way are: 
  2519.  
  2520.  o Debug Session Control 
  2521.  o Program view windows (Source, Disassembly or Mixed) 
  2522.  o Local Variables 
  2523.  o Parent and Z-Order Tree 
  2524.  o Program Monitor 
  2525.  o Register 
  2526.  o Stack 
  2527.  o Storage 
  2528.  o Window Analysis 
  2529.  o Window Characteristics 
  2530.  
  2531.  Using the Initial Window Placement action window, you can change the initial 
  2532.  opening position and initial opening size window characteristics. 
  2533.  
  2534.  
  2535. ΓòÉΓòÉΓòÉ 6.3.1. Changing the Initial Opening Positions ΓòÉΓòÉΓòÉ
  2536.  
  2537. To change the opening position of the Stack window: 
  2538.  
  2539.   1. From the Options menu in the Source window, select Session settings  
  2540.      Initial window placement. The Initial Window Placement action window is 
  2541.      displayed. 
  2542.  
  2543.      The debugger windows are displayed under the Window group heading.  The 
  2544.      rectangular area inside the Window box represents your screen.  The Width 
  2545.      and Height of the representational screen are shown under the Screen size 
  2546.      group heading. The lower left-hand corner of the screen has coordinates 
  2547.      0,0. 
  2548.  
  2549.      Note:  The full title of each window may not be displayed. 
  2550.  
  2551.   2. Under the Window group heading, select the Stack window with your mouse. 
  2552.      It may be hidden behind other windows, so you may have look for it.  The 
  2553.      entry field at the bottom of the Window area is updated with the title 
  2554.      Stack. 
  2555.  
  2556.   3. Placing the mouse on the title bar to select the Stack window, move the 
  2557.      window horizontally until it is almost touching the Register window. 
  2558.  
  2559.      The new X (horizontal axis) and Y (vertical axis) coordinate data are 
  2560.      displayed under the Placement Values group heading. 
  2561.  
  2562.  
  2563. ΓòÉΓòÉΓòÉ 6.3.2. Changing the Initial Opening Sizes ΓòÉΓòÉΓòÉ
  2564.  
  2565. To change the opening size of the Register window: 
  2566.  
  2567.   1. In the Initial window placement window, select the Register window under 
  2568.      the Window group heading. 
  2569.  
  2570.      The list box at the bottom of the Window entry field is updated with the 
  2571.      title Register. 
  2572.  
  2573.   2. Placing the mouse pointer on the right edge of the Register window (a 
  2574.      double arrow is shown when it is positioned correctly), drag and release 
  2575.      the edge of the window until the full title is displayed. 
  2576.  
  2577.      The new Height and Width values are displayed under the Placement Values 
  2578.      group heading. 
  2579.  
  2580.   3. Select Save session setting to save your selections for the next debugging 
  2581.      session.  This is the default. 
  2582.  
  2583.   4. Select the OK push button to select the information that you have entered 
  2584.      and to close the action window. 
  2585.  
  2586.  The initial opening positions and sizes of the windows you inidcated are set. 
  2587.  The new size and position are applied the next time you open the affected 
  2588.  window. 
  2589.  
  2590.  
  2591. ΓòÉΓòÉΓòÉ 6.4. Selecting the Font for the Source Window ΓòÉΓòÉΓòÉ
  2592.  
  2593. You can change the font that is used for the text displayed in a debugger 
  2594. window. 
  2595.  
  2596. To select the new font: 
  2597.  
  2598.   1. From the Options menu in the Source window, select Fonts. 
  2599.  
  2600.      The Font Selection window displays the font that is currently being used 
  2601.      in that window and allows you to make changes. 
  2602.  
  2603.   2. If you would like to change the font, in the Name scroll box, highlight a 
  2604.      font (for example, the Courier font).  In the Style scroll box, highlight 
  2605.      a font style (such as bold, italic, or normal).  A sample of the font is 
  2606.      displayed in the Sample field.  The default is Courier, font size 10. 
  2607.  
  2608.      Note:  Your system might use different fonts. 
  2609.  
  2610.   3. Select the OK push button to select the information that you entered and 
  2611.      close the Font window. 
  2612.  
  2613.      If you made a change, the text in the Source window is now displayed in 
  2614.      the new font. 
  2615.  
  2616.  
  2617. ΓòÉΓòÉΓòÉ 7. The End ΓòÉΓòÉΓòÉ
  2618.  
  2619. You have now reached the end of this tutorial, having learned all the major 
  2620. functions and features of the IBM C/C++ Debugger. 
  2621.  
  2622. Experiment with other functions of the debugger using the sample programs or a 
  2623. program of your own.  Use the on-line help to obtain more information about a 
  2624. debugger feature. 
  2625.  
  2626.  
  2627. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  2628.  
  2629. Trademark of IBM Corporation 
  2630.  
  2631.  
  2632. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  2633.  
  2634. Session settings contain the profile information for your debugger session that 
  2635. are set up when you choose Options  Session Settings from the Debug Session 
  2636. Control window or any of the program view windows. 
  2637.  
  2638. This includes information such as: 
  2639.  
  2640.  o Source window properties 
  2641.  o Monitor properties 
  2642.  o PM debugging mode 
  2643.  o Default data representation 
  2644.  o Animation rate 
  2645.  o Initial window placement. 
  2646.  
  2647.  
  2648. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  2649.  
  2650. The step commands execute a single line of code at a time. 
  2651.  
  2652.  
  2653. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  2654.  
  2655. Restart information can be stored for each program that you debug. 
  2656.  
  2657. This information is used to restore all the windows and breakpoints as they 
  2658. were during a previous debugging session on the same program when the debugger 
  2659. starts up. 
  2660.  
  2661. One restart information file is saved per program. For example, the restart 
  2662. information is stored in the PROG.@2R file for PROG program. 
  2663.  
  2664. For executable files and pre-loaded DLLs, only information relating to the 
  2665. primary thread is restored. 
  2666.  
  2667.  
  2668. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  2669.  
  2670. If you are starting the debugger for the first time, the Change Location action 
  2671. window is displayed, prompting you to type the location where the session 
  2672. settings and restart information files should be stored. 
  2673.  
  2674. The session settings information file, which is called IPMD.@2S, is created and 
  2675. stored in the directory that you specified. The Change Location action window 
  2676. is displayed only once. It reappears if the IPMD.@2S file is erased. 
  2677.  
  2678.  
  2679. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  2680.  
  2681. There are two wait states in the debugger: 
  2682.  
  2683.  o When the debugger is busy doing something, it displays a clock icon.  This 
  2684.    icon will disappear when the wait is over (for example, loading a program 
  2685.    into the debugger). 
  2686.  
  2687.  o When your program is running, the debugger displays a clock icon with a 
  2688.    rectangle behind it. This means that your program is waiting for input. If 
  2689.    so, select your program window (if necessary) and provide it with the input 
  2690.    it needs. 
  2691.