Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@mips.com>
To: Daniel Jacobowitz <drow@false.org>
Cc: gdb-patches@sourceware.org, insight@sourceware.org,
	     Nigel Stephens <nigel@mips.com>,
	     "Maciej W. Rozycki" <macro@linux-mips.org>
Subject: Re: Disassemble branch delay slot instructions automatically
Date: Wed, 20 Jun 2007 13:56:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.61.0706151547560.30938@perivale.mips.com> (raw)
In-Reply-To: <20070613165622.GA1023@caradoc.them.org>

On Wed, 13 Jun 2007, Daniel Jacobowitz wrote:

> I think the patch is pretty much OK, except for the use of
> TARGET_PRINT_INSN.  We're trying to eliminate the gdbarch macros now.
> I think the best solution would be to add the extra argument to
> gdb_print_insn; it's only used here and in the TUI.

 And also in Insight; I have updated that too.  I suppose the plan is to 
substitute TARGET_PRINT_INSN with gdbarch_print_insn(), but that should be 
done separately, so that it is not mixed with functional changes.

> Why did you need the new function that modified an existing
> disassemble_info, instead of using the existing one?

 Well, I guess Nigel could answer this question, and my feeling is it is 
not a particularly useful complication, but it is not relevant anymore.

> This probably deserves a NEWS entry.

 Done.

 Here is my new version, which has been tested natively for 
mips-unknown-linux-gnu and remotely for mipsisa32-sde-elf, using 
mips-sim-sde32/-EB, mips-sim-sde32/-mips16/-EB, mips-sim-sde32/-EL and 
mips-sim-sde32/-mips16/-EL as the targets, with no regressions.

gdb/:
2007-06-20  Nigel Stephens  <nigel@mips.com>
            Maciej W. Rozycki  <macro@mips.com>

	* 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  <macro@mips.com>

	* generic/gdbtk-cmds.c (gdbtk_load_asm): Update the call to
	gdb_print_insn().

 OK to apply?

  Maciej

12235.diff
Index: binutils-quilt/src/gdb/printcmd.c
===================================================================
--- binutils-quilt.orig/src/gdb/printcmd.c	2007-06-19 14:49:26.000000000 +0100
+++ binutils-quilt/src/gdb/printcmd.c	2007-06-19 14:53:12.000000000 +0100
@@ -43,6 +43,7 @@
 #include "gdb_assert.h"
 #include "block.h"
 #include "disasm.h"
+#include "dis-asm.h"
 
 #ifdef TUI
 #include "tui/tui.h"		/* For tui_active et.al.   */
@@ -70,6 +71,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 +282,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 +806,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-19 14:49:26.000000000 +0100
+++ binutils-quilt/src/gdb/disasm.c	2007-06-19 14:53:12.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 TARGET_PRINT_INSN (memaddr, &di);
+  struct disassemble_info di;
+  int length;
+
+  di = gdb_disassemble_info (current_gdbarch, stream);
+  length = TARGET_PRINT_INSN (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-19 14:49:26.000000000 +0100
+++ binutils-quilt/src/gdb/disasm.h	2007-06-19 14:53:12.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-19 14:49:26.000000000 +0100
+++ binutils-quilt/src/gdb/tui/tui-disasm.c	2007-06-19 14:53:12.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-19 14:49:26.000000000 +0100
+++ binutils-quilt/src/gdb/gdbtk/generic/gdbtk-cmds.c	2007-06-19 14:53:44.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-19 12:24:32.000000000 +0100
+++ binutils-quilt/src/gdb/NEWS	2007-06-19 15:16:19.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


  reply	other threads:[~2007-06-20 13:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-15 18:13 Maciej W. Rozycki
2007-05-16 15:32 ` Daniel Jacobowitz
2007-05-18 15:47   ` Maciej W. Rozycki
2007-06-13 16:56     ` Daniel Jacobowitz
2007-06-20 13:56       ` Maciej W. Rozycki [this message]
2007-06-20 14:09         ` Daniel Jacobowitz
2007-06-20 15:25           ` Maciej W. Rozycki
2007-06-20 18:37         ` Eli Zaretskii
2007-06-21 15:19           ` Maciej W. Rozycki
2007-06-21 19:01             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.61.0706151547560.30938@perivale.mips.com \
    --to=macro@mips.com \
    --cc=drow@false.org \
    --cc=gdb-patches@sourceware.org \
    --cc=insight@sourceware.org \
    --cc=macro@linux-mips.org \
    --cc=nigel@mips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox