🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #8853

Patch to disassemble argument of `break' instruction on MIPS

#8853
From: Jonathan Stone
Date: Sun, 20 Sep 1992 23:59
77 lines
3506 bytes
GDB doesn't understand that the BREAK instruction of the mips R2000 family
takes an argument. (see Kane, p. A-25) This patch changes GDB's disassembly
of Mips instructions to show that argument.  Those who write either their own
operating systems or handlers for breakpoint exceptions on MIPS chips, and
also use GDB, may find this patch useful.

*** gdb/mips-pinsn.c	Fri Jun 12 23:08:01 1992
--- dec-mips-ultrix/gdb/mips-pinsn.c	Sun Sep 20 15:09:32 1992
***************
*** 79,84 ****
--- 79,88 ----
        fprintf (stream, "0x%x", ((struct op_r_fmt *) l)->shamt);
        break;
  
+     case 'B':
+       fprintf (stream, "0x%x", ((struct op_brk_fmt *) l)->code);
+       break;
+ 
      case 'S':
        fprintf (stream, "$f%d", ((struct fop_r_fmt *) l)->fs);
        break;
*** include/opcode/mips.h	Thu Jun 11 12:18:55 1992
--- dec-mips-ultrix/gdb/opcode/mips.h	Sun Sep 20 16:44:08 1992
***************
*** 80,85 ****
--- 80,98 ----
    short delta : 16)
  };
  
+ struct op_brk_fmt
+ {
+   BIT_FIELDS_4(
+   unsigned op: 6,
+   unsigned code: 10,
+  /* Kane states the breakpoint-code code
+   *  field in BREAK is 20 bits.   Yet MIPS 
+   * assemblers and debuggers only use ten bits.
+   */
+   unsigned illdefined: 10,
+   unsigned spec: 6)
+ };
+ 
  struct fop_r_fmt
  {
  BIT_FIELDS_6(
***************
*** 106,115 ****
--- 119,130 ----
     "t" rt: target register
     "i" immediate
     "a" target address
+    "b" branch target address
     "c" branch condition
     "d" rd: destination register specifier
     "h" shamt: shift amount
     "f" funct: function field
+    "B" breakpoint code
  
    for fpu
     "S" fs source 1 register
***************
*** 145,151 ****
    {"jr",	op_func(0, 8),	op_func(0x3f, 0x1fffff),	"s", 1},
    {"jalr",	op_func(0, 9),	op_func(0x3f, 0x1f07ff),	"d,s", 1},
    {"syscall",	op_func(0, 12),	op_func(0x3f, 0x3f),		"", 0},
!   {"break",	op_func(0, 13),	op_func(0x3f, 0x3f),		"", 0},
    {"mfhi",      op_func(0, 16), op_func(0x3f, 0x03ff07ff),      "d", 0},
    {"mthi",      op_func(0, 17), op_func(0x3f, 0x1fffff),        "s", 0},
    {"mflo",      op_func(0, 18), op_func(0x3f, 0x03ff07ff),      "d", 0},
--- 160,166 ----
    {"jr",	op_func(0, 8),	op_func(0x3f, 0x1fffff),	"s", 1},
    {"jalr",	op_func(0, 9),	op_func(0x3f, 0x1f07ff),	"d,s", 1},
    {"syscall",	op_func(0, 12),	op_func(0x3f, 0x3f),		"", 0},
!   {"break",	op_func(0, 13),	op_func(0x3f, 0x3f),		"B", 0},
    {"mfhi",      op_func(0, 16), op_func(0x3f, 0x03ff07ff),      "d", 0},
    {"mthi",      op_func(0, 17), op_func(0x3f, 0x1fffff),        "s", 0},
    {"mflo",      op_func(0, 18), op_func(0x3f, 0x03ff07ff),      "d", 0},
Technical Details
Message-ID: <1992Sep20.235919.13278@CSD-NewsHost.Stanford.EDU>
Path: arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cs.stanford.edu!jonathan

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5053,5246e07ae1d54ead,start
X-Google-Attributes: gidf5053,public
X-Google-ArrivalTime: 1992-09-21 14:43:34 PST
Newsgroups: gnu.gdb.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cs.stanford.edu!jonathan
From: jonathan@cs.stanford.edu (Jonathan Stone)
Subject: Patch to disassemble argument  of `break' instruction  on MIPS
Message-ID: <1992Sep20.235919.13278@CSD-NewsHost.Stanford.EDU>
Keywords: MIPS, break
Sender: gnulists@ai.mit.edu
Reply-To: jonathan@cs.stanford.edu (Jonathan Stone)
Organization: Computer Science Department, Stanford University
Distribution: gnu
Date: Sun, 20 Sep 1992 23:59:19 GMT
Approved: bug-gdb@prep.ai.mit.edu
Lines: 78