From: brian Date: Wed, 5 May 2004 02:32:11 +0000 (-0700) Subject: no more fixmes X-Git-Tag: merge~22 X-Git-Url: http://git.megacz.com/?p=nestedvm.git;a=commitdiff_plain;h=ba59dfdff778e2a1b0dbe38b19534a8e775f4a4b no more fixmes darcs-hash:20040505023211-24bed-a7954030b968b94251df2ec12e06081ae66971a1.gz --- diff --git a/src/org/ibex/nestedvm/Runtime.java b/src/org/ibex/nestedvm/Runtime.java index fc97e71..2f23d1c 100644 --- a/src/org/ibex/nestedvm/Runtime.java +++ b/src/org/ibex/nestedvm/Runtime.java @@ -9,6 +9,9 @@ import java.io.*; import java.util.Arrays; public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { + /** True to write useful diagnostic information to stderr when things go wrong */ + final static boolean STDERR_DIAG = true; + /** Number of bits to shift to get the page number (1<<= OPEN_MAX) return -EBADFD; if(fds[fdn] == null) return -EBADFD; byte[] buf = byteBuf(count); copyin(addr,buf,count); - return fds[fdn].write(buf,0,count); + try { + return fds[fdn].write(buf,0,count); + } catch(ErrnoException e) { + if(e.errno == EPIPE) sys_exit(128+13); + throw e; + } } /** The read syscall */ @@ -864,7 +870,7 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { switch(n) { case _SC_CLK_TCK: return 1000; default: - System.err.println("WARNING: Attempted to use unknown sysconf key: " + n); + if(STDERR_DIAG) System.err.println("WARNING: Attempted to use unknown sysconf key: " + n); return -EINVAL; } } @@ -887,7 +893,7 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { try { for(int i=start;i= gd.tasks.length)) return -ECHILD; + if(pid !=-1 && (pid <= 0 || pid >= gs.tasks.length)) return -ECHILD; if(children == null) return blocking ? -ECHILD : 0; UnixRuntime done = null; @@ -166,7 +165,7 @@ public abstract class UnixRuntime extends Runtime implements Cloneable { if(pid == -1) { if(exitedChildren.size() > 0) done = (UnixRuntime)exitedChildren.remove(exitedChildren.size() - 1); } else if(pid > 0) { - UnixRuntime t = gd.tasks[pid]; + UnixRuntime t = gs.tasks[pid]; if(t.parent != this) return -ECHILD; if(t.state == EXITED) { if(!exitedChildren.remove(t)) throw new Error("should never happen"); @@ -179,9 +178,9 @@ public abstract class UnixRuntime extends Runtime implements Cloneable { if(done == null) { if(!blocking) return 0; try { children.wait(); } catch(InterruptedException e) {} - System.err.println("waitpid woke up: " + exitedChildren.size()); + //System.err.println("waitpid woke up: " + exitedChildren.size()); } else { - gd.tasks[done.pid] = null; + gs.tasks[done.pid] = null; break; } } @@ -195,7 +194,7 @@ public abstract class UnixRuntime extends Runtime implements Cloneable { if(children != null) synchronized(children) { for(Enumeration e = exitedChildren.elements(); e.hasMoreElements(); ) { UnixRuntime child = (UnixRuntime) e.nextElement(); - gd.tasks[child.pid] = null; + gs.tasks[child.pid] = null; } exitedChildren.clear(); for(Enumeration e = activeChildren.elements(); e.hasMoreElements(); ) { @@ -207,11 +206,11 @@ public abstract class UnixRuntime extends Runtime implements Cloneable { UnixRuntime _parent = parent; if(_parent == null) { - gd.tasks[pid] = null; + gs.tasks[pid] = null; } else { synchronized(_parent.children) { if(parent == null) { - gd.tasks[pid] = null; + gs.tasks[pid] = null; } else { parent.activeChildren.remove(this); parent.exitedChildren.add(this); @@ -251,7 +250,7 @@ public abstract class UnixRuntime extends Runtime implements Cloneable { return -ENOMEM; } - System.err.println("fork " + pid + " -> " + r.pid + " tasks[" + r.pid + "] = " + gd.tasks[r.pid]); + //System.err.println("fork " + pid + " -> " + r.pid + " tasks[" + r.pid + "] = " + gd.tasks[r.pid]); if(children == null) { children = new Object(); activeChildren = new Vector(); @@ -282,7 +281,7 @@ public abstract class UnixRuntime extends Runtime implements Cloneable { for(;;) { for(;;) { if(r.execute()) break; - System.err.println("WARNING: Pause requested while executing runAndExec()"); + if(STDERR_DIAG) System.err.println("WARNING: Pause requested while executing runAndExec()"); } if(r.state != EXECED) return r.exitStatus(); r = r.execedRuntime; @@ -304,7 +303,7 @@ public abstract class UnixRuntime extends Runtime implements Cloneable { private int exec(String normalizedPath, String[] argv, String[] envp) throws ErrnoException { if(argv.length == 0) argv = new String[]{""}; - Object o = gd.exec(this,normalizedPath); + Object o = gs.exec(this,normalizedPath); if(o == null) return -ENOENT; if(o instanceof Class) { @@ -330,7 +329,7 @@ public abstract class UnixRuntime extends Runtime implements Cloneable { private int exec(UnixRuntime r, String[] argv, String[] envp) { - System.err.println("Execing " + r); + //System.err.println("Execing " + r); for(int i=0;i " + path + " pwd: " + cwd); - if(gd.stat(this,path).type() != FStat.S_IFDIR) return -ENOTDIR; + //System.err.println("Chdir: " + cstring(addr) + " -> " + path + " pwd: " + cwd); + if(gs.stat(this,path).type() != FStat.S_IFDIR) return -ENOTDIR; cwd = path; - System.err.println("Now: [" + cwd + "]"); + //System.err.println("Now: [" + cwd + "]"); return 0; } @@ -508,7 +555,7 @@ public abstract class UnixRuntime extends Runtime implements Cloneable { path = path.substring(1); int p; for(p=0;p 0) outp--; while(outp > 0 && out[outp] != '/') outp--; - System.err.println("After ..: " + new String(out,0,outp)); + //System.err.println("After ..: " + new String(out,0,outp)); continue; } inp++;