public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: rmoseley@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: Merge branch 'master' of ssh://sources.redhat.com/git/frysk
Date: Sat, 17 Nov 2007 08:35:00 -0000	[thread overview]
Message-ID: <20071117083516.23475.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  c91caeb6b58115c176b57e419581084ee067888c (commit)
       via  b5cd3e0210e13f705c31ee46e992fbda3d61979f (commit)
      from  c9bca79bdca4785a6ca8209aaab7ffcf8ea24d1c (commit)

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

- Log -----------------------------------------------------------------
commit c91caeb6b58115c176b57e419581084ee067888c
Merge: b5cd3e0210e13f705c31ee46e992fbda3d61979f c9bca79bdca4785a6ca8209aaab7ffcf8ea24d1c
Author: Rick Moseley <rmoseley@redhat.com>
Date:   Sat Nov 17 02:35:03 2007 -0600

    Merge branch 'master' of ssh://sources.redhat.com/git/frysk
    
    Conflicts:
    
    	frysk-core/frysk/hpd/ChangeLog

commit b5cd3e0210e13f705c31ee46e992fbda3d61979f
Author: Rick Moseley <rmoseley@redhat.com>
Date:   Sat Nov 17 02:26:53 2007 -0600

    Implement load/run capability.
    
    * AttachCommand.java: Implement load/run capability.
    * CLI.java: Ditto.
    * LoadCommand.java: Ditto.
    * RunCommand.java: Ditto.
    * TestLoadCommand: Test new load/run capability.
    * ProcTaskIDManager.java(removeProcID,manageProcSelect): New.
    * fhpd.java: Fix bz #5256.
    * TestFhd.java(testHpdCommand): Ditto.

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

Summary of changes:
 frysk-core/frysk/bindir/ChangeLog          |    5 +++
 frysk-core/frysk/bindir/TestFhd.java       |    2 +-
 frysk-core/frysk/bindir/fhpd.java          |   13 ++-----
 frysk-core/frysk/hpd/AttachCommand.java    |    2 +-
 frysk-core/frysk/hpd/CLI.java              |   28 ++++++++++++---
 frysk-core/frysk/hpd/ChangeLog             |    8 ++++
 frysk-core/frysk/hpd/LoadCommand.java      |    8 +++-
 frysk-core/frysk/hpd/RunCommand.java       |   49 +++++++++++++++++++++++++--
 frysk-core/frysk/hpd/TestLoadCommand.java  |   27 +++++++++++++++-
 frysk-core/frysk/rt/ChangeLog              |    4 ++
 frysk-core/frysk/rt/ProcTaskIDManager.java |   16 +++++++++
 11 files changed, 138 insertions(+), 24 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog
index 3280ca7..69e9e03 100644
--- a/frysk-core/frysk/bindir/ChangeLog
+++ b/frysk-core/frysk/bindir/ChangeLog
@@ -1,3 +1,8 @@
+2007-11-16  Rick Moseley  <rmoseley@redhat.com>
+
+	* fhpd.java: Fix bz #5256.
+	* TestFhd.java(testHpdCommand): Ditto.
+
 2007-11-16  Phil Muldoon  <pmuldoon@redhat.com>
 
 	* fhpd.java(main): Add option -noexe. Append
diff --git a/frysk-core/frysk/bindir/TestFhd.java b/frysk-core/frysk/bindir/TestFhd.java
index 0a4865f..08d4fb1 100755
--- a/frysk-core/frysk/bindir/TestFhd.java
+++ b/frysk-core/frysk/bindir/TestFhd.java
@@ -81,7 +81,7 @@ public class TestFhd
 			   Config.getBinFile("fhpd").getPath(), 
 			   Config.getPkgLibFile("hpd-c").getPath() 
 		       });
-	e.expect(5, "Attached to process.*\n" + prompt);
+	e.expect(5, "Loaded executable file.*" + prompt);
 	e.close();
     }
   
diff --git a/frysk-core/frysk/bindir/fhpd.java b/frysk-core/frysk/bindir/fhpd.java
index f065cef..4012dd0 100644
--- a/frysk-core/frysk/bindir/fhpd.java
+++ b/frysk-core/frysk/bindir/fhpd.java
@@ -104,12 +104,7 @@ public class fhpd
 	core = corePairs[0].coreFile;
 	exeFile = corePairs[0].exeFile;
     }
-    
-  
-      
-      
     };
-    
     parser.add(new Option("noexe", "Do not attempt to read an"+
 	" executable for a corefile ") {
 	public void parsed(String exeValue) throws OptionException {
@@ -121,10 +116,10 @@ public class fhpd
 				      + exeValue);
 	  }
 	}
