25#include "abg-internal.h"
30#include "abg-internal.h"
32ABG_BEGIN_EXPORT_DECLARATIONS
40ABG_END_EXPORT_DECLARATIONS
48using std::dynamic_pointer_cast;
55process_ctf_typedef(reader *rdr,
56 ctf_dict_t *ctf_dictionary,
60process_ctf_base_type(reader *rdr,
61 ctf_dict_t *ctf_dictionary,
65build_ir_node_for_variadic_parameter_type(reader &rdr,
69build_ir_node_for_void_type(reader& rdr,
73build_ir_node_for_void_pointer_type(reader& rdr,
77process_ctf_function_type(reader *rdr,
78 ctf_dict_t *ctf_dictionary,
82process_ctf_sou_members(reader *rdr,
83 ctf_dict_t *ctf_dictionary,
85 class_or_union_sptr sou);
88process_ctf_forward_type(reader *rdr,
89 ctf_dict_t *ctf_dictionary,
93process_ctf_struct_type(reader *rdr,
94 ctf_dict_t *ctf_dictionary,
98process_ctf_union_type(reader *rdr,
99 ctf_dict_t *ctf_dictionary,
103process_ctf_array_type(reader *rdr,
104 ctf_dict_t *ctf_dictionary,
108process_ctf_qualified_type(reader *rdr,
109 ctf_dict_t *ctf_dictionary,
113process_ctf_pointer_type(reader *rdr,
114 ctf_dict_t *ctf_dictionary,
118process_ctf_enum_type(reader *rdr,
119 ctf_dict_t *ctf_dictionary,
123fill_ctf_section(
const Elf_Scn *elf_section, ctf_sect_t *ctf_section);
126lookup_symbol_in_ctf_archive(ctf_archive_t *ctfa, ctf_dict_t **ctf_dict,
127 const char *sym_name);
130dic_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)
216 vector<type_base_sptr> types;
217 for (
const auto& entry : types_map)
218 types.push_back(entry.second);
221 (types.begin(), types.end(),
222 [](vector<type_base_sptr>::iterator& i)
238 reader(
const string& elf_path,
239 const vector<char**>& debug_info_root_paths,
290 const vector<char**>& debug_info_root_paths,
291 bool load_all_types =
false,
292 bool linux_kernel_mode =
false)
294 load_all_types = load_all_types;
295 linux_kernel_mode = linux_kernel_mode;
313 cur_transl_unit()
const
321 {
return options().env;}
328 {
return options().env;}
337 find_ctfa_file(std::string& ctfa_file)
339 std::string ctfa_dirname;
340 dir_name(corpus_path(), ctfa_dirname,
false);
345 ctfa_file = ctfa_dirname +
"/vmlinux.ctfa";
352 for (
const auto& path : debug_info_root_paths())
370 corpus_sptr corp =
corpus();
371 if ((corp->get_origin() & corpus::LINUX_KERNEL_BINARY_ORIGIN)
377 (~STATUS_DEBUG_INFO_NOT_FOUND);
381 if ((status & STATUS_NO_SYMBOLS_FOUND)
382 || !(status & STATUS_OK))
388 GElf_Ehdr *ehdr, eh_mem;
389 if (!(ehdr = gelf_getehdr(elf_handle(), &eh_mem)))
393 const char *symtab_name =
".dynsym";
394 const char *strtab_name =
".dynstr";
396 if (ehdr->e_type == ET_REL)
398 symtab_name =
".symtab";
399 strtab_name =
".strtab";
402 const Elf_Scn* ctf_scn = find_ctf_section();
403 fill_ctf_section(ctf_scn, &ctf_sect);
405 const Elf_Scn* symtab_scn =
406 elf_helpers::find_section_by_name(elf_handle(), symtab_name);
407 fill_ctf_section(symtab_scn, &symtab_sect);
409 const Elf_Scn* strtab_scn =
410 elf_helpers::find_section_by_name(elf_handle(), strtab_name);
411 fill_ctf_section(strtab_scn, &strtab_sect);
420 process_ctf_archive()
422 corpus_sptr corp =
corpus();
425 std::make_shared<translation_unit>(env(),
"", 64);
426 ir_translation_unit->set_language(translation_unit::LANG_C);
427 corp->add(ir_translation_unit);
428 cur_transl_unit(ir_translation_unit);
431 ctf_dict_t *ctf_dict, *dict_tmp;
432 const auto symt = symtab();
435 std::string dict_name;
437 if ((corp->get_origin() & corpus::LINUX_KERNEL_BINARY_ORIGIN)
442 std::size_t pos = dict_name.find(
".");
443 if (pos != string::npos)
444 dict_name.erase(pos);
446 std::replace(dict_name.begin(), dict_name.end(),
'-',
'_');
449 if ((ctf_dict = ctf_dict_open(ctfa,
450 dict_name.empty() ? NULL : dict_name.c_str(),
453 fprintf(stderr,
"ERROR dictionary not found\n");
461 std::string sym_name = symbol->get_name();
462 ctf_id_t ctf_sym_type;
464 ctf_sym_type = lookup_symbol_in_ctf_archive(ctfa, &ctf_dict,
466 if (ctf_sym_type == CTF_ERR)
469 if (ctf_type_kind(ctf_dict, ctf_sym_type) != CTF_K_FUNCTION)
471 const char *var_name = sym_name.c_str();
472 type_base_sptr var_type = build_type(ctf_dict, ctf_sym_type);
478 var_declaration.reset(
new var_decl(var_name,
483 var_declaration->set_symbol(symbol);
485 ir_translation_unit->get_global_scope());
486 var_declaration->set_is_in_public_symbol_table(
true);
487 add_var_to_exported_or_undefined_decls(var_declaration.get());
491 const char *func_name = sym_name.c_str();
492 ctf_id_t ctf_sym = ctf_sym_type;
493 type_base_sptr func_type = build_type(ctf_dict, ctf_sym);
503 func_declaration->set_symbol(symbol);
505 ir_translation_unit->get_global_scope());
506 func_declaration->set_is_in_public_symbol_table(
true);
507 add_fn_to_exported_or_undefined_decls(func_declaration.get());
513 ctf_dict_close(ctf_dict);
518 canonicalize_all_types();
533 process_ctf_type(ctf_dict_t *ctf_dictionary,
536 corpus_sptr corp =
corpus();
538 int type_kind = ctf_type_kind(ctf_dictionary, ctf_type);
539 type_base_sptr result;
541 if (lookup_unknown_type(ctf_type))
544 if ((result =
lookup_type(ctf_dictionary, ctf_type)))
553 = process_ctf_base_type(
this, ctf_dictionary, ctf_type);
560 = process_ctf_typedef(
this, ctf_dictionary, ctf_type);
567 = process_ctf_pointer_type(
this, ctf_dictionary, ctf_type);
568 result = pointer_type;
575 type_base_sptr qualified_type
576 = process_ctf_qualified_type(
this, ctf_dictionary, ctf_type);
577 result = qualified_type;
583 = process_ctf_array_type(
this, ctf_dictionary, ctf_type);
590 = process_ctf_enum_type(
this, ctf_dictionary, ctf_type);
597 = process_ctf_function_type(
this, ctf_dictionary, ctf_type);
604 = process_ctf_struct_type(
this, ctf_dictionary, ctf_type);
609 result = process_ctf_forward_type(
this, ctf_dictionary, ctf_type);
614 = process_ctf_union_type(
this, ctf_dictionary, ctf_type);
626 fprintf(stderr,
"NOT PROCESSED TYPE %lu\n", ctf_type);
627 add_unknown_type(ctf_type);
645 build_type(ctf_dict_t *ctf_dictionary, ctf_id_t ctf_type)
647 type_base_sptr result =
lookup_type(ctf_dictionary, ctf_type);
650 result = process_ctf_type(ctf_dictionary, ctf_type);
665 corpus_sptr corp =
corpus();
669 origin |= corpus::CTF_ORIGIN;
670 corp->set_origin(origin);
672 slurp_elf_info(status);
674 return corpus_sptr();
676 if (!(origin & corpus::LINUX_KERNEL_BINARY_ORIGIN)
681 if ((corp->get_origin() & corpus::LINUX_KERNEL_BINARY_ORIGIN)
686 std::string ctfa_filename;
687 if (find_ctfa_file(ctfa_filename))
688 ctfa = ctf_arc_open(ctfa_filename.c_str(), &errp);
696 ctfa = ctf_arc_bufopen(&ctf_sect, &symtab_sect,
697 &strtab_sect, &errp);
704 process_ctf_archive();
721typedef shared_ptr<reader> reader_sptr;
732process_ctf_typedef(reader *rdr,
733 ctf_dict_t *ctf_dictionary,
736 corpus_sptr corp = rdr->corpus();
740 ctf_id_t ctf_utype = ctf_type_reference(ctf_dictionary, ctf_type);
741 if (ctf_utype == CTF_ERR)
744 const char *typedef_name = ctf_type_name_raw(ctf_dictionary, ctf_type);
745 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
749 type_base_sptr utype = rdr->build_type(ctf_dictionary, ctf_utype);
754 result = dynamic_pointer_cast<typedef_decl>
755 (rdr->lookup_type(ctf_dictionary, ctf_type));
768 decl_base_sptr decl =
is_decl(utype);
770 decl->set_naming_typedef(result);
776 rdr->add_type(ctf_dictionary, ctf_type, result);
792process_ctf_base_type(reader *rdr,
793 ctf_dict_t *ctf_dictionary,
796 corpus_sptr corp = rdr->corpus();
800 ctf_id_t ctf_ref = ctf_type_reference(ctf_dictionary, ctf_type);
801 const char *type_name = ctf_type_name_raw(ctf_dictionary,
802 (ctf_ref != CTF_ERR) ? ctf_ref : ctf_type);
807 ctf_encoding_t type_encoding;
808 if (ctf_type_encoding(ctf_dictionary,
809 (ctf_ref != CTF_ERR) ? ctf_ref : ctf_type,
814 if (type_encoding.cte_bits == 0
815 && type_encoding.cte_format == CTF_INT_SIGNED)
818 decl_base_sptr type_declaration = build_ir_node_for_void_type(*rdr,
820 type_base_sptr void_type =
is_type(type_declaration);
826 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
828 string normalized_type_name = type_name;
831 normalized_type_name = int_type.
to_string();
840 type_encoding.cte_bits,
850 rdr->add_type(ctf_dictionary, ctf_type, result);
864build_ir_node_for_variadic_parameter_type(reader &rdr,
873 return type_declaration;
909build_ir_node_for_void_pointer_type(reader& rdr,
928process_ctf_function_type(reader *rdr,
929 ctf_dict_t *ctf_dictionary,
932 corpus_sptr corp = rdr->corpus();
937 ctf_funcinfo_t funcinfo;
938 ctf_func_type_info(ctf_dictionary, ctf_type, &funcinfo);
939 int vararg_p = funcinfo.ctc_flags & CTF_FUNC_VARARG;
942 ctf_id_t ctf_ret_type = funcinfo.ctc_return;
943 type_base_sptr ret_type = rdr->build_type(ctf_dictionary, ctf_ret_type);
948 int argc = funcinfo.ctc_argc;
949 std::vector<ctf_id_t> argv(argc);
950 if (
static_cast<ctf_id_t
>(ctf_func_type_args(ctf_dictionary, ctf_type,
951 argc, argv.data())) == CTF_ERR)
955 for (
int i = 0; i < argc; i++)
957 ctf_id_t ctf_arg_type = argv[i];
958 type_base_sptr arg_type = rdr->build_type(ctf_dictionary, ctf_arg_type);
967 function_parms.push_back(parm);
972 type_base_sptr arg_type =
973 is_type(build_ir_node_for_variadic_parameter_type(*rdr, tunit));
980 function_parms.push_back(parm);
983 result = dynamic_pointer_cast<function_type>
984 (rdr->lookup_type(ctf_dictionary, ctf_type));
991 tunit->get_address_size(),
996 tunit->bind_function_type_life_time(result);
997 result->set_is_artificial(
true);
1000 rdr->add_type(ctf_dictionary, ctf_type, result);
1014process_ctf_sou_members(reader *rdr,
1015 ctf_dict_t *ctf_dictionary,
1017 class_or_union_sptr sou)
1019 corpus_sptr corp = rdr->corpus();
1021 ssize_t member_size;
1022 ctf_next_t *member_next = NULL;
1023 const char *member_name = NULL;
1024 ctf_id_t member_ctf_type;
1026 while ((member_size = ctf_member_next(ctf_dictionary, ctf_type,
1027 &member_next, &member_name,
1031 ctf_membinfo_t membinfo;
1033 if (
static_cast<ctf_id_t
>(ctf_member_info(ctf_dictionary,
1036 &membinfo)) == CTF_ERR)
1040 type_base_sptr member_type = rdr->build_type(ctf_dictionary,
1052 sou->add_data_member(data_member_decl,
1056 membinfo.ctm_offset);
1058 if (ctf_errno(ctf_dictionary) != ECTF_NEXT_END)
1059 fprintf(stderr,
"ERROR from ctf_member_next\n");
1070static type_base_sptr
1071process_ctf_forward_type(reader *rdr,
1072 ctf_dict_t *ctf_dictionary,
1076 decl_base_sptr result;
1077 std::string type_name = ctf_type_name_raw(ctf_dictionary,
1079 bool type_is_anonymous = (type_name ==
"");
1080 uint32_t kind = ctf_type_kind_forwarded (ctf_dictionary, ctf_type);
1082 if (kind == CTF_K_UNION)
1089 decl_base::VISIBILITY_DEFAULT,
1090 type_is_anonymous));
1091 union_fwd->set_is_declaration_only(
true);
1096 if (!type_is_anonymous)
1097 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
1102 struct_fwd(
new class_decl(rdr->env(), type_name,
1106 decl_base::VISIBILITY_DEFAULT,
1107 type_is_anonymous));
1108 struct_fwd->set_is_declaration_only(
true);
1109 result = struct_fwd;
1116 rdr->add_type(ctf_dictionary, ctf_type,
is_type(result));
1130process_ctf_struct_type(reader *rdr,
1131 ctf_dict_t *ctf_dictionary,
1134 corpus_sptr corp = rdr->corpus();
1137 std::string struct_type_name = ctf_type_name_raw(ctf_dictionary,
1139 bool struct_type_is_anonymous = (struct_type_name ==
"");
1141 if (!struct_type_is_anonymous)
1142 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
1149 ctf_type_size(ctf_dictionary, ctf_type) * 8,
1153 decl_base::VISIBILITY_DEFAULT,
1154 struct_type_is_anonymous));
1164 rdr->add_type(ctf_dictionary, ctf_type, result);
1169 process_ctf_sou_members(rdr, ctf_dictionary, ctf_type, result);
1182static union_decl_sptr
1183process_ctf_union_type(reader *rdr,
1184 ctf_dict_t *ctf_dictionary,
1187 corpus_sptr corp = rdr->corpus();
1189 union_decl_sptr result;
1190 std::string union_type_name = ctf_type_name_raw(ctf_dictionary,
1192 bool union_type_is_anonymous = (union_type_name ==
"");
1194 if (!union_type_is_anonymous)
1195 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
1202 ctf_type_size(ctf_dictionary, ctf_type) * 8,
1204 decl_base::VISIBILITY_DEFAULT,
1205 union_type_is_anonymous));
1215 rdr->add_type(ctf_dictionary, ctf_type, result);
1220 process_ctf_sou_members(rdr, ctf_dictionary, ctf_type, result);
1238build_array_ctf_range(reader *rdr, ctf_dict_t *dic,
1239 ctf_id_t index, uint64_t nelems)
1241 bool is_non_finite =
false;
1242 corpus_sptr corp = rdr->corpus();
1245 array_type_def::subrange_type::bound_value lower_bound;
1246 array_type_def::subrange_type::bound_value upper_bound;
1248 type_base_sptr index_type = rdr->build_type(dic, index);
1252 lower_bound.set_unsigned(0);
1253 upper_bound.set_unsigned(nelems > 0 ? nelems - 1 : 0U);
1256 if (upper_bound.get_unsigned_value() == 0 && nelems == 0)
1257 is_non_finite =
true;
1259 subrange.reset(
new array_type_def::subrange_type(rdr->env(),
1265 translation_unit::LANG_C));
1267 subrange->set_size_in_bits(rdr->cur_transl_unit()->get_address_size());
1272 subrange->is_non_finite(is_non_finite);
1289process_ctf_array_type(reader *rdr,
1290 ctf_dict_t *ctf_dictionary,
1293 corpus_sptr corp = rdr->corpus();
1296 ctf_arinfo_t ctf_ainfo;
1299 if (
static_cast<ctf_id_t
>(ctf_array_info(ctf_dictionary,
1301 &ctf_ainfo)) == CTF_ERR)
1304 ctf_id_t ctf_element_type = ctf_ainfo.ctr_contents;
1305 ctf_id_t ctf_index_type = ctf_ainfo.ctr_index;
1306 uint64_t nelems = ctf_ainfo.ctr_nelems;
1310 int type_array_kind = ctf_type_kind(ctf_dictionary, ctf_element_type);
1311 while (type_array_kind == CTF_K_ARRAY)
1313 if (
static_cast<ctf_id_t
>(ctf_array_info(ctf_dictionary,
1315 &ctf_ainfo)) == CTF_ERR)
1318 subrange = build_array_ctf_range(rdr, ctf_dictionary,
1319 ctf_ainfo.ctr_index,
1320 ctf_ainfo.ctr_nelems);
1321 subranges.push_back(subrange);
1322 ctf_element_type = ctf_ainfo.ctr_contents;
1323 type_array_kind = ctf_type_kind(ctf_dictionary, ctf_element_type);
1326 std::reverse(subranges.begin(), subranges.end());
1329 type_base_sptr element_type = rdr->build_type(ctf_dictionary,
1335 type_base_sptr index_type = rdr->build_type(ctf_dictionary,
1340 result = dynamic_pointer_cast<array_type_def>
1341 (rdr->lookup_type(ctf_dictionary, ctf_type));
1345 subrange = build_array_ctf_range(rdr, ctf_dictionary,
1346 ctf_index_type, nelems);
1347 subranges.push_back(subrange);
1355 rdr->add_type(ctf_dictionary, ctf_type, result);
1382static decl_base_sptr
1383maybe_strip_qualification(
const qualified_type_def_sptr t)
1388 decl_base_sptr result = t;
1389 type_base_sptr u = t->get_underlying_type();
1401 type_base_sptr element_type = array->get_element_type();
1406 quals |= t->get_cv_quals();
1409 qualified->set_cv_quals(quals);
1424static type_base_sptr
1425process_ctf_qualified_type(reader *rdr,
1426 ctf_dict_t *ctf_dictionary,
1429 corpus_sptr corp = rdr->corpus();
1431 type_base_sptr result;
1432 int type_kind = ctf_type_kind(ctf_dictionary, ctf_type);
1433 ctf_id_t ctf_utype = ctf_type_reference(ctf_dictionary, ctf_type);
1434 type_base_sptr utype = rdr->build_type(ctf_dictionary, ctf_utype);
1438 result = dynamic_pointer_cast<type_base>
1439 (rdr->lookup_type(ctf_dictionary, ctf_type));
1444 if (type_kind == CTF_K_CONST)
1445 qualifiers |= qualified_type_def::CV_CONST;
1446 else if (type_kind == CTF_K_VOLATILE)
1447 qualifiers |= qualified_type_def::CV_VOLATILE;
1448 else if (type_kind == CTF_K_RESTRICT)
1449 qualifiers |= qualified_type_def::CV_RESTRICT;
1469 rdr->add_type(ctf_dictionary, ctf_type, result);
1484process_ctf_pointer_type(reader *rdr,
1485 ctf_dict_t *ctf_dictionary,
1488 corpus_sptr corp = rdr->corpus();
1491 ctf_id_t ctf_target_type = ctf_type_reference(ctf_dictionary, ctf_type);
1492 if (ctf_target_type == CTF_ERR)
1495 type_base_sptr target_type = rdr->build_type(ctf_dictionary,
1500 result = dynamic_pointer_cast<pointer_type_def>
1501 (rdr->lookup_type(ctf_dictionary, ctf_type));
1505 if (rdr->env().is_void_type(target_type))
1506 result =
is_pointer_type(build_ir_node_for_void_pointer_type(*rdr, tunit));
1509 ctf_type_size(ctf_dictionary,
1511 ctf_type_align(ctf_dictionary,
1517 rdr->add_type(ctf_dictionary, ctf_type, result);
1532process_ctf_enum_type(reader *rdr,
1533 ctf_dict_t *ctf_dictionary,
1538 ctf_id_t ctf_ref = ctf_type_reference(ctf_dictionary, ctf_type);
1539 std::string enum_name = ctf_type_name_raw(ctf_dictionary,
1540 (ctf_ref != CTF_ERR)
1541 ? ctf_ref : ctf_type);
1543 if (!enum_name.empty())
1544 if (corpus_sptr corp = rdr->should_reuse_type_from_corpus_group())
1551 size_t utype_size_in_bits = ctf_type_size(ctf_dictionary,
1552 (ctf_ref != CTF_ERR)
1553 ? ctf_ref : ctf_type) * 8;
1554 string underlying_type_name =
1556 utype_size_in_bits);
1560 underlying_type_name,
1564 utype->set_is_anonymous(
true);
1565 utype->set_is_artificial(
true);
1574 ctf_next_t *enum_next = NULL;
1578 while ((ename = ctf_enum_next(ctf_dictionary, ctf_type, &enum_next, &evalue)))
1579 enms.push_back(enum_type_decl::enumerator(ename, evalue));
1581 if (ctf_errno(ctf_dictionary) != ECTF_NEXT_END)
1583 fprintf(stderr,
"ERROR from ctf_enum_next\n");
1588 utype, enms, enum_name.c_str()));
1592 rdr->add_type(ctf_dictionary, ctf_type, result);
1615lookup_symbol_in_ctf_archive(ctf_archive_t *ctfa, ctf_dict_t **ctf_dict,
1616 const char *sym_name)
1619 ctf_dict_t *dict = *ctf_dict;
1620 ctf_id_t ctf_type = ctf_lookup_by_symbol_name(dict, sym_name);
1622 if (ctf_type != CTF_ERR)
1627 ctf_type = ctf_lookup_variable(dict, sym_name);
1630 if (ctf_type == CTF_ERR)
1633 ctf_next_t *i = NULL;
1634 const char *arcname;
1636 while ((fp = ctf_archive_next(ctfa, &i, &arcname, 1, &ctf_err)) != NULL)
1638 if ((ctf_type = ctf_lookup_by_symbol_name (fp, sym_name)) == CTF_ERR)
1639 ctf_type = ctf_lookup_variable(fp, sym_name);
1641 if (ctf_type != CTF_ERR)
1660fill_ctf_section(
const Elf_Scn *elf_section, ctf_sect_t *ctf_section)
1662 GElf_Shdr section_header_mem, *section_header;
1663 Elf_Data *section_data;
1665 section_header = gelf_getshdr(
const_cast<Elf_Scn*
>(elf_section),
1666 §ion_header_mem);
1667 section_data = elf_getdata(
const_cast<Elf_Scn*
>(elf_section), 0);
1672 ctf_section->cts_name =
"";
1673 ctf_section->cts_data = (
char *) section_data->d_buf;
1674 ctf_section->cts_size = section_data->d_size;
1675 ctf_section->cts_entsize = section_header->sh_entsize;
1687elf_based_reader_sptr
1689 const vector<char**>& debug_info_root_paths,
1692 reader_sptr result(
new reader(elf_path,
1693 debug_info_root_paths,
1710 const std::string& elf_path,
1711 const vector<char**>& debug_info_root_path)
1713 ctf::reader& r =
dynamic_cast<reader&
>(rdr);
1714 r.initialize(elf_path, debug_info_root_path);
1731dic_type_key(ctf_dict_t *dic, ctf_id_t ctf_type)
1733 std::stringstream key;
1735 if (ctf_type_isparent (dic, ctf_type))
1736 key << std::hex << ctf_type;
1738 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.
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.
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.
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.