From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 63EC0385841F; Tue, 20 Sep 2022 18:40:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63EC0385841F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663699248; bh=jD48gZz46BpVmGuwGbEOjqdQiPsHCDWHuVAzwLVbaXk=; h=From:To:Subject:Date:From; b=N8P3dxduiSMMc0HLxok0Oya+nT/jRsUH2QhYE8FK27i+CAVB16ta78GssIoKNzKay dzguWRsNdh6oQBPANC8S/48mgQbVMubsPxa3/jdPhIbPzMK9FQ+wwU2SaKZOn311VG 4r4tJDsOelqZbOHsji8+KTgr5KSHv+vYGFY7mEZk= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Move solib_ops into gdbarch X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 5898c79ae692ed02dd9267888541b352423a9331 X-Git-Newrev: 9e468e953cd2f605a3f51d6ef6532e46b8fdd7b4 Message-Id: <20220920184048.63EC0385841F@sourceware.org> Date: Tue, 20 Sep 2022 18:40:48 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D9e468e953cd2= f605a3f51d6ef6532e46b8fdd7b4 commit 9e468e953cd2f605a3f51d6ef6532e46b8fdd7b4 Author: Tom Tromey Date: Mon Aug 8 10:41:43 2022 -0600 Move solib_ops into gdbarch =20 This changs solib_ops to be an ordinary gdbarch value and updates all the uses. This removes a longstanding FIXME and makes the code somewhat cleaner as well. Diff: --- gdb/amd64-darwin-tdep.c | 2 +- gdb/arch-utils.c | 1 + gdb/dicos-tdep.c | 2 +- gdb/frv-tdep.c | 2 +- gdb/gdbarch-components.py | 8 ++++++++ gdb/gdbarch-gen.h | 5 +++++ gdb/gdbarch.c | 22 ++++++++++++++++++++++ gdb/i386-darwin-tdep.c | 2 +- gdb/i386-nto-tdep.c | 2 +- gdb/mips-linux-tdep.c | 2 +- gdb/ppc-linux-tdep.c | 2 +- gdb/rs6000-aix-tdep.c | 2 +- gdb/solib-svr4.c | 2 +- gdb/solib.c | 48 ++++++++++++-------------------------------= ---- gdb/solib.h | 5 ----- gdb/tic6x-linux-tdep.c | 2 +- gdb/windows-tdep.c | 2 +- 17 files changed, 59 insertions(+), 52 deletions(-) diff --git a/gdb/amd64-darwin-tdep.c b/gdb/amd64-darwin-tdep.c index 7fc35536bc6..718bf4996e5 100644 --- a/gdb/amd64-darwin-tdep.c +++ b/gdb/amd64-darwin-tdep.c @@ -113,7 +113,7 @@ x86_darwin_init_abi_64 (struct gdbarch_info info, struc= t gdbarch *gdbarch) =20 tdep->jb_pc_offset =3D 56; =20 - set_solib_ops (gdbarch, &darwin_so_ops); + set_gdbarch_so_ops (gdbarch, &darwin_so_ops); } =20 void _initialize_amd64_darwin_tdep (); diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 9bd4f0ddae6..5943965bd75 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -36,6 +36,7 @@ #include "reggroups.h" #include "auxv.h" #include "observable.h" +#include "solib-target.h" =20 #include "gdbsupport/version.h" =20 diff --git a/gdb/dicos-tdep.c b/gdb/dicos-tdep.c index caff2474719..d22dfd65c60 100644 --- a/gdb/dicos-tdep.c +++ b/gdb/dicos-tdep.c @@ -28,7 +28,7 @@ void dicos_init_abi (struct gdbarch *gdbarch) { - set_solib_ops (gdbarch, &solib_target_so_ops); + set_gdbarch_so_ops (gdbarch, &solib_target_so_ops); =20 /* Every process, although has its own address space, sees the same list of shared libraries. There's no "main executable" in DICOS, diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c index 8029080c043..8bbc2fa57ae 100644 --- a/gdb/frv-tdep.c +++ b/gdb/frv-tdep.c @@ -1556,7 +1556,7 @@ frv_gdbarch_init (struct gdbarch_info info, struct gd= barch_list *arches) set_gdbarch_convert_from_func_ptr_addr (gdbarch, frv_convert_from_func_ptr_addr); =20 - set_solib_ops (gdbarch, &frv_so_ops); + set_gdbarch_so_ops (gdbarch, &frv_so_ops); =20 /* Hook in ABI-specific overrides, if they have been registered. */ gdbarch_init_osabi (info, gdbarch); diff --git a/gdb/gdbarch-components.py b/gdb/gdbarch-components.py index 71aa5991fbe..ad71bf754de 100644 --- a/gdb/gdbarch-components.py +++ b/gdb/gdbarch-components.py @@ -1262,6 +1262,14 @@ Function( invalid=3DFalse, ) =20 +Value( + comment=3D"Vtable of solib operations functions.", + type=3D"const struct target_so_ops *", + name=3D"so_ops", + postdefault=3D"&solib_target_so_ops", + printer=3D"host_address_to_string (gdbarch->so_ops)", +) + Method( comment=3D""" If in_solib_dynsym_resolve_code() returns true, and SKIP_SOLIB_RESOLVER diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h index 0504962e50d..c7a24704c7c 100644 --- a/gdb/gdbarch-gen.h +++ b/gdb/gdbarch-gen.h @@ -702,6 +702,11 @@ typedef CORE_ADDR (gdbarch_skip_trampoline_code_ftype)= (struct frame_info *frame extern CORE_ADDR gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, st= ruct frame_info *frame, CORE_ADDR pc); extern void set_gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, gdb= arch_skip_trampoline_code_ftype *skip_trampoline_code); =20 +/* Vtable of solib operations functions. */ + +extern const struct target_so_ops * gdbarch_so_ops (struct gdbarch *gdbarc= h); +extern void set_gdbarch_so_ops (struct gdbarch *gdbarch, const struct targ= et_so_ops * so_ops); + /* If in_solib_dynsym_resolve_code() returns true, and SKIP_SOLIB_RESOLVER evaluates non-zero, this is the address where the debugger will place a step-resume breakpoint to get us past the dynamic linker. */ diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 0edae7f6f0a..18d46a39d7a 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -153,6 +153,7 @@ struct gdbarch gdbarch_single_step_through_delay_ftype *single_step_through_delay =3D n= ullptr; gdbarch_print_insn_ftype *print_insn =3D nullptr; gdbarch_skip_trampoline_code_ftype *skip_trampoline_code =3D nullptr; + const struct target_so_ops * so_ops =3D 0; gdbarch_skip_solib_resolver_ftype *skip_solib_resolver =3D nullptr; gdbarch_in_solib_return_trampoline_ftype *in_solib_return_trampoline =3D= nullptr; gdbarch_in_indirect_branch_thunk_ftype *in_indirect_branch_thunk =3D nul= lptr; @@ -504,6 +505,8 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of single_step_through_delay, has predicate. */ /* Skip verify of print_insn, invalid_p =3D=3D 0 */ /* Skip verify of skip_trampoline_code, invalid_p =3D=3D 0 */ + if (gdbarch->so_ops =3D=3D 0) + gdbarch->so_ops =3D &solib_target_so_ops; /* Skip verify of skip_solib_resolver, invalid_p =3D=3D 0 */ /* Skip verify of in_solib_return_trampoline, invalid_p =3D=3D 0 */ /* Skip verify of in_indirect_branch_thunk, invalid_p =3D=3D 0 */ @@ -1012,6 +1015,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file= *file) gdb_printf (file, "gdbarch_dump: skip_trampoline_code =3D <%s>\n", host_address_to_string (gdbarch->skip_trampoline_cod= e)); + gdb_printf (file, + "gdbarch_dump: so_ops =3D %s\n", + host_address_to_string (gdbarch->so_ops)); gdb_printf (file, "gdbarch_dump: skip_solib_resolver =3D <%s>\n", host_address_to_string (gdbarch->skip_solib_resolver= )); @@ -3366,6 +3372,22 @@ set_gdbarch_skip_trampoline_code (struct gdbarch *gd= barch, gdbarch->skip_trampoline_code =3D skip_trampoline_code; } =20 +const struct target_so_ops * +gdbarch_so_ops (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch !=3D NULL); + if (gdbarch_debug >=3D 2) + gdb_printf (gdb_stdlog, "gdbarch_so_ops called\n"); + return gdbarch->so_ops; +} + +void +set_gdbarch_so_ops (struct gdbarch *gdbarch, + const struct target_so_ops * so_ops) +{ + gdbarch->so_ops =3D so_ops; +} + CORE_ADDR gdbarch_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc) { diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c index 2a9198aceb3..5e7929b2c99 100644 --- a/gdb/i386-darwin-tdep.c +++ b/gdb/i386-darwin-tdep.c @@ -271,7 +271,7 @@ i386_darwin_init_abi (struct gdbarch_info info, struct = gdbarch *gdbarch) alignment. */ set_gdbarch_long_double_bit (gdbarch, 128); =20 - set_solib_ops (gdbarch, &darwin_so_ops); + set_gdbarch_so_ops (gdbarch, &darwin_so_ops); } =20 static enum gdb_osabi diff --git a/gdb/i386-nto-tdep.c b/gdb/i386-nto-tdep.c index 259867f262b..69d298c871f 100644 --- a/gdb/i386-nto-tdep.c +++ b/gdb/i386-nto-tdep.c @@ -361,7 +361,7 @@ i386nto_init_abi (struct gdbarch_info info, struct gdba= rch *gdbarch) nto_svr4_so_ops.in_dynsym_resolve_code =3D nto_in_dynsym_resolve_code; } - set_solib_ops (gdbarch, &nto_svr4_so_ops); + set_gdbarch_so_ops (gdbarch, &nto_svr4_so_ops); =20 set_gdbarch_wchar_bit (gdbarch, 32); set_gdbarch_wchar_signed (gdbarch, 0); diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c index ca313a28279..7dae1ca34de 100644 --- a/gdb/mips-linux-tdep.c +++ b/gdb/mips-linux-tdep.c @@ -1594,7 +1594,7 @@ mips_linux_init_abi (struct gdbarch_info info, mips_svr4_so_ops.in_dynsym_resolve_code =3D mips_linux_in_dynsym_resolve_code; } - set_solib_ops (gdbarch, &mips_svr4_so_ops); + set_gdbarch_so_ops (gdbarch, &mips_svr4_so_ops); =20 set_gdbarch_write_pc (gdbarch, mips_linux_write_pc); =20 diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index beef4bd393c..ed154fd4a63 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -2126,7 +2126,7 @@ ppc_linux_init_abi (struct gdbarch_info info, powerpc_so_ops.in_dynsym_resolve_code =3D powerpc_linux_in_dynsym_resolve_code; } - set_solib_ops (gdbarch, &powerpc_so_ops); + set_gdbarch_so_ops (gdbarch, &powerpc_so_ops); =20 set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver); } diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c index 41384993c26..86270c81855 100644 --- a/gdb/rs6000-aix-tdep.c +++ b/gdb/rs6000-aix-tdep.c @@ -1180,7 +1180,7 @@ rs6000_aix_init_osabi (struct gdbarch_info info, stru= ct gdbarch *gdbarch) set_gdbarch_wchar_signed (gdbarch, 0); set_gdbarch_auto_wide_charset (gdbarch, rs6000_aix_auto_wide_charset); =20 - set_solib_ops (gdbarch, &solib_aix_so_ops); + set_gdbarch_so_ops (gdbarch, &solib_aix_so_ops); frame_unwind_append_unwinder (gdbarch, &aix_sighandle_frame_unwind); } =20 diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 95a1e1eb722..893da86e27e 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -3026,7 +3026,7 @@ set_solib_svr4_fetch_link_map_offsets (struct gdbarch= *gdbarch, =20 ops->fetch_link_map_offsets =3D flmo; =20 - set_solib_ops (gdbarch, &svr4_so_ops); + set_gdbarch_so_ops (gdbarch, &svr4_so_ops); set_gdbarch_iterate_over_objfiles_in_search_order (gdbarch, svr4_iterate_over_objfiles_in_search_order); } diff --git a/gdb/solib.c b/gdb/solib.c index 859d345f39c..7cfdd81114c 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -57,30 +57,6 @@ =20 /* Architecture-specific operations. */ =20 -/* Per-architecture data key. */ -static const registry::key> - solib_data; - -static const struct target_so_ops * -solib_ops (struct gdbarch *gdbarch) -{ - const struct target_so_ops *result =3D solib_data.get (gdbarch); - if (result =3D=3D nullptr) - { - result =3D &solib_target_so_ops; - set_solib_ops (gdbarch, &solib_target_so_ops); - } - return result; -} - -/* Set the solib operations for GDBARCH to NEW_OPS. */ - -void -set_solib_ops (struct gdbarch *gdbarch, const struct target_so_ops *new_op= s) -{ - solib_data.set (gdbarch, new_ops); -} =0C =20 /* external data declarations */ @@ -145,7 +121,7 @@ show_solib_search_path (struct ui_file *file, int from_= tty, static gdb::unique_xmalloc_ptr solib_find_1 (const char *in_pathname, int *fd, bool is_solib) { - const struct target_so_ops *ops =3D solib_ops (target_gdbarch ()); + const struct target_so_ops *ops =3D gdbarch_so_ops (target_gdbarch ()); int found_file =3D -1; gdb::unique_xmalloc_ptr temp_pathname; const char *fskind =3D effective_target_file_system_kind (); @@ -576,7 +552,7 @@ get_cbfd_soname_build_id (gdb_bfd_ref_ptr abfd, const c= har *soname) static int solib_map_sections (struct so_list *so) { - const struct target_so_ops *ops =3D solib_ops (target_gdbarch ()); + const struct target_so_ops *ops =3D gdbarch_so_ops (target_gdbarch ()); =20 gdb::unique_xmalloc_ptr filename (tilde_expand (so->so_name)); gdb_bfd_ref_ptr abfd (ops->bfd_open (filename.get ())); @@ -670,7 +646,7 @@ solib_map_sections (struct so_list *so) static void clear_so (struct so_list *so) { - const struct target_so_ops *ops =3D solib_ops (target_gdbarch ()); + const struct target_so_ops *ops =3D gdbarch_so_ops (target_gdbarch ()); =20 delete so->sections; so->sections =3D NULL; @@ -707,7 +683,7 @@ clear_so (struct so_list *so) void free_so (struct so_list *so) { - const struct target_so_ops *ops =3D solib_ops (target_gdbarch ()); + const struct target_so_ops *ops =3D gdbarch_so_ops (target_gdbarch ()); =20 clear_so (so); ops->free_so (so); @@ -793,7 +769,7 @@ solib_used (const struct so_list *const known) void update_solib_list (int from_tty) { - const struct target_so_ops *ops =3D solib_ops (target_gdbarch ()); + const struct target_so_ops *ops =3D gdbarch_so_ops (target_gdbarch ()); struct so_list *inferior =3D ops->current_sos(); struct so_list *gdb, **gdb_link; =20 @@ -1234,7 +1210,7 @@ solib_name_from_address (struct program_space *pspace= , CORE_ADDR address) bool solib_keep_data_in_core (CORE_ADDR vaddr, unsigned long size) { - const struct target_so_ops *ops =3D solib_ops (target_gdbarch ()); + const struct target_so_ops *ops =3D gdbarch_so_ops (target_gdbarch ()); =20 if (ops->keep_data_in_core) return ops->keep_data_in_core (vaddr, size) !=3D 0; @@ -1247,7 +1223,7 @@ solib_keep_data_in_core (CORE_ADDR vaddr, unsigned lo= ng size) void clear_solib (void) { - const struct target_so_ops *ops =3D solib_ops (target_gdbarch ()); + const struct target_so_ops *ops =3D gdbarch_so_ops (target_gdbarch ()); =20 disable_breakpoints_in_shlibs (); =20 @@ -1272,7 +1248,7 @@ clear_solib (void) void solib_create_inferior_hook (int from_tty) { - const struct target_so_ops *ops =3D solib_ops (target_gdbarch ()); + const struct target_so_ops *ops =3D gdbarch_so_ops (target_gdbarch ()); =20 ops->solib_create_inferior_hook (from_tty); } @@ -1282,7 +1258,7 @@ solib_create_inferior_hook (int from_tty) bool in_solib_dynsym_resolve_code (CORE_ADDR pc) { - const struct target_so_ops *ops =3D solib_ops (target_gdbarch ()); + const struct target_so_ops *ops =3D gdbarch_so_ops (target_gdbarch ()); =20 return ops->in_dynsym_resolve_code (pc) !=3D 0; } @@ -1318,7 +1294,7 @@ no_shared_libraries (const char *ignored, int from_tt= y) void update_solib_breakpoints (void) { - const struct target_so_ops *ops =3D solib_ops (target_gdbarch ()); + const struct target_so_ops *ops =3D gdbarch_so_ops (target_gdbarch ()); =20 if (ops->update_breakpoints !=3D NULL) ops->update_breakpoints (); @@ -1329,7 +1305,7 @@ update_solib_breakpoints (void) void handle_solib_event (void) { - const struct target_so_ops *ops =3D solib_ops (target_gdbarch ()); + const struct target_so_ops *ops =3D gdbarch_so_ops (target_gdbarch ()); =20 if (ops->handle_event !=3D NULL) ops->handle_event (); @@ -1417,7 +1393,7 @@ reload_shared_libraries (const char *ignored, int fro= m_tty, =20 reload_shared_libraries_1 (from_tty); =20 - ops =3D solib_ops (target_gdbarch ()); + ops =3D gdbarch_so_ops (target_gdbarch ()); =20 /* Creating inferior hooks here has two purposes. First, if we reload=20 shared libraries then the address of solib breakpoint we've computed diff --git a/gdb/solib.h b/gdb/solib.h index 251028472c0..a7e751ed9b3 100644 --- a/gdb/solib.h +++ b/gdb/solib.h @@ -71,11 +71,6 @@ extern bool in_solib_dynsym_resolve_code (CORE_ADDR); =20 extern void no_shared_libraries (const char *ignored, int from_tty); =20 -/* Set the solib operations for GDBARCH to NEW_OPS. */ - -extern void set_solib_ops (struct gdbarch *gdbarch, - const struct target_so_ops *new_ops); - /* Synchronize GDB's shared object list with inferior's. =20 Extract the list of currently loaded shared objects from the diff --git a/gdb/tic6x-linux-tdep.c b/gdb/tic6x-linux-tdep.c index b2422d1ccc0..b99cfc0d5e3 100644 --- a/gdb/tic6x-linux-tdep.c +++ b/gdb/tic6x-linux-tdep.c @@ -170,7 +170,7 @@ tic6x_uclinux_init_abi (struct gdbarch_info info, struc= t gdbarch *gdbarch) linux_init_abi (info, gdbarch, 0); =20 /* Shared library handling. */ - set_solib_ops (gdbarch, &dsbt_so_ops); + set_gdbarch_so_ops (gdbarch, &dsbt_so_ops); =20 tdep->syscall_next_pc =3D tic6x_linux_syscall_next_pc; =20 diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index 702af65d450..e5e37fcaa53 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -931,7 +931,7 @@ windows_init_abi_common (struct gdbarch_info info, stru= ct gdbarch *gdbarch) windows_so_ops =3D solib_target_so_ops; windows_so_ops.solib_create_inferior_hook =3D windows_solib_create_inferior_hook; - set_solib_ops (gdbarch, &windows_so_ops); + set_gdbarch_so_ops (gdbarch, &windows_so_ops); =20 set_gdbarch_get_siginfo_type (gdbarch, windows_get_siginfo_type); }