remote-mips.c: Fix namespace pollution

Maciej W. Rozycki macro@mips.com
Tue Feb 5 17:50:00 GMT 2008


Hello,

 The recent renaming of gdb_breakpoint() to set_breakpoint() within 
breakpoint.c triggered a problem with remote-mips.c defining a static 
function of the same name.  Given breakpoint.c is a piece of generic code 
I think it is the responsibility of the target-specific bits to keep the 
namespace clean.  Taking this into account I have prepared the following 
change which renames all the related functions, giving them a mips_ 
prefix.

2008-02-05  Maciej W. Rozycki  <macro@mips.com>

	* remote-mips.c (set_breakpoint): Rename to...
	(mips_set_breakpoint): ... this.
	(clear_breakpoint): Rename to...
	(mips_clear_breakpoint): ... this.
	(common_breakpoint): Rename to...
	(mips_common_breakpoint): ... this.
	(check_lsi_error): Rename to...
	(mips_check_lsi_error): ... this.

 OK to apply?

  Maciej

gdb-set_breakpoint.diff
Index: binutils-quilt/src/gdb/remote-mips.c
===================================================================
--- binutils-quilt.orig/src/gdb/remote-mips.c	2008-02-05 14:38:19.000000000 +0000
+++ binutils-quilt/src/gdb/remote-mips.c	2008-02-05 14:42:59.000000000 +0000
@@ -140,12 +140,13 @@
 static int mips_make_srec (char *buffer, int type, CORE_ADDR memaddr,
 			   unsigned char *myaddr, int len);
 
-static int set_breakpoint (CORE_ADDR addr, int len, enum break_type type);
+static int mips_set_breakpoint (CORE_ADDR addr, int len, enum break_type type);
 
-static int clear_breakpoint (CORE_ADDR addr, int len, enum break_type type);
+static int mips_clear_breakpoint (CORE_ADDR addr, int len,
+				  enum break_type type);
 
-static int common_breakpoint (int set, CORE_ADDR addr, int len,
-			      enum break_type type);
+static int mips_common_breakpoint (int set, CORE_ADDR addr, int len,
+				   enum break_type type);
 
 /* Forward declarations.  */
 extern struct target_ops mips_ops;
@@ -1450,7 +1451,7 @@
 
   /* Clear all breakpoints: */
   if ((mips_monitor == MON_IDT
-       && clear_breakpoint (-1, 0, BREAK_UNUSED) == 0)
+       && mips_clear_breakpoint (-1, 0, BREAK_UNUSED) == 0)
       || mips_monitor == MON_LSI)
     monitor_supports_breakpoints = 1;
   else
@@ -2236,8 +2237,8 @@
 mips_insert_breakpoint (struct bp_target_info *bp_tgt)
 {
   if (monitor_supports_breakpoints)
-    return set_breakpoint (bp_tgt->placed_address, MIPS_INSN32_SIZE,
-			   BREAK_FETCH);
+    return mips_set_breakpoint (bp_tgt->placed_address, MIPS_INSN32_SIZE,
+				BREAK_FETCH);
   else
     return memory_insert_breakpoint (bp_tgt);
 }
@@ -2246,8 +2247,8 @@
 mips_remove_breakpoint (struct bp_target_info *bp_tgt)
 {
   if (monitor_supports_breakpoints)
-    return clear_breakpoint (bp_tgt->placed_address, MIPS_INSN32_SIZE,
-			     BREAK_FETCH);
+    return mips_clear_breakpoint (bp_tgt->placed_address, MIPS_INSN32_SIZE,
+				  BREAK_FETCH);
   else
     return memory_remove_breakpoint (bp_tgt);
 }
