Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symtab refactor #1

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a5d02b9
Bug 26127 - abidw --annotate emits incomplete function types
Jun 18, 2020
5f1945b
get_canonical_type_for: restore environment better
myxoid Jun 17, 2020
df47240
Improve code comments and whitespace.
myxoid Jun 10, 2020
56db287
Refactor d.context() as ctxt in report(enum_diff).
myxoid Jun 10, 2020
2b2f073
Tidy build_enum_type state variables.
myxoid Jun 10, 2020
dd1c608
Rename declaration-definition change category.
myxoid Jun 29, 2020
db88763
abg-cxx-compat: add simplified version of std::optional
metti Apr 28, 2020
3be8a10
abg-cxx-compat: more <functional> support: std::bind and friends
metti Apr 29, 2020
4fba0c2
abg-ir: elf_symbol: add is_in_ksymtab field
metti Apr 29, 2020
f515490
abg-ir: elf_symbol: add is_suppressed field
metti Jun 8, 2020
3a34228
dwarf-reader split: create abg-symtab-reader.{h,cc} and test case
metti Apr 13, 2020
c8bccd4
Refactor ELF symbol table reading by adding a new symtab reader
metti Apr 29, 2020
b28ecc7
Integrate new symtab reader into corpus and read_context
metti May 19, 2020
a330a1d
corpus: make get_(undefined_)?_(var|fun)_symbols use the new symtab
metti Apr 30, 2020
197b11b
corpus: make get_unreferenced_(function|variable)_symbols use the new…
metti May 4, 2020
554d990
abg-reader: avoid using the (var|function)_symbol_map
metti May 4, 2020
a880ff8
dwarf-reader: read_context: use new symtab in *_symbols_is_exported
metti May 6, 2020
ec12acb
Switch kernel stuff over to new symtab and drop unused code
metti May 6, 2020
46a8880
abg-elf-helpers: migrate ppc64 specific helpers
metti May 11, 2020
176bdd5
symtab_reader: add support for ppc64 ELFv1 binaries
metti May 14, 2020
6c9fe81
abg-corpus: remove symbol maps and their setters
metti May 20, 2020
ccadb62
dwarf reader: drop now-unused code related to symbol table reading
metti Jun 2, 2020
12b74a3
test-symtab: add tests for whitelisted functions
metti Jun 29, 2020
8379985
symtab/dwarf-reader: allow hinting of main symbols for aliases
metti Jun 30, 2020
c59aada
dwarf-reader/writer: consider aliases when dealing with suppressions
metti Jun 28, 2020
de78448
symtab: Add support for MODVERSIONS (CRC checksums)
metti Jun 30, 2020
dd0428c
reader/symtab: Improve handling for suppressed aliases
metti Jul 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ abg-version.h \
abg-viz-common.h \
abg-viz-dot.h \
abg-viz-svg.h \
abg-regex.h
abg-regex.h \
abg-symtab-reader.h

EXTRA_DIST = abg-version.h.in
10 changes: 5 additions & 5 deletions include/abg-comparison.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,9 @@ enum diff_category
/// present as a child of a other nodes in the diff tree.
REDUNDANT_CATEGORY = 1 << 13,

/// This means that a diff node in the sub-tree carries a class type
/// that was declaration-only and that is now defined, or vice
/// versa.
CLASS_DECL_ONLY_DEF_CHANGE_CATEGORY = 1 << 14,
/// This means that a diff node in the sub-tree carries a type that
/// was declaration-only and that is now defined, or vice versa.
TYPE_DECL_ONLY_DEF_CHANGE_CATEGORY = 1 << 14,

/// A diff node in this category is a function parameter type which
/// top cv-qualifiers change.
Expand All @@ -447,6 +446,7 @@ enum diff_category
/// array type of a global variable, but the ELF size of the
/// variable didn't change.
BENIGN_INFINITE_ARRAY_CHANGE_CATEGORY = 1 << 20,

/// A special enumerator that is the logical 'or' all the
/// enumerators above.
///
Expand All @@ -467,7 +467,7 @@ enum diff_category
| SIZE_OR_OFFSET_CHANGE_CATEGORY
| VIRTUAL_MEMBER_CHANGE_CATEGORY
| REDUNDANT_CATEGORY
| CLASS_DECL_ONLY_DEF_CHANGE_CATEGORY
| TYPE_DECL_ONLY_DEF_CHANGE_CATEGORY
| FN_PARM_TYPE_TOP_CV_CHANGE_CATEGORY
| FN_PARM_TYPE_CV_CHANGE_CATEGORY
| FN_RETURN_TYPE_CV_CHANGE_CATEGORY
Expand Down
24 changes: 3 additions & 21 deletions include/abg-corpus.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,26 +170,14 @@ class corpus
operator==(const corpus&) const;

void
set_fun_symbol_map(string_elf_symbols_map_sptr);
set_symtab(symtab_reader::symtab_sptr);

void
set_undefined_fun_symbol_map(string_elf_symbols_map_sptr);

void
set_var_symbol_map(string_elf_symbols_map_sptr);

void
set_undefined_var_symbol_map(string_elf_symbols_map_sptr);

const string_elf_symbols_map_sptr
get_fun_symbol_map_sptr() const;
const symtab_reader::symtab_sptr&
get_symtab() const;

virtual const string_elf_symbols_map_type&
get_fun_symbol_map() const;

const string_elf_symbols_map_sptr
get_undefined_fun_symbol_map_sptr() const;

const string_elf_symbols_map_type&
get_undefined_fun_symbol_map() const;

Expand All @@ -199,15 +187,9 @@ class corpus
const elf_symbols&
get_sorted_undefined_fun_symbols() const;

const string_elf_symbols_map_sptr
get_var_symbol_map_sptr() const;

virtual const string_elf_symbols_map_type&
get_var_symbol_map() const;

const string_elf_symbols_map_sptr
get_undefined_var_symbol_map_sptr() const;

const string_elf_symbols_map_type&
get_undefined_var_symbol_map() const;

Expand Down
100 changes: 100 additions & 0 deletions include/abg-cxx-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#ifndef __ABG_CXX_COMPAT_H
#define __ABG_CXX_COMPAT_H

// C++11 support (mostly via tr1 if compiled with earlier standard)

#if __cplusplus >= 201103L

#include <functional>
Expand All @@ -39,13 +41,32 @@

#endif

// C++17 support (via custom implementations if compiled with earlier standard)

#if __cplusplus >= 201703L

#include <optional>

#else

#include <stdexcept> // for throwing std::runtime_error("bad_optional_access")

#endif

namespace abg_compat {

#if __cplusplus >= 201103L

// <functional>
using std::bind;
using std::function;
using std::hash;

namespace placeholders
{
using namespace std::placeholders;
}

// <memory>
using std::shared_ptr;
using std::weak_ptr;
Expand All @@ -61,8 +82,15 @@ using std::unordered_set;
#else

// <functional>
using std::tr1::bind;
using std::tr1::function;
using std::tr1::hash;

namespace placeholders
{
using namespace std::tr1::placeholders;
}

// <memory>
using std::tr1::shared_ptr;
using std::tr1::weak_ptr;
Expand All @@ -77,6 +105,78 @@ using std::tr1::unordered_set;

#endif

#if __cplusplus >= 201703L

using std::optional;

#else

// <optional>

/// Simplified implementation of std::optional just enough to be used as a
/// replacement for our purposes and when compiling with pre C++17.
///
/// The implementation intentionally does not support a whole lot of features
/// to minimize the maintainence effort with this.
template <typename T> class optional
{
bool has_value_;
T value_;

public:
optional() : has_value_(false), value_() {}
optional(const T& value) : has_value_(true), value_(value) {}

bool
has_value() const
{
return has_value_;
}

const T&
value() const
{
if (!has_value_)
throw std::runtime_error("bad_optional_access");
return value_;
}

const T
value_or(const T& default_value) const
{
if (!has_value_)
return default_value;
return value_;
}

const T&
operator*() const
{ return value_; }

T&
operator*()
{ return value_; }

const T*
operator->() const
{ return &value_; }

T*
operator->()
{ return &value_; }

optional&
operator=(const T& value)
{
has_value_ = true;
value_ = value;
return *this;
}

explicit operator bool() const { return has_value_; }
};

#endif
}

