public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: tthomas@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Add dynamic array types to funit-address. Date: Wed, 28 Nov 2007 22:01:00 -0000 [thread overview] Message-ID: <20071128220110.12000.qmail@sourceware.org> (raw) The branch, master has been updated via 74d6f72347b4ddd28315728a507de7215f3d11c0 (commit) via 1e4fb52a6de8676091de06750e82b78ce64c69ba (commit) via 0748ad52a7271e7f6b929f6661b99061bebca519 (commit) from 1e71dcb17fdefb823eeef9a67f0e27f616e86882 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 74d6f72347b4ddd28315728a507de7215f3d11c0 Author: Teresa Thomas <tthomas@redhat.com> Date: Wed Nov 28 16:56:08 2007 -0500 Add dynamic array types to funit-address. frysk-core/frysk/pkglibdir/ChangeLog 2007-11-28 Teresa Thomas <tthomas@redhat.com> * funit-addresses.c (dynamicOneD): New (dynamicTwoD): New. commit 1e4fb52a6de8676091de06750e82b78ce64c69ba Author: Teresa Thomas <tthomas@redhat.com> Date: Wed Nov 28 16:48:37 2007 -0500 Clean up PieceLocation. frysk-core/frysk/debuginfo/ChangeLog 2007-11-28 Teresa Thomas <tthomas@redhat.com> * TestPieceLocation.java (testMapping): Delete - redundant test. * PieceLocation.java (indexOf): Make private, Throw exception on failure. (pieceOf): Ditto. commit 0748ad52a7271e7f6b929f6661b99061bebca519 Author: Teresa Thomas <tthomas@redhat.com> Date: Wed Nov 28 16:43:16 2007 -0500 Re-write slice for pointers, simplify. frysk-core/frysk/value/ChangeLog 2007-11-28 Teresa Thomas <tthomas@redhat.com> * PointerType.java (slice): Re-write. * ArrayType.java (slice): Remove FIX-ME comment. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/debuginfo/ChangeLog | 10 ++++++- frysk-core/frysk/debuginfo/PieceLocation.java | 10 +++--- frysk-core/frysk/debuginfo/TestPieceLocation.java | 10 ------ frysk-core/frysk/pkglibdir/ChangeLog | 5 +++ frysk-core/frysk/pkglibdir/funit-addresses.c | 23 ++++++++++++++- frysk-core/frysk/value/ArrayType.java | 6 +-- frysk-core/frysk/value/ChangeLog | 7 ++++- frysk-core/frysk/value/PointerType.java | 32 +++++--------------- 8 files changed, 57 insertions(+), 46 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/debuginfo/ChangeLog b/frysk-core/frysk/debuginfo/ChangeLog index 1308ae6..10c7918 100644 --- a/frysk-core/frysk/debuginfo/ChangeLog +++ b/frysk-core/frysk/debuginfo/ChangeLog @@ -1,5 +1,13 @@ -2007-11-28 Sami Wagiaalla <swagiaal@redhat.com> +2007-11-28 Teresa Thomas <tthomas@redhat.com> + * TestPieceLocation.java (testMapping): Delete - redundant + test. + * PieceLocation.java (indexOf): Make private, Throw + exception on failure. + (pieceOf): Ditto. + +2007-11-28 Sami Wagiaalla <swagiaal@redhat.com> + * LocationExpression.java: Removed frame requirement from constructor to be passed as an argument to decoding functions. * TestAddress.java: Updated. diff --git a/frysk-core/frysk/debuginfo/PieceLocation.java b/frysk-core/frysk/debuginfo/PieceLocation.java index c356dfa..6f888fb 100644 --- a/frysk-core/frysk/debuginfo/PieceLocation.java +++ b/frysk-core/frysk/debuginfo/PieceLocation.java @@ -103,7 +103,7 @@ extends Location * @param offset - overall byte offset of value * @return - piece index */ - protected long indexOf(long offset) + private long indexOf(long offset) { // indexCount will be set to contain the overall byte index of // first byte of every piece. @@ -125,7 +125,7 @@ extends Location else indexCount += len; } - return -1; + throw new RuntimeException("Index out of range for offset " + offset); } /** @@ -134,7 +134,7 @@ extends Location * @param offset - overall byte offset of value * @return - piece that contains the byte at OFFSET */ - protected Piece pieceOf(long offset) + private Piece pieceOf(long offset) { // indexCount will be set to contain the overall byte // index of first byte of every piece. @@ -148,14 +148,14 @@ extends Location if ( offset >= indexCount && offset < indexCount+len ) { // If condition will satisfy if (overall) offset - //is within current piece. + // is within current piece. return (Piece)o; } else indexCount += len; } - return null; + throw new RuntimeException("Piece out of range for offset " + offset); } /** diff --git a/frysk-core/frysk/debuginfo/TestPieceLocation.java b/frysk-core/frysk/debuginfo/TestPieceLocation.java index 690c232..1ea10c8 100644 --- a/frysk-core/frysk/debuginfo/TestPieceLocation.java +++ b/frysk-core/frysk/debuginfo/TestPieceLocation.java @@ -88,16 +88,6 @@ extends TestLib l = null; } - public void testMapping() - { - // Test for length - assertEquals ("total bytes", l.length(), 15); - - // Test for index and piece mapping - assertEquals("piece index", 1, l.indexOf(6)); - assertEquals("piece", l.getPieces().get(1), l.pieceOf(6)); - } - public void testGetPutByte() { // Test for putByte & getByte of MemoryPiece diff --git a/frysk-core/frysk/pkglibdir/ChangeLog b/frysk-core/frysk/pkglibdir/ChangeLog index 67dfeab..1706b00 100644 --- a/frysk-core/frysk/pkglibdir/ChangeLog +++ b/frysk-core/frysk/pkglibdir/ChangeLog @@ -1,3 +1,8 @@ +2007-11-28 Teresa Thomas <tthomas@redhat.com> + + * funit-addresses.c (dynamicOneD): New + (dynamicTwoD): New. + 2007-11-26 Teresa Thomas <tthomas@redhat.com> * funit-addresses.c (ptrStrings): New. diff --git a/frysk-core/frysk/pkglibdir/funit-addresses.c b/frysk-core/frysk/pkglibdir/funit-addresses.c index ba02f13..cf057b9 100644 --- a/frysk-core/frysk/pkglibdir/funit-addresses.c +++ b/frysk-core/frysk/pkglibdir/funit-addresses.c @@ -65,12 +65,28 @@ int oneD[] = { 4, 3, 2, 1}; char* string = "hello world"; int* ptr = NULL; char* ptrStrings[] = {"zero", "one", "two", "three"}; +int** dynamicTwoD = NULL; +int* dynamicOneD = NULL; int main(int argc, char* argv[]) { static int static_int = 22; volatile int volatile_int = 33; - register int reg = 5; + register int reg = 5; + int i, k; + + // Dynamically allocated two d array [5][3] + dynamicTwoD = malloc (sizeof (int*) * 5); + for (i=0; i<5; i++) + dynamicTwoD[i] = malloc (sizeof(int) * 3); + // Fill with value 9 + for (i=0; i<5; i++) + for (k=0; k<3; k++) + dynamicTwoD[i][k] = 9; + + dynamicOneD = malloc (sizeof(int) * 3); + for (i =0 ; i<3; i++) + dynamicOneD[i] = 5; static_int_address = &static_int; volatile_int_address = &volatile_int; @@ -82,6 +98,11 @@ int main(int argc, char* argv[]) *(my_cars.audi) = 3; my_cars.lexus = reg; + // Free Dynamic memory + /*for (i = 0; i < 5; i ++) + free(twoDArray[i]); + free(twoDArray);*/ + if (strcmp(argv[1], "loop") == 0) while (1) {} diff --git a/frysk-core/frysk/value/ArrayType.java b/frysk-core/frysk/value/ArrayType.java index 0011ead..c3a38ff 100644 --- a/frysk-core/frysk/value/ArrayType.java +++ b/frysk-core/frysk/value/ArrayType.java @@ -168,11 +168,9 @@ public class ArrayType */ public Value slice (Value v, Value i, Value j, ByteBuffer taskMem) { - int len = (int)(j.asLong() - i.asLong() + 1); - - // FIXME: Allow this case instead of throwing error? + int len = (int)(j.asLong() - i.asLong() + 1); if (len < 0) { - throw new RuntimeException("Error: Index 1 should be less than Index 2"); + throw new RuntimeException("Error: Index 1 should be <= than Index 2"); } // Create a new dimensions list diff --git a/frysk-core/frysk/value/ChangeLog b/frysk-core/frysk/value/ChangeLog index 39b20b5..5c4f559 100644 --- a/frysk-core/frysk/value/ChangeLog +++ b/frysk-core/frysk/value/ChangeLog @@ -1,6 +1,11 @@ +2007-11-28 Teresa Thomas <tthomas@redhat.com> + + * PointerType.java (slice): Re-write. + * ArrayType.java (slice): Remove FIX-ME comment. + 007-11-28 Sami Wagiaalla <swagiaal@redhat.com> - LocationExpression.java: Removed frame requirement from constructor + * LocationExpression.java: Removed frame requirement from constructor to be passed as an argument to decoding functions. * Variable.java: Updated. diff --git a/frysk-core/frysk/value/PointerType.java b/frysk-core/frysk/value/PointerType.java index 43e5d97..d72c414 100644 --- a/frysk-core/frysk/value/PointerType.java +++ b/frysk-core/frysk/value/PointerType.java @@ -142,40 +142,24 @@ public class PointerType /** * Slice operation for pointers. - * - * Supports upto 2-dimensional results. */ public Value slice (Value v, Value i, Value j, ByteBuffer taskMem) { // Evaluate length and offset of slice. long offset = v.asLong() + i.asLong()*type.getSize(); - int len = (int)(j.asLong() - i.asLong() + 1)*type.getSize(); + int len = (int)(j.asLong() - i.asLong() + 1); + if (len < 0) { + throw new RuntimeException("Error: Index 1 should be <= than Index 2"); + } // Create a simple memory location with it. Location loc = PieceLocation.createSimpleLoc - (offset, len, taskMem); - - /* Determine return type. - * Note: Slicing can give one-D or multi-D results - * depending on the type of value being pointed to. - */ + (offset, len*type.getSize(), taskMem); ArrayList dims = new ArrayList(); - // Set default return type as type of value being - // pointed to. - Type resultType = type; - - // When length of slice calculated is greater than type's - // size, result will be an array. - if (len > type.getSize()) - { - dims.add(new Integer(len/type.getSize()-1)); - // Create 2-d arrays in case of ptrs to ptrs or arrays. - if (type instanceof PointerType || type instanceof ArrayType) - dims.add(new Integer(len-1)); - resultType = new ArrayType(type, len, dims); - } - + dims.add(new Integer(len-1)); + Type resultType = new ArrayType(type, len*type.getSize(), dims); + return new Value (resultType, loc); } hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2007-11-28 22:01 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20071128220110.12000.qmail@sourceware.org \ --to=tthomas@sourceware.org \ --cc=frysk-cvs@sourceware.org \ --cc=frysk@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).