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>
This commit is contained in:
Simon Marchi
2023-09-29 14:24:38 -04:00
parent 72c4529c85
commit 99d9c3b92c
93 changed files with 579 additions and 504 deletions

View File

@@ -1183,12 +1183,13 @@ show_mask_address (struct ui_file *file, int from_tty,
const char *additional_text = "";
if (mask_address_var == AUTO_BOOLEAN_AUTO)
{
if (gdbarch_bfd_arch_info (target_gdbarch ())->arch != bfd_arch_mips)
if (gdbarch_bfd_arch_info (current_inferior ()->arch ())->arch
!= bfd_arch_mips)
additional_text = _(" (current architecture is not MIPS)");
else
{
mips_gdbarch_tdep *tdep
= gdbarch_tdep<mips_gdbarch_tdep> (target_gdbarch ());
= gdbarch_tdep<mips_gdbarch_tdep> (current_inferior ()->arch ());
if (mips_mask_address_p (tdep))
additional_text = _(" (currently \"on\")");
@@ -6926,7 +6927,8 @@ show_mipsfpu_command (const char *args, int from_tty)
{
const char *fpu;
if (gdbarch_bfd_arch_info (target_gdbarch ())->arch != bfd_arch_mips)
if (gdbarch_bfd_arch_info (current_inferior ()->arch ())->arch
!= bfd_arch_mips)
{
gdb_printf
("The MIPS floating-point coprocessor is unknown "
@@ -6934,7 +6936,7 @@ show_mipsfpu_command (const char *args, int from_tty)
return;
}
switch (mips_get_fpu_type (target_gdbarch ()))
switch (mips_get_fpu_type (current_inferior ()->arch ()))
{
case MIPS_FPU_SINGLE:
fpu = "single-precision";
@@ -8850,7 +8852,8 @@ show_mips_abi (struct ui_file *file,
struct cmd_list_element *ignored_cmd,
const char *ignored_value)
{
if (gdbarch_bfd_arch_info (target_gdbarch ())->arch != bfd_arch_mips)
if (gdbarch_bfd_arch_info (current_inferior ()->arch ())->arch
!= bfd_arch_mips)
gdb_printf
(file,
"The MIPS ABI is unknown because the current architecture "
@@ -8858,7 +8861,7 @@ show_mips_abi (struct ui_file *file,
else
{
enum mips_abi global_abi = global_mips_abi ();
enum mips_abi actual_abi = mips_abi (target_gdbarch ());
enum mips_abi actual_abi = mips_abi (current_inferior ()->arch ());
const char *actual_abi_str = mips_abi_strings[actual_abi];
if (global_abi == MIPS_ABI_UNKNOWN)