Changeset 7326 for trunk/src


Ignore:
Timestamp:
Nov 13, 2001, 12:06:03 AM (24 years ago)
Author:
phaller
Message:

.

Location:
trunk/src/kernel32
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/KERNEL32.DEF

    r7010 r7326  
    1 ; $Id: KERNEL32.DEF,v 1.125 2001-10-11 00:59:42 phaller Exp $
     1; $Id: KERNEL32.DEF,v 1.126 2001-11-12 23:04:56 phaller Exp $
    22
    33;Basis is Windows95 KERNEL32
     
    12021202    PerfView_DumpProfile                                          @3104 NONAME
    12031203    PerfView_Write                                                @3105 NONAME
     1204    _dbg_GetLastCallerName@0                                      @3106 NONAME
     1205    _dbg_ThreadPushCall@4                                         @3107 NONAME
     1206    _dbg_ThreadPopCall@0                                          @3108 NONAME
     1207
  • trunk/src/kernel32/perfview.cpp

    r7027 r7326  
    1 /* $Id: perfview.cpp,v 1.3 2001-10-12 03:48:06 phaller Exp $ */
     1/* $Id: perfview.cpp,v 1.4 2001-11-12 23:04:57 phaller Exp $ */
    22
    33/*
     
    1919// insert "nullified" dummies here to save space in the executable image
    2020void PerfView_Initialize(void) {}
    21 void PerfView_RegisterCall(char* pszFunctionName,
     21void PerfView_RegisterCall(char* pszCallerName,
     22                           char* pszFunctionName,
    2223                           unsigned long int nTicks) {}
    2324
     
    8788
    8889// register a call to a function
    89 void _Optlink PerfView_RegisterCall(char* pszFunctionName,
     90void _Optlink PerfView_RegisterCall(char* pszCallerName,
     91                                    char* pszFunctionName,
    9092                                    unsigned long int nTicks)
    9193{
     
    127129  if (nTicks > p->nMaximumTicks)
    128130    p->nMaximumTicks = nTicks;
     131
     132
     133  // add call-path tracing
     134  if (NULL != pszCallerName)
     135  {
     136    // build path name
     137    char szBuf[256];
     138    strcpy(szBuf, pszCallerName);
     139    strcat(szBuf, "->");
     140    strcat(szBuf, pszFunctionName);
     141   
     142    // check if that particular callpath is registered already
     143    PPERFVIEW_FUNCTION p2 = (PPERFVIEW_FUNCTION)pProfileMap->getElement(szBuf);
     144    if (NULL == p2)
     145    {
     146      // new function call
     147      p2 = (PPERFVIEW_FUNCTION)malloc( sizeof( PERFVIEW_FUNCTION ) );
     148      p2->pszFunctionName = strdup( szBuf );
     149      p2->nCalled = 0;
     150      p2->nTotalTicks = 0;
     151      p2->nMinimumTicks = 0xffffffff;
     152      p2->nMaximumTicks = 0;
     153     
     154      // add to the hashtable
     155      pProfileMap->addElement(p2->pszFunctionName, p2);
     156    }
     157   
     158    // update statistical data
     159    p2->nCalled++;
     160    p2->nTotalTicks += nTicks;
     161   
     162    if (nTicks < p2->nMinimumTicks)
     163      p2->nMinimumTicks = nTicks;
     164   
     165    if (nTicks > p2->nMaximumTicks)
     166      p2->nMaximumTicks = nTicks;
     167  }
    129168}
    130169
  • trunk/src/kernel32/thread.cpp

    r7318 r7326  
    1 /* $Id: thread.cpp,v 1.33 2001-11-10 12:47:48 sandervl Exp $ */
     1/* $Id: thread.cpp,v 1.34 2001-11-12 23:04:56 phaller Exp $ */
    22
    33/*
     
    9090
    9191
     92#define MAX_CALLSTACK_SIZE 128
     93void WIN32API dbg_ThreadPushCall(char *pszCaller)
     94{
     95#ifdef DEBUG
     96  TEB *teb;
     97 
     98  // embedded dbg_IncThreadCallDepth
     99  teb = GetThreadTEB();
     100  if(teb == NULL)
     101    return;
     102   
     103  teb->o.odin.dbgCallDepth++;
     104 
     105  // add caller name to call stack trace
     106  int iIndex = teb->o.odin.dbgCallDepth;
     107 
     108  // allocate callstack on demand
     109  if (teb->o.odin.arrstrCallStack == NULL)
     110    teb->o.odin.arrstrCallStack = (PVOID*)malloc( sizeof(LPSTR) * MAX_CALLSTACK_SIZE);
     111 
     112  // insert entry
     113  if (iIndex < MAX_CALLSTACK_SIZE)
     114    teb->o.odin.arrstrCallStack[iIndex] = (PVOID)pszCaller;
     115#endif
     116}
     117
     118
    92119void WIN32API dbg_DecThreadCallDepth()
    93120{
     
    99126    --(teb->o.odin.dbgCallDepth);
    100127#endif
     128}
     129
     130
     131void WIN32API dbg_ThreadPopCall()
     132{
     133#ifdef DEBUG
     134  TEB *teb;
     135 
     136  // embedded dbg_DecThreadCallDepth
     137  teb = GetThreadTEB();
     138  if(teb == NULL)
     139    return;
     140 
     141  --(teb->o.odin.dbgCallDepth);
     142 
     143  // add caller name to call stack trace
     144  int iIndex = teb->o.odin.dbgCallDepth;
     145 
     146  // insert entry
     147  if (teb->o.odin.arrstrCallStack)
     148    if (iIndex < MAX_CALLSTACK_SIZE)
     149      teb->o.odin.arrstrCallStack[iIndex] = NULL;
     150#endif
     151}
     152
     153char* WIN32API dbg_GetLastCallerName()
     154{
     155  // retrieve last caller name from stack
     156  TEB *teb;
     157 
     158  // embedded dbg_DecThreadCallDepth
     159  teb = GetThreadTEB();
     160  if(teb != NULL)
     161  {
     162    int iIndex = teb->o.odin.dbgCallDepth - 1;
     163    if ( (iIndex > 0) &&
     164         (iIndex < MAX_CALLSTACK_SIZE) )
     165    {
     166      return (char*)teb->o.odin.arrstrCallStack[iIndex];
     167    }
     168  }
     169 
     170  return NULL;
    101171}
    102172
Note: See TracChangeset for help on using the changeset viewer.