@@ -2293,7 +2294,7 @@
 int
 mips_insert_watchpoint (CORE_ADDR addr, int len, int type)
 {
-  if (set_breakpoint (addr, len, type))
+  if (mips_set_breakpoint (addr, len, type))
     return -1;
 
   return 0;
@@ -2302,7 +2303,7 @@
 int
 mips_remove_watchpoint (CORE_ADDR addr, int len, int type)
 {
-  if (clear_breakpoint (addr, len, type))
+  if (mips_clear_breakpoint (addr, len, type))
     return -1;
 
   return 0;
@@ -2318,18 +2319,18 @@
 /* Insert a breakpoint.  */
 
 static int
-set_breakpoint (CORE_ADDR addr, int len, enum break_type type)
+mips_set_breakpoint (CORE_ADDR addr, int len, enum break_type type)
 {
-  return common_breakpoint (1, addr, len, type);
+  return mips_common_breakpoint (1, addr, len, type);
 }
 
 
 /* Clear a breakpoint.  */
 
 static int
-clear_breakpoint (CORE_ADDR addr, int len, enum break_type type)
+mips_clear_breakpoint (CORE_ADDR addr, int len, enum break_type type)
 {
-  return common_breakpoint (0, addr, len, type);
+  return mips_common_breakpoint (0, addr, len, type);
 }
 
 
@@ -2338,10 +2339,10 @@
    print the warning text and return 0.  If it's an error, print
    the error text and return 1.  <ADDR> is the address of the breakpoint
    that was being set.  <RERRFLG> is the error code returned by PMON. 
-   This is a helper function for common_breakpoint.  */
+   This is a helper function for mips_common_breakpoint.  */
 
 static int
-check_lsi_error (CORE_ADDR addr, int rerrflg)
+mips_check_lsi_error (CORE_ADDR addr, int rerrflg)
 {
   struct lsi_error *err;
   char *saddr = paddr_nz (addr);	/* printable address string */
@@ -2360,15 +2361,15 @@
 	      if ((err->code & rerrflg) == err->code)
 		{
 		  found = 1;
-		  fprintf_unfiltered (gdb_stderr,
-				  "common_breakpoint (0x%s): Warning: %s\n",
+		  fprintf_unfiltered (gdb_stderr, "\
+mips_common_breakpoint (0x%s): Warning: %s\n",
 				      saddr,
 				      err->string);
 		}
 	    }
 	  if (!found)
-	    fprintf_unfiltered (gdb_stderr,
-			"common_breakpoint (0x%s): Unknown warning: 0x%x\n",
+	    fprintf_unfiltered (gdb_stderr, "\
+mips_common_breakpoint (0x%s): Unknown warning: 0x%x\n",
 				saddr,
 				rerrflg);
 	}
@@ -2380,15 +2381,15 @@
     {
       if ((err->code & rerrflg) == err->code)
 	{
-	  fprintf_unfiltered (gdb_stderr,
-			      "common_breakpoint (0x%s): Error: %s\n",
+	  fprintf_unfiltered (gdb_stderr, "\
+mips_common_breakpoint (0x%s): Error: %s\n",
 			      saddr,
 			      err->string);
 	  return 1;
 	}
     }
-  fprintf_unfiltered (gdb_stderr,
-		      "common_breakpoint (0x%s): Unknown error: 0x%x\n",
+  fprintf_unfiltered (gdb_stderr, "\
+mips_common_breakpoint (0x%s): Unknown error: 0x%x\n",
 		      saddr,
 		      rerrflg);
   return 1;
@@ -2409,7 +2410,7 @@
    Return 0 if successful; otherwise 1.  */
 
 static int
-common_breakpoint (int set, CORE_ADDR addr, int len, enum break_type type)
+mips_common_breakpoint (int set, CORE_ADDR addr, int len, enum break_type type)
 {
   char buf[DATA_MAXLEN + 1];
   char cmd, rcmd;
@@ -2442,7 +2443,8 @@
 	  /* Clear the table entry and tell PMON to clear the breakpoint.  */
 	  if (i == MAX_LSI_BREAKPOINTS)
 	    {
-	      warning ("common_breakpoint: Attempt to clear bogus breakpoint at %s\n",
+	      warning ("\
+mips_common_breakpoint: Attempt to clear bogus breakpoint at %s\n",
 		       paddr_nz (addr));
 	      return 1;
 	    }
@@ -2456,9 +2458,11 @@
 
 	  nfields = sscanf (buf, "0x%x b 0x0 0x%x", &rpid, &rerrflg);
 	  if (nfields != 2)
-	    mips_error ("common_breakpoint: Bad response from remote board: %s", buf);
+	    mips_error ("\
+mips_common_breakpoint: Bad response from remote board: %s",
+			buf);
 
-	  return (check_lsi_error (addr, rerrflg));
+	  return (mips_check_lsi_error (addr, rerrflg));
 	}
       else
 	/* set a breakpoint */
@@ -2508,10 +2512,12 @@
 	  nfields = sscanf (buf, "0x%x %c 0x%x 0x%x",
 			    &rpid, &rcmd, &rresponse, &rerrflg);
 	  if (nfields != 4 || rcmd != cmd || rresponse > 255)
-	    mips_error ("common_breakpoint: Bad response from remote board: %s", buf);
+	    mips_error ("\
+mips_common_breakpoint: Bad response from remote board: %s",
+			buf);
 
 	  if (rerrflg != 0)
-	    if (check_lsi_error (addr, rerrflg))
+	    if (mips_check_lsi_error (addr, rerrflg))
 	      return 1;
 
 	  /* rresponse contains PMON's breakpoint number.  Record the
@@ -2575,7 +2581,8 @@
 			&rpid, &rcmd, &rerrflg, &rresponse);
 
       if (nfields != 4 || rcmd != cmd)
-	mips_error ("common_breakpoint: Bad response from remote board: %s",
+	mips_error ("\
+mips_common_breakpoint: Bad response from remote board: %s",
 		    buf);
 
       if (rerrflg != 0)
@@ -2585,8 +2592,8 @@
 	  if (mips_monitor == MON_DDB)
 	    rresponse = rerrflg;
 	  if (rresponse != 22)	/* invalid argument */
-	    fprintf_unfiltered (gdb_stderr,
-			     "common_breakpoint (0x%s):  Got error: 0x%x\n",
+	    fprintf_unfiltered (gdb_stderr, "\
+mips_common_breakpoint (0x%s):  Got error: 0x%x\n",
 				paddr_nz (addr), rresponse);
 	  return 1;
 	}



More information about the Gdb-patches mailing list