Show
Ignore:
Timestamp:
11/19/08 13:24:39 (17 years ago)
Author:
yumileroy
Message:

[svn] * Updated to 6743 and 685

Moved language id used by Arena to a higher place to solve conflicts
Added the empty script folders

Original author: Neo2003
Date: 2008-10-09 08:42:22-05:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/shared/WheatyExceptionReport.cpp

    r2 r28  
    99#pragma warning(disable:4311) 
    1010#include <windows.h> 
     11#include <tlhelp32.h> 
    1112#include <stdio.h> 
    1213#include <tchar.h> 
     
    328329 
    329330//=========================================================================== 
     331void WheatyExceptionReport::printTracesForAllThreads() 
     332{ 
     333  HANDLE hThreadSnap = INVALID_HANDLE_VALUE;  
     334  THREADENTRY32 te32;  
     335  
     336  DWORD dwOwnerPID = GetCurrentProcessId(); 
     337  m_hProcess = GetCurrentProcess(); 
     338  // Take a snapshot of all running threads   
     339  hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );  
     340  if( hThreadSnap == INVALID_HANDLE_VALUE )  
     341    return;  
     342  
     343  // Fill in the size of the structure before using it.  
     344  te32.dwSize = sizeof(THREADENTRY32 );  
     345  
     346  // Retrieve information about the first thread, 
     347  // and exit if unsuccessful 
     348  if( !Thread32First( hThreadSnap, &te32 ) )  
     349  { 
     350    CloseHandle( hThreadSnap );    // Must clean up the 
     351                                   //   snapshot object! 
     352    return; 
     353  } 
     354 
     355  // Now walk the thread list of the system, 
     356  // and display information about each thread 
     357  // associated with the specified process 
     358  do  
     359  {  
     360    if( te32.th32OwnerProcessID == dwOwnerPID ) 
     361    { 
     362        CONTEXT context; 
     363        context.ContextFlags = 0xffffffff; 
     364        HANDLE threadHandle = OpenThread(THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION,false, te32.th32ThreadID); 
     365        if(threadHandle && GetThreadContext(threadHandle, &context)) 
     366        { 
     367            WriteStackDetails( &context, false, threadHandle ); 
     368        } 
     369        CloseHandle(threadHandle); 
     370    } 
     371  } while( Thread32Next(hThreadSnap, &te32 ) );  
     372 
     373//  Don't forget to clean up the snapshot object. 
     374  CloseHandle( hThreadSnap ); 
     375} 
     376 
     377 
     378//=========================================================================== 
    330379// Open the report file, and write the desired information to it.  Called by 
    331380// WheatyUnhandledExceptionFilter 
     
    412461    CONTEXT trashableContext = *pCtx; 
    413462 
    414     WriteStackDetails( &trashableContext, false ); 
     463    WriteStackDetails( &trashableContext, false, NULL ); 
     464    printTracesForAllThreads(); 
    415465 
    416466//    #ifdef _M_IX86                                          // X86 Only! 
     
    420470 
    421471    trashableContext = *pCtx; 
    422     WriteStackDetails( &trashableContext, true ); 
     472    WriteStackDetails( &trashableContext, true, NULL ); 
    423473 
    424474    _tprintf( _T("========================\r\n") ); 
     
    552602void WheatyExceptionReport::WriteStackDetails( 
    553603PCONTEXT pContext, 
    554 bool bWriteVariables )                                      // true if local/params should be output 
     604bool bWriteVariables, HANDLE pThreadHandle)                                      // true if local/params should be output 
    555605{ 
    556606    _tprintf( _T("\r\nCall stack:\r\n") ); 
     
    592642        if ( ! StackWalk64(  dwMachineType, 
    593643            m_hProcess, 
    594             GetCurrentThread(), 
     644            pThreadHandle != NULL ? pThreadHandle : GetCurrentThread(), 
    595645            &sf, 
    596646            pContext,