This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix alignment of disassemble /r
- From: Yao Qi <yao at codesourcery dot com>
- To: Daniel Gutson <daniel dot gutson at tallertechnologies dot com>, gdb-patches <gdb-patches at sourceware dot org>
- Date: Thu, 17 Apr 2014 09:07:25 +0800
- Subject: Re: [PATCH] Fix alignment of disassemble /r
- Authentication-results: sourceware.org; auth=none
- References: <CAF5HaEUBbK4d2reSxUpUQwp7Zt_KjcpNC_nbUrMHRb0yNo9wtw at mail dot gmail dot com>
On 04/12/2014 06:24 AM, Daniel Gutson wrote:
> when disassembling in raw mode (/r) in a variable-length insn
> architecture (i.e. x86),
> the output can be completely messed since no alignment takes place.
The /r output is messed, but not completely :).
>
> I am aware of the uiout->table stuff, but it seems an overkill since I
> should change
> the current_uiout when disassembling in this mode (and I didn't find
> any actual use of this
> machinery at least for x86).
> Therefore, I added a hack in the dump_insns when the /r flag is specified.
> This clearly isn't the cutiest thing in the world, and I specified a
> hardcoded maximum number
> of opcode bytes to align (currently 8) though it is easily changeable.
Hard-coded opcode length will affect other targets. For example, without
your patch, the disassembly for c6x is like,
(gdb) disassemble /r main
Dump of assembler code for function main:
0x00000860 <+0>: c2 1b be 07 subah .D2 b15,16,b15
0x00000864 <+4>: f6 02 3d 07 stw .D2T2 b14,*+b15(32)
with your patch applied, it becomes
(gdb) disassemble /r main
Dump of assembler code for function main:
0x00000860 <+0>: c2 1b be 07 subah .D2 b15,16,b15
0x00000864 <+4>: f6 02 3d 07 stw .D2T2 b14,*+b15(32)
gdbarch_max_insn_length can tell us the max instruction length, but if we
align the instruction to the max length (it is 16 on x86), the text
instruction will be far behind the hex code, which is a little ugly.
--
Yao (éå)