diff options
Diffstat (limited to 'gdb/solib-svr4.h')
-rw-r--r-- | gdb/solib-svr4.h | 126 |
1 files changed, 110 insertions, 16 deletions
diff --git a/gdb/solib-svr4.h b/gdb/solib-svr4.h index 1ff9be7..b331fa7 100644 --- a/gdb/solib-svr4.h +++ b/gdb/solib-svr4.h @@ -20,12 +20,15 @@ #ifndef GDB_SOLIB_SVR4_H #define GDB_SOLIB_SVR4_H +#include "gdbarch.h" #include "solib.h" struct objfile; -struct solib_ops; - -extern const solib_ops svr4_so_ops; +struct link_map_offsets; +struct probe_and_action; +struct svr4_info; +struct svr4_library_list; +struct svr4_so; /* Link map info to include in an allocated solib entry. */ @@ -50,6 +53,101 @@ struct lm_info_svr4 final : public lm_info using lm_info_svr4_up = std::unique_ptr<lm_info_svr4>; +/* What to do when a probe stop occurs. */ + +enum probe_action +{ + /* Something went seriously wrong. Stop using probes and + revert to using the older interface. */ + PROBES_INTERFACE_FAILED, + + /* No action is required. The shared object list is still + valid. */ + DO_NOTHING, + + /* The shared object list should be reloaded entirely. */ + FULL_RELOAD, + + /* Attempt to incrementally update the shared object list. If + the update fails or is not possible, fall back to reloading + the list in full. */ + UPDATE_OR_RELOAD, +}; + +/* solib_ops for SVR4 systems. */ + +struct svr4_solib_ops : public solib_ops +{ + void relocate_section_addresses (solib &so, target_section *) const override; + void clear_so (const solib &so) const override; + void clear_solib (program_space *pspace) const override; + void create_inferior_hook (int from_tty) const override; + owning_intrusive_list<solib> current_sos () const override; + bool open_symbol_file_object (int from_tty) const override; + bool in_dynsym_resolve_code (CORE_ADDR pc) const override; + bool same (const solib &gdb, const solib &inferior) const override; + bool keep_data_in_core (CORE_ADDR vaddr, unsigned long size) const override; + void update_breakpoints () const override; + void handle_event () const override; + std::optional<CORE_ADDR> find_solib_addr (solib &so) const override; + bool supports_namespaces () const override { return true; } + int find_solib_ns (const solib &so) const override; + int num_active_namespaces () const override; + std::vector<const solib *> get_solibs_in_ns (int nsid) const override; + + /* Return the appropriate link map offsets table for the architecture. */ + virtual link_map_offsets *fetch_link_map_offsets () const = 0; + + /* This needs to be public because it's accessed from an observer. */ + void current_sos_direct (svr4_info *info) const; + +private: + void create_probe_breakpoints (svr4_info *info, gdbarch *gdbarch, + const std::vector<probe *> *probes, + objfile *objfile) const; + bool find_and_create_probe_breakpoints (svr4_info *info, gdbarch *gdbarch, + obj_section *os, + bool with_prefix) const; + void create_event_breakpoints (svr4_info *info, gdbarch *gdbarch, + CORE_ADDR address) const; + int enable_break (svr4_info *info, int from_tty) const; + bool is_default_namespace (CORE_ADDR debug_base) const; + void free_probes_table (svr4_info *info) const; + CORE_ADDR find_r_brk (svr4_info *info) const; + CORE_ADDR find_r_ldsomap (svr4_info *info) const; + owning_intrusive_list<solib> default_sos (svr4_info *info) const; + int read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, + std::vector<svr4_so> &sos, int ignore_first) const; + lm_info_svr4_up read_lm_info (CORE_ADDR lm_addr) const; + int has_lm_dynamic_from_link_map () const; + CORE_ADDR lm_addr_check (const solib &so, bfd *abfd) const; + CORE_ADDR read_r_next (CORE_ADDR debug_base) const; + CORE_ADDR read_r_map (CORE_ADDR debug_base) const; + int parse_libraries (const char *document, svr4_library_list *list); + int current_sos_via_xfer_libraries (svr4_library_list *list, + const char *annex) const; + owning_intrusive_list<solib> collect_probes_sos (svr4_info *info) const; + owning_intrusive_list<solib> current_sos_1 (svr4_info *info) const; + owning_intrusive_list<solib> solibs_from_svr4_sos + (const std::vector<svr4_so> &sos) const; + void register_event_probe (objfile *objfile, probe *prob, CORE_ADDR address, + enum probe_action action) const; + void disable_probes_interface (svr4_info *info) const; + probe_and_action *event_probe_at (CORE_ADDR address) const; + void update_full (svr4_info *info) const; + int update_incremental (svr4_info *info, CORE_ADDR debug_base, + CORE_ADDR lm) const; + bool update_event_breakpoint (breakpoint *b) const; + CORE_ADDR find_debug_base (const solib *solib) const; +}; + +/* solib_ops for ILP32 SVR4 systems. */ + +struct ilp32_svr4_solib_ops : public svr4_solib_ops +{ + link_map_offsets *fetch_link_map_offsets () const override; +}; + /* Critical offsets and sizes which describe struct r_debug and struct link_map on SVR4-like targets. All offsets and sizes are in bytes unless otherwise specified. */ @@ -91,26 +189,22 @@ struct link_map_offsets int l_name_offset; }; -/* set_solib_svr4_fetch_link_map_offsets() is intended to be called by - a <arch>_gdbarch_init() function. It is used to establish an - architecture specific link_map_offsets fetcher for the architecture - being defined. */ +/* Set the gdbarch methods for SVR4 systems. */ -extern void set_solib_svr4_fetch_link_map_offsets - (struct gdbarch *gdbarch, struct link_map_offsets *(*func) (void)); +extern void set_solib_svr4_ops (gdbarch *gdbarch, + gdbarch_make_solib_ops_ftype make_solib_ops); /* This function is called by thread_db.c. Return the address of the link map for the given objfile. */ extern CORE_ADDR svr4_fetch_objfile_link_map (struct objfile *objfile); -/* Fetch (and possibly build) an appropriate `struct link_map_offsets' - for ILP32 and LP64 SVR4 systems. */ -extern struct link_map_offsets *svr4_ilp32_fetch_link_map_offsets (void); -extern struct link_map_offsets *svr4_lp64_fetch_link_map_offsets (void); +/* Return a new solib_ops for ILP32 SVR4 systems. */ + +extern solib_ops_up make_svr4_ilp32_solib_ops (); + +/* Return a new solib_ops for LP64 SVR4 systems. */ -/* Return true if PC lies in the dynamic symbol resolution code of the - SVR4 run time loader. */ -bool svr4_in_dynsym_resolve_code (CORE_ADDR pc); +extern solib_ops_up make_svr4_lp64_solib_ops (); /* For the MUSL C library, given link map address LM_ADDR, return the corresponding TLS module id, or 0 if not found. */ |