diff options
| author | KyleMiles <krm504@nyu.edu> | 2021-05-19 20:40:24 -0400 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2021-07-07 23:27:29 -0400 |
| commit | d19f5e85ee26c3d6604798d30ab821d15731cada (patch) | |
| tree | 9851b7f6bf5589df69508d4489c11148515cb550 /binaryninjaapi.h | |
| parent | 0f58b0742e3010eee6bbd2e15f4dd4930ec0d822 (diff) | |
DebugInfo - plugable debug information importers - C++, Rust, and Python APIs
Diffstat (limited to 'binaryninjaapi.h')
| -rw-r--r-- | binaryninjaapi.h | 90 |
1 files changed, 89 insertions, 1 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 5c3e0cde..6d4119ca 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -1301,6 +1301,17 @@ __attribute__ ((format (printf, 1, 2))) bool autoDiscovered; }; + struct DataVariableAndName + { + DataVariableAndName() { } + DataVariableAndName(uint64_t a, Type* t, bool d, const std::string& n) : address(a), type(t), autoDiscovered(d), name(n) { } + + uint64_t address; + Confidence<Ref<Type>> type; + bool autoDiscovered; + std::string name; + }; + class TagType: public CoreRefCountObject<BNTagType, BNNewTagTypeReference, BNFreeTagType> { public: @@ -5623,8 +5634,85 @@ __attribute__ ((format (printf, 1, 2))) uint64_t findConstant; DataBuffer findBuffer; - + std::vector<BNAddressRange> ranges; uint64_t totalLength; }; + + struct DebugFunctionInfo + { + std::string shortName; + std::string fullName; + std::string rawName; + uint64_t address; + Ref<Type> returnType; + std::vector<std::tuple<std::string, Ref<Type>>> parameters; + bool variableParameters; + Ref<CallingConvention> callingConvention; + Ref<Platform> platform; + + DebugFunctionInfo(std::string shortName, + std::string fullName, + std::string rawName, + uint64_t address, + Ref<Type> returnType, + std::vector<std::tuple<std::string, Ref<Type>>> parameters, + bool variableParameters, + Ref<CallingConvention> callingConvention, + Ref<Platform> platform) : + shortName(shortName), + fullName(fullName), + rawName(rawName), + address(address), + returnType(returnType), + parameters(parameters), + variableParameters(variableParameters), + callingConvention(callingConvention), + platform(platform) + {} + }; + + class DebugInfo : public CoreRefCountObject<BNDebugInfo, BNNewDebugInfoReference, BNFreeDebugInfoReference> + { + public: + DebugInfo(BNDebugInfo* debugInfo); + + std::vector<NameAndType> GetTypes(const std::string& parserName = ""); + std::vector<DebugFunctionInfo> GetFunctions(const std::string& parserName = ""); + std::vector<DataVariableAndName> GetDataVariables(const std::string& parserName = ""); + + bool AddType(const std::string& name, Ref<Type> type); + bool AddFunction(const DebugFunctionInfo& function); + bool AddDataVariable(uint64_t address, Ref<Type> type, const std::string& name = ""); + }; + + class DebugInfoParser : public CoreRefCountObject<BNDebugInfoParser, BNNewDebugInfoParserReference, BNFreeDebugInfoParserReference> + { + public: + DebugInfoParser(BNDebugInfoParser* parser); + + static Ref<DebugInfoParser> GetByName(const std::string& name); + static std::vector<Ref<DebugInfoParser>> GetList(); + static std::vector<Ref<DebugInfoParser>> GetListForView(const Ref<BinaryView> data); + + std::string GetName() const; + Ref<DebugInfo> Parse(Ref<BinaryView> view, Ref<DebugInfo> existingDebugInfo = nullptr) const; + + bool IsValidForView(const Ref<BinaryView> view) const; + }; + + class CustomDebugInfoParser : public DebugInfoParser + { + static bool IsValidCallback(void* ctxt, BNBinaryView* view); + static void ParseCallback(void* ctxt, BNDebugInfo* debugInfo, BNBinaryView* view); + BNDebugInfoParser* Register(const std::string& name); + + public: + CustomDebugInfoParser(const std::string& name); + virtual ~CustomDebugInfoParser() {} + + virtual bool IsValid(Ref<BinaryView>) = 0; + virtual void ParseInfo(Ref<DebugInfo>, Ref<BinaryView>) = 0; + }; } + |
