public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Add support for watching variables bigger than the max length a watch register can watch.
@ 2008-05-23 18:16 tthomas
  0 siblings, 0 replies; only message in thread
From: tthomas @ 2008-05-23 18:16 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  3cb51ecd23610d8509b05bfd4fa9bfc6d466e61b (commit)
       via  a73e6b7871725b9e14f278e768400aeba178554d (commit)
       via  a2c65c27450317e89f11cb51d319db96ceac3e66 (commit)
       via  8bbe39bf404b507702d7d561bbcedf3d9103c9ba (commit)
      from  bba3683f7288ea6129dc0139762184dff45dca37 (commit)

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

- Log -----------------------------------------------------------------
commit 3cb51ecd23610d8509b05bfd4fa9bfc6d466e61b
Author: Teresa Thomas <tthomas@redhat.com>
Date:   Fri May 23 14:13:42 2008 -0400

    Add support for watching variables bigger than the max length a watch register can watch.
    
    frysk-core/frysk/hpd/ChangeLog:
    2008-05-23 Teresa Thomas  <tthomas@redhat.com>
    
    	* WatchCommand.java (interpret): Install multiple
    	watchobservers if necessary.
    	* TestWatchCommand.java: New tests added.

commit a73e6b7871725b9e14f278e768400aeba178554d
Author: Teresa Thomas <tthomas@redhat.com>
Date:   Fri May 23 14:08:28 2008 -0400

    Test program containing different C data types for watchpoint testing.
    
    frysk-core/frysk/pkglibdir/ChangeLog:
    2007-05-23 Teresa Thomas <tthomas@redhat.com>
    
    	* funit-ctypes.c: New file.

commit a2c65c27450317e89f11cb51d319db96ceac3e66
Author: Teresa Thomas <tthomas@redhat.com>
Date:   Fri May 23 14:06:11 2008 -0400

    Add a done event to be executed when a task stops due to one or more actionpoints being hit.
    
    frysk-core/frysk/event/ChangeLog:
    2008-05-23  Teresa Thomas  <tthomas@redhat.com>
    
    	* ActionPointEvent.java: New file.

commit 8bbe39bf404b507702d7d561bbcedf3d9103c9ba
Author: Teresa Thomas <tthomas@redhat.com>
Date:   Fri May 23 14:01:41 2008 -0400

    Schedule an actionpoint done event in blockedByAction.
    
    frysk-core/frysk/stepping/ChangeLog:
    2008-05-23    Teresa Thomas  <tthomas@redhat.com>
    
    	* SteppingEngine.java (messages): New.
    	(blockedByActionPoint(Task,TaskObserver,String,PrintWriter)): New.

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

Summary of changes:
 .../ActionPointEvent.java}                         |   81 +++++++-------------
 frysk-core/frysk/event/ChangeLog                   |    4 +
 frysk-core/frysk/hpd/ChangeLog                     |   10 ++-
 frysk-core/frysk/hpd/TestWatchCommand.java         |   64 +++++++++++++++
 frysk-core/frysk/hpd/WatchCommand.java             |   50 +++++++++---
 frysk-core/frysk/pkglibdir/ChangeLog               |    4 +
 frysk-core/frysk/pkglibdir/funit-ctypes.c          |   63 +++++++++++++++
 frysk-core/frysk/stepping/ChangeLog                |    5 +
 frysk-core/frysk/stepping/SteppingEngine.java      |   51 ++++++++++++-
 9 files changed, 262 insertions(+), 70 deletions(-)
 copy frysk-core/frysk/{hpd/TestWatchCommand.java => event/ActionPointEvent.java} (54%)
 create mode 100644 frysk-core/frysk/pkglibdir/funit-ctypes.c

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/TestWatchCommand.java b/frysk-core/frysk/event/ActionPointEvent.java
similarity index 54%
copy from frysk-core/frysk/hpd/TestWatchCommand.java
copy to frysk-core/frysk/event/ActionPointEvent.java
index 9e61682..6b99e48 100644
--- a/frysk-core/frysk/hpd/TestWatchCommand.java
+++ b/frysk-core/frysk/event/ActionPointEvent.java
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2008, Red Hat Inc.
+// Copyright 2005, Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -37,61 +37,36 @@
 // version and license this file solely under the GPL without
 // exception.
 
-package frysk.hpd;
+package frysk.event;
 
-import frysk.config.Prefix;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.Set;
 
 /**
-* This class tests the "watch" command.
-*/
-public class TestWatchCommand extends TestLib {
+ * Event to be exectued after a task stops due to
+ * one or more action points being hit.
+ */
+public class ActionPointEvent
+    implements Event {
+    
+    Set messages;
+    PrintWriter writer;
+    
+    public ActionPointEvent (Set messages, PrintWriter writer)
+    {
+	this.messages = messages;
+	this.writer = writer;
+    }
 
-  public void testWatchPointSetAndHit()
-  {
-      e = new HpdTestbed();
-      e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-watchpoint").getPath(),
-                                "Loaded executable file.*");
-      e.sendCommandExpectPrompt("start", "Attached to process.*");
-      
-      e.send("watch source\n"); 
-      e.expect(".*Watchpoint set: source.*");
-      
-      e.send("go\n"); 
-      e.expect(".*Watchpoint hit: source.*Value before hit ="
-  	        + ".*Value after  hit =.*");
+    public void execute ()
+    {	
+	Iterator it = messages.iterator();	
+	while (it.hasNext()) {
+	    String element = (String)it.next();	  
+	    writer.print(element);
+	}	
+	messages.clear();
+    }
 
-      e.send("quit\n");
-      e.expect("Quitting\\.\\.\\.");
-      e.close();
-  }
-
-  public void testMultipleWatchPointSetAndHit()
-  {
-      e = new HpdTestbed();
-      e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-watchpoint").getPath(),
-                                "Loaded executable file.*");
-      e.sendCommandExpectPrompt("start", "Attached to process.*");
-
-      e.send("watch source\n"); 
-      e.expect(".*Watchpoint set: source.*");
-      e.send("watch read_only -a\n"); 
-      e.expect(".*Watchpoint set: read_only.*");
-      
-      e.send("go\n"); 
-      e.expect(".*Watchpoint hit: source.*Value before hit ="
-	      + ".*Value after  hit =.*");
-
-      e.send("go\n"); 
-      e.expect(".*Watchpoint hit: read_only.*Value before hit ="
-	      + ".*Value after  hit =.*");
-
-      e.send("go\n"); 
-      e.expect(".*Task " + "[0-9]+" + " is exiting with status " 
-	       + "[0-9]+");
-      
-      e.send("quit\n");
-      e.expect("Quitting\\.\\.\\.");
-      e.close();
-  }  
-  
 }
\ No newline at end of file
diff --git a/frysk-core/frysk/event/ChangeLog b/frysk-core/frysk/event/ChangeLog
index 60a7513..b457707 100644
--- a/frysk-core/frysk/event/ChangeLog
+++ b/frysk-core/frysk/event/ChangeLog
@@ -1,3 +1,7 @@
+2008-05-23  Teresa Thomas  <tthomas@redhat.com>
+
+	* ActionPointEvent.java: New file.
+
 2008-02-28  Andrew Cagney  <cagney@redhat.com>
 
 	* EventLoop.java: Use frysk.rsl.
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index e0d9f2b..5adea17 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,7 +1,13 @@
-2008-05-22  Andrew Cagney  <cagney@redhat.com>
+2008-05-23 Teresa Thomas  <tthomas@redhat.com>
 
-	* TestDisassemblerCommand.java: Don't use lib.opcodes.
+	* WatchCommand.java (interpret): Install multiple
+	watchobservers if necessary.
+	* TestWatchCommand.java: New tests added. 
 
+2008-05-22  Andrew Cagney  <cagney@redhat.com>
+	
+	* TestDisassemblerCommand.java: Don't use lib.opcodes.
+	
 2008-05-21  Sami Wagiaalla  <swagiaal@redhat.com>
 
 	ObjectDeclarationSearchEngine: Constructor now 
diff --git a/frysk-core/frysk/hpd/TestWatchCommand.java b/frysk-core/frysk/hpd/TestWatchCommand.java
index 9e61682..db673ec 100644
--- a/frysk-core/frysk/hpd/TestWatchCommand.java
+++ b/frysk-core/frysk/hpd/TestWatchCommand.java
@@ -94,4 +94,68 @@ public class TestWatchCommand extends TestLib {
       e.close();
   }  
   
+  /*
+   * Test to watch a variable that requires multiple
+   * watchpoints on IA32.
+   */
+  public void testWatchLongLong()
+  {
+      e = new HpdTestbed();
+      e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-ctypes").getPath(),
+                                "Loaded executable file.*");
+      e.sendCommandExpectPrompt("start", "Attached to process.*");
+      
+      e.send("watch long_long\n"); 
+      e.expect(".*Watchpoint set: long_long.*");
+      
+      e.send("go\n"); 
+      e.expect(".*Watchpoint hit: long_long.*Value before hit ="
+  	        + ".*Value after  hit =.*");
+
+      e.send("quit\n");
+      e.expect("Quitting\\.\\.\\.");
+      e.close();
+  }  
+  
+  /*
+   * Test to watch a data type whose size is larger than
+   * that can be watched by all hardware watch registers
+   * put together.
+   */
+  public void testWatchOversized()
+  {
+      e = new HpdTestbed();
+      e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-ctypes").getPath(),
+                                "Loaded executable file.*");
+      e.sendCommandExpectPrompt("start", "Attached to process.*");
+      
+      e.send("watch bigArray\n"); 
+      e.expect(".*Watchpoint set error: Variable size too large.*");
+      
+      e.send("quit\n");
+      e.expect("Quitting\\.\\.\\.");
+      e.close();
+  }   
+  
+  /*
+   * Test to watch a variable that is smaller than the max
+   * size a single watch register can watch.
+   */
+  public void testUndersized() {
+      e = new HpdTestbed();
+      e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-ctypes").getPath(),
+                                "Loaded executable file.*");
+      e.sendCommandExpectPrompt("start", "Attached to process.*");
+      
+      e.send("watch char_\n"); 
+      e.expect(".*Watchpoint set: char_.*");
+      
+      e.send("go\n"); 
+      e.expect(".*Watchpoint hit: char_.*Value before hit ="
+  	        + ".*Value after  hit =.*");
+
+      e.send("quit\n");
+      e.expect("Quitting\\.\\.\\.");
+      e.close();     
+  }
 }
\ No newline at end of file
diff --git a/frysk-core/frysk/hpd/WatchCommand.java b/frysk-core/frysk/hpd/WatchCommand.java
index 2224fa0..118f926 100644
--- a/frysk-core/frysk/hpd/WatchCommand.java
+++ b/frysk-core/frysk/hpd/WatchCommand.java
@@ -43,6 +43,7 @@ import java.util.Iterator;
 import java.util.List;
 
 import frysk.expr.Expression;
+import frysk.isa.watchpoints.WatchpointFunctionFactory;
 import frysk.proc.Action;
 import frysk.proc.Task;
 import frysk.proc.TaskObserver;
@@ -96,19 +97,43 @@ class WatchCommand extends ParameterizedCommand {
 		cli.printError(e);
 		continue;
 	    }	    
-	    // XXX: will fail for non-contiguos memory and registers 
-	    // XXX: Add error handling
-	    long address = expr.getLocation().getAddress();
 
 	    // XXX: getValue may modify inferior.
 	    String oldValueStr = expr.getValue().toPrint
-	                        (Format.NATURAL, task.getMemory());
+	                         (Format.NATURAL, task.getMemory());
 
-	    // Add a watch point observer to task.
+	    // Get the number of hardware watchpoints - architecture dependent
+	    int watchpointCount = WatchpointFunctionFactory.getWatchpointFunctions
+	                          (task.getISA()).getWatchpointCount();
+	    // Get the max length a hardware watchpoint can watch - architecture dependent
+	    int watchLength = WatchpointFunctionFactory.getWatchpointFunctions
+                              (task.getISA()).getWatchpointMaxLength();
+	 
+	    // XXX: May fail for non-contiguos memory and registers 
+	    long variableAddress = expr.getLocation().getAddress();
+	    int variableLength = expr.getType().getSize();
+	    
+	    if (variableLength > watchpointCount * watchLength )
+		throw new RuntimeException ("Watchpoint set error: Variable size too large.");
+
+	    // Calculate number of watch observers needed to completely
+	    // watch the variable.
+	    int numberOfObservers = (int)Math.ceil((double)variableLength/
+		                                   (double)watchLength);
+
+	    // Add watchpoint observers to task. 
+	    for (int i=0; i< numberOfObservers-1; i++) {
+		WatchpointObserver wpo = new WatchpointObserver
+		                         (expr, cli, expressionStr, oldValueStr);    
+		task.requestAddWatchObserver
+		     (wpo, variableAddress + i*watchLength, watchLength, writeOnly);
+	    }	
+	    // Last observer may not need to watch all watchLength bytes. 
 	    WatchpointObserver wpo = new WatchpointObserver
-	                             (expr, cli, expressionStr, oldValueStr);
+	                            (expr, cli, expressionStr, oldValueStr);
 	    task.requestAddWatchObserver
-	         (wpo, address, expr.getType().getSize(), writeOnly);		
+	         (wpo, variableAddress + (numberOfObservers-1)*watchLength, 
+	          variableLength-(numberOfObservers-1)*watchLength, writeOnly);
 	}       
     }
     
@@ -131,15 +156,14 @@ class WatchCommand extends ParameterizedCommand {
 	    
 	    String newValueStr = expr.getValue().toPrint
 	                         (Format.NATURAL, task.getMemory());
-	    cli.outWriter.println("Watchpoint hit: " + exprStr); 
-	    cli.outWriter.println(); 
-	    cli.outWriter.println("   Value before hit = " + oldValueStr);
-	    cli.outWriter.println("   Value after  hit = " + newValueStr);
-	    cli.outWriter.println(); 
+	    
+	    String watchMessage = "Watchpoint hit: " + exprStr + "\n" +
+	                          "   Value before hit = " + oldValueStr + "\n" +
+	                          "   Value after  hit = " + newValueStr + "\n";
 	    // Remember the previous value
 	    oldValueStr = newValueStr;
 
-	    cli.getSteppingEngine().blockedByActionPoint(task, this);
+	    cli.getSteppingEngine().blockedByActionPoint(task, this, watchMessage, cli.outWriter);
 	    task.requestUnblock(this);
 	    return Action.BLOCK;
 	}
diff --git a/frysk-core/frysk/pkglibdir/ChangeLog b/frysk-core/frysk/pkglibdir/ChangeLog
index 2092dc9..870ed2a 100644
--- a/frysk-core/frysk/pkglibdir/ChangeLog
+++ b/frysk-core/frysk/pkglibdir/ChangeLog
@@ -1,3 +1,7 @@
+2007-05-23 Teresa Thomas <tthomas@redhat.com>
+
+	* funit-ctypes.c: New file.
+	
 2008-05-15  Tim Moore  <timoore@redhat.com>
 
 	* funit-scopes-multi-file-b.c: Initialize a  pointer to function
diff --git a/frysk-core/frysk/pkglibdir/funit-ctypes.c b/frysk-core/frysk/pkglibdir/funit-ctypes.c
new file mode 100644
index 0000000..6a5e3fb
--- /dev/null
+++ b/frysk-core/frysk/pkglibdir/funit-ctypes.c
@@ -0,0 +1,63 @@
+// This file is part of the program FRYSK.
+//
+// Copyright 2007 Oracle Corporation.
+// Copyright 2007, Red Hat Inc.
+//
+// FRYSK is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// FRYSK is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with FRYSK; if not, write to the Free Software Foundation,
+// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+// 
+// In addition, as a special exception, Red Hat, Inc. gives You the
+// additional right to link the code of FRYSK with code not covered
+// under the GNU General Public License ("Non-GPL Code") and to
+// distribute linked combinations including the two, subject to the
+// limitations in this paragraph. Non-GPL Code permitted under this
+// exception must only link to the code of FRYSK through those well
+// defined interfaces identified in the file named EXCEPTION found in
+// the source code files (the "Approved Interfaces"). The files of
+// Non-GPL Code may instantiate templates or use macros or inline
+// functions from the Approved Interfaces without causing the
+// resulting work to be covered by the GNU General Public
+// License. Only Red Hat, Inc. may make changes or additions to the
+// list of Approved Interfaces. You must obey the GNU General Public
+// License in all respects for all of the FRYSK code and other code
+// used in conjunction with FRYSK except the Non-GPL Code covered by
+// this exception. If you modify this file, you may extend this
+// exception to your version of the file, but you are not obligated to
+// do so. If you do not wish to provide this exception without
+// modification, you must delete this exception statement from your
+// version and license this file solely under the GPL without
+// exception.
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+
+int array[4];
+int bigArray[9];
+float float_ = 0.0;
+double double_ = 0.0;
+long long long_long = 111;
+char char_ = 'A';
+
+int main(int argc, char* argv[])
+{
+  int k=0;  
+  for (k=0; k<4; k++)
+     array[k] = k;
+
+  double_ = 12.0;
+  long_long = 0x11223344aabbccddLL;
+  char_ = 'B';
+  	   
+  return 0;
+}
diff --git a/frysk-core/frysk/stepping/ChangeLog b/frysk-core/frysk/stepping/ChangeLog
index daba7fd..e158c8a 100644
--- a/frysk-core/frysk/stepping/ChangeLog
+++ b/frysk-core/frysk/stepping/ChangeLog
@@ -1,3 +1,8 @@
+2008-05-23    Teresa Thomas  <tthomas@redhat.com>
+
+	* SteppingEngine.java (messages): New.
+	(blockedByActionPoint(Task,TaskObserver,String,PrintWriter)): New.
+
 2008-04-17  Mark Wielaard  <mwielaard@redhat.com>
 
 	* TestStepping.java (testStepSigRaise): Don't mark unresolved #4237.
diff --git a/frysk-core/frysk/stepping/SteppingEngine.java b/frysk-core/frysk/stepping/SteppingEngine.java
index c380dd3..796d0b6 100644
--- a/frysk-core/frysk/stepping/SteppingEngine.java
+++ b/frysk-core/frysk/stepping/SteppingEngine.java
@@ -39,6 +39,7 @@
 
 package frysk.stepping;
 
+import java.io.PrintWriter;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -48,11 +49,15 @@ import java.util.ListIterator;
 import java.util.Map;
 import java.util.Observable;
 import java.util.Observer;
+import java.util.Set;
+
 import frysk.rsl.Log;
 import frysk.sys.ProcessIdentifier;
 import frysk.sys.ProcessIdentifierFactory;
 import lib.dwfl.DwflLine;
 import frysk.debuginfo.DebugInfoFrame;
+import frysk.event.ActionPointEvent;
+import frysk.event.Event;
 import frysk.event.RequestStopEvent;
 import frysk.proc.Action;
 import frysk.proc.Manager;
@@ -106,6 +111,9 @@ public class SteppingEngine {
     private LinkedList threadsList;
 
     private BreakpointManager breakpointManager;
+    
+    /* Set that keeps the list of actionpoint messages */
+    private static Set messages = new HashSet();
 
     public SteppingEngine() {
 	this.runningTasks = new HashSet();
@@ -979,7 +987,7 @@ public class SteppingEngine {
 	tse = (TaskStepEngine) this.taskStateMap.get(task);
 	tse.setState(new RunningState(task));
     }
-    
+
     /**
      * Sets the stepping engine on being hit by an action point.  
      * 
@@ -1007,6 +1015,45 @@ public class SteppingEngine {
     }
     
     /**
+     * Sets the stepping engine on being hit by an action point.  
+     * 
+     * to      - Observer that causes task to block.
+     * message - message describing the cause of program block
+     * writer  - writer to print message to
+     */    
+    public void blockedByActionPoint(Task task, TaskObserver to, 
+	                             String message, PrintWriter writer) {
+	
+	/* Set messages being empty implies the fist action point being hit.
+	 */
+	if (messages.isEmpty()) {
+	    
+	    // Schedule a done event on the first sight of an action point
+	    Event e = new ActionPointEvent(messages, writer);
+	    Manager.eventLoop.add(e);
+	    
+	    // Requests the addition of the stepping observer to task if 
+	    // not inserted already.
+	    if (!(task.isInstructionObserverAdded(this.steppingObserver))) {
+		task.requestAddInstructionObserver(this.steppingObserver);
+	    }
+
+	    // Add the observer to the task's blockers list
+	    addBlocker(task, to);
+
+	    TaskStepEngine tse = null;
+	    tse = (TaskStepEngine) this.taskStateMap.get(task);	
+	    if (!tse.isStopped()) {
+		// Set the state of task as stopped
+		tse.setState(new StoppedState(task));	
+		// Remove the task from the running tasks list      
+		this.runningTasks.remove(task);
+	    }
+	}
+	messages.add(message);
+    }
+    
+    /**
      * Adds the given Observer to this.steppingObserver's Observer list.
      * 
      * @param o The Observer to be added.
@@ -1420,4 +1467,4 @@ public class SteppingEngine {
 	}
 	return blockers;
     }
-}
+}
\ No newline at end of file


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


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

only message in thread, other threads:[~2008-05-23 18:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-23 18:16 [SCM] master: Add support for watching variables bigger than the max length a watch register can watch tthomas

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