public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Check memory address alignment before setting watchpoint.
@ 2008-05-13 14:38 pmuldoon
  0 siblings, 0 replies; only message in thread
From: pmuldoon @ 2008-05-13 14:38 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  e62c4482adaf39915db4f42983327a7b715d316a (commit)
      from  d5bc17c1a45b723f2dcf3b87e5f0695de83524c3 (commit)

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

- Log -----------------------------------------------------------------
commit e62c4482adaf39915db4f42983327a7b715d316a
Author: Phil Muldoon <pmuldoon@redhat.com>
Date:   Tue May 13 15:37:46 2008 +0100

    Check memory address alignment before setting watchpoint.
    
    2008-05-13  Phil Muldoon  <pmuldoon@redhat.com>
    
    	* TestTaskObserverWatchpoint.java (testAddFailed): Add alignment test.
    
    2008-05-13  Phil Muldoon  <pmuldoon@redhat.com>
    
    	* IA32WatchpointFunctions.java (setWatchpoint): Add alignment check.
    	* X8664WatchpointFunctions.java (setWatchpoint): Ditto.

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

Summary of changes:
 frysk-core/frysk/isa/watchpoints/ChangeLog         |    5 ++++
 .../isa/watchpoints/IA32WatchpointFunctions.java   |    4 +++
 .../isa/watchpoints/X8664WatchpointFunctions.java  |    6 ++++-
 frysk-core/frysk/proc/ChangeLog                    |    4 +++
 .../frysk/proc/TestTaskObserverWatchpoint.java     |   26 +++++++++----------
 5 files changed, 30 insertions(+), 15 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/isa/watchpoints/ChangeLog b/frysk-core/frysk/isa/watchpoints/ChangeLog
index 961ea10..8c86788 100644
--- a/frysk-core/frysk/isa/watchpoints/ChangeLog
+++ b/frysk-core/frysk/isa/watchpoints/ChangeLog
@@ -1,3 +1,8 @@
+2008-05-13  Phil Muldoon  <pmuldoon@redhat.com>
+
+	* IA32WatchpointFunctions.java (setWatchpoint): Add alignment check.
+	* X8664WatchpointFunctions.java (setWatchpoint): Ditto.
+	
 2008-05-07  Teresa Thomas  <tthomas@redhat.com>
 
 	* IA32WatchpointFunctions.java (setWatchpoint): Fix
diff --git a/frysk-core/frysk/isa/watchpoints/IA32WatchpointFunctions.java b/frysk-core/frysk/isa/watchpoints/IA32WatchpointFunctions.java
index ce962aa..8d170df 100644
--- a/frysk-core/frysk/isa/watchpoints/IA32WatchpointFunctions.java
+++ b/frysk-core/frysk/isa/watchpoints/IA32WatchpointFunctions.java
@@ -71,6 +71,10 @@ class IA32WatchpointFunctions extends WatchpointFunctions {
 	// turn bit on ( b= bit no):  l |= (1L << b);
 	if ((range == 1) || (range == 2) || (range == 4)) {
 	    
+	    if ((addr &~ (range -1)) != addr)
+		throw new RuntimeException("Address 0x"+Long.toHexString(addr) + 
+			" is not aligned on a " + range + " byte boundary. Cannot set watchpoint.");
+
 	    // Set the Debug register with the linear address.
 	    task.setRegister(IA32Registers.DEBUG_REGS_GROUP.getRegisters()[index],
 			     addr);
diff --git a/frysk-core/frysk/isa/watchpoints/X8664WatchpointFunctions.java b/frysk-core/frysk/isa/watchpoints/X8664WatchpointFunctions.java
index 11f5030..7104854 100644
--- a/frysk-core/frysk/isa/watchpoints/X8664WatchpointFunctions.java
+++ b/frysk-core/frysk/isa/watchpoints/X8664WatchpointFunctions.java
@@ -65,11 +65,15 @@ class X8664WatchpointFunctions extends WatchpointFunctions {
     public void setWatchpoint(Task task, int index, 
 	       long addr, int range,
 	       boolean writeOnly) {
-
+	
 	// turn bit off (b = bit no): l &= ~(1L << b)
 	// turn bit on ( b= bit no):  l |= (1L << b);
 	if ((range == 1) || (range == 2) || (range == 4) || (range == 8)) {
 	    
+	    if ((addr &~ (range -1)) != addr)
+		throw new RuntimeException("Address 0x"+Long.toHexString(addr) + 
+			" is not aligned on a " + range + " byte boundary. Cannot set watchpoint.");
+	    
 	    // Set the Debug register with the linear address.
 	    task.setRegister(X8664Registers.DEBUG_REGS_GROUP.getRegisters()[index],
 			     addr);
diff --git a/frysk-core/frysk/proc/ChangeLog b/frysk-core/frysk/proc/ChangeLog
index ab70cc1..d5b5a7f 100644
--- a/frysk-core/frysk/proc/ChangeLog
+++ b/frysk-core/frysk/proc/ChangeLog
@@ -1,3 +1,7 @@
+2008-05-13  Phil Muldoon  <pmuldoon@redhat.com>
+
+	* TestTaskObserverWatchpoint.java (testAddFailed): Add alignment test.
+
 2008-05-12  Phil Muldoon  <pmuldoon@redhat.com>
 
 	* TestTaskObserverWatchpoint.java (testAddFailed): New.	
diff --git a/frysk-core/frysk/proc/TestTaskObserverWatchpoint.java b/frysk-core/frysk/proc/TestTaskObserverWatchpoint.java
index a100008..94fdfde 100644
--- a/frysk-core/frysk/proc/TestTaskObserverWatchpoint.java
+++ b/frysk-core/frysk/proc/TestTaskObserverWatchpoint.java
@@ -177,12 +177,8 @@ extends TestLib
 
     }
 
-    // This test case tests whether watchpoints are caught when a task is in a straight
-    // "running" condition. This really tests the basic and advertised functionality of watchpoints:
-    // to be caught by hardware, not software. In this  test:  set up the watchpoint, set up
-    // a terminated observer to guard the watchpoint was caught, and simply set the task to run.
-    // If the watchpoint observer is called, and the test is blocked then the test passes. If the
-    // process terminates and the watchpoint is not caught, then this signified an error condition.
+    // This test case tests whether watchpoints addFailed is called on
+    // a variety of error conditions.
     public void testAddFailed () {
 	if (unresolvedOnPPC(5991)) 
 	    return;
@@ -209,21 +205,23 @@ extends TestLib
 	// Find Variable source for watch
 	long address = getGlobalSymbolAddress(task,"source");
 
-	// Add watch observer
-	AddFailWatchObserver watch = new AddFailWatchObserver();
-	task.requestAddWatchObserver(watch, address, 72, true);
-	task.requestUnblock(co);
+	// Add bad  length watch observer
+	AddFailWatchObserver badLength = new AddFailWatchObserver();
+	task.requestAddWatchObserver(badLength, address, 72, true);
+	
+	AddFailWatchObserver badAlignment = new AddFailWatchObserver();
+	task.requestAddWatchObserver(badAlignment, address-1, 4, true);
 
+	task.requestUnblock(co);
 	assertRunUntilStop("Run and test watchpoint ");
-
 	// Make sure it triggered.
-	assertTrue("addedFailed", watch.addFailed);
+	assertTrue("addedFailed on length", badLength.addFailed);
+	assertTrue("addedFailed on bad alignment", badAlignment.addFailed);
 
+	
 	// Delete both observers.
 	task.requestDeleteCodeObserver(co, mainAddress);
 	runPending();
-
-
     }
 
     // This test case tests whether 'read or write' watchpoints are caught when a task is in a straight


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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-05-13 14:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-13 14:38 [SCM] master: Check memory address alignment before setting watchpoint pmuldoon

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).