From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9422 invoked by alias); 5 Mar 2008 03:58:22 -0000 Received: (qmail 9391 invoked by uid 367); 5 Mar 2008 03:58:21 -0000 Date: Wed, 05 Mar 2008 03:58:00 -0000 Message-ID: <20080305035821.9376.qmail@sourceware.org> From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Fix print const_char_pointer. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: cf7ad51045d0b226e2bbc4d737af7b265a787157 X-Git-Newrev: ed3e465f0588c2297480be91501c431a5ccf2b22 Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2008-q1/txt/msg00310.txt.bz2 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 Date: Tue Mar 4 22:57:25 2008 -0500 Fix print const_char_pointer. frysk-core/frysk/value/ChangeLog 2008-03-04 Andrew Cagney * 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 + * TestPointer.java (testConstCharPointer()): New. + * PointerType.java: Get the target's ultimate type. + * TestComposite.java: Update to match 2008-02-19 Stan Cox 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