This is the mail archive of the frysk-cvs@sources.redhat.com mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[SCM] master: Fix print const_char_pointer.


The branch, master has been updated
       via  ed3e465f0588c2297480be91501c431a5ccf2b22 (commit)
      from  cf7ad51045d0b226e2bbc4d737af7b265a787157 (commit)

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

- Log -----------------------------------------------------------------
commit ed3e465f0588c2297480be91501c431a5ccf2b22
Author: Andrew Cagney <cagney@redhat.com>
Date:   Tue Mar 4 22:57:25 2008 -0500

    Fix print const_char_pointer.
    
    frysk-core/frysk/value/ChangeLog
    2008-03-04  Andrew Cagney  <cagney@redhat.com>
    
    	* TestPointer.java (testConstCharPointer()): New.
    	* PointerType.java: Get the target's ultimate type.

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

Summary of changes:
 frysk-core/frysk/value/ChangeLog        |    3 +++
 frysk-core/frysk/value/PointerType.java |   11 ++++++-----
 frysk-core/frysk/value/TestPointer.java |   16 ++++++++++++++++
 3 files changed, 25 insertions(+), 5 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/value/ChangeLog b/frysk-core/frysk/value/ChangeLog
index 1fe75b5..dfee409 100644
--- a/frysk-core/frysk/value/ChangeLog
+++ b/frysk-core/frysk/value/ChangeLog
@@ -1,5 +1,8 @@
 2008-03-04  Andrew Cagney  <cagney@redhat.com>
 
+	* TestPointer.java (testConstCharPointer()): New.
+	* PointerType.java: Get the target's ultimate type.
+
 	* TestComposite.java: Update to match 2008-02-19 Stan Cox
 	<scox@redhat.com> CompositeType.java change.  Fixes #5859.
 
diff --git a/frysk-core/frysk/value/PointerType.java b/frysk-core/frysk/value/PointerType.java
index e63bb50..84f5b92 100644
--- a/frysk-core/frysk/value/PointerType.java
+++ b/frysk-core/frysk/value/PointerType.java
@@ -89,16 +89,17 @@ public class PointerType
 	} catch (RuntimeException e) {
 	    throw new RuntimeException("Peek Memory");
 	}
-	if (type instanceof CharType) {
+	Type ultimateType = type.getUltimateType();
+	if (ultimateType instanceof CharType) {
 	    // XXX: ByteBuffer.slice wants longs.
 	    long addr = getBigInteger(location).longValue();
 	    writer.print(" \"");
 	    while (true) {
-		Location l = new ByteBufferLocation(memory, addr,
-						    type.getSize());
+		Location l = new ByteBufferLocation
+		    (memory, addr, ultimateType.getSize());
 		BigInteger c = BigInteger.ZERO;
 		try {
-		   c = ((CharType)type).getBigInteger(l);
+		   c = ((CharType)ultimateType).getBigInteger(l);
 		} catch (RuntimeException e) {
 		    writer.print(" < Memory Error > ");
 		    break;
@@ -106,7 +107,7 @@ public class PointerType
 		if (c.equals(BigInteger.ZERO))
 		    break; // NUL
 		writer.print((char)c.longValue());
-		addr += type.getSize();
+		addr += ultimateType.getSize();
 	    }
 	    writer.print("\"");
 	}
diff --git a/frysk-core/frysk/value/TestPointer.java b/frysk-core/frysk/value/TestPointer.java
index 062b17f..df93465 100644
--- a/frysk-core/frysk/value/TestPointer.java
+++ b/frysk-core/frysk/value/TestPointer.java
@@ -98,4 +98,20 @@ public class TestPointer
 	Value idx2 = new Value(t_idx2, l_idx2);	
 	assertEquals("toPrint", "\"Wor\"", t.slice(string, idx, idx2, memory).toPrint());
     }    
+
+    public void testConstCharPointer() {
+	// Construct a buffer with a string in it.
+	ArrayByteBuffer memory
+	    = new ArrayByteBuffer("0123Hello World\0>>>".getBytes());
+	Type t = new PointerType("xxx", ByteOrder.BIG_ENDIAN, 1,
+				 new ConstType
+				 (new CharType
+				  ("char", ByteOrder.BIG_ENDIAN, 1, true)));
+	// Construct the pointer and try it.
+	Location l = new ScratchLocation(new byte[] { 4 });
+	assertEquals("toPrint", "(const char *) 0x4 \"Hello World\"",
+		     t.toPrint(l, memory, Format.NATURAL));
+    }
+    
+
 }


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]