-      });
-    parser.setHeader("Usage: fhpd <PID> || fhpd <COREFILE> [<EXEFILE>]");
-    parser.parse(args);
+    });
     
+    parser.setHeader("Usage: fhpd <PID> || fhpd <EXEFILE> || fhpd <COREFILE> [<EXEFILE>]");
+    parser.parse(args);
     Manager.eventLoop.start();
     String line = "";
     
@@ -133,7 +128,7 @@ public class fhpd
       if (pid > 0)
         line = "attach " + pid;
       else if (execFile != null)
-        line = "run " + execFile.getCanonicalPath();
+        line = "load " + execFile.getCanonicalPath();
       else if (core != null) {
 	  line = "core " + core.getCanonicalPath();      
 	  if (exeFile != null)
diff --git a/frysk-core/frysk/hpd/AttachCommand.java b/frysk-core/frysk/hpd/AttachCommand.java
index 69c2ba2..dd3e519 100644
--- a/frysk-core/frysk/hpd/AttachCommand.java
+++ b/frysk-core/frysk/hpd/AttachCommand.java
@@ -100,7 +100,7 @@ class AttachCommand extends ParameterizedCommand {
 		cli.outWriter.println(pid);
 		continue;
 	    }
-	    cli.doAttach(findProc.proc);
+	    cli.doAttach(findProc.proc, -1);
 	}
     }
 
diff --git a/frysk-core/frysk/hpd/CLI.java b/frysk-core/frysk/hpd/CLI.java
index d7fcf07..2134399 100644
--- a/frysk-core/frysk/hpd/CLI.java
+++ b/frysk-core/frysk/hpd/CLI.java
@@ -69,6 +69,8 @@ public class CLI {
     CountDownLatch attachedLatch;
     //Processes started with run command
     final HashSet runningProcs = new HashSet();
+    //Processes loaded with load command
+    final HashSet loadedProcs = new HashSet();
 
     private class TaskInfo {
         DebugInfoFrame frame;
@@ -125,14 +127,14 @@ public class CLI {
 	} catch (RuntimeException e) {
 	    if (nasty(e))
 		e.printStackTrace(outWriter);
-	    return -1;		
+	    return -1;
 	}
     }
 
     /*
      * Command handlers
      */
-    public void doAttach(Proc proc) {
+    public void doAttach(Proc proc, int procID) {
         synchronized (this) {
             attached = -1;
             attachedLatch = new CountDownLatch(1);
@@ -144,7 +146,7 @@ public class CLI {
 	    outWriter.print("Attached to process ");
 	    outWriter.println(attached);
         } catch (InterruptedException ie) {
-	    throw new RuntimeException("attachLatch interrupted");
+            throw new RuntimeException("attachLatch interrupted");
         } finally {
             synchronized (this) {
                 attached = -1;
@@ -152,7 +154,12 @@ public class CLI {
             }
         }
         steppingEngine.getBreakpointManager().manageProcess(proc);
-        idManager.manageProc(proc, idManager.reserveProcID());
+        // If passed a taskID < 0, request a reserved ProcID
+        if (procID < 0)
+            idManager.manageProc(proc, idManager.reserveProcID());
+        // Assign this proc to the passed in procID 
+        else
+            idManager.manageProcSelect(proc, procID);
     }
 
     final PrintWriter outWriter;
@@ -255,13 +262,13 @@ public class CLI {
                 }
             }
             catch (RuntimeException e) {
-		printError(e);
+                printError(e);
             }
             flushMessages();
         }
         return null;
     }
-
+    
     /**
      * Identify "nasty", or internal exceptions; these are the
      * RuntimeExceptions thrown by the Java system.
@@ -435,6 +442,15 @@ public class CLI {
         return runningProcs;
     }
  
+    /**
+     * Get the set of processes (Proc) started by the load command. Access to the
+     * CLI object should be synchronized when using the set.
+     * @return the set
+     */
+    public HashSet getLoadedProcs() {
+        return loadedProcs;
+    }
+    
     SteppingEngine getSteppingEngine () {
         return this.steppingEngine;
     }
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index b5690a0..e743c96 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,11 @@
+2007-11-16  Rick Moseley  <rmoseley@redhat.com>
+
+	* AttachCommand.java: Implement load/run capability.
+	* CLI.java: Ditto.
+	* LoadCommand.java: Ditto.
+	* RunCommand.java: Ditto.
+	* TestLoadCommand: Test new load/run capability.
+	
 2007-11-16  Stan Cox  <scox@redhat.com>
 
 	* TestListCommand.java (testListPC): Use sendCommandExpectPrompt.
diff --git a/frysk-core/frysk/hpd/LoadCommand.java b/frysk-core/frysk/hpd/LoadCommand.java
index cbad88d..d3f61e9 100644
--- a/frysk-core/frysk/hpd/LoadCommand.java
+++ b/frysk-core/frysk/hpd/LoadCommand.java
@@ -70,9 +70,10 @@ public class LoadCommand extends ParameterizedCommand {
 
 	File executableFile = new File(cmd.parameter(0));
 
-	if (!executableFile.exists() || !executableFile.canRead()) {
+	if (!executableFile.exists() || !executableFile.canRead()
+		|| !executableFile.isFile()) {
 	    throw new InvalidCommandException
-		("File does not exist or is not readable.");
+		("File does not exist or is not readable or is not a file.");
 	}
 
 	Host exeHost = new LinuxExeHost(Manager.eventLoop, executableFile);
@@ -97,6 +98,9 @@ public class LoadCommand extends ParameterizedCommand {
 			frame));
 	    }
 	}
+	synchronized (cli) {
+	    cli.getLoadedProcs().add(exeProc);
+	}
     }
 
 
diff --git a/frysk-core/frysk/hpd/RunCommand.java b/frysk-core/frysk/hpd/RunCommand.java
index f50feb3..2fec965 100644
--- a/frysk-core/frysk/hpd/RunCommand.java
+++ b/frysk-core/frysk/hpd/RunCommand.java
@@ -48,6 +48,7 @@ import frysk.proc.Task;
 import frysk.proc.TaskObserver;
 import frysk.util.CountDownLatch;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 
 class RunCommand extends Command {
@@ -116,10 +117,44 @@ class RunCommand extends Command {
     }
 
     public void interpret(CLI cli, Input cmd) {
+	/* If the run command is given no args, check to see if 
+	   any procs were loaded with the load command or loaded
+	   when fhpd was started */
 	if (cmd.size() < 1) {
-	    // XXX: should default to previous values.
-	    throw new InvalidCommandException("missing program");
+	    if (cli.runningProcs.isEmpty() && cli.loadedProcs.isEmpty())
+		throw new InvalidCommandException("missing program");
 	}
+	
+	// If a parameter was given the run command, go ahead and run it
+	if (cmd.size() >= 1) {
+	    run(cli, cmd);
+	    return;
+	}
+	
+	/* If we made it here, a run command was given with no parameters
+	 * and there are either running procs or loaded procs
+	 */
+	
+	/* This is the case where there are loaded procs */
+	if (!cli.loadedProcs.isEmpty()) {
+	    Iterator foo = cli.targetset.getTasks();
+	    while (foo.hasNext()) {
+		Task task = (Task) foo.next();
+		int taskID = cli.idManager.getProcID(task.getProc());
+		cli.execCommand("run " + task.getProc().getExe() + " " +
+			Integer.toString(taskID));
+	    }
+	    // Clear all of the loaded procs now that they have been run
+	    synchronized(cli) {
+		cli.loadedProcs.clear();
+	    }
+	}
+	// Found no loaded procs, print usage message
+	// XXX Need to fix, add core files and running proc handling
+	else throw new InvalidCommandException("missing program");  
+    }
+	
+    private void run(CLI cli, Input cmd) {
 	Runner runner = new Runner(cli);
 	Manager.host.requestCreateAttachedProc(cmd.stringArrayValue(), runner);
         try {
@@ -128,10 +163,16 @@ class RunCommand extends Command {
             return;
         }
         // register with SteppingEngine et.al.
-	cli.doAttach(runner.launchedTask.getProc());
+        // If a second parameter was passed, it was a specific ProcTaskID to use
+        if (cmd.size() > 1)
+            cli.doAttach(runner.launchedTask.getProc(), 
+        	    Integer.parseInt(cmd.parameter(1)));
+        // If not, pass a -1 so a new ProcTaskID will be assigned
+        else
+            cli.doAttach(runner.launchedTask.getProc(), -1);
 	runner.launchedTask.requestUnblock(runner);
     }
-
+    
     int complete(CLI cli, Input input, int cursor, List completions) {
 	return CompletionFactory.completeFileName(cli, input, cursor,
 						  completions);
diff --git a/frysk-core/frysk/hpd/TestLoadCommand.java b/frysk-core/frysk/hpd/TestLoadCommand.java
index 467ccbc..10eeee4 100644
--- a/frysk-core/frysk/hpd/TestLoadCommand.java
+++ b/frysk-core/frysk/hpd/TestLoadCommand.java
@@ -59,7 +59,32 @@ public class TestLoadCommand extends TestLib {
 	e = new HpdTestbed();
 	e.send("load " + Config.getPkgDataFile("test-exe-x86").getPath()
 		+ "foo\n");
-	e.expect(5, "File does not exist or is not readable.*");
+	e.expect(5, "File does not exist or is not readable*");
+	e.close();
+    }
+    
+    public void testLoadRun() {
+	e = new HpdTestbed();
+	e.send("load " + Config.getPkgLibFile("funit-hello").getPath()
+		+ "\n");
+	e.expect(5, "Loaded executable file.*" + prompt);
+	e.send("focus\n");
+	e.expect(5, "Target set*");
+	e.expect(5, "[0.0]*0*0*");
+	e.send("load " + Config.getPkgLibFile("funit-hello").getPath()
+		+ "\n");
+	e.expect(5, "Loaded executable file.*" + prompt);
+	e.send("focus\n");
+	e.expect(5, "Target set*");
+	e.expect(5, "[0.0]*0*0*");
+	e.expect(5, "[1.0]*0*0*" + prompt);
+	e.send("run\n");
+	e.expect(5, "Attached to process*");
+	e.expect(5, "Attached to process*");
+	e.send("focus\n");
+	e.expect(5, "Target set*");
+	e.expect(5, "[0.0]*");
+	e.expect(5, "[1.0]*" + prompt);
 	e.close();
     }
 }
diff --git a/frysk-core/frysk/rt/ChangeLog b/frysk-core/frysk/rt/ChangeLog
index f1f42ec..b7ac848 100644
--- a/frysk-core/frysk/rt/ChangeLog
+++ b/frysk-core/frysk/rt/ChangeLog
@@ -1,3 +1,7 @@
+2007-11-16  Rick Moseley  <rmoseley@redhat.com>
+
+	* ProcTaskIDManager.java(removeProcID,manageProcSelect): New.
+
 2007-11-06  Tim Moore  <timoore@redhat.com>
     
     	* BreakpointManager.java (refreshBreakpoints): Enable breakpoint
diff --git a/frysk-core/frysk/rt/ProcTaskIDManager.java b/frysk-core/frysk/rt/ProcTaskIDManager.java
index d24086f..1e8934e 100644
--- a/frysk-core/frysk/rt/ProcTaskIDManager.java
+++ b/frysk-core/frysk/rt/ProcTaskIDManager.java
@@ -87,6 +87,15 @@ public class ProcTaskIDManager
         procList.add(null);
         return result;
     }
+    
+    public void manageProcSelect(Proc proc, int usedID) {
+	ProcEntry entry;
+	synchronized (this) {
+	    entry = new ProcEntry(proc, usedID);
+	    procList.set(usedID, entry);
+	    procMap.put(proc, new Integer(usedID));
+	}
+    }
 
     public void manageProc(Proc proc, int reservedID) {
         ProcEntry entry;
@@ -103,6 +112,13 @@ public class ProcTaskIDManager
         else
             return null;
     }
+    
+    public synchronized boolean removeProcID(int id) {
+	if (id > procList.size() || id < 0)
+	    return false;
+	procList.remove(id);
+	return true;
+    }
 
     public synchronized int getProcID(Proc proc) {
         Integer result = (Integer)procMap.get(proc);


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


             reply	other threads:[~2007-11-17  8:35 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-17  8:35 rmoseley [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-06-05 15:33 rmoseley
2008-05-12 16:30 rmoseley
2008-05-12 16:07 pmuldoon
2008-05-09 17:29 rmoseley
2008-04-02 22:41 pmuldoon
2008-04-01 12:28 pmuldoon
2008-03-20 20:20 rmoseley
2008-03-18 16:22 pmuldoon
2008-02-26 15:32 pmuldoon
2008-01-24 19:23 rmoseley
2008-01-23 21:10 rmoseley
2008-01-03 16:55 pmuldoon
2007-12-13 20:18 rmoseley
2007-12-04 17:45 jflavio
2007-11-30  4:24 jflavio
2007-11-28 21:40 jflavio
2007-11-28 16:20 jflavio
2007-11-28 13:08 pmuldoon
2007-11-28 12:04 mark
2007-11-20 22:47 scox
2007-11-19 17:58 scox
2007-11-16 15:59 scox
2007-11-16 14:59 pmuldoon
2007-11-14  2:38 scox
2007-11-14  2:09 jflavio
2007-11-13  0:41 scox
2007-11-10 14:47 jflavio
2007-11-10  0:34 scox
2007-11-09 14:59 jflavio

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=20071117083516.23475.qmail@sourceware.org \
    --to=rmoseley@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: link
Be 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).