diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2023-09-29 14:24:38 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2023-10-10 10:44:35 -0400 |
commit | 99d9c3b92ca96a7425cbb6b1bf453ede9477a2ee (patch) | |
tree | 7f642c989f7c7b49bd40ab5873fc12be632e6ea9 /gdb/procfs.c | |
parent | 72c4529c85907a5e1e04960ff1362a5a185553a0 (diff) | |
download | binutils-99d9c3b92ca96a7425cbb6b1bf453ede9477a2ee.zip binutils-99d9c3b92ca96a7425cbb6b1bf453ede9477a2ee.tar.gz binutils-99d9c3b92ca96a7425cbb6b1bf453ede9477a2ee.tar.bz2 |
gdb: remove target_gdbarch
This function is just a wrapper around the current inferior's gdbarch.
I find that having that wrapper just obscures where the arch is coming
from, and that it's often used as "I don't know which arch to use so
I'll use this magical target_gdbarch function that gets me an arch" when
the arch should in fact come from something in the context (a thread,
objfile, symbol, etc). I think that removing it and inlining
`current_inferior ()->arch ()` everywhere will make it a bit clearer
where that arch comes from and will trigger people into reflecting
whether this is the right place to get the arch or not.
Change-Id: I79f14b4e4934c88f91ca3a3155f5fc3ea2fadf6b
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
Diffstat (limited to 'gdb/procfs.c')
-rw-r--r-- | gdb/procfs.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/gdb/procfs.c b/gdb/procfs.c index 48e9f3d..0e8a08f 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -174,7 +174,7 @@ procfs_target::auxv_parse (const gdb_byte **readptr, const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) { - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); const gdb_byte *ptr = *readptr; if (endptr == ptr) @@ -711,9 +711,10 @@ proc_watchpoint_address (procinfo *pi, CORE_ADDR *addr) if (!proc_get_status (pi)) return 0; - *addr = (CORE_ADDR) gdbarch_pointer_to_address (target_gdbarch (), - builtin_type (target_gdbarch ())->builtin_data_ptr, - (gdb_byte *) &pi->prstatus.pr_lwp.pr_info.si_addr); + gdbarch *arch = current_inferior ()->arch (); + *addr = gdbarch_pointer_to_address + (arch, builtin_type (arch)->builtin_data_ptr, + (gdb_byte *) &pi->prstatus.pr_lwp.pr_info.si_addr); return 1; } @@ -1517,12 +1518,12 @@ proc_parent_pid (procinfo *pi) static void * procfs_address_to_host_pointer (CORE_ADDR addr) { - struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; + gdbarch *arch = current_inferior ()->arch (); + type *ptr_type = builtin_type (arch)->builtin_data_ptr; void *ptr; gdb_assert (sizeof (ptr) == ptr_type->length ()); - gdbarch_address_to_pointer (target_gdbarch (), ptr_type, - (gdb_byte *) &ptr, addr); + gdbarch_address_to_pointer (arch, ptr_type, (gdb_byte *) &ptr, addr); return ptr; } @@ -3013,7 +3014,8 @@ procfs_target::can_use_hw_breakpoint (enum bptype type, int cnt, int othertype) procfs_address_to_host_pointer will reveal that an internal error will be generated when the host and target pointer sizes are different. */ - struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; + type *ptr_type + = builtin_type (current_inferior ()->arch ())->builtin_data_ptr; if (sizeof (void *) != ptr_type->length ()) return 0; @@ -3061,7 +3063,7 @@ procfs_target::insert_watchpoint (CORE_ADDR addr, int len, struct expression *cond) { if (!target_have_steppable_watchpoint () - && !gdbarch_have_nonsteppable_watchpoint (target_gdbarch ())) + && !gdbarch_have_nonsteppable_watchpoint (current_inferior ()->arch ())) /* When a hardware watchpoint fires off the PC will be left at the instruction following the one which caused the watchpoint. It will *NOT* be necessary for GDB to step over @@ -3224,7 +3226,7 @@ info_mappings_callback (struct prmap *map, find_memory_region_ftype ignore, pr_off = (unsigned int) map->pr_offset; - if (gdbarch_addr_bit (target_gdbarch ()) == 32) + if (gdbarch_addr_bit (current_inferior ()->arch ()) == 32) gdb_printf ("\t%#10lx %#10lx %#10lx %#10x %7s\n", (unsigned long) map->pr_vaddr, (unsigned long) map->pr_vaddr + map->pr_size - 1, @@ -3251,7 +3253,7 @@ info_proc_mappings (procinfo *pi, int summary) return; /* No output for summary mode. */ gdb_printf (_("Mapped address spaces:\n\n")); - if (gdbarch_ptr_bit (target_gdbarch ()) == 32) + if (gdbarch_ptr_bit (current_inferior ()->arch ()) == 32) gdb_printf ("\t%10s %10s %10s %10s %7s\n", "Start Addr", " End Addr", |