25 #include "abg-internal.h"
30 #include "abg-internal.h"
32 ABG_BEGIN_EXPORT_DECLARATIONS
40 ABG_END_EXPORT_DECLARATIONS
48 using std::dynamic_pointer_cast;
55 process_ctf_typedef(reader *rdr,
56 ctf_dict_t *ctf_dictionary,
60 process_ctf_base_type(reader *rdr,
61 ctf_dict_t *ctf_dictionary,
65 build_ir_node_for_variadic_parameter_type(reader &rdr,
69 build_ir_node_for_void_type(reader& rdr,
73 build_ir_node_for_void_pointer_type(reader& rdr,
77 process_ctf_function_type(reader *rdr,
78 ctf_dict_t *ctf_dictionary,
82 process_ctf_sou_members(reader *rdr,
83 ctf_dict_t *ctf_dictionary,
85 class_or_union_sptr sou);
88 process_ctf_forward_type(reader *rdr,
89 ctf_dict_t *ctf_dictionary,
93 process_ctf_struct_type(reader *rdr,
94 ctf_dict_t *ctf_dictionary,
97 static union_decl_sptr
98 process_ctf_union_type(reader *rdr,
99 ctf_dict_t *ctf_dictionary,
103 process_ctf_array_type(reader *rdr,
104 ctf_dict_t *ctf_dictionary,
107 static type_base_sptr
108 process_ctf_qualified_type(reader *rdr,
109 ctf_dict_t *ctf_dictionary,
113 process_ctf_pointer_type(reader *rdr,
114 ctf_dict_t *ctf_dictionary,
118 process_ctf_enum_type(reader *rdr,
119 ctf_dict_t *ctf_dictionary,
123 fill_ctf_section(
const Elf_Scn *elf_section, ctf_sect_t *ctf_section);
126 lookup_symbol_in_ctf_archive(ctf_archive_t *ctfa, ctf_dict_t **ctf_dict,
127 const char *sym_name);
130 dic_type_key(ctf_dict_t *dic, ctf_id_t ctf_type);
147 std::set<ctf_id_t> unknown_types_set;
152 ctf_sect_t symtab_sect;
153 ctf_sect_t strtab_sect;
162 exported_decls_builder()
173 add_type(ctf_dict_t *dic, ctf_id_t ctf_type, type_base_sptr type)
175 string key = dic_type_key(dic, ctf_type);
176 types_map.insert(std::make_pair(key, type));
183 add_unknown_type(ctf_id_t ctf_type)
185 unknown_types_set.insert(ctf_type);
196 type_base_sptr result;
197 std::string key = dic_type_key(dic, ctf_type);
199 auto search = types_map.find(key);
200 if (search != types_map.end())
201 result = search->second;
209 lookup_unknown_type(ctf_id_t ctf_type)
210 {
return unknown_types_set.find(ctf_type) != unknown_types_set.end(); }
214 canonicalize_all_types(
void)
217 (types_map.begin(), types_map.end(),
218 [](
const string_type_base_sptr_map_type::const_iterator& i)
219 {return i->second;});
234 reader(
const string& elf_path,
235 const vector<char**>& debug_info_root_paths,
286 const vector<char**>& debug_info_root_paths,
287 bool load_all_types =
false,
288 bool linux_kernel_mode =
false)
290 load_all_types = load_all_types;
291 linux_kernel_mode = linux_kernel_mode;
309 cur_transl_unit()
const
317 {
return options().env;}
324 {
return options().env;}
333 find_ctfa_file(std::string& ctfa_file)
335 std::string ctfa_dirname;
336 dir_name(corpus_path(), ctfa_dirname,
false);
341 ctfa_file = ctfa_dirname +
"/vmlinux.ctfa";
348 for (
const auto& path : debug_info_root_paths())
366 corpus_sptr corp =
corpus();
367 if ((corp->get_origin() & corpus::LINUX_KERNEL_BINARY_ORIGIN)
373 (~STATUS_DEBUG_INFO_NOT_FOUND);
377 if ((status & STATUS_NO_SYMBOLS_FOUND)
378 || !(status & STATUS_OK))
384 GElf_Ehdr *ehdr, eh_mem;
385 if (!(ehdr = gelf_getehdr(elf_handle(), &eh_mem)))
389 const char *symtab_name =
".dynsym";
390 const char *strtab_name =
".dynstr";
392 if (ehdr->e_type == ET_REL)
394 symtab_name =
".symtab";
395 strtab_name =
".strtab";
398 const Elf_Scn* ctf_scn = find_ctf_section();
399 fill_ctf_section(ctf_scn, &ctf_sect);
401 const Elf_Scn* symtab_scn =
402 elf_helpers::find_section_by_name(elf_handle(), symtab_name);
403 fill_ctf_section(symtab_scn, &symtab_sect);
405 const Elf_Scn* strtab_scn =
406 elf_helpers::find_section_by_name(elf_handle(), strtab_name);
407 fill_ctf_section(strtab_scn, &strtab_sect);
416 process_ctf_archive()
418 corpus_sptr corp =
corpus();
421 std::make_shared<translation_unit>(env(),
"", 64);
422 ir_translation_unit->set_language(translation_unit::LANG_C);
423 corp->add(ir_translation_unit);
424 cur_transl_unit(ir_translation_unit);
427 ctf_dict_t *ctf_dict, *dict_tmp;
428 const auto symt = symtab();
431 std::string dict_name;
433 if ((corp->get_origin() & corpus::LINUX_KERNEL_BINARY_ORIGIN)
438 std::size_t pos = dict_name.find(
".");
439 if (pos != string::npos)
440 dict_name.erase(pos);
442 std::replace(dict_name.begin(), dict_name.end(),
'-',
'_');
445 if ((ctf_dict = ctf_dict_open(ctfa,
446 dict_name.empty() ? NULL : dict_name.c_str(),
449 fprintf(stderr,
"ERROR dictionary not found\n");
457 std::string sym_name = symbol->get_name();
458 ctf_id_t ctf_sym_type;
460 ctf_sym_type = lookup_symbol_in_ctf_archive(ctfa, &ctf_dict,
462 if (ctf_sym_type == CTF_ERR)
465 if (ctf_type_kind(ctf_dict, ctf_sym_type) != CTF_K_FUNCTION)
467 const char *var_name = sym_name.c_str();
468 type_base_sptr var_type = build_type(ctf_dict, ctf_sym_type);
474 var_declaration.reset(
new var_decl(var_name,
479 var_declaration->set_symbol(symbol);
481 ir_translation_unit->get_global_scope());
482 var_declaration->set_is_in_public_symbol_table(
true);
483 add_var_to_exported_or_undefined_decls(var_declaration.get());
487 const char *func_name = sym_name.c_str();
488 ctf_id_t ctf_sym = ctf_sym_type;
489 type_base_sptr func_type = build_type(ctf_dict, ctf_sym);
499 func_declaration->set_symbol(symbol);
501 ir_translation_unit->get_global_scope());
502 func_declaration->set_is_in_public_symbol_table(
true);
503 add_fn_to_exported_or_undefined_decls(func_declaration.get());
509 ctf_dict_close(ctf_dict);
514 canonicalize_all_types();
529 process_ctf_type(ctf_dict_t *ctf_dictionary,
532 corpus_sptr corp =
corpus();
534 int type_kind = ctf_type_kind(ctf_dictionary, ctf_type);
535 type_base_sptr result;
537 if (lookup_unknown_type(ctf_type))
540 if ((result =
lookup_type(ctf_dictionary, ctf_type)))
549 = process_ctf_base_type(
this, ctf_dictionary, ctf_type);
556 = process_ctf_typedef(
this, ctf_dictionary, ctf_type);
563 = process_ctf_pointer_type(
this, ctf_dictionary, ctf_type);
564 result = pointer_type;
571 type_base_sptr qualified_type
572 = process_ctf_qualified_type(
this, ctf_dictionary, ctf_type);
573 result = qualified_type;
579 = process_ctf_array_type(
this, ctf_dictionary, ctf_type);
586 = process_ctf_enum_type(
this, ctf_dictionary, ctf_type);
593 = process_ctf_function_type(
this, ctf_dictionary, ctf_type);
600 = process_ctf_struct_type(
this, ctf_dictionary, ctf_type);
605 result = process_ctf_forward_type(
this, ctf_dictionary, ctf_type);
610 = process_ctf_union_type(
this, ctf_dictionary, ctf_type);
622 fprintf(stderr,
"NOT PROCESSED TYPE %lu\n", ctf_type);
623 add_unknown_type(ctf_type);
641 build_type(ctf_dict_t *ctf_dictionary, ctf_id_t ctf_type)
643 type_base_sptr result =
lookup_type(ctf_dictionary, ctf_type);
646 result = process_ctf_type(ctf_dictionary, ctf_type);
661 corpus_sptr corp =
corpus();
665 origin |= corpus::CTF_ORIGIN;
666 corp->set_origin(origin);
668 slurp_elf_info(status);
670 return corpus_sptr();
672 if (!(origin & corpus::LINUX_KERNEL_BINARY_ORIGIN)
677 if ((corp->get_origin() & corpus::LINUX_KERNEL_BINARY_ORIGIN)
682 std::string ctfa_filename;
683 if (find_ctfa_file(ctfa_filename))
684 ctfa = ctf_arc_open(ctfa_filename.c_str(), &errp);
692 ctfa = ctf_arc_bufopen(&ctf_sect, &symtab_sect,
693 &strtab_sect, &errp);
700 process_ctf_archive();
717 typedef shared_ptr<reader> reader_sptr;
728 process_ctf_typedef(reader *rdr,
729 ctf_dict_t *ctf_dictionary,
732 corpus_sptr corp = rdr->corpus();
736 ctf_id_t ctf_utype = ctf_type_reference(ctf_dictionary, ctf_type);
737 if (ctf_utype == CTF_ERR)
740 const char *typedef_name = ctf_type_name_raw(ctf_dictionary, ctf_type);
741 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
745 type_base_sptr utype = rdr->build_type(ctf_dictionary, ctf_utype);
750 result = dynamic_pointer_cast<typedef_decl>
751 (rdr->lookup_type(ctf_dictionary, ctf_type));
764 decl_base_sptr decl =
is_decl(utype);
766 decl->set_naming_typedef(result);
772 rdr->add_type(ctf_dictionary, ctf_type, result);
788 process_ctf_base_type(reader *rdr,
789 ctf_dict_t *ctf_dictionary,
792 corpus_sptr corp = rdr->corpus();
796 ctf_id_t ctf_ref = ctf_type_reference(ctf_dictionary, ctf_type);
797 const char *type_name = ctf_type_name_raw(ctf_dictionary,
798 (ctf_ref != CTF_ERR) ? ctf_ref : ctf_type);
803 ctf_encoding_t type_encoding;
804 if (ctf_type_encoding(ctf_dictionary,
805 (ctf_ref != CTF_ERR) ? ctf_ref : ctf_type,
810 if (type_encoding.cte_bits == 0
811 && type_encoding.cte_format == CTF_INT_SIGNED)
814 decl_base_sptr type_declaration = build_ir_node_for_void_type(*rdr,
816 type_base_sptr void_type =
is_type(type_declaration);
822 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
824 string normalized_type_name = type_name;
827 normalized_type_name = int_type.
to_string();
836 type_encoding.cte_bits,
846 rdr->add_type(ctf_dictionary, ctf_type, result);
859 static decl_base_sptr
860 build_ir_node_for_variadic_parameter_type(reader &rdr,
869 return type_declaration;
883 static decl_base_sptr
905 build_ir_node_for_void_pointer_type(reader& rdr,
924 process_ctf_function_type(reader *rdr,
925 ctf_dict_t *ctf_dictionary,
928 corpus_sptr corp = rdr->corpus();
933 ctf_funcinfo_t funcinfo;
934 ctf_func_type_info(ctf_dictionary, ctf_type, &funcinfo);
935 int vararg_p = funcinfo.ctc_flags & CTF_FUNC_VARARG;
938 ctf_id_t ctf_ret_type = funcinfo.ctc_return;
939 type_base_sptr ret_type = rdr->build_type(ctf_dictionary, ctf_ret_type);
944 int argc = funcinfo.ctc_argc;
945 std::vector<ctf_id_t> argv(argc);
946 if (
static_cast<ctf_id_t
>(ctf_func_type_args(ctf_dictionary, ctf_type,
947 argc, argv.data())) == CTF_ERR)
951 for (
int i = 0; i < argc; i++)
953 ctf_id_t ctf_arg_type = argv[i];
954 type_base_sptr arg_type = rdr->build_type(ctf_dictionary, ctf_arg_type);
963 function_parms.push_back(parm);
968 type_base_sptr arg_type =
969 is_type(build_ir_node_for_variadic_parameter_type(*rdr, tunit));
976 function_parms.push_back(parm);
979 result = dynamic_pointer_cast<function_type>
980 (rdr->lookup_type(ctf_dictionary, ctf_type));
987 tunit->get_address_size(),
992 tunit->bind_function_type_life_time(result);
993 result->set_is_artificial(
true);
996 rdr->add_type(ctf_dictionary, ctf_type, result);
1010 process_ctf_sou_members(reader *rdr,
1011 ctf_dict_t *ctf_dictionary,
1013 class_or_union_sptr sou)
1015 corpus_sptr corp = rdr->corpus();
1017 ssize_t member_size;
1018 ctf_next_t *member_next = NULL;
1019 const char *member_name = NULL;
1020 ctf_id_t member_ctf_type;
1022 while ((member_size = ctf_member_next(ctf_dictionary, ctf_type,
1023 &member_next, &member_name,
1027 ctf_membinfo_t membinfo;
1029 if (
static_cast<ctf_id_t
>(ctf_member_info(ctf_dictionary,
1032 &membinfo)) == CTF_ERR)
1036 type_base_sptr member_type = rdr->build_type(ctf_dictionary,
1048 sou->add_data_member(data_member_decl,
1052 membinfo.ctm_offset);
1054 if (ctf_errno(ctf_dictionary) != ECTF_NEXT_END)
1055 fprintf(stderr,
"ERROR from ctf_member_next\n");
1066 static type_base_sptr
1067 process_ctf_forward_type(reader *rdr,
1068 ctf_dict_t *ctf_dictionary,
1072 decl_base_sptr result;
1073 std::string type_name = ctf_type_name_raw(ctf_dictionary,
1075 bool type_is_anonymous = (type_name ==
"");
1076 uint32_t kind = ctf_type_kind_forwarded (ctf_dictionary, ctf_type);
1078 if (kind == CTF_K_UNION)
1085 decl_base::VISIBILITY_DEFAULT,
1086 type_is_anonymous));
1087 union_fwd->set_is_declaration_only(
true);
1092 if (!type_is_anonymous)
1093 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
1098 struct_fwd(
new class_decl(rdr->env(), type_name,
1102 decl_base::VISIBILITY_DEFAULT,
1103 type_is_anonymous));
1104 struct_fwd->set_is_declaration_only(
true);
1105 result = struct_fwd;
1112 rdr->add_type(ctf_dictionary, ctf_type,
is_type(result));
1126 process_ctf_struct_type(reader *rdr,
1127 ctf_dict_t *ctf_dictionary,
1130 corpus_sptr corp = rdr->corpus();
1133 std::string struct_type_name = ctf_type_name_raw(ctf_dictionary,
1135 bool struct_type_is_anonymous = (struct_type_name ==
"");
1137 if (!struct_type_is_anonymous)
1138 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
1145 ctf_type_size(ctf_dictionary, ctf_type) * 8,
1149 decl_base::VISIBILITY_DEFAULT,
1150 struct_type_is_anonymous));
1160 rdr->add_type(ctf_dictionary, ctf_type, result);
1165 process_ctf_sou_members(rdr, ctf_dictionary, ctf_type, result);
1178 static union_decl_sptr
1179 process_ctf_union_type(reader *rdr,
1180 ctf_dict_t *ctf_dictionary,
1183 corpus_sptr corp = rdr->corpus();
1185 union_decl_sptr result;
1186 std::string union_type_name = ctf_type_name_raw(ctf_dictionary,
1188 bool union_type_is_anonymous = (union_type_name ==
"");
1190 if (!union_type_is_anonymous)
1191 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
1198 ctf_type_size(ctf_dictionary, ctf_type) * 8,
1200 decl_base::VISIBILITY_DEFAULT,
1201 union_type_is_anonymous));
1211 rdr->add_type(ctf_dictionary, ctf_type, result);
1216 process_ctf_sou_members(rdr, ctf_dictionary, ctf_type, result);
1234 build_array_ctf_range(reader *rdr, ctf_dict_t *dic,
1235 ctf_id_t index, uint64_t nelems)
1237 bool is_non_finite =
false;
1238 corpus_sptr corp = rdr->corpus();
1241 array_type_def::subrange_type::bound_value lower_bound;
1242 array_type_def::subrange_type::bound_value upper_bound;
1244 type_base_sptr index_type = rdr->build_type(dic, index);
1248 lower_bound.set_unsigned(0);
1249 upper_bound.set_unsigned(nelems > 0 ? nelems - 1 : 0U);
1252 if (upper_bound.get_unsigned_value() == 0 && nelems == 0)
1253 is_non_finite =
true;
1255 subrange.reset(
new array_type_def::subrange_type(rdr->env(),
1261 translation_unit::LANG_C));
1265 subrange->is_non_finite(is_non_finite);
1282 process_ctf_array_type(reader *rdr,
1283 ctf_dict_t *ctf_dictionary,
1286 corpus_sptr corp = rdr->corpus();
1289 ctf_arinfo_t ctf_ainfo;
1292 if (
static_cast<ctf_id_t
>(ctf_array_info(ctf_dictionary,
1294 &ctf_ainfo)) == CTF_ERR)
1297 ctf_id_t ctf_element_type = ctf_ainfo.ctr_contents;
1298 ctf_id_t ctf_index_type = ctf_ainfo.ctr_index;
1299 uint64_t nelems = ctf_ainfo.ctr_nelems;
1303 int type_array_kind = ctf_type_kind(ctf_dictionary, ctf_element_type);
1304 while (type_array_kind == CTF_K_ARRAY)
1306 if (
static_cast<ctf_id_t
>(ctf_array_info(ctf_dictionary,
1308 &ctf_ainfo)) == CTF_ERR)
1311 subrange = build_array_ctf_range(rdr, ctf_dictionary,
1312 ctf_ainfo.ctr_index,
1313 ctf_ainfo.ctr_nelems);
1314 subranges.push_back(subrange);
1315 ctf_element_type = ctf_ainfo.ctr_contents;
1316 type_array_kind = ctf_type_kind(ctf_dictionary, ctf_element_type);
1319 std::reverse(subranges.begin(), subranges.end());
1322 type_base_sptr element_type = rdr->build_type(ctf_dictionary,
1328 type_base_sptr index_type = rdr->build_type(ctf_dictionary,
1333 result = dynamic_pointer_cast<array_type_def>
1334 (rdr->lookup_type(ctf_dictionary, ctf_type));
1338 subrange = build_array_ctf_range(rdr, ctf_dictionary,
1339 ctf_index_type, nelems);
1340 subranges.push_back(subrange);
1348 rdr->add_type(ctf_dictionary, ctf_type, result);
1375 static decl_base_sptr
1376 maybe_strip_qualification(
const qualified_type_def_sptr t)
1381 decl_base_sptr result = t;
1382 type_base_sptr u = t->get_underlying_type();
1394 type_base_sptr element_type = array->get_element_type();
1399 quals |= t->get_cv_quals();
1402 qualified->set_cv_quals(quals);
1417 static type_base_sptr
1418 process_ctf_qualified_type(reader *rdr,
1419 ctf_dict_t *ctf_dictionary,
1422 corpus_sptr corp = rdr->corpus();
1424 type_base_sptr result;
1425 int type_kind = ctf_type_kind(ctf_dictionary, ctf_type);
1426 ctf_id_t ctf_utype = ctf_type_reference(ctf_dictionary, ctf_type);
1427 type_base_sptr utype = rdr->build_type(ctf_dictionary, ctf_utype);
1431 result = dynamic_pointer_cast<type_base>
1432 (rdr->lookup_type(ctf_dictionary, ctf_type));
1437 if (type_kind == CTF_K_CONST)
1438 qualifiers |= qualified_type_def::CV_CONST;
1439 else if (type_kind == CTF_K_VOLATILE)
1440 qualifiers |= qualified_type_def::CV_VOLATILE;
1441 else if (type_kind == CTF_K_RESTRICT)
1442 qualifiers |= qualified_type_def::CV_RESTRICT;
1462 rdr->add_type(ctf_dictionary, ctf_type, result);
1477 process_ctf_pointer_type(reader *rdr,
1478 ctf_dict_t *ctf_dictionary,
1481 corpus_sptr corp = rdr->corpus();
1484 ctf_id_t ctf_target_type = ctf_type_reference(ctf_dictionary, ctf_type);
1485 if (ctf_target_type == CTF_ERR)
1488 type_base_sptr target_type = rdr->build_type(ctf_dictionary,
1493 result = dynamic_pointer_cast<pointer_type_def>
1494 (rdr->lookup_type(ctf_dictionary, ctf_type));
1498 if (rdr->env().is_void_type(target_type))
1499 result =
is_pointer_type(build_ir_node_for_void_pointer_type(*rdr, tunit));
1502 ctf_type_size(ctf_dictionary,
1504 ctf_type_align(ctf_dictionary,
1510 rdr->add_type(ctf_dictionary, ctf_type, result);
1525 process_ctf_enum_type(reader *rdr,
1526 ctf_dict_t *ctf_dictionary,
1531 ctf_id_t ctf_ref = ctf_type_reference(ctf_dictionary, ctf_type);
1532 std::string enum_name = ctf_type_name_raw(ctf_dictionary,
1533 (ctf_ref != CTF_ERR)
1534 ? ctf_ref : ctf_type);
1536 if (!enum_name.empty())
1537 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
1544 size_t utype_size_in_bits = ctf_type_size(ctf_dictionary,
1545 (ctf_ref != CTF_ERR)
1546 ? ctf_ref : ctf_type) * 8;
1547 string underlying_type_name =
1549 utype_size_in_bits);
1553 underlying_type_name,
1557 utype->set_is_anonymous(
true);
1558 utype->set_is_artificial(
true);
1567 ctf_next_t *enum_next = NULL;
1571 while ((ename = ctf_enum_next(ctf_dictionary, ctf_type, &enum_next, &evalue)))
1572 enms.push_back(enum_type_decl::enumerator(ename, evalue));
1574 if (ctf_errno(ctf_dictionary) != ECTF_NEXT_END)
1576 fprintf(stderr,
"ERROR from ctf_enum_next\n");
1581 utype, enms, enum_name.c_str()));
1585 rdr->add_type(ctf_dictionary, ctf_type, result);
1608 lookup_symbol_in_ctf_archive(ctf_archive_t *ctfa, ctf_dict_t **ctf_dict,
1609 const char *sym_name)
1612 ctf_dict_t *dict = *ctf_dict;
1613 ctf_id_t ctf_type = ctf_lookup_by_symbol_name(dict, sym_name);
1615 if (ctf_type != CTF_ERR)
1620 ctf_type = ctf_lookup_variable(dict, sym_name);
1623 if (ctf_type == CTF_ERR)
1626 ctf_next_t *i = NULL;
1627 const char *arcname;
1629 while ((fp = ctf_archive_next(ctfa, &i, &arcname, 1, &ctf_err)) != NULL)
1631 if ((ctf_type = ctf_lookup_by_symbol_name (fp, sym_name)) == CTF_ERR)
1632 ctf_type = ctf_lookup_variable(fp, sym_name);
1634 if (ctf_type != CTF_ERR)
1653 fill_ctf_section(
const Elf_Scn *elf_section, ctf_sect_t *ctf_section)
1655 GElf_Shdr section_header_mem, *section_header;
1656 Elf_Data *section_data;
1658 section_header = gelf_getshdr(
const_cast<Elf_Scn*
>(elf_section),
1659 §ion_header_mem);
1660 section_data = elf_getdata(
const_cast<Elf_Scn*
>(elf_section), 0);
1665 ctf_section->cts_name =
"";
1666 ctf_section->cts_data = (
char *) section_data->d_buf;
1667 ctf_section->cts_size = section_data->d_size;
1668 ctf_section->cts_entsize = section_header->sh_entsize;
1680 elf_based_reader_sptr
1682 const vector<char**>& debug_info_root_paths,
1685 reader_sptr result(
new reader(elf_path,
1686 debug_info_root_paths,
1703 const std::string& elf_path,
1704 const vector<char**>& debug_info_root_path)
1706 ctf::reader& r =
dynamic_cast<reader&
>(rdr);
1707 r.initialize(elf_path, debug_info_root_path);
1724 dic_type_key(ctf_dict_t *dic, ctf_id_t ctf_type)
1726 std::stringstream key;
1728 if (ctf_type_isparent (dic, ctf_type))
1729 key << std::hex << ctf_type;
1731 key << std::hex << ctf_type <<
'-' << ctf_cuname(dic);
This file contains the declarations of the entry points to de-serialize an instance of abigail::corpu...
This file contains the declarations for an elf-based. DWARF and CTF readers can inherit this one.
This contains a set of ELF utilities used by the dwarf reader.
#define ABG_ASSERT(cond)
This is a wrapper around the 'assert' glibc call. It allows for its argument to have side effects,...
This contains the private implementation of the suppression engine of libabigail.
This contains the declarations for the symtab reader.
virtual ir::corpus_sptr read_corpus(status &status)
Read the ELF information associated to the current ELF file and construct an ABI representation from ...
The common interface of readers based on ELF.
virtual void initialize(const std::string &elf_path, const vector< char ** > &debug_info_root_paths)
(re)Initialize) the resources used by the current reader.
status
The status of the fe_iface::read_corpus call.
@ STATUS_NO_SYMBOLS_FOUND
This status is for when the symbols of the ELF binaries could not be read.
@ STATUS_DEBUG_INFO_NOT_FOUND
This status is for when the debug info could not be read.
@ STATUS_OK
This status is for when the call went OK.
@ STATUS_UNKNOWN
The status is in an unknown state.
The abstraction of an array type.
shared_ptr< subrange_type > subrange_sptr
Convenience typedef for a shared pointer on a function_decl::subrange.
std::vector< subrange_sptr > subranges_type
Convenience typedef for a vector of subrange_sptr.
Abstracts a class declaration.
Abstracts the building of the set of exported variables and functions.
Abstraction of a group of corpora.
This is the abstraction of a set of translation units (themselves seen as bundles of unitary abi arte...
origin
This abstracts where the corpus comes from. That is, either it has been read from the native xml form...
void sort_functions()
Sort the set of functions exported by this corpus.
exported_decls_builder_sptr get_exported_decls_builder() const
Getter for the object that is responsible for determining what decls ought to be in the set of export...
origin get_origin() const
Getter for the origin of the corpus.
void sort_variables()
Sort the set of variables exported by this corpus.
Abstracts a declaration for an enum type.
std::vector< enumerator > enumerators
Convenience typedef for a list of enumerator.
This is an abstraction of the set of resources necessary to manage several aspects of the internal re...
const type_base_sptr & get_void_type() const
Get the unique type_decl that represents a "void" type for the current environment....
const type_base_sptr & get_void_pointer_type() const
Getter of the "pointer-to-void" IR node that is shared across the ABI corpus. This node must be the o...
bool canonicalization_is_done() const
Test if the canonicalization of types created out of the current environment is done.
const type_base_sptr & get_variadic_parameter_type() const
Get a type_decl instance that represents a the type of a variadic function parameter....
Abstraction of a function parameter.
Abstraction for a function declaration.
shared_ptr< parameter > parameter_sptr
Convenience typedef for a shared pointer on a function_decl::parameter.
std::vector< parameter_sptr > parameters
Convenience typedef for a vector of parameter_sptr.
Abstraction of a function type.
The internal representation of an integral type.
string to_string(bool internal=false) const
Return the string representation of the current instance of integral_type.
The source location of a token.
The abstraction of a pointer type.
The abstraction of a qualified type.
CV
Bit field values representing the cv qualifiers of the underlying type.
A basic type declaration that introduces no scope.
The abstraction of a typedef declaration.
Abstracts a union type declaration.
Abstracts a variable declaration.
Helper class to allow range-for loops on symtabs for C++11 and later code. It serves as a proxy for t...
The symtab filter is the object passed to the symtab object in order to iterate over the symbols in t...
void set_public_symbols(bool new_value=true)
Enable or disable public symbol filtering.
void reset_reader(elf_based_reader &rdr, const std::string &elf_path, const vector< char ** > &debug_info_root_path)
Re-initialize a reader so that it can re-used to read another binary.
elf_based_reader_sptr create_reader(const std::string &elf_path, const vector< char ** > &debug_info_root_paths, environment &env)
Create and return a new read context to process CTF information from a given ELF file.
type_decl_sptr lookup_basic_type(const interned_string &type_name, const translation_unit &tu)
Lookup a basic type from a translation unit.
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.
shared_ptr< function_decl > function_decl_sptr
Convenience typedef for a shared pointer on a function_decl.
bool is_type(const type_or_decl_base &tod)
Test whether a declaration is a type.
shared_ptr< array_type_def > array_type_def_sptr
Convenience typedef for a shared pointer on a array_type_def.
bool is_anonymous_type(const type_base *t)
Test whether a declaration is a type.
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< class_decl > class_decl_sptr
Convenience typedef for a shared pointer on a class_decl.
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.
const type_decl * is_type_decl(const type_or_decl_base *t)
Test whether a type is a type_decl (a builtin type).
function_type_sptr is_function_type(const type_or_decl_base_sptr &t)
Test whether a type is a function_type.
shared_ptr< function_type > function_type_sptr
Convenience typedef for a shared pointer on a function_type.
shared_ptr< typedef_decl > typedef_decl_sptr
Convenience typedef for a shared pointer on a typedef_decl.
class_decl_sptr lookup_class_type(const string &fqn, const translation_unit &tu)
Lookup a class type from a translation unit.
bool parse_integral_type(const string &type_name, integral_type &type)
Parse an integral type from a string.
const enum_type_decl * is_enum_type(const type_or_decl_base *d)
Test if a decl is an enum_type_decl.
shared_ptr< var_decl > var_decl_sptr
Convenience typedef for a shared pointer on a var_decl.
shared_ptr< type_or_decl_base > type_or_decl_base_sptr
A convenience typedef for a shared_ptr to type_or_decl_base.
shared_ptr< translation_unit > translation_unit_sptr
Convenience typedef for a shared pointer on a translation_unit type.
const type_base_sptr lookup_type(const interned_string &fqn, const translation_unit &tu)
Lookup a type in a translation unit.
union_decl_sptr lookup_union_type(const interned_string &type_name, const translation_unit &tu)
Lookup a union type from a translation unit.
type_base_sptr canonicalize(type_base_sptr t)
Compute the canonical type of a given type.
shared_ptr< pointer_type_def > pointer_type_def_sptr
Convenience typedef for a shared pointer on a pointer_type_def.
enum_type_decl_sptr lookup_enum_type(const interned_string &type_name, const translation_unit &tu)
Lookup an enum type from a translation unit.
decl_base * is_decl(const type_or_decl_base *d)
Test if an ABI artifact is a declaration.
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...
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.
shared_ptr< enum_type_decl > enum_type_decl_sptr
Convenience typedef for shared pointer to a enum_type_decl.
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.
const decl_base * get_type_declaration(const type_base *t)
Get the declaration for a given type.
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.
shared_ptr< type_decl > type_decl_sptr
Convenience typedef for a shared pointer on a type_decl.
qualified_type_def * is_qualified_type(const type_or_decl_base *t)
Test whether a type is a reference_type_def.
typedef_decl_sptr lookup_typedef_type(const interned_string &type_name, const translation_unit &tu)
Lookup a typedef type from a translation unit.
Toplevel namespace for libabigail.