25 #include "abg-internal.h"
30 #include "abg-internal.h"
32 ABG_BEGIN_EXPORT_DECLARATIONS
47 using std::dynamic_pointer_cast;
54 process_ctf_typedef(reader *rdr,
55 ctf_dict_t *ctf_dictionary,
59 process_ctf_base_type(reader *rdr,
60 ctf_dict_t *ctf_dictionary,
64 build_ir_node_for_variadic_parameter_type(reader &rdr,
68 build_ir_node_for_void_type(reader& rdr,
72 build_ir_node_for_void_pointer_type(reader& rdr,
76 process_ctf_function_type(reader *rdr,
77 ctf_dict_t *ctf_dictionary,
81 process_ctf_sou_members(reader *rdr,
82 ctf_dict_t *ctf_dictionary,
84 class_or_union_sptr sou);
87 process_ctf_forward_type(reader *rdr,
88 ctf_dict_t *ctf_dictionary,
92 process_ctf_struct_type(reader *rdr,
93 ctf_dict_t *ctf_dictionary,
96 static union_decl_sptr
97 process_ctf_union_type(reader *rdr,
98 ctf_dict_t *ctf_dictionary,
102 process_ctf_array_type(reader *rdr,
103 ctf_dict_t *ctf_dictionary,
106 static type_base_sptr
107 process_ctf_qualified_type(reader *rdr,
108 ctf_dict_t *ctf_dictionary,
112 process_ctf_pointer_type(reader *rdr,
113 ctf_dict_t *ctf_dictionary,
117 process_ctf_enum_type(reader *rdr,
118 ctf_dict_t *ctf_dictionary,
122 fill_ctf_section(
const Elf_Scn *elf_section, ctf_sect_t *ctf_section);
125 lookup_symbol_in_ctf_archive(ctf_archive_t *ctfa, ctf_dict_t **ctf_dict,
126 const char *sym_name);
129 dic_type_key(ctf_dict_t *dic, ctf_id_t ctf_type);
135 class reader :
public elf_based_reader
146 std::set<ctf_id_t> unknown_types_set;
151 ctf_sect_t symtab_sect;
152 ctf_sect_t strtab_sect;
160 corpus::exported_decls_builder*
161 exported_decls_builder()
162 {
return corpus()->get_exported_decls_builder().get();}
172 add_type(ctf_dict_t *dic, ctf_id_t ctf_type, type_base_sptr type)
174 string key = dic_type_key(dic, ctf_type);
175 types_map.insert(std::make_pair(key, type));
182 add_unknown_type(ctf_id_t ctf_type)
184 unknown_types_set.insert(ctf_type);
195 type_base_sptr result;
196 std::string key = dic_type_key(dic, ctf_type);
198 auto search = types_map.find(key);
199 if (search != types_map.end())
200 result = search->second;
208 lookup_unknown_type(ctf_id_t ctf_type)
209 {
return unknown_types_set.find(ctf_type) != unknown_types_set.end(); }
213 canonicalize_all_types(
void)
216 (types_map.begin(), types_map.end(),
217 [](
const string_type_base_sptr_map_type::const_iterator& i)
218 {
return i->second;});
233 reader(
const string& elf_path,
234 const vector<char**>& debug_info_root_paths,
285 const vector<char**>& debug_info_root_paths,
286 bool load_all_types =
false,
287 bool linux_kernel_mode =
false)
289 load_all_types = load_all_types;
290 linux_kernel_mode = linux_kernel_mode;
308 cur_transl_unit()
const
332 find_ctfa_file(std::string& ctfa_file)
334 std::string ctfa_dirname;
340 ctfa_file = ctfa_dirname +
"/vmlinux.ctfa";
365 corpus_sptr corp =
corpus();
366 if ((corp->get_origin() & corpus::LINUX_KERNEL_BINARY_ORIGIN)
376 if ((status & STATUS_NO_SYMBOLS_FOUND)
383 GElf_Ehdr *ehdr, eh_mem;
384 if (!(ehdr = gelf_getehdr(
elf_handle(), &eh_mem)))
388 const char *symtab_name =
".dynsym";
389 const char *strtab_name =
".dynstr";
391 if (ehdr->e_type == ET_REL)
393 symtab_name =
".symtab";
394 strtab_name =
".strtab";
398 fill_ctf_section(ctf_scn, &ctf_sect);
400 const Elf_Scn* symtab_scn =
401 elf_helpers::find_section_by_name(
elf_handle(), symtab_name);
402 fill_ctf_section(symtab_scn, &symtab_sect);
404 const Elf_Scn* strtab_scn =
405 elf_helpers::find_section_by_name(
elf_handle(), strtab_name);
406 fill_ctf_section(strtab_scn, &strtab_sect);
415 process_ctf_archive()
417 corpus_sptr corp =
corpus();
420 std::make_shared<translation_unit>(env(),
"", 64);
421 ir_translation_unit->set_language(translation_unit::LANG_C);
422 corp->add(ir_translation_unit);
423 cur_transl_unit(ir_translation_unit);
426 ctf_dict_t *ctf_dict, *dict_tmp;
427 const auto symt =
symtab();
428 symtab_reader::symtab_filter filter = symt->make_filter();
429 filter.set_public_symbols();
430 std::string dict_name;
432 if ((corp->get_origin() & corpus::LINUX_KERNEL_BINARY_ORIGIN)
437 std::size_t pos = dict_name.find(
".");
438 if (pos != string::npos)
439 dict_name.erase(pos);
441 std::replace(dict_name.begin(), dict_name.end(),
'-',
'_');
444 if ((ctf_dict = ctf_dict_open(ctfa,
445 dict_name.empty() ? NULL : dict_name.c_str(),
448 fprintf(stderr,
"ERROR dictionary not found\n");
454 for (
const auto& symbol : symtab_reader::filtered_symtab(*symt, filter))
456 std::string sym_name = symbol->get_name();
457 ctf_id_t ctf_sym_type;
459 ctf_sym_type = lookup_symbol_in_ctf_archive(ctfa, &ctf_dict,
461 if (ctf_sym_type == CTF_ERR)
464 if (ctf_type_kind(ctf_dict, ctf_sym_type) != CTF_K_FUNCTION)
466 const char *var_name = sym_name.c_str();
467 type_base_sptr var_type = build_type(ctf_dict, ctf_sym_type);
473 var_declaration.reset(
new var_decl(var_name,
478 var_declaration->set_symbol(symbol);
480 ir_translation_unit->get_global_scope());
481 var_declaration->set_is_in_public_symbol_table(
true);
486 const char *func_name = sym_name.c_str();
487 ctf_id_t ctf_sym = ctf_sym_type;
488 type_base_sptr func_type = build_type(ctf_dict, ctf_sym);
494 func_declaration.reset(
new function_decl(func_name,
498 func_declaration->set_symbol(symbol);
500 ir_translation_unit->get_global_scope());
501 func_declaration->set_is_in_public_symbol_table(
true);
508 ctf_dict_close(ctf_dict);
513 canonicalize_all_types();
514 corpus()->sort_functions();
515 corpus()->sort_variables();
528 process_ctf_type(ctf_dict_t *ctf_dictionary,
531 corpus_sptr corp =
corpus();
533 int type_kind = ctf_type_kind(ctf_dictionary, ctf_type);
534 type_base_sptr result;
536 if (lookup_unknown_type(ctf_type))
539 if ((result =
lookup_type(ctf_dictionary, ctf_type)))
548 = process_ctf_base_type(
this, ctf_dictionary, ctf_type);
555 = process_ctf_typedef(
this, ctf_dictionary, ctf_type);
556 result =
is_type(typedef_decl);
562 = process_ctf_pointer_type(
this, ctf_dictionary, ctf_type);
563 result = pointer_type;
570 type_base_sptr qualified_type
571 = process_ctf_qualified_type(
this, ctf_dictionary, ctf_type);
572 result = qualified_type;
578 = process_ctf_array_type(
this, ctf_dictionary, ctf_type);
585 = process_ctf_enum_type(
this, ctf_dictionary, ctf_type);
592 = process_ctf_function_type(
this, ctf_dictionary, ctf_type);
593 result = function_type;
599 = process_ctf_struct_type(
this, ctf_dictionary, ctf_type);
604 result = process_ctf_forward_type(
this, ctf_dictionary, ctf_type);
608 union_decl_sptr union_decl
609 = process_ctf_union_type(
this, ctf_dictionary, ctf_type);
621 fprintf(stderr,
"NOT PROCESSED TYPE %lu\n", ctf_type);
622 add_unknown_type(ctf_type);
640 build_type(ctf_dict_t *ctf_dictionary, ctf_id_t ctf_type)
642 type_base_sptr result =
lookup_type(ctf_dictionary, ctf_type);
645 result = process_ctf_type(ctf_dictionary, ctf_type);
660 corpus_sptr corp =
corpus();
664 origin |= corpus::CTF_ORIGIN;
665 corp->set_origin(origin);
667 slurp_elf_info(status);
669 return corpus_sptr();
671 if (!(origin & corpus::LINUX_KERNEL_BINARY_ORIGIN)
676 if ((corp->get_origin() & corpus::LINUX_KERNEL_BINARY_ORIGIN)
681 std::string ctfa_filename;
682 if (find_ctfa_file(ctfa_filename))
683 ctfa = ctf_arc_open(ctfa_filename.c_str(), &errp);
691 ctfa = ctf_arc_bufopen(&ctf_sect, &symtab_sect,
692 &strtab_sect, &errp);
694 env().canonicalization_is_done(
false);
699 process_ctf_archive();
700 corpus()->sort_functions();
701 corpus()->sort_variables();
704 env().canonicalization_is_done(
true);
716 typedef shared_ptr<reader> reader_sptr;
727 process_ctf_typedef(reader *rdr,
728 ctf_dict_t *ctf_dictionary,
731 corpus_sptr corp = rdr->corpus();
735 ctf_id_t ctf_utype = ctf_type_reference(ctf_dictionary, ctf_type);
736 if (ctf_utype == CTF_ERR)
739 const char *typedef_name = ctf_type_name_raw(ctf_dictionary, ctf_type);
740 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
744 type_base_sptr utype = rdr->build_type(ctf_dictionary, ctf_utype);
749 result = dynamic_pointer_cast<typedef_decl>
750 (rdr->lookup_type(ctf_dictionary, ctf_type));
754 result.reset(
new typedef_decl(typedef_name, utype, location(),
763 decl_base_sptr decl =
is_decl(utype);
765 decl->set_naming_typedef(result);
771 rdr->add_type(ctf_dictionary, ctf_type, result);
787 process_ctf_base_type(reader *rdr,
788 ctf_dict_t *ctf_dictionary,
791 corpus_sptr corp = rdr->corpus();
795 ctf_id_t ctf_ref = ctf_type_reference(ctf_dictionary, ctf_type);
796 const char *type_name = ctf_type_name_raw(ctf_dictionary,
797 (ctf_ref != CTF_ERR) ? ctf_ref : ctf_type);
802 ctf_encoding_t type_encoding;
803 if (ctf_type_encoding(ctf_dictionary,
804 (ctf_ref != CTF_ERR) ? ctf_ref : ctf_type,
809 if (type_encoding.cte_bits == 0
810 && type_encoding.cte_format == CTF_INT_SIGNED)
813 decl_base_sptr type_declaration = build_ir_node_for_void_type(*rdr,
815 type_base_sptr void_type =
is_type(type_declaration);
821 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
823 string normalized_type_name = type_name;
824 integral_type int_type;
826 normalized_type_name = int_type.to_string();
833 result.reset(
new type_decl(rdr->env(),
835 type_encoding.cte_bits,
845 rdr->add_type(ctf_dictionary, ctf_type, result);
858 static decl_base_sptr
859 build_ir_node_for_variadic_parameter_type(reader &rdr,
863 const ir::environment& env = rdr.env();
864 type_base_sptr t = env.get_variadic_parameter_type();
868 return type_declaration;
882 static decl_base_sptr
885 const environment& env = rdr.env();
886 type_base_sptr t = env.get_void_type();
904 build_ir_node_for_void_pointer_type(reader& rdr,
907 const environment& env = rdr.env();
908 type_base_sptr t = env.get_void_pointer_type();
923 process_ctf_function_type(reader *rdr,
924 ctf_dict_t *ctf_dictionary,
927 corpus_sptr corp = rdr->corpus();
932 ctf_funcinfo_t funcinfo;
933 ctf_func_type_info(ctf_dictionary, ctf_type, &funcinfo);
934 int vararg_p = funcinfo.ctc_flags & CTF_FUNC_VARARG;
937 ctf_id_t ctf_ret_type = funcinfo.ctc_return;
938 type_base_sptr ret_type = rdr->build_type(ctf_dictionary, ctf_ret_type);
943 int argc = funcinfo.ctc_argc;
944 std::vector<ctf_id_t> argv(argc);
945 if (static_cast<ctf_id_t>(ctf_func_type_args(ctf_dictionary, ctf_type,
946 argc, argv.data())) == CTF_ERR)
950 for (
int i = 0; i < argc; i++)
952 ctf_id_t ctf_arg_type = argv[i];
953 type_base_sptr arg_type = rdr->build_type(ctf_dictionary, ctf_arg_type);
958 (
new function_decl::parameter(arg_type,
"",
962 function_parms.push_back(parm);
967 type_base_sptr arg_type =
968 is_type(build_ir_node_for_variadic_parameter_type(*rdr, tunit));
971 (
new function_decl::parameter(arg_type,
"",
975 function_parms.push_back(parm);
978 result = dynamic_pointer_cast<function_type>
979 (rdr->lookup_type(ctf_dictionary, ctf_type));
984 result.reset(
new function_type(ret_type,
986 tunit->get_address_size(),
991 tunit->bind_function_type_life_time(result);
992 result->set_is_artificial(
true);
995 rdr->add_type(ctf_dictionary, ctf_type, result);
1009 process_ctf_sou_members(reader *rdr,
1010 ctf_dict_t *ctf_dictionary,
1012 class_or_union_sptr sou)
1014 corpus_sptr corp = rdr->corpus();
1016 ssize_t member_size;
1017 ctf_next_t *member_next = NULL;
1018 const char *member_name = NULL;
1019 ctf_id_t member_ctf_type;
1021 while ((member_size = ctf_member_next(ctf_dictionary, ctf_type,
1022 &member_next, &member_name,
1026 ctf_membinfo_t membinfo;
1028 if (static_cast<ctf_id_t>(ctf_member_info(ctf_dictionary,
1031 &membinfo)) == CTF_ERR)
1035 type_base_sptr member_type = rdr->build_type(ctf_dictionary,
1047 sou->add_data_member(data_member_decl,
1051 membinfo.ctm_offset);
1053 if (ctf_errno(ctf_dictionary) != ECTF_NEXT_END)
1054 fprintf(stderr,
"ERROR from ctf_member_next\n");
1065 static type_base_sptr
1066 process_ctf_forward_type(reader *rdr,
1067 ctf_dict_t *ctf_dictionary,
1071 decl_base_sptr result;
1072 std::string type_name = ctf_type_name_raw(ctf_dictionary,
1074 bool type_is_anonymous = (type_name ==
"");
1075 uint32_t kind = ctf_type_kind_forwarded (ctf_dictionary, ctf_type);
1077 if (kind == CTF_K_UNION)
1080 union_fwd(
new union_decl(rdr->env(),
1084 decl_base::VISIBILITY_DEFAULT,
1085 type_is_anonymous));
1086 union_fwd->set_is_declaration_only(
true);
1091 if (!type_is_anonymous)
1092 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
1097 struct_fwd(
new class_decl(rdr->env(), type_name,
1101 decl_base::VISIBILITY_DEFAULT,
1102 type_is_anonymous));
1103 struct_fwd->set_is_declaration_only(
true);
1104 result = struct_fwd;
1111 rdr->add_type(ctf_dictionary, ctf_type,
is_type(result));
1125 process_ctf_struct_type(reader *rdr,
1126 ctf_dict_t *ctf_dictionary,
1129 corpus_sptr corp = rdr->corpus();
1132 std::string struct_type_name = ctf_type_name_raw(ctf_dictionary,
1134 bool struct_type_is_anonymous = (struct_type_name ==
"");
1136 if (!struct_type_is_anonymous)
1137 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
1142 result.reset(
new class_decl(rdr->env(),
1144 ctf_type_size(ctf_dictionary, ctf_type) * 8,
1148 decl_base::VISIBILITY_DEFAULT,
1149 struct_type_is_anonymous));
1159 rdr->add_type(ctf_dictionary, ctf_type, result);
1164 process_ctf_sou_members(rdr, ctf_dictionary, ctf_type, result);
1177 static union_decl_sptr
1178 process_ctf_union_type(reader *rdr,
1179 ctf_dict_t *ctf_dictionary,
1182 corpus_sptr corp = rdr->corpus();
1184 union_decl_sptr result;
1185 std::string union_type_name = ctf_type_name_raw(ctf_dictionary,
1187 bool union_type_is_anonymous = (union_type_name ==
"");
1189 if (!union_type_is_anonymous)
1190 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
1195 result.reset(
new union_decl(rdr->env(),
1197 ctf_type_size(ctf_dictionary, ctf_type) * 8,
1199 decl_base::VISIBILITY_DEFAULT,
1200 union_type_is_anonymous));
1210 rdr->add_type(ctf_dictionary, ctf_type, result);
1215 process_ctf_sou_members(rdr, ctf_dictionary, ctf_type, result);
1233 build_array_ctf_range(reader *rdr, ctf_dict_t *dic,
1234 ctf_id_t index, uint64_t nelems)
1236 bool is_non_finite =
false;
1237 corpus_sptr corp = rdr->corpus();
1240 array_type_def::subrange_type::bound_value lower_bound;
1241 array_type_def::subrange_type::bound_value upper_bound;
1243 type_base_sptr index_type = rdr->build_type(dic, index);
1247 lower_bound.set_unsigned(0);
1248 upper_bound.set_unsigned(nelems > 0 ? nelems - 1 : 0U);
1251 if (upper_bound.get_unsigned_value() == 0 && nelems == 0)
1252 is_non_finite =
true;
1254 subrange.reset(
new array_type_def::subrange_type(rdr->env(),
1260 translation_unit::LANG_C));
1264 subrange->is_non_finite(is_non_finite);
1281 process_ctf_array_type(reader *rdr,
1282 ctf_dict_t *ctf_dictionary,
1285 corpus_sptr corp = rdr->corpus();
1288 ctf_arinfo_t ctf_ainfo;
1291 if (static_cast<ctf_id_t>(ctf_array_info(ctf_dictionary,
1293 &ctf_ainfo)) == CTF_ERR)
1296 ctf_id_t ctf_element_type = ctf_ainfo.ctr_contents;
1297 ctf_id_t ctf_index_type = ctf_ainfo.ctr_index;
1298 uint64_t nelems = ctf_ainfo.ctr_nelems;
1302 int type_array_kind = ctf_type_kind(ctf_dictionary, ctf_element_type);
1303 while (type_array_kind == CTF_K_ARRAY)
1305 if (static_cast<ctf_id_t>(ctf_array_info(ctf_dictionary,
1307 &ctf_ainfo)) == CTF_ERR)
1310 subrange = build_array_ctf_range(rdr, ctf_dictionary,
1311 ctf_ainfo.ctr_index,
1312 ctf_ainfo.ctr_nelems);
1313 subranges.push_back(subrange);
1314 ctf_element_type = ctf_ainfo.ctr_contents;
1315 type_array_kind = ctf_type_kind(ctf_dictionary, ctf_element_type);
1318 std::reverse(subranges.begin(), subranges.end());
1321 type_base_sptr element_type = rdr->build_type(ctf_dictionary,
1327 type_base_sptr index_type = rdr->build_type(ctf_dictionary,
1332 result = dynamic_pointer_cast<array_type_def>
1333 (rdr->lookup_type(ctf_dictionary, ctf_type));
1337 subrange = build_array_ctf_range(rdr, ctf_dictionary,
1338 ctf_index_type, nelems);
1339 subranges.push_back(subrange);
1342 result.reset(
new array_type_def(element_type, subranges, location()));
1347 rdr->add_type(ctf_dictionary, ctf_type, result);
1374 static decl_base_sptr
1375 maybe_strip_qualification(
const qualified_type_def_sptr t)
1380 decl_base_sptr result = t;
1381 type_base_sptr u = t->get_underlying_type();
1393 type_base_sptr element_type = array->get_element_type();
1398 quals |= t->get_cv_quals();
1401 qualified->set_cv_quals(quals);
1416 static type_base_sptr
1417 process_ctf_qualified_type(reader *rdr,
1418 ctf_dict_t *ctf_dictionary,
1421 corpus_sptr corp = rdr->corpus();
1423 type_base_sptr result;
1424 int type_kind = ctf_type_kind(ctf_dictionary, ctf_type);
1425 ctf_id_t ctf_utype = ctf_type_reference(ctf_dictionary, ctf_type);
1426 type_base_sptr utype = rdr->build_type(ctf_dictionary, ctf_utype);
1430 result = dynamic_pointer_cast<type_base>
1431 (rdr->lookup_type(ctf_dictionary, ctf_type));
1436 if (type_kind == CTF_K_CONST)
1437 qualifiers |= qualified_type_def::CV_CONST;
1438 else if (type_kind == CTF_K_VOLATILE)
1439 qualifiers |= qualified_type_def::CV_VOLATILE;
1440 else if (type_kind == CTF_K_RESTRICT)
1441 qualifiers |= qualified_type_def::CV_RESTRICT;
1449 result.reset(
new qualified_type_def(utype, qualifiers, location()));
1461 rdr->add_type(ctf_dictionary, ctf_type, result);
1476 process_ctf_pointer_type(reader *rdr,
1477 ctf_dict_t *ctf_dictionary,
1480 corpus_sptr corp = rdr->corpus();
1483 ctf_id_t ctf_target_type = ctf_type_reference(ctf_dictionary, ctf_type);
1484 if (ctf_target_type == CTF_ERR)
1487 type_base_sptr target_type = rdr->build_type(ctf_dictionary,
1492 result = dynamic_pointer_cast<pointer_type_def>
1493 (rdr->lookup_type(ctf_dictionary, ctf_type));
1497 if (rdr->env().is_void_type(target_type))
1498 result =
is_pointer_type(build_ir_node_for_void_pointer_type(*rdr, tunit));
1500 result.reset(
new pointer_type_def(target_type,
1501 ctf_type_size(ctf_dictionary,
1503 ctf_type_align(ctf_dictionary,
1509 rdr->add_type(ctf_dictionary, ctf_type, result);
1524 process_ctf_enum_type(reader *rdr,
1525 ctf_dict_t *ctf_dictionary,
1530 ctf_id_t ctf_ref = ctf_type_reference(ctf_dictionary, ctf_type);
1531 std::string enum_name = ctf_type_name_raw(ctf_dictionary,
1532 (ctf_ref != CTF_ERR)
1533 ? ctf_ref : ctf_type);
1535 if (!enum_name.empty())
1536 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
1543 size_t utype_size_in_bits = ctf_type_size(ctf_dictionary,
1544 (ctf_ref != CTF_ERR)
1545 ? ctf_ref : ctf_type) * 8;
1546 string underlying_type_name =
1548 utype_size_in_bits);
1551 utype.reset(
new type_decl(rdr->env(),
1552 underlying_type_name,
1556 utype->set_is_anonymous(
true);
1557 utype->set_is_artificial(
true);
1566 ctf_next_t *enum_next = NULL;
1570 while ((ename = ctf_enum_next(ctf_dictionary, ctf_type, &enum_next, &evalue)))
1571 enms.push_back(enum_type_decl::enumerator(ename, evalue));
1573 if (ctf_errno(ctf_dictionary) != ECTF_NEXT_END)
1575 fprintf(stderr,
"ERROR from ctf_enum_next\n");
1579 result.reset(
new enum_type_decl(enum_name.c_str(), location(),
1580 utype, enms, enum_name.c_str()));
1584 rdr->add_type(ctf_dictionary, ctf_type, result);
1607 lookup_symbol_in_ctf_archive(ctf_archive_t *ctfa, ctf_dict_t **ctf_dict,
1608 const char *sym_name)
1611 ctf_dict_t *dict = *ctf_dict;
1612 ctf_id_t ctf_type = ctf_lookup_by_symbol_name(dict, sym_name);
1614 if (ctf_type != CTF_ERR)
1619 ctf_type = ctf_lookup_variable(dict, sym_name);
1622 if (ctf_type == CTF_ERR)
1625 ctf_next_t *i = NULL;
1626 const char *arcname;
1628 while ((fp = ctf_archive_next(ctfa, &i, &arcname, 1, &ctf_err)) != NULL)
1630 if ((ctf_type = ctf_lookup_by_symbol_name (fp, sym_name)) == CTF_ERR)
1631 ctf_type = ctf_lookup_variable(fp, sym_name);
1633 if (ctf_type != CTF_ERR)
1652 fill_ctf_section(
const Elf_Scn *elf_section, ctf_sect_t *ctf_section)
1654 GElf_Shdr section_header_mem, *section_header;
1655 Elf_Data *section_data;
1657 section_header = gelf_getshdr(const_cast<Elf_Scn*>(elf_section),
1658 §ion_header_mem);
1659 section_data = elf_getdata(const_cast<Elf_Scn*>(elf_section), 0);
1664 ctf_section->cts_name =
"";
1665 ctf_section->cts_data = (
char *) section_data->d_buf;
1666 ctf_section->cts_size = section_data->d_size;
1667 ctf_section->cts_entsize = section_header->sh_entsize;
1676 elf_based_reader_sptr
1677 create_reader(
const std::string& elf_path,
1678 const vector<char**>& debug_info_root_paths,
1681 reader_sptr result(
new reader(elf_path,
1682 debug_info_root_paths,
1706 reset_reader(elf_based_reader& rdr,
1707 const std::string& elf_path,
1708 const vector<char**>& debug_info_root_path)
1710 ctf::reader& r =
dynamic_cast<reader&
>(rdr);
1711 r.initialize(elf_path, debug_info_root_path);
1728 dic_type_key(ctf_dict_t *dic, ctf_id_t ctf_type)
1730 std::stringstream key;
1732 if (ctf_type_isparent (dic, ctf_type))
1733 key << std::hex << ctf_type;
1735 key << std::hex << ctf_type <<
'-' << ctf_cuname(dic);
decl_base_sptr add_decl_to_scope(decl_base_sptr decl, scope_decl *scope)
Appends a declaration to a given scope, if the declaration doesn't already belong to one and if the d...
bool is_type(const type_or_decl_base &tod)
Test whether a declaration is a type.
type_decl_sptr lookup_basic_type(const interned_string &type_name, const translation_unit &tu)
Lookup a basic type from a translation unit.
const type_decl * is_type_decl(const type_or_decl_base *t)
Test whether a type is a type_decl (a builtin type).
const options_type & options() const
Getter of the the options of the current Front End Interface.
typedef_decl_sptr lookup_typedef_type(const interned_string &type_name, const translation_unit &tu)
Lookup a typedef type from a translation unit.
shared_ptr< function_type > function_type_sptr
Convenience typedef for a shared pointer on a function_type.
unordered_map< string, type_base_sptr > string_type_base_sptr_map_type
A convenience typedef for a map which key is a string and which value is a type_base_sptr.
function_type_sptr is_function_type(const type_or_decl_base_sptr &t)
Test whether a type is a function_type.
status
The status of the fe_iface::read_corpus call.
shared_ptr< var_decl > var_decl_sptr
Convenience typedef for a shared pointer on a var_decl.
const Elf_Scn * find_ctf_section() const
Find and return a pointer to the the CTF section.
virtual ir::corpus_sptr read_corpus(status &status)
Read the ELF information associated to the current ELF file and construct an ABI representation from ...
class_or_union * is_class_or_union_type(const type_or_decl_base *t)
Test if a type is a class_or_union.
shared_ptr< translation_unit > translation_unit_sptr
Convenience typedef for a shared pointer on a translation_unit type.
shared_ptr< typedef_decl > typedef_decl_sptr
Convenience typedef for a shared pointer on a typedef_decl.
This contains the declarations for the symtab reader.
string build_internal_underlying_enum_type_name(const string &base_name, bool is_anonymous, uint64_t size)
Build the internal name of the underlying type of an enum.
This status is for when the debug info could not be read.
union_decl_sptr lookup_union_type(const interned_string &type_name, const translation_unit &tu)
Lookup a union type from a translation unit.
corpus_group_sptr & corpus_group()
Getter for the ABI corpus group being built by the current front-end.
std::vector< enumerator > enumerators
Convenience typedef for a list of enumerator.
type_base_sptr canonicalize(type_base_sptr t)
Compute the canonical type of a given type.
const type_base_sptr lookup_type(const interned_string &fqn, const translation_unit &tu)
Lookup a type in a translation unit.
void add_var_to_exported_or_undefined_decls(const var_decl *var)
Add the representation of the ABI of a variable to the set of exported or undefined declarations of t...
Toplevel namespace for libabigail.
shared_ptr< function_decl > function_decl_sptr
Convenience typedef for a shared pointer on a function_decl.
decl_base * is_decl(const type_or_decl_base *d)
Test if an ABI artifact is a declaration.
const enum_type_decl * is_enum_type(const type_or_decl_base *d)
Test if a decl is an enum_type_decl.
const vector< char ** > & debug_info_root_paths() const
Getter of the vector of directory paths to look into for split debug information files.
std::vector< parameter_sptr > parameters
Convenience typedef for a vector of parameter_sptr.
shared_ptr< parameter > parameter_sptr
Convenience typedef for a shared pointer on a function_decl::parameter.
virtual void initialize(const std::string &elf_path, const vector< char ** > &debug_info_root_paths)
(re)Initialize) the resources used by the current reader.
origin
This abstracts where the corpus comes from. That is, either it has been read from the native xml form...
This contains the private implementation of the suppression engine of libabigail. ...
enum_type_decl_sptr lookup_enum_type(const interned_string &type_name, const translation_unit &tu)
Lookup an enum type from a translation unit.
const decl_base * get_type_declaration(const type_base *t)
Get the declaration for a given type.
shared_ptr< type_or_decl_base > type_or_decl_base_sptr
A convenience typedef for a shared_ptr to type_or_decl_base.
This file contains the declarations for an elf-based. DWARF and CTF readers can inherit this one...
shared_ptr< type_decl > type_decl_sptr
Convenience typedef for a shared pointer on a type_decl.
corpus_sptr corpus()
Getter for the ABI corpus being built by the current front-end.
This file contains the declarations of the entry points to de-serialize an instance of abigail::corpu...
#define ABG_ASSERT(cond)
This is a wrapper around the 'assert' glibc call. It allows for its argument to have side effects...
void add_fn_to_exported_or_undefined_decls(const function_decl *fn)
Add the representation of the ABI of a function to the set of exported declarations or undefined decl...
array_type_def * is_array_type(const type_or_decl_base *type, bool look_through_qualifiers)
Test if a type is an array_type_def.
This status is for when the symbols of the ELF binaries could not be read.
bool is_anonymous_type(const type_base *t)
Test whether a declaration is a type.
shared_ptr< enum_type_decl > enum_type_decl_sptr
Convenience typedef for shared pointer to a enum_type_decl.
shared_ptr< class_decl > class_decl_sptr
Convenience typedef for a shared pointer on a class_decl.
qualified_type_def * is_qualified_type(const type_or_decl_base *t)
Test whether a type is a reference_type_def.
class_decl_sptr lookup_class_type(const string &fqn, const translation_unit &tu)
Lookup a class type from a translation unit.
symtab_reader::symtab_sptr & symtab() const
Getter of an abstract representation of the symbol table of the underlying ELF file.
const std::string & corpus_path() const
Getter of the path to the file which an ABI corpus is to be created for.
This contains a set of ELF utilities used by the dwarf reader.
std::vector< subrange_sptr > subranges_type
Convenience typedef for a vector of subrange_sptr.
void canonicalize_types(const input_iterator &begin, const input_iterator &end, deref_lambda deref)
Compute the canonical type for all the IR types of the system.
The status is in an unknown state.
bool parse_integral_type(const string &type_name, integral_type &type)
Parse an integral type from a string.
shared_ptr< subrange_type > subrange_sptr
Convenience typedef for a shared pointer on a function_decl::subrange.
Elf * elf_handle() const
Getter of the handle used to access ELF information from the current ELF file.
shared_ptr< array_type_def > array_type_def_sptr
Convenience typedef for a shared pointer on a array_type_def.
shared_ptr< pointer_type_def > pointer_type_def_sptr
Convenience typedef for a shared pointer on a pointer_type_def.
const pointer_type_def * is_pointer_type(const type_or_decl_base *t, bool look_through_qualifiers)
Test whether a type is a pointer_type_def.
This status is for when the call went OK.
elf_based_reader(const std::string &elf_path, const vector< char ** > &debug_info_root_paths, environment &env)
Readers that implement this interface must provide a factory method to create a reader instance as th...
CV
Bit field values representing the cv qualifiers of the underlying type.