From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13974 invoked by alias); 20 Jun 2007 15:25:28 -0000 Received: (qmail 13904 invoked by uid 22791); 20 Jun 2007 15:25:26 -0000 X-Spam-Check-By: sourceware.org Received: from dmz.mips-uk.com (HELO dmz.mips-uk.com) (194.74.144.194) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 20 Jun 2007 15:25:21 +0000 Received: from internal-mx1 ([192.168.192.240] helo=ukservices1.mips.com) by dmz.mips-uk.com with esmtp (Exim 3.35 #1 (Debian)) id 1I123Z-00079P-00; Wed, 20 Jun 2007 16:25:17 +0100 Received: from perivale.mips.com ([192.168.192.200]) by ukservices1.mips.com with esmtp (Exim 3.36 #1 (Debian)) id 1I123S-0002rB-00; Wed, 20 Jun 2007 16:25:10 +0100 Received: from macro (helo=localhost) by perivale.mips.com with local-esmtp (Exim 4.63) (envelope-from ) id 1I123S-0006jr-19; Wed, 20 Jun 2007 16:25:10 +0100 Date: Wed, 20 Jun 2007 15:25:00 -0000 From: "Maciej W. Rozycki" To: Daniel Jacobowitz cc: gdb-patches@sourceware.org, insight@sourceware.org, Nigel Stephens , "Maciej W. Rozycki" , Eli Zaretskii Subject: Re: Disassemble branch delay slot instructions automatically In-Reply-To: <20070620140925.GA29461@caradoc.them.org> Message-ID: References: <20070516153242.GA8062@caradoc.them.org> <20070613165622.GA1023@caradoc.them.org> <20070620140925.GA29461@caradoc.them.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MIPS-Technologies-UK-MailScanner: Found to be clean X-MIPS-Technologies-UK-MailScanner-From: macro@mips.com Mailing-List: contact insight-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: insight-owner@sourceware.org X-SW-Source: 2007-q2/txt/msg00081.txt.bz2 On Wed, 20 Jun 2007, Daniel Jacobowitz wrote: > In fact, it happened yesterday. Well, it seems to be always the case that something changes under your feet during a test cycle. ;-) > So I imagine you need to refresh this patch. I was actually > suggesting you add the disassemble_info argument to gdb_print_insn, > not the number of delay slots; but this way seems fine too. I have thought of it at once, but then concluded copying the whole structure again for its just one member would not make much sense and would effectively make gdb_print_insn() of questionable use -- the three callers could use an explicit sequence of gdb_disassemble_info(); gdbarch_print_insn() instead. > This version is OK, if Eli likes the NEWS entry and you add a > Makefile.in update (since you added #include's). Eli, is the below > OK? Sigh... -- I always seem to forget about this bit (even though it has bitten me a couple of times already). But wait! -- it is actually not needed anymore now that "struct disassemble_info" is not used here. For the record -- here's my current version that I am going to commit except for possible NEWS entry adjustments. gdb/: 2007-06-20 Nigel Stephens Maciej W. Rozycki * disasm.c (gdb_print_insn): Return the number of branch delay slot instructions too. * disasm.h (gdb_print_insn): Update prototype. * printcmd.c (branch_delay_insns): New variable to record the number of delay slot instructions after disassembling a branch. (print_formatted): Record the number of branch delay slot instructions. (do_examine): When disassembling, if the last instruction disassembled has any branch delay slots, then bump the count so that they get disassembled too. * tui/tui-disasm.c (tui_disassemble): Update the call to gdb_print_insn(). * NEWS: Document the new behaviour. gdb/gdbtk/: 2007-06-20 Maciej W. Rozycki * generic/gdbtk-cmds.c (gdbtk_load_asm): Update the call to gdb_print_insn(). Maciej 12235.diff Index: binutils-quilt/src/gdb/printcmd.c =================================================================== --- binutils-quilt.orig/src/gdb/printcmd.c 2007-06-20 15:03:30.000000000 +0100 +++ binutils-quilt/src/gdb/printcmd.c 2007-06-20 15:45:33.000000000 +0100 @@ -70,6 +70,10 @@ static CORE_ADDR next_address; +/* Number of delay instructions following current disassembled insn. */ + +static int branch_delay_insns; + /* Last address examined. */ static CORE_ADDR last_examine_address; @@ -277,8 +281,9 @@ /* We often wrap here if there are long symbolic names. */ wrap_here (" "); - next_address = VALUE_ADDRESS (val) - + gdb_print_insn (VALUE_ADDRESS (val), stream); + next_address = (VALUE_ADDRESS (val) + + gdb_print_insn (VALUE_ADDRESS (val), stream, + &branch_delay_insns)); break; default: @@ -800,6 +805,10 @@ release_value (last_examine_value); print_formatted (last_examine_value, format, size, gdb_stdout); + + /* Display any branch delay slots following the final insn. */ + if (format == 'i' && count == 1) + count += branch_delay_insns; } printf_filtered ("\n"); gdb_flush (gdb_stdout); Index: binutils-quilt/src/gdb/disasm.c =================================================================== --- binutils-quilt.orig/src/gdb/disasm.c 2007-06-20 15:03:30.000000000 +0100 +++ binutils-quilt/src/gdb/disasm.c 2007-06-20 15:42:24.000000000 +0100 @@ -387,11 +387,24 @@ } /* Print the instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ + on STREAM. Returns the length of the instruction, in bytes, + and, if requested, the number of branch delay slot instructions. */ int -gdb_print_insn (CORE_ADDR memaddr, struct ui_file *stream) +gdb_print_insn (CORE_ADDR memaddr, struct ui_file *stream, + int *branch_delay_insns) { - struct disassemble_info di = gdb_disassemble_info (current_gdbarch, stream); - return gdbarch_print_insn (current_gdbarch, memaddr, &di); + struct disassemble_info di; + int length; + + di = gdb_disassemble_info (current_gdbarch, stream); + length = gdbarch_print_insn (current_gdbarch, memaddr, &di); + if (branch_delay_insns) + { + if (di.insn_info_valid) + *branch_delay_insns = di.branch_delay_insns; + else + *branch_delay_insns = 0; + } + return length; } Index: binutils-quilt/src/gdb/disasm.h =================================================================== --- binutils-quilt.orig/src/gdb/disasm.h 2007-06-20 15:03:30.000000000 +0100 +++ binutils-quilt/src/gdb/disasm.h 2007-06-20 15:42:24.000000000 +0100 @@ -30,9 +30,12 @@ int mixed_source_and_assembly, int how_many, CORE_ADDR low, CORE_ADDR high); -/* Print the instruction at address MEMADDR in debugged memory, on - STREAM. Returns length of the instruction, in bytes. */ +/* Print the instruction at address MEMADDR in debugged memory, + on STREAM. Returns the length of the instruction, in bytes, + and, if requested, the number of branch delay slot instructions. */ -extern int gdb_print_insn (CORE_ADDR memaddr, struct ui_file *stream); +extern int gdb_print_insn (CORE_ADDR memaddr, + struct ui_file *stream, + int *branch_delay_insns); #endif Index: binutils-quilt/src/gdb/tui/tui-disasm.c =================================================================== --- binutils-quilt.orig/src/gdb/tui/tui-disasm.c 2007-06-20 15:03:30.000000000 +0100 +++ binutils-quilt/src/gdb/tui/tui-disasm.c 2007-06-20 15:42:24.000000000 +0100 @@ -72,7 +72,7 @@ ui_file_rewind (gdb_dis_out); - pc = pc + gdb_print_insn (pc, gdb_dis_out); + pc = pc + gdb_print_insn (pc, gdb_dis_out, NULL); asm_lines->insn = xstrdup (tui_file_get_strbuf (gdb_dis_out)); Index: binutils-quilt/src/gdb/gdbtk/generic/gdbtk-cmds.c =================================================================== --- binutils-quilt.orig/src/gdb/gdbtk/generic/gdbtk-cmds.c 2007-06-20 15:03:30.000000000 +0100 +++ binutils-quilt/src/gdb/gdbtk/generic/gdbtk-cmds.c 2007-06-20 15:42:24.000000000 +0100 @@ -1895,7 +1895,7 @@ result_ptr->obj_ptr = client_data->result_obj[2]; /* FIXME: cagney/2003-09-08: This should use gdb_disassembly. */ - insn = gdb_print_insn (pc, gdb_stdout); + insn = gdb_print_insn (pc, gdb_stdout, NULL); gdb_flush (gdb_stdout); client_data->widget_line_no++; Index: binutils-quilt/src/gdb/NEWS =================================================================== --- binutils-quilt.orig/src/gdb/NEWS 2007-06-20 15:03:30.000000000 +0100 +++ binutils-quilt/src/gdb/NEWS 2007-06-20 15:42:24.000000000 +0100 @@ -41,6 +41,9 @@ layout. It also supports a TextSeg= and DataSeg= response when only segment base addresses (rather than offsets) are available. +* The /i format now outputs any trailing branch delay slot instructions +immediately following the last instruction within the count specified. + * New commands set remoteflow