Changeset 1019 for trunk/dll/fortify.c


Ignore:
Timestamp:
May 26, 2008, 11:02:41 PM (17 years ago)
Author:
Steven Levine
Message:

Show TID for leaking scope

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/fortify.c

    r1015 r1019  
    4242
    4343 /* 06 May 08 SHL Rework scope logic to be MT capable
     44    26 May 08 SHL Show TID for leaking scope
    4445 */
    4546
     
    6667#define MT_SCOPES 1
    6768unsigned long Get_TID_Ordinal(void);
     69// Get tib_ptib2 from TIB
     70// Get thread id from TIB2
    6871#pragma aux Get_TID_Ordinal = \
    69  "mov eax, far ptr fs:[0x14]" \
    70  modify exact [eax] \
     72 "mov ebx, fs:[0xc]" \
     73 "mov eax, [ebx+0]" \
     74 modify exact [eax ebx] \
    7175 value [eax]
    7276#endif
     
    252256
    253257#ifdef MT_SCOPES
    254     unsigned short ordinal;
     258    unsigned ordinal;
    255259#endif
    256260
     
    686690#ifdef MT_SCOPES
    687691    ordinal = Get_TID_Ordinal();
    688     if(ordinal < st_cScopes && st_pScopes[ordinal] > 0)
     692    if (ordinal < st_cScopes && st_pScopes[ordinal] > 0)
    689693#else
    690694    if(st_Scope > 0)
     
    10041008
    10051009#ifdef MT_SCOPES
    1006     // 06 May 08 SHL fixme to complain to leave without enter
     1010    // Complain on leave without enter 06 May 08 SHL
    10071011    ordinal = Get_TID_Ordinal();
    10081012    if (ordinal < st_cScopes && st_pScopes[ordinal] > 0)
    10091013        st_pScopes[ordinal]--;
    10101014    else {
    1011         sprintf(st_Buffer, "\nFortify: attempting to leave scope before enter at %s.%lu\n", file, line);
     1015        sprintf(st_Buffer,
     1016                "\nFortify: attempting to leave scope before enter at %s.%lu in TID %u\n",
     1017                file, line, ordinal);   // 26 May 08 SHL
    10121018        st_Output(st_Buffer);
    10131019    }
     
    10311037            {
    10321038                // Report just first occurrance
     1039#ifdef MT_SCOPES
     1040                sprintf(st_Buffer,
     1041                        "\nFortify: Memory leak detected leaving scope at %s.%lu in TID %u\n",
     1042                        file, line, ordinal);
     1043#else
    10331044                sprintf(st_Buffer, "\nFortify: Memory leak detected leaving scope at %s.%lu\n", file, line);
     1045#endif
    10341046                st_Output(st_Buffer);
    10351047                sprintf(st_Buffer, "%10s %8s %s\n", "Address", "Size", "Allocator");
     
    16801692    unsigned long FreedBlocks = 0;
    16811693#ifdef MT_SCOPES
    1682     unsigned short ordinal = Get_TID_Ordinal();
     1694    unsigned ordinal = Get_TID_Ordinal();
    16831695#endif
    16841696
Note: See TracChangeset for help on using the changeset viewer.