diff options
| author | Peter LaFosse <peter@vector35.com> | 2017-03-05 13:12:01 -0500 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2017-03-05 13:12:01 -0500 |
| commit | cf5997848b8819725315bd2c8dd8a04c70da3b63 (patch) | |
| tree | 24d9360e3ccfaee361aca4d345072c142c386a41 /architecture.cpp | |
| parent | a0132eed82d28d4408a2475847e1804a157b3dc1 (diff) | |
| parent | 27f1271083efb09efc6405f91be893ab38dad9a0 (diff) | |
Merginging with dev
Diffstat (limited to 'architecture.cpp')
| -rw-r--r-- | architecture.cpp | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/architecture.cpp b/architecture.cpp index 3c7d9af8..d72e7f42 100644 --- a/architecture.cpp +++ b/architecture.cpp @@ -52,7 +52,14 @@ InstructionTextToken::InstructionTextToken(): type(TextToken), value(0) InstructionTextToken::InstructionTextToken(BNInstructionTextTokenType t, const std::string& txt, uint64_t val, - size_t s, size_t o) : type(t), text(txt), value(val), size(s), operand(o) + size_t s, size_t o) : type(t), text(txt), value(val), size(s), operand(o), context(NoTokenContext), address(0) +{ +} + + +InstructionTextToken::InstructionTextToken(BNInstructionTextTokenType t, BNInstructionTextTokenContext ctxt, + const string& txt, uint64_t a, uint64_t val, size_t s, size_t o): + type(t), text(txt), value(val), size(s), operand(o), context(ctxt), address(a) { } @@ -153,6 +160,8 @@ bool Architecture::GetInstructionTextCallback(void* ctxt, const uint8_t* data, u (*result)[i].value = tokens[i].value; (*result)[i].size = tokens[i].size; (*result)[i].operand = tokens[i].operand; + (*result)[i].context = tokens[i].context; + (*result)[i].address = tokens[i].address; } return true; } @@ -737,9 +746,9 @@ void Architecture::SetBinaryViewTypeConstant(const string& type, const string& n bool Architecture::ParseTypesFromSource(const string& source, const string& fileName, - map<string, Ref<Type>>& types, map<string, Ref<Type>>& variables, - map<string, Ref<Type>>& functions, string& errors, - const vector<string>& includeDirs) + map<QualifiedName, Ref<Type>>& types, map<QualifiedName, Ref<Type>>& variables, + map<QualifiedName, Ref<Type>>& functions, string& errors, const vector<string>& includeDirs, + const string& autoTypeSource) { BNTypeParserResult result; char* errorStr; @@ -753,26 +762,35 @@ bool Architecture::ParseTypesFromSource(const string& source, const string& file functions.clear(); bool ok = BNParseTypesFromSource(m_object, source.c_str(), fileName.c_str(), &result, - &errorStr, includeDirList, includeDirs.size()); + &errorStr, includeDirList, includeDirs.size(), autoTypeSource.c_str()); errors = errorStr; BNFreeString(errorStr); if (!ok) return false; for (size_t i = 0; i < result.typeCount; i++) - types[result.types[i].name] = new Type(BNNewTypeReference(result.types[i].type)); + { + QualifiedName name = QualifiedName::FromAPIObject(&result.types[i].name); + types[name] = new Type(BNNewTypeReference(result.types[i].type)); + } for (size_t i = 0; i < result.variableCount; i++) - types[result.variables[i].name] = new Type(BNNewTypeReference(result.variables[i].type)); + { + QualifiedName name = QualifiedName::FromAPIObject(&result.variables[i].name); + types[name] = new Type(BNNewTypeReference(result.variables[i].type)); + } for (size_t i = 0; i < result.functionCount; i++) - types[result.functions[i].name] = new Type(BNNewTypeReference(result.functions[i].type)); + { + QualifiedName name = QualifiedName::FromAPIObject(&result.functions[i].name); + types[name] = new Type(BNNewTypeReference(result.functions[i].type)); + } BNFreeTypeParserResult(&result); return true; } -bool Architecture::ParseTypesFromSourceFile(const string& fileName, map<string, Ref<Type>>& types, - map<string, Ref<Type>>& variables, map<string, Ref<Type>>& functions, - string& errors, const vector<string>& includeDirs) +bool Architecture::ParseTypesFromSourceFile(const string& fileName, map<QualifiedName, Ref<Type>>& types, + map<QualifiedName, Ref<Type>>& variables, map<QualifiedName, Ref<Type>>& functions, + string& errors, const vector<string>& includeDirs, const string& autoTypeSource) { BNTypeParserResult result; char* errorStr; @@ -786,18 +804,27 @@ bool Architecture::ParseTypesFromSourceFile(const string& fileName, map<string, functions.clear(); bool ok = BNParseTypesFromSourceFile(m_object, fileName.c_str(), &result, &errorStr, - includeDirList, includeDirs.size()); + includeDirList, includeDirs.size(), autoTypeSource.c_str()); errors = errorStr; BNFreeString(errorStr); if (!ok) return false; for (size_t i = 0; i < result.typeCount; i++) - types[result.types[i].name] = new Type(BNNewTypeReference(result.types[i].type)); + { + QualifiedName name = QualifiedName::FromAPIObject(&result.types[i].name); + types[name] = new Type(BNNewTypeReference(result.types[i].type)); + } for (size_t i = 0; i < result.variableCount; i++) - variables[result.variables[i].name] = new Type(BNNewTypeReference(result.variables[i].type)); + { + QualifiedName name = QualifiedName::FromAPIObject(&result.variables[i].name); + variables[name] = new Type(BNNewTypeReference(result.variables[i].type)); + } for (size_t i = 0; i < result.functionCount; i++) - functions[result.functions[i].name] = new Type(BNNewTypeReference(result.functions[i].type)); + { + QualifiedName name = QualifiedName::FromAPIObject(&result.functions[i].name); + functions[name] = new Type(BNNewTypeReference(result.functions[i].type)); + } BNFreeTypeParserResult(&result); return true; } @@ -954,8 +981,8 @@ bool CoreArchitecture::GetInstructionText(const uint8_t* data, uint64_t addr, si for (size_t i = 0; i < count; i++) { - result.push_back(InstructionTextToken(tokens[i].type, tokens[i].text, tokens[i].value, - tokens[i].size, tokens[i].operand)); + result.push_back(InstructionTextToken(tokens[i].type, tokens[i].context, tokens[i].text, tokens[i].address, + tokens[i].value, tokens[i].size, tokens[i].operand)); } BNFreeInstructionText(tokens, count); |
