Merge "Add ELF symbol binding to JSON dump"

am: e8eca8112c

Change-Id: I3ec1b5bce4c241d2fecac0bae6b7a691b781a2fa
This commit is contained in:
Hsin-Yi Chen
2018-09-17 19:26:46 -07:00
committed by android-build-merger
8 changed files with 90 additions and 23 deletions

View File

@@ -85,10 +85,6 @@ class IRToJsonConverter {
static JsonObject ConvertRvalueReferenceTypeIR( static JsonObject ConvertRvalueReferenceTypeIR(
const RvalueReferenceTypeIR *rvalue_reference_typep); const RvalueReferenceTypeIR *rvalue_reference_typep);
static JsonObject ConvertElfFunctionIR(const ElfFunctionIR *elf_function_ir);
static JsonObject ConvertElfObjectIR(const ElfObjectIR *elf_object_ir);
}; };
class JsonIRDumper : public IRDumper, public IRToJsonConverter { class JsonIRDumper : public IRDumper, public IRToJsonConverter {

View File

@@ -49,6 +49,12 @@ static const std::map<VTableComponentIR::Kind, std::string>
{VTableComponentIR::Kind::UnusedFunctionPointer, "unused_function_pointer"}, {VTableComponentIR::Kind::UnusedFunctionPointer, "unused_function_pointer"},
}; };
static const std::map<ElfSymbolIR::ElfSymbolBinding, std::string>
elf_symbol_binding_ir_to_json{
{ElfSymbolIR::ElfSymbolBinding::Weak, "weak"},
{ElfSymbolIR::ElfSymbolBinding::Global, "global"},
};
// If m contains k, this function returns the value. // If m contains k, this function returns the value.
// Otherwise, it prints error_msg and exits. // Otherwise, it prints error_msg and exits.
template <typename K, typename V> template <typename K, typename V>
@@ -79,6 +85,12 @@ VTableComponentKindIRToJson(VTableComponentIR::Kind kind) {
"Failed to convert VTableComponentIR::Kind to JSON"); "Failed to convert VTableComponentIR::Kind to JSON");
} }
static inline const std::string &
ElfSymbolBindingIRToJson(ElfSymbolIR::ElfSymbolBinding binding) {
return FindInMap(elf_symbol_binding_ir_to_json, binding,
"Failed to convert ElfSymbolBinding to JSON");
}
void IRToJsonConverter::AddTemplateInfo( void IRToJsonConverter::AddTemplateInfo(
JsonObject &type_decl, const abi_util::TemplatedArtifactIR *template_ir) { JsonObject &type_decl, const abi_util::TemplatedArtifactIR *template_ir) {
Json::Value &elements = type_decl["template_info"]; Json::Value &elements = type_decl["template_info"];
@@ -183,20 +195,6 @@ JsonObject IRToJsonConverter::ConvertRecordTypeIR(const RecordTypeIR *recordp) {
return record_type; return record_type;
} }
JsonObject
IRToJsonConverter::ConvertElfObjectIR(const ElfObjectIR *elf_object_ir) {
JsonObject elf_object;
elf_object["name"] = elf_object_ir->GetName();
return elf_object;
}
JsonObject
IRToJsonConverter::ConvertElfFunctionIR(const ElfFunctionIR *elf_function_ir) {
JsonObject elf_function;
elf_function["name"] = elf_function_ir->GetName();
return elf_function;
}
void IRToJsonConverter::AddFunctionParametersAndSetReturnType( void IRToJsonConverter::AddFunctionParametersAndSetReturnType(
JsonObject &function, const CFunctionLikeIR *cfunction_like_ir) { JsonObject &function, const CFunctionLikeIR *cfunction_like_ir) {
function["return_type"] = cfunction_like_ir->GetReturnType(); function["return_type"] = cfunction_like_ir->GetReturnType();
@@ -377,11 +375,9 @@ bool JsonIRDumper::AddLinkableMessageIR(const LinkableMessageIR *lm) {
return true; return true;
} }
bool JsonIRDumper::AddElfSymbolMessageIR(const ElfSymbolIR *em) { bool JsonIRDumper::AddElfSymbolMessageIR(const ElfSymbolIR *elf_symbol_ir) {
std::string key; std::string key;
JsonObject elf_symbol; switch (elf_symbol_ir->GetKind()) {
elf_symbol["name"] = em->GetName();
switch (em->GetKind()) {
case ElfSymbolIR::ElfFunctionKind: case ElfSymbolIR::ElfFunctionKind:
key = "elf_functions"; key = "elf_functions";
break; break;
@@ -391,7 +387,10 @@ bool JsonIRDumper::AddElfSymbolMessageIR(const ElfSymbolIR *em) {
default: default:
return false; return false;
} }
translation_unit_[key].append(elf_symbol); Json::Value &elf_symbol = translation_unit_[key].append(JsonObject());
elf_symbol["name"] = elf_symbol_ir->GetName();
elf_symbol["binding"] =
ElfSymbolBindingIRToJson(elf_symbol_ir->GetBinding());
return true; return true;
} }

View File

@@ -68,42 +68,52 @@
[ [
{ {
"binding" : "global",
"name" : "_Z26test_virtual_function_callP12SuperSpeaker" "name" : "_Z26test_virtual_function_callP12SuperSpeaker"
}, },
{ {
"binding" : "global",
"name" : "_ZN12NotReferenced" "name" : "_ZN12NotReferenced"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker11SpeakLouderEv" "name" : "_ZN12SuperSpeaker11SpeakLouderEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi" "name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker9SpeakLoudEv" "name" : "_ZN12SuperSpeaker9SpeakLoudEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN16LowVolumeSpeaker5SpeakEv" "name" : "_ZN16LowVolumeSpeaker5SpeakEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN16LowVolumeSpeaker6ListenEv" "name" : "_ZN16LowVolumeSpeaker6ListenEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker11BadPracticeEf" "name" : "_ZN17HighVolumeSpeaker11BadPracticeEf"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker5SpeakEv" "name" : "_ZN17HighVolumeSpeaker5SpeakEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker6ListenEv" "name" : "_ZN17HighVolumeSpeaker6ListenEv"
} }
], ],
@@ -111,10 +121,12 @@
[ [
{ {
"binding" : "global",
"name" : "_ZTV16LowVolumeSpeaker" "name" : "_ZTV16LowVolumeSpeaker"
}, },
{ {
"binding" : "global",
"name" : "_ZTV17HighVolumeSpeaker" "name" : "_ZTV17HighVolumeSpeaker"
} }
], ],

View File

@@ -68,42 +68,52 @@
[ [
{ {
"binding" : "global",
"name" : "_Z26test_virtual_function_callP12SuperSpeaker" "name" : "_Z26test_virtual_function_callP12SuperSpeaker"
}, },
{ {
"binding" : "global",
"name" : "_ZN12NotReferenced" "name" : "_ZN12NotReferenced"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker11SpeakLouderEv" "name" : "_ZN12SuperSpeaker11SpeakLouderEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi" "name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker9SpeakLoudEv" "name" : "_ZN12SuperSpeaker9SpeakLoudEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN16LowVolumeSpeaker5SpeakEv" "name" : "_ZN16LowVolumeSpeaker5SpeakEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN16LowVolumeSpeaker6ListenEv" "name" : "_ZN16LowVolumeSpeaker6ListenEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker11BadPracticeEf" "name" : "_ZN17HighVolumeSpeaker11BadPracticeEf"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker5SpeakEv" "name" : "_ZN17HighVolumeSpeaker5SpeakEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker6ListenEv" "name" : "_ZN17HighVolumeSpeaker6ListenEv"
} }
], ],
@@ -111,10 +121,12 @@
[ [
{ {
"binding" : "global",
"name" : "_ZTV16LowVolumeSpeaker" "name" : "_ZTV16LowVolumeSpeaker"
}, },
{ {
"binding" : "global",
"name" : "_ZTV17HighVolumeSpeaker" "name" : "_ZTV17HighVolumeSpeaker"
} }
], ],

View File

@@ -68,42 +68,52 @@
[ [
{ {
"binding" : "global",
"name" : "_Z26test_virtual_function_callP12SuperSpeaker" "name" : "_Z26test_virtual_function_callP12SuperSpeaker"
}, },
{ {
"binding" : "global",
"name" : "_ZN12NotReferenced" "name" : "_ZN12NotReferenced"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker11SpeakLouderEv" "name" : "_ZN12SuperSpeaker11SpeakLouderEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi" "name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker9SpeakLoudEv" "name" : "_ZN12SuperSpeaker9SpeakLoudEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN16LowVolumeSpeaker5SpeakEv" "name" : "_ZN16LowVolumeSpeaker5SpeakEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN16LowVolumeSpeaker6ListenEv" "name" : "_ZN16LowVolumeSpeaker6ListenEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker11BadPracticeEf" "name" : "_ZN17HighVolumeSpeaker11BadPracticeEf"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker5SpeakEv" "name" : "_ZN17HighVolumeSpeaker5SpeakEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker6ListenEv" "name" : "_ZN17HighVolumeSpeaker6ListenEv"
} }
], ],
@@ -111,10 +121,12 @@
[ [
{ {
"binding" : "global",
"name" : "_ZTV16LowVolumeSpeaker" "name" : "_ZTV16LowVolumeSpeaker"
}, },
{ {
"binding" : "global",
"name" : "_ZTV17HighVolumeSpeaker" "name" : "_ZTV17HighVolumeSpeaker"
} }
], ],

View File

@@ -68,42 +68,52 @@
[ [
{ {
"binding" : "global",
"name" : "_Z26test_virtual_function_callP12SuperSpeaker" "name" : "_Z26test_virtual_function_callP12SuperSpeaker"
}, },
{ {
"binding" : "global",
"name" : "_ZN12NotReferenced" "name" : "_ZN12NotReferenced"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker11SpeakLouderEv" "name" : "_ZN12SuperSpeaker11SpeakLouderEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi" "name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker9SpeakLoudEv" "name" : "_ZN12SuperSpeaker9SpeakLoudEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN16LowVolumeSpeaker5SpeakEv" "name" : "_ZN16LowVolumeSpeaker5SpeakEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN16LowVolumeSpeaker6ListenEv" "name" : "_ZN16LowVolumeSpeaker6ListenEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker11BadPracticeEf" "name" : "_ZN17HighVolumeSpeaker11BadPracticeEf"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker5SpeakEv" "name" : "_ZN17HighVolumeSpeaker5SpeakEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker6ListenEv" "name" : "_ZN17HighVolumeSpeaker6ListenEv"
} }
], ],
@@ -111,10 +121,12 @@
[ [
{ {
"binding" : "global",
"name" : "_ZTV16LowVolumeSpeaker" "name" : "_ZTV16LowVolumeSpeaker"
}, },
{ {
"binding" : "global",
"name" : "_ZTV17HighVolumeSpeaker" "name" : "_ZTV17HighVolumeSpeaker"
} }
], ],

View File

@@ -68,42 +68,52 @@
[ [
{ {
"binding" : "global",
"name" : "_Z26test_virtual_function_callP12SuperSpeaker" "name" : "_Z26test_virtual_function_callP12SuperSpeaker"
}, },
{ {
"binding" : "global",
"name" : "_ZN12NotReferenced" "name" : "_ZN12NotReferenced"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker11SpeakLouderEv" "name" : "_ZN12SuperSpeaker11SpeakLouderEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi" "name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker9SpeakLoudEv" "name" : "_ZN12SuperSpeaker9SpeakLoudEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN16LowVolumeSpeaker5SpeakEv" "name" : "_ZN16LowVolumeSpeaker5SpeakEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN16LowVolumeSpeaker6ListenEv" "name" : "_ZN16LowVolumeSpeaker6ListenEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker11BadPracticeEf" "name" : "_ZN17HighVolumeSpeaker11BadPracticeEf"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker5SpeakEv" "name" : "_ZN17HighVolumeSpeaker5SpeakEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker6ListenEv" "name" : "_ZN17HighVolumeSpeaker6ListenEv"
} }
], ],
@@ -111,10 +121,12 @@
[ [
{ {
"binding" : "global",
"name" : "_ZTV16LowVolumeSpeaker" "name" : "_ZTV16LowVolumeSpeaker"
}, },
{ {
"binding" : "global",
"name" : "_ZTV17HighVolumeSpeaker" "name" : "_ZTV17HighVolumeSpeaker"
} }
], ],

View File

@@ -68,42 +68,52 @@
[ [
{ {
"binding" : "global",
"name" : "_Z26test_virtual_function_callP12SuperSpeaker" "name" : "_Z26test_virtual_function_callP12SuperSpeaker"
}, },
{ {
"binding" : "global",
"name" : "_ZN12NotReferenced" "name" : "_ZN12NotReferenced"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker11SpeakLouderEv" "name" : "_ZN12SuperSpeaker11SpeakLouderEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi" "name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi"
}, },
{ {
"binding" : "global",
"name" : "_ZN12SuperSpeaker9SpeakLoudEv" "name" : "_ZN12SuperSpeaker9SpeakLoudEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN16LowVolumeSpeaker5SpeakEv" "name" : "_ZN16LowVolumeSpeaker5SpeakEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN16LowVolumeSpeaker6ListenEv" "name" : "_ZN16LowVolumeSpeaker6ListenEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker11BadPracticeEf" "name" : "_ZN17HighVolumeSpeaker11BadPracticeEf"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker5SpeakEv" "name" : "_ZN17HighVolumeSpeaker5SpeakEv"
}, },
{ {
"binding" : "global",
"name" : "_ZN17HighVolumeSpeaker6ListenEv" "name" : "_ZN17HighVolumeSpeaker6ListenEv"
} }
], ],
@@ -111,10 +121,12 @@
[ [
{ {
"binding" : "global",
"name" : "_ZTV16LowVolumeSpeaker" "name" : "_ZTV16LowVolumeSpeaker"
}, },
{ {
"binding" : "global",
"name" : "_ZTV17HighVolumeSpeaker" "name" : "_ZTV17HighVolumeSpeaker"
} }
], ],