Changeset 47290 in vbox for trunk/src/VBox/Runtime/common/dbg/dbgmoddwarf.cpp
- Timestamp:
- Jul 21, 2013 9:59:53 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/dbg/dbgmoddwarf.cpp
r47057 r47290 388 388 typedef struct RTDWARFABBREV 389 389 { 390 /** Whether this entry is filled in or not. */391 bool fFilled;392 390 /** Whether there are children or not. */ 393 391 bool fChildren; … … 396 394 /** Offset into the abbrev section of the specification pairs. */ 397 395 uint32_t offSpec; 396 /** The abbreviation table offset this is entry is valid for. 397 * UINT32_MAX if not valid. */ 398 uint32_t offAbbrev; 398 399 } RTDWARFABBREV; 399 400 /** Pointer to an abbreviation cache entry. */ … … 453 454 /** The number of cached abbreviations we've allocated space for. */ 454 455 uint32_t cCachedAbbrevsAlloced; 455 /** Used for range checking cache lookups. */456 uint32_t cCachedAbbrevs;457 456 /** Array of cached abbreviations, indexed by code. */ 458 457 PRTDWARFABBREV paCachedAbbrevs; … … 2838 2837 if (pThis->cCachedAbbrevsAlloced < uCode) 2839 2838 { 2840 if (uCode > _64K)2839 if (uCode >= _64K) 2841 2840 fFillCache = false; 2842 2841 else … … 2848 2847 else 2849 2848 { 2849 Log(("rtDwarfAbbrev_LookupMiss: Growing from %u to %u...\n", pThis->cCachedAbbrevsAlloced, cNew)); 2850 pThis->paCachedAbbrevs = (PRTDWARFABBREV)pv; 2851 for (uint32_t i = pThis->cCachedAbbrevsAlloced; i < cNew; i++) 2852 pThis->paCachedAbbrevs[i].offAbbrev = UINT32_MAX; 2850 2853 pThis->cCachedAbbrevsAlloced = cNew; 2851 pThis->paCachedAbbrevs = (PRTDWARFABBREV)pv;2852 2854 } 2853 2855 } … … 2867 2869 /* 2868 2870 * Search for the entry and fill the cache while doing so. 2871 * We assume that abbreviation codes for a unit will stop when we see 2872 * zero code or when the code value drops. 2869 2873 */ 2874 uint32_t uPrevCode = 0; 2870 2875 for (;;) 2871 2876 { 2872 2877 /* Read the 'header'. Skipping zero code bytes. */ 2873 uint32_t const uCurCode = rtDwarfCursor_GetULeb128AsU32(&Cursor, 0); 2878 uint32_t const uCurCode = rtDwarfCursor_GetULeb128AsU32(&Cursor, 0); 2879 if (pRet && (uCurCode == 0 || uCurCode < uPrevCode)) 2880 break; /* probably end of unit. */ 2874 2881 if (uCurCode != 0) 2875 2882 { … … 2889 2896 { 2890 2897 PRTDWARFABBREV pEntry = &pThis->paCachedAbbrevs[uCurCode - 1]; 2891 while (pThis->cCachedAbbrevs < uCurCode)2898 if (pEntry->offAbbrev != pThis->offCachedAbbrev) 2892 2899 { 2893 pThis->paCachedAbbrevs[pThis->cCachedAbbrevs].fFilled = false; 2894 pThis->cCachedAbbrevs++; 2900 pEntry->offAbbrev = pThis->offCachedAbbrev; 2901 pEntry->fChildren = RT_BOOL(uChildren); 2902 pEntry->uTag = uCurTag; 2903 pEntry->offSpec = rtDwarfCursor_CalcSectOffsetU32(&Cursor); 2904 2905 if (uCurCode == uCode) 2906 { 2907 Assert(!pRet); 2908 pRet = pEntry; 2909 if (uCurCode == pThis->cCachedAbbrevsAlloced) 2910 break; 2911 } 2895 2912 } 2896 2897 pEntry->fFilled = true; 2898 pEntry->fChildren = RT_BOOL(uChildren); 2899 pEntry->uTag = uCurTag; 2900 pEntry->offSpec = rtDwarfCursor_CalcSectOffsetU32(&Cursor); 2901 2902 if (uCurCode == uCode) 2903 { 2904 pRet = pEntry; 2905 if (uCurCode == pThis->cCachedAbbrevsAlloced) 2906 break; 2907 } 2913 else if (pRet) 2914 break; /* Next unit, don't cache more. */ 2915 /* else: We're growing the cache and re-reading old data. */ 2908 2916 } 2909 2917 … … 2949 2957 { 2950 2958 pRet = &pThis->LookupAbbrev; 2951 pRet->fFilled = true;2952 2959 pRet->fChildren = RT_BOOL(uChildren); 2953 2960 pRet->uTag = uCurTag; 2954 2961 pRet->offSpec = rtDwarfCursor_CalcSectOffsetU32(&Cursor); 2962 pRet->offAbbrev = pThis->offCachedAbbrev; 2955 2963 break; 2956 2964 } … … 2983 2991 static PCRTDWARFABBREV rtDwarfAbbrev_Lookup(PRTDBGMODDWARF pThis, uint32_t uCode) 2984 2992 { 2985 if ( uCode - 1 >= pThis->cCachedAbbrevs 2986 || !pThis->paCachedAbbrevs[uCode - 1].fFilled)2993 if ( uCode - 1 >= pThis->cCachedAbbrevsAlloced 2994 || pThis->paCachedAbbrevs[uCode - 1].offAbbrev != pThis->offCachedAbbrev) 2987 2995 return rtDwarfAbbrev_LookupMiss(pThis, uCode); 2988 2996 return &pThis->paCachedAbbrevs[uCode - 1]; … … 2993 3001 * Sets the abbreviation offset of the current unit. 2994 3002 * 2995 * This will flush the cached abbreviation entries if the offset differs from2996 * the previous unit.2997 *2998 3003 * @param pThis The DWARF instance. 2999 3004 * @param offAbbrev The offset into the abbreviation section. … … 3001 3006 static void rtDwarfAbbrev_SetUnitOffset(PRTDBGMODDWARF pThis, uint32_t offAbbrev) 3002 3007 { 3003 if (pThis->offCachedAbbrev != offAbbrev) 3004 { 3005 pThis->offCachedAbbrev = offAbbrev; 3006 pThis->cCachedAbbrevs = 0; 3007 } 3008 pThis->offCachedAbbrev = offAbbrev; 3008 3009 } 3009 3010 … … 4284 4285 { 4285 4286 /* End of siblings, up one level. (Is this correct?) */ 4286 pParentDie = pParentDie->pParent; 4287 if (!pParentDie) 4287 if (pParentDie->pParent) 4288 4288 { 4289 /* Padding. */ 4290 while (!rtDwarfCursor_IsAtEndOfUnit(pCursor)) 4291 { 4292 uAbbrCode = rtDwarfCursor_GetULeb128AsU32(pCursor, UINT32_MAX); 4293 if (uAbbrCode) 4294 { 4295 Log(("%08x: End of DIE stack, but still more info to parse: uAbbrCode=%#x (+%u bytes).\n", 4296 offLog, uAbbrCode, pCursor->cbUnitLeft)); 4297 return VERR_DWARF_BAD_INFO; 4298 } 4299 } 4300 break; 4289 pParentDie = pParentDie->pParent; 4290 cDepth--; 4291 if (!fKeepDies && pParentDie->pParent) 4292 rtDwarfInfo_FreeChildren(pThis, pParentDie); 4301 4293 } 4302 cDepth--;4303 if (!fKeepDies && pParentDie->pParent)4304 rtDwarfInfo_FreeChildren(pThis, pParentDie);4305 4294 } 4306 4295 else … … 4326 4315 pDieDesc = g_aTagDescs[0].pDesc; 4327 4316 } 4328 Log4(("%08x: %*stag=%s (%#x )%s\n", offLog, cDepth * 2, "", pszName,4329 pAbbrev->uTag, pAbbrev->fChildren ? " has children" : ""));4317 Log4(("%08x: %*stag=%s (%#x, abbrev %u)%s\n", offLog, cDepth * 2, "", pszName, 4318 pAbbrev->uTag, uAbbrCode, pAbbrev->fChildren ? " has children" : "")); 4330 4319 4331 4320 /* … … 4756 4745 * Free the cached abbreviations and unload all sections. 4757 4746 */ 4758 pThis->cCachedAbbrevs = pThis->cCachedAbbrevsAlloced = 0;4747 pThis->cCachedAbbrevsAlloced = 0; 4759 4748 RTMemFree(pThis->paCachedAbbrevs); 4749 pThis->paCachedAbbrevs = NULL; 4760 4750 4761 4751 for (unsigned iSect = 0; iSect < RT_ELEMENTS(pThis->aSections); iSect++)
Note:
See TracChangeset
for help on using the changeset viewer.