/*static char *SCCSID = "@(#)ptcheck.c  6.9 92/03/29";*/

#define SCCSID "@(#)ptcheck.c   6.9 92/03/29"

/***    PTCHECK.C - DosDebug calls for DosPTrace
 *
 *      SCCSID = @(#)ptcheck.c  6.9 92/03/29
 *
 *      THIS IS AN OS/2 VERSION 2.x SPECIFIC FILE
 *
 *       IBM/Microsoft Confidential
 *
 *       Copyright (c) IBM Corporation 1987, 1989
 *       Copyright (c) Microsoft Corporation 1987, 1989
 *
 *       All Rights Reserved
 *
 *      This will enable any 16-bit PTrace calls to be used on OS/2 2.0,
 *      and use the enhanced API calls of DBG32ApiDebug. DosCheck() performs the
 *      actual DBG32ApiDebug call, with the Debug buffer passed by pointer. After
 *      checking the return from the call, it will receive and log all
 *      notifications pending. This will avoid the stack overflow of multiple
 *      notifications pending throughout the user program.
 *
 *****************************************************************************
 *  Change                                                               Chg *
 *  Activity      Date    BY   Reason                                    Num *
 *  --------      ----    ---  -------                                   --- *
 *  DCR 1372    10/19/91  ARJ  Added for DOSPTRACE Support NEW           NEW *
 *  PTR B728776 11/17/91  ARJ  Return TRC_C_LIB_ret for first stop cmd   001 *
 *  PTR B730560 12/14/91  ARJ  Return TRC_C_GPF_ret for ACCESS VIOLATION 002 *
 *  PTR B731011 12/19/91  ARJ  ReSet xcpt_code for each exception        003 *
 *  PTR B731011 01/08/92  ARJ  Return DBG_N_ProcTerm for Process Dying   004 *
 *                             and DBG_N_AsyncStop for Asynchronous Stop 004 *
 *  PTR B735331 03/29/92  Edd  Move TmpBuff onto stack to make code re-entrant
 *  DFT 0046550 08/11/92  ARJ  Return orginal buffer with PID for        005 *
 *                             DBG_N_NewProc (fix for pmr 1E231)         005 *
 *                             DBG_N_AliasFree and DBG_N_CoError         005 *
 *  DFT 0000ARJ 08/11/92  ARJ  Return orginal command if error occurs on ARJ1*
 *                             DBG_N_ModuleFree, DBG_N_ThreadCreate or   ARJ1*
 *                             DBG_N_WatchPoint DosPtrace does handle    ARJ1*
 *****************************************************************************
 ****************************************************************************/
#define INCL_DOS
#define INCL_TYPES                  /* DRV_\H\basedef.h typedefs            */
#define INCL_ERRORS                 /* DRV_\H\bseerr.h  OS/2 error numbers  */
#define FOR_EXEHDR     1            /*                                      */
#define FNO_NUM     FNO_PTCHECK_C   /* DRV_\SRC\DOS\DOSINC\fnotask.h        */

#include <fnotask.h>                /* DRV_\SRC\DOS\DOSINC\                 */
#include <os2.h>                    /* DRV_\H\                              */
#include <osconst.h>                /* DRV_\SRC\DOS\DOSINC\                 */
#include <ostypes.h>                /* DRV_\SRC\DOS\DOSINC\                 */
#include <osmac.h>                  /*                                      */
#include <infoseg.h>                /* DRV_\H\                              */
#include <vmowner.h>                /* DRV_\SRC\DOS\DOSINC\                 */
#include <dossymc.h>                /* DRV_\SRC\DOS\DOSINC\                 */
#include <except.h>                 /* DRV_\SRC\DOS\DOSINC\                 */
#include <mi.h>                     /* DRV_\H\                              */
#include <pgexport.h>               /* DRV_\SRC\DOS\DOSINC\                 */
#include <vmexport.h>               /* DRV_\SRC\DOS\DOSINC\                 */
#include <selxport.h>               /* DRV_\SRC\DOS\DOSINC\                 */
#include <seldesc.h>                /* DRV_\H\                              */
#include <tkexport.h>               /* DRV_\SRC\DOS\DOSINC\                 */
#include <curdir.h>                 /* DRV_\SRC\DOS\DOSINC\                 */
#include <dirent.h>                 /* DRV_\SRC\DOS\DOSINC\                 */
#include <find.h>                   /* DRV_\SRC\DOS\DOSINC\                 */
#include <screen.h>                 /* DRV_\SRC\DOS\DOSINC\                 */
#include <sem.h>                    /* DRV_\SRC\DOS\DOSINC\                 */
#include <sigdef.h>
#include <tkptda.h>                 /* DRV_\SRC\DOS\DOSINC\                 */
#include <bseerr.h>                 /* DRV_\H\                              */
#include <tklocal.h>                /* DRV_\SRC\DOS\TASK\                   */
#include <proc.h>                   /* DRV_\SRC\DOS\DOSINC\                 */
#include <ptrace.h>                 /* DRV_\SRC\DOS\DOSINC\                 */
#include <sched.h>                  /* DRV_\SRC\DOS\DOSINC\                 */
#include <string.h>                 /* DRV_\H\  and  DRV_\H386\             */
#include <dbgex.h>                                                               // B729833
#include <dbgapi.h>

#ifdef PTSTRICT
extern PTBugBug;                                /* DosPtrace debug flag         */
#endif

#define kPDB_t  uDB_t

struct kPDB_Temp {
        unsigned long   Pid;            /* Debuggee Process id          */
        unsigned long   Tid;            /* Debuggee Thread id           */
        long            Cmd;            /* Command or Notification      */
        long            Value;          /* Generic Data Value           */
        unsigned long   Addr;           /* Debuggee Address             */
        unsigned long   Buffer;         /* Debugger Buffer Address      */
        unsigned long   Len;            /* Length of Range              */
        unsigned long   Index;          /* Generic Identifier Index     */
        unsigned long   MTE;            /* Module Table Entry Handle    */
};


ULONG  PTCheck(kPDB_t *);

extern ULONG DBG32ApiDebug(kPDB_t *,ulong_t);                                    // B729833


#if RAS
#pragma code_seg("DEBUGSWAP_TEXT", "CODE")      /* swap PTRACE code */
#endif

ULONG PTCheck(kPDB_t *DBuf)
{


    ULONG  Dbg_rc;
    ULONG  xcpt_code;
    struct kPDB_Temp TmpBuff;           /* b735331 moved buffer onto stack */
    struct kPDB_Temp *pTmpBuff = SSToDS(&TmpBuff); /* b735311 created tmp ptr */

#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
        { printf("\n\n*..* PTCheck.c *** PTCHECK          "); }
#endif

/*  Zero out tempoprary buffer                                              */
    memset(pTmpBuff, 0, sizeof(struct kPDB_Temp));

    if ( DBuf->Cmd >= DBG_N_Success )                         /*        A001 */
     {                                                        /*        A001 */
       Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE);                                    // B729833

#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..*return 1 Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd); }
#endif
     }                                                        /*        A001 */

