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

Method ProcessHotSwapVariables

IDEHelper/DbgModule.cpp:7120–7304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7118}
7119
7120void DbgModule::ProcessHotSwapVariables()
7121{
7122 BP_ZONE("DbgModule::ProcessHotSwapVariables");
7123
7124 auto linkedModule = GetLinkedModule();
7125
7126 for (auto staticVariable : mStaticVariables)
7127 {
7128 bool replaceVariable = false;
7129
7130 const char* findName = staticVariable->GetMappedName();
7131 auto itr = linkedModule->mStaticVariableMap.find(findName);
7132 if (itr != linkedModule->mStaticVariableMap.end())
7133 {
7134 DbgVariable* oldVariable = itr->second;
7135 // If the old static field has the same type as the new static field then we keep the same
7136 // address, otherwise we use the new (zeroed-out) allocated space
7137
7138 auto _GetNewAddress = [&]()
7139 {
7140 addr_target newAddress = 0;
7141 if (mDbgFlavor == DbgFlavor_GNU)
7142 {
7143 newAddress = mDebugTarget->GetStaticAddress(staticVariable);
7144 }
7145 else
7146 {
7147 // In CodeView, the newVariable ends up pointing to the old address, so we need to store
7148 // the location in our own mSymbolNameMap
7149 auto entry = mSymbolNameMap.Find(oldVariable->mLinkName);
7150 if (entry != NULL)
7151 newAddress = entry->mValue->mAddress;
7152 }
7153 return newAddress;
7154 };
7155
7156 if (oldVariable->mType->IsSizedArray())
7157 {
7158 mDebugTarget->GetCompilerSettings();
7159
7160 bool doMerge = strstr(oldVariable->mName, "sBfClassVData") != NULL;
7161 bool keepInPlace = (doMerge) && (strstr(oldVariable->mName, ".vext") == NULL);
7162 if (doMerge)
7163 {
7164 addr_target oldAddress = mDebugTarget->GetStaticAddress(oldVariable);
7165 addr_target newAddress = _GetNewAddress();
7166 if (newAddress == 0)
7167 continue;
7168
7169 uint8* newData = GetHotTargetData(newAddress);
7170 int newArraySize = (int)staticVariable->mType->GetByteCount();
7171 int oldArraySize = (int)oldVariable->mType->GetByteCount();
7172
7173 int copySize = std::min(newArraySize, oldArraySize);
7174
7175 BF_ASSERT((oldArraySize & (sizeof(addr_target) - 1)) == 0);
7176
7177 DbgModule* defModule = oldVariable->mType->mCompileUnit->mDbgModule;

Callers

nothing calls this directly

Calls 14

GetMappedNameMethod · 0.80
findMethod · 0.80
GetStaticAddressMethod · 0.80
GetCompilerSettingsMethod · 0.80
GetByteCountMethod · 0.80
endMethod · 0.45
FindMethod · 0.45
IsSizedArrayMethod · 0.45
EnableWritingMethod · 0.45
ReadMemoryMethod · 0.45
WriteMemoryMethod · 0.45
EqualsMethod · 0.45

Tested by

no test coverage detected