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

.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.