diff options
| author | Josh Ferrell <josh@vector35.com> | 2024-06-13 14:13:11 -0400 |
|---|---|---|
| committer | Josh Ferrell <josh@vector35.com> | 2024-06-13 14:13:11 -0400 |
| commit | d75066545afdc9b5d0a52bd2518e43f683c671a5 (patch) | |
| tree | bed26d348a726fc02c1d44cbdc36a8056b44baaf /debuginfo.cpp | |
| parent | f3a440248cda4d0c850cd32e3aa127ab29e0bb3e (diff) | |
Apply stack variables from DWARF
Diffstat (limited to 'debuginfo.cpp')
| -rw-r--r-- | debuginfo.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/debuginfo.cpp b/debuginfo.cpp index 412d44bb..9a4a2c9e 100644 --- a/debuginfo.cpp +++ b/debuginfo.cpp @@ -96,11 +96,26 @@ vector<DebugFunctionInfo> DebugInfo::GetFunctions(const string& parserName) cons vector<string> components; for (size_t componentN = 0; componentN < functions[i].componentN; ++componentN) components.emplace_back(functions[i].components[componentN]); + + vector<VariableNameAndType> localVariables; + for (size_t localVariableN = 0; localVariableN < functions[i].localVariableN; ++localVariableN) + { + auto& bnVar = functions[i].localVariables[localVariableN]; + + VariableNameAndType vnt; + vnt.var = bnVar.var; + vnt.name = bnVar.name; + vnt.autoDefined = bnVar.autoDefined; + vnt.type = Confidence<Ref<Type>>(new Type(BNNewTypeReference(bnVar.type)), bnVar.typeConfidence); + localVariables.push_back(vnt); + } + result.emplace_back(functions[i].shortName ? functions[i].shortName : "", functions[i].fullName ? functions[i].fullName : "", functions[i].rawName ? functions[i].rawName : "", functions[i].address, functions[i].type ? new Type(BNNewTypeReference(functions[i].type)) : nullptr, - functions[i].platform ? new CorePlatform(BNNewPlatformReference(functions[i].platform)) : nullptr, components); + functions[i].platform ? new CorePlatform(BNNewPlatformReference(functions[i].platform)) : nullptr, + components, localVariables); } BNFreeDebugFunctions(functions, count); @@ -286,6 +301,17 @@ bool DebugInfo::AddFunction(const DebugFunctionInfo& function) for (size_t i = 0; i < function.components.size(); ++i) components[i] = (char*)function.components[i].c_str(); + BNVariableNameAndType* localVariables = new BNVariableNameAndType[function.localVariables.size()]; + for (size_t i = 0; i < function.localVariables.size(); i++) + { + auto v = function.localVariables[i]; + localVariables[i].var = v.var; + localVariables[i].type = v.type.GetValue()->m_object; + localVariables[i].typeConfidence = v.type.GetConfidence(); + localVariables[i].name = (char*)v.name.c_str(); + localVariables[i].autoDefined = v.autoDefined; + } + BNDebugFunctionInfo input; input.shortName = function.shortName.size() ? BNAllocString(function.shortName.c_str()) : nullptr; @@ -296,13 +322,16 @@ bool DebugInfo::AddFunction(const DebugFunctionInfo& function) input.platform = function.platform ? function.platform->GetObject() : nullptr; input.components = components; input.componentN = function.components.size(); + input.localVariables = localVariables; + input.localVariableN = function.localVariables.size(); bool result = BNAddDebugFunction(m_object, &input); BNFreeString(input.shortName); BNFreeString(input.fullName); BNFreeString(input.rawName); - + delete[] components; + delete[] localVariables; return result; } |
