MCPcopy Create free account
hub / github.com/beefytech/Beef / PropogateRegisterUpCallStack_ExceptionDirectory

Method PropogateRegisterUpCallStack_ExceptionDirectory

IDEHelper/DebugTarget.cpp:1187–1420  ·  view source on GitHub ↗

We write the modified callerRegisters into the saved memory locations in the callee's stack frame -- this is needed for modifying variables tied to non-volatile registers on non-topmost stack frames

Source from the content-addressed store, hash-verified

1185// We write the modified callerRegisters into the saved memory locations in the callee's stack frame --
1186// this is needed for modifying variables tied to non-volatile registers on non-topmost stack frames
1187bool DebugTarget::PropogateRegisterUpCallStack_ExceptionDirectory(addr_target findPC, CPURegisters* callerRegisters, CPURegisters* calleeRegisters, void* regPtr, bool& wasSaved)
1188{
1189 addr_target pcAddress = calleeRegisters->GetPC();
1190
1191 auto exceptionDirectoryEntry = mExceptionDirectoryMap.Get(findPC, DBG_MAX_LOOKBACK);
1192 if ((exceptionDirectoryEntry != NULL) && (findPC >= exceptionDirectoryEntry->mAddress) &&
1193 (findPC < exceptionDirectoryEntry->mAddress + exceptionDirectoryEntry->mAddressLength))
1194 {
1195 auto dbgModule = exceptionDirectoryEntry->mDbgModule;
1196 //const uint8* data = dbgModule->mExceptionData + exceptionDirectoryEntry->mExceptionPos;
1197
1198 uint32 exceptionPos = exceptionDirectoryEntry->mExceptionPos;
1199 while ((exceptionPos & 1) != 0)
1200 {
1201 // It's a reference to another entry -- directly reference the 'exceptionPos' from that other entry
1202 dbgModule->mOrigImageData->Read(dbgModule->mImageBase + (exceptionPos & ~1) + 8, (uint8*)&exceptionPos, 4);
1203 }
1204
1205 struct EntryHeader
1206 {
1207 uint8 mVersion;
1208 uint8 mPrologSize;
1209 uint8 mNumUnwindCodes;
1210 uint8 mFrameRegister;
1211 };
1212
1213 EntryHeader entryHeader;
1214
1215 dbgModule->mOrigImageData->Read(dbgModule->mImageBase + exceptionPos, (uint8*)&entryHeader, sizeof(EntryHeader));
1216
1217 uint8 version = entryHeader.mVersion;
1218 uint8 flags = (version >> 3);
1219 version &= 7;
1220
1221 int dataSize = entryHeader.mNumUnwindCodes * 2;
1222
1223 if (flags & 4) // UNW_FLAG_CHAININFO
1224 {
1225 if ((entryHeader.mNumUnwindCodes % 2) == 1)
1226 dataSize += 2; // Align
1227 dataSize += sizeof(uint32)*3;
1228 }
1229
1230 uint8 dataBuf[512];
1231 dbgModule->mOrigImageData->Read(dbgModule->mImageBase + exceptionPos + sizeof(EntryHeader), dataBuf, dataSize);
1232 const uint8* data = dataBuf;
1233
1234 if (flags & 1) // UNW_FLAG_EHANDLER
1235 {
1236 }
1237 else if (flags & 4) // UNW_FLAG_CHAININFO
1238 {
1239 }
1240
1241 /*if (pcAddress < exceptionDirectoryEntry->mAddress + prologSize)
1242 {
1243 // We're in the prolog so just do a standard leaf 'ret'
1244 return false;

Callers

nothing calls this directly

Calls 8

GetPCMethod · 0.45
GetMethod · 0.45
ReadMethod · 0.45
GetSPMethod · 0.45
WriteMemoryMethod · 0.45
GetXMMRegRefMethod · 0.45
GetPCRegisterRefMethod · 0.45

Tested by

no test coverage detected