home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / GO.C < prev    next >
Text File  |  1996-08-27  |  35KB  |  678 lines

  1. /*****************************************************************************/
  2. /* File:                                             IBM INTERNAL USE ONLY   */
  3. /*   go.c                                                                 822*/
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*                                                                           */
  7. /*  Execution functions.                                                     */
  8. /*                                                                           */
  9. /* History:                                                                  */
  10. /*                                                                           */
  11. /*   06/11/93 Created.                                                       */
  12. /*                                                                           */
  13. /*...                                                                        */
  14. /*... 05/04/93  822   Joe       Add mte table handling.                      */
  15. /*... 06/04/93  827   Joe       Add remote debug support.                    */
  16. /*... 12/06/93  906   Joe       Fix for not hitting conditional breaks.      */
  17. /*... 05/19/94  920   Joe       Fix hang.                                    */
  18. /*...                                                                        */
  19. /*****************************************************************************/
  20. #include "all.h"
  21.  
  22. int    WatchpointFlag = TRUE;
  23.  
  24. extern PROCESS_NODE   *pnode;
  25. extern uchar           Re_Parse_Data;   /* flag to indicate wether all       */
  26.                                         /* variables in datawindow are to    */
  27.                                         /* be reparsed.                      */
  28. extern CmdParms       cmd;
  29.  
  30. int          DataRecalc;
  31. PtraceBuffer AppPTB;
  32.  
  33. /*****************************************************************************/
  34. /* Functions to get/set Exec variables.                                      */
  35. /*****************************************************************************/
  36. static TSTATE *ExecThread;
  37. static AFILE  *Execfp;
  38. static ULONG   ExecTid;
  39. static ULONG   ExecAddr;
  40. static LNOTAB *pExecLnoTabEntry;
  41. static ULONG   ExecAddrlo;
  42. static ULONG   ExecAddrhi;
  43. static ULONG   ExecMid;
  44.  
  45. TSTATE *GetExecThread(void)      { return(ExecThread); }
  46. AFILE  *GetExecfp(void)          { return(Execfp);     }
  47. ULONG   GetExecTid(void)         { return(ExecTid);    }
  48. ULONG   GetExecAddr(void)        { return(ExecAddr);   }
  49. LNOTAB *GetExecLnoTabEntry(void) { return(pExecLnoTabEntry); }
  50. ULONG   GetExecMid(void)         { return(ExecMid);    }
  51.  
  52. void    SetExecAddr( ULONG addr) { ExecAddr = addr;    }
  53.  
  54. ULONG   GetExecLno(void)         { return(NULL);    }/*!!!!! remove */
  55. /*****************************************************************************/
  56. /* GoInit()                                                               827*/
  57. /*                                                                           */
  58. /* Description:                                                              */
  59. /*                                                                           */
  60. /*  Initialize the exe for debugging.                                        */
  61. /*                                                                           */
  62. /* Parameters:                                                               */
  63. /*                                                                           */
  64. /*  pid     this is the pid of the process that we're going to connect to    */
  65. /*          and debug.                                                       */
  66. /*  sid     this is the session id containing the pid.                       */
  67. /*                                                                           */
  68. /* Return:                                                                   */
  69. /*                                                                           */
  70. /*  rc                                                                       */
  71. /*                                                                           */
  72. /* Assumptions:                                                              */
  73. /*                                                                           */
  74. /*  none                                                                     */
  75. /*                                                                           */
  76. /*****************************************************************************/
  77. APIRET GoInit( ULONG pid, ULONG sid )
  78. {
  79.  UINT    *pModuleLoadTable = NULL;
  80.  int      ModuleLoadTableLength;
  81.  APIRET   rc = 0;
  82.  
  83.  memset( &AppPTB,0,sizeof(AppPTB) );
  84.  AppPTB.Pid = pid;
  85.  AppPTB.Tid = sid;
  86.  
  87.  rc = xGoInit( &AppPTB,
  88.                (ULONG*)&ExecAddr,
  89.                &pModuleLoadTable,
  90.                &ModuleLoadTableLength );
  91.  
  92.  if( rc == 1 )
  93.   return(1);
  94.  
  95.  if( rc )
  96.   return( rc );
  97.  
  98.  if( pModuleLoadTable )
  99.  {
  100. //DumpModuleLoadTable( pModuleLoadTable );
  101.  
  102.   UpdateMteTable( pModuleLoadTable );
  103.   ExeDllInit( pModuleLoadTable );
  104.   Tfree(pModuleLoadTable);
  105.  }
  106.  return(0);
  107. }
  108.  
  109. /*****************************************************************************/
  110. /* GoEntry()                                                              827*/
  111. /*                                                                           */
  112. /* Description:                                                              */
  113. /*                                                                           */
  114. /*  Run to an initial entry point.                                           */
  115. /*                                                                           */
  116. /* Parameters:                                                               */
  117. /*                                                                           */
  118. /* Return:                                                                   */
  119. /*                                                                           */
  120. /*  rc                                                                       */
  121. /*                                                                           */
  122. /* Assumptions:                                                              */
  123. /*                                                                           */
  124. /*  none                                                                     */
  125. /*                                                                           */
  126. /*****************************************************************************/
  127. APIRET GoEntry( void )
  128. {
  129.  UINT    *pModuleLoadTable = NULL;
  130.  int      ModuleLoadTableLength;
  131.  APIRET   rc = 0;
  132.  int      ExecFlags;
  133.  
  134.  /***************************************************************************/
  135.  /* - When dealing with multiple processes you have to know that the        */
  136.  /*   session that issued the DosStartSession() to start the parent         */
  137.  /*   debuggee is the only session that can select the debuggee sessions.   */
  138.  /*                                                                         */
  139.  /*   (The child debuggee sessions are essentially treated like child       */
  140.  /*   sessions of the parent probe even though they were not directly       */
  141.  /*   started by the debugger using DosStartSession().  )                   */
  142.  /*                                                                         */
  143.  /* - ...But, the session that started the parent debuggee( or one of its   */
  144.  /*   children) must also be in the foreground before it can issue          */
  145.  /*   the DosSelectSession() successfully.                                  */
  146.  /*                                                                         */
  147.  /* - So, if we're running child/multiple processes on a single             */
  148.  /*   machine, we have to tell the parent debugger to bring the             */
  149.  /*   parent probe to the foreground so that when we send the               */
  150.  /*   xSelectSession() the parent probe will be in the foreground and       */
  151.  /*   capable of issueing a successful DosSelectSession().                  */
  152.  /***************************************************************************/
  153.  if( ConnectType()==LOCAL_PIPE )
  154.  {
  155.   SendMsgToDbgQue( DBG_QMSG_SELECT_PARENT_ESP, NULL, 0 );
  156.  }
  157.  xSelectSession();
  158.  
  159.  ExecFlags = 0;
  160.  ExecFlags |= LOAD_MODULES;
  161.  
  162.  rc = xGoEntry( &AppPTB,
  163.                 (ULONG*)&ExecAddr,
  164.                 &pModuleLoadTable,
  165.                 &ModuleLoadTableLength,
  166.                 ExecAddr,
  167.                 ExecFlags);
  168.  
  169.  if( pModuleLoadTable )
  170.  {
  171.   UpdateMteTable( pModuleLoadTable );
  172.   ExeDllInit( pModuleLoadTable );
  173.   Tfree(pModuleLoadTable);
  174.  }
  175.  
  176.  /****************************************************************************/
  177.  /* - DosStartSession() has a restriction that only a parent can select      */
  178.  /*   itself or a child session.  So, we have to send a message to the       */
  179.  /*   parent debugger telling it to bring this debugger session to the       */
  180.  /*   foreground.                                                            */
  181.  /****************************************************************************/
  182.  if( ConnectType()==LOCAL_PIPE )
  183.  {
  184.   DBG_QUE_ELEMENT Qelement;
  185.  
  186.   Qelement.pid = DbgGetProcessID();
  187.   SendMsgToDbgQue( DBG_QMSG_SELECT_SESSION, &Qelement, sizeof(Qelement) );
  188.  }
  189.  
  190.  SetExecValues( AppPTB.Tid, FALSE );
  191.  SetActFrames();                       /* query active stack frames         */
  192.  return(rc);
  193. }
  194.  
  195. /*****************************************************************************/
  196. /* Go()                                                                      */
  197. /*                                                                           */
  198. /* Description:                                                              */
  199. /*                                                                           */
  200. /*   Application execution function.                                         */
  201. /*                                                                           */
  202. /* Parameters:                                                               */
  203. /*                                                                           */
  204. /*   func       the execution function.                                      */
  205. /*                                                                           */
  206. /* Return:                                                                   */
  207. /*                                                                           */
  208. /*   rc         return code.                                                 */
  209. /*                                                                           */
  210. /* Assumptions:                                                              */
  211. /*                                                                           */
  212. /*****************************************************************************/
  213. int Go( UINT func)
  214. {                                       /*                                   */
  215.  APIRET   rc;                           /* local return code                 */
  216.  int      UserSessionSelected;
  217.  int      ExecFlags;
  218.  
  219.  Re_Parse_Data = TRUE;                  /* Set the parse var flag         244*/
  220.  
  221.  if( IsWatchPoint() && WatchpointFlag )                                                   /*701*/
  222.   PutInWps();
  223.  
  224.  /****************************************************************************/
  225.  /* - Breakpoint file may have been updated...check it.                      */
  226.  /****************************************************************************/
  227.  MergeBreakpoints();
  228.  
  229.  /****************************************************************************/
  230.  /* - Bring the app to foreground if need be.                                */
  231.  /* - The swap flags for the source and asm views are tied together.         */
  232.  /*   That's why we have the checks on ASMSTEP and ASMSTEPINTO.              */
  233.  /****************************************************************************/
  234.  UserSessionSelected = FALSE;
  235.  {
  236.   UINT  funcx;
  237.  
  238.   funcx = func;
  239.   if( func == ASMSSTEP)
  240.    funcx = SSTEP;
  241.   else if( func == ASMSSTEPINTOFUNC )
  242.    funcx = SSTEPINTOFUNC;
  243.  
  244.   if( IsSwapFlag(funcx) )
  245.   {
  246.    /**************************************************************************/
  247.    /* - If we're running with the probe bound to the debugger, then we       */
  248.    /*   simply select the child debugger session like always.                */
  249.    /**************************************************************************/
  250.    if( ConnectType()==BOUND )
  251.     DosSelectSession(DbgGetSessionID());
  252.    else
  253.    {
  254.     /*************************************************************************/
  255.     /* - When dealing with multiple processes you have to know that the      */
  256.     /*   session that issued the DosStartSession() to start the parent       */
  257.     /*   debuggee is the only session that can select the debuggee sessions. */
  258.     /*                                                                       */
  259.     /*   (The child debuggee sessions are essentially treated like child     */
  260.     /*   sessions of the parent probe even though they were not directly     */
  261.     /*   started by the debugger using DosStartSession().  )                 */
  262.     /*                                                                       */
  263.     /* - ...But, the session that started the parent debuggee( or one of its */
  264.     /*   children) must also be in the foreground before it can issue        */
  265.     /*   the DosSelectSession() successfully.                                */
  266.     /*                                                                       */
  267.     /* - So, if we're running child/multiple processes on a single           */
  268.     /*   machine, we have to tell the parent debugger to bring the           */
  269.     /*   parent probe to the foreground so that when we send the             */
  270.     /*   xSelectSession() the parent probe will be in the foreground and     */
  271.     /*   capable of issueing a successful DosSelectSession().                */
  272.     /*************************************************************************/
  273.     if( ConnectType()==LOCAL_PIPE )
  274.     {
  275.      SendMsgToDbgQue( DBG_QMSG_SELECT_PARENT_ESP, NULL, 0 );
  276.     }
  277.     xSelectSession();
  278.    }
  279.  
  280.    UserSessionSelected = TRUE;
  281.   }
  282.  }
  283.  
  284. carryon:
  285.  
  286.  ExecFlags = 0;
  287.  ExecFlags |= LOAD_MODULES;
  288.  if( IsDeferredBrk() )
  289.   ExecFlags |= RUNNING_DEFERRED;
  290.  
  291.  switch( func )                                                         /*701*/
  292.  {                                                                      /*701*/
  293.  
  294.   case RUNNOLOAD:
  295.    /**************************************************************************/
  296.    /* - turn off the load modules bit.                                       */
  297.    /**************************************************************************/
  298.    ExecFlags &= ~LOAD_MODULES;
  299.    rc = GoFast( ExecFlags );
  300.    break;
  301.  
  302.   case RUN:                                                             /*701*/
  303.   case RUNTOCURSOR:                                                     /*701*/
  304.   case RUNNOSWAP:                                                       /*701*/
  305.   case RUNTOCURSORNOSWAP:                                               /*701*/
  306.    rc = GoFast( ExecFlags );                                            /*827*/
  307.    break;                                                               /*701*/
  308.                                                                         /*701*/
  309.   case SSTEP:                           /* Source line step. Step over. /*701*/
  310.   case SSTEPNOSWAP:                                                     /*701*/
  311.    rc = GoStep(OVERCALL,ExecFlags);                                     /*827*/
  312.    break;                                                               /*701*/
  313.                                                                         /*701*/
  314.   case ASMSSTEP:                                                        /*701*/
  315.   case ASMSSTEPNOSWAP:                                                  /*701*/
  316.    if( func == ASMSSTEP)                                                /*701*/
  317.     func = SSTEP;                                                       /*701*/
  318.    ExecAddrlo = ExecAddrhi = ExecAddr;                                  /*827*/
  319.    rc = GoStep(OVERCALL,ExecFlags);                                     /*827*/
  320.    break;                                                               /*701*/
  321.                                                                         /*701*/
  322.   case ASMSSTEPINTOFUNC:                                                /*701*/
  323.   case ASMSSTEPINTOFUNCNOSWAP:                                          /*701*/
  324.    if( func == ASMSSTEPINTOFUNC)                                        /*701*/
  325.     func = SSTEPINTOFUNC;                                               /*701*/
  326.    ExecAddrlo = ExecAddrhi = ExecAddr;                                  /*827*/
  327.    rc = GoStep(INTOCALL,ExecFlags);                                     /*827*/
  328.    break;                                                               /*701*/
  329.                                                                         /*701*/
  330.   case SSTEPINTOFUNC:                                                   /*701*/
  331.   case SSTEPINTOFUNCNOSWAP:                                             /*701*/
  332.    rc = GoStep(INTOCALL,ExecFlags);                                     /*827*/
  333.    break;                                                               /*701*/
  334.                                                                         /*701*/
  335.  }                                                                      /*701*/
  336.  
  337.  /****************************************************************************/
  338.  /* - We may come here when running with deferred break points, so           */
  339.  /*   just back up and continue with the original function.                  */
  340.  /****************************************************************************/
  341.  if( rc == (APIRET)DBG_N_ModuleLoad )
  342.   goto carryon;
  343.  
  344.  /****************************************************************************/
  345.  /* - set the DataRecalc flag.                                               */
  346.  /****************************************************************************/
  347.  DataRecalc = TRUE;
  348.  
  349.  /****************************************************************************/
  350.  /* - Now, bring the debugger back to the foreground if necessary.           */
  351.  /****************************************************************************/
  352.  if(UserSessionSelected == TRUE && rc != TRAP_INTERLOCK )               /*901*/
  353.  {
  354.   if( ConnectType()==BOUND )
  355.    DosSelectSession(0);
  356.   else
  357.   {
  358.    /**************************************************************************/
  359.    /* - DosStartSession() has a restriction that only a parent can select    */
  360.    /*   itself or a child session.  So, we have to send a message to the     */
  361.    /*   parent debugger telling it to bring this debugger session to the     */
  362.    /*   foreground.                                                          */
  363.    /**************************************************************************/
  364.    if( ConnectType()==LOCAL_PIPE )
  365.    {
  366.     DBG_QUE_ELEMENT Qelement;
  367.  
  368.     Qelement.pid = DbgGetProcessID();
  369.     SendMsgToDbgQue( DBG_QMSG_SELECT_SESSION, &Qelement, sizeof(Qelement) );
  370.    }
  371.   }
  372.  }
  373.  
  374.  
  375.  if( rc != TRAP_INTERLOCK )                                             /*920*/
  376.  {                                                                      /*920*/
  377.   SetExecValues( AppPTB.Tid, FALSE );
  378.   SetActFrames();                       /* query active stack frames         */
  379.                                         /*                                   */
  380.   SetRegChgMask();                      /* set the registers change mask  400*/
  381.  }                                                                      /*920*/
  382.  return( rc );                          /* return to caller with ret code.   */
  383. }
  384.  
  385. /*****************************************************************************/
  386. /* GoFast()                                                                  */
  387. /*                                                                           */
  388. /* Description:                                                              */
  389. /*                                                                           */
  390. /*   Run until we get a notification from DosDebug.                          */
  391. /*                                                                           */
  392. /* Parameters:                                                               */
  393. /*                                                                           */
  394. /* Return:                                                                   */
  395. /*                                                                           */
  396. /* Assumptions:                                                              */
  397. /*                                                                           */
  398. /*****************************************************************************/
  399. APIRET GoFast( int ExecFlags)
  400. {
  401.  BRK    *atbrk;
  402.  APIRET  rc;
  403.  APIRET  rcx;
  404.  UINT   *pModuleLoadTable = NULL;
  405.  int     ModuleLoadTableLength = 0;
  406.  
  407.  /****************************************************************************/
  408.  /* - If there's a break point defined for the current CS:EIP, then          */
  409.  /*   single step before inserting the breakpoints.                          */
  410.  /* - Insert all the breakpoints.                                            */
  411.  /* - Run the application.                                                   */
  412.  /* - Update the mte table if needed.                                        */
  413.  /* - Handle any dll loads/frees.                                            */
  414.  /* - If we land on a breakpoint and it's conditional and the condition is   */
  415.  /*   not met, then stay in the loop.                                        */
  416.  /****************************************************************************/
  417.  for(;;)
  418.  {
  419.   rc = xGoFast( &AppPTB,
  420.                 (ULONG*)&ExecAddr,
  421.                 &pModuleLoadTable,
  422.                 &ModuleLoadTableLength,
  423.                 ExecAddr,
  424.                 ExecFlags);
  425.   if( pModuleLoadTable )
  426.   {
  427.    UpdateMteTable( pModuleLoadTable );
  428.    rcx = ExeDllInit( pModuleLoadTable );
  429.    Tfree(pModuleLoadTable);
  430.   }
  431.  
  432.   /***************************************************************************/
  433.   /* - test for dll load and address load breakpoints.                       */
  434.   /***************************************************************************/
  435.   if( (rcx == TRAP_ADDR_LOAD) ||
  436.       (rcx == TRAP_DLL_LOAD)
  437.     )
  438.    return(rcx);
  439.  
  440.   /***************************************************************************/
  441.   /* - At this point, xGoFast() will have defined a new ExecAddr.            */
  442.   /* - Get out of here if not a breakpoint notification.                     */
  443.   /***************************************************************************/
  444.   if( rc != TRAP_BPT )
  445.    break;
  446.  
  447.   /***************************************************************************/
  448.   /* - At this point, we're at a breakpoint.                                 */
  449.   /* - Take the break if it's not one we know about or it's a simple break.  */
  450.   /***************************************************************************/
  451.   atbrk = IfBrkOnAddr( ExecAddr );
  452.   if( (atbrk == NULL) ||
  453.       (atbrk->cond == NULL )
  454.     )
  455.    break;
  456.  
  457.   /***************************************************************************/
  458.   /* - At this point, we have a conditional breakpoint.                      */
  459.   /* - If the condition is met then take the break.                          */
  460.   /***************************************************************************/
  461.   DataRecalc = TRUE;                                                    /*906*/
  462.   if( EvalCbrk(atbrk->cond) == TRUE )
  463.    break;
  464.  }
  465.  return(rc);
  466. }
  467.  
  468. /*****************************************************************************/
  469. /* GoStep()                                                                  */
  470. /*                                                                           */
  471. /* Description:                                                              */
  472. /*                                                                           */
  473. /*   Step a source line stepping over any call instructions.                 */
  474. /*                                                                           */
  475. /* Parameters:                                                               */
  476. /*                                                                           */
  477. /*   void                                                                    */
  478. /*                                                                           */
  479. /* Return:                                                                   */
  480. /*                                                                           */
  481. /*   void                                                                    */
  482. /*                                                                           */
  483. /* Assumptions:                                                              */
  484. /*                                                                           */
  485. /*****************************************************************************/
  486. APIRET GoStep( int how, int ExecFlags )
  487. {
  488.  APIRET  rc;
  489.  APIRET  rcx;
  490.  UINT   *pModuleLoadTable = NULL;
  491.  int     ModuleLoadTableLength = 0;
  492.  
  493.  rc = xGoStep( &AppPTB,
  494.                (ULONG*)&ExecAddr,
  495.                &pModuleLoadTable,
  496.                &ModuleLoadTableLength,
  497.                ExecAddr,
  498.                ExecAddrlo,
  499.                ExecAddrhi,
  500.                how,
  501.                ExecFlags );
  502.  if( pModuleLoadTable )
  503.  {
  504.   UpdateMteTable( pModuleLoadTable );
  505.   rcx = ExeDllInit( pModuleLoadTable );
  506.   Tfree(pModuleLoadTable);
  507.   /***************************************************************************/
  508.   /* - test for dll load and address load breakpoints.                       */
  509.   /***************************************************************************/
  510.   if( (rcx == TRAP_ADDR_LOAD) ||
  511.       (rcx == TRAP_DLL_LOAD)
  512.     )
  513.    return(rcx);
  514.  }
  515.  return(rc);
  516. }
  517.  
  518. /*****************************************************************************/
  519. /* SetExecValues()                                                           */
  520. /*                                                                           */
  521. /* Description:                                                              */
  522. /*                                                                           */
  523. /*   Setting pertinent execution context values after returning from         */
  524. /*   an execution function including:                                        */
  525. /*                                                                           */
  526. /*    ExecTid = The thread id that execution stopped in.                     */
  527. /*                                                                           */
  528. /*                                                                           */
  529. /*                                                                           */
  530. /* Parameters:                                                               */
  531. /*                                                                           */
  532. /*   void                                                                    */
  533. /*                                                                           */
  534. /* Return:                                                                   */
  535. /*                                                                           */
  536. /*   void                                                                    */
  537. /*                                                                           */
  538. /* Assumptions:                                                              */
  539. /*                                                                           */
  540. /*****************************************************************************/
  541. extern TSTATE *thead;
  542. void SetExecValues( ULONG exectid, int GetRegsFlag)
  543. {
  544.  TSTATE       *np;                      /* thread state node pointer         */
  545.  DEBFILE      *pdf;                     /* -> to debug file structure        */
  546.  APIRET        rc;
  547.  LNOTAB       *pLnoTabEntry;
  548.  ULONG         span;
  549.  
  550.  /****************************************************************************/
  551.  /* - if we're switching context to another thread then we need to read      */
  552.  /*   the registers.                                                         */
  553.  /****************************************************************************/
  554.  if( GetRegsFlag == TRUE )
  555.  {
  556.   PtraceBuffer ptb;
  557.  
  558.   /***************************************************************************/
  559.   /* - tell esp to set it's execution context to a new thread.               */
  560.   /* - if there's an error, don't change anything and return.                */
  561.   /***************************************************************************/
  562.   ptb  = AppPTB;
  563.   rc = xSetExecThread( &ExecAddr, &AppPTB, exectid);
  564.   if( rc != 0 )
  565.   {
  566.    AppPTB = ptb;
  567.    return;
  568.   }
  569.  }
  570.  
  571.  /****************************************************************************/
  572.  /* - build the thread list.                                                 */
  573.  /****************************************************************************/
  574.  BuildThreadList();
  575.  
  576.  /****************************************************************************/
  577.  /* - scan the list and set the pointer to the executing thread and          */
  578.  /*   set the executing thread id.                                           */
  579.  /****************************************************************************/
  580.  for ( np = thead; np != NULL ; np = np->next )
  581.  {
  582.   if( np->tid == exectid)
  583.    break;
  584.  }
  585.  ExecThread = np;
  586.  ExecTid    = 0;
  587.  if( np )
  588.   ExecTid = np->tid;
  589.  
  590.  /****************************************************************************/
  591.  /* - find the pdf we're executing in.                                       */
  592.  /****************************************************************************/
  593.  pdf = FindExeOrDllWithAddr( ExecAddr );
  594.  
  595.  /****************************************************************************/
  596.  /* If we can't find a pdf for this address, then we have landed on          */
  597.  /* an address in hyperspace.  This may happen when we pop a bad eip         */
  598.  /* on a ret instruction. So, as far as building a view, we're dead meat     */
  599.  /* at this point. Just return and report the execption relative to the      */
  600.  /* old exec values.                                                         */
  601.  /****************************************************************************/
  602.  if( pdf == NULL )
  603.   return;
  604.  
  605.  /****************************************************************************/
  606.  /* - set the executing line. 0 ==> no source line for this ExecAddr.        */
  607.  /* - set the executing module id. 0 ==> no mid for this address.            */
  608.  /****************************************************************************/
  609.  ExecMid          = DBMapInstAddr( ExecAddr, &pLnoTabEntry, pdf);
  610.  pExecLnoTabEntry = pLnoTabEntry;
  611.  
  612.  /****************************************************************************/
  613.  /* - Set the start and end addresses if we landed on a source line. Else,   */
  614.  /*   the start and end addresses will be the same for an assembler line.    */
  615.  /****************************************************************************/
  616.  ExecAddrlo = ExecAddrhi = ExecAddr;
  617.  if( (pExecLnoTabEntry != NULL) &&  (pExecLnoTabEntry->lno != 0) )
  618.  {
  619.   int sfi;
  620.   int lno;
  621.  
  622.   sfi = pExecLnoTabEntry->sfi;
  623.   lno = pExecLnoTabEntry->lno;
  624.  
  625.   ExecAddrlo = DBMapLno(ExecMid, lno, sfi, &span , pdf );
  626.   ExecAddrhi = ExecAddrlo + span - 1;
  627.  
  628.   if( ExecAddr > ExecAddrhi )
  629.   {
  630.    MODULE *pModule;
  631.    LNOTAB *pLnoTabEntry;
  632.    CSECT  *pCsect;
  633.  
  634.    ExecAddrlo = ExecAddrhi = ExecAddr;
  635.  
  636.    if( (pModule      = GetPtrToModule( ExecMid, pdf)         ) &&
  637.        (pCsect       = GetCsectWithAddr( pModule,  ExecAddr) ) &&
  638.        (pLnoTabEntry = GetLnoWithAddr( pCsect, ExecAddr)     ) &&
  639.        (span         = GetLineSpan( pModule, pLnoTabEntry)   )
  640.      )
  641.    {
  642.     ExecAddrlo = ExecAddr;
  643.     ExecAddrhi = ExecAddrlo + span - 1;
  644.    }
  645.   }
  646.  }
  647.  
  648. }
  649.  
  650. /*****************************************************************************/
  651. /* SetExecfp()                                                               */
  652. /*                                                                           */
  653. /* Description:                                                              */
  654. /*                                                                           */
  655. /*   Build a view for the context of the execution address.                  */
  656. /*                                                                           */
  657. /* Parameters:                                                               */
  658. /*                                                                           */
  659. /*   void                                                                    */
  660. /*                                                                           */
  661. /* Return:                                                                   */
  662. /*                                                                           */
  663. /*   void                                                                    */
  664. /*                                                                           */
  665. /* Assumptions:                                                              */
  666. /*                                                                           */
  667. /*****************************************************************************/
  668. AFILE *SetExecfp( void )
  669. {
  670.  AFILE       *fp;
  671.  
  672.  fp = Execfp;
  673.  Execfp = findfp( ExecAddr);
  674.  if( Execfp == NULL )
  675.   Execfp = fp;
  676.  return(Execfp);
  677. }
  678.