mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Remap SPDB line-numbers after sorting filenames
This commit is contained in:
@@ -998,6 +998,12 @@ SPDBChunk::SPDBChunk(void *chunk)
|
||||
|
||||
delete[] pages;
|
||||
|
||||
// save the filenames in their original order
|
||||
std::vector<std::string> filenames;
|
||||
filenames.reserve(Files.size());
|
||||
for(size_t i = 0; i < Files.size(); i++)
|
||||
filenames.push_back(Files[i].first);
|
||||
|
||||
// Sort files according to the order they come in the Names array, this seems to be more reliable
|
||||
// about placing the main file first.
|
||||
std::sort(Files.begin(), Files.end(), [&Names](const std::pair<std::string, std::string> &a,
|
||||
@@ -1024,6 +1030,19 @@ SPDBChunk::SPDBChunk(void *chunk)
|
||||
return aIdx < bIdx;
|
||||
});
|
||||
|
||||
// create a map from filename -> index
|
||||
std::map<std::string, int32_t> remapping;
|
||||
for(size_t i = 0; i < Files.size(); i++)
|
||||
remapping[Files[i].first] = (int32_t)i;
|
||||
|
||||
// remap the line info by looking up the original intended filename, then looking up the new index
|
||||
for(auto it = m_LineNumbers.begin(); it != m_LineNumbers.end(); ++it)
|
||||
{
|
||||
if(it->second.fileIndex == -1)
|
||||
continue;
|
||||
it->second.first = remapping[filenames[it->second.first]];
|
||||
}
|
||||
|
||||
m_HasDebugInfo = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user