#endif // __ABG_CXX_COMPAT_H
6 changes: 0 additions & 6 deletions include/abg-dwarf-reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,6 @@ set_drop_undefined_syms(read_context& ctxt,
void
set_do_log(read_context& ctxt, bool f);

void
set_ignore_symbol_table(read_context &ctxt, bool f);

bool
get_ignore_symbol_table(const read_context &ctxt);

void
set_environment(read_context& ctxt,
ir::environment*);
Expand Down
10 changes: 9 additions & 1 deletion include/abg-fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ typedef weak_ptr<typedef_decl> typedef_decl_wptr;

class enum_type_decl;

/// Convenience typedef for shared pointer on enum_type_decl.
/// Convenience typedef for shared pointer to a @ref enum_type_decl.
typedef shared_ptr<enum_type_decl> enum_type_decl_sptr;

class class_or_union;
Expand Down Expand Up @@ -1331,6 +1331,14 @@ typedef vector<suppression_sptr> suppressions_type;

} // end namespace suppr

namespace symtab_reader
{

class symtab;
typedef abg_compat::shared_ptr<symtab> symtab_sptr;

} // end namespace symtab_reader

void
dump(const decl_base_sptr, std::ostream&);

Expand Down
66 changes: 53 additions & 13 deletions include/abg-ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,11 @@ class elf_symbol
bool d,
bool c,
const version& ve,
visibility vi,
bool is_linux_string_cst = false);
visibility vi,
bool is_linux_string_cst = false,
bool is_in_ksymtab = false,
uint64_t crc = 0,
bool is_suppressed = false);

elf_symbol(const elf_symbol&);

Expand All @@ -865,17 +868,20 @@ class elf_symbol
create();

static elf_symbol_sptr
create(const environment* e,
size_t i,
size_t s,
const string& n,
type t,
binding b,
bool d,
bool c,
const version& ve,
visibility vi,
bool is_linux_string_cst = false);
create(const environment* e,
size_t i,
size_t s,
const string& n,
type t,
binding b,
bool d,
bool c,
const version& ve,
visibility vi,
bool is_linux_string_cst = false,
bool is_in_ksymtab = false,
uint64_t crc = 0,
bool is_suppressed = false);

const environment*
get_environment() const;
Expand Down Expand Up @@ -943,6 +949,24 @@ class elf_symbol
bool
is_variable() const;

bool
is_in_ksymtab() const;

void
set_is_in_ksymtab(bool is_in_ksymtab);

uint64_t
get_crc() const;

void
set_crc(uint64_t crc);

bool
is_suppressed() const;

void
set_is_suppressed(bool is_suppressed);

const elf_symbol_sptr
get_main_symbol() const;

Expand All @@ -952,6 +976,9 @@ class elf_symbol
bool
is_main_symbol() const;

elf_symbol_sptr
update_main_symbol(const std::string&);

elf_symbol_sptr
get_next_alias() const;

Expand Down Expand Up @@ -1391,6 +1418,9 @@ class decl_base : public virtual type_or_decl_base
const interned_string&
peek_qualified_name() const;

void
clear_qualified_name();

void
set_qualified_name(const interned_string&) const;

Expand Down Expand Up @@ -2024,6 +2054,7 @@ class qualified_type_def : public virtual type_base, public virtual decl_base

protected:
string build_name(bool, bool internal = false) const;
virtual void on_canonical_type_set();

public:

Expand Down Expand Up @@ -2126,6 +2157,9 @@ class pointer_type_def : public virtual type_base, public virtual decl_base
// Forbidden.
pointer_type_def();

protected:
virtual void on_canonical_type_set();

public:

/// A hasher for instances of pointer_type_def
Expand Down Expand Up @@ -2180,6 +2214,9 @@ class reference_type_def : public virtual type_base, public virtual decl_base
// Forbidden.
reference_type_def();

protected:
virtual void on_canonical_type_set();

public:

/// Hasher for intances of reference_type_def.
Expand Down Expand Up @@ -3068,6 +3105,9 @@ class function_type : public virtual type_base
struct priv;
typedef shared_ptr<priv> priv_sptr;

protected:
virtual void on_canonical_type_set();

public:
/// Hasher for an instance of function_type
struct hash;
Expand Down
Loading