mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-09 01:00:51 +00:00
Handled attached metadata
This commit is contained in:
@@ -943,6 +943,10 @@ Program::Program(const byte *bytes, size_t length)
|
||||
functionDecls.erase(0);
|
||||
|
||||
auto getValue = [this, &f](uint64_t v) { return GetFunctionValue(f, v); };
|
||||
auto getMeta = [this, &f](uint64_t v) {
|
||||
size_t idx = (size_t)v;
|
||||
return idx - 1 < m_Metadata.size() ? &m_Metadata[idx] : &f.metadata[idx];
|
||||
};
|
||||
auto getMetaOrNull = [this, &f](uint64_t v) {
|
||||
size_t idx = (size_t)v;
|
||||
return idx == 0 ? NULL : (idx - 1 < m_Metadata.size() ? &m_Metadata[idx - 1]
|
||||
@@ -1096,6 +1100,38 @@ Program::Program(const byte *bytes, size_t length)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(IS_KNOWN(funcChild.id, KnownBlocks::METADATA_ATTACHMENT))
|
||||
{
|
||||
for(const LLVMBC::BlockOrRecord &meta : funcChild.children)
|
||||
{
|
||||
if(meta.IsBlock())
|
||||
{
|
||||
RDCERR("Unexpected subblock in METADATA_ATTACHMENT");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!IS_KNOWN(meta.id, MetaDataRecord::ATTACHMENT))
|
||||
{
|
||||
RDCERR("Unexpected record %u in METADATA_ATTACHMENT", meta.id);
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t idx = 0;
|
||||
|
||||
rdcarray<rdcpair<uint64_t, Metadata *>> attach;
|
||||
|
||||
if(meta.ops.size() % 2 != 0)
|
||||
idx++;
|
||||
|
||||
for(; idx < meta.ops.size(); idx += 2)
|
||||
attach.push_back(make_rdcpair(meta.ops[idx], getMeta(meta.ops[idx + 1])));
|
||||
|
||||
if(meta.ops.size() % 2 == 0)
|
||||
f.attachedMeta.swap(attach);
|
||||
else
|
||||
f.instructions[meta.ops[0]].attachedMeta.swap(attach);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RDCERR("Unexpected subblock %u in FUNCTION_BLOCK", funcChild.id);
|
||||
|
||||
@@ -286,6 +286,8 @@ enum class MathFlags : uint32_t
|
||||
|
||||
BITMASK_OPERATORS(MathFlags);
|
||||
|
||||
typedef rdcarray<rdcpair<uint64_t, Metadata *>> AttachedMetadata;
|
||||
|
||||
struct Instruction
|
||||
{
|
||||
enum
|
||||
@@ -336,6 +338,7 @@ struct Instruction
|
||||
uint32_t debugLoc = ~0U;
|
||||
const Type *type = NULL;
|
||||
rdcarray<Symbol> args;
|
||||
AttachedMetadata attachedMeta;
|
||||
|
||||
// function calls
|
||||
const Attributes *paramAttrs = NULL;
|
||||
@@ -360,6 +363,8 @@ struct Function
|
||||
rdcarray<Block> blocks;
|
||||
rdcarray<Value> values;
|
||||
rdcarray<Metadata> metadata;
|
||||
|
||||
AttachedMetadata attachedMeta;
|
||||
};
|
||||
|
||||
class Program
|
||||
|
||||
@@ -593,6 +593,21 @@ void Program::MakeDisassemblyString()
|
||||
DebugLocation &debugLoc = m_DebugLocations[inst.debugLoc];
|
||||
|
||||
m_Disassembly += StringFormat::Fmt(", !dbg !%u", GetOrAssignMetaID(debugLoc));
|
||||
}
|
||||
|
||||
if(!inst.attachedMeta.empty())
|
||||
{
|
||||
for(size_t m = 0; m < inst.attachedMeta.size(); m++)
|
||||
{
|
||||
m_Disassembly +=
|
||||
StringFormat::Fmt(", !%s !%u", m_Kinds[inst.attachedMeta[m].first].c_str(),
|
||||
GetOrAssignMetaID(inst.attachedMeta[m].second));
|
||||
}
|
||||
}
|
||||
|
||||
if(inst.debugLoc != ~0U)
|
||||
{
|
||||
DebugLocation &debugLoc = m_DebugLocations[inst.debugLoc];
|
||||
|
||||
if(!debugCall && debugLoc.line > 0)
|
||||
{
|
||||
@@ -602,14 +617,26 @@ void Program::MakeDisassemblyString()
|
||||
|
||||
if(debugCall)
|
||||
{
|
||||
if(inst.funcCall->name == "llvm.dbg.value" || inst.funcCall->name == "llvm.dbg.declare")
|
||||
size_t varIdx = 0, exprIdx = 0;
|
||||
if(inst.funcCall->name == "llvm.dbg.value")
|
||||
{
|
||||
RDCASSERT(inst.args[2].type == SymbolType::Metadata);
|
||||
RDCASSERT(inst.args[3].type == SymbolType::Metadata);
|
||||
varIdx = 2;
|
||||
exprIdx = 3;
|
||||
}
|
||||
else if(inst.funcCall->name == "llvm.dbg.declare")
|
||||
{
|
||||
varIdx = 1;
|
||||
exprIdx = 2;
|
||||
}
|
||||
|
||||
if(varIdx > 0)
|
||||
{
|
||||
RDCASSERT(inst.args[varIdx].type == SymbolType::Metadata);
|
||||
RDCASSERT(inst.args[exprIdx].type == SymbolType::Metadata);
|
||||
m_Disassembly += StringFormat::Fmt(
|
||||
" ; var:%s ",
|
||||
escapeString(GetDebugVarName(GetFunctionMetadata(func, inst.args[2].idx)->dwarf)));
|
||||
m_Disassembly += GetFunctionMetadata(func, inst.args[3].idx)->valString();
|
||||
" ; var:%s ", escapeString(GetDebugVarName(
|
||||
GetFunctionMetadata(func, inst.args[varIdx].idx)->dwarf)));
|
||||
m_Disassembly += GetFunctionMetadata(func, inst.args[exprIdx].idx)->valString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user