home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / info / kdebug.doc < prev    next >
Text File  |  1992-09-14  |  187KB  |  5,390 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.                                                                    IBM OS/2 2.0
  14.  
  15.                                                                 KERNEL DEBUGGER
  16.  
  17.                                                               PRELIMINARY DRAFT
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.                                                              September 14, 1992
  26.  
  27.  
  28.                                                      Issued by:  David E. Reich
  29.  
  30.  
  31.                                                                  IBM Boca Raton
  32.                                                               Tie line 982-0329
  33.                                                              DREICH at BCRVMPC1
  34.  
  35.                                        Prepared by: David E. Reich & Edd Doutre
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.   +--- NOTE -----------------------------------------------------------+
  74.   |                                                                    |
  75.   | Before using this information and the product it supports, be sure |
  76.   | to read the general information under "Notices" on page v.         |
  77.   |                                                                    |
  78.   +--------------------------------------------------------------------+
  79.  
  80.  
  81.  
  82.   FIRST EDITION (APRIL 1992)
  83.  
  84.   THE FOLLOWING PARAGRAPH DOES NOT APPLY TO THE UNITED KINGDOM OR ANY
  85.   COUNTRY WHERE SUCH PROVISIONS ARE INCONSISTENT WITH LOCAL LAW:  INTER-
  86.   NATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS PUBLICATION "AS
  87.   IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  88.   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  89.   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  Some states do
  90.   not allow disclaimer of express or implied warranties in certain
  91.   transactions, therefore, this statement may not apply to you.
  92.  
  93.   This publication could include technical inaccuracies or typographical
  94.   errors.  Changes are periodically made to the information herein;
  95.   these changes will be incorporated in new editions of the publication.
  96.   IBM may make improvements and/or changes in the product(s) and/or the
  97.   program(s) described in this publication at any time.
  98.  
  99.   It is possible that this publication may contain reference to, or
  100.   information about, IBM products (machines and programs), programming,
  101.   or services that are not announced in your country.  Such references
  102.   or information must not be construed to mean that IBM intends to
  103.   announce such IBM products, programming, or services in your country.
  104.  
  105.   Requests for technical information about IBM products should be made
  106.   to your IBM Authorized Dealer or your IBM Marketing Representative.
  107.  
  108.   IBM may have patents or pending patent applications covering subject
  109.   matter in this document.  The furnishing of this document does not
  110.   give you any license to these patents.  You can send license
  111.   inquiries, in writing, to the IBM Director of Commercial Relations,
  112.   IBM Corporation, Purchase, NY 10577.
  113.  
  114.   COPYRIGHT LICENSE:  This publication contains printed sample applica-
  115.   tion programs in source language, which illustrate OS/2 programming
  116.   techniques.  You may copy and distribute these sample programs in any
  117.   form without payment to IBM, for the purposes of developing, using,
  118.   marketing or distributing application programs conforming to the OS/2
  119.   application programming interface.
  120.  
  121.   Each copy of any portion of these sample programs or any derivative
  122.   work, which is distributed to others, must include a copyright notice
  123.   as follows:  "(C) (your company name) (year) All Rights Reserved."
  124.  
  125.   (C) COPYRIGHT INTERNATIONAL BUSINESS MACHINES CORPORATION 1992.  ALL
  126.   RIGHTS RESERVED.
  127.   Note to U.S. Government Users -- Documentation related to restricted
  128.   rights -- Use, duplication or disclosure is subject to restrictions
  129.   set forth in GSA ADP Schedule Contract with IBM Corp.
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.   CONTENTS
  140.   ________
  141.  
  142.  
  143.  
  144.  
  145.  
  146.                       INTRODUCTION   1
  147.                         Conventions and Symbols   2
  148.                         Entering the Debugger   2
  149.                         Expressions   3
  150.                         Numbers   7
  151.                         Strings   8
  152.                         Symbol Files   8
  153.  
  154.                       TIPS FOR USING THE KERNEL DEBUGGER   11
  155.  
  156.                       KERNEL DEBUGGER COMMANDS   15
  157.                       Breakpoint Commands   15
  158.                         BREAKPOINT (BP)   15
  159.                         COMPARE   17
  160.                         DUMP   17
  161.                         ENTER   20
  162.                         FILL   21
  163.                         GO   21
  164.                         Help/Print Expression   22
  165.                         HEX   22
  166.                         INPUT   22
  167.                         List Near Symbol   22
  168.                         List Groups   23
  169.                         List Maps   23
  170.                         List Absolute Symbols   23
  171.                         List Symbols   23
  172.                         Add/Remove Active Map   23
  173.                         Conditional Execution   23
  174.                         Stack Trace   24
  175.                         MOVE   24
  176.                         OUTPUT   25
  177.                         PTRACE   25
  178.                         REGISTER   26
  179.                         SEARCH   28
  180.                         TRACE   28
  181.                         UNASSEMBLE   29
  182.                         Interrupt and Trap Vector   30
  183.                         Debugger Option   31
  184.                         Default Command Lines   32
  185.                       External Debugger Commands   33
  186.                         Help   33
  187.                         COM Port Baud Rate   33
  188.                         Dump ABIOS Common Data Area   33
  189.                         Dump OS/2 Data Structures   34
  190.                         Swap in TSD or Page   34
  191.                         User Stack Trace   35
  192.                         Print MTE Segment Table   35
  193.                         Memory Arena Record Dump   36
  194.  
  195.  
  196.                                                                   Contents  iii
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.                         Memory Context Record Dump   37
  207.                         Memory Alias Record Dump   37
  208.                         Memory Object Record Dump   38
  209.                         Memory Page Frame Dump   39
  210.                         Memory Virtual Page Structure Dump   40
  211.                         Print Process Status   40
  212.                         User Register   41
  213.                         REBOOT   41
  214.                         Task Context Change   41
  215.                         RAS Trace Buffer Print   42
  216.  
  217.                       ADVANCED KERNEL DEBUGGER TECHNIQUES   43
  218.                         Setting Useful Breakpoints   43
  219.                         Debugging Kernel Device Drivers   52
  220.                         Debugging VM Start Sessions   53
  221.                         Debugging CMD.EXE   54
  222.  
  223.                       SETUP FOR REMOTE DEBUGGING   55
  224.                       Items Required to Set Up a System for Remote
  225.                        Debugging   55
  226.                         Target System   55
  227.                         IBM 5853 Modem   56
  228.                         Modem Data Cable   56
  229.                         Analog Dial-in Telephone Line   57
  230.                         Communications Software   57
  231.                       The Configuration Process   57
  232.                         Limitations of this Setup   60
  233.                         Problem Determination   60
  234.  
  235.                       APPENDIX A.  SAMPLE DEBUGGING SESSION   63
  236.  
  237.                       INDEX   69
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.   iv  OS/2 Kernel Debugger
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.   NOTICES
  273.   _______
  274.  
  275.  
  276.  
  277.  
  278.  
  279.                       References in this publication to IBM products, programs,
  280.                       or services do not imply that IBM intends to make these
  281.                       available in all countries in which IBM operates.  Any
  282.                       reference to an IBM product, program, or service is not
  283.                       intended to state or imply that only IBM's product,
  284.                       program, or service may be used.  Any functionally equiv-
  285.                       alent product, program, or service that does not infringe
  286.                       any of IBM's intellectual property rights or other
  287.                       legally protectible rights may be used instead of the IBM
  288.                       product, program, or service.  Evaluation and verifica-
  289.                       tion of operation in conjunction with other products,
  290.                       programs, or services, except those expressly designated
  291.                       by IBM, are the user's responsibility.
  292.  
  293.  
  294.   TRADEMARKS
  295.   __________
  296.  
  297.                       The following terms, denoted by an asterisk (*) in this
  298.                       publication, are trademarks of the IBM Corporation in the
  299.                       United States or other countries, or both:
  300.  
  301.                           IBM
  302.                           Operating System/2
  303.                           OS/2
  304.                           PS/2
  305.  
  306.                       The following terms, denoted by a double asterisk (**) in
  307.                       this publication, are trademarks of another company as
  308.                       follows:
  309.  
  310.                       Hayes               Hayes Microcomputer Products, Inc.
  311.                       Intel               Intel Corporation
  312.                       80286               Intel Corporation
  313.                       80287               Intel Corporation
  314.                       80386               Intel Corporation
  315.                       Windows             Microsoft Corporation
  316.  
  317.  
  318.   DOUBLE-BYTE CHARACTER SET (DBCS)
  319.   ________________________________
  320.  
  321.                       Throughout this publication, you will see references to
  322.                       specific values for character strings.  The values are
  323.                       for the single-byte character set (SBCS).  If you use the
  324.                       double-byte character set (DBCS), note that one DBCS
  325.                       character equals two SBCS characters.
  326.  
  327.  
  328.  
  329.  
  330.  
  331.                                                                      Notices  v
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.   vi  OS/2 Kernel Debugger
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.   PREFACE
  408.   _______
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.   ABOUT THIS BOOK
  417.   _______________
  418.  
  419.                       This document describes the use of the kernel debugger
  420.                       functions in the OS/2 2.0 system.
  421.  
  422.                       This release of the OS/2 2.0 toolkit contains a copy of
  423.                       the OS/2 2.0 debugging kernel.  It is included to assist
  424.                       you in debugging your applications and drivers until
  425.                       higher-level debuggers such as IPMD can provide adequate
  426.                       debugging functions in complex situations.
  427.  
  428.                       The kernel debugger is a low-level debugger oriented
  429.                       toward system and device-driver debugging.
  430.  
  431.                       The use of this kernel is supported as an aid in debug-
  432.                       ging your software.  We offer support for the installa-
  433.                       tion and use of the debugging kernel and its commands and
  434.                       syntax.
  435.  
  436.  
  437.   ORGANIZATION OF THIS BOOK
  438.   _________________________
  439.  
  440.                       "INTRODUCTION" ON PAGE 1
  441.                                 This chapter contains information about:
  442.  
  443.                                 o   Conventions and Symbols
  444.                                 o   Entering the Debugger
  445.                                 o   Expressions
  446.                                 o   Numbers
  447.                                 o   Strings
  448.                                 o   Symbol Files
  449.  
  450.                       "TIPS FOR USING THE KERNEL DEBUGGER" ON PAGE 11
  451.                                 This chapter contains tips for using the kernel
  452.                                 debugger.
  453.  
  454.                       "KERNEL DEBUGGER COMMANDS" ON PAGE 15
  455.                                 This chapter describes the commands of the
  456.                                 kernel debugger.
  457.  
  458.                       "ADVANCED KERNEL DEBUGGER TECHNIQUES" ON PAGE 43
  459.                                 This chapter describes some advanced techniques
  460.                                 for using the kernel debugger.
  461.  
  462.  
  463.  
  464.  
  465.  
  466.                                                                    Preface  vii
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.                       "SETUP FOR REMOTE DEBUGGING" ON PAGE 55
  477.                                 This chapter describes how to set up a system
  478.                                 for remote debugging.
  479.  
  480.                       APPENDIX A, "SAMPLE DEBUGGING SESSION" ON PAGE 63
  481.                                 This appendix shows a sample debugging session.
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.   viii  OS/2 Kernel Debugger
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.   INTRODUCTION
  543.   ____________
  544.  
  545.  
  546.  
  547.  
  548.  
  549.                       The kernel debugger is derived from the DEBUG and SYMDEB
  550.                       debuggers, with enhancements to handle both real-mode and
  551.                       protected-mode operation.  Most of the commands and
  552.                       structure of this debugger are the same as for DEBUG and
  553.                       SYMDEB.  This document describes most of the kernel
  554.                       debugger's commands and new features.
  555.  
  556.                       The kernel debugger is actually a version of the
  557.                       OS/2(*) 2.0 kernel that has a user interface included in
  558.                       the kernel itself.  This interface always gets its input
  559.                       from an asynchronous port, usually COM2 or COM1, and
  560.                       always prints its output to the same asynchronous port.
  561.  
  562.                       The debugger and user interface actually amount to about
  563.                       80KB (where KB equals 1024 bytes) of code and data.
  564.                       However, there are two versions of the debug kernel - the
  565.                       'AllStrict' kernel and the 'HStrict' kernel.
  566.  
  567.                       The 'HStrict' kernel is about 795KB, and is simply the
  568.                       retail kernel with the debugger interface added.  The
  569.                       retail kernel is about 710KB.
  570.  
  571.                       The 'AllStrict' kernel is about 965KB.  The additional
  572.                       170KB is error checking code and messages to catch errors
  573.                       and cause an IPE (Internal Processing Error) when a
  574.                       retail or HStrict kernel would have let the error pass,
  575.                       or would have returned it to the application program.
  576.                       This results in a very "picky" operating system, from an
  577.                       applications point of view, but it is important to catch
  578.                       these types of problems early and provide error recovery
  579.                       code in the retail versions.  All this error checking
  580.                       makes it much easier to find and fix problems when the
  581.                       testers are running the 'AllStrict' kernel.
  582.  
  583.                       The debugger normally uses COM2 for its input and output,
  584.                       but if no COM2 exists, it looks for a COM1 port.  If
  585.                       neither COM1 or COM2 exists, it looks for any other COM
  586.                       port in the ROM data area (40:0).  A three-wire null
  587.                       modem cable is all that is needed, with pins 2 and 3
  588.                       switched on one end of the cable.  A full null modem
  589.                       cable works as well.
  590.  
  591.                       An asynchronous modem can be used to set up a remote
  592.                       debugging session.  In a remote debugging session, you
  593.  
  594.   ---------------
  595.  
  596.   (*) Trademark of the IBM Corporation.
  597.  
  598.  
  599.                                                                 Introduction  1
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.                       call over a telephone line to the system that has the
  610.                       problem.  This allows you to solve problems at remote
  611.                       locations, using the kernel debugger.  For example, prob-
  612.                       lems in Germany, England, Spain, South America, and Iowa
  613.                       have been solved with remote debugging sessions.
  614.  
  615.                       See "Setup for Remote Debugging" on page 55 for more
  616.                       information about remote debugging.
  617.  
  618.  
  619.   CONVENTIONS AND SYMBOLS
  620.  
  621.                       Most commands are one or two characters, with one-
  622.                       character options.  The semicolon character (;) is the
  623.                       command separator, and the comma (,) or a blank is the
  624.                       operand separator.
  625.  
  626.                       When the syntax of the command is shown, the following
  627.                       conventions are used:
  628.  
  629.                       o   Arguments between square brackets ([ ]) are optional.
  630.  
  631.                       o   A horizontal bar (|) indicates that either argument
  632.                           is acceptable.
  633.  
  634.                       The definitions of some of the arguments used in the com-
  635.                       mands are as follows:
  636.  
  637.                            <range> = <addr> [<word>] | [<addr>] [L <word>]
  638.  
  639.                            <addr> = [& | #][<word>:]<word> | %<dword>
  640.  
  641.                            <list> = <byte>, <byte>, ... | "string"
  642.  
  643.                            <string> = "char" | 'char'
  644.  
  645.                            <dword>, <word>, <byte> = expressions that evaluate
  646.                           to the size indicated in the symbols <>.
  647.  
  648.  
  649.   ENTERING THE DEBUGGER
  650.  
  651.                       There are various ways to get into the debugger.  The
  652.                       first way is during initialization.  If the following
  653.                       keys are pressed at the debugger's console, the debugger
  654.                       is entered:
  655.  
  656.                       o   "r" - (lowercase r) enters the debugger at the begin-
  657.                           ning of system kernel initialization in real mode.
  658.                           This is very early in system initialization.
  659.  
  660.                       o   "p" - enters the debugger after we have gone into
  661.                           protected mode for the first time.  Symbols have not
  662.                           been loaded yet.
  663.  
  664.  
  665.   2  OS/2 Kernel Debugger
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.                       o   "<space-bar>" - enters the debugger after most of the
  676.                           kernel has been initialized.  Symbols for the system
  677.                           kernel have been loaded.
  678.  
  679.                       After initialization is complete, the debugger can be
  680.                       entered at any time by pressing Ctrl+C at the debugger's
  681.                       console.  The debugger is entered when and where the next
  682.                       timer tick is taken after the keys were pressed.
  683.  
  684.                       An NMI (non-maskable interrupt) switch allows you to
  685.                       break into the debugger even if interrupts are disabled.
  686.                       Pressing Ctrl+C does not allow this.
  687.  
  688.                       An "INT 3" in the kernel or in a program also causes the
  689.                       debugger to stop.
  690.  
  691.                       When a kernel panic occurs, a message is sent to both the
  692.                       screen and the debugger port.  Before sending the message
  693.                       to the screen, the screen is cleared and set to text
  694.                       mode.  This can be a problem if you need to see how far a
  695.                       test case got before crashing.  If you set the byte flag
  696.                       fDebugOnly to nonzero, the message goes to the debug port
  697.                       __________
  698.                       only, and the screen is left unchanged.
  699.  
  700.                       After symbols are loaded, an initialization file named
  701.                       KDB.INI is read and executed.  Any debugger command or
  702.                       list of debugger commands can be in the KDB.INI file.  A
  703.                       "G" command should be at the end of the commands unless
  704.                       you want the debugger to stop after the KDB.INI file is
  705.                       executed.
  706.  
  707.  
  708.   EXPRESSIONS
  709.  
  710.                       The expression evaluator has been enhanced to provide
  711.                       support for four types of addresses - real mode
  712.                       (&segment:offset), protected mode (#selector:offset),
  713.                       linear address (%dword) and physical address (%%dword).
  714.                       The symbols "&", "#", "%", and "%%" override the current
  715.                       address type, allowing selectors to be used in real mode,
  716.                       segments to be used in protected mode, and so on.  The
  717.                       "%" linear address and the "%%" physical address operator
  718.                       actually convert other address types to a linear or phys-
  719.                       ical address.  For example, %(#001F:0220) looks up
  720.                       selector 1F's linear address in the current LDT, and adds
  721.                       hex 0220 to it.  Linear and physical addresses are the
  722.                       same, unless paging is enabled on an 80386(**) processor.
  723.  
  724.                       o   ?  <expr> | "<string>"
  725.  
  726.  
  727.   ---------------
  728.  
  729.   (**) Trademark of the Intel Corporation.
  730.  
  731.  
  732.                                                                 Introduction  3
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742.                       This command evaluates the expression, and prints it in
  743.                       all the standard numerical bases, along with the ASCII
  744.                       character for the value and an address' physical address.
  745.                       It also prints an indication of whether the expression
  746.                       evaluated to TRUE (nonzero) or FALSE (zero).  It prints a
  747.                       string if the string is surrounded by single or double
  748.                       quotation marks.
  749.  
  750.                       #1F:02C0       Protected Mode address
  751.  
  752.                       &3450:1234     Real Mode address
  753.  
  754.                       %310230        Linear address
  755.  
  756.                       %%310230       Physical address
  757.  
  758.                       Addresses can be used in any mode.  In real mode, you can
  759.                       use protected mode addresses as long as there is an over-
  760.                       ride.  The default depends on the current debugger mode.
  761.  
  762.                       There are keywords that return the value of registers,
  763.                       breakpoints, and so on in expressions.  Here is a list of
  764.                       them:
  765.  
  766.                       o   AX, BX, CX, DX, SI, DI, BP, DS, ES, SS, CS, SP, IP -
  767.                           register values
  768.  
  769.                       o   FLG - value of the flags
  770.  
  771.                       o   GDTB - value of the GDT base as a physical address
  772.  
  773.                       o   GDTL - value of the GDT limit
  774.  
  775.                       o   IDTB - value of the IDT base as a physical address
  776.  
  777.                       o   IDTL - value of the IDT limit
  778.  
  779.                       o   TR, LDTR, MSW - value of the TR, LDTR, and MSW regis-
  780.                           ters
  781.  
  782.                       o   BR0, BR1,..., BR9 - the address at that breakpoint.
  783.  
  784.                           The 80386 keywords are (in addition to the above):
  785.  
  786.                       o   EAX, EBX, ECX, EDX, ESI, EDI, EBP, ESP, EIP -
  787.                           extended register values
  788.  
  789.                       o   FS, GS - segment registers
  790.  
  791.                       o   EFLG - value of extend flags
  792.  
  793.                       o   CR0, CR2, CR3 - control register values
  794.  
  795.                       o   DR0, DR1, DR2, DR3, DR6, DR7 - debug register values
  796.  
  797.  
  798.   4  OS/2 Kernel Debugger
  799.  
  800.  
  801.  
  802.  
  803.  
  804.  
  805.  
  806.  
  807.  
  808.                       o   TR6, TR7 - test register values.
  809.  
  810.                       These register names are searched for first, before the
  811.                       symbol table is searched.  The "@" character can override
  812.                       the register name lookup, and cause a search of the
  813.                       symbol table for the name.  The term "@ax" causes a
  814.                       search for a symbol called "ax", instead of evaluating to
  815.                       the register value.
  816.  
  817.                       The operators that can be used in expressions are docu-
  818.                       mented in the SYMDEB manual, except for the address oper-
  819.                       ators (&, #, %) and the new relational operators.  The
  820.                       precedence of the operators has been changed to be more
  821.                       like "C".
  822.  
  823.  
  824.   Operators in precedence order
  825.  
  826.                       1.  (  )
  827.  
  828.                       2.  |  :
  829.  
  830.                       3.  &  #  %  %%  -  !  NOT  SEG  OFF  BY  WO  DW  POI
  831.                           PORT  WPORT  (all unary operators)
  832.  
  833.                       4.  *  /  MOD
  834.  
  835.                       5.  +  -
  836.  
  837.                       6.  >  <  >=  <=
  838.  
  839.                       7.  ==   !=
  840.  
  841.                       8.  AND  XOR  OR
  842.  
  843.                       9.  &&  ||
  844.  
  845.  
  846.   Binary operator definitions
  847.  
  848.                       ( )           Parentheses, used to change order of evalu-
  849.                                     ation
  850.  
  851.                       :             Address binder, binds segment/selector and
  852.                                     offsets
  853.  
  854.                       *             Multiplication
  855.  
  856.                       /             Division
  857.  
  858.                       MOD           Modulo (remainder)
  859.  
  860.                       +             Addition
  861.  
  862.  
  863.  
  864.                                                                 Introduction  5
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.                       -             Subtraction
  875.  
  876.                       >             Greater than relational operator
  877.  
  878.                       <             Less than relational operator
  879.  
  880.                       >=            Greater than or equal to relational oper-
  881.                                     ator
  882.  
  883.                       <=            Less than or equal to relational operator
  884.  
  885.                       ==            Equal to operator
  886.  
  887.                       !=            Not equal to relational operator
  888.  
  889.                       AND           Bitwise AND
  890.  
  891.                       XOR           Bitwise exclusive OR
  892.  
  893.                       OR            Bitwise inclusive OR
  894.  
  895.                       &&            Logical AND
  896.  
  897.                       ||            Logical OR
  898.  
  899.  
  900.   Unary operator definitions
  901.  
  902.                       |             Task number/address operator
  903.  
  904.                       &             Address type is segment:offset
  905.  
  906.                       #             Address type is selector:offset
  907.  
  908.                       %             Address type is linear
  909.  
  910.                       %%            Address type is physical
  911.  
  912.                       -             Two's complement
  913.  
  914.                       !             Logical NOT operator
  915.  
  916.                       NOT           Bitwise one's complement
  917.  
  918.                       SEG           Returns the segment portion
  919.  
  920.                       OFF           Returns the offset portion
  921.  
  922.                       BY            1-byte value from the address
  923.  
  924.                       WO            2-byte value from the address
  925.  
  926.                       DW            4-byte value from the address
  927.  
  928.  
  929.  
  930.   6  OS/2 Kernel Debugger
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.                       POI           4-byte address from the address
  941.  
  942.                       PORT          1-byte value from an 8-bit I/O port
  943.  
  944.                       WPORT         2-byte value from a 16-bit I/O port
  945.  
  946.                       If two or more operators have the same precedence, the
  947.                       expression is evaluated from left to right, even for
  948.                       unary operators.  "C" evaluates unary operators from
  949.                       right to left, which is more intuitive and easier to use.
  950.                       Expressions such as "poi #60:133" must be written as
  951.                       "poi (#60:133)" because of the way the debugger handles
  952.                       unary operators.
  953.  
  954.                       Ranges are an address and either a length or an end.
  955.                       "4544:0 L5" is address (4544:0) and a length of 5
  956.                       objects.  If you are dumping words, 5 words are dumped.
  957.                       "#8:32 50" is a range of bytes from address "8:32" to and
  958.                       including "8:50".
  959.  
  960.                       NOTE:  On <ranges>, if the second address has a unary
  961.                       operator such as "&" or "#", then it must be separated by
  962.                       a comma from the first.  Parentheses work as well, for
  963.                       example:
  964.  
  965.                       >DB DS:40,%40000        Correct
  966.  
  967.                       >DB DS:40 (%40000)      Correct
  968.  
  969.                       >DB DS:40 %40000        Incorrect
  970.  
  971.                       This is because of the way the expression evaluator
  972.                       parses the input.
  973.  
  974.  
  975.   NUMBERS
  976.  
  977.                       The default base for numbers in the kernel debugger is 16
  978.                       (hexadecimal).  You can add a one-letter suffix to the
  979.                       digits of a number to indicate the base of the number, as
  980.                       shown in the following table.  The term "nnnnnn" repres-
  981.                       ents a number that consists of a variable number of
  982.                       digits.
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.                                                                 Introduction  7
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.                       +--------------+------------------+---------------------+
  1007.                       | Number       | Base             | Valid digits        |
  1008.                         ______         ____               ____________
  1009.                       +--------------+------------------+---------------------+
  1010.                       | nnnnnnY      | Binary           | 0 1                 |
  1011.                       +--------------+------------------+---------------------+
  1012.                       | nnnnnnO      | Octal            | 0 1 2 3 4 5 6 7     |
  1013.                       +--------------+------------------+---------------------+
  1014.                       | nnnnnnQ      | Octal            | 0 1 2 3 4 5 6 7     |
  1015.                       +--------------+------------------+---------------------+
  1016.                       | nnnnnnT      | Decimal          | 0 1 2 3 4 5 6 7 8 9 |
  1017.                       +--------------+------------------+---------------------+
  1018.                       | nnnnnnH      | Hexadecimal      | 0 1 2 3 4 5 6 7 8 9 |
  1019.                       |              |                  | A B C D E F         |
  1020.                       +--------------+------------------+---------------------+
  1021.  
  1022.  
  1023.   STRINGS
  1024.  
  1025.                       A string can be represented as follows:
  1026.  
  1027.                       o   'characters'
  1028.  
  1029.                       o   "characters"
  1030.  
  1031.                       A string represents a list of ASCII values.  It can be
  1032.                       any number of and combination of characters enclosed in
  1033.                       single (') or double (") quotation marks.  The starting
  1034.                       and ending quotation marks must be the same type.  If a
  1035.                       matching quotation mark appears inside the string, it
  1036.                       must be given twice to prevent the debugger from ending
  1037.                       the string too soon.
  1038.  
  1039.                       Examples:
  1040.  
  1041.                       o   'This is a string'
  1042.  
  1043.                       o   "This is a string"
  1044.  
  1045.                       o   'This ''string'' is okay'
  1046.  
  1047.                       o   "This ""string"" is okay"
  1048.  
  1049.  
  1050.   SYMBOL FILES
  1051.  
  1052.                       The kernel debugger supports symbolic debugging.  The
  1053.                       MAPSYM utility program converts a .MAP file to a .SYM
  1054.                       file.  When a symbol file (generated with MAPSYM) is
  1055.                       loaded by the operating system, the debugger can use
  1056.                       public symbols in the operating system, executable pro-
  1057.                       grams, dynamic link libraries, or any device driver as
  1058.                       part of an expression.  The disassembler and the BL
  1059.                       command also display addresses symbolically if the symbol
  1060.                       exists for the address.
  1061.  
  1062.  
  1063.   8  OS/2 Kernel Debugger
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.                       The debugger uses the MAPSYM format for the symbol file.
  1074.                       The statement "MAPSYM MAPFILE.MAP" generates the .SYM
  1075.                       file "MAPFILE.SYM".  The kernel's symbols must be on the
  1076.                       system boot drive in the root directory, in a file named
  1077.                       OS2KRNL.SYM.  For device drivers, the .SYM file must be
  1078.                       in the same directory as the device driver file with the
  1079.                       .SYM extension.
  1080.  
  1081.                       To load symbols for a program or module, the .SYM file
  1082.                       must be in the same directory as the .EXE or .DLL file,
  1083.                       and the symbols will be loaded automatically.
  1084.  
  1085.                       The file name of the .SYM file must match that of the
  1086.                       executable (program, device driver or DLL) it corresponds
  1087.                       to.
  1088.  
  1089.                       There can be more than one symbol file loaded at one
  1090.                       time, and more than one currently "active".  The "WA",
  1091.                       "WR" and "LM" commands control and list the currently
  1092.                       active map files.  The term "map file" refers to the .SYM
  1093.                       file generated by MAPSYM.  Each newly-loaded map file
  1094.                       starts in the active state.
  1095.  
  1096.                       The message "Symbols Linked (xxxxxxxx)" is printed when
  1097.                       there is a successful load of a symbol file.  The
  1098.                       "xxxxxxx" is the map name listed in the "LM" command.
  1099.                       The message "Symbols Unlinked (xxxxxxxxx)" is printed
  1100.                       when a program that has loaded symbols exits and the
  1101.                       symbol file is removed.
  1102.  
  1103.                       Symbols are case insensitive.  The "@" forces the string
  1104.                       to be looked up as a symbol rather than as a register
  1105.                       name.
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.                                                                 Introduction  9
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.   10  OS/2 Kernel Debugger
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.   TIPS FOR USING THE KERNEL DEBUGGER
  1206.   __________________________________
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.                       The kernel debugger is a compiled part of the kernel.
  1213.                       Connect a terminal to communications port 2 (COM2) to
  1214.                       receive output from the kernel debugger.  To interrupt
  1215.                       the kernel debugger at any time, press Control and C
  1216.                       (Ctrl+C) on the terminal.
  1217.  
  1218.                       For more detailed information about these commands, see
  1219.                       "Kernel Debugger Commands" on page 15.
  1220.  
  1221.                       o    ?
  1222.  
  1223.                       This command gets you a help screen, and '.?' gets you a
  1224.                       help screen for the extended commands.
  1225.  
  1226.                       o    .P
  1227.  
  1228.                       This command displays all of the processes running in the
  1229.                       system.  The left-hand column of this display shows the
  1230.                       'slot number', which is important for the '.ss' command.
  1231.  
  1232.                       When you set a breakpoint in an application, the current
  1233.                       debugger 'context' must be changed to that process.  For
  1234.                       example, if you press Ctrl+C and you interrupt while
  1235.                       'BAR.EXE' is executing, but you want to set a breakpoint
  1236.                       in 'FOO.EXE', you must change the debugger context to
  1237.                       'FOO.EXE'.
  1238.  
  1239.                       o    .SS [slot number]
  1240.  
  1241.                       Type '.p', find out the slot number of 'FOO.EXE', and
  1242.                       type '.ss [slot number]'.  Now you can set breakpoints in
  1243.                       'FOO.EXE'.  Since .DLLs have no 'process' associated with
  1244.                       them, in order to set a breakpoint in a .DLL you need to
  1245.                       be in the context of an application that is dynamically
  1246.                       linked to that .DLL.
  1247.  
  1248.                       o    BP [addr]
  1249.  
  1250.                       This sets a break point at the address [addr].  [addr]
  1251.                       can be symbolic or numerical.  For 32-bit applications,
  1252.                       this is a 32-bit address.  For 16-bit applications, this
  1253.                       is a 16-bit address.
  1254.  
  1255.                       o   BC [bp number]
  1256.  
  1257.                       o   BD [bp number]
  1258.  
  1259.                       o   BC *
  1260.  
  1261.  
  1262.                                          Tips for Using the Kernel Debugger  11
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.  
  1270.  
  1271.  
  1272.                       o   BD *
  1273.  
  1274.                       'BC [bp number]' clears a breakpoint, while 'BD' disables
  1275.                       it.  'BC *' clears all breakpoints, while 'BD *' disables
  1276.                       all breakpoints.
  1277.  
  1278.                       o   DA [addr]
  1279.  
  1280.                       o   DB [addr]
  1281.  
  1282.                       o   DW [addr]
  1283.  
  1284.                       o   DD [addr]
  1285.  
  1286.                       These stand for 'dump ASCII', 'dump byte', 'dump word'
  1287.                       and 'dump doubleword', respectively.  These commands
  1288.                       display memory starting at address [addr].  'DW [addr] L
  1289.                       20' displays hex 20 words starting at [addr].
  1290.  
  1291.                       o    E [addr]
  1292.  
  1293.                       This allows you to edit memory (change memory contents)
  1294.                       at [addr].
  1295.  
  1296.                       o    K
  1297.  
  1298.                       This gives a stack-frame backtrace of the current appli-
  1299.                       cation (even at ring 0).
  1300.  
  1301.                       o    .K [slot number]
  1302.  
  1303.                       This gives a stack-frame backtrace of the thread in this
  1304.                       slot.  If you are in ring 0, this causes a ring-3 back-
  1305.                       trace.
  1306.  
  1307.                       o    DD SS:ESP
  1308.  
  1309.                       This dumps the stack data at the current top of the
  1310.                       stack.  'ESP' always points to the last thing pushed onto
  1311.                       the stack.
  1312.  
  1313.                       o    DD SS:EBP
  1314.  
  1315.                       This is what links 'C' stack-frames together at any time.
  1316.                       The 'EBP' register points on the stack to where the old
  1317.                       'EBP' is saved.  After 'EBP' on the stack, you get the
  1318.                       return address and then the parameters passed to the
  1319.                       function that is currently executing.  References to
  1320.                       [EBP+n] refer to passed parameters, while references to
  1321.                       [EBP-n] refer to local variables.
  1322.  
  1323.                       o    G
  1324.  
  1325.                       This means 'go' or execute.
  1326.  
  1327.  
  1328.   12  OS/2 Kernel Debugger
  1329.  
  1330.  
  1331.  
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.                       o    R
  1339.  
  1340.                       This dumps the register set.  To set a register, type 'r
  1341.                       [reg] = value'.  For example, 'r EAX = 6' puts 6 into
  1342.                       register EAX.  To execute some code over again or jump
  1343.                       ahead in code, reset the instruction pointer by typing 'r
  1344.                       EIP=[addr]'.
  1345.  
  1346.                       o    P
  1347.  
  1348.                       This process-steps through the code.  This uses the "INT
  1349.                       3" type of stepping.  This steps over function calls.
  1350.                                                        ____
  1351.  
  1352.                       NOTE:  If a function exits to an address other than the
  1353.                       return address (where the "INT 3" is waiting), you may
  1354.                       get unexpected results.  Also watch out for conditional
  1355.                       jumps, loops, and reps.
  1356.  
  1357.                       o    T
  1358.  
  1359.                       This single-steps through the code.  This does not use
  1360.                       the "INT 3" type of stepping as 'p' does, but actually
  1361.                       steps into any function calls.
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.                                          Tips for Using the Kernel Debugger  13
  1396.  
  1397.  
  1398.  
  1399.  
  1400.  
  1401.  
  1402.  
  1403.  
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409.  
  1410.  
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.  
  1460.  
  1461.   14  OS/2 Kernel Debugger
  1462.  
  1463.  
  1464.  
  1465.  
  1466.  
  1467.  
  1468.  
  1469.  
  1470.  
  1471.   KERNEL DEBUGGER COMMANDS
  1472.   ________________________
  1473.  
  1474.  
  1475.  
  1476.  
  1477.  
  1478.                       There are many kernel debugger commands. These can
  1479.                       control execution of the system under test.  This chapter
  1480.                       describes these commands.
  1481.  
  1482.  
  1483.   BREAKPOINT COMMANDS
  1484.   ___________________
  1485.  
  1486.                       These commands are executed when a breakpoint is hit.
  1487.  
  1488.  
  1489.   BREAKPOINT (BP)
  1490.  
  1491.                       There are two kinds of breakpoints in the kernel
  1492.                       debugger: temporary (sometimes called GO breakpoints) and
  1493.                       sticky.  Temporary breakpoints are set when the GO
  1494.                       command is executed, and go away when the debugger is
  1495.                       entered again for any reason (hitting a GO or sticky
  1496.                       breakpoint, a trap or fault, and so on).  Sticky break-
  1497.                       points are created, removed, and disabled with the com-
  1498.                       mands listed below.
  1499.  
  1500.                       If you set a breakpoint in an LDT segment when a thread
  1501.                       other than thread 1 is running, that breakpoint will be
  1502.                       moved to thread 1 when the current thread ends (so that
  1503.                       it can still be addressed).  When thread 1 ends, the
  1504.                       breakpoint will be disabled, and its address marked as
  1505.                       invalid.  When that task slot is reused, the breakpoint
  1506.                       can be enabled again, but it is not advisable to do so
  1507.                       unless you are sure that the new task has the same code
  1508.                                      ____
  1509.                       at that spot.
  1510.  
  1511.                       On an 80386 processor, the debug registers can be used in
  1512.                       a sticky breakpoint.  See the BR command.
  1513.  
  1514.                       o    BP[n] [<address>] [<passcount>] [<breakpoint com-
  1515.                           mands>]
  1516.  
  1517.                       This command sets a new breakpoint, or changes an old
  1518.                       sticky breakpoint.  The "n" is an optional breakpoint
  1519.                       number to select an old breakpoint for changing or
  1520.                       forcing a new breakpoint to a certain number.  If the
  1521.                       breakpoint number is omitted, the first available break-
  1522.                       point number is used.  The number must be just after the
  1523.                       "BP", with no intervening space.  It must be a digit from
  1524.                       '0' to '9'.  There must be a space after the number.  Up
  1525.                       to 10 breakpoints can be set.  The address is required
  1526.                       for all new breakpoints.  Either an address or a break-
  1527.                       point number can be used to change an existing break-
  1528.  
  1529.  
  1530.                                                    Kernel Debugger Commands  15
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.                       point.  A breakpoint command or passcount can be added or
  1541.                       changed with commands such as BP0 "DB DS:ESI;R" or BP2 5.
  1542.  
  1543.                       A breakpoint command is a string of any debugger commands
  1544.                       that are executed when that breakpoint is hit.  Semico-
  1545.                       lons (;) separate commands from one another.  Everything
  1546.                       is forced to uppercase unless surrounded by single quota-
  1547.                       tion marks.  Two single or double quotation marks remove
  1548.                       their special meaning.
  1549.  
  1550.                       A passcount greater than zero means that this breakpoint
  1551.                       must be executed that many times before the debugger
  1552.                       actually breaks.  The default for passcount is zero.
  1553.  
  1554.                       o    BR[<bp>] E|W|R|1|2|4 [<addr>] [<passcnt>] ["<bp
  1555.                           cmds>"]
  1556.  
  1557.                       This command sets an 80386 debug register.  Debug regis-
  1558.                       ters can be used to break on data reads and writes, and
  1559.                       instruction execution (which is the same as a regular
  1560.                       breakpoint).  Up to four debug registers can be set and
  1561.                       enabled at one time.  Disabled BR breakpoints do not use
  1562.                       up a debug register.  The flag definitions are:
  1563.  
  1564.                       Flag      Description
  1565.                       ____      ___________
  1566.  
  1567.                       1         One-byte length (default)
  1568.  
  1569.                       2         Word length on a word boundary
  1570.  
  1571.                       4         Doubleword length on a doubleword boundary
  1572.  
  1573.                       E         Break on instruction execution only (one-byte
  1574.                                 length only)
  1575.  
  1576.                       W         Break on writes only
  1577.  
  1578.                       R         Break on reads and writes
  1579.  
  1580.                       For one-byte breakpoints, the linear address alignment
  1581.                       does not matter, but for word-length breakpoints the
  1582.                       linear address must be on a word boundary.  For a
  1583.                       doubleword-length breakpoint, the linear address must be
  1584.                       on a doubleword boundary.  The debugger converts the
  1585.                       address to linear, and prints an error message if the
  1586.                       alignment is incorrect.
  1587.  
  1588.                       Only addresses that can be converted to linear (segment,
  1589.                       selector, and linear, but not physical) can be used in
  1590.                       the BR command address.  The rest of the arguments are
  1591.                       exactly like a BP command.
  1592.  
  1593.                       o   BT[<n>] [<address>]
  1594.  
  1595.  
  1596.  
  1597.   16  OS/2 Kernel Debugger
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.                       This command sets a time-stamping breakpoint.
  1608.  
  1609.                       o   BS
  1610.  
  1611.                       This command shows the time stamp entries.
  1612.  
  1613.                       o   BL
  1614.  
  1615.                       This command lists the currently set breakpoints along
  1616.                       with the current and original passcount and the break-
  1617.                       point command, if any.  An "e" after the breakpoint
  1618.                       number means that the breakpoint is enabled; a "d" means
  1619.                       that it is disabled.  After either one of those, there
  1620.                       may be an "I" which indicates that the address was
  1621.                       invalid the last time the debugger tried to set or clear
  1622.                       the breakpoint.
  1623.  
  1624.                       o   BC[n],[n],...
  1625.  
  1626.                       Removes (clears) the list of breakpoint numbers from the
  1627.                       debugger's breakpoint table.
  1628.  
  1629.                       o   BE[n],[n],...
  1630.  
  1631.                       Enables the list of breakpoint numbers.
  1632.  
  1633.                       o   BD[n],[n],...
  1634.  
  1635.                       Disables the list of breakpoint numbers, so the break-
  1636.                       point is not actually put into the code, but is saved
  1637.                       until it is enabled.
  1638.  
  1639.  
  1640.   COMPARE
  1641.  
  1642.                       o   C <range> <addr>
  1643.  
  1644.                       This command compares the bytes in the memory location
  1645.                       specified by <range> with the corresponding bytes in the
  1646.                       memory locations beginning at <addr>.  If all corre-
  1647.                       sponding bytes match, the kernel debugger displays its
  1648.                       prompt and waits for the next command.  If one or more
  1649.                       corresponding bytes do not match, each pair of mismatched
  1650.                       bytes is displayed.
  1651.  
  1652.  
  1653.   DUMP
  1654.  
  1655.                       o   D [<range>]
  1656.  
  1657.                       Dumps memory in the last format used.
  1658.  
  1659.                       o   DA [<range>]
  1660.  
  1661.  
  1662.  
  1663.                                                    Kernel Debugger Commands  17
  1664.  
  1665.  
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.                       Dumps memory in ASCII format only.
  1674.  
  1675.                       o   DB [<range>]
  1676.  
  1677.                       Dumps memory in bytes and ASCII.
  1678.  
  1679.                       o   DW [<range>]
  1680.  
  1681.                       Dumps memory in words.
  1682.  
  1683.                       o   DD [<range>]
  1684.  
  1685.                       Dumps memory in doublewords.
  1686.  
  1687.                       o   DG[A] [<range>]
  1688.  
  1689.                       This command dumps the global descriptor table (GDT).
  1690.                       The "A" option causes all the entries to be dumped (not
  1691.                       just the valid entries).  The default is to display only
  1692.                       the valid GDT entries.  A range of entries or just one
  1693.                       GDT entry can be displayed.  If the command is passed an
  1694.                       LDT selector, it displays "LDT" and the appropriate LDT
  1695.                       entry.
  1696.  
  1697.                       o   DI[A] [<range>]
  1698.  
  1699.                       This command dumps the interrupt descriptor table.  The
  1700.                       "A" option causes all the entries to be dumped (not just
  1701.                       the valid entries).  The default is to display just the
  1702.                       valid IDT entries.  A range of entries or just one IDT
  1703.                       entry can be displayed.
  1704.  
  1705.                       o   DL[A|P|S|H] [<range>]
  1706.  
  1707.                       This command dumps the local descriptor table.  The "A"
  1708.                       option causes all the entries to be dumped (not just the
  1709.                       valid entries).  The default is to display just the valid
  1710.                       LDT entries.  A range of entries or just one LDT entry
  1711.                       can be displayed.  If the command is passed a GDT
  1712.                       selector, it displays "GDT" and the appropriate GDT
  1713.                       entry.
  1714.  
  1715.                       The options P, S, and H are used to dump private, shared,
  1716.                       or huge segment selectors respectively.  To dump the huge
  1717.                       segment selectors, give the shadow selector, followed by
  1718.                       the maximum number of selectors reserved for that
  1719.                       segment, plus 1.
  1720.  
  1721.                       o   DP[A|D] [<range>]
  1722.  
  1723.                       This command dumps the page directory and page tables.
  1724.                       Page tables are always skipped if the corresponding page
  1725.                       directory entry is not present.  Page directory entries
  1726.                       appear with an asterisk next to the page frame, and are
  1727.  
  1728.  
  1729.   18  OS/2 Kernel Debugger
  1730.  
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.                       dumped once preceding a 4-megabyte region.  As a general
  1740.                       rule, you can ignore any lines beginning with an
  1741.                       asterisk.
  1742.  
  1743.                       The "A" option dumps all present page directory and page
  1744.                       table entries; the default is to skip page directory and
  1745.                       page table entries that are zero.  A zero page table
  1746.                       entry means that the page is uncommitted.
  1747.  
  1748.                       The "D" option dumps only page directory entries.  If a
  1749.                       count is given as part of the optional range, it is
  1750.                       interpreted as a page directory entry count.  For
  1751.                       example:
  1752.  
  1753.  
  1754.                              ##dp ff000 l4
  1755.                               linaddr   frame   pteframe  state res Dc Au CD WT Us rW Pn state
  1756.                              %000ff000* 00343  frame=00343  2    0  D  A        U  W  P  resident
  1757.                              %000ff000  000ff  frame=000ff  1    0  c  A        U  W  P  uvirt
  1758.                              %00100000  002ae  frame=002ae  0    0  c  A        U  W  P  pageable
  1759.                              %00101000  00215  vp id=0083c  0    0  c  u        U  W  n  pageable
  1760.                              %00102000         vp id=0083d  0    0  c  u        U  W  n  pageable
  1761.  
  1762.                                                    bit   bit
  1763.                                                    set  clear
  1764.                                                    ---  -----
  1765.                                             key:    D    c    Dirty / clean
  1766.                                                     A    u    Accessed / unaccessed
  1767.                                                     U    s    User / supervisor
  1768.                                                     W    r    Writable / read-only
  1769.                                                     P    n    Present / not-present
  1770.  
  1771.                       The PTEFRAME field contains the contents of the high-
  1772.                       order 20 bits in the PTE.  If the page is present, that
  1773.                       value is the high-order 20 bits of the physical address
  1774.                       that the page maps.  To find out information about that
  1775.                       physical address, you can issue the .MP command.  If the
  1776.                       page is not present, the PTEFRAME field contains an index
  1777.                       into the Virtual Page (VP) structure.  The .MV command
  1778.                       can dump information from that structure.  A non-present
  1779.                       page may still be cross-linked to a page of physical
  1780.                       memory via the VP, and if it is, that physical address is
  1781.                       in the FRAME column.
  1782.  
  1783.                       An exception is that uvirt pages (noted in the STATE
  1784.                                            _____
  1785.                       column) are direct mappings of physical memory, without
  1786.                       any other page manager structures associated with them.
  1787.  
  1788.                       o   DT [<addr>]
  1789.  
  1790.                       This command dumps the TSS.  If no address is given, it
  1791.                       dumps the current TSS pointed to by the TR register,
  1792.                       extracting the type (16-bit or 32-bit) from the
  1793.  
  1794.  
  1795.  
  1796.                                                    Kernel Debugger Commands  19
  1797.  
  1798.  
  1799.  
  1800.  
  1801.  
  1802.  
  1803.  
  1804.  
  1805.  
  1806.                       descriptor access byte.  If an address is given, the type
  1807.                       is extracted from the 386env flag.
  1808.  
  1809.                       o   DX
  1810.  
  1811.                       This command dumps the 80286(**) loadall buffer.
  1812.  
  1813.  
  1814.   ENTER
  1815.  
  1816.                       o   E <addr> [<list>]
  1817.  
  1818.                       This command enters one or more byte values into memory
  1819.                       at the specified <addr>.  If the optional <list> is
  1820.                       given, the command replaces the byte at the given address
  1821.                       and the bytes at each subsequent address until all values
  1822.                       in the list have been used.  If no <list> is given, the
  1823.                       command prompts for a replacement value.
  1824.  
  1825.                       If an error occurs, all byte values remain unchanged.
  1826.  
  1827.                       If you do not supply a <list>, the kernel debugger
  1828.                       prompts for a new value at <addr> by displaying this
  1829.                       address and its current value followed by a dot (.).  You
  1830.                       can then replace the value, skip to the next value,
  1831.                       return to a previous value, or exit the command by fol-
  1832.                       lowing these steps:
  1833.  
  1834.                       1.  To replace the byte value, simply type the new value
  1835.                           after the current value.  Make sure you type a
  1836.                           1-digit or 2-digit hexadecimal number.  The command
  1837.                           ignores extra trailing digits or other characters.
  1838.  
  1839.                       2.  To skip to the next byte, press the Spacebar.  Once
  1840.                           you have skipped to the next byte, you can change its
  1841.                           value or skip to the next byte.  If you skip beyond
  1842.                           an 8-byte boundary, the kernel debugger starts a new
  1843.                           display line by displaying the new address and value.
  1844.  
  1845.                       3.  To return to the preceding byte, type a hyphen (-).
  1846.                           When you return to the preceding byte, the kernel
  1847.                           debugger starts a new display line with the address
  1848.                           and value of that byte.
  1849.  
  1850.                       4.  To exit the E command, press Return.  You can exit
  1851.                           the command at any time.
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.   ---------------
  1858.  
  1859.   (**) Trademark of the Intel Corporation.
  1860.  
  1861.  
  1862.   20  OS/2 Kernel Debugger
  1863.  
  1864.  
  1865.  
  1866.  
  1867.  
  1868.  
  1869.  
  1870.  
  1871.  
  1872.   FILL
  1873.  
  1874.                       o   F <range> <list>
  1875.  
  1876.                       This command fills the addresses in the given <range>
  1877.                       with the values in the <list>.  If the range specifies
  1878.                       more bytes than the number of values in the list, the
  1879.                       list is repeated until all bytes in the range are filled.
  1880.                       If <list> has more values than the number of bytes in the
  1881.                       range, the command ignores any extra values.
  1882.  
  1883.  
  1884.   GO
  1885.  
  1886.                       o    G[S][T][=<start-address>][<break-address>],,,
  1887.  
  1888.                       This command passes execution control to the program at
  1889.                       the given <start-address>.  Execution continues to the
  1890.                       end of the code or until a <break-address> is encount-
  1891.                       ered.  The debuggee code also stops at any breakpoints
  1892.                       set using the Breakpoint Set command.
  1893.  
  1894.                       If no <start-address> is given, the command passes exe-
  1895.                       cution to the address specified by the current values of
  1896.                       CS and IP registers.  The equal sign (=) may be used only
  1897.                       when a <start-address> is given.
  1898.  
  1899.                       If a <break-address> is given, it must specify an
  1900.                       instruction address (that is, the address must contain
  1901.                       the first byte of an instruction opcode).  Up to ten
  1902.                       addresses can be given at one time.  The addresses can be
  1903.                       given in any order.  Only the first address encountered
  1904.                       during execution causes a break.  All others are ignored.
  1905.                       If you attempt to set more than ten breakpoints, an error
  1906.                       message is displayed.
  1907.  
  1908.                       The "S" option prints the time (in PERFVIEW timer ticks)
  1909.                       from when the system is started with GS until the next
  1910.                       entry to the debugger.  No attempt is made to calculate
  1911.                       and remove debugger overhead from the measurement.
  1912.  
  1913.                       The "T" option allows trapped exceptions to resume at the
  1914.                       original trap handler address without having to unhook
  1915.                       the exception.  Instead of issuing the "vcp d; t; vsp d"
  1916.                       commands, you can use the "T" option of the GO command.
  1917.  
  1918.                       When execution of the debuggee code reaches a breakpoint,
  1919.                       the kernel debugger normally displays the current values
  1920.                       of the registers and flags.  It also displays the next
  1921.                       instruction to be executed.  If the default command (Z)
  1922.                       has been changed to something other than the REGISTER (R)
  1923.                       command, the debugger executes the command list set by
  1924.                       the last ZS command.
  1925.  
  1926.  
  1927.  
  1928.                                                    Kernel Debugger Commands  21
  1929.  
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.   HELP/PRINT EXPRESSION
  1939.  
  1940.                       o   ?[<expr>]|'string'
  1941.  
  1942.                       This command prints help if no arguments are given.  If
  1943.                       an expression is given, it prints the value of the evalu-
  1944.                       ated expression in all bases.  If a string is given, it
  1945.                       prints the string on the console.
  1946.  
  1947.  
  1948.   HEX
  1949.  
  1950.                       o   H <value1> <value2>
  1951.  
  1952.                       This command displays the sum and difference of two
  1953.                       hexadecimal numbers.  The debugger adds <value1> to
  1954.                       <value2> and displays the result.  It then subtracts
  1955.                       <value2> from <value1> and displays that result.  The
  1956.                       results are displayed on one line, and are always in
  1957.                       hexadecimal.  See the Help/Print Expression command for a
  1958.                       more general expression display.
  1959.  
  1960.  
  1961.   INPUT
  1962.  
  1963.                       o   I <port>
  1964.  
  1965.                       This command reads and displays one byte from the given
  1966.                       input <port>.  The <port> can be any 16-bit port address.
  1967.  
  1968.  
  1969.   LIST NEAR SYMBOL
  1970.  
  1971.                       o   LN [<addr>]
  1972.  
  1973.                       This command lists the nearest symbol both forward from
  1974.                       and back to the address passed.  The default is the
  1975.                       current disassembly address.  All the active maps are
  1976.                       searched.
  1977.  
  1978.                       There is the possibility that there will be duplicates
  1979.                       when <addr> is specified as a selector:offset.  Make sure
  1980.                       that you have selected the correct slot (with the .S
  1981.                       command) before you issue the LN command with a
  1982.                       selector:offset.
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988.  
  1989.  
  1990.  
  1991.  
  1992.  
  1993.  
  1994.   22  OS/2 Kernel Debugger
  1995.  
  1996.  
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  
  2002.  
  2003.  
  2004.   LIST GROUPS
  2005.  
  2006.                       o   LG [<mapname>]
  2007.  
  2008.                       This command lists the selector or segment and the name
  2009.                       for each group in the active maps or the specified map.
  2010.  
  2011.  
  2012.   LIST MAPS
  2013.  
  2014.                       o   LM
  2015.  
  2016.                       This command lists all the current symbol files that are
  2017.                       loaded, and shows which ones are active.
  2018.  
  2019.  
  2020.   LIST ABSOLUTE SYMBOLS
  2021.  
  2022.                       o   LA [<mapname>]
  2023.  
  2024.                       This command lists all the absolute symbols in the active
  2025.                       maps or the specified map.
  2026.  
  2027.  
  2028.   LIST SYMBOLS
  2029.  
  2030.                       o   LS <addr>
  2031.  
  2032.                       This command lists all the symbols in the group that the
  2033.                       address is in.
  2034.  
  2035.  
  2036.   ADD/REMOVE ACTIVE MAP
  2037.  
  2038.                       o   WA <mapname> | *
  2039.  
  2040.                       o   WR <mapname> | *
  2041.  
  2042.                       "WA" adds a map to the active list.  "WR" removes it.
  2043.                       The "LM" command displays the names of map files that are
  2044.                       available.  "*" means all maps.  All maps start actively
  2045.                       when first linked.
  2046.  
  2047.  
  2048.   CONDITIONAL EXECUTION
  2049.  
  2050.                       o   J <expr> [<command list>]
  2051.  
  2052.                       This command executes the command list if the expression
  2053.                       evaluates to TRUE (nonzero).  Otherwise, it continues to
  2054.                       the next command in the command line (not including the
  2055.                       ones in the "command list").  The command list must be in
  2056.                       single or double quotation marks if there is more than
  2057.                       more command (separated by ";").  A single command, or no
  2058.  
  2059.  
  2060.                                                    Kernel Debugger Commands  23
  2061.  
  2062.  
  2063.  
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069.  
  2070.                       command, can also be used without quotation marks.  This
  2071.                       command can be used in breakpoint commands to condi-
  2072.                       tionally break when an expression becomes true, or even
  2073.                       in the default command (Z).
  2074.  
  2075.                       The command BP 167:1454 "J AX == 0;G" breaks when AX
  2076.                       equals zero when this breakpoint is hit.
  2077.  
  2078.                       The command BP 167:1452 "J BY (DS:SI+3) == 40 'R;G';DG
  2079.                       DS" prints the registers and continues execution, if when
  2080.                       this breakpoint is hit the byte pointed to by "DS:SI+3"
  2081.                       is equal to 40.  Otherwise, it prints the descriptor
  2082.                       table entry in DS.
  2083.  
  2084.                       The command BP 156:1455 "J (MSW AND 1) == 1 'G'" breaks
  2085.                       when the breakpoint is reached in real mode.  BP 156:1455
  2086.                       "J (MSW AND 1)" is a shortcut that does the same thing
  2087.                       (like "C" boolean expressions).
  2088.  
  2089.                       See the default command (Z) for more examples.
  2090.  
  2091.  
  2092.   STACK TRACE
  2093.  
  2094.                       o   K[S|B] [<SS:EBP>] [<CS:EIP>]
  2095.  
  2096.                       This command threads through the BP chain on the stack
  2097.                       and prints the address, 4 words or doublewords of parame-
  2098.                       ters, and any symbol found for the address.  The starting
  2099.                       stack frame address (SS:EBP) and the initial code segment
  2100.                       (CS:EIP) can be specified.  Defaults are SS:EBP and
  2101.                       CS:EIP.  The "S" (Small) option indicates that the frame
  2102.                       is 16 bits wide, and the "B" (Big) option indicates that
  2103.                       the frame is 32 bits wide.  The default depends on the D
  2104.                       bit in the CS selector.
  2105.  
  2106.  
  2107.   MOVE
  2108.  
  2109.                       o   M <range> <addr>
  2110.  
  2111.                       This command moves the block of memory specified by
  2112.                       <range> to the location starting at <addr>.
  2113.  
  2114.                       All moves are guaranteed to be performed without data
  2115.                       loss, even when the source and destination blocks
  2116.                       overlap.  This means the destination block is always an
  2117.                       exact duplicate of the original source block.  If the
  2118.                       destination block overlaps some portion of the source
  2119.                       block, the original source is changed.
  2120.  
  2121.                       To prevent data loss, this command copies data from the
  2122.                       source block's lowest address first whenever the source
  2123.                       is at a higher address than the destination.  If the
  2124.  
  2125.  
  2126.   24  OS/2 Kernel Debugger
  2127.  
  2128.  
  2129.  
  2130.  
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.                       source is at a lower address, this command copies data
  2137.                       from the source's highest address first.
  2138.  
  2139.  
  2140.   OUTPUT
  2141.  
  2142.                       o   O <port> <byte>
  2143.  
  2144.                       This command sends the given <byte> to the specified
  2145.                       output <port>.  The <port> can be any 16-bit port
  2146.                       address.
  2147.  
  2148.  
  2149.   PTRACE
  2150.  
  2151.                       o   P[N|T] [=<start-address>] [<count>]
  2152.  
  2153.                       This command executes the instruction at the given
  2154.                       <start-address>, and then displays the current values of
  2155.                       the all the registers and flags (or whatever the Z
  2156.                       command has been set to).
  2157.  
  2158.                       The difference between PTRACE and TRACE commands is that
  2159.                       PTRACE stops after instructions such as CALL, REP MOVSB,
  2160.                       and so on, instead of tracing into the call or each rep
  2161.                       string operation.
  2162.  
  2163.                       If the optional <start-address> is given, the command
  2164.                       starts execution at the given address.  Otherwise, it
  2165.                       starts execution at the instruction pointed to by the
  2166.                       current CS and IP registers.  The equal sign (=) may be
  2167.                       used only if a <start-address> is given.
  2168.  
  2169.                       If the optional <count> is given, the command continues
  2170.                       to execute <count> instructions before stopping.  The
  2171.                       command displays the current values of the registers and
  2172.                       flags for each instruction before executing the next.
  2173.  
  2174.                       The "N" option suppresses the register display, so that
  2175.                       only the assembly line is displayed.  This only works if
  2176.                       the "default command" (see the Z command) is an "R" (the
  2177.                       normal setting).
  2178.  
  2179.                       The "T" option allows the original trap handler address
  2180.                       to be traced into without having to unhook the exception.
  2181.                       Instead of issuing the "vcp d; t; vsp d" commands, you
  2182.                       can use the "T" option of the PTRACE command.
  2183.  
  2184.  
  2185.  
  2186.  
  2187.  
  2188.  
  2189.  
  2190.  
  2191.  
  2192.                                                    Kernel Debugger Commands  25
  2193.  
  2194.  
  2195.  
  2196.  
  2197.  
  2198.  
  2199.  
  2200.  
  2201.  
  2202.   REGISTER
  2203.  
  2204.                       o   R[T][<register-name> [<value>]]
  2205.  
  2206.                       This command displays the contents of a CPU register, and
  2207.                       allows the contents to be changed to a new value.
  2208.  
  2209.                       The "T" option toggles the "regterse" flag (see the Y
  2210.                       command).
  2211.  
  2212.                       If no <register-name> is given, the command displays all
  2213.                       the registers, flags, and the instruction at the address
  2214.                       pointed to by the current CS and IP register values.
  2215.  
  2216.                       If a <register-name> is given, the command displays the
  2217.                       current value of the given register, and prompts for a
  2218.                       new value.  If both a <register-name> and <value> are
  2219.                       given, the command changes the register to the given
  2220.                       value.
  2221.  
  2222.                       The <register-name> can be any one of the following
  2223.                       names:
  2224.  
  2225.                       o   AX, BX, CX, DX, SI, DI, BP, SP, IP, PC - general reg-
  2226.                           isters.
  2227.  
  2228.                       o   DS, ES, SS, CS - segment registers.
  2229.  
  2230.                       o   GDTB - GDT base as a linear address.
  2231.  
  2232.                       o   GDTL - GDT limit.
  2233.  
  2234.                       o   IDTB - IDT base as a linear address.
  2235.  
  2236.                       o   IDTL - IDT limit.
  2237.  
  2238.                       o   TR, LDTR - TR, LDTR registers.
  2239.  
  2240.                       o   IOPL - input/output privilege level portion of flag
  2241.                           registers.
  2242.  
  2243.                       o   F - flag register.
  2244.  
  2245.                       o   MSW - Machine status word.
  2246.  
  2247.                       The 80386 <register-names> are the following (in addition
  2248.                       to the above):
  2249.  
  2250.                       o   EAX, EBX, ECX, EDX, ESI, EDI, EBP, ESP, EIP -
  2251.                           extended general registers.
  2252.  
  2253.                       o   FS, GS - segment registers.
  2254.  
  2255.                       o   EF - extended flag register.
  2256.  
  2257.  
  2258.   26  OS/2 Kernel Debugger
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268.                       o   CR0, CR2, CR3 - control registers.
  2269.  
  2270.                       o   DR0, DR1, DR2, DR3, DR6, DR7 - debug registers.
  2271.  
  2272.                       o   TR6, TR7 - test registers.
  2273.  
  2274.                       IP and PC name the same register - the Instruction
  2275.                       Pointer.  F is a special name for the Flags register.
  2276.  
  2277.                       To change a register value, supply name of the register
  2278.                       when you enter the REGISTER command.  If you do not also
  2279.                       supply a value, the command displays the name of the reg-
  2280.                       ister, its current value, and a colon prompt.  Type the
  2281.                       new value, and press Return.  If you do not want to
  2282.                       change the value, just press Return.  If you enter an
  2283.                       illegal name, the command displays an error message.
  2284.  
  2285.                       To change a flag value, supply the register name "F" when
  2286.                       you enter the REGISTER command.  The command displays the
  2287.                       current value of each flag as a two-letter name.  The
  2288.                       following is a table of flag values:
  2289.  
  2290.   +----------------------------------------------------------------+
  2291.   | Table 1. Values for the Flag Register                          |
  2292.   +------------------+----------------------+----------------------+
  2293.   | FLAG             | SET                  | CLEAR                |
  2294.   +------------------+----------------------+----------------------+
  2295.   | Overflow         | OV                   | NV                   |
  2296.   +------------------+----------------------+----------------------+
  2297.   | Direction        | DN (Decrement)       | UP (Increment)       |
  2298.   +------------------+----------------------+----------------------+
  2299.   | Interrupt        | EI (Enabled)         | DI (Disabled)        |
  2300.   +------------------+----------------------+----------------------+
  2301.   | Sign             | NG (Negative)        | PL (Plus)            |
  2302.   +------------------+----------------------+----------------------+
  2303.   | Zero             | ZR                   | NZ                   |
  2304.   +------------------+----------------------+----------------------+
  2305.   | Aux Carry        | AC                   | NA                   |
  2306.   +------------------+----------------------+----------------------+
  2307.   | Parity           | PE (Even)            | PO (Odd)             |
  2308.   +------------------+----------------------+----------------------+
  2309.   | Carry            | CY                   | NC                   |
  2310.   +------------------+----------------------+----------------------+
  2311.   | Nested Task      | NT                   | (toggles)            |
  2312.   +------------------+----------------------+----------------------+
  2313.  
  2314.                       At the end of the list of values, the command displays a
  2315.                       hyphen (-).  When you see the hyphen, enter new values
  2316.                       for the flags you want to change, then press Return.  You
  2317.                       can enter flag values in any order.  Spaces between
  2318.                       values are not required.  Flags for which new values are
  2319.                       not entered remain unchanged.  If you do not want to
  2320.                       change any flags, just press Return.
  2321.  
  2322.  
  2323.  
  2324.                                                    Kernel Debugger Commands  27
  2325.  
  2326.  
  2327.  
  2328.  
  2329.  
  2330.  
  2331.  
  2332.  
  2333.  
  2334.                       If you enter a name other than those shown above, the
  2335.                       command prints an error message.  The flags up to the
  2336.                       error are changed; flags at and after the error are not.
  2337.  
  2338.                       Changing the MSW (Machine Status Word) is the same as
  2339.                       changing the flag registers, but with the following flag
  2340.                       names:
  2341.  
  2342.   +------------------------------------------------------------+
  2343.   | Table 2. Values for the Machine Status Word                |
  2344.   +----------------------------------+--------+----------------+
  2345.   | FLAG                             | SET    | CLEAR          |
  2346.   +----------------------------------+--------+----------------+
  2347.   | Protected Mode                   | PM     | (toggles)      |
  2348.   +----------------------------------+--------+----------------+
  2349.   | Monitor Processor Extension      | MP     | (toggles)      |
  2350.   +----------------------------------+--------+----------------+
  2351.   | Emulate Processor Extension      | EM     | (toggles)      |
  2352.   +----------------------------------+--------+----------------+
  2353.   | Task Switched                    | TS     | (toggles)      |
  2354.   +----------------------------------+--------+----------------+
  2355.  
  2356.                       "Toggles" means that if the flag is set, using the flag
  2357.                       name in the REGISTER command clears it.  If the flag is
  2358.                       clear, using the flag name in the REGISTER command sets
  2359.                       it.
  2360.  
  2361.  
  2362.   SEARCH
  2363.  
  2364.                       o   S <range> <list>
  2365.  
  2366.                       This command searches the given <range> of memory
  2367.                       locations for the byte values given in <list>.  If the
  2368.                       bytes in the list are found, the command displays the
  2369.                       address of each occurrence of the list.  Otherwise, it
  2370.                       displays nothing.
  2371.  
  2372.                       The <list> can have any number of bytes.  Each must be
  2373.                       separated by a space or comma.  If the list contains more
  2374.                       than one byte, this command does not display an address
  2375.                       unless the bytes beginning at that address exactly match
  2376.                       the value and order of the bytes in the list.
  2377.  
  2378.  
  2379.   TRACE
  2380.  
  2381.                       o   T[A|C|N|S|T|X][=<start-address>][<count>][<addr>]
  2382.  
  2383.                       This command executes the instruction at the given
  2384.                       <start-address>, then displays the current values of all
  2385.                       the registers and flags.
  2386.  
  2387.  
  2388.  
  2389.  
  2390.   28  OS/2 Kernel Debugger
  2391.  
  2392.  
  2393.  
  2394.  
  2395.  
  2396.  
  2397.  
  2398.  
  2399.  
  2400.                       If the optional <start-address> is given, the command
  2401.                       starts execution at the given address.  Otherwise, it
  2402.                       starts execution at the instruction pointed to by the
  2403.                       current CS and IP registers.  The equal sign (=) may be
  2404.                       used only if a <start-address> is given.
  2405.  
  2406.                       If the optional <count> is given, the command continues
  2407.                       to execute a number of instructions equal to <count>
  2408.                       before stopping.  The command displays the current values
  2409.                       of the registers and flags for each instruction before
  2410.                       executing the next instruction.
  2411.  
  2412.                       The "A" option allows the user to specify an ending
  2413.                       address for the trace.  Instructions are traced until
  2414.                       [<addr>] is reached.
  2415.  
  2416.                       The "C" option suppresses all output, and counts
  2417.                       instructions traced.  An end address is required for this
  2418.                       command.
  2419.  
  2420.                       The "N" option suppresses the register display, so that
  2421.                       only the assembly line is displayed.  This only works if
  2422.                       the "default command" (see the Z command) is an "R" (the
  2423.                       normal setting).
  2424.  
  2425.                       The "S" (special trace) option is identical to the "C"
  2426.                       option, except that the instruction and count are dis-
  2427.                       played for every call and the return from that call.
  2428.  
  2429.                       The "T" option allows original trap handler address to be
  2430.                       traced into without having to unhook the exception.
  2431.                       Instead of issuing the "vcp d; t; vsp d" commands, you
  2432.                       can use the "T" option of the TRACE command.
  2433.  
  2434.                       The "X" option forces the debugger to trace regions of
  2435.                       code known to be untraceable (for example,
  2436.                       _PGSwitchContext).
  2437.  
  2438.  
  2439.   UNASSEMBLE
  2440.  
  2441.                       o    U [<range>]
  2442.  
  2443.                       This command displays the instructions in a mnemonic
  2444.                       format.  All the 80386(**) and 80387(**) opcodes can be
  2445.                       displayed.
  2446.  
  2447.                       If given a <range>, the specified address is displayed
  2448.                       for the number of bytes specified.  If the <range> con-
  2449.  
  2450.  
  2451.   ---------------
  2452.  
  2453.   (**) Trademark of the Intel Corporation.
  2454.  
  2455.  
  2456.                                                    Kernel Debugger Commands  29
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.                       tains the "L" option (for example, u 90:234 l3), this
  2467.                       specifies the number of lines to display.
  2468.  
  2469.  
  2470.   INTERRUPT AND TRAP VECTOR
  2471.  
  2472.                       o    VL[N | P | V | R | F]
  2473.  
  2474.                       This command lists the real and protected mode vectors
  2475.                       that the debugger intercepts.  Vectors that have been set
  2476.                       with VT (rather than with VS) are printed with an
  2477.                       asterisk following the vector number.  VLR lists only the
  2478.                       real mode vectors, and VLP lists only the protect mode
  2479.                       vectors.  VL lists both, as follows:
  2480.  
  2481.                               R 0 1 2 3 4 5 6
  2482.                               V 0 1 2
  2483.                               P 0 1 2 3 4 5 6 7 8* 9 A B
  2484.  
  2485.                       The "N" (Noisy) option lists the traps that beep when
  2486.                       hit.
  2487.  
  2488.                       The "F" (Fatal) option causes the kernel to route the
  2489.                       faults that are fatal to a process to the debugger
  2490.                       instead of displaying the popup message.  For GP faults,
  2491.                       "VSF D" is the same a "VSP D".  For page faults, "VSP E"
  2492.                       traps all ring 3 and ring 2 page faults, and "VSF E"
  2493.                       traps only the invalid page faults.
  2494.  
  2495.                       o   VT[N | P | V | R | F] n[,n,..]
  2496.  
  2497.                       This command adds a new vector that the debugger inter-
  2498.                       cepts.  VTR installs a debugger handler in the real mode
  2499.                       IDT.  VTP installs a debugger handler in the protected
  2500.                       mode IDT.  VSV or VTV intercepts V86 mode exceptions or
  2501.                       traps.
  2502.  
  2503.                       The "N" option causes the intercepted traps to beep when
  2504.                       hit.
  2505.  
  2506.                       The "F" (Fatal) option causes the kernel to route the
  2507.                       faults that are fatal to a process to the debugger
  2508.                       instead of displaying the popup message.  For GP faults,
  2509.                       "VSF D" is the same a "VSP D".  For page faults, "VSP E"
  2510.                       traps all ring 3 and ring 2 page faults, and "VSF E"
  2511.                       traps only the invalid page faults.
  2512.  
  2513.                       o   VS[N | P | V | R | F] n[,n,..]
  2514.  
  2515.                       This command is the same as VT, except that VS does not
  2516.                       intercept ring 0 interrupts.  The VSV and VTV commands
  2517.                       intercept V86 mode exceptions or traps.
  2518.  
  2519.  
  2520.  
  2521.  
  2522.   30  OS/2 Kernel Debugger
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531.  
  2532.                       The "N" option causes the intercepted traps to beep when
  2533.                       hit.
  2534.  
  2535.                       The "F" (Fatal) option causes the kernel to route the
  2536.                       faults that are fatal to a process to the debugger
  2537.                       instead of displaying the popup message.  For GP faults,
  2538.                       "VSF D" is the same a "VSP D".  For page faults, "VSP E"
  2539.                       traps all ring 3 and ring 2 page faults, and "VSF E"
  2540.                       traps only the invalid page faults.
  2541.  
  2542.                       o   VC[N | P | V | R | F] n,[n],..
  2543.  
  2544.                       This command clears the vectors indicated, reinstalling
  2545.                       whatever address was in the vector before the debugger
  2546.                       obtained the vector.
  2547.  
  2548.                       The "N" option causes the affected traps to not beep when
  2549.                       hit.  It does not clear the trap itself.
  2550.  
  2551.                       The "F" (Fatal) option causes the kernel to route the
  2552.                       faults that are fatal to a process to the debugger
  2553.                       instead of displaying the popup message.  For GP faults,
  2554.                       "VSF D" is the same a "VSP D".  For page faults, "VSP E"
  2555.                       traps all ring 3 and ring 2 page faults, and "VSF E"
  2556.                       traps only the invalid page faults.
  2557.  
  2558.                       NOTE:  If you want to intercept general protection faults
  2559.                       before the operating system does, then you can issue "VTP
  2560.                       D" before the fault is hit, examine the information about
  2561.                       the fault, and issue "VCP D" and "G" to let the system GP
  2562.                       handler get control and end the process.  Alternatively,
  2563.                       you can issue the "VCP D" command after hitting the
  2564.                       fault, and trace into the exception handler.  The "TT"
  2565.                       and "GT" commands do this automatically.
  2566.  
  2567.  
  2568.   DEBUGGER OPTION
  2569.  
  2570.                       o   Y[?] [386env|dislwr|regterse]
  2571.  
  2572.                       This command allows the debugger configuration to be
  2573.                       changed.  The "?" prints the current options supported.
  2574.                       The "Y" command by itself prints the current state of the
  2575.                       options.  The "Y" command and a flag name sets or toggles
  2576.                       an options flag.  The flags are as follows:
  2577.  
  2578.                       386ENV      32-bit environment (toggles)
  2579.  
  2580.                       DISLWR      lowercase disassembly (toggles)
  2581.  
  2582.                       REGTERSE    terse register set (toggles)
  2583.  
  2584.                       All these flags toggle their state when set, and are
  2585.                       printed only when the option is on.
  2586.  
  2587.  
  2588.                                                    Kernel Debugger Commands  31
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595.  
  2596.  
  2597.  
  2598.                       The "386env" flag controls the size of addresses, regis-
  2599.                       ters, and so on when displayed.  When this option is on,
  2600.                       addresses, registers, and so on are printed in 32-bit
  2601.                       formats; otherwise they are printed in the 16-bit
  2602.                       formats.  This flag has nothing to do with the processor
  2603.                       that the debugger is executing in.  It only concerns the
  2604.                       display sizes.
  2605.  
  2606.                       The "dislwr" flag controls the disassembler's lowercase
  2607.                       option.  When the flag is on, disassembly is in lower-
  2608.                       case.
  2609.  
  2610.                       The "regterse" flag controls the number of registers dis-
  2611.                       played in the register dump command.  In the 32-bit
  2612.                       format, when the "regterse" flag is on, only the first
  2613.                       three lines are displayed (instead of the normal six-line
  2614.                       plus disassembly-line display).  In the 16-bit format
  2615.                       (386env off), only the first two lines of the normal
  2616.                       three-line display (plus the disassembly line) are
  2617.                       printed.
  2618.  
  2619.  
  2620.   DEFAULT COMMAND LINES
  2621.  
  2622.                       o   Z
  2623.  
  2624.                       This command executes the default command.  The default
  2625.                       command is a string of debugger commands that are exe-
  2626.                       cuted any time the debugger is entered and there is no
  2627.                       breakpoint command attached to the entry.  It starts as
  2628.                       only the "R" command, but any string of commands can be
  2629.                       used.
  2630.  
  2631.                       o   ZL
  2632.  
  2633.                       List the default command.
  2634.  
  2635.                       o   ZS <string>
  2636.  
  2637.                       Change the default command.  If there are any errors (too
  2638.                       long), it returns to the "R" command.
  2639.  
  2640.                       If you want to just "GO" on all the "INT 3s" in your
  2641.                       application or test program, here is what you do:
  2642.  
  2643.                               ZS "J (BY CS:EIP) == CC 'G&csq;R."
  2644.  
  2645.                       This restarts execution every time you enter the debugger
  2646.                       on an "INT 3".
  2647.  
  2648.                       A watchpoint can be set up as follows:
  2649.  
  2650.                               ZS "J (WO 40:1234) == 0EED 'r';t"
  2651.  
  2652.  
  2653.  
  2654.   32  OS/2 Kernel Debugger
  2655.  
  2656.  
  2657.  
  2658.  
  2659.  
  2660.  
  2661.  
  2662.  
  2663.  
  2664.                       This command traces until the word at 40:1234 is equal to
  2665.                       hex 0EED.  This will not work if you are tracing through
  2666.                       the mode-switching code in the operating system or other
  2667.                       sections of code that cannot be traced.
  2668.  
  2669.  
  2670.   EXTERNAL DEBUGGER COMMANDS
  2671.   __________________________
  2672.  
  2673.                       These commands are part of the debugger, but are specific
  2674.                       to the environment the debugger is running in.  The fol-
  2675.                       lowing commands are for the OS/2 2.0 environment.
  2676.  
  2677.  
  2678.   HELP
  2679.  
  2680.                       o    .?
  2681.  
  2682.                       This command prints the help menu for the external
  2683.                       debugger commands.
  2684.  
  2685.  
  2686.   COM PORT BAUD RATE
  2687.  
  2688.                       o    .B <baud rate> [<port addr>]
  2689.  
  2690.                       This command sets the baud rate of the debugging port.
  2691.                       Valid values for the baud rate are 150, 300, 600, 1200,
  2692.                       2400, 4800, 9600 and 19200.  Since the default base of
  2693.                       numbers for the debugger is 16, you must add the suffix
  2694.                       "T" to a decimal (base 10) number to indicate a decimal
  2695.                       value.  For example, if you want to debug over a
  2696.                       1200-baud line, the correct command is:
  2697.  
  2698.                               .B 1200T
  2699.  
  2700.                       The port address option can be "1" for COM1, or "2" for
  2701.                       COM2.  Anything else is taken as a base port address.
  2702.                       During initialization, if there is no COM2, the debugger
  2703.                       checks for COM1 and then any other COM port address in
  2704.                       the ROM data area, and uses it as the console.
  2705.  
  2706.  
  2707.   DUMP ABIOS COMMON DATA AREA
  2708.  
  2709.                       o    .C
  2710.  
  2711.                       This command dumps the ABIOS common data area.
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719.  
  2720.  
  2721.                                                    Kernel Debugger Commands  33
  2722.  
  2723.  
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.   DUMP OS/2 DATA STRUCTURES
  2732.  
  2733.                       o    .D <data structure name> [<addr>]
  2734.  
  2735.                       This command displays a few common OS/2 data structures.
  2736.                       The data structures supported are:
  2737.  
  2738.                       Name        Description
  2739.                       ____        ___________
  2740.  
  2741.                       SFT         System file table entry
  2742.  
  2743.                       VPB         Volume parameter block
  2744.  
  2745.                       DPB         Disk parameter block
  2746.  
  2747.                       CDS         Current Directory Structure
  2748.  
  2749.                       KSEM        Internal Kernel Semaphore
  2750.  
  2751.                       DT          Disk Trace
  2752.  
  2753.                       DEV         Device driver header
  2754.  
  2755.                       REQ         Device driver request packet
  2756.  
  2757.                       MFT         Master file table entry
  2758.  
  2759.                       BUF         File system buffer
  2760.  
  2761.                       BPB         BIOS parameter block
  2762.  
  2763.                       SEM32       32-bit Semaphore structure
  2764.  
  2765.                       MUXQ        32-bit Semaphore MuxQ chain
  2766.  
  2767.                       OPENQ       32-bit Semaphore OpenQ chain
  2768.  
  2769.  
  2770.   SWAP IN TSD OR PAGE
  2771.  
  2772.                       o    .I[D|B] [<addr>]
  2773.  
  2774.                       o    .IT[D|B] [<slot>]
  2775.  
  2776.                       If only ".I" is given, the page enclosing that address is
  2777.                       swapped in.  The address may include an optional task
  2778.                       slot number override, as in %3|20000.  The ".IT" command
  2779.                       swaps in the corresponding task's TSD.  The "D" option
  2780.                       queues a single swap-in request to be acted upon at task
  2781.                       time by the KDB daemon thread.  If the "D" option is not
  2782.                       given, this command is restricted to being executed in
  2783.                       user mode (ring 3 or ring 2) or kernel mode if it is not
  2784.                       interrupt time, if the thread is not blocked, swapping or
  2785.  
  2786.  
  2787.  
  2788.   34  OS/2 Kernel Debugger
  2789.  
  2790.  
  2791.  
  2792.  
  2793.  
  2794.  
  2795.  
  2796.  
  2797.  
  2798.                       leaving the kernel (InDos is 0).  The ".I[T]" command
  2799.                       checks for all these conditions, and prints an error.
  2800.  
  2801.  
  2802.   USER STACK TRACE
  2803.  
  2804.                       o    .K[S|B] [<slot> | # | *]
  2805.  
  2806.                       This command threads through the BP chain on the user
  2807.                       stack of the slot specified, and prints the address, 4
  2808.                       words or doublewords of parameters, and any symbol found
  2809.                       for the address.  The default starting point is taken
  2810.                       from the user SS:EBP and CS:EIP of the debugger's default
  2811.                       slot (the one selected with .S).  The "S" (Small) option
  2812.                       indicates that the frame is 16 bits wide, and the "B"
  2813.                       (Big) option indicates that the frame is 32 bits wide.
  2814.                       The default depends on the D bit in the user's CS.
  2815.  
  2816.  
  2817.   PRINT MTE SEGMENT TABLE
  2818.  
  2819.                       o    .LM[O][L|P|V|X] <hobmte|laddr|"modulename"]
  2820.  
  2821.                       This command prints module table entries (MTEs) and their
  2822.                       associated object and segment table entries.
  2823.  
  2824.                       The "O" option suppresses the object or segment table
  2825.                       display.
  2826.  
  2827.                       The "L" option displays only library (.DLL) MTEs.
  2828.  
  2829.                       The "P" option displays only Physical Device Driver (PDD)
  2830.                       MTEs.
  2831.  
  2832.                       The "V" option displays only Virtual Device Driver (VDD)
  2833.                       MTEs.
  2834.  
  2835.                       The "X" option displays only executable (.EXE) MTEs.
  2836.  
  2837.                       If a nonzero HOBMTE is given, only those MTEs with a
  2838.                       matching HOBMTE are printed.  If a nonzero linear address
  2839.                       is given, only the MTE pointed to by the linear address
  2840.                       is printed.  If a quoted string is given, only those MTEs
  2841.                       with a matching module name are printed.  The module
  2842.                       names for A:\BAR.DLL and C:\FOO\BAR.EXE are both "BAR".
  2843.                       No drive, path or extension information should be given.
  2844.  
  2845.  
  2846.  
  2847.  
  2848.  
  2849.  
  2850.  
  2851.  
  2852.  
  2853.  
  2854.                                                    Kernel Debugger Commands  35
  2855.  
  2856.  
  2857.  
  2858.  
  2859.  
  2860.  
  2861.  
  2862.  
  2863.  
  2864.   MEMORY ARENA RECORD DUMP
  2865.  
  2866.                       o    .MA[A|B|C|F|H|L|M|R] [<har|laddr>] | [<har|laddr>
  2867.                           L<number of entries>]
  2868.  
  2869.                       This command displays the virtual memory manager's arena
  2870.                       records.  If no handle or linear address is given, the
  2871.                       entire table is displayed.  If a linear address is given,
  2872.                       it is considered a pointer to an arena record.  One
  2873.                       record or a range of records can be displayed.
  2874.  
  2875.                       The "A" option displays all contexts (the default is the
  2876.                       current context only).
  2877.  
  2878.                       The "B" option displays only busy (allocated) entries.
  2879.                       This is the default.
  2880.  
  2881.                       The "F" option displays only free (unallocated) entries.
  2882.  
  2883.                       The "C" option finds the corresponding object record, and
  2884.                       displays the arena, object, alias and context record
  2885.                       chains.
  2886.  
  2887.                       The "H" option follows hash links, displaying entries.
  2888.  
  2889.                       The "L" option follows forward links, displaying entries.
  2890.  
  2891.                       The "R" option follows reverse links, displaying entries.
  2892.  
  2893.                       The "M" option causes all arena records whose linear
  2894.                       address range encloses the given linear address to be
  2895.                       displayed.  A linear address must also be given, and no
  2896.                       count is allowed.  Context information is ignored, so if
  2897.                       the linear address is valid in multiple contexts, mul-
  2898.                       tiple arena records are displayed.  A physical address
  2899.                       may be given instead of a linear address to allow non-
  2900.                       present linear addresses to get past the debugger's
  2901.                       expression analyzer.  If a selector address type is used,
  2902.                       it must be converted to a linear address on the command
  2903.                       line.
  2904.  
  2905.                       If you ever need to find out who owns a selector because
  2906.                       of a GP fault in some unknown LDT or GDT segment or
  2907.                       memory object, the following command is useful:
  2908.  
  2909.                                   .M
  2910.                               or
  2911.                                   .MAMC CS:EIP
  2912.  
  2913.  
  2914.                       This command displays the arena record and memory object
  2915.                       record (and the owner) of the code segment.  It also
  2916.                       follows the context record chains and displays them.  The
  2917.                       "CS" can be substituted with any selector, and the "EIP"
  2918.  
  2919.  
  2920.   36  OS/2 Kernel Debugger
  2921.  
  2922.  
  2923.  
  2924.  
  2925.  
  2926.  
  2927.  
  2928.  
  2929.  
  2930.                       with any offset.  This command converts the
  2931.                       selector:offset into a linear address automatically, so
  2932.                       the resulting address can be used to find and interpret
  2933.                       the arena records and memory object records.
  2934.  
  2935.                       Since ".M" defaults to ".MAMC" when no options are given,
  2936.                       and since specifying the "M" option to any ".M" command
  2937.                       uses "CS:EIP" for the default, ".M" is the same as ".MAMC
  2938.                       CS:EIP".
  2939.  
  2940.  
  2941.   MEMORY CONTEXT RECORD DUMP
  2942.  
  2943.                       o    .MC[B|C|F] [<hco|laddr>] | [<hco|laddr> L<number of
  2944.                           entries>]
  2945.  
  2946.                       This command displays the virtual memory manager's
  2947.                       context records.  If no handle or linear address is
  2948.                       given, the entire table is displayed.  If a linear
  2949.                       address is given, it is considered a pointer to a context
  2950.                       record.  One record or a range of records can be dis-
  2951.                       played.
  2952.  
  2953.                       The "B" option displays only busy (allocated) entries.
  2954.                       This is the default.
  2955.  
  2956.                       The "F" option displays only free (unallocated) entries.
  2957.  
  2958.                       The "C" option also follows context record chains and
  2959.                       displays them.
  2960.  
  2961.  
  2962.   MEMORY ALIAS RECORD DUMP
  2963.  
  2964.                       o    .ML[C] [<hal|laddr>] | [<hal|laddr> L<number of
  2965.                           entries>]
  2966.  
  2967.                       This command displays the virtual memory manager's alias
  2968.                       records.  If no handle or linear address is given, the
  2969.                       entire table is displayed.  If a linear address is given,
  2970.                       it is considered a pointer to an alias record.  One
  2971.                       record or a range of records can be displayed.
  2972.  
  2973.                       The "B" option displays only busy (allocated) entries.
  2974.                       This is the default.
  2975.  
  2976.                       The "F" option displays only free (unallocated) entries.
  2977.  
  2978.                       The "C" option finds the corresponding object record, and
  2979.                       displays the arena, object, alias and context record
  2980.                       chains.
  2981.  
  2982.  
  2983.  
  2984.  
  2985.  
  2986.                                                    Kernel Debugger Commands  37
  2987.  
  2988.  
  2989.  
  2990.  
  2991.  
  2992.  
  2993.  
  2994.  
  2995.  
  2996.   MEMORY OBJECT RECORD DUMP
  2997.  
  2998.                       o    .MO[B|C|F|M|N|P|S|V] [<hob|laddr>] | [<hob|laddr>
  2999.                           L<number of entries>]
  3000.  
  3001.                       This command displays the virtual memory manager's memory
  3002.                       object records.  If no handle or linear address is given,
  3003.                       the entire table is displayed.  If a linear address is
  3004.                       given, it is considered a pointer to an object record.
  3005.                       One record or a range of records can be displayed.
  3006.  
  3007.                       This command attempts to display which process, MTE or
  3008.                       PTDA owns the segment.  It displays the owner as a short
  3009.                       ASCII string when appropriate.  It displays the PID of
  3010.                       the process and, if possible, the name of the module that
  3011.                       owns this segment.  Code segments normally have only the
  3012.                       module name and no process ID.  If the segment is an MTE,
  3013.                       PTDA or LDT, this command displays the object name, the
  3014.                       process ID (if the segment is a PTDA) and the module
  3015.                       name, if possible.
  3016.  
  3017.                       Here are a few examples of the owners that this command
  3018.                       can display:
  3019.  
  3020.                       Owner       Description
  3021.                       _____       ___________
  3022.  
  3023.                       FREE        Free memory
  3024.  
  3025.                       DEVHLP      Allocated by the AllocPhys devhlp
  3026.  
  3027.                       IDEVICE     Installable device driver memory
  3028.  
  3029.                       SYSTEM      System owned memory
  3030.  
  3031.                       DOSEXE      The initial memory arena when the operating
  3032.                                   system started.  This includes all of the
  3033.                                   system code and data segments.
  3034.  
  3035.                       MTE         A module table entry
  3036.  
  3037.                       PTDA        A per task data arena
  3038.  
  3039.                       LDT         A local descriptor table
  3040.  
  3041.                       If it only has a PID or a module name, then this piece of
  3042.                       memory is owned by the process or module.
  3043.  
  3044.                       The "B" option causes in-use (busy) object records to be
  3045.                       displayed.
  3046.  
  3047.                       The "F" option causes free object records to be dis-
  3048.                       played.
  3049.  
  3050.  
  3051.  
  3052.  
  3053.   38  OS/2 Kernel Debugger
  3054.  
  3055.  
  3056.  
  3057.  
  3058.  
  3059.  
  3060.  
  3061.  
  3062.  
  3063.                       The "C" option displays the arena, object, alias and
  3064.                       context record chains.
  3065.  
  3066.                       The "M" option causes all pseudo object records with an
  3067.                       exactly matching linear address to be displayed.  A
  3068.                       linear address must also be given, and no count is
  3069.                       allowed.  If a selector address type is used, it must be
  3070.                       converted to a linear address on the command line.  A
  3071.                       physical address may be given instead of a linear address
  3072.                       to allow non-present linear addresses to get past the
  3073.                       debugger's expression analyzer.
  3074.  
  3075.                       The "N" option causes non-pseudo object records to be
  3076.                       displayed.
  3077.  
  3078.                       The "P" option causes pseudo object records to be dis-
  3079.                       played.
  3080.  
  3081.                       The "S" option causes object records with the semaphore
  3082.                       busy or wanted to be displayed.
  3083.  
  3084.                       The "V" option causes object record linear addresses to
  3085.                       be displayed.  It also disables the owner interpretation.
  3086.  
  3087.  
  3088.   MEMORY PAGE FRAME DUMP
  3089.  
  3090.                       o    .MP[B|F|H|L|R|S] [<frame|laddr>] | [<frame|laddr>
  3091.                           L<number of entries>]
  3092.  
  3093.                       This command displays the page manager's page frame
  3094.                       structures.  If no handle or linear address is given, the
  3095.                       entire table is displayed.  If a linear address is given,
  3096.                       it is considered a pointer to a page frame structure.
  3097.                       One record or a range of records can be displayed.
  3098.  
  3099.                       The "B" option displays only busy (allocated) entries.
  3100.                       This is the default.
  3101.  
  3102.                       The "F" option displays only free (unallocated) entries.
  3103.  
  3104.                       The "H" option follows hash links, displaying entries.
  3105.  
  3106.                       The "L" option follows forward links, displaying entries.
  3107.  
  3108.                       The "R" option follows reverse links, displaying entries.
  3109.  
  3110.                       This data structure contains per-physical-page informa-
  3111.                       tion.  To find out the owner of a particular physical
  3112.                       page, issue ".MP FrameNumber", where FrameNumber is the
  3113.                       physical address shifted right by 12 bits (take off 3 hex
  3114.                       zeros).  If the page is not free, the "pVP" field con-
  3115.                       tains a flat pointer to the virtual page structure.
  3116.                       Issue ".MV %pVP", where pVP is the value from the .MP
  3117.  
  3118.  
  3119.                                                    Kernel Debugger Commands  39
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127.  
  3128.  
  3129.                       dump, to get the contents of the VP.  The "Hob" field of
  3130.                       the VP is a handle to the Object Record.  Issue ".MO Hob"
  3131.                       to dump it.  This displays a readable string for the
  3132.                       owner on the right of the display (see the .MO command).
  3133.                       Issuing the .MA command for the "Har" field in the object
  3134.                       record gives the base virtual address of the object con-
  3135.                       taining the page (under "va").  Use the "HobPg" field of
  3136.                       the VP to get the page offset within the object.
  3137.  
  3138.  
  3139.   MEMORY VIRTUAL PAGE STRUCTURE DUMP
  3140.  
  3141.                       o    .MV[B|F|L|R] [<vpid|laddr>] | [<swapid|laddr>
  3142.                           L<number of entries>]
  3143.  
  3144.                       This command displays the swap manager's swap frame
  3145.                       structures.  If no handle or linear address is given, the
  3146.                       entire table is displayed.  If a linear address is given,
  3147.                       it is considered a pointer to a swap frame structure.
  3148.                       One record or a range of records can be displayed.
  3149.  
  3150.                       See the .MP command for an example.
  3151.  
  3152.                       The "B" option displays only busy (allocated) entries.
  3153.                       This is the default.
  3154.  
  3155.                       The "F" option displays only free (unallocated) entries.
  3156.  
  3157.                       The "L" option follows forward links, displaying entries.
  3158.  
  3159.                       The "R" option follows reverse links, displaying entries.
  3160.  
  3161.  
  3162.   PRINT PROCESS STATUS
  3163.  
  3164.                       o    .P[B|U] [<slot> | # | *]
  3165.  
  3166.                       This command displays the current status of the process
  3167.                       and thread.  The asterisk (*) by the slot number means
  3168.                       the currently executing task or the last task to have
  3169.                       blocked.  The number sign (#) marks what the debugger
  3170.                       thinks the current task is (set by the .S command).  If
  3171.                       "#", "*", or a slot number is used on the command line,
  3172.                       only the corresponding slot's information is displayed.
  3173.  
  3174.                       Without the "B" or "U" option, this command prints the
  3175.                       PID, parent PID, command subtree number, thread number,
  3176.                       state, priority, block ID, PTDA address, TCB offset, dis-
  3177.                       patch ESP, screen group and name of the process or
  3178.                       thread.
  3179.  
  3180.                       The "B" option displays the detailed blocked information.
  3181.                       The HANDLESEM entry is for the current virtual memory
  3182.                       manager handle semaphores owned by this process.  The
  3183.  
  3184.  
  3185.   40  OS/2 Kernel Debugger
  3186.  
  3187.  
  3188.  
  3189.  
  3190.  
  3191.  
  3192.  
  3193.  
  3194.  
  3195.                       CHILD entry is for a child process that is being exe-
  3196.                       cuted.  It is printed after all the threads in the exe-
  3197.                       cuting task (and their HANDLESEM entries) have been
  3198.                       printed.
  3199.  
  3200.                       The "U" option displays user state information, which
  3201.                       includes the CS:EIP and SS:ESP at the time the kernel was
  3202.                       entered, along with the number of arguments that were
  3203.                       passed, their PTDA offset, and the offset of the register
  3204.                       stack frame.
  3205.  
  3206.  
  3207.   USER REGISTER
  3208.  
  3209.                       o    .R [<slot> | # | *]
  3210.  
  3211.                       The .R command displays the contents of the user's CPU
  3212.                       registers, flags, and the next instruction to be executed
  3213.                       for a specified slot.  This is for the user at the time
  3214.                       of entry to the kernel.
  3215.  
  3216.                       If no parameter is given, or if "#" is on the command
  3217.                       line, the debugger's current slot (selected by the .S
  3218.                       command) is used.  If "*" is on the command line, the
  3219.                       currently scheduled slot (or the last one to block) is
  3220.                       used.  Alternatively, if there is a number on the command
  3221.                       line, it is taken as the slot to use.
  3222.  
  3223.  
  3224.   REBOOT
  3225.  
  3226.                       o    .REBOOT
  3227.  
  3228.                       This command warm-starts the machine.  The whole string
  3229.                       ".REBOOT" must be typed.
  3230.  
  3231.  
  3232.   TASK CONTEXT CHANGE
  3233.  
  3234.                       o    .S[S] [<slot> | *]
  3235.  
  3236.                       This command changes what the debugger thinks the current
  3237.                       task context is.  If no slot number is passed, it prints
  3238.                       the current task number.  This allows dumping of some
  3239.                       process-specific data (the LDT or stack) for other than
  3240.                       the current task.  The "S" option also changes the SS and
  3241.                       ESP to the new task's PTDA selector and dispatch ESP
  3242.                       value.  The original SS and ESP are automatically
  3243.                       restored when the debugger exits, or when the ".SS"
  3244.                       command is used to switch back to the current task.  The
  3245.                       "*" slot number changes the debugger's current task
  3246.                       number to the real system task number.
  3247.  
  3248.  
  3249.  
  3250.  
  3251.                                                    Kernel Debugger Commands  41
  3252.  
  3253.  
  3254.  
  3255.  
  3256.  
  3257.  
  3258.  
  3259.  
  3260.  
  3261.   RAS TRACE BUFFER PRINT
  3262.  
  3263.                       o    .T [<count>] [maj=<xx> [min=<yy>]]
  3264.  
  3265.                       This command dumps the RAS trace buffer, optionally
  3266.                       dumping only events with the specified major and minor
  3267.                       event codes.
  3268.  
  3269.  
  3270.  
  3271.  
  3272.  
  3273.  
  3274.  
  3275.  
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298.  
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304.  
  3305.  
  3306.  
  3307.  
  3308.  
  3309.  
  3310.  
  3311.  
  3312.  
  3313.  
  3314.  
  3315.  
  3316.  
  3317.   42  OS/2 Kernel Debugger
  3318.  
  3319.  
  3320.  
  3321.  
  3322.  
  3323.  
  3324.  
  3325.  
  3326.  
  3327.   ADVANCED KERNEL DEBUGGER TECHNIQUES
  3328.   ___________________________________
  3329.  
  3330.  
  3331.  
  3332.  
  3333.  
  3334.  
  3335.  
  3336.   SETTING USEFUL BREAKPOINTS
  3337.  
  3338.                       There are many things that can be done when you use a
  3339.                       combination of these debugger commands.  You can easily
  3340.                       set up the debugger to stop at a certain label, print
  3341.                       information about the current system millisecond, current
  3342.                       process, and executing file, and then continue.  For
  3343.                       example, this would be very useful in analyzing the per-
  3344.                       formance of a subsystem .DLL.  Another example is to set
  3345.                       a breakpoint on a file-read label in the file system, and
  3346.                       dump information about which file is being read, where it
  3347.                       is being read from, how much of the file is being read,
  3348.                       and who is reading it.
  3349.  
  3350.                       In order to do this, you must know some internal informa-
  3351.                       tion about the kernel and other system components, such
  3352.                       as labels of various Application Program Interface (API)
  3353.                       functions or worker routines.
  3354.  
  3355.                       One way to keep some release independence is to base
  3356.                       breakpoints from function labels with an offset.  These
  3357.                       change much less often than the linear addresses of the
  3358.                       functions.  An example is as follows:
  3359.  
  3360.                               BP _LDRGetMte + 63 "DA %EDX L EAX + 1; G"
  3361.  
  3362.  
  3363.                       This command places a breakpoint at the symbol
  3364.                       _LDRGetMte, offset by hex 63.  Whenever that breakpoint
  3365.                       is hit, the debugger dumps (in ASCII) the memory at the
  3366.                       linear address stored in register EDX, for a length con-
  3367.                       tained in register EAX plus one byte.  The program then
  3368.                       continues executing.
  3369.  
  3370.                       Of course this offset within the function may change, but
  3371.                       it is easier to find the new offset if it does than to
  3372.                       use linear addresses for your breakpoints.
  3373.  
  3374.                       The effect of this breakpoint is to display the name of
  3375.                       any executable file (for example, with file types .EXE,
  3376.                       .DLL, or .SYS) that is started with DosExecPgm,
  3377.                       DosStartSession, or DosLoadModule, or imported from any
  3378.                       other executable file.  This is very useful when debug-
  3379.                                                       ____
  3380.                       ging problems in applications.
  3381.  
  3382.  
  3383.  
  3384.  
  3385.                                         Advanced Kernel Debugger Techniques  43
  3386.  
  3387.  
  3388.  
  3389.  
  3390.  
  3391.  
  3392.  
  3393.  
  3394.  
  3395.                       A breakpoint that can help you profile your code to see
  3396.                       how often you are taking page faults on pieces of code is
  3397.                       as follows:
  3398.  
  3399.                       1.   Unassemble at the label _ldrgetpage for approxi-
  3400.                           mately 30 instructions
  3401.  
  3402.                       2.   Look for a call to _ldrvalidatemtehandle
  3403.  
  3404.                       3.   Set a breakpoint on the instruction immediately fol-
  3405.                           lowing that call (where execution would go upon
  3406.                           return from the call) as follows:
  3407.  
  3408.                         bp %address ".lm %eax;g"
  3409.  
  3410.  
  3411.                       This breakpoint will cause the loader to display the name
  3412.                       of the code module (DLL or EXE) that code is being read
  3413.                       from. This of course needs to be looked at in perspec-
  3414.                       tive. For example, all code that is ever executed is ref-
  3415.                       erenced at least once (the first time it is loaded).
  3416.                       However, if you are seeing excessively long code load
  3417.                       times and a large amount of what looks to be thrashing,
  3418.                       you may want to look here. Also, if you have code
  3419.                       residing on remote drives, you may want to look here to
  3420.                       see how much you are hitting the code on the remote drive
  3421.                       to possible reconfigure it.
  3422.  
  3423.                       A breakpoint you can use to profile (timestamp test) your
  3424.                       code is:
  3425.  
  3426.                           BP xxxxxx "DD SISData+4 L1;g"
  3427.  
  3428.                           where xxxxxx is the address or label you wish to profile.
  3429.  
  3430.  
  3431.                       This breakpoint will give you a runnin millisecond
  3432.                       counter in hexadecimal. If you want to tell the time it
  3433.                       takes between two points in the code, add this to the
  3434.                       breakpoints and the time will be displayed when it hits
  3435.                       the points. This will help in narrowing down the slow
  3436.                       area of code. Be careful when analyzing the results,
  3437.                       however, as although the timer is reported in millisec-
  3438.                       onds, it is only updated every 16 milliseconds.
  3439.  
  3440.                       Another useful breakpoint is one that tells you what
  3441.                       kernel calls you are executing. There is a routine called
  3442.                       "sci" that is used in all OS/2 kernel calls. By setting
  3443.                       the following breakpoint you can have it report what
  3444.                       kernel calls you are making.
  3445.  
  3446.                         bp sci+d4 "ln cs:bp+4;g"
  3447.  
  3448.  
  3449.  
  3450.  
  3451.   44  OS/2 Kernel Debugger
  3452.  
  3453.  
  3454.  
  3455.  
  3456.  
  3457.  
  3458.  
  3459.  
  3460.  
  3461.                       This breakpoint says to break on sci+d4 and list the near
  3462.                       symbol representing the name of the kernel call. This is
  3463.                       more effective than just stopping and listing near
  3464.                       symbols because this displays just the name of the
  3465.                       routine and makes tracing a series of kernel calls much
  3466.                       easier.
  3467.  
  3468.                        If you need to look into the functions dealing with the
  3469.                       graphics engine (especially if you are writing a Presen-
  3470.                       tation Driver such as a printer or display driver) you
  3471.                       can set the following breakpoint:
  3472.  
  3473.                           bp dispatch32
  3474.  
  3475.  
  3476.                       This breakpoint is in PMGRE.DLL. When this breakpoint is
  3477.                       hit, you should look at the return address. Then, unas-
  3478.                       semble at that address MINUS approximately 20 bytes. What
  3479.                       you are looking for is the first doubleword pushed onto
  3480.                       the stack before the call. This should be the doubleword
  3481.                       representing the command flags and the engine function
  3482.                       number.  The command flags are the high order word and
  3483.                       the function number is the low order word of the
  3484.                       doubleword. You could look at the stack frame to get
  3485.                       this, but since this is the first dword pushed, it is the
  3486.                       last dword in the frame due to the 32 bit calling con-
  3487.                       ventions. Since the DDI stack frames are variable sized,
  3488.                       you may have to do some searching to find the end of the
  3489.                       frame. You can do this too, but unassembling before the
  3490.                       call works just as well and may be easier.
  3491.  
  3492.                       For 16-bit presentation drivers, you would want to set
  3493.                       the breakpoint as follows:
  3494.  
  3495.                          bp dispatch16
  3496.  
  3497.  
  3498.                       Since the 16-bit calling conventions put the function
  3499.                       number first, you can simply look at the stack frame on
  3500.                       this one.
  3501.  
  3502.                       Another useful breakpoint is as follows:
  3503.  
  3504.                               BP _LDRNewExe "G %(DW(SS:ESP)); DD _pgSwappablePages L 3; G"
  3505.  
  3506.  
  3507.                       This command places a breakpoint at the symbol
  3508.                       _LDRNewExe.  When that breakpoint is reached, the program
  3509.                       continues executing until the caller is returned to.  The
  3510.                       debugger then displays the number of pages of swappable
  3511.                       memory in the system, followed by the number of fixed
  3512.                       (resident) pages, followed by the number of pages of
  3513.                       discardable memory (read-only or execute-only pages).
  3514.                       The program then continues executing.
  3515.  
  3516.  
  3517.                                         Advanced Kernel Debugger Techniques  45
  3518.  
  3519.  
  3520.  
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526.  
  3527.                       The effect of this breakpoint is to display the hex
  3528.                       number of pages that are in use by the whole system after
  3529.                       every executable program is started.
  3530.  
  3531.                       The term "G %(DW(SS:ESP))" means "Go (G) to the linear
  3532.                       address (%) that is the doubleword (DW) at the top of the
  3533.                       stack (SS:ESP) and stop".  The operators "WO" and "BY"
  3534.                       are similar to "DW".  "WO" means "word," and "BY" means
  3535.                       "byte."  This type of setup can be useful when displaying
  3536.                       parameters for a function call as well, for example:
  3537.  
  3538.                               BP _LdrOpenNewExe "DA %(DW(SS:ESP+4)); G"
  3539.  
  3540.  
  3541.                       When this breakpoint is executed, the debugger dumps
  3542.                       ASCII (DA) starting at the linear address (%) given in
  3543.                       the doubleword (DW) at SS:ESP plus 4 bytes (the
  3544.                       doubleword at the top of the stack is the address for
  3545.                       _LdrOpenNewExe to return to).  The program then continues
  3546.                       executing.
  3547.  
  3548.                       The effect of this breakpoint is to display (in ASCII)
  3549.                       the name of every executable loaded module that actually
  3550.                       opens a file.  The difference between this breakpoint and
  3551.                       the one given earlier is that the earlier one displays
  3552.                       the names even if the module was attached to instead of
  3553.                                 _____________________________________________
  3554.                       newly opened and loaded.  This breakpoint only gives the
  3555.                       _______________________
  3556.                       newly opened names.  By setting both breakpoints and sub-
  3557.                       __________________
  3558.                       tracting the names, you can determine the imported
  3559.                       modules.
  3560.  
  3561.                       A series of commands that can be useful in determining
  3562.                       the amount of memory an application requires is as
  3563.                       follows:
  3564.  
  3565.                               .PU  (pick a thread that is in the process you wish to examine)
  3566.                               .SS n (where 'n' is the thread or slot number you picked)
  3567.                               DL   (list all valid LDT selectors (all 16-bit segments))
  3568.  
  3569.  
  3570.                       If the DL command listing stops with an address not
  3571.                       present or invalid, issue the ".ID x" command (where 'x'
  3572.                       is the address) and then the G (Go) command.  When the
  3573.                       system stops again, the LDT page will be present.
  3574.                       Reissue the ".SS n" and DL commands, and you will get a
  3575.                       more complete listing of the LDT selectors.  An example
  3576.                       of the output follows:
  3577.  
  3578.  
  3579.  
  3580.  
  3581.  
  3582.  
  3583.  
  3584.  
  3585.  
  3586.   46  OS/2 Kernel Debugger
  3587.  
  3588.  
  3589.  
  3590.  
  3591.  
  3592.  
  3593.  
  3594.  
  3595.  
  3596.                               # .PU
  3597.                                 ... (generates a lot of information like...)
  3598.                          Slot Pid  Ord  pPTDA    Name    pstkframe  CS:EIP        SS:ESP     cbargs
  3599.                          0012 0006 0012 7d31ccb0 FOO.EXE 7d102f50 d02f:00002501 0b3f:00007eee 0008
  3600.                          ...  ...  ...  ...      ...     ...      ...           ...           ...
  3601.  
  3602.                               # .SS 12
  3603.                               # DL
  3604.                                 ... (try it and stop at %7b176000...)
  3605.                               # .ID %7b176000
  3606.                                 task|addr 0012|7b176000 queued, g to continue
  3607.                               # G
  3608.                                 ... (stops at INT3 in tasking...)
  3609.                                 0170:fff629f4 cc             int     3
  3610.                               # .SS 12
  3611.                               # DL
  3612.                                 0007  Data    Bas=7b175000 Lim=0000ffff DPL=3 P  RO
  3613.                                 000f  Data    Bas=00010000 Lim=00001677 DPL=3 P  RW    A
  3614.                                 0017  Code    Bas=00020000 Lim=00003197 DPL=3 P  RE    A
  3615.                                 001f  Data    Bas=00030000 Lim=00001fff DPL=3 P  RW    A
  3616.                                 ...   ...     ...          ...          ...   .  ..    .
  3617.  
  3618.  
  3619.                       The first entry (0007 Data ...) points to the process'
  3620.                       LDT itself, and should not be counted when adding up the
  3621.                       amount of memory the application itself is using.
  3622.                       However, it is part of the system overhead that is used
  3623.                       for the process, and should be attributed as such.
  3624.  
  3625.                       The following breakpoints give you a great deal of infor-
  3626.                       mation about the startup of an application:
  3627.  
  3628.                       BP G_TKEXECPGM              "? 'ExecPgm'; G"
  3629.  
  3630.                       BP G_W_LOADMODULE           "? 'LoadModule'; G"
  3631.  
  3632.                       BP H_W_QAPPTYPE             "? 'QryApplType'; DA DS:DX;
  3633.                                                   G"
  3634.  
  3635.                       BP _LDRGETMTE + 63          "DA %EDX ; G"
  3636.  
  3637.                       BP _LDROPENNEWEXE           "DA %(DW(SS:ESP+4)) ;
  3638.                                                   G"
  3639.  
  3640.                       BP _LOAD_ERROR              "DD SS:ESP L 3; G"
  3641.  
  3642.                       BP H_W_GETPROCADDR          "? 'GetProcAddr'; G"
  3643.  
  3644.                       BP H_W_GETPROCADDR + 23     "? 'by ordinal'; ? DI; G"
  3645.  
  3646.                       BP H_W_GETPROCADDR + 25     "? 'by name'; DA AX:DI; G"
  3647.  
  3648.                       These nine breakpoints give the programmer using the
  3649.                       kernel debugger a great deal of information about how a
  3650.  
  3651.  
  3652.                                         Advanced Kernel Debugger Techniques  47
  3653.  
  3654.  
  3655.  
  3656.  
  3657.  
  3658.  
  3659.  
  3660.  
  3661.  
  3662.                       program loads and starts executing.  These breakpoints
  3663.                       can be placed into a KDB.INI file on a machine under test
  3664.                       to allow you to determine which binary files are loaded
  3665.                       and executed.  Please again note that these offsets may
  3666.                       change in subsequent releases of the OS/2 kernel and
  3667.                       loader.  Some of the possible types of files are the
  3668.                       following:
  3669.  
  3670.  
  3671.  
  3672.  
  3673.  
  3674.  
  3675.  
  3676.  
  3677.  
  3678.  
  3679.  
  3680.  
  3681.  
  3682.  
  3683.  
  3684.  
  3685.  
  3686.  
  3687.  
  3688.  
  3689.  
  3690.  
  3691.  
  3692.  
  3693.  
  3694.  
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700.  
  3701.  
  3702.  
  3703.  
  3704.  
  3705.  
  3706.  
  3707.  
  3708.  
  3709.  
  3710.  
  3711.  
  3712.  
  3713.  
  3714.  
  3715.  
  3716.  
  3717.  
  3718.   48  OS/2 Kernel Debugger
  3719.  
  3720.  
  3721.  
  3722.  
  3723.  
  3724.  
  3725.  
  3726.  
  3727.  
  3728.                       File Type   File
  3729.                       _________   ____
  3730.  
  3731.                       .DLL        Dynamic Link Library
  3732.  
  3733.                       .EXE        Executable program
  3734.  
  3735.                       .FON        Static Font File
  3736.  
  3737.                       .PSF        Dynamic Font File
  3738.  
  3739.                       .QPR        Queue Printer Driver
  3740.  
  3741.                       .PDR        Printer Driver
  3742.  
  3743.                       .SYS        Physical Device Driver
  3744.  
  3745.                       .VDD        Virtual Device Driver
  3746.  
  3747.                       The next two breakpoints inform the debugger that the
  3748.                       specified label was passed.  This allows you to interpret
  3749.                       the successive breakpoints accurately.
  3750.  
  3751.                         1.  bp g_tkExecPgm         "? 'DosExecPgm'; G"
  3752.                         2.  bp g_w_loadmodule   "? 'DosLoadModule'; G"
  3753.  
  3754.  
  3755.                       The next breakpoint prints the name of the routine being
  3756.                       executed, and prints the name of the file being queried.
  3757.  
  3758.                         3.  bp h_w_QAppType     "? 'DosQueryAppType'; DA DS:DX; G"
  3759.  
  3760.  
  3761.                       A program issues DosQueryAppType (QAT) when it has to
  3762.                       determine the application type of an executable file.
  3763.                       For example, when you type 'FREDDY' at a command prompt
  3764.                       and press Enter, the system program CMD.EXE has to find
  3765.                       out whether the file 'FREDDY' is a .EXE file, a .CMD
  3766.                       file, a .COM file, or some other type of file.
  3767.  
  3768.                       Some information can be derived from the file's exten-
  3769.                       sion.  The DOS command processor works this way.
  3770.                       However, you may still need to determine whether a .EXE
  3771.                       file is a DOS application, a 16-bit OS/2 Version 1.3
  3772.                       application, a 32-bit OS/2 Version 2.0 application, or a
  3773.                       Windows(**) application.  DosQueryAppType (QAT) attempts
  3774.                       to determine this in a way that is very similiar to what
  3775.                       happens when the program is actually loaded and executed.
  3776.  
  3777.                       Sometimes, DosQueryAppType (QAT) is issued to verify that
  3778.                       the file exists.  For example, SysInit (the thread that
  3779.  
  3780.   ---------------
  3781.  
  3782.   (**) Trademark of the Microsoft Corporation.
  3783.  
  3784.  
  3785.                                         Advanced Kernel Debugger Techniques  49
  3786.  
  3787.  
  3788.  
  3789.  
  3790.  
  3791.  
  3792.  
  3793.  
  3794.  
  3795.                       loads all the device drivers) has to determine whether a
  3796.                       device driver exists, and whether the file contains a
  3797.                       valid device driver.  SysInit issues DosQueryAppType
  3798.                       (QAT) for all of the BASEDEV= and DEVICE= statements in
  3799.                       the CONFIG.SYS file.
  3800.  
  3801.                       Sometimes, the QAT type does not need to open the file.
  3802.                       If the Shell queries the type of a file several times in
  3803.                       quick succession, the first QAT call determines the type
  3804.                       of the file, and then saves it for a few cycles.  If
  3805.                       another QAT call is made immediately for the same file,
  3806.                                                                    ____
  3807.                       the previously-determined type is returned.  This value
  3808.                       is cleared when any other file-system access is made,
  3809.                       such as when a file is deleted.
  3810.  
  3811.                       To see whether a file was actually opened for a loader or
  3812.                       tasking call, see breakpoint number 5.
  3813.  
  3814.                       Breakpoint number 4 prints the name of any file being
  3815.                       loaded, read, attached to, or otherwise referred to (for
  3816.                       example, imported) in the loader.
  3817.  
  3818.                         4.  bp _ldrGetMte + 63  "DA %EDX ; G"
  3819.  
  3820.  
  3821.                       If breakpoint number 1, 2, or 3 immediately precedes
  3822.                       breakpoint number 4, then breakpoint number 4 indicates
  3823.                       the name of the primary module being executed by
  3824.                       DosExecPgm, or loaded by DosLoadModule (DLM), or queried
  3825.                       by DosQueryAppType (QAT).  If breakpoint number 4 does
  3826.                       not follow one of the labelling breakpoints, then this
  3827.                       ___
  3828.                       indicates that a module is being imported.
  3829.                                                        ________
  3830.  
  3831.                       Breakpoint number 5 displays the name of any file being
  3832.                       opened for execution by the loader.  This breakpoint,
  3833.                       along with breakpoint number 6, allows the debugger to
  3834.                       find a large number of observed problems.
  3835.  
  3836.                         5.  bp _ldrOpenNewExe   "DA %(DW(SS:ESP+4)) ; G"
  3837.                         6.  bp _load_error         "DD SS:ESP L 3; G"
  3838.  
  3839.  
  3840.                       Breakpoint number 6 is the error handler for this area.
  3841.                       Many error codes are not returned through a base-pointer
  3842.                       chained stack frame through several levels of function
  3843.                       calls.  Instead, a special stack frame is created when
  3844.                       the loader is entered, and the stack offset to this frame
  3845.                       is preserved.  When an error occurs, _load_error() is
  3846.                       called with two parameters - error code and an optional
  3847.                       MTE handle.  In breakpoint number 6, the debugger dis-
  3848.                       plays the return address from where the error was
  3849.                       detected, the error code for what happened, and either a
  3850.                       zero or a module table entry (MTE) handle for where the
  3851.                       error was found.  File BSEERR.H contains the Control
  3852.  
  3853.  
  3854.   50  OS/2 Kernel Debugger
  3855.  
  3856.  
  3857.  
  3858.  
  3859.  
  3860.  
  3861.  
  3862.  
  3863.  
  3864.                       Program error codes.  Common error codes are 2
  3865.                       (ERROR_FILE_NOT_FOUND) and 193 (ERROR_BAD_EXE_FORMAT).
  3866.                       If an MTE handle is supplied, issue the '.lm[o] handle'
  3867.                       command to obtain more information.
  3868.  
  3869.                       After _load_error() finishes processing, it clears the
  3870.                       stack of everything above the special stack frame.  It
  3871.                       then returns directly to the original caller, without
  3872.                       executing any intervening code.  This is efficient, and
  3873.                       it avoids a large amount of error-handling code in each
  3874.                       function.
  3875.  
  3876.                       The next three breakpoints are used to determine what is
  3877.                       being retrieved from a .DLL after a successful call to
  3878.                       DosLoadModule (DLM).  Breakpoint number 7 displays the
  3879.                       label 'DosGetProcAddr', followed by information about the
  3880.                       .DLL being queried, including its name.
  3881.  
  3882.                       Breakpoint number 8 displays the ordinal number of the
  3883.                                                        ______________
  3884.                       code or data being sought in the .DLL.  Breakpoint number
  3885.                       9 displays the name of the code or data being sought in
  3886.                                      ____
  3887.                       the .DLL.  Breakpoints number 8 and 9 are mutually exclu-
  3888.                       sive.
  3889.  
  3890.                         7.  bp h_w_getprocaddr          "? 'DosGetProcAddr'; .LM EAX; G"
  3891.                         8.  bp h_w_getprocaddr + 23  "? 'by ordinal'; ? DI; G"
  3892.                         9.  bp h_w_getprocaddr + 25  "? 'by name'; DA AX:DI; G"
  3893.  
  3894.  
  3895.                       Breakpoints number 7, 8, and 9 do not tell you anything
  3896.                       about information that is being imported from a .DLL.  To
  3897.                                                       ________
  3898.                       do this, more information about the internal operation of
  3899.                       the loader is required.
  3900.  
  3901.                       The following is an example of using these breakpoints:
  3902.  
  3903.                       LoadModule
  3904.  
  3905.                       C:\OS2\DLL\TIMESNRM.PSF
  3906.                       43 3a 5c 4f 53 32 5c 44-4c 4c 5c 54 49 4d 45 53 C:\OS2\DLL\TIMESNRM.PSF.
  3907.                       QryApplType
  3908.  
  3909.                       C:\OS2\PMSHELL.EXE
  3910.                       43 3a 5c 4f 53 32 5c 50-4d 53 48 45 4c 4c 2e 45 C:\OS2\PMSHELL.EXE
  3911.                       QryApplType
  3912.  
  3913.                       04a8:00000002 C:\OS2\PMSHELL.EXE
  3914.                       QryApplType
  3915.  
  3916.                       04a8:00000002 C:\OS2\PMSHELL.EXE
  3917.                       ExecPgm
  3918.  
  3919.                       C:\OS2\PMSHELL.EXE
  3920.                       LoadModule
  3921.  
  3922.  
  3923.                                         Advanced Kernel Debugger Techniques  51
  3924.  
  3925.  
  3926.  
  3927.  
  3928.  
  3929.  
  3930.  
  3931.  
  3932.  
  3933.  
  3934.                       BVSCALLS
  3935.                       GetProcAddr
  3936.  
  3937.                       by ordinal
  3938.  
  3939.                       0003H 3T 3Q 0000000000000011Y '.' TRUE
  3940.                       LoadModule
  3941.  
  3942.                       PMSDMRI
  3943.                       LoadModule
  3944.  
  3945.                       C:\OS2\DLL\PMATM.DLL
  3946.                       GetProcAddr
  3947.  
  3948.                       by name
  3949.  
  3950.                       04a8:00000002 FONT_DRIVER_DISPATCH_TABLE
  3951.                       LoadModule
  3952.  
  3953.                       DISPLAY
  3954.                       LoadModule
  3955.  
  3956.                       C:\OS2\DLL\DISPLAY.DLL
  3957.                       LoadModule
  3958.  
  3959.                       PMCTLS
  3960.  
  3961.                       LoadModule
  3962.  
  3963.                       SPL1B
  3964.                       LoadModule
  3965.  
  3966.                       SPL1D
  3967.                       53 50 4c 31 44                                  SPL1D
  3968.                       0030:00006724  fff8b6c3 00000002 00000000 (this is what _load_error() displays)
  3969.  
  3970.  
  3971.   DEBUGGING KERNEL DEVICE DRIVERS
  3972.  
  3973.                       There are some structures in the kernel debugger that are
  3974.                       useful when you are debugging a kernel device driver.
  3975.                       You can issue the following commands to refer to these
  3976.                       structures.
  3977.  
  3978.                       o   .D DEV DS:0
  3979.  
  3980.                           This command displays the header of the device
  3981.                           driver.  It helps you determine which device driver
  3982.                           you are debugging.
  3983.  
  3984.                       o   .D REQ ES:BX
  3985.  
  3986.  
  3987.  
  3988.  
  3989.   52  OS/2 Kernel Debugger
  3990.  
  3991.  
  3992.  
  3993.  
  3994.  
  3995.  
  3996.  
  3997.  
  3998.  
  3999.                           This command displays the kernel request packet.
  4000.                           This packet is passed between the file system and a
  4001.                           kernel device driver.  Issue this command at the
  4002.                           strategy entry point or exit point of the device
  4003.                           driver.  This command helps you determine which
  4004.                           request the device driver has just finished proc-
  4005.                           essing, or is about to process.
  4006.  
  4007.                       o   .MAMC
  4008.  
  4009.                           This command displays the module name of the program
  4010.                           that is currently executing.  This helps you deter-
  4011.                           mine the owner of the process that trapped.
  4012.  
  4013.                       o   VSF*
  4014.  
  4015.                           This command sets the trap vectors.  This causes the
  4016.                           kernel debugger to stop at the instruction that is
  4017.                           about to cause a trap.
  4018.  
  4019.  
  4020.   DEBUGGING VM START SESSIONS
  4021.  
  4022.                       Before you begin kernel debugging in a VM Start session,
  4023.                       you must establish interrupt vectors 1 and 3 again.
  4024.                       Issue the command "DD %%0" to see what they should be,
  4025.                       and then issue the commands to set them to their correct
  4026.                       values, for example:
  4027.  
  4028.                                   E &0:4 12 67 00 1d
  4029.                                   E &0:c 57 67 00 1d
  4030.  
  4031.  
  4032.                       To debug a trap 6 or incorrect-output problem, set a
  4033.                       breakpoint at the "VMINT21" entry point.
  4034.  
  4035.                       You can find the segment of FSFILTER by looking at the
  4036.                       "INT 20h" or "INT 21h" vectors (0:80 and 0:84, respec-
  4037.                       tively).  The offset of "VMINT21" is hex 330.  Trace
  4038.                       through all of the "INT 21" calls until the error is
  4039.                       observed.  Run the test again to the last successful "INT
  4040.                       21", then begin stepping through the code until the error
  4041.                       is found.
  4042.  
  4043.                       A method of eliminating FSFILTER as the component with
  4044.                       the problem is to set up a test case that executes from
  4045.                       the diskette.  This way, you can execute a VM Start
  4046.                       session without installing FSFILTER.  If the problem
  4047.                       still occurs, then FSFILTER is not the cause of the
  4048.                       problem.
  4049.  
  4050.  
  4051.  
  4052.  
  4053.  
  4054.  
  4055.                                         Advanced Kernel Debugger Techniques  53
  4056.  
  4057.  
  4058.  
  4059.  
  4060.  
  4061.  
  4062.  
  4063.  
  4064.  
  4065.   DEBUGGING CMD.EXE
  4066.  
  4067.                       A problem that appears to be in CMD.EXE is usually
  4068.                       located in a different program.  Due to the way the
  4069.                       kernel debugger works, CMD.EXE symbols are often shown
  4070.                       when they should not be.  This can happen when a trap
  4071.                       occurs in an application that was started from the
  4072.                       command prompt.
  4073.  
  4074.                       You can issue a List Near Symbol (LN) command at the
  4075.                       debug terminal.  However, there are probably no symbols
  4076.                       for the application, so the kernel debugger displays the
  4077.                       closest symbols.  These symbols are usually from CMD.EXE
  4078.                       (the parent process).
  4079.  
  4080.                       Therefore, you should first issue the Print Process
  4081.                       Status (.P #) command.  This command shows which process
  4082.                       actually trapped.  If the line does not show "CMD" on the
  4083.                       right-hand side, the program that trapped is not CMD.EXE.
  4084.  
  4085.  
  4086.  
  4087.  
  4088.  
  4089.  
  4090.  
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096.  
  4097.  
  4098.  
  4099.  
  4100.  
  4101.  
  4102.  
  4103.  
  4104.  
  4105.  
  4106.  
  4107.  
  4108.  
  4109.  
  4110.  
  4111.  
  4112.  
  4113.  
  4114.  
  4115.  
  4116.  
  4117.  
  4118.  
  4119.  
  4120.  
  4121.   54  OS/2 Kernel Debugger
  4122.  
  4123.  
  4124.  
  4125.  
  4126.  
  4127.  
  4128.  
  4129.  
  4130.  
  4131.   SETUP FOR REMOTE DEBUGGING
  4132.   __________________________
  4133.  
  4134.  
  4135.  
  4136.  
  4137.  
  4138.                       The OS/2 kernel debugger allows you to diagnose a problem
  4139.                       quickly if you have access to the computer that has the
  4140.                       problem.  Installing a modem on the target system allows
  4141.                       you to call it by telephone, and to communicate with the
  4142.                       system.
  4143.  
  4144.                       This chapter assumes that you have installed the OS/2
  4145.                       debug kernel on your system.  Although the debug kernel
  4146.                       works with almost any modem, this chapter describes
  4147.                       installation of the IBM(*) 5853 modem operating at 2400
  4148.                       bits per second (bps).
  4149.  
  4150.  
  4151.   ITEMS REQUIRED TO SET UP A SYSTEM FOR REMOTE DEBUGGING
  4152.   ______________________________________________________
  4153.  
  4154.                       To complete the installation, you need the following:
  4155.  
  4156.                       o   A target system with both the retail kernel and the
  4157.                           debug kernel
  4158.  
  4159.                       o   An IBM 5853 modem
  4160.  
  4161.                       o   A modem data cable
  4162.  
  4163.                       o   An analog dial-in telephone line
  4164.  
  4165.                       o   Communications software
  4166.  
  4167.  
  4168.   TARGET SYSTEM
  4169.  
  4170.                       The target system is the computer that has the problem to
  4171.                           _____________
  4172.                       be debugged.  This computer should have the debug kernel
  4173.                       and symbols installed on it.  If you configure the modem
  4174.                       using the target system, you may want to do this before
  4175.                                                                        ______
  4176.                       you install the debug kernel.  The kernel debugger inter-
  4177.                       feres with communications programs that use the same
  4178.                       serial port.  If you have another computer available, you
  4179.                       can configure the modem on that computer, and then move
  4180.                       the modem to the target system.
  4181.  
  4182.  
  4183.  
  4184.  
  4185.  
  4186.  
  4187.  
  4188.  
  4189.  
  4190.  
  4191.                                                  Setup for Remote Debugging  55
  4192.  
  4193.  
  4194.  
  4195.  
  4196.  
  4197.  
  4198.  
  4199.  
  4200.  
  4201.   IBM 5853 MODEM
  4202.  
  4203.                       This modem is a synchronous (V.25bis) and asynchronous
  4204.                       (V.22bis) modem with built-in error correction and speed
  4205.                       buffering.  The speed buffering feature is especially
  4206.                       helpful for remote debugging, since it allows the kernel
  4207.                       debugger to communicate at 9600 bps, regardless of the
  4208.                       true modem speed.  This allows you to restart the kernel
  4209.                       without requiring an operator at the local console to
  4210.                       reset the 'dte' baud rate.  The MNP-3 error correction
  4211.                       prevents transmission errors from interfering with the
  4212.                       debugging session if the modem at the other end also sup-
  4213.                       ports MNP-3 error correction.  These features make the
  4214.                       IBM 5853 modem a good choice for remote debugging.
  4215.  
  4216.  
  4217.   MODEM DATA CABLE
  4218.  
  4219.                       The configuration of the cable used to connect the IBM
  4220.                       5853 modem to the target system is not important.  Any
  4221.                       serial data cable should have the connections required by
  4222.                       the debug kernel.  Make sure that you do not use a null-
  4223.                                                                          _____
  4224.                       modem cable.  You will need either a 25-to-25 pin cable
  4225.                       _____
  4226.                       (for connection to the built-in serial port on a PS/2(*)
  4227.                       system), or a 25-to-9 pin cable (for connection to a
  4228.                       dual-asynchronous card).
  4229.  
  4230.  
  4231.  
  4232.  
  4233.  
  4234.  
  4235.  
  4236.  
  4237.  
  4238.  
  4239.  
  4240.  
  4241.  
  4242.  
  4243.  
  4244.  
  4245.  
  4246.  
  4247.  
  4248.  
  4249.  
  4250.  
  4251.  
  4252.  
  4253.  
  4254.   ---------------
  4255.  
  4256.   (*) Trademark of the IBM Corporation.
  4257.  
  4258.  
  4259.   56  OS/2 Kernel Debugger
  4260.  
  4261.  
  4262.  
  4263.  
  4264.  
  4265.  
  4266.  
  4267.  
  4268.  
  4269.                       The required connections for the remote debug cable are
  4270.                       as follows:
  4271.  
  4272.   +----------------------------------+      +----------------------------------+
  4273.   |                                  |      |                                  |
  4274.   |          MODEM        COMPUTER   |      |          MODEM        COMPUTER   |
  4275.   |          DB25P         DB25J     |      |          DB25P         DB9J      |
  4276.   |                                  |      |                                  |
  4277.   |           +-+           +-+      |      |           +-+           +-+      |
  4278.   |           |2|-----------|2|      |      |           |2|-----------|3|      |
  4279.   |           |3|-----------|3|      |      |           |3|-----------|2|      |
  4280.   |           |7|-----------|7|      |      |           |7|-----------|5|      |
  4281.   |           +-+           +-+      |      |           +-+           +-+      |
  4282.   |                                  |      |                                  |
  4283.   +----------------------------------+      +----------------------------------+
  4284.   Figure 1. 25-to-25 Pin Cable              Figure 2. 25-to-9 Pin Cable
  4285.  
  4286.   Notice that the 25-to-9 pin cable reverses pins 2 and 3.  Do not confuse this
  4287.   with a null-modem cable, because the signals on a 25-to-9 pin cable are
  4288.   normally reversed.
  4289.  
  4290.  
  4291.   ANALOG DIAL-IN TELEPHONE LINE
  4292.  
  4293.   In order to call the modem and connect to the target computer, you need a
  4294.   standard voice-grade telephone line that can be dialed directly.  A con-
  4295.   nection can be made if the line must go through a switchboard, but this is
  4296.   more difficult for the person who is debugging the problem.  Digital tele-
  4297.   phone lines do not work with the modem.
  4298.  
  4299.  
  4300.   COMMUNICATIONS SOFTWARE
  4301.  
  4302.   Any terminal software that can communicate at 9600 bps is sufficient.  The
  4303.   OS/2 2.0 system comes with a program named Softerm Custom that is adequate
  4304.   for remote debugging.
  4305.  
  4306.  
  4307.   THE CONFIGURATION PROCESS
  4308.   _________________________
  4309.  
  4310.   After you have assembled the required items, follow these steps to prepare
  4311.   the target system for remote debugging:
  4312.  
  4313.   1.  RESET THE MODEM TO FACTORY DEFAULTS.
  4314.  
  4315.       Perform the following actions:
  4316.  
  4317.       a.  Turn off the modem.
  4318.  
  4319.       b.  Press and latch in all front panel switches.
  4320.  
  4321.       c.  Move all switches on the back of the modem to the Up/On position,
  4322.           except for switch number 4, which should be in the Down/Off position.
  4323.  
  4324.  
  4325.  
  4326.                                                  Setup for Remote Debugging  57
  4327.  
  4328.  
  4329.  
  4330.  
  4331.  
  4332.  
  4333.  
  4334.  
  4335.  
  4336.       d.  Turn on the modem.
  4337.  
  4338.       e.  Wait 5 seconds.
  4339.  
  4340.       f.  Turn off the modem.
  4341.  
  4342.       g.  Press and latch out all front panel switches, except the RL switch,
  4343.           which must be latched in.
  4344.                 ____
  4345.  
  4346.       The modem is now reset to its factory defaults, and is ready to be pro-
  4347.       grammed for remote debugging.
  4348.  
  4349.   2.  CONFIGURE THE MODEM FOR REMOTE DEBUGGING.
  4350.  
  4351.       Using the data cable, connect the modem to the system where the communi-
  4352.       cations software is installed.  If this is the target system, you should
  4353.       use the retail kernel to avoid a conflict with the communication port.
  4354.       Set the communications software for 9600 bps operation, and turn on the
  4355.       modem.
  4356.  
  4357.       Type START and press Enter.
  4358.  
  4359.       You must type START in uppercase.  The modem should respond with "IBM
  4360.       5853".  If it does not, turn off the modem, and then turn it on.  Check
  4361.       your cable connections, and try again.
  4362.  
  4363.  
  4364.  
  4365.  
  4366.  
  4367.  
  4368.  
  4369.  
  4370.  
  4371.  
  4372.  
  4373.  
  4374.  
  4375.  
  4376.  
  4377.  
  4378.  
  4379.  
  4380.  
  4381.  
  4382.  
  4383.  
  4384.  
  4385.  
  4386.  
  4387.  
  4388.  
  4389.  
  4390.  
  4391.  
  4392.  
  4393.   58  OS/2 Kernel Debugger
  4394.  
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.  
  4401.  
  4402.  
  4403.       When you see "IBM 5853", press the following keys and type the following
  4404.       commands:
  4405.  
  4406.       Key and command       System action
  4407.       _______________       _____________
  4408.  
  4409.       [CTRL+N]"OP 2=0"      Disable modem command responses
  4410.  
  4411.       [CTRL+N]"OP 15=1"     Answer the phone on ring 1
  4412.  
  4413.       [CTRL+N]"OP 27=7"     Set 'dte' speed to 9600 bps
  4414.  
  4415.       [CTRL+N]"SB 1"        Lock 'dte' speed
  4416.  
  4417.       [CTRL+N]"IT 0"        Disable inactivity timeout
  4418.  
  4419.       The sequence [Ctrl+N] means press and hold the Control (Ctrl) key and
  4420.       press N.  The first time you do this, the modem should respond with
  4421.       "<COM>".  These commands ensure that the modem answers incoming calls,
  4422.       and stays at 9600 bps regardless of the true modem speed.  Some of these
  4423.       commands are already set, but doing this again ensures they are set prop-
  4424.       erly in case factory defaults change.
  4425.  
  4426.       You may now turn off the modem and move it to the target system if you
  4427.       configured the modem on another system.  Turning off the modem does not
  4428.       erase the modem configuration.  The modem is configured properly for
  4429.       remote debugging until you reconfigure it.
  4430.  
  4431.       NOTE:  If you have a different modem, you can probably use it if you can
  4432.       configure the modem to do the following:
  4433.  
  4434.       o   Lock the 'dte' rate at 9600 bps.
  4435.  
  4436.       o   Answer the phone when it rings.
  4437.  
  4438.       o   Ignore the state of the 'dtr' signal; always treat the target com-
  4439.           puter as if it were ready to communicate.
  4440.  
  4441.       o   Use XON/XOFF as flow control between the modem and the target com-
  4442.           puter.
  4443.  
  4444.       o   Disable modem result codes (that is, do not send 'ring' or 'connect'
  4445.           messages when answering the telephone).
  4446.  
  4447.       Most V.22bis modems with MNP-5 or V.42 error correction can perform these
  4448.       functions.  Standard V.22bis modems (without error correction) such as
  4449.       the Hayes(**) Smartmodem 2400 cannot perform these functions because they
  4450.       do not support locked 9600 bps 'dte' speeds.  Consult the modem's manual
  4451.       for information about configuration.
  4452.  
  4453.   3.  CONNECT THE MODEM TO THE TARGET SYSTEM.
  4454.  
  4455.   ---------------
  4456.  
  4457.   (**) Trademark of Hayes Microcomputer Products, Inc.
  4458.  
  4459.  
  4460.                                                  Setup for Remote Debugging  59
  4461.  
  4462.  
  4463.  
  4464.  
  4465.  
  4466.  
  4467.  
  4468.  
  4469.  
  4470.       After you have configured the modem, connect one end of the data cable to
  4471.       the modem, and connect the other end to the serial port on the target
  4472.       system.  If the target system has more than one serial port, connect the
  4473.       cable to the port that is configured as COM2.  Use the PS/2 reference
  4474.       diskette to determine which port is configured as COM2.  Connect the
  4475.       telephone line to the modem, and turn on the modem.  The remote debug
  4476.       system is ready.
  4477.  
  4478.   When the modem phone rings, the answering modem attempts to establish an
  4479.   error-free connection with the calling modem .  If the calling modem does not
  4480.   support MNP, a normal connection is made.  You can tell that the connection
  4481.   is error-free if the ECL light on the modem blinks.  The person at the system
  4482.   with the calling modem is then able to perform all remote debugging func-
  4483.   tions, including remote restart of the system to be debugged.  Since the
  4484.   modem always stays at 9600 bps, there is no need to reset the debugger speed
  4485.   locally.
  4486.  
  4487.  
  4488.   LIMITATIONS OF THIS SETUP
  4489.  
  4490.   Since the modem communicates with the target system at 9600 bps, but can only
  4491.   communicate with the remote modem at 2400 bps, the modem must use flow
  4492.   control to avoid data overruns.  The only flow control supported by the debug
  4493.   kernel is XON/XOFF.  The only time this causes a problem is when the remote
  4494.   user wants to create a pause in a continuous data display by pressing Ctrl+S.
  4495.   If the modem has also sent a Ctrl+S signal, the signal from the user is
  4496.   ignored.  You may have to press Ctrl+S several times before the display
  4497.   pauses.  This is not a problem if the remote user's communication program
  4498.   supports a "scroll-back buffer," because then there is no reason to create a
  4499.   pause in the display by pressing Ctrl+S.
  4500.  
  4501.  
  4502.   PROBLEM DETERMINATION
  4503.  
  4504.   If you cannot establish a remote debugging connection after following these
  4505.   instructions, this table may help:
  4506.  
  4507.  
  4508.  
  4509.  
  4510.  
  4511.  
  4512.  
  4513.  
  4514.  
  4515.  
  4516.  
  4517.  
  4518.  
  4519.  
  4520.  
  4521.  
  4522.  
  4523.  
  4524.  
  4525.  
  4526.   60  OS/2 Kernel Debugger
  4527.  
  4528.  
  4529.  
  4530.  
  4531.  
  4532.  
  4533.  
  4534.  
  4535.  
  4536.   +---------------------------------------------------------------------------+
  4537.   | Table 3. Problem Determination for Remote Setup                           |
  4538.   +------------------------+-------------------------+------------------------+
  4539.   | SYMPTOM                | PROBLEM                 | SOLUTION               |
  4540.   +------------------------+-------------------------+------------------------+
  4541.   | Calling modem hears    | No modem power.         | Plug in the modem      |
  4542.   | the phone ring, but    |                         | power cord, and turn   |
  4543.   | you hear nothing from  |                         | on the power switch.   |
  4544.   | the modem.             +-------------------------+------------------------+
  4545.   |                        | Telephone line is not   | Plug the telephone     |
  4546.   |                        | connected to the modem. | line into the modem.   |
  4547.   +------------------------+-------------------------+------------------------+
  4548.   | Modem rings, but does  | RL switch is not        | Latch in the RL switch |
  4549.   | not answer.            | latched in.             | on the front of the    |
  4550.   |                        |                         | modem.                 |
  4551.   +------------------------+-------------------------+------------------------+
  4552.   | Modem answers, but     | Retail kernel is        | Remove the retail      |
  4553.   | there is no response   | installed.              | kernel and install the |
  4554.   | from the debug kernel. |                         | debug kernel.          |
  4555.   |                        +-------------------------+------------------------+
  4556.   |                        | Data cable is not con-  | Connect the data cable |
  4557.   |                        | nected properly.        | from the modem to the  |
  4558.   |                        |                         | target system.  Plug   |
  4559.   |                        |                         | the data cable into    |
  4560.   |                        |                         | the COM2 port if the   |
  4561.   |                        |                         | target system has more |
  4562.   |                        |                         | than one serial port.  |
  4563.   +------------------------+-------------------------+------------------------+
  4564.   | User at the remote     | Modem is not locked at  | Perform modem config-  |
  4565.   | modem sees "garbage"   | 9600 bps.               | uration again.         |
  4566.   | on the screen, and is  +-------------------------+------------------------+
  4567.   | unable to control the  | Debug kernel is not     | Use the local debug    |
  4568.   | debugging session.     | operating at 9600 bps.  | console to send the    |
  4569.   |                        |                         | command ".B 9600t" to  |
  4570.   |                        |                         | the kernel, or restart |
  4571.   |                        |                         | the target system.     |
  4572.   +------------------------+-------------------------+------------------------+
  4573.  
  4574.  
  4575.  
  4576.  
  4577.  
  4578.  
  4579.  
  4580.  
  4581.  
  4582.  
  4583.  
  4584.  
  4585.  
  4586.  
  4587.  
  4588.  
  4589.  
  4590.  
  4591.  
  4592.                                                  Setup for Remote Debugging  61
  4593.  
  4594.  
  4595.  
  4596.  
  4597.  
  4598.  
  4599.  
  4600.  
  4601.  
  4602.  
  4603.  
  4604.  
  4605.  
  4606.  
  4607.  
  4608.  
  4609.  
  4610.  
  4611.  
  4612.  
  4613.  
  4614.  
  4615.  
  4616.  
  4617.  
  4618.  
  4619.  
  4620.  
  4621.  
  4622.  
  4623.  
  4624.  
  4625.  
  4626.  
  4627.  
  4628.  
  4629.  
  4630.  
  4631.  
  4632.  
  4633.  
  4634.  
  4635.  
  4636.  
  4637.  
  4638.  
  4639.  
  4640.  
  4641.  
  4642.  
  4643.  
  4644.  
  4645.  
  4646.  
  4647.  
  4648.  
  4649.  
  4650.  
  4651.  
  4652.  
  4653.  
  4654.  
  4655.  
  4656.  
  4657.  
  4658.   62  OS/2 Kernel Debugger
  4659.  
  4660.  
  4661.  
  4662.  
  4663.  
  4664.  
  4665.  
  4666.  
  4667.  
  4668.   APPENDIX A.  SAMPLE DEBUGGING SESSION
  4669.   _____________________________________
  4670.  
  4671.  
  4672.  
  4673.  
  4674.  
  4675.                       This example shows a deadlock.  Slot #42 waits on a
  4676.                       VMGetSem semaphore that slot #37 owns, and slot #37 waits
  4677.                       on a KSEMRequestExclusive semaphore that slot #42 owns.
  4678.  
  4679.                       Start to display current processes and threads status
  4680.                       with the detailed blocked information.
  4681.  
  4682.  
  4683.  
  4684.  
  4685.  
  4686.  
  4687.  
  4688.  
  4689.  
  4690.  
  4691.  
  4692.  
  4693.  
  4694.  
  4695.  
  4696.  
  4697.  
  4698.  
  4699.  
  4700.  
  4701.  
  4702.  
  4703.  
  4704.  
  4705.  
  4706.  
  4707.  
  4708.  
  4709.  
  4710.  
  4711.  
  4712.  
  4713.  
  4714.  
  4715.  
  4716.  
  4717.  
  4718.  
  4719.  
  4720.  
  4721.  
  4722.  
  4723.  
  4724.  
  4725.                                       Appendix A.  Sample Debugging Session  63
  4726.  
  4727.  
  4728.  
  4729.  
  4730.  
  4731.  
  4732.  
  4733.  
  4734.  
  4735.                         ##.pb
  4736.                          Slot  Sta BlockID  Name     Type        Addr    Symbol
  4737.                          0001  blk fff1a894 *ager
  4738.                          0002  blk fff82124 *tsd                         _tkTSDDaemon
  4739.                          0003  blk fff4c850 *ctxh                        _kmCTXHDaemon
  4740.                          0004  blk fff825f1 *kdb                         _tkKDBDaemon
  4741.                          0005  blk fff0c820 *lazyw                       _semLW
  4742.                          0006  blk fff19770 *asyncr                      _AsyncReadSem
  4743.                          0009  blk fffe000f pmshell  RamSem    0743:06ac
  4744.                          0008  blk fffe0004 pmshell  RamSem    bf3f:0066
  4745.                          000b  blk ffca0002 pmshell
  4746.                          000c  blk fffd000c pmshell  MuxWait
  4747.                          000d  blk fffd000d pmshell  MuxWait
  4748.                          000e  blk 04000a72 pmshell  DosSem    0400:0a72 CtrlNumLkQ
  4749.                          0007  blk fffe0008 pmshell  RamSem    d1a7:028e HSEMINIRUN
  4750.                          0011  blk fffe000a pmshell  RamSem    d0c7:0020
  4751.                          0012  blk fffd0012 pmshell  MuxWait
  4752.                          0013  blk fffe000c pmshell  RamSem    d09f:0ba0 memory_pool + 127
  4753.                          0014  blk fffe000e pmshell  RamSem    d09f:0ba8 memory_pool + 12f
  4754.                          0015  blk fffd0015 pmshell  MuxWait
  4755.                          0016  blk fffe000b pmshell  RamSem    d147:00d8 FSRSUSER + 10
  4756.                         *0017# blk 04000a64 pmshell  DosSem    0400:0a64 SMHotKeyQ
  4757.                          0018  blk fffe000b pmshell  RamSem    d147:00d8 FSRSUSER + 10
  4758.                          0019  blk fffe0011 pmshell  RamSem    0743:06c8
  4759.                          000a  blk 04000a80 harderr  DosSem    0400:0a80 HardErrPkt
  4760.                          Slot  Sta BlockID  Name     Type        Addr    Symbol
  4761.                          000f  blk 04000d94 harderr  DosSem    0400:0d94 CtrlPrtScQ
  4762.                          0010  blk 04000db4 harderr  DosSem    0400:0db4 VideoPauseFlag
  4763.                          001a  blk fffe000b pmshell  RamSem    d147:00d8
  4764.                          001b  blk fe92c2a8 pmshell  Sem32     8001 0009
  4765.                          001c  blk fffe0015 pmshell  RamSem    be5f:0a2c
  4766.                          001d  blk 0f280012 pmshell                      hash_table + ??
  4767.                          001e  blk 0f30000e pmshell                      profile_records + ??
  4768.                          0020  blk 0f400012 pmshell
  4769.                          0021  blk fffe0017 pmshell  RamSem    d0c7:0088
  4770.                          0022  blk fffe0016 pmshell  RamSem    0743:06d8
  4771.                          001f  blk ffca0005 !cmd
  4772.                          0023  blk fffe003d switch   RamSem    a8af:0004
  4773.                          0024  blk fe90dff4 testlog
  4774.                          0025  blk fffd0025 switch   MuxWait
  4775.                          0026  blk fffe003a switch   RamSem    a8af:0008
  4776.                          0027  blk fffe0031 switch   RamSem    a8af:000c
  4777.                          0028  blk fffe003f switch   RamSem    a8af:0010
  4778.                          0029  blk fffe003c switch   RamSem    a8af:0014
  4779.                          002a  blk fffe0043 switch   RamSem    a8af:0018
  4780.                          002b  blk fffe0041 switch   RamSem    a8af:001c
  4781.                          002c  blk fffe0048 switch   RamSem    a8af:0020
  4782.                          002d  blk fffe0047 switch   RamSem    a8af:0024
  4783.                          002e  blk fffe0042 switch   RamSem    a8af:0028
  4784.                          Slot  Sta BlockID  Name     Type        Addr    Symbol
  4785.                          0035  blk fee6c060 testlog2
  4786.                          0037  blk fe90dfe0 cube32
  4787.                          0038  blk fffe0187 clock32  RamSem    0743:06dc
  4788.                          0042  blk fee6c060 clock32
  4789.  
  4790.  
  4791.   64  OS/2 Kernel Debugger
  4792.  
  4793.  
  4794.  
  4795.  
  4796.  
  4797.  
  4798.  
  4799.  
  4800.  
  4801.                          003b  blk fe90dff4 testlog2
  4802.                          003e  blk fffe000b !gp2 RamSem    d147:00d8 FSRSUSER + 10
  4803.                          003f  blk fe90dff4 testlog2
  4804.                          0041  blk fe90dff4 testlog2
  4805.  
  4806.  
  4807.                       Use the command to switch back to a task that is blocked on the FSRUSER
  4808.                       semaphore. We change the debuggers current task number to the real OS2 task
  4809.                       number #3e.
  4810.  
  4811.  
  4812.                         ##.ss 3e
  4813.                         ##.pb#
  4814.                          Slot  Sta BlockID  Name     Type        Addr    Symbol
  4815.                          003e# blk fffe000b !gp2 RamSem    d147:00d8 FSRSUSER + 10
  4816.  
  4817.  
  4818.                       Display the FastRam Semaphore structure to find out who owns it.
  4819.  
  4820.  
  4821.                         ##dw d147:d8 - e l10
  4822.                         d147:000000ca  0000 0046 0002 0001 0000 ffff ffff 0101
  4823.                         d147:000000da  000b 0000 0000 0000 0000 0000 0000 ffff
  4824.  
  4825.                         typedef struct _DOSFSRSEM ñ     /* dosfsrs */
  4826.                             USHORT  cb;         0000
  4827.                             PID     pid;        0046
  4828.                             TID     tid;        0002
  4829.                             USHORT  cUsage;     0001
  4830.                             USHORT  client;     0000
  4831.                             ULONG   sem;        ffffffff
  4832.                         ç DOSFSRSEM;
  4833.  
  4834.  
  4835.  
  4836.                       Display the processes and threads status to find the slot number of process
  4837.                       #46 and thread #2.
  4838.  
  4839.  
  4840.  
  4841.  
  4842.  
  4843.  
  4844.  
  4845.  
  4846.  
  4847.  
  4848.  
  4849.  
  4850.  
  4851.  
  4852.  
  4853.  
  4854.  
  4855.  
  4856.  
  4857.                                       Appendix A.  Sample Debugging Session  65
  4858.  
  4859.  
  4860.  
  4861.  
  4862.  
  4863.  
  4864.  
  4865.  
  4866.  
  4867.                         ##.p
  4868.                          Slot  Pid  Ppid Csid Ord  Sta Pri  pTSD     pPTDA    pTCB     Disp SG Name
  4869.                          0001  0001 0000 0000 0001 blk 0100 ffe44000 ffe468d4 ffe46728 1e7c 00 *ager
  4870.                          0002  0001 0000 0000 0002 blk 0100 7cc02000 ffe468d4 fd109020 1f3c 00 *tsd
  4871.                          0003  0001 0000 0000 0003 blk 0200 7cc04000 ffe468d4 fd1091cc 1f50 00 *ctxh
  4872.                          0004  0001 0000 0000 0004 blk 081f 7cc06000 ffe468d4 fd109378 1f48 00 *kdb
  4873.                          0005  0001 0000 0000 0005 blk 081f 7cc08000 ffe468d4 fd109524 1f20 00 *lazyw
  4874.                          0006  0001 0000 0000 0006 blk 081f 7cc0a000 ffe468d4 fd1096d0 1f3c 00 *asyncr
  4875.                          0009  0002 0001 0002 0001 blk 0500 7cc10000 fd13f020 fd109bd4 1eac 01 pmshell
  4876.                          0008  0002 0001 0002 0002 blk 0800 7cc0e000 fd13f020 fd109a28      01 pmshell
  4877.                          000b  0002 0001 0002 0003 blk 0800 7cc14000 fd13f020 fd109f2c      01 pmshell
  4878.                          000c  0002 0001 0002 0004 blk 0800 7cc16000 fd13f020 fd10a0d8      01 pmshell
  4879.                          000d  0002 0001 0002 0005 blk 0800 7cc18000 fd13f020 fd10a284      01 pmshell
  4880.                          000e  0002 0001 0002 0006 blk 0800 7cc1a000 fd13f020 fd10a430      01 pmshell
  4881.                          0007  0002 0001 0002 0007 blk 0800 7cc0c000 fd13f020 fd10987c 1eac 01 pmshell
  4882.                          0011  0002 0001 0002 0008 blk 0200 7cc20000 fd13f020 fd10a934      01 pmshell
  4883.                          0012  0002 0001 0002 0009 blk 0200 7cc22000 fd13f020 fd10aae0      01 pmshell
  4884.                          0013  0002 0001 0002 000a blk 0800 7cc24000 fd13f020 fd10ac8c      01 pmshell
  4885.                          0014  0002 0001 0002 000b blk 0800 7cc26000 fd13f020 fd10ae38      01 pmshell
  4886.                          0015  0002 0001 0002 000c blk 0800 7cc28000 fd13f020 fd10afe4 1e9c 01 pmshell
  4887.                          0016  0002 0001 0002 000d blk 0500 7cc2a000 fd13f020 fd10b190 1eac 01 pmshell
  4888.                         *0017  0002 0001 0002 000e blk 0804 7cc2c000 fd13f020 fd10b33c 1ea4 01 pmshell
  4889.                          0018  0002 0001 0002 000f blk 0500 7cc2e000 fd13f020 fd10b4e8 1eac 01 pmshell
  4890.                          0019  0002 0001 0002 0010 blk 0200 7cc30000 fd13f020 fd10b694      01 pmshell
  4891.                          000a  0003 0002 0003 0001 blk 0800 7cc12000 fd13f74c fd109d80      00 harderr
  4892.                          Slot  Pid  Ppid Csid Ord  Sta Pri  pTSD     pPTDA    pTCB     Disp SG Name
  4893.                          000f  0003 0002 0003 0002 blk 0800 7cc1c000 fd13f74c fd10a5dc      00 harderr
  4894.                          0010  0003 0002 0003 0003 blk 0800 7cc1e000 fd13f74c fd10a788      00 harderr
  4895.                          001a  0004 0002 0004 0001 blk 0500 7cc32000 fd13fe78 fd10b840 1eac 10 pmshell
  4896.                          001b  0004 0002 0004 0002 blk 0200 7cc34000 fd13fe78 fd10b9ec      10 pmshell
  4897.                          001c  0004 0002 0004 0003 blk 0200 7cc36000 fd13fe78 fd10bb98      10 pmshell
  4898.                          001d  0004 0002 0004 0004 blk 0200 7cc38000 fd13fe78 fd10bd44      10 pmshell
  4899.                          001e  0004 0002 0004 0005 blk 0200 7cc3a000 fd13fe78 fd10bef0      10 pmshell
  4900.                          0020  0004 0002 0004 0007 blk 0800 7cc3e000 fd13fe78 fd10c248      10 pmshell
  4901.                          0021  0004 0002 0004 0008 blk 011f 7cc40000 fd13fe78 fd10c3f4      10 pmshell
  4902.                          0022  0004 0002 0004 0009 blk 0800 7cc42000 fd13fe78 fd10c5a0      10 pmshell
  4903.                          001f  0005 0002 0005 0001 blk 0200 7cc3c000 fd1405a4 fd10c09c      04 !cmd
  4904.                          0023  001f 0002 001f 0001 blk 021f 7cc44000 fd141b28 fd10c74c      11 switch
  4905.                          0024  001e 001d 001e 0001 blk 0214 7cc46000 fd140cd0 fd10c8f8 1df8 04 testlog
  4906.                          0025  001d 0005 001d 0001 blk 0214 7cc48000 fd1413fc fd10caa4 1e9c 04 switch
  4907.                          0026  0020 0002 0020 0001 blk 021f 7cc4a000 fd142254 fd10cc50 1eac 12 switch
  4908.                          0027  0021 0002 0021 0001 blk 021f 7cc4c000 fd142980 fd10cdfc 1eac 13 switch
  4909.                          0028  0022 0002 0022 0001 blk 021f 7cc4e000 fd1430ac fd10cfa8 1eac 14 switch
  4910.                          0029  0023 0002 0023 0001 blk 021f 7cc50000 fd1437d8 fd10d154 1eac 15 switch
  4911.                          002a  0024 0002 0024 0001 blk 021f 7cc52000 fd143f04 fd10d300 1eac 16 switch
  4912.                          002b  0025 0002 0025 0001 blk 021f 7cc54000 fd144630 fd10d4ac 1eac 17 switch
  4913.                          002c  0026 0002 0026 0001 blk 021f 7cc56000 fd144d5c fd10d658 1eac 18 switch
  4914.                          002d  0027 0002 0027 0001 blk 031f 7cc58000 fd145488 fd10d804 1eac 19 switch
  4915.                          002e  0028 0002 0028 0001 blk 021f 7cc5a000 fd145bb4 fd10d9b0      1a switch
  4916.                          Slot  Pid  Ppid Csid Ord  Sta Pri  pTSD     pPTDA    pTCB     Disp SG Name
  4917.                          0035  0042 0020 003d 0001 blk 030b 7cc68000 fd148de8 fd10e564 1dec 12 testlog2
  4918.                          0037  0043 0024 0043 0001 blk 050b 7cc6c000 fd149514 fd10e8bc 1d4c 16 cube32
  4919.                          0038  0046 0025 0046 0001 blk 020b 7cc6e000 fd14aa98 fd10ea68 1eac 17 clock32
  4920.                          0042  0046 0025 0046 0002 blk 050b 7cc82000 fd14aa98 fd10fb20 1d8a 17 clock32
  4921.  
  4922.  
  4923.   66  OS/2 Kernel Debugger
  4924.  
  4925.  
  4926.  
  4927.  
  4928.  
  4929.  
  4930.  
  4931.  
  4932.  
  4933.                          003b  0047 0043 0047 0001 blk 020b 7cc74000 fd14b1c4 fd10ef6c 1df8 16 testlog2
  4934.                          003e# 004a 0027 004a 0001 blk 050b 7cc7a000 fd14c748 fd10f470 1eac 19 !gp2
  4935.                          003f  004b 0046 004b 0001 blk 020b 7cc7c000 fd14ce74 fd10f61c 1df8 17 testlog2
  4936.                          0041  004e 004a 004e 0001 blk 030b 7cc80000 fd14dccc fd10f974 1df8 19 testlog2
  4937.  
  4938.  
  4939.                       Use the command to switch back to the task that owns the FSRUSER
  4940.                       semaphore. We change the debuggers current task number to the real OS2 task
  4941.                       number #42.
  4942.  
  4943.                       ##.ss 42
  4944.  
  4945.                       Get the stack backtrace of the thread #2 process #45
  4946.                       in this slot #42.
  4947.  
  4948.  
  4949.                         ##k
  4950.                         0170:fff80ac8 00000000 00006b50 00006c1a fff685a2 _TKSleep + 1a6
  4951.                         0170:fff685a2 fee6c060 ffffffff 00000000 00000000 _VMGetSem + 239
  4952.                         0170:fff63758 fff10005 00000085 7cc83e2a 7cc83eb6 _vmReserveSub + 338
  4953.                         0170:fff63322 00000010 14411016 00000000 fff1a2f4 _VMReserve + c8
  4954.                         0170:fff955dc 00000010 14411016 fd14aa98 00000000 _VMAllocMem + 2f4
  4955.                         0170:fff93926 00010000 000000e0 14411016 000008ba selwrk$g_selAllocSeg + 116
  4956.                         0170:000038b9 00000158 00006d68 004a6d6c 01587503
  4957.  
  4958.                       The first parameter of VmGetSem is a memory object 0005
  4959.                       We display the virtual memory manager-s memory object
  4960.                       records to find out who owns it.
  4961.  
  4962.  
  4963.                         ##.mo 5
  4964.                          hob       va     flgs own  hmte  sown,cnt lt st xf
  4965.                          0005  %fff1a2f4  8000 ffe1 0000  0037 03  00 00 00 vmah
  4966.  
  4967.                       The slot number 37 owns it, we switch to its context.
  4968.  
  4969.  
  4970.                         ##.ss 37
  4971.  
  4972.                         ##.p#
  4973.                          Slot  Pid  Ppid Csid Ord  Sta Pri  pTSD     pPTDA    pTCB     Disp SG Name
  4974.                          0037# 0043 0024 0043 0001 blk 050b 7cc6c000 fd149514 fd10e8bc 1d4c 16 cube32
  4975.  
  4976.                         ##.pb#
  4977.                          Slot  Sta BlockID  Name     Type        Addr    Symbol
  4978.                          0037# blk fe90dfe0 cube32
  4979.  
  4980.                       Get the stack backtrace of the thread #1 process #43 in this slot #37.
  4981.  
  4982.  
  4983.  
  4984.  
  4985.  
  4986.  
  4987.  
  4988.  
  4989.                                       Appendix A.  Sample Debugging Session  67
  4990.  
  4991.  
  4992.  
  4993.  
  4994.  
  4995.  
  4996.  
  4997.  
  4998.  
  4999.                         ##k
  5000.                         0170:fff80ac8 00000000 00006158 00006158 fff4fdb6 _TKSleep + 1a6
  5001.                         0170:fff4fdb6 fe90dfe0 ffffffff 00000000 00000001 _KSEMRequestExclusive + d6
  5002.                         0170:fff93b7b fe90dfd8 ffffffff 0000fec8 fed0b078 _SELRemDiscRec + 13
  5003.                         0170:fff91f66 00000781 7cc6de14 000061a8 fff66219 _SELFree + 5e
  5004.                         0170:fff66219 7cc6de14 7cc6de14 fee73820 13380000 _VMFreeMemOd + 149
  5005.                         0170:fff9773e 21000002 7cc6de14 0000559f fff1a2f4 _vmFreeAll + 11c
  5006.                         0170:fff97560 fff1a2f4 fd149514 00000000 fd149514 _VMFreeTask + 9d
  5007.                         0170:fff779e4 fd149514 fd144ba6 fe93d8c0 00000001 _LDRFreeTask + 10
  5008.                         0170:fff47ee3 fd149514 00006246 62e40158 8d480000 sproc4_LDRFreeTask + 1c
  5009.                         0170:fff86573 fd149514 00006304 fff86bb1 00030000 _tkExitList + 8b
  5010.                         0170:fff86bb1 00030000 00000000 7cc60003 00000000 _VRExitList + 26
  5011.                         0170:fff70e81 00000000 00000000 00000000 0000632c DOSEXITLIST + 15
  5012.  
  5013.                       We are waiting on a KSEMRequestExclusive semaphore that slot #42 owns.
  5014.  
  5015.                       ##.d ksem %fe90dfd8
  5016.                       Signature     : KSEM                        Nest: 0001
  5017.                       Type          : SHARE                    Readers: 0000
  5018.                       Flags         : 00                PendingReaders: 0000
  5019.                       Owner         : 0042              PendingWriters: 0001
  5020.  
  5021.  
  5022.  
  5023.  
  5024.  
  5025.  
  5026.  
  5027.  
  5028.  
  5029.  
  5030.  
  5031.  
  5032.  
  5033.  
  5034.  
  5035.  
  5036.  
  5037.  
  5038.  
  5039.  
  5040.  
  5041.  
  5042.  
  5043.  
  5044.  
  5045.  
  5046.  
  5047.  
  5048.  
  5049.  
  5050.  
  5051.  
  5052.  
  5053.  
  5054.  
  5055.   68  OS/2 Kernel Debugger
  5056.  
  5057.  
  5058.  
  5059.  
  5060.  
  5061.  
  5062.  
  5063.  
  5064.  
  5065.   INDEX
  5066.   _____
  5067.  
  5068.  
  5069.  
  5070.  
  5071.  
  5072.      +--------------------+                 commands (continued)
  5073.      | SPECIAL CHARACTERS |                    .LM  35
  5074.      +--------------------+                    .MA  36
  5075.                                                .MC  37
  5076.   .MAP files  8                                .ML  37
  5077.   .SYM files  8                                .MO  38
  5078.                                                .MP  39
  5079.                                                .MV  40
  5080.      +---+                                     .P  40
  5081.      | A |                                     .R  41
  5082.      +---+                                     .REBOOT  41
  5083.                                                .S  41
  5084.   Add Active Map (WA) command  23              .T  42
  5085.   AllStrict kernel  1                          BC  17
  5086.                                                BD  17
  5087.                                                BE  17
  5088.      +---+                                     BL  17
  5089.      | B |                                     BP  15
  5090.      +---+                                     BR  16
  5091.                                                BS  17
  5092.   backtrace  12                                BT  16
  5093.   Breakpoint (B) commands  15                  C  17
  5094.   breakpoint, sticky  15                       D  17
  5095.   breakpoint, temporary  15                    DA  17
  5096.   breakpoints, useful  43                      DB  18
  5097.                                                DD  18
  5098.                                                DG  18
  5099.      +---+                                     DI  18
  5100.      | C |                                     DL  18
  5101.      +---+                                     DP  18
  5102.                                                DT  19
  5103.   CMD.EXE, debugging  54                       DW  18
  5104.   COM Port Baud Rate (.B) command  33          DX  20
  5105.   COM1 port  1                                 E  20
  5106.   COM2 port  1, 11                             F  21
  5107.   commands                                     G  21
  5108.      ?  22                                     H  22
  5109.      .?  33                                    I  22
  5110.      .B  33                                    J  23
  5111.      .C  33                                    K  24
  5112.      .D  34                                    LA  23
  5113.      .I  34                                    LG  23
  5114.      .IT  34                                   LM  23
  5115.      .K  35                                    LN  22
  5116.  
  5117.  
  5118.  
  5119.  
  5120.  
  5121.  
  5122.                                                                       Index  69
  5123.  
  5124.  
  5125.  
  5126.  
  5127.  
  5128.  
  5129.  
  5130.  
  5131.  
  5132.   commands (continued)                         +---+
  5133.      LS  23                                    | F |
  5134.      M  24                                     +---+
  5135.      O  25
  5136.      P  25                                  files, map  9
  5137.      R  26                                  files, symbol  8
  5138.      S  28                                  FILL (F) command  21
  5139.      T  28                                  FSFILTER  53
  5140.      U  29
  5141.      VC  31
  5142.      VL  30                                    +---+
  5143.      VS  30                                    | G |
  5144.      VT  30                                    +---+
  5145.      WA  23
  5146.      WR  23                                 GO (G) command  21
  5147.      Y  31
  5148.      Z  32
  5149.      ZL  32                                    +---+
  5150.      ZS  32                                    | H |
  5151.   commands, kernel debugger  15                +---+
  5152.   COMPARE (C) command  17
  5153.   Conditional Execution (J)                 Help (.?) command  33
  5154.    command  23                              Help/Print Expression (?)
  5155.   conventions  2                             command  22
  5156.                                             HEX (H) command  22
  5157.                                             HStrict kernel  1
  5158.      +---+
  5159.      | D |
  5160.      +---+                                     +---+
  5161.                                                | I |
  5162.   DEBUG debugger  1                            +---+
  5163.   Debugger Option (Y) command  31
  5164.   Default Command Lines  32                 initialization file  3
  5165.   device drivers, debugging  52             INPUT (I) command  22
  5166.   DUMP (D) commands  17                     INT 20h  53
  5167.   Dump ABIOS Common Data Area (.C)          INT 21h  53
  5168.    command  33                              Interrupt and Trap Vector
  5169.   Dump OS/2 Data Structures (.D)             commands  30
  5170.    command  34
  5171.  
  5172.                                                +---+
  5173.      +---+                                     | K |
  5174.      | E |                                     +---+
  5175.      +---+
  5176.                                             KDB.INI  3
  5177.   ENTER (E) command  20                     kernel debugger commands  15
  5178.   entering the debugger  2                  keywords  4
  5179.   expressions  3
  5180.   external debugger commands  33
  5181.  
  5182.  
  5183.  
  5184.  
  5185.  
  5186.  
  5187.  
  5188.   70  OS/2 Kernel Debugger
  5189.  
  5190.  
  5191.  
  5192.  
  5193.  
  5194.  
  5195.  
  5196.  
  5197.  
  5198.      +---+                                     +---+
  5199.      | L |                                     | O |
  5200.      +---+                                     +---+
  5201.  
  5202.   List Absolute Symbols (LA)                operators, binary  5
  5203.    command  23                              operators, precedence order  5
  5204.   List Groups (LG) command  23              operators, unary  6
  5205.   List Maps (LM) command  23                OUTPUT (O) command  25
  5206.   List Near Symbol (LN) command  22
  5207.   List Symbols (LS) commands  23
  5208.                                                +---+
  5209.                                                | P |
  5210.      +---+                                     +---+
  5211.      | M |
  5212.      +---+                                  Print MTE Segment Table (.LM)
  5213.                                              command  35
  5214.   map files  9                              Print Process Status (.P)
  5215.   MAPSYM utility  8                          command  40
  5216.   Memory Alias Record Dump (.ML)            PTRACE (P) command  25
  5217.    command  37
  5218.   Memory Arena Record Dump (.MA)
  5219.    command  36                                 +---+
  5220.   Memory Context Record Dump (.MC)             | R |
  5221.    command  37                                 +---+
  5222.   Memory Object Record Dump (.MO)
  5223.    command  38                              RAS Trace Buffer Print (.T)
  5224.   Memory Page Frame Dump (.MP)               command  42
  5225.    command  39                              REBOOT (.REBOOT) command  41
  5226.   Memory Virtual Page Structure Dump        REGISTER (R) command  26
  5227.    (.MV) command  40                        remote debugging  1
  5228.   MOVE (M) command  24                      Remove Active Map (WR) command  23
  5229.                                             request packet, kernel  53
  5230.                                             retail kernel  1
  5231.      +---+
  5232.      | N |
  5233.      +---+                                     +---+
  5234.                                                | S |
  5235.   NMI (non-maskable interrupt)                 +---+
  5236.    switch  3
  5237.   non-maskable interrupt (NMI)              SEARCH (S) command  28
  5238.    switch  3                                Stack Trace (K) command  24
  5239.   numbers, base of  7                       strings, character  8
  5240.                                             Swap in TSD or Page commands  34
  5241.                                             symbol files  8
  5242.                                             symbols  2
  5243.                                             SYMDEB debugger  1, 5
  5244.  
  5245.  
  5246.  
  5247.  
  5248.  
  5249.  
  5250.  
  5251.  
  5252.  
  5253.  
  5254.                                                                       Index  71
  5255.  
  5256.  
  5257.  
  5258.  
  5259.  
  5260.  
  5261.  
  5262.  
  5263.  
  5264.      +---+
  5265.      | T |
  5266.      +---+
  5267.  
  5268.   Task Context Change (.S) command  41
  5269.   TRACE (T) command  28
  5270.   trap vectors  53
  5271.  
  5272.  
  5273.      +---+
  5274.      | U |
  5275.      +---+
  5276.  
  5277.   UNASSEMBLE (U) command  29
  5278.   User Register (.R) command  41
  5279.   User Stack Trace (.K) command  35
  5280.  
  5281.  
  5282.      +---+
  5283.      | V |
  5284.      +---+
  5285.  
  5286.   Virtual Page (VP) structure  19
  5287.   VM Start sessions, debugging  53
  5288.   VMINT21  53
  5289.  
  5290.  
  5291.  
  5292.  
  5293.  
  5294.  
  5295.  
  5296.  
  5297.  
  5298.  
  5299.  
  5300.  
  5301.  
  5302.  
  5303.  
  5304.  
  5305.  
  5306.  
  5307.  
  5308.  
  5309.  
  5310.  
  5311.  
  5312.  
  5313.  
  5314.  
  5315.  
  5316.  
  5317.  
  5318.  
  5319.  
  5320.   72  OS/2 Kernel Debugger
  5321.  
  5322.  
  5323.  
  5324.  
  5325.  
  5326.  
  5327. +++EDF002W DOCPROF tag found outside PROLOG. (Page 0  File:
  5328. KDEBUG SCRIPT)
  5329. DSMMOM397I '.EDF#CNTX' WAS IMBEDDED AT LINE 3 OF 'KDEBUG'
  5330. +++EDF154E Value of COLS or CWIDTHS attribute on the TABLE t
  5331. ag exceeds page width. (Page 7  File: KDEBUG SCRIPT)
  5332. DSMMOM397I '.EDFTABL' WAS IMBEDDED AT LINE 495 OF 'KDEBUG'
  5333. DSMLBR529E 'KP' WOULD EXCEED MAXIMUM SIZE.
  5334. DSMMOM395I 'KDEBUG' LINE 3078: .LB
  5335. DSMLBR529E 'KP' WOULD EXCEED MAXIMUM SIZE.
  5336. DSMMOM395I 'KDEBUG' LINE 3171: .LB
  5337. DSMBEG323I STARTING PASS 2 OF 2.
  5338. +++EDF002W DOCPROF tag found outside PROLOG. (Page 0  File:
  5339. KDEBUG SCRIPT)
  5340. DSMMOM397I '.EDF#CNTX' WAS IMBEDDED AT LINE 3 OF 'KDEBUG'
  5341. +++EDF154E Value of COLS or CWIDTHS attribute on the TABLE t
  5342. ag exceeds page width. (Page 7  File: KDEBUG SCRIPT)
  5343. DSMMOM397I '.EDFTABL' WAS IMBEDDED AT LINE 495 OF 'KDEBUG'
  5344. DSMW32708E TEXT EXCEEDS RIGHT PAGE BOUNDARY ON PAGE 19.
  5345. DSMW32708E TEXT EXCEEDS RIGHT PAGE BOUNDARY ON PAGE 44.
  5346. DSMW32708E TEXT EXCEEDS RIGHT PAGE BOUNDARY ON PAGE 45.
  5347. DSMW32708E TEXT EXCEEDS RIGHT PAGE BOUNDARY ON PAGE 46.
  5348. DSMW32708E TEXT EXCEEDS RIGHT PAGE BOUNDARY ON PAGE 47.
  5349. DSMW32708E TEXT EXCEEDS RIGHT PAGE BOUNDARY ON PAGE 49.
  5350. DSMW32708E TEXT EXCEEDS RIGHT PAGE BOUNDARY ON PAGE 51.
  5351. DSMW32708E TEXT EXCEEDS RIGHT PAGE BOUNDARY ON PAGE 52.
  5352. DSMLBR529E 'KP' WOULD EXCEED MAXIMUM SIZE.
  5353. DSMMOM395I 'KDEBUG' LINE 3078: .LB
  5354. DSMW32708E TEXT EXCEEDS RIGHT PAGE BOUNDARY ON PAGE 64.
  5355. DSMLBR529E 'KP' WOULD EXCEED MAXIMUM SIZE.
  5356. DSMMOM395I 'KDEBUG' LINE 3171: .LB
  5357. DSMW32708E TEXT EXCEEDS RIGHT PAGE BOUNDARY ON PAGE 65.
  5358. DSMW32708E TEXT EXCEEDS RIGHT PAGE BOUNDARY ON PAGE 66.
  5359. DSMW32708E TEXT EXCEEDS RIGHT PAGE BOUNDARY ON PAGE 67.
  5360. DSMW32708E TEXT EXCEEDS RIGHT PAGE BOUNDARY ON PAGE 68.
  5361.  
  5362.  
  5363.  
  5364.  
  5365.  
  5366.  
  5367.  
  5368.  
  5369.  
  5370.  
  5371.  
  5372.  
  5373.  
  5374.  
  5375.  
  5376.  
  5377.  
  5378.  
  5379.  
  5380.  
  5381.  
  5382.  
  5383.  
  5384.  
  5385.  
  5386.  
  5387.  
  5388.  
  5389.  
  5390.