summaryrefslogtreecommitdiff
path: root/view/sharedcache/core/SharedCache.cpp
diff options
context:
space:
mode:
authorWeiN76LQh <WeiN76LQh@github.com>2024-11-21 17:36:01 +0000
committerkat <kat@vector35.com>2024-12-23 11:38:42 -0500
commitfb31e0abb07eb40179310a0cb817b18831321900 (patch)
tree3d58baab0d1f57988127a0491635ab1ac4fe1a0f /view/sharedcache/core/SharedCache.cpp
parent3429718517806507641861347342952251225833 (diff)
[SharedCache] Serialize `SharedCache::m_symbolInfos`
`SharedCache::m_symbolInfos` isn't being serialized but there is an attempt to deserialize it. This commit adds in the code to serialize it. I slightly modified the format because I didn't really understand how it was expected to be serialized based on the deserialization code. The deserialization code looked wrong to me but its likely a misunderstanding on my part. I kept it similar to how `m_exportInfos` is serialized.
Diffstat (limited to 'view/sharedcache/core/SharedCache.cpp')
-rw-r--r--view/sharedcache/core/SharedCache.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/view/sharedcache/core/SharedCache.cpp b/view/sharedcache/core/SharedCache.cpp
index 81b5053a..e4d4ef11 100644
--- a/view/sharedcache/core/SharedCache.cpp
+++ b/view/sharedcache/core/SharedCache.cpp
@@ -3386,6 +3386,27 @@ void SharedCache::Store(SerializationContext& context) const
}
context.writer.EndArray();
+ Serialize(context, "symbolInfos");
+ context.writer.StartArray();
+ for (const auto& pair1 : State().symbolInfos)
+ {
+ context.writer.StartObject();
+ Serialize(context, "key", pair1.first);
+ Serialize(context, "value");
+ context.writer.StartArray();
+ for (const auto& pair2 : pair1.second)
+ {
+ context.writer.StartObject();
+ Serialize(context, "key", pair2.first);
+ Serialize(context, "val1", pair2.second.first);
+ Serialize(context, "val2", pair2.second.second);
+ context.writer.EndObject();
+ }
+ context.writer.EndArray();
+ context.writer.EndObject();
+ }
+ context.writer.EndArray();
+
Serialize(context, "backingCaches", State().backingCaches);
Serialize(context, "stubIslands", State().stubIslandRegions);
Serialize(context, "images", State().images);
@@ -3441,13 +3462,14 @@ void SharedCache::Load(DeserializationContext& context)
for (auto& symbolInfo : context.doc["symbolInfos"].GetArray())
{
- std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>> symbolInfoVec;
- for (auto& symbolInfoPair : symbolInfo.GetArray())
+ std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>>
+ symbolInfos;
+ for (auto& si : symbolInfo["value"].GetArray())
{
- symbolInfoVec.push_back({symbolInfoPair[0].GetUint64(),
- {(BNSymbolType)symbolInfoPair[1].GetUint(), symbolInfoPair[2].GetString()}});
+ symbolInfos.push_back({si["key"].GetUint64(),
+ {static_cast<BNSymbolType>(si["val1"].GetUint64()), si["val2"].GetString()}});
}
- MutableState().symbolInfos[symbolInfo[0].GetUint64()] = std::move(symbolInfoVec);
+ MutableState().symbolInfos[symbolInfo["key"].GetUint64()] = std::move(symbolInfos);
}
for (auto& bcV : context.doc["backingCaches"].GetArray())