aboutsummaryrefslogtreecommitdiff
path: root/gdb/disasm.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2023-09-29 14:24:38 -0400
committerSimon Marchi <simon.marchi@efficios.com>2023-10-10 10:44:35 -0400
commit99d9c3b92ca96a7425cbb6b1bf453ede9477a2ee (patch)
tree7f642c989f7c7b49bd40ab5873fc12be632e6ea9 /gdb/disasm.c
parent72c4529c85907a5e1e04960ff1362a5a185553a0 (diff)
downloadbinutils-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/disasm.c')
-rw-r--r--gdb/disasm.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/gdb/disasm.c b/gdb/disasm.c
index aa5c6da..2e866f6 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -33,6 +33,7 @@
#include "valprint.h"
#include "cli/cli-style.h"
#include "objfiles.h"
+#include "inferior.h"
/* Disassemble functions.
FIXME: We should get rid of all the duplicate code in gdb that does
@@ -59,7 +60,8 @@ show_use_libopcodes_styling (struct ui_file *file, int from_tty,
struct cmd_list_element *c,
const char *value)
{
- gdb_non_printing_memory_disassembler dis (target_gdbarch ());
+ gdbarch *arch = current_inferior ()->arch ();
+ gdb_non_printing_memory_disassembler dis (arch);
bool supported = dis.disasm_info ()->created_styled_output;
if (supported || !use_libopcodes_styling)
@@ -71,7 +73,7 @@ show_use_libopcodes_styling (struct ui_file *file, int from_tty,
turned on! */
gdb_printf (file, _("Use of libopcodes styling support is \"off\""
" (not supported on architecture \"%s\")\n"),
- gdbarch_bfd_arch_info (target_gdbarch ())->printable_name);
+ gdbarch_bfd_arch_info (arch)->printable_name);
}
}
@@ -81,7 +83,8 @@ static void
set_use_libopcodes_styling (const char *args, int from_tty,
struct cmd_list_element *c)
{
- gdb_non_printing_memory_disassembler dis (target_gdbarch ());
+ gdbarch *arch = current_inferior ()->arch ();
+ gdb_non_printing_memory_disassembler dis (arch);
bool supported = dis.disasm_info ()->created_styled_output;
/* If the current architecture doesn't support libopcodes styling then we
@@ -93,7 +96,7 @@ set_use_libopcodes_styling (const char *args, int from_tty,
{
use_libopcodes_styling_option = use_libopcodes_styling;
error (_("Use of libopcodes styling not supported on architecture \"%s\"."),
- gdbarch_bfd_arch_info (target_gdbarch ())->printable_name);
+ gdbarch_bfd_arch_info (arch)->printable_name);
}
else
use_libopcodes_styling = use_libopcodes_styling_option;