Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SharedCache] Serialize SharedCache::m_symbolInfos #6174

Merged
merged 2 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion view/sharedcache/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ endif()
set(HARD_FAIL_MODE OFF CACHE BOOL "Enable hard fail mode")
set(SLIDEINFO_DEBUG_TAGS OFF CACHE BOOL "Enable debug tags in slideinfo")
set(VIEW_NAME "DSCView" CACHE STRING "Name of the view")
set(METADATA_VERSION 2 CACHE STRING "Version of the metadata")
set(METADATA_VERSION 3 CACHE STRING "Version of the metadata")

add_subdirectory(core)
add_subdirectory(api)
Expand Down
32 changes: 27 additions & 5 deletions view/sharedcache/core/SharedCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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())
Expand Down