* [PATCH] Multi-arch i386 instruction printing
@ 2002-09-15 7:02 Mark Kettenis
2002-09-16 8:26 ` Michal Ludvig
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mark Kettenis @ 2002-09-15 7:02 UTC (permalink / raw)
To: gdb-patches
This patch multi-arch's i386 instruction printing. In doing so I took
a somewhat different approach than what's done for other targets, by
always overriding the disassemble_info fields that the i386
instruction printer cares about.
Seems to work fine, and should also be able to handle x86_64.
Checked in.
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* i386-tdep.c (gdb_print_insn_i386): Removed.
(i386_print_insn): New function.
(i386_gdbarch_init): Set print_insn to i386_print_insns.
(_initialize_i386_tdep): Don't initialize tm_print_insn and
tm_print_insn_info.
Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.86
diff -u -p -r1.86 i386-tdep.c
--- i386-tdep.c 6 Sep 2002 21:28:18 -0000 1.86
+++ i386-tdep.c 15 Sep 2002 13:47:53 -0000
@@ -1288,15 +1288,17 @@ i386_pc_in_sigtramp (CORE_ADDR pc, char
deals with switching between those. */
static int
-gdb_print_insn_i386 (bfd_vma memaddr, disassemble_info *info)
+i386_print_insn (bfd_vma pc, disassemble_info *info)
{
- if (disassembly_flavor == att_flavor)
- return print_insn_i386_att (memaddr, info);
- else if (disassembly_flavor == intel_flavor)
- return print_insn_i386_intel (memaddr, info);
- /* Never reached -- disassembly_flavour is always either att_flavor
- or intel_flavor. */
- internal_error (__FILE__, __LINE__, "failed internal consistency check");
+ gdb_assert (disassembly_flavor == att_flavor
+ || disassembly_flavor == intel_flavor);
+
+ /* FIXME: kettenis/20020915: Until disassembler_options is properly
+ constified, cast to prevent a compiler warning. */
+ info->disassembler_options = (char *) disassembly_flavor;
+ info->mach = gdbarch_bfd_arch_info (current_gdbarch)->mach;
+
+ return print_insn_i386 (pc, info);
}
\f
@@ -1569,6 +1571,8 @@ i386_gdbarch_init (struct gdbarch_info i
set_gdbarch_pseudo_register_read (gdbarch, i386_pseudo_register_read);
set_gdbarch_pseudo_register_write (gdbarch, i386_pseudo_register_write);
+ set_gdbarch_print_insn (gdbarch, i386_print_insn);
+
/* Hook in ABI-specific overrides, if they have been registered. */
gdbarch_init_osabi (info, gdbarch, osabi);
@@ -1600,9 +1604,6 @@ _initialize_i386_tdep (void)
{
register_gdbarch_init (bfd_arch_i386, i386_gdbarch_init);
- tm_print_insn = gdb_print_insn_i386;
- tm_print_insn_info.mach = bfd_lookup_arch (bfd_arch_i386, 0)->mach;
-
/* Add the variable that controls the disassembly flavor. */
{
struct cmd_list_element *new_cmd;
@@ -1623,7 +1624,7 @@ and the default value is \"att\".",
struct cmd_list_element *new_cmd;
new_cmd = add_set_enum_cmd ("struct-convention", no_class,
- valid_conventions,
+ valid_conventions,
&struct_convention, "\
Set the convention for returning small structs, valid values \
are \"default\", \"pcc\" and \"reg\", and the default value is \"default\".",
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Multi-arch i386 instruction printing
2002-09-15 7:02 [PATCH] Multi-arch i386 instruction printing Mark Kettenis
@ 2002-09-16 8:26 ` Michal Ludvig
2002-09-16 22:31 ` Andrew Cagney
2002-09-18 1:12 ` Michal Ludvig
2 siblings, 0 replies; 4+ messages in thread
From: Michal Ludvig @ 2002-09-16 8:26 UTC (permalink / raw)
To: Mark Kettenis; +Cc: GDB Patches
[-- Attachment #1: Type: text/plain, Size: 537 bytes --]
Mark Kettenis wrote:
> This patch multi-arch's i386 instruction printing. In doing so I took
> a somewhat different approach than what's done for other targets, by
> always overriding the disassemble_info fields that the i386
> instruction printer cares about.
>
> Seems to work fine, and should also be able to handle x86_64.
Here's the same for x86-64 - just for easier merge when you'll do the
multiarch gdb ;-)
Can I commit it?
Michal Ludvig
--
* SuSE CR, s.r.o * mludvig@suse.cz
* +420 2 9654 5373 * http://www.suse.cz
[-- Attachment #2: x86_64_print_insn.diff --]
[-- Type: text/plain, Size: 2111 bytes --]
2002-09-16 Michal Ludvig <mludvig@suse.cz>
* x86-64-tdep.c (gdb_print_insn_x86_64): Removed.
(86_64_print_insn): Added.
(x86_64_gdbarch_init): Set print_insn to i386_print_insns.
(_initialize_x86_64_tdep): Don't initialize tm_print_insn and
tm_print_insn_info.
Index: x86-64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-tdep.c,v
retrieving revision 1.27
diff -u -p -r1.27 x86-64-tdep.c
--- x86-64-tdep.c 12 Sep 2002 08:39:26 -0000 1.27
+++ x86-64-tdep.c 16 Sep 2002 15:19:22 -0000
@@ -820,19 +820,14 @@ x86_64_register_number (const char *name
\f
-/* We have two flavours of disassembly. The machinery on this page
- deals with switching between those. */
-
+/* This is the same as i386_print_insn(). */
static int
-gdb_print_insn_x86_64 (bfd_vma memaddr, disassemble_info * info)
+x86_64_print_insn (bfd_vma pc, disassemble_info *info)
{
- if (disassembly_flavour == att_flavour)
- return print_insn_i386_att (memaddr, info);
- else if (disassembly_flavour == intel_flavour)
- return print_insn_i386_intel (memaddr, info);
- /* Never reached -- disassembly_flavour is always either att_flavour
- or intel_flavour. */
- internal_error (__FILE__, __LINE__, "failed internal consistency check");
+ info->disassembler_options = (char *) disassembly_flavour;
+ info->mach = gdbarch_bfd_arch_info (current_gdbarch)->mach;
+
+ return print_insn_i386 (pc, info);
}
\f
@@ -1021,6 +1016,8 @@ x86_64_gdbarch_init (struct gdbarch_info
set_gdbarch_read_fp (gdbarch, cfi_read_fp);
+ set_gdbarch_print_insn (gdbarch, x86_64_print_insn);
+
/* Discard from the stack the innermost frame, restoring all registers. */
set_gdbarch_pop_frame (gdbarch, x86_64_pop_frame);
@@ -1142,9 +1139,6 @@ _initialize_x86_64_tdep (void)
offset += x86_64_register_info_table[i].size;
}
}
-
- tm_print_insn = gdb_print_insn_x86_64;
- tm_print_insn_info.mach = bfd_mach_x86_64;
/* Add the variable that controls the disassembly flavour. */
{
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Multi-arch i386 instruction printing
2002-09-15 7:02 [PATCH] Multi-arch i386 instruction printing Mark Kettenis
2002-09-16 8:26 ` Michal Ludvig
@ 2002-09-16 22:31 ` Andrew Cagney
2002-09-18 1:12 ` Michal Ludvig
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Cagney @ 2002-09-16 22:31 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
> + gdb_assert (disassembly_flavor == att_flavor
> + || disassembly_flavor == intel_flavor);
> +
> + /* FIXME: kettenis/20020915: Until disassembler_options is properly
> + constified, cast to prevent a compiler warning. */
> + info->disassembler_options = (char *) disassembly_flavor;
> + info->mach = gdbarch_bfd_arch_info (current_gdbarch)->mach;
Just create a ``change-request'' bug report. Something else I get to
persue with the binutils folks (unless you want the task :-).
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Multi-arch i386 instruction printing
2002-09-15 7:02 [PATCH] Multi-arch i386 instruction printing Mark Kettenis
2002-09-16 8:26 ` Michal Ludvig
2002-09-16 22:31 ` Andrew Cagney
@ 2002-09-18 1:12 ` Michal Ludvig
2 siblings, 0 replies; 4+ messages in thread
From: Michal Ludvig @ 2002-09-18 1:12 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
Mark Kettenis wrote:
> This patch multi-arch's i386 instruction printing. In doing so I took
> a somewhat different approach than what's done for other targets, by
> always overriding the disassemble_info fields that the i386
> instruction printer cares about.
>
> Seems to work fine, and should also be able to handle x86_64.
I propose once again an introdction of i386-common.[ch] (as I already
did in eflags register printing thread).
IMHO i386_print_insn() is a perfect candidate to go there, while it's
the same on all i386-platforms as well as on x86-64 arch. I believe that
more functions finally could go there. What do you think about it?
Michal Ludvig
--
* SuSE CR, s.r.o * mludvig@suse.cz
* +420 2 9654 5373 * http://www.suse.cz
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-09-18 8:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-15 7:02 [PATCH] Multi-arch i386 instruction printing Mark Kettenis
2002-09-16 8:26 ` Michal Ludvig
2002-09-16 22:31 ` Andrew Cagney
2002-09-18 1:12 ` Michal Ludvig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox