[SCM] master: Workaround PPC register problems.

cagney@sourceware.org cagney@sourceware.org
Fri Nov 9 17:14:00 GMT 2007


The branch, master has been updated
       via  685835609bb5c145000f0dd69785b781672e7a36 (commit)
       via  2bec14b3c5d10a5cd3c61abe74ac2014b370ab25 (commit)
      from  b0961692e1128f38fc66e23bdfa710e102b03fbb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 685835609bb5c145000f0dd69785b781672e7a36
Author: Andrew Cagney <cagney@redhat.com>
Date:   Fri Nov 9 12:05:16 2007 -0500

    Workaround PPC register problems.
    
    frysk-core/frysk/proc/ChangeLog
    2007-11-09  Andrew Cagney  <cagney@redhat.com>
    
    	* PPCBankRegisters.java (PPC32BE_ON_PPC64BE): Don't add "nip",
    	"ctr", "lnk", "xer", "ccr".

commit 2bec14b3c5d10a5cd3c61abe74ac2014b370ab25
Author: Andrew Cagney <cagney@redhat.com>
Date:   Fri Nov 9 11:41:26 2007 -0500

    Stop Input.stringValue() including arguments.
    
    frysk-core/frysk/hpd/ChangeLog
    2007-11-09  Andrew Cagney  <cagney@redhat.com>
    
    	* Input.java: Eliminate the sentinel.
    	(remove(int)): Delete.
    	(removeFirst()): New.
    	(removeLast()): New.
    	(stringValue()): Handle truncated input.
    	* ParameterizedCommand.java: Update.
    	* TestInput.java (testRemoveLast()): new.

-----------------------------------------------------------------------

Summary of changes:
 frysk-core/frysk/hpd/ChangeLog                 |   10 +++++
 frysk-core/frysk/hpd/Input.java                |   43 ++++++++++++++---------
 frysk-core/frysk/hpd/ParameterizedCommand.java |    6 ++--
 frysk-core/frysk/hpd/TestInput.java            |   43 +++++++++++++----------
 frysk-core/frysk/proc/ChangeLog                |    5 +++
 frysk-core/frysk/proc/PPCBankRegisters.java    |   12 ++++---
 6 files changed, 75 insertions(+), 44 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 53eea58..2d0e721 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,13 @@
+2007-11-09  Andrew Cagney  <cagney@redhat.com>
+
+	* Input.java: Eliminate the sentinel.
+	(remove(int)): Delete.
+	(removeFirst()): New.
+	(removeLast()): New.
+	(stringValue()): Handle truncated input.
+	* ParameterizedCommand.java: Update.
+	* TestInput.java (testRemoveLast()): new.
+
 2007-11-09  Sami Wagiaalla  <swagiaal@redhat.com>
 
 	Changed CoreFileAtSignal to return core File instead of core Proc.
diff --git a/frysk-core/frysk/hpd/Input.java b/frysk-core/frysk/hpd/Input.java
index 0d822cf..1b025b5 100644
--- a/frysk-core/frysk/hpd/Input.java
+++ b/frysk-core/frysk/hpd/Input.java
@@ -69,8 +69,6 @@ class Input {
     private final String fullCommand;
     private final String set;
     private final String action;
-    // The tokens include a SENTINEL pointing at the end of the
-    // buffer.
     private final List tokens;
 
     private Input(String fullCommand, String set, String action, List tokens) {
@@ -100,7 +98,7 @@ class Input {
 	    if (tempToken.startsWith("[") && tempToken.endsWith("]")) {
 		// if p/t-set
 		set = tempToken;
-		remove(0);
+		removeFirst();
 	    } else {
 		set = null;
 	    }
@@ -119,7 +117,10 @@ class Input {
      * Return the N'th parameter.
      */
     String parameter(int n) {
-	return token(n).value;
+	if (n < 0 || n > size())
+	    return null;
+	else
+	    return token(n).value;
     }
 
     /**
@@ -139,32 +140,42 @@ class Input {
      * string.
      */
     String stringValue() {
-	return fullCommand.substring(token(0).start);
+	if (size() > 0)
+	    return fullCommand.substring(token(0).start,
+					 token(size()-1).end);
+	else
+	    return "";
     }
 
     /**
-     * Return the N'th token.
-     *
-     * The end-of-tokens is denoted by a sentinel (Token.value ==
-     * NULL) that provides the position of the end-of-buffer.
+     * Return the N'th token; or null.
      */
     Token token(int n) {
-	return (Token)tokens.get(n);
+	if (n < 0 || n >= size())
+	    return null;
+	else
+	    return (Token)tokens.get(n);
     }
 
     /**
-     * Remove the N'th parameter.
+     * Remove the first token.
      */
-    void remove(int n) {
-	tokens.remove(n);
+    void removeFirst() {
+	tokens.remove(0);
+    }
+
+    /**
+     * Remove the last token.
+     */
+    void removeLast() {
+	tokens.remove(size() - 1);
     }
 
     /**
      * Return the number or size of the parameter list.
      */
     int size() {
-	// Do not count the SENTINEL.
-	return tokens.size() - 1;
+	return tokens.size();
     }
 
     public String toString() {
@@ -253,8 +264,6 @@ class Input {
 	if (start >= 0) {
 	    tokens.add(new Token(token.toString(), start, str.length()));
 	}
-	// Add a SENTINEL pointing at the end of the input string.
-	tokens.add(new Token(null, str.length(), str.length()));
 	return tokens;
     }
 }
diff --git a/frysk-core/frysk/hpd/ParameterizedCommand.java b/frysk-core/frysk/hpd/ParameterizedCommand.java
index be08aa0..b598809 100644
--- a/frysk-core/frysk/hpd/ParameterizedCommand.java
+++ b/frysk-core/frysk/hpd/ParameterizedCommand.java
@@ -95,7 +95,7 @@ abstract class ParameterizedCommand extends Command {
 		     + commandOption.parameter);
 	    if (eq == -1) {
 		argument = input.parameter(index);
-		input.remove(index);
+		input.removeLast();
 	    } else {
 		argument = option.substring(eq + 1);
 	    }
@@ -123,7 +123,7 @@ abstract class ParameterizedCommand extends Command {
 		    throw new InvalidCommandException
 			("Invalid option "
 			 + input.parameter(currentIndex + 1));
-		input.remove(currentIndex);
+		input.removeLast();
 		break;
 	    }
 	    if (string.equals("-help")) {
@@ -133,7 +133,7 @@ abstract class ParameterizedCommand extends Command {
 	    if (string.charAt(0) != '-')
 		continue;
 	    handleOption(input, string, currentIndex + 1, options);
-	    input.remove(currentIndex);
+	    input.removeLast();
 	}
 	interpret(cli, input, options);
     }
diff --git a/frysk-core/frysk/hpd/TestInput.java b/frysk-core/frysk/hpd/TestInput.java
index fd3769f..c8af94a 100644
--- a/frysk-core/frysk/hpd/TestInput.java
+++ b/frysk-core/frysk/hpd/TestInput.java
@@ -53,7 +53,7 @@ public class TestInput extends TestLib {
 	assertEquals("size", results.length, input.size());
 	assertEquals("set", set, input.getSet());
 	assertEquals("stringArrayValue", results, input.stringArrayValue());
-	for (int i = 0; i < results.length + 1; i++) {
+	for (int i = 0; i < results.length; i++) {
 	    assertEquals("parameter " + i,
 			 i == results.length ? null : results[i],
 			 input.parameter(i));
@@ -73,14 +73,12 @@ public class TestInput extends TestLib {
     }
 
     private void check(String input, String[] results) {
-	int[] starts = new int[results.length + 1];
-	int[] ends = new int[results.length + 1];
+	int[] starts = new int[results.length];
+	int[] ends = new int[results.length];
 	for (int i = 0; i < results.length; i++) {
 	    starts[i] = input.indexOf(results[i]);
 	    ends[i] = starts[i] + results[i].length();
 	}
-	starts[results.length] = input.length();
-	ends[results.length] = input.length();
 	check(new Input(input), null, results, starts, ends);
     }
 
@@ -106,6 +104,13 @@ public class TestInput extends TestLib {
 	check(input, new String[0]);
     }
 
+    public void testRemoveLast() {
+	Input input = new Input("p0 p1 p2 p3");
+	input.removeLast();
+	assertEquals("stringValue", "p0 p1 p2", input.stringValue());
+	assertEquals("size", 3, input.size());
+    }
+
     public void testEmpty() {
 	check("", new String[0]);
     }
@@ -126,54 +131,54 @@ public class TestInput extends TestLib {
 	// Remember, \" is one character.
 	check(new Input("1 \" 2 \" 3"), null,
 	      new String[] { "1", " 2 ", "3" },
-	      new int[] { 0, 2, 8, 9 },
-	      new int[] { 1, 7, 9, 9 });
+	      new int[] { 0, 2, 8 },
+	      new int[] { 1, 7, 9 });
     }
 
     public void testDoubleQuoteInToken() {
 	// Remember, \" is one character.
 	check(new Input(" a\" \"b "), null,
 	      new String[] { "a b" },
-	      new int[] { 1, 7 },
-	      new int[] { 6, 7 });
+	      new int[] { 1 },
+	      new int[] { 6 });
     }
 
     public void testEmptyQuote() {
 	// Remember, \" is one character.
 	check(new Input("\"\""), null,
 	      new String[] { "" },
-	      new int[] { 0, 2 },
-	      new int[] { 2, 2 });
+	      new int[] { 0 },
+	      new int[] { 2 });
     }
 
     public void testEmptyQuoteBetweenParameters() {
 	// Remember, \" is one character.
 	check(new Input("1 \"\" 3"), null,
 	      new String[] {"1", "", "3"},
-	      new int[] { 0, 2, 5, 6 },
-	      new int[] { 1, 4, 6, 6 });
+	      new int[] { 0, 2, 5 },
+	      new int[] { 1, 4, 6 });
     }
 
     public void testEscapedQuote() {
 	// Remember, \" is one character.
 	check(new Input("\\\""), null,
 	      new String[] { "\"" },
-	      new int[] { 0, 2 },
-	      new int[] { 2, 2 });
+	      new int[] { 0 },
+	      new int[] { 2 });
     }
 
     public void testSet() {
 	check(new Input(" [1.2] "), "[1.2]",
 	      new String[0],
-	      new int[] { 7 },
-	      new int[] { 7 });
+	      new int[0],
+	      new int[0]);
     }
 
     public void testSetAndParameters() {
 	check(new Input(" [1.2] a b"), "[1.2]",
 	      new String[] { "a", "b" },
-	      new int[] { 7, 9, 10 },
-	      new int[] { 8, 10, 10 });
+	      new int[] { 7, 9 },
+	      new int[] { 8, 10 });
     }
 
     private void checkInvalidCommandException(String input) {
diff --git a/frysk-core/frysk/proc/ChangeLog b/frysk-core/frysk/proc/ChangeLog
index 357707b..8d9b128 100644
--- a/frysk-core/frysk/proc/ChangeLog
+++ b/frysk-core/frysk/proc/ChangeLog
@@ -1,3 +1,8 @@
+2007-11-09  Andrew Cagney  <cagney@redhat.com>
+
+	* PPCBankRegisters.java (PPC32BE_ON_PPC64BE): Don't add "nip",
+	"ctr", "lnk", "xer", "ccr".
+
 2007-11-09  Jose Flavio Aguilar Paulino <jflavio@br.ibm.com>
 
         * IsaPowerPC.java: Updated it to also support Power32.
diff --git a/frysk-core/frysk/proc/PPCBankRegisters.java b/frysk-core/frysk/proc/PPCBankRegisters.java
index 22b43a9..1eecc0f 100644
--- a/frysk-core/frysk/proc/PPCBankRegisters.java
+++ b/frysk-core/frysk/proc/PPCBankRegisters.java
@@ -239,13 +239,15 @@ public class PPCBankRegisters {
 	.add("gpr29")
 	.add("gpr30")
 	.add("gpr31")
-	.add("nip")
+    // XXX: No such register on PPC32
+    //.add("nip")
 	.add("msr")
 	.add("orig_r3")
-	.add("ctr")
-	.add("lnk")
-	.add("xer")
-	.add("ccr")
+    // XXX: No such register on PPC32
+    //.add("ctr")
+    //.add("lnk")
+    //.add("xer")
+    //.add("ccr")
     // No such register on ppc64.
     // .add("mq"))
 	.add("trap")


hooks/post-receive
--
frysk system monitor/debugger



More information about the Frysk-cvs mailing list