/*  save the kPDB_t from the first call                                     */
    memcpy(pTmpBuff, DBuf, sizeof(struct kPDB_Temp));

    while (Dbg_rc == NO_ERROR && DBuf->Cmd != DBG_N_Success)
    {

#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..* WHILE Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd); }
#endif

        if (DBuf->Cmd < DBG_N_Success) { /*all notifications come back negtive*/

            /* save the kPDB_t before a success is returned                  */
            memcpy(pTmpBuff, DBuf, sizeof(struct kPDB_Temp));

            switch (DBuf->Cmd) {
                case DBG_N_Error:         /*  -1  */
                    return(Dbg_rc);

                case DBG_N_Exception:     /*  -7  */
#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..* DBG_N_Exception (-7)");  }
#endif
                    switch (DBuf->Value) {              /*              A002 */

                    /*********************************************************/
                    /* Pre First Chance Notifications should be handled A002 */
                    /* internally before returning to the Debugger      A002 */
                    /*********************************************************/
                    case DBG_X_PRE_FIRST_CHANCE:        /* 0x00000000   A002 */

                    xcpt_code = DBuf->Buffer;               /*          A003 */

#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..*      xcpt_code is: %4x",xcpt_code);  }
#endif

                     /* Is this an execption cases we want to handle    A002 */
                     if ( (xcpt_code == XCPT_BREAKPOINT) ||   /* 0xC000009F A002 */
                          (xcpt_code == XCPT_SINGLE_STEP) )   /* 0xC00000A0 A002 */
                      {
                       /* Notify exception management that we handled   A002 */
                       TmpBuff.Buffer = xcpt_code;
                       DBuf->Buffer = (ULONG)0;         /*the exception A002 */
                       DBuf->Cmd = DBG_C_Continue;      /*              A002 */
                       DBuf->Value = XCPT_CONTINUE_STOP; /* 0x00716668  A002 */
                       Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE); /* B729833  */

                       if ((Dbg_rc == NO_ERROR) && (DBuf->Cmd == DBG_N_Error))
                        { return(DBuf->Cmd); }

                      } /* if end */
                     else
                      {
                      /*******************************************/
                      /* DosPtrace does not handle these XCPTs   */
                      /*   this is a new one or a design error   */
                      /*******************************************/
#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..*   7.2 Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd);
       printf("\n*..*DBG_X_PRE_FIRST_CHANCE ERROR UnKnown eXeCPTion: %4x",
                 xcpt_code);
       printf("\n*..*look in DRV6\H\BSEXCPT.H for details");
     }
#endif
                       /* Let exception management handle the exception A002 */
                       DBuf->Buffer = (ULONG)0;
                       DBuf->Cmd = DBG_C_Continue;
                       DBuf->Value = XCPT_CONTINUE_SEARCH;
                       Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE); // B729833

                       if ((Dbg_rc == NO_ERROR) && (DBuf->Cmd == DBG_N_Error))
                        { return(DBuf->Cmd); }

                       continue;
                      } /* else end */

                    /* end case DBG_X_PRE_FIRST_CHANCE notification    A002 */
                    break;                                         /*  A002 */

                    /*********************************************************/
                    /* First and Last Chance Notifications should be    A002 */
                    /* handled by the debugger or passed back to the userA002*/
                    /*********************************************************/
                    case DBG_X_FIRST_CHANCE:            /* 0x00000001   A002 */
                    case DBG_X_LAST_CHANCE:             /* 0x00000002   A002 */

                    xcpt_code = ((PEXCEPTIONREPORTRECORD)
                                  DBuf->Buffer)->ExceptionNum; /*       A003 */

#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..*      xcpt_code is: %4x",xcpt_code);  }
#endif

                     /* Is this an execption cases we want to handle    A002 */
                     if ( (xcpt_code == XCPT_SIGNAL) ||  /* 0xC0010003  A002 */
                          (xcpt_code == XCPT_ACCESS_VIOLATION) ) /* 0xC0000005 A002 */
                      {
                       /* Notify exception management that we handled   A002 */
                       /* the exception                                 A002 */
                       TmpBuff.Value  = DBuf->Buffer;   /*save address  A002 */
                       TmpBuff.Buffer = xcpt_code;      /*save code     A002 */
                       DBuf->Buffer = (ULONG)0;         /*              A002 */
                       DBuf->Cmd = DBG_C_Continue;      /*              A002 */
                       DBuf->Value = XCPT_CONTINUE_STOP; /* 0x00716668  A002 */
                       Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE); /* B729833  */

                       if ((Dbg_rc == NO_ERROR) && (DBuf->Cmd == DBG_N_Error))
                        { return(DBuf->Cmd); }

                      } /* if end */
                     else
                      {
                      /*******************************************/
                      /* DosPtrace does not handle these XCPTs   */
                      /*   this is a new one or a design error   */
                      /*******************************************/
#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..*   7.4 Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd);
       printf("\n*..*DBG_X_1st or 2nd_CHANCE ERROR UnKnown eXeCPTion: %4x",
                 xcpt_code);
       printf("\n*..*look in DRV6\H\BSEXCPT.H for details");
     }
#endif
                       /* Let exception management handle the exception A002 */
                       DBuf->Buffer = (ULONG)0;
                       DBuf->Cmd = DBG_C_Continue;
                       DBuf->Value = XCPT_CONTINUE_SEARCH;
                       Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE); // B729833

                       if ((Dbg_rc == NO_ERROR) && (DBuf->Cmd == DBG_N_Error))
                        { return(DBuf->Cmd); }

                       continue;
                      } /* else end */

                    /* end case DBG_X_1st or 2nd_CHANCE notification   A002 */
                    break;                                         /*  A002 */

                    /*********************************************************/
                    /* This is DBG_X_STACK_INVALID or a unrecognized    A002 */
                    /* value, in which case DosPtrace will not handle it A002*/
                    /*********************************************************/
                    default:                            /*              A002 */

                       /* Let exception management handle the exception A002 */

                    xcpt_code = ((PEXCEPTIONREPORTRECORD)
                                  DBuf->Buffer)->ExceptionNum; /*       A003 */

#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..*   7.6 DBuf->Value: %4x",DBuf->Value);
       printf("\n*..* Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd);
       printf("\n*..* DEFAULT Case TAKEN UnKnown eXeCPTion: %4x",
                 xcpt_code);
       printf("\n*..*look in DRV6\H\BSEXCPT.H for details");
     }
#endif
                       DBuf->Buffer = (ULONG)0;
                       DBuf->Cmd = DBG_C_Continue;
                       DBuf->Value = XCPT_CONTINUE_SEARCH;
                       Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE);    // B729833

                       if ((Dbg_rc == NO_ERROR) && (DBuf->Cmd == DBG_N_Error))
                        { return(DBuf->Cmd); }

                       continue;                                    /*   A002 */

                    }  /* end SWITCH for Dbuf->Value                     A002 */

                    memcpy(DBuf, pTmpBuff, sizeof(struct kPDB_Temp));
                    return(Dbg_rc);

                case DBG_N_ProcTerm:      /*  -6  */
                    DBuf->Cmd = DBG_C_Continue;
                    DBuf->Value = XCPT_CONTINUE_STOP;
                    Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE);                    // B729833
#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..*   -6  Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd); }
#endif
                    if (Dbg_rc == NO_ERROR)                      /*     M004 */
                    {                                            /*     M004 */
                       if (DBuf->Cmd == DBG_N_Error) {           /*     M004 */
                           return(DBuf->Cmd);                    /*     M004 */
                       } /* endif */                             /*     M004 */
                    }                                            /*     M004 */
                    memcpy(DBuf, pTmpBuff, sizeof(struct kPDB_Temp));/* A004 */
                    return(Dbg_rc);                              /*     M004 */

                case DBG_N_ModuleLoad:    /*  -8  */
                    DBuf->Cmd = DBG_C_Continue;
                    DBuf->Value = XCPT_CONTINUE_STOP;
                    Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE);                    // B729833
#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..*   -8  Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd); }
#endif
                    if (Dbg_rc == NO_ERROR)
                    {
                       if (DBuf->Cmd == DBG_N_Error) {
                           return(DBuf->Cmd);
                       } /* endif */
                    }
                    memcpy(DBuf, pTmpBuff, sizeof(struct kPDB_Temp));
                    return(Dbg_rc);

                case DBG_N_CoError:       /*  -9  */
                    DBuf->Cmd = DBG_C_Continue;
                    DBuf->Value = XCPT_CONTINUE_STOP;
                    Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE);                    // B729833
#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..*   -9  Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd); }
#endif
                    if (Dbg_rc == NO_ERROR)                      /*     A005 */
                    {                                            /*     A005 */
                       if (DBuf->Cmd == DBG_N_Error) {           /*     A005 */
                           return(DBuf->Cmd);                    /*     A005 */
                       } /* endif */                             /*     A005 */
                    }                                            /*     A005 */
                    memcpy(DBuf, pTmpBuff, sizeof(struct kPDB_Temp));/* A005 */
                    return(Dbg_rc);                              /*     A005 */

                case DBG_N_ThreadTerm:    /* -10  */
                    DBuf->Cmd = DBG_C_Continue;
                    DBuf->Value = XCPT_CONTINUE_STOP;
                    Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE);                    // B729833
#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..*   -10 Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd); }
#endif
                    if (Dbg_rc == NO_ERROR)
                    {
                       if (DBuf->Cmd == DBG_N_Error) {
                           return(DBuf->Cmd);
                       } /* endif */
                    }
                    memcpy(DBuf, pTmpBuff, sizeof(struct kPDB_Temp));
                    return(Dbg_rc);

                case DBG_N_AsyncStop:     /* -11  */
                    DBuf->Cmd = DBG_C_Continue;
                    DBuf->Value = XCPT_CONTINUE_STOP;            /*     M004 */
                    Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE);                    // B729833
#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..*   -11 Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd); }
#endif
                    if (Dbg_rc == NO_ERROR)                      /*     M004 */
                    {                                            /*     M004 */
                       if (DBuf->Cmd == DBG_N_Error) {           /*     M004 */
                           return(DBuf->Cmd);                    /*     M004 */
                       } /* endif */                             /*     M004 */
                    }                                            /*     M004 */
                    memcpy(DBuf, pTmpBuff, sizeof(struct kPDB_Temp));
                    return(Dbg_rc);
                    break;

                case DBG_N_NewProc:       /* -12  */
                    DBuf->Cmd = DBG_C_Continue;
                    DBuf->Value = XCPT_CONTINUE_STOP;
                    Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE);                    // B729833
#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..*   -12 Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd); }
#endif
                    if (Dbg_rc == NO_ERROR)                      /*     A005 */
                    {                                            /*     A005 */
                       if (DBuf->Cmd == DBG_N_Error) {           /*     A005 */
                           return(DBuf->Cmd);                    /*     A005 */
                       } /* endif */                             /*     A005 */
                    }                                            /*     A005 */
                    memcpy(DBuf, pTmpBuff, sizeof(struct kPDB_Temp));/* A005 */
                    return(Dbg_rc);                              /*     A005 */

                case DBG_N_AliasFree:     /* -13  */
                    DBuf->Cmd = DBG_C_Continue;
                    DBuf->Value = XCPT_CONTINUE_STOP;
                    Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE);                    // B729833
#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..*   -13 Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd); }
#endif
                    if (Dbg_rc == NO_ERROR)                      /*     A005 */
                    {                                            /*     A005 */
                       if (DBuf->Cmd == DBG_N_Error) {           /*     A005 */
                           return(DBuf->Cmd);                    /*     A005 */
                       } /* endif */                             /*     A005 */
                    }                                            /*     A005 */
                    memcpy(DBuf, pTmpBuff, sizeof(struct kPDB_Temp));/* A005 */
                    return(Dbg_rc);                              /*     A005 */

                case DBG_N_Watchpoint:    /* -14  */
                    /*********************************************************/
                    /* This NOTIFICATION is not handled by DosPtrace !!!     */
                    /* It is not returned. The command that was executing    */
                    /* when the notification appeared will be reissued.      */
                    /*********************************************************/
                    DBuf->Cmd = DBG_C_Continue;
                    DBuf->Value = XCPT_CONTINUE_SEARCH;
                    Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE);                    // B729833
#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     {
       printf("\n*..*   -14 DBG_N_WatchPoint is not handled by PTRACE");
       printf("\n*..*   -14 Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd);
     }
#endif
                    if (Dbg_rc == NO_ERROR)
                    {
                       if (DBuf->Cmd == DBG_N_Error)
                       {
                          memcpy(DBuf, pTmpBuff, sizeof(struct kPDB_Temp)); /* ARJ1*/
                          return(DBuf->Cmd);
                       } /* endif */
                       else
                       {
                          continue;
                       } /* end else */
                    }
                    memcpy(DBuf, pTmpBuff, sizeof(struct kPDB_Temp));
                    return(Dbg_rc);

                case DBG_N_ModuleFree:    /* -16  */
                    /*********************************************************/
                    /* This NOTIFICATION is not handled by DosPtrace !!!     */
                    /* It is not returned. The command that was executing    */
                    /* when the notification appeared will be reissued.      */
                    /*********************************************************/
                    DBuf->Cmd = DBG_C_Continue;
                    DBuf->Value = XCPT_CONTINUE_SEARCH;
                    Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE);                    // B729833
#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     {
       printf("\n*..*   -16 DBG_N_ModuleFree   is not handled by PTRACE");
       printf("\n*..*   -16 Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd);
     }
#endif
                    if (Dbg_rc == NO_ERROR)
                    {
                       if (DBuf->Cmd == DBG_N_Error)
                       {
                          memcpy(DBuf, pTmpBuff, sizeof(struct kPDB_Temp)); /* ARJ1*/
                          return(DBuf->Cmd);
                       } /* endif */
                       else
                       {
                          continue;
                       } /* end else */
                    }
                    memcpy(DBuf, pTmpBuff, sizeof(struct kPDB_Temp));
                    return(Dbg_rc);

                case DBG_N_ThreadCreate:  /* -15  */
                    /*********************************************************/
                    /* This NOTIFICATION is not handled by DosPtrace !!!     */
                    /* It is not returned. The command that was executing    */
                    /* when the notification appeared will be reissued.      */
                    /*********************************************************/
                    DBuf->Cmd = DBG_C_Continue;
                    DBuf->Value = XCPT_CONTINUE_SEARCH;
                    Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE);                    // B729833
#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     {
       printf("\n*..*   -15 DBG_N_ThreadCreate is not handled by PTRACE");
       printf("\n*..*   -15 Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd);
     }
#endif
                    if (Dbg_rc == NO_ERROR)
                    {
                       if (DBuf->Cmd == DBG_N_Error)
                       {
                          memcpy(DBuf, pTmpBuff, sizeof(struct kPDB_Temp)); /* ARJ1*/
                          return(DBuf->Cmd);
                       } /* endif */
                       else
                       {
                          continue;
                       } /* end else */
                    }
                    memcpy(DBuf, pTmpBuff, sizeof(struct kPDB_Temp));
                    return(Dbg_rc);

                case DBG_N_RangeStep:     /* -17  */
                    DBuf->Cmd = DBG_C_Continue;
                    DBuf->Value = XCPT_CONTINUE_STOP;
                    Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE);                    // B729833
#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..*   -17 Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd); }
#endif
                    if (Dbg_rc != NO_ERROR) {
                        return(Dbg_rc);
                    } else {
                        if (DBuf->Cmd == DBG_N_Error) {
                            continue;
                        } /* endif */
                    }
                    break;

            }  /* end switch */
        } /* endif */

        DBuf->Cmd = DBG_C_Stop;
        DBuf->Value = 0;
        DBuf->Tid = 0;
        Dbg_rc = DBG32ApiDebug(DBuf,DBGP_PTRACE);                                // B729833
#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
     { printf("\n*..*  END  Dbg_rc: %4x, DBuf->Cmd: %4x",Dbg_rc,DBuf->Cmd); }
#endif

    } /* end of while no error and no success */

    memcpy(DBuf, pTmpBuff, sizeof(struct kPDB_Temp));

#ifdef PTSTRICT
    if (PTBugBug & PTCHECKc)
        {
           printf("\n\n*..*Exit    PTCheck\n");
           printf("\n*..*Dbg_rc: %4x, DBuf->Cmd: %4x\n\n",Dbg_rc,DBuf->Cmd);
        }
#endif

    return(Dbg_rc);

}
