| 2521 | } |
| 2522 | |
| 2523 | void DbgModule::ParseExceptionData() |
| 2524 | { |
| 2525 | if (mExceptionDirectory.IsEmpty()) |
| 2526 | return; |
| 2527 | |
| 2528 | BP_ZONE("DbgModule::ParseExceptionData"); |
| 2529 | |
| 2530 | for (auto entry : mExceptionDirectory) |
| 2531 | { |
| 2532 | const uint8* data = entry.mData; |
| 2533 | const uint8* dataEnd = data + entry.mSize; |
| 2534 | |
| 2535 | static int entryCount = 0; |
| 2536 | |
| 2537 | addr_target imageBase = GetTargetImageBase(); |
| 2538 | |
| 2539 | while (data < dataEnd) |
| 2540 | { |
| 2541 | addr_target beginAddress = GET(uint32); |
| 2542 | addr_target endAddress = GET(uint32); |
| 2543 | uint32 unwindData = GET(uint32); |
| 2544 | |
| 2545 | //TODO: Apparently unwindData can refer to another runtime entry in the .pdata if the LSB is set to 1? |
| 2546 | |
| 2547 | beginAddress += (addr_target)imageBase; |
| 2548 | endAddress += (addr_target)imageBase; |
| 2549 | |
| 2550 | int exSize = (int)(endAddress - beginAddress); |
| 2551 | for (int exOffset = 0; true; exOffset += DBG_MAX_LOOKBACK) |
| 2552 | { |
| 2553 | int curSize = exSize - exOffset; |
| 2554 | if (curSize <= 0) |
| 2555 | break; |
| 2556 | |
| 2557 | BP_ALLOC_T(DbgExceptionDirectoryEntry); |
| 2558 | DbgExceptionDirectoryEntry* exceptionDirectoryEntry = mAlloc.Alloc<DbgExceptionDirectoryEntry>(); |
| 2559 | |
| 2560 | exceptionDirectoryEntry->mAddress = beginAddress + exOffset; |
| 2561 | exceptionDirectoryEntry->mOrigAddressOffset = exOffset; |
| 2562 | exceptionDirectoryEntry->mAddressLength = curSize; |
| 2563 | exceptionDirectoryEntry->mExceptionPos = (int)unwindData; |
| 2564 | exceptionDirectoryEntry->mDbgModule = this; |
| 2565 | mDebugTarget->mExceptionDirectoryMap.Insert(exceptionDirectoryEntry); |
| 2566 | |
| 2567 | entryCount++; |
| 2568 | } |
| 2569 | } |
| 2570 | } |
| 2571 | } |
| 2572 | |
| 2573 | static int gIdx = 0; |
| 2574 | |