Index: frysk-core/frysk/bindir/ftrace.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/bindir/ftrace.java,v retrieving revision 1.18 diff -u -r1.18 ftrace.java --- frysk-core/frysk/bindir/ftrace.java 7 Aug 2006 20:22:15 -0000 1.18 +++ frysk-core/frysk/bindir/ftrace.java 13 Sep 2006 11:48:36 -0000 @@ -144,7 +144,9 @@ System.out.println("Got task exception " + e); return Action.CONTINUE; } - frysk.proc.Syscall syscall = frysk.proc.Syscall.syscallByNum(syscallEventInfo.number(task)); + + frysk.proc.Syscall syscall = syscallEventInfo.getSyscall(task); + PrintWriter printWriter = new PrintWriter(System.out); printWriter.print(task.getProc().getPid() + "." + task.getTid() + " "); syscall.printCall(printWriter, task, syscallEventInfo); @@ -165,7 +167,8 @@ System.out.println("Got task exception " + e); return Action.CONTINUE; } - frysk.proc.Syscall syscall = frysk.proc.Syscall.syscallByNum(syscallEventInfo.number(task)); + frysk.proc.Syscall syscall = syscallEventInfo.getSyscall(task); + PrintWriter printWriter = new PrintWriter(System.out); syscall.printReturn(printWriter, task, syscallEventInfo); printWriter.flush(); Index: frysk-core/frysk/proc/Isa.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/proc/Isa.java,v retrieving revision 1.11 diff -u -r1.11 Isa.java --- frysk-core/frysk/proc/Isa.java 23 Aug 2006 04:04:19 -0000 1.11 +++ frysk-core/frysk/proc/Isa.java 13 Sep 2006 11:48:36 -0000 @@ -39,6 +39,7 @@ package frysk.proc; +import java.util.HashMap; import java.util.Iterator; import inua.eio.ByteOrder; @@ -95,4 +96,13 @@ //{ //throw new RuntimeException ("not implemented"); //} + + /** @return Syscall[] return system call list for this Linux. */ + Syscall[] getSyscallList (); + /** @return HashMap return a HashMap for unknown system calls. */ + HashMap getUnknownSyscalls (); + + /** @return Syscall return system call object if the name could be + * found in syscallList, otherwise return null. */ + Syscall syscallByName (String Name); } Index: frysk-core/frysk/proc/IsaEMT64.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/proc/IsaEMT64.java,v retrieving revision 1.4 diff -u -r1.4 IsaEMT64.java --- frysk-core/frysk/proc/IsaEMT64.java 29 Aug 2006 05:35:43 -0000 1.4 +++ frysk-core/frysk/proc/IsaEMT64.java 13 Sep 2006 11:48:36 -0000 @@ -39,6 +39,7 @@ package frysk.proc; +import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import inua.eio.ByteOrder; @@ -165,4 +166,19 @@ return pcValue; } + + public Syscall[] getSyscallList () + { + return LinuxEMT64Syscall.syscallList; + } + + public HashMap getUnknownSyscalls () + { + return LinuxEMT64Syscall.unknownSyscalls; + } + + public Syscall syscallByName (String name) + { + return Syscall.iterateSyscallByName (name, LinuxEMT64Syscall.syscallList); + } } Index: frysk-core/frysk/proc/IsaIA32.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/proc/IsaIA32.java,v retrieving revision 1.4 diff -u -r1.4 IsaIA32.java --- frysk-core/frysk/proc/IsaIA32.java 29 Aug 2006 05:35:43 -0000 1.4 +++ frysk-core/frysk/proc/IsaIA32.java 13 Sep 2006 11:48:36 -0000 @@ -39,6 +39,7 @@ package frysk.proc; +import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import inua.eio.ByteOrder; @@ -172,6 +173,33 @@ return pcValue; } -} + public Syscall[] getSyscallList () + { + return LinuxIa32Syscall.syscallList; + } + + public HashMap getUnknownSyscalls () + { + return LinuxIa32Syscall.unknownSyscalls; + } + + public Syscall syscallByName (String name) + { + Syscall syscall; + + syscall = Syscall.iterateSyscallByName (name, LinuxIa32Syscall.syscallList); + if (syscall != null) + return syscall; + + syscall = Syscall.iterateSyscallByName (name, LinuxIa32Syscall.socketSubcallList); + if (syscall != null) + return syscall; + syscall = Syscall.iterateSyscallByName (name, LinuxIa32Syscall.ipcSubcallList); + if (syscall != null) + return syscall; + + return null; + } +} Index: frysk-core/frysk/proc/IsaPPC.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/proc/IsaPPC.java,v retrieving revision 1.2 diff -u -r1.2 IsaPPC.java --- frysk-core/frysk/proc/IsaPPC.java 23 Aug 2006 04:04:19 -0000 1.2 +++ frysk-core/frysk/proc/IsaPPC.java 13 Sep 2006 11:48:36 -0000 @@ -1,7 +1,45 @@ // This file is part of the program FRYSK. +// +// Copyright 2006 IBM Corp. +// +// 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. package frysk.proc; +import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; @@ -109,4 +147,33 @@ { throw new RuntimeException("unsupported architecture: " + this); } + + public Syscall[] getSyscallList () + { + return LinuxPowerPCSyscall.syscallList; + } + + public HashMap getUnknownSyscalls () + { + return LinuxPowerPCSyscall.unknownSyscalls; + } + + public Syscall syscallByName (String name) + { + Syscall syscall; + + syscall = Syscall.iterateSyscallByName (name, LinuxPowerPCSyscall.syscallList); + if (syscall != null) + return syscall; + + syscall = Syscall.iterateSyscallByName (name, LinuxPowerPCSyscall.socketSubcallList); + if (syscall != null) + return syscall; + + syscall = Syscall.iterateSyscallByName (name, LinuxPowerPCSyscall.ipcSubcallList); + if (syscall != null) + return syscall; + + return null; + } } Index: frysk-core/frysk/proc/IsaPPC64.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/proc/IsaPPC64.java,v retrieving revision 1.5 diff -u -r1.5 IsaPPC64.java --- frysk-core/frysk/proc/IsaPPC64.java 29 Aug 2006 05:35:43 -0000 1.5 +++ frysk-core/frysk/proc/IsaPPC64.java 13 Sep 2006 11:48:37 -0000 @@ -1,7 +1,44 @@ // This file is part of the program FRYSK. - +// +// Copyright 2006 IBM Corp. +// +// 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. package frysk.proc; +import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; @@ -140,4 +177,33 @@ return pcValue; } + + public Syscall[] getSyscallList () + { + return LinuxPowerPCSyscall.syscallList; + } + + public HashMap getUnknownSyscalls () + { + return LinuxPowerPCSyscall.unknownSyscalls; + } + + public Syscall syscallByName (String name) + { + Syscall syscall; + + syscall = Syscall.iterateSyscallByName (name, LinuxPowerPCSyscall.syscallList); + if (syscall != null) + return syscall; + + syscall = Syscall.iterateSyscallByName (name, LinuxPowerPCSyscall.socketSubcallList); + if (syscall != null) + return syscall; + + syscall = Syscall.iterateSyscallByName (name, LinuxPowerPCSyscall.ipcSubcallList); + if (syscall != null) + return syscall; + + return null; + } } Index: frysk-core/frysk/proc/LinuxEMT64.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/proc/LinuxEMT64.java,v retrieving revision 1.2 diff -u -r1.2 LinuxEMT64.java --- frysk-core/frysk/proc/LinuxEMT64.java 11 Jul 2006 21:25:25 -0000 1.2 +++ frysk-core/frysk/proc/LinuxEMT64.java 13 Sep 2006 11:48:37 -0000 @@ -39,53 +39,40 @@ package frysk.proc; +import java.util.HashMap; + class LinuxEMT64 - extends IsaEMT64 implements SyscallEventDecoder + extends IsaEMT64 implements SyscallEventDecoder { - private static LinuxEMT64 isa; - static LinuxEMT64 isaSingleton () - { - if (isa == null) - isa = new LinuxEMT64 (); - return isa; - } + private static LinuxEMT64 isa; + static LinuxEMT64 isaSingleton () + { + if (isa == null) + isa = new LinuxEMT64 (); + return isa; + } + + // This is used to keep track of syscalls whose number we do not + // know. + static HashMap unknownSyscalls; - private SyscallEventInfo info; - public SyscallEventInfo getSyscallEventInfo () - { - if (info == null) - info = new SyscallEventInfo () - { - public int number (Task task) - { - return (int)getRegisterByName ("orig_rax").get (task); - } - public long returnCode (Task task) - { - return getRegisterByName ("rax").get (task); - } - public long arg (Task task, int n) - { - switch (n) { - case 0: - return (long)number (task); - case 1: - return getRegisterByName("rdi").get (task); - case 2: - return getRegisterByName("rsi").get (task); - case 3: - return getRegisterByName("rdx").get (task); - case 4: - return getRegisterByName("r10").get (task); - case 5: - return getRegisterByName("r8").get (task); - case 6: - return getRegisterByName("r9").get (task); - default: - throw new RuntimeException ("unknown syscall arg"); - } - } - }; - return info; - } + private SyscallEventInfo info; + + public SyscallEventInfo getSyscallEventInfo () + { + if (info == null) + info = new SyscallEventInfo () + { + public int number (Task task) + { + return (int)getRegisterByName ("orig_rax").get (task); + } + public Syscall getSyscall(Task task) + { + int number = this.number(task); + return LinuxEMT64Syscall.syscallByNum (task, number); + } + }; + return info; + } } Index: frysk-core/frysk/proc/LinuxIa32.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/proc/LinuxIa32.java,v retrieving revision 1.8 diff -u -r1.8 LinuxIa32.java --- frysk-core/frysk/proc/LinuxIa32.java 11 Jul 2006 21:25:25 -0000 1.8 +++ frysk-core/frysk/proc/LinuxIa32.java 13 Sep 2006 11:48:37 -0000 @@ -40,52 +40,33 @@ package frysk.proc; class LinuxIa32 - extends IsaIA32 implements SyscallEventDecoder + extends IsaIA32 implements SyscallEventDecoder { - private static LinuxIa32 isa; - static LinuxIa32 isaSingleton () - { - if (isa == null) - isa = new LinuxIa32 (); - return isa; - } + private static LinuxIa32 isa; + static LinuxIa32 isaSingleton () + { + if (isa == null) + isa = new LinuxIa32 (); + return isa; + } + + private SyscallEventInfo info; + public SyscallEventInfo getSyscallEventInfo () + { + if (info == null) + info = new SyscallEventInfo () + { + public int number (Task task) + { + return (int)getRegisterByName ("orig_eax").get (task); + } + public Syscall getSyscall(Task task) + { + int number = this.number(task); + return LinuxIa32Syscall.syscallByNum (task, number); + } + }; + return info; + } - private SyscallEventInfo info; - public SyscallEventInfo getSyscallEventInfo () - { - if (info == null) - info = new SyscallEventInfo () - { - public int number (Task task) - { - return (int)getRegisterByName ("orig_eax").get (task); - } - public long returnCode (Task task) - { - return getRegisterByName ("eax").get (task); - } - public long arg (Task task, int n) - { - switch (n) { - case 0: - return (long)number (task); - case 1: - return getRegisterByName("ebx").get (task); - case 2: - return getRegisterByName("ecx").get (task); - case 3: - return getRegisterByName("edx").get (task); - case 4: - return getRegisterByName("esi").get (task); - case 5: - return getRegisterByName("edi").get (task); - case 6: - return getRegisterByName("eax").get (task); - default: - throw new RuntimeException ("unknown syscall arg"); - } - } - }; - return info; - } } Index: frysk-core/frysk/proc/LinuxPPC.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/proc/LinuxPPC.java,v retrieving revision 1.4 diff -u -r1.4 LinuxPPC.java --- frysk-core/frysk/proc/LinuxPPC.java 11 Sep 2006 20:50:39 -0000 1.4 +++ frysk-core/frysk/proc/LinuxPPC.java 13 Sep 2006 11:48:37 -0000 @@ -2,13 +2,15 @@ package frysk.proc; +import java.util.HashMap; + import java.util.logging.Level; import java.util.logging.Logger; class LinuxPPC extends IsaPPC implements SyscallEventDecoder { - private static Logger logger = Logger.getLogger ("frysk");//.proc"); + private static Logger logger = Logger.getLogger ("frysk");//.proc"); private static LinuxPPC isa; static LinuxPPC isaSingleton () @@ -18,6 +20,10 @@ return isa; } + // This is used to keep track of syscalls whose number we do not + // know. + static HashMap unknownSyscalls; + private SyscallEventInfo info; public SyscallEventInfo getSyscallEventInfo () @@ -30,38 +36,13 @@ logger.log (Level.FINE, "Get GPR0 {0}\n", getRegisterByName("gpr0")); return (int)getRegisterByName("gpr0").get(task); } - public long returnCode (Task task) - { - int flag = (int) getRegisterByName("ccr").get(task); - - if ((flag & 0x10000000) != 0) - return -getRegisterByName("gpr3").get(task); - else - return getRegisterByName("gpr3").get(task); - } - public long arg (Task task, int n) - { - switch (n) - { - case 0: - return (long)number(task); - case 1: - return getRegisterByName("orig_r3").get(task); - case 2: - return getRegisterByName("gpr4").get(task); - case 3: - return getRegisterByName("gpr5").get(task); - case 4: - return getRegisterByName("gpr6").get(task); - case 5: - return getRegisterByName("gpr7").get(task); - case 6: - return getRegisterByName("gpr8").get(task); - default: - throw new RuntimeException ("unknown syscall arg"); - } - } + public Syscall getSyscall(Task task) + { + int number = this.number(task); + return LinuxPowerPCSyscall.syscallByNum (task, number); + } }; return info; } -} \ No newline at end of file + +} Index: frysk-core/frysk/proc/LinuxPPC64.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/proc/LinuxPPC64.java,v retrieving revision 1.4 diff -u -r1.4 LinuxPPC64.java --- frysk-core/frysk/proc/LinuxPPC64.java 11 Sep 2006 20:50:39 -0000 1.4 +++ frysk-core/frysk/proc/LinuxPPC64.java 13 Sep 2006 11:48:37 -0000 @@ -2,13 +2,14 @@ package frysk.proc; +import java.util.HashMap; import java.util.logging.Level; import java.util.logging.Logger; class LinuxPPC64 extends IsaPPC64 implements SyscallEventDecoder { - private static Logger logger = Logger.getLogger ("frysk");//.proc"); + private static Logger logger = Logger.getLogger ("frysk");//.proc"); private static LinuxPPC64 isa; static LinuxPPC64 isaSingleton () @@ -18,6 +19,10 @@ return isa; } + // This is used to keep track of syscalls whose number we do not + // know. + static HashMap unknownSyscalls; + private SyscallEventInfo info; public SyscallEventInfo getSyscallEventInfo () { @@ -29,36 +34,13 @@ logger.log (Level.FINE, "Get GPR0 {0}\n",getRegisterByName("gpr0")); return (int)getRegisterByName("gpr0").get(task); } - public long returnCode (Task task) - { - int flag = (int)getRegisterByName("ccr").get(task); - if ((flag & 0x10000000) != 0) - return -getRegisterByName("gpr3").get(task); - else - return getRegisterByName("gpr3").get(task); - } - public long arg (Task task, int n) + + public Syscall getSyscall(Task task) { - switch (n) - { - case 0: - return (long)number (task); - case 1: - return getRegisterByName("orig_r3").get(task); - case 2: - return getRegisterByName("gpr4").get(task); - case 3: - return getRegisterByName("gpr5").get(task); - case 4: - return getRegisterByName("gpr6").get(task); - case 5: - return getRegisterByName("gpr7").get(task); - case 6: - return getRegisterByName("gpr8").get(task); - default: - throw new RuntimeException ("unknown syscall arg"); - } - } + int number = this.number(task); + return LinuxPowerPCSyscall.syscallByNum (task, number); + } + }; return info; } Index: frysk-core/frysk/proc/Syscall.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/proc/Syscall.java,v retrieving revision 1.12 diff -u -r1.12 Syscall.java --- frysk-core/frysk/proc/Syscall.java 6 Sep 2006 15:28:32 -0000 1.12 +++ frysk-core/frysk/proc/Syscall.java 13 Sep 2006 11:48:37 -0000 @@ -38,6 +38,7 @@ // exception. package frysk.proc; +import java.util.HashMap; import inua.util.PrintWriter; /** @@ -45,7 +46,7 @@ * used in combination with {@link SyscallEventInfo} and the * task to get information about a particular system call event. */ -public class Syscall +public abstract class Syscall { int number; public final int numArgs; @@ -96,23 +97,32 @@ { return number; } - - private void printStringArg (PrintWriter writer, - frysk.proc.Task task, - long addr) + /** Return true if this object equals the argument. */ + public boolean equals(Object other) { - if (addr == 0) - writer.print ("0x0"); - else { - writer.print ("\""); - StringBuffer x = new StringBuffer (); - task.memory.get (addr, 20, x); - if (x.length () == 20) - x.append ("..."); - x.append ("\""); - writer.print (x); - } + // Syscall objects are unique. + return this == other; + } + + abstract public long getArguments (Task task, int n); + abstract public long getReturnCode (Task task); + + private void printStringArg (PrintWriter writer, + frysk.proc.Task task, + long addr) + { + if (addr == 0) + writer.print ("0x0"); + else { + writer.print ("\""); + StringBuffer x = new StringBuffer (); + task.memory.get (addr, 20, x); + if (x.length () == 20) + x.append ("..."); + x.append ("\""); + writer.print (x); } + } /** * Print a textual representation of a system call. @@ -212,295 +222,116 @@ return writer; } - /** - * Given a system call's number, this will return the corresponding - * Syscall object. Note that system call numbers are platform - * dependent. - * XXX: Eventually this will be moved down to Linux, or even - * further. - * @param num the number of the system call - */ - public static Syscall syscallByNum (int num) - { - if(num >= syscallList.length || num < 0){ - return new Syscall("UKNOWN SYSCALL", num); + /** + * Given a system call's name, this will return the corresponding + * Syscall object. If no predefined system call with that name + * is available, this will return null. + * @param name the name of the system call + * @param syscallList system calls list + * @return the Syscall object, or null + */ + public static Syscall iterateSyscallByName (String name, Syscall[] syscallList) + { + for (int i = 0; i < syscallList.length; ++i) + if (name.equals(syscallList[i].name)) + return syscallList[i]; + return null; + } + + /** + * Given a system call's number, this will return the corresponding + * Syscall object. Note that system call numbers are platform + * dependent. This will return a Syscall object in all cases; if + * there is no predefined system call with the given number, a unique + * "unknown" system call with the indicated number will be saved in + * unknownSyscalls. + * @param num the number of the system call + * @param task the current task + * @return the Syscall object + */ + public static Syscall syscallByNum (int num, Task task) + { + Syscall[] syscallList; + HashMap unknownSyscalls; + + try + { + syscallList = task.getIsa().getSyscallList (); + unknownSyscalls = task.getIsa().getUnknownSyscalls (); + } + catch (Exception e) + { + throw new RuntimeException ("Could not get the isa"); + } + + if (num < 0) + { + throw new RuntimeException ("Negative Syscall Number:" + + Integer.toString(num)); + } + else if (num >= syscallList.length) + { + synchronized (Syscall.class) + { + Integer key = new Integer(num); + if (unknownSyscalls == null) + unknownSyscalls = new HashMap(); + else if (unknownSyscalls.containsKey(key)) + return (Syscall) unknownSyscalls.get(key); + + class UnknownSyscall + extends Syscall + { + UnknownSyscall (String name, int number) + { + super (name, number); + } + + public long getArguments (Task task, int n) + { + return 0; + } + public long getReturnCode (Task task) + { + return 0; + } + } + Syscall result = new UnknownSyscall("UNKNOWN SYSCALL " + + Integer.toString(num), num); + + unknownSyscalls.put(key, result); + + return result; + } + } + else + { + return syscallList[num]; + } + } + + /** + * Given a system call's name, this will return the corresponding + * Syscall object. If no predefined system call with that name + * is available, this will return null. + * @param name the name of the system call + * @param task the cuurent task + * @return the Syscall object, or null + * @throws NullPointerException if name is null + */ + public static Syscall syscallByName (String name, Task task) + { + Syscall syscall; + + try + { + syscall = task.getIsa().syscallByName(name); + } + catch (Exception e) + { + throw new RuntimeException ("Could not get the name of isa"); } - return syscallList[num]; - } - private static Syscall[] syscallList = { - new Syscall (0), - new Syscall ("exit", 1, 1), - new Syscall ("fork", 2, 0, "i: "), - new Syscall ("read", 3, 3, "i:ibn "), - new Syscall ("write", 4, 3, "i:ibn "), - new Syscall ("open", 5, 3, "i:siv "), - new Syscall ("close", 6, 1, "i:i "), - new Syscall ("waitpid", 7, 3, "i:ipi "), - new Syscall ("creat", 8, 2, "i:sv"), - new Syscall ("link", 9, 2, "i:ss "), - new Syscall ("unlink", 10, 1, "i:s "), - new Syscall ("execve", 11, 3, "i:ppp "), - new Syscall ("chdir", 12, 1, "i:s "), - new Syscall ("time", 13, 1, "i:P "), - new Syscall ("sys_mknod", 14, 3, "i:sii "), - new Syscall ("chmod", 15, 2, "i:si "), - new Syscall ("lchown", 16, 3, "i:sii "), - new Syscall ("break", 17), - new Syscall ("old_stat", 18, 3, "i:pp "), - new Syscall ("lseek", 19, 3, "i:iii "), - new Syscall ("getpid", 20, 0, "i: "), - new Syscall ("mount", 21, 5, "i:sssip "), - new Syscall ("umount", 22, 1, "i:s "), - new Syscall ("setuid", 23, 1, "i:i "), - new Syscall ("getuid", 24, 0, "i: "), - new Syscall ("stime", 25, 1, "i:p "), - new Syscall ("ptrace", 26, 4, "i:iiii "), - new Syscall ("alarm", 27, 1, "i:i "), - new Syscall ("old_fstat", 28, 2, "i:ip "), - new Syscall ("pause", 29, 0, "i: "), - new Syscall ("utime", 30, 2, "i:sP "), - new Syscall ("stty", 31), - new Syscall ("gtty", 32), - new Syscall ("access", 33, 2, "i:si "), - new Syscall ("nice", 34, 1, "i:i "), - new Syscall ("ftime", 35, 1, "i:p "), - new Syscall ("sync", 36, 0, "i: "), - new Syscall ("kill", 37, 2, "i:ii "), - new Syscall ("rename", 38, 2, "i:ss "), - new Syscall ("mkdir", 39, 2, "i:si "), - new Syscall ("rmdir", 40, 1, "i:s "), - new Syscall ("dup", 41, 1, "i:i "), - new Syscall ("pipe", 42, 1, "i:f "), - new Syscall ("times", 43, 1, "i:p "), - new Syscall ("prof", 44), - new Syscall ("brk", 45, 1, "i:p "), - new Syscall ("setgid", 46, 1, "i:i "), - new Syscall ("getgid", 47, 0, "i: "), - new Syscall ("signal", 48, 2, "i:ii "), - new Syscall ("geteuid", 49, 0, "i: "), - new Syscall ("getegid", 50, 0, "i: "), - new Syscall ("acct", 51, 1, "i:S "), - new Syscall ("umount2", 52, 2, "i:si "), - new Syscall ("lock", 53), - new Syscall ("ioctl", 54, 3, "i:iiI "), - new Syscall ("fcntl", 55, 3, "i:iiF "), - new Syscall ("mpx", 56), - new Syscall ("setpgid", 57, 2, "i:ii "), - new Syscall ("ulimit", 58, 2, "i:ii "), - new Syscall ("oldolduname", 59), - new Syscall ("umask", 60, 1, "i:i "), - new Syscall ("chroot", 61, 1, "i:s "), - new Syscall ("ustat", 62, 2, "i:ip "), - new Syscall ("dup2", 63, 2, "i:ii "), - new Syscall ("getppid", 64, 0, "i: "), - new Syscall ("getpgrp", 65, 0, "i: "), - new Syscall ("setsid", 66, 0, "i: "), - new Syscall ("sigaction", 67, 3, "i:ipp "), - new Syscall ("sgetmask", 68), - new Syscall ("ssetmask", 69), - new Syscall ("setreuid", 70, 2, "i:ii "), - new Syscall ("setregid", 71, 2, "i:ii "), - new Syscall ("sigsuspend", 72, 1, "i:p "), - new Syscall ("sigpending", 73, 1, "i:p "), - new Syscall ("sethostname", 74, 2, "i:pi "), - new Syscall ("setrlimit", 75, 2, "i:ip "), - new Syscall ("getrlimit", 76, 2, "i:ip "), - new Syscall ("getrusage", 77, 2, "i:ip "), - new Syscall ("gettimeofday", 78, 2, "i:PP "), - new Syscall ("settimeofday", 79, 2, "i:PP "), - new Syscall ("getgroups", 80, 2, "i:ip "), - new Syscall ("setgroups", 81, 2, "i:ip "), - new Syscall ("select", 82, 5, "i:iPPPP "), - new Syscall ("symlink", 83, 2, "i:ss "), - new Syscall ("oldlstat", 84, 2, "i:pp "), - new Syscall ("readlink", 85, 3, "i:spi "), - new Syscall ("uselib", 86, 1, "i:s "), - new Syscall ("swapon", 87, 2, "i:si "), - new Syscall ("reboot", 88, 1, "i:i "), - new Syscall (89), - new Syscall ("mmap", 90, 6, "b:aniiii "), - new Syscall ("munmap", 91, 2, "i:ai "), - new Syscall ("truncate", 92, 2, "i:si "), - new Syscall ("ftruncate", 93, 2, "i:ii "), - new Syscall ("fchmod", 94, 2, "i:ii "), - new Syscall ("fchown", 95, 3, "i:iii "), - new Syscall ("getpriority", 96, 2, "i:ii "), - new Syscall ("setpriority", 97, 3, "i:iii "), - new Syscall ("profil", 98, 4, "i:piii "), - new Syscall ("statfs", 99, 2, "i:sp "), - new Syscall ("fstatfs", 100, 2, "i:ip "), - new Syscall ("ioperm", 101, 3, "i:iii "), - new Syscall ("socketcall", 102, 2, "i:ip "), - new Syscall ("klogctl", 103, 3, "i:isi "), - new Syscall ("setitimer", 104, 3, "i:ipp "), - new Syscall ("getitimer", 105, 2, "i:ip "), - new Syscall ("sys_stat", 106, 2, "i:sp "), - new Syscall ("sys_lstat", 107, 2, "i:sp "), - new Syscall ("sys_fstat", 108, 2, "i:ip "), - new Syscall ("old_uname", 109, 1, "i:p "), - new Syscall ("iopl", 110, 1, "i:i "), - new Syscall ("vhangup", 111, 1, "i:i "), - new Syscall ("idle", 112, 0, "i: "), - new Syscall (113), - new Syscall ("wait4", 114, 4, "i:iWiP "), - new Syscall ("swapoff", 115, 1, "i:s "), - new Syscall ("sysinfo", 116, 1, "i:p "), - new Syscall ("ipc", 117, 6, "i:iiiipi "), - new Syscall ("fsync", 118, 1, "i:i "), - new Syscall ("sigreturn", 119), - new Syscall ("clone", 120, 2, "i:ip "), - new Syscall ("setdomain", 121, 2, "i:si "), - new Syscall ("uname", 122, 1, "i:p "), - new Syscall ("modify_ldt", 123, 3, "i:ipi "), - new Syscall ("adjtimex", 124, 1, "i:p "), - new Syscall ("mprotect", 125, 3, "i:aii "), - new Syscall ("sigprocmask", 126, 3, "i:ipp "), - new Syscall ("create_module", 127, 3), - new Syscall ("init_module", 128, 5), - new Syscall ("delete_module", 129, 3), - new Syscall ("get_kernel_syms", 130, 1, "i:p "), - new Syscall ("quotactl", 131, 4, "i:isip "), - new Syscall ("getpgid", 132, 1, "i:i "), - new Syscall ("fchdir", 133, 1, "i:i "), - new Syscall ("bdflush", 134, 2, "i:ii "), - new Syscall ("sysfs", 135, 1, "i:i "), - new Syscall ("personality", 136, 1, "i:i "), - new Syscall ("afs_syscall", 137), - new Syscall ("setfsuid", 138, 1, "i:i "), - new Syscall ("setfsgid", 139, 1, "i:i "), - new Syscall ("llseek", 140, 5, "i:iuupi "), - new Syscall ("s_getdents", 141, 3, "i:ipi "), - new Syscall ("select", 142, 5, "i:iPPPP "), - new Syscall ("flock", 143, 2, "i:ii "), - new Syscall ("msync", 144, 3, "i:aii "), - new Syscall ("readv", 145, 3, "i:ipi "), - new Syscall ("writev", 146, 3, "i:ipi "), - new Syscall ("getsid", 147, 1, "i:i "), - new Syscall ("fdatasync", 148, 1, "i:i "), - new Syscall ("sysctl", 149, 1, "i:p "), - new Syscall ("mlock", 150, 2, "i:bn "), - new Syscall ("munlock", 151, 2, "i:ai "), - new Syscall ("mlockall", 152, 1, "i:i "), - new Syscall ("munlockall", 153, 0, "i: "), - new Syscall ("sched_setp", 154, 2, "i:ip "), - new Syscall ("sched_getp", 155, 2, "i:ip "), - new Syscall ("sched_sets", 156, 3, "i:iip "), - new Syscall ("sched_gets", 157, 1, "i:i "), - new Syscall ("sched_yield", 158, 0, "i: "), - new Syscall ("sched_primax", 159, 1, "i:i "), - new Syscall ("sched_primin", 160, 1, "i:i "), - new Syscall ("sched_rr_gi", 161, 2, "i:ip "), - new Syscall ("nanosleep", 162, 2, "i:pp "), - new Syscall ("mremap", 163, 4, "b:aini "), - new Syscall ("setresuid", 164, 3, "i:iii "), - new Syscall ("getresuid", 165, 3, "i:ppp "), - new Syscall ("vm86", 166, 1, "i:p "), - new Syscall ("query_module", 167, 5, "i:sipip "), - new Syscall ("poll", 168, 3, "i:pii "), - new Syscall ("nfsservctl", 169, 3, "i:ipp "), - new Syscall ("setresgid", 170, 3, "i:iii "), - new Syscall ("getresgid", 171, 3, "i:ppp "), - new Syscall ("prctl", 172, 5, "i:iiiii "), - new Syscall ("rt_sigreturn", 173), - new Syscall ("rt_sigaction", 174), - new Syscall ("rt_sigprocmask", 175), - new Syscall ("rt_sigpending", 176), - new Syscall ("rt_sigtimedwait", 177), - new Syscall ("rt_sigqueueinfo", 178), - new Syscall ("rt_sigsuspend", 179), - new Syscall ("pread64", 180), - new Syscall ("pwrite64", 181), - new Syscall ("chown", 182, 3, "i:sii "), - new Syscall ("getcwd", 183, 2, "i:bi "), - new Syscall ("capget", 184, 2, "i:pp "), - new Syscall ("capset", 185, 2, "i:pp "), - new Syscall ("sigaltstack", 186, 2, "i:PP "), - new Syscall ("sendfile", 187, 4, "i:iipi "), - new Syscall ("getpmsg", 188), - new Syscall ("putpmsg", 189), - new Syscall ("vfork", 190, 0, "i: "), - new Syscall ("ugetrlimit", 191), - new Syscall ("mmap", 192, 6, "b:aniiii "), - new Syscall ("truncate64", 193, 3, "i:shl "), - new Syscall ("ftruncate64", 194, 3, "i:ihl "), - new Syscall ("stat64", 195, 2, "i:sp "), - new Syscall ("lstat64", 196, 2, "i:sp "), - new Syscall ("fstat64", 197, 2, "i:ip "), - new Syscall ("lchown32", 198, 3, "i:sii "), - new Syscall ("getuid32", 199), - new Syscall ("getgid32", 200), - new Syscall ("geteuid32", 201), - new Syscall ("getegid32", 202), - new Syscall ("setreuid32", 203, 2, "i:ii "), - new Syscall ("setregid32", 204, 2, "i:ii "), - new Syscall ("getgroups32", 205, 2, "i:ip "), - new Syscall ("setgroups32", 206, 2, "i:ip "), - new Syscall ("fchown32", 207, 3, "i:iii "), - new Syscall ("setresuid32", 208, 3, "i:iii "), - new Syscall ("getresuid32", 209, 3, "i:ppp "), - new Syscall ("setresgid32", 210, 3, "i:iii "), - new Syscall ("getresgid32", 211, 3, "i:ppp "), - new Syscall ("chown32", 212, 3, "i:sii "), - new Syscall ("setuid32", 213, 1, "i:i "), - new Syscall ("setgid32", 214, 1, "i:i "), - new Syscall ("setfsuid32", 215, 1, "i:i "), - new Syscall ("setfsgid32", 216, 1, "i:i "), - new Syscall ("pivot_root", 217, 2, "i:ss "), - new Syscall ("mincore", 218, 3, "i:anV "), - new Syscall ("madvise", 219, 3, "i:pii "), - new Syscall ("getdents64", 220, 3, "i:ipi "), - new Syscall ("fcntl64", 221, 3, "i:iip "), - new Syscall (222), - new Syscall (223), - new Syscall ("gettid", 224, 0), - new Syscall ("readahead", 225, 4, "i:ihli "), - new Syscall ("setxattr", 226), - new Syscall ("lsetxattr", 227), - new Syscall ("fsetxattr", 228), - new Syscall ("getxattr", 229), - new Syscall ("lgetxattr", 230), - new Syscall ("fgetxattr", 231), - new Syscall ("listxattr", 232), - new Syscall ("llistxattr", 233), - new Syscall ("flistxattr", 234), - new Syscall ("removexattr", 235), - new Syscall ("lremovexattr", 236), - new Syscall ("fremovexattr", 237), - new Syscall ("tkill", 238, 2, "i:ii "), - new Syscall ("sendfile64", 239, 4, "i:iipi "), - new Syscall ("futex", 240, 4, "i:piip "), - new Syscall ("sched_setaffinity", 241), - new Syscall ("sched_getaffinity", 242), - new Syscall ("set_thread_area", 243, 1, "i:p "), - new Syscall ("get_thread_area", 244, 1, "i:p "), - new Syscall ("io_setup", 245, 2, "i:ip "), - new Syscall ("io_destroy", 246, 1, "i:i "), - new Syscall ("io_getevents", 247, 5, "i:iiipp "), - new Syscall ("io_submit", 248, 3, "i:iip "), - new Syscall ("io_cancel", 249, 3, "i:ipp "), - new Syscall ("fadvise64", 250), - new Syscall (251), - new Syscall ("exit_group", 252, 1, " :i ", true), - new Syscall ("lookup_dcookie", 253), - new Syscall ("epoll_create", 254), - new Syscall ("epoll_ctl", 255), - new Syscall ("epoll_wait", 256), - new Syscall ("remap_file_pages", 257), - new Syscall ("set_tid_address", 258), - new Syscall ("timer_create", 259), - new Syscall ("timer_settime", 260), - new Syscall ("timer_gettime", 261), - new Syscall ("timer_getoverrun", 262), - new Syscall ("timer_delete", 263), - new Syscall ("clock_settime", 264), - new Syscall ("clock_gettime", 265), - new Syscall ("clock_getres", 266), - new Syscall ("clock_nanosleep", 267), - new Syscall ("statfs64", 268), - new Syscall ("fstatfs64", 269), - new Syscall ("tgkill", 270), - new Syscall ("utimes", 271), - new Syscall ("fadvise64_64", 272), - }; + return syscall; + } } Index: frysk-core/frysk/proc/SyscallEventInfo.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/proc/SyscallEventInfo.java,v retrieving revision 1.4 diff -u -r1.4 SyscallEventInfo.java --- frysk-core/frysk/proc/SyscallEventInfo.java 11 Jul 2006 21:25:25 -0000 1.4 +++ frysk-core/frysk/proc/SyscallEventInfo.java 13 Sep 2006 11:48:37 -0000 @@ -44,11 +44,36 @@ */ public abstract class SyscallEventInfo { - public final static int ENTER = 0; - public final static int EXIT = 1; - public final static int UNKNOWN = -1; + public final static int ENTER = 0; + public final static int EXIT = 1; + public final static int UNKNOWN = -1; + + public abstract int number (Task task); + /** + * getSyscall does everything on the assumption that there is a + * system, and programmer want to know the information about this + * system call. A meaningless Syscall object is returned when + * getSyscall is called at the moment no system call occurs. + * @param task the task that system call occured + * @return the Syscall object + */ + public abstract Syscall getSyscall (Task task); - public abstract int number (Task task); - public abstract long arg (Task task, int n); - public abstract long returnCode (Task task); + /** + * @param task the task that system call occured + * @param n the number of this argument + * @return value of this argument + */ + public long arg (Task task, int n) + { + return getSyscall(task).getArguments(task, n); + } + /** + * @param task the task that system call occured + * @return return value of this system call + */ + public long returnCode (Task task) + { + return getSyscall(task).getReturnCode(task); + } } Index: frysk-gui/frysk/gui/monitor/observers/SysCallUtilyInfo.java =================================================================== RCS file: /cvs/frysk/frysk-gui/frysk/gui/monitor/observers/SysCallUtilyInfo.java,v retrieving revision 1.4 diff -u -r1.4 SysCallUtilyInfo.java --- frysk-gui/frysk/gui/monitor/observers/SysCallUtilyInfo.java 6 Sep 2006 17:43:08 -0000 1.4 +++ frysk-gui/frysk/gui/monitor/observers/SysCallUtilyInfo.java 13 Sep 2006 12:21:13 -0000 @@ -58,8 +58,7 @@ return ""; } - Syscall syscall = Syscall - .syscallByNum(syscallEventInfo.number(task)); + Syscall syscall = syscallEventInfo.getSyscall(task); enterCall = syscall.getName(); if (syscall.numArgs > 0) enterCall += " ("; @@ -119,7 +118,7 @@ return ""; } - Syscall syscall = Syscall.syscallByNum(syscallEventInfo.number(task)); + Syscall syscall = syscallEventInfo.getSyscall(task); returnCall += syscall.getName() + " returns with value "; --- /dev/null 2006-09-01 16:42:34.468363500 +0800 +++ frysk-core/frysk/proc/LinuxPowerPCSyscall.java 2006-09-13 19:41:53.000000000 +0800 @@ -0,0 +1,541 @@ +// This file is part of the program FRYSK. +// +// Copyright 2006 IBM Corp. +// +// 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. + +package frysk.proc; + +import java.util.HashMap; + +public class LinuxPowerPCSyscall +{ + static final int SOCKET_NUM = 102; + static final int IPC_NUM = 117; + + // This is used to keep track of syscalls whose number we do not + // know. + static HashMap unknownSyscalls; + + static class PowerPCSyscall + extends Syscall + { + PowerPCSyscall (String name, int number, int numArgs, + String argList, boolean noreturn) + { + super (name, number, numArgs, argList, noreturn); + } + PowerPCSyscall (String name, int number, int numArgs, String argList) + { + super (name, number, numArgs, argList); + } + PowerPCSyscall (String name, int number, int numArgs) + { + super (name, number, numArgs); + } + PowerPCSyscall (String name, int number) + { + super (name, number); + } + PowerPCSyscall (int number) + { + super (number); + } + + public long getArguments (Task task, int n) + { + Isa isa; + try + { + isa = task.getIsa(); + } + catch (Exception e) + { + throw new RuntimeException ("Could not get isa"); + } + + switch (n) + { + case 0: + return isa.getRegisterByName("gpr0").get(task); + case 1: + return isa.getRegisterByName("orig_r3").get(task); + case 2: + return isa.getRegisterByName("gpr4").get(task); + case 3: + return isa.getRegisterByName("gpr5").get(task); + case 4: + return isa.getRegisterByName("gpr6").get(task); + case 5: + return isa.getRegisterByName("gpr7").get(task); + case 6: + return isa.getRegisterByName("gpr8").get(task); + default: + throw new RuntimeException ("unknown syscall arg"); + } + } + public long getReturnCode (Task task) + { + Isa isa; + try + { + isa = task.getIsa(); + } + catch (Exception e) + { + throw new RuntimeException ("Could not get isa"); + } + + int flag = (int) isa.getRegisterByName("ccr").get(task); + + if ((flag & 0x10000000) != 0) + return -isa.getRegisterByName("gpr3").get(task); + else + return isa.getRegisterByName("gpr3").get(task); + } + } + + static Syscall[] syscallList = { + new PowerPCSyscall (0), + new PowerPCSyscall ("write", 1, 3, "i:ibn "), + new PowerPCSyscall ("open", 2, 3, "i:siv "), + new PowerPCSyscall ("read", 3, 3, "i:ibn "), + new PowerPCSyscall ("write", 4, 3, "i:ibn "), + new PowerPCSyscall ("open", 5, 3, "i:siv "), + new PowerPCSyscall ("close", 6, 1, "i:i "), + new PowerPCSyscall ("waitpid", 7, 3, "i:ipi "), + new PowerPCSyscall ("creat", 8, 2, "i:sv"), + new PowerPCSyscall ("link", 9, 2, "i:ss "), + new PowerPCSyscall ("unlink", 10, 1, "i:s "), + new PowerPCSyscall ("execve", 11, 3, "i:ppp "), + new PowerPCSyscall ("chdir", 12, 1, "i:s "), + new PowerPCSyscall ("time", 13, 1, "i:P "), + new PowerPCSyscall ("mknod", 14), + new PowerPCSyscall ("chmod", 15, 2, "i:si "), + new PowerPCSyscall ("lchown", 16, 3, "i:sii "), + new PowerPCSyscall ("break", 17 ), + new PowerPCSyscall ("oldstat", 18), + new PowerPCSyscall ("lseek", 19, 3, "i:iii "), + new PowerPCSyscall ("getpid", 20, 0, "i: "), + new PowerPCSyscall ("mount", 21, 5, "i:sssip "), + new PowerPCSyscall ("umount", 22, 1, "i:s "), + new PowerPCSyscall ("setuid", 23, 1, "i:i "), + new PowerPCSyscall ("getuid", 24, 0, "i: "), + new PowerPCSyscall ("stime", 25, 1, "i:p "), + new PowerPCSyscall ("ptrace", 26, 4, "i:iiii "), + new PowerPCSyscall ("alarm", 27, 1, "i:i "), + new PowerPCSyscall ("oldfstat", 28), + new PowerPCSyscall ("pause", 29, 0, "i: "), + new PowerPCSyscall ("utime", 30, 2, "i:sP "), + new PowerPCSyscall ("stty", 31), + new PowerPCSyscall ("gtty", 32), + new PowerPCSyscall ("access", 33, 2, "i:si "), + new PowerPCSyscall ("nice", 34, 1, "i:i "), + new PowerPCSyscall ("ftime", 35, 1, "i:p "), + new PowerPCSyscall ("sync", 36, 0, "i: "), + new PowerPCSyscall ("kill", 37, 2, "i:ii "), + new PowerPCSyscall ("rename", 38, 2, "i:ss "), + new PowerPCSyscall ("mkdir", 39, 2, "i:si "), + new PowerPCSyscall ("rmdir", 40, 1, "i:s "), + new PowerPCSyscall ("dup", 41, 1, "i:i "), + new PowerPCSyscall ("pipe", 42, 1, "i:f "), + new PowerPCSyscall ("times", 43, 1, "i:p "), + new PowerPCSyscall ("prof", 44), + new PowerPCSyscall ("brk", 45, 1, "i:p "), + new PowerPCSyscall ("setgid", 46, 1, "i:i "), + new PowerPCSyscall ("getgid", 47, 0, "i: "), + new PowerPCSyscall ("signal", 48, 2, "i:ii "), + new PowerPCSyscall ("geteuid", 49, 0, "i: "), + new PowerPCSyscall ("getegid", 50, 0, "i: "), + new PowerPCSyscall ("acct", 51, 1, "i:S "), + new PowerPCSyscall ("umount2", 52, 2, "i:si "), + new PowerPCSyscall ("lock", 53), + new PowerPCSyscall ("ioctl", 54, 3, "i:iiI "), + new PowerPCSyscall ("fcntl", 55, 3, "i:iiF "), + new PowerPCSyscall ("mpx", 56), + new PowerPCSyscall ("setpgid", 57, 2, "i:ii "), + new PowerPCSyscall ("ulimit", 58, 2, "i:ii "), + new PowerPCSyscall ("oldolduname", 59), + new PowerPCSyscall ("umask", 60, 1, "i:i "), + new PowerPCSyscall ("chroot", 61, 1, "i:s "), + new PowerPCSyscall ("ustat", 62, 2, "i:ip "), + new PowerPCSyscall ("dup2", 63, 2, "i:ii "), + new PowerPCSyscall ("getppid", 64, 0, "i: "), + new PowerPCSyscall ("getpgrp", 65, 0, "i: "), + new PowerPCSyscall ("setsid", 66, 0, "i: "), + new PowerPCSyscall ("sigaction", 67, 3, "i:ipp "), + new PowerPCSyscall ("sgetmask", 68), + new PowerPCSyscall ("ssetmask", 69), + new PowerPCSyscall ("setreuid", 70, 2, "i:ii "), + new PowerPCSyscall ("setregid", 71, 2, "i:ii "), + new PowerPCSyscall ("sigsuspend", 72, 1, "i:p "), + new PowerPCSyscall ("sigpending", 73, 1, "i:p "), + new PowerPCSyscall ("sethostname", 74, 2, "i:pi "), + new PowerPCSyscall ("setrlimit", 75, 2, "i:ip "), + new PowerPCSyscall ("getrlimit", 76, 2, "i:ip "), + new PowerPCSyscall ("getrusage", 77, 2, "i:ip "), + new PowerPCSyscall ("gettimeofday", 78, 2, "i:PP "), + new PowerPCSyscall ("settimeofday", 79, 2, "i:PP "), + new PowerPCSyscall ("getgroups", 80, 2, "i:ip "), + new PowerPCSyscall ("setgroups", 81, 2, "i:ip "), + new PowerPCSyscall ("select", 82, 5, "i:iPPPP "), + new PowerPCSyscall ("symlink", 83, 2, "i:ss "), + new PowerPCSyscall ("oldlstat", 84, 2, "i:pp "), + new PowerPCSyscall ("readlink", 85, 3, "i:spi "), + new PowerPCSyscall ("uselib", 86, 1, "i:s "), + new PowerPCSyscall ("swapon", 87, 2, "i:si "), + new PowerPCSyscall ("reboot", 88, 1, "i:i "), + new PowerPCSyscall ("readdir", 89), + new PowerPCSyscall ("mmap", 90, 6, "b:aniiii "), + new PowerPCSyscall ("munmap", 91, 2, "i:ai "), + new PowerPCSyscall ("truncate", 92, 2, "i:si "), + new PowerPCSyscall ("ftruncate", 93, 2, "i:ii "), + new PowerPCSyscall ("fchmod", 94, 2, "i:ii "), + new PowerPCSyscall ("fchown", 95, 3, "i:iii "), + new PowerPCSyscall ("getpriority", 96, 2, "i:ii "), + new PowerPCSyscall ("setpriority", 97, 3, "i:iii "), + new PowerPCSyscall ("profil", 98, 4, "i:piii "), + new PowerPCSyscall ("statfs", 99, 2, "i:sp "), + new PowerPCSyscall ("fstatfs", 100, 2, "i:ip "), + new PowerPCSyscall ("ioperm", 101, 3, "i:iii "), + new PowerPCSyscall ("socketcall", 102, 2, "i:ip "), + new PowerPCSyscall ("syslog", 103), + new PowerPCSyscall ("setitimer", 104, 3, "i:ipp "), + new PowerPCSyscall ("getitimer", 105, 2, "i:ip "), + new PowerPCSyscall ("stat", 106), + new PowerPCSyscall ("lstat", 107), + new PowerPCSyscall ("fstat", 108), + new PowerPCSyscall ("olduname", 109), + new PowerPCSyscall ("iopl", 110, 1, "i:i "), + new PowerPCSyscall ("vhangup", 111, 1, "i:i "), + new PowerPCSyscall ("idle", 112, 0, "i: "), + new PowerPCSyscall ("vm86", 113, 1, "i:p "), + new PowerPCSyscall ("wait4", 114, 4, "i:iWiP "), + new PowerPCSyscall ("swapoff", 115, 1, "i:s "), + new PowerPCSyscall ("sysinfo", 116, 1, "i:p "), + new PowerPCSyscall ("ipc", 117, 6, "i:iiiipi "), + new PowerPCSyscall ("fsync", 118, 1, "i:i "), + new PowerPCSyscall ("sigreturn", 119), + new PowerPCSyscall ("clone", 120, 2, "i:ip "), + new PowerPCSyscall ("setdomainname", 121), + new PowerPCSyscall ("uname", 122, 1, "i:p "), + new PowerPCSyscall ("modify_ldt", 123, 3, "i:ipi "), + new PowerPCSyscall ("adjtimex", 124, 1, "i:p "), + new PowerPCSyscall ("mprotect", 125, 3, "i:aii "), + new PowerPCSyscall ("sigprocmask", 126, 3, "i:ipp "), + new PowerPCSyscall ("create_module", 127, 3), + new PowerPCSyscall ("init_module", 128, 5), + new PowerPCSyscall ("delete_module", 129, 3), + new PowerPCSyscall ("get_kernel_syms", 130, 1, "i:p "), + new PowerPCSyscall ("quotactl", 131, 4, "i:isip "), + new PowerPCSyscall ("getpgid", 132, 1, "i:i "), + new PowerPCSyscall ("fchdir", 133, 1, "i:i "), + new PowerPCSyscall ("bdflush", 134, 2, "i:ii "), + new PowerPCSyscall ("sysfs", 135, 1, "i:i "), + new PowerPCSyscall ("personality", 136, 1, "i:i "), + new PowerPCSyscall ("afs_syscall", 137), + new PowerPCSyscall ("setfsuid", 138, 1, "i:i "), + new PowerPCSyscall ("setfsgid", 139, 1, "i:i "), + new PowerPCSyscall ("_llseek", 140), + new PowerPCSyscall ("getdents", 141), + new PowerPCSyscall ("_newselect", 142), + new PowerPCSyscall ("flock", 143, 2, "i:ii "), + new PowerPCSyscall ("msync", 144, 3, "i:aii "), + new PowerPCSyscall ("readv", 145, 3, "i:ipi "), + new PowerPCSyscall ("writev", 146, 3, "i:ipi "), + new PowerPCSyscall ("getsid", 147, 1, "i:i "), + new PowerPCSyscall ("fdatasync", 148, 1, "i:i "), + new PowerPCSyscall ("_sysctl", 149), + new PowerPCSyscall ("mlock", 150, 2, "i:bn "), + new PowerPCSyscall ("munlock", 151, 2, "i:ai "), + new PowerPCSyscall ("mlockall", 152, 1, "i:i "), + new PowerPCSyscall ("munlockall", 153, 0, "i: "), + new PowerPCSyscall ("sched_setparam", 154), + new PowerPCSyscall ("sched_getparam", 155), + new PowerPCSyscall ("sched_setscheduler", 156), + new PowerPCSyscall ("sched_getscheduler", 157), + new PowerPCSyscall ("sched_yield", 158, 0, "i: "), + new PowerPCSyscall ("sched_get_priority_max", 159), + new PowerPCSyscall ("sched_get_priority_min", 160), + new PowerPCSyscall ("sched_rr_get_interval", 161), + new PowerPCSyscall ("nanosleep", 162, 2, "i:pp "), + new PowerPCSyscall ("mremap", 163, 4, "b:aini "), + new PowerPCSyscall ("setresuid", 164, 3, "i:iii "), + new PowerPCSyscall ("getresuid", 165, 3, "i:ppp "), + new PowerPCSyscall ("query_module", 166, 5, "i:sipip "), + new PowerPCSyscall ("poll", 167, 3, "i:pii "), + new PowerPCSyscall ("nfsservctl", 168, 3, "i:ipp "), + new PowerPCSyscall ("setresgid", 169, 3, "i:iii "), + new PowerPCSyscall ("getresgid", 170, 3, "i:ppp "), + new PowerPCSyscall ("prctl", 171, 5, "i:iiiii "), + new PowerPCSyscall ("rt_sigreturn", 172), + new PowerPCSyscall ("rt_sigaction", 173), + new PowerPCSyscall ("rt_sigprocmask", 174), + new PowerPCSyscall ("rt_sigpending", 175), + new PowerPCSyscall ("rt_sigtimedwait", 176), + new PowerPCSyscall ("rt_sigqueueinfo", 177), + new PowerPCSyscall ("rt_sigsuspend", 178), + new PowerPCSyscall ("pread64", 179), + new PowerPCSyscall ("pwrite64", 180), + new PowerPCSyscall ("chown", 181, 3, "i:sii "), + new PowerPCSyscall ("getcwd", 182, 2, "i:bi "), + new PowerPCSyscall ("capget", 183, 2, "i:pp "), + new PowerPCSyscall ("capset", 184, 2, "i:pp "), + new PowerPCSyscall ("sigaltstack", 185, 2, "i:PP "), + new PowerPCSyscall ("sendfile", 186, 4, "i:iipi "), + new PowerPCSyscall ("getpmsg", 187), + new PowerPCSyscall ("putpmsg", 188), + new PowerPCSyscall ("vfork", 189, 0, "i: "), + new PowerPCSyscall ("ugetrlimit", 190), + new PowerPCSyscall ("readahead", 191, 4, "i:ihli "), + new PowerPCSyscall ("mmap2", 192), + new PowerPCSyscall ("truncate64", 193, 3, "i:shl "), + new PowerPCSyscall ("ftruncate64", 194, 3, "i:ihl "), + new PowerPCSyscall ("stat64", 195, 2, "i:sp "), + new PowerPCSyscall ("lstat64", 196, 2, "i:sp "), + new PowerPCSyscall ("fstat64", 197, 2, "i:ip "), + new PowerPCSyscall ("pciconfig_read", 198), + new PowerPCSyscall ("pciconfig_write", 199), + new PowerPCSyscall ("pciconfig_iobase", 200), + new PowerPCSyscall ("multiplexer", 201), + new PowerPCSyscall ("getdents64", 202, 3, "i:ipi "), + new PowerPCSyscall ("pivot_root", 203, 2, "i:ss "), + new PowerPCSyscall ("fcntl64", 204, 3, "i:iip "), + new PowerPCSyscall ("madvise", 205, 3, "i:pii "), + new PowerPCSyscall ("mincore", 206, 3, "i:anV "), + new PowerPCSyscall ("gettid", 207, 0), + new PowerPCSyscall ("tkill", 208, 2, "i:ii "), + new PowerPCSyscall ("setxattr", 209), + new PowerPCSyscall ("lsetxattr", 210), + new PowerPCSyscall ("fsetxattr", 211), + new PowerPCSyscall ("getxattr", 212), + new PowerPCSyscall ("lgetxattr", 213), + new PowerPCSyscall ("fgetxattr", 214), + new PowerPCSyscall ("listxattr", 215), + new PowerPCSyscall ("llistxattr", 216), + new PowerPCSyscall ("flistxattr", 217), + new PowerPCSyscall ("removexattr", 218), + new PowerPCSyscall ("lremovexattr", 219), + new PowerPCSyscall ("fremovexattr", 220), + new PowerPCSyscall ("futex", 221, 4, "i:piip "), + new PowerPCSyscall ("sched_setaffinity", 222), + new PowerPCSyscall ("sched_getaffinity", 223), + new PowerPCSyscall (224), + new PowerPCSyscall (225), + new PowerPCSyscall ("sendfile64", 226, 4, "i:iipi "), + new PowerPCSyscall ("io_setup", 227, 2, "i:ip "), + new PowerPCSyscall ("io_destroy", 228, 1, "i:i "), + new PowerPCSyscall ("io_getevents", 229, 5, "i:iiipp "), + new PowerPCSyscall ("io_submit", 230, 3, "i:iip "), + new PowerPCSyscall ("io_cancel", 231, 3, "i:ipp "), + new PowerPCSyscall ("set_tid_address", 232), + new PowerPCSyscall ("fadvise64", 233), + new PowerPCSyscall ("exit_group", 234, 1, " :i "), + new PowerPCSyscall ("lookup_dcookie", 235), + new PowerPCSyscall ("epoll_create", 236), + new PowerPCSyscall ("epoll_ctl", 237), + new PowerPCSyscall ("epoll_wait", 238), + new PowerPCSyscall ("remap_file_pages", 239), + new PowerPCSyscall ("timer_create", 240), + new PowerPCSyscall ("timer_settime", 241), + new PowerPCSyscall ("timer_gettime", 242), + new PowerPCSyscall ("timer_getoverrun", 243), + new PowerPCSyscall ("timer_delete", 244), + new PowerPCSyscall ("clock_settime", 245), + new PowerPCSyscall ("clock_gettime", 246), + new PowerPCSyscall ("clock_getres", 247), + new PowerPCSyscall ("clock_nanosleep", 248), + new PowerPCSyscall ("swapcontext", 249), + new PowerPCSyscall ("tgkill", 250), + new PowerPCSyscall ("utimes", 251), + new PowerPCSyscall ("statfs64", 252 ), + new PowerPCSyscall ("fstatfs64", 253), + new PowerPCSyscall ("fadvise64_64", 254), + new PowerPCSyscall ("rtas", 255), + new PowerPCSyscall ("sys_debug_setcontext", 256), + new PowerPCSyscall (257), + new PowerPCSyscall (258), + new PowerPCSyscall (259), + new PowerPCSyscall ("get_mempolicy", 260), + new PowerPCSyscall ("set_mempolicy", 261), + new PowerPCSyscall ("mq_open", 262), + new PowerPCSyscall ("mq_unlink", 263), + new PowerPCSyscall ("mq_timedsend", 264), + new PowerPCSyscall ("mq_timedreceive", 265), + new PowerPCSyscall ("mq_notify", 266), + new PowerPCSyscall ("mq_getsetattr", 267), + new PowerPCSyscall ("kexec_load", 268), + new PowerPCSyscall ("add_key", 269), + new PowerPCSyscall ("request_key", 270), + new PowerPCSyscall ("keyctl", 271), + new PowerPCSyscall ("waitid", 272), + new PowerPCSyscall ("ioprio_set", 273), + new PowerPCSyscall ("ioprio_get", 274), + new PowerPCSyscall ("inotify_init", 275), + new PowerPCSyscall ("inotify_add_watch", 276), + new PowerPCSyscall ("inotify_rm_watch", 277), + new PowerPCSyscall ("syscalls", 278) + }; + + static class SocketSubSyscall + extends PowerPCSyscall + { + SocketSubSyscall (String name, int number) + { + super (name, number); + } + SocketSubSyscall (String name, int number, int numArgs, String argList) + { + super (name, number, numArgs, argList); + } + public long getArguments (Task task, int n) + { + /** Arguments in socket subcalls are dereferenced. */ + Isa isa; + try + { + isa = task.getIsa(); + } + catch (Exception e) + { + throw new RuntimeException ("Could not get isa"); + } + long base = isa.getRegisterByName("gpr4").get (task); + + // FIXME: There are some bi-arch issues + return task.memory.getInt(base + (n-1) * isa.getWordSize()); + } + } + + static Syscall[] socketSubcallList = { + new SocketSubSyscall ("", SOCKET_NUM), + new SocketSubSyscall ("socket", SOCKET_NUM, 3, "i:iii"), + new SocketSubSyscall ("bind", SOCKET_NUM, 3, "i:ipi "), + new SocketSubSyscall ("connect", SOCKET_NUM, 3, "i:ipi "), + new SocketSubSyscall ("listen", SOCKET_NUM, 2, "i:ii "), + new SocketSubSyscall ("accept", SOCKET_NUM, 3, "i:ipp "), + new SocketSubSyscall ("getsockname",SOCKET_NUM, 3, "i:ipp "), + new SocketSubSyscall ("getpeername",SOCKET_NUM, 4, "i:iiip "), + new SocketSubSyscall ("socketpair", SOCKET_NUM, 4, "i:iiip "), + new SocketSubSyscall ("send", SOCKET_NUM, 4, "i:ipii "), + new SocketSubSyscall ("recv", SOCKET_NUM, 4, "i:ipii "), + new SocketSubSyscall ("sendto", SOCKET_NUM, 6, "i:ipiipi"), + new SocketSubSyscall ("recvfrom", SOCKET_NUM, 6, "i:ipiipp "), + new SocketSubSyscall ("shutdown", SOCKET_NUM, 2, "i:ii "), + new SocketSubSyscall ("setsockopt", SOCKET_NUM, 5, "i:iiipp "), + new SocketSubSyscall ("getsockopt", SOCKET_NUM, 5, "i:iiipp "), + new SocketSubSyscall ("sendmsg", SOCKET_NUM, 5, "i:iiipp "), + new SocketSubSyscall ("recvmsg", SOCKET_NUM, 5, "i:iiipp ") + }; + + + static class IpcSubSyscall + extends PowerPCSyscall + { + IpcSubSyscall (String name, int number) + { + super (name, number); + } + IpcSubSyscall (String name, int number, int numArgs, String argList) + { + super (name, number, numArgs, argList); + } + + public long getArguments (Task task, int n) + { + if (n == 0) + return super.getArguments (task, 0); + else + // these arguements are shifted by one. + return super.getArguments (task, n+1); + } + + } + static Syscall[] ipcSubcallList = { + new IpcSubSyscall ("semop", IPC_NUM), + new IpcSubSyscall("semget", IPC_NUM), + new IpcSubSyscall("semctl", IPC_NUM), + new IpcSubSyscall("semtimedop", IPC_NUM), + new IpcSubSyscall("", IPC_NUM), + new IpcSubSyscall("", IPC_NUM), + new IpcSubSyscall("", IPC_NUM), + new IpcSubSyscall("", IPC_NUM), + new IpcSubSyscall("", IPC_NUM), + new IpcSubSyscall("", IPC_NUM), + new IpcSubSyscall("msgsnd", IPC_NUM), + new IpcSubSyscall("msgrcv", IPC_NUM), + new IpcSubSyscall("msgget", IPC_NUM), + new IpcSubSyscall("msgctl", IPC_NUM), + new IpcSubSyscall("", IPC_NUM), + new IpcSubSyscall("", IPC_NUM), + new IpcSubSyscall("", IPC_NUM), + new IpcSubSyscall("", IPC_NUM), + new IpcSubSyscall("", IPC_NUM), + new IpcSubSyscall("", IPC_NUM), + new IpcSubSyscall("shmat", IPC_NUM), + new IpcSubSyscall("shmdt", IPC_NUM), + new IpcSubSyscall("shmget", IPC_NUM), + new IpcSubSyscall("shmctl", IPC_NUM) + }; + + public static Syscall syscallByNum (Task task, int number) + { + if (number != SOCKET_NUM && number != IPC_NUM) + return Syscall.syscallByNum (number, task); + else + { + /** sub syscall number is in . */ + int subSyscallNumber = 0; + try + { + subSyscallNumber = (int) task.getIsa().getRegisterByName("orig_r3").get(task); + } + catch (Exception e) + { + throw new RuntimeException ("Could not get isa"); + } + + if (number == SOCKET_NUM) + { + return socketSubcallList[subSyscallNumber]; + } + else + { + return ipcSubcallList[subSyscallNumber]; + } + } + } +} --- /dev/null 2006-09-01 16:42:34.468363500 +0800 +++ frysk-core/frysk/proc/LinuxIa32Syscall.java 2006-09-13 17:12:51.000000000 +0800 @@ -0,0 +1,531 @@ +// This file is part of the program FRYSK. +// +// Copyright 2006 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. + +package frysk.proc; + +import java.util.HashMap; + +public class LinuxIa32Syscall +{ + static final int SOCKET_NUM = 102; + static final int IPC_NUM = 117; + + // This is used to keep track of syscalls whose number we do not + // know. + static HashMap unknownSyscalls; + + static class Ia32Syscall + extends Syscall + { + Ia32Syscall (String name, int number, int numArgs, + String argList, boolean noreturn) + { + super (name, number, numArgs, argList, noreturn); + } + Ia32Syscall (String name, int number, int numArgs, String argList) + { + super (name, number, numArgs, argList); + } + Ia32Syscall (String name, int number, int numArgs) + { + super (name, number, numArgs); + } + Ia32Syscall (String name, int number) + { + super (name, number); + } + Ia32Syscall (int number) + { + super (number); + } + + public long getArguments (Task task, int n) + { + Isa isa; + try + { + isa = task.getIsa(); + } + catch (Exception e) + { + throw new RuntimeException ("Could not get isa"); + } + + switch (n) + { + case 0: + return isa.getRegisterByName ("orig_eax").get (task); + case 1: + return isa.getRegisterByName("ebx").get (task); + case 2: + return isa.getRegisterByName("ecx").get (task); + case 3: + return isa.getRegisterByName("edx").get (task); + case 4: + return isa.getRegisterByName("esi").get (task); + case 5: + return isa.getRegisterByName("edi").get (task); + case 6: + return isa.getRegisterByName("eax").get (task); + default: + throw new RuntimeException ("unknown syscall arg"); + } + } + public long getReturnCode (Task task) + { + Isa isa; + try + { + isa = task.getIsa(); + } + catch (Exception e) + { + throw new RuntimeException ("Could not get isa"); + } + return isa.getRegisterByName ("eax").get (task); + } + } + + static Syscall[] syscallList = { + new Ia32Syscall (0), + new Ia32Syscall ("exit", 1, 1), + new Ia32Syscall ("fork", 2, 0, "i: "), + new Ia32Syscall ("read", 3, 3, "i:ibn "), + new Ia32Syscall ("write", 4, 3, "i:ibn "), + new Ia32Syscall ("open", 5, 3, "i:siv "), + new Ia32Syscall ("close", 6, 1, "i:i "), + new Ia32Syscall ("waitpid", 7, 3, "i:ipi "), + new Ia32Syscall ("creat", 8, 2, "i:sv"), + new Ia32Syscall ("link", 9, 2, "i:ss "), + new Ia32Syscall ("unlink", 10, 1, "i:s "), + new Ia32Syscall ("execve", 11, 3, "i:ppp "), + new Ia32Syscall ("chdir", 12, 1, "i:s "), + new Ia32Syscall ("time", 13, 1, "i:P "), + new Ia32Syscall ("sys_mknod", 14, 3, "i:sii "), + new Ia32Syscall ("chmod", 15, 2, "i:si "), + new Ia32Syscall ("lchown", 16, 3, "i:sii "), + new Ia32Syscall ("break", 17), + new Ia32Syscall ("old_stat", 18, 3, "i:pp "), + new Ia32Syscall ("lseek", 19, 3, "i:iii "), + new Ia32Syscall ("getpid", 20, 0, "i: "), + new Ia32Syscall ("mount", 21, 5, "i:sssip "), + new Ia32Syscall ("umount", 22, 1, "i:s "), + new Ia32Syscall ("setuid", 23, 1, "i:i "), + new Ia32Syscall ("getuid", 24, 0, "i: "), + new Ia32Syscall ("stime", 25, 1, "i:p "), + new Ia32Syscall ("ptrace", 26, 4, "i:iiii "), + new Ia32Syscall ("alarm", 27, 1, "i:i "), + new Ia32Syscall ("old_fstat", 28, 2, "i:ip "), + new Ia32Syscall ("pause", 29, 0, "i: "), + new Ia32Syscall ("utime", 30, 2, "i:sP "), + new Ia32Syscall ("stty", 31), + new Ia32Syscall ("gtty", 32), + new Ia32Syscall ("access", 33, 2, "i:si "), + new Ia32Syscall ("nice", 34, 1, "i:i "), + new Ia32Syscall ("ftime", 35, 1, "i:p "), + new Ia32Syscall ("sync", 36, 0, "i: "), + new Ia32Syscall ("kill", 37, 2, "i:ii "), + new Ia32Syscall ("rename", 38, 2, "i:ss "), + new Ia32Syscall ("mkdir", 39, 2, "i:si "), + new Ia32Syscall ("rmdir", 40, 1, "i:s "), + new Ia32Syscall ("dup", 41, 1, "i:i "), + new Ia32Syscall ("pipe", 42, 1, "i:f "), + new Ia32Syscall ("times", 43, 1, "i:p "), + new Ia32Syscall ("prof", 44), + new Ia32Syscall ("brk", 45, 1, "i:p "), + new Ia32Syscall ("setgid", 46, 1, "i:i "), + new Ia32Syscall ("getgid", 47, 0, "i: "), + new Ia32Syscall ("signal", 48, 2, "i:ii "), + new Ia32Syscall ("geteuid", 49, 0, "i: "), + new Ia32Syscall ("getegid", 50, 0, "i: "), + new Ia32Syscall ("acct", 51, 1, "i:S "), + new Ia32Syscall ("umount2", 52, 2, "i:si "), + new Ia32Syscall ("lock", 53), + new Ia32Syscall ("ioctl", 54, 3, "i:iiI "), + new Ia32Syscall ("fcntl", 55, 3, "i:iiF "), + new Ia32Syscall ("mpx", 56), + new Ia32Syscall ("setpgid", 57, 2, "i:ii "), + new Ia32Syscall ("ulimit", 58, 2, "i:ii "), + new Ia32Syscall ("oldolduname", 59), + new Ia32Syscall ("umask", 60, 1, "i:i "), + new Ia32Syscall ("chroot", 61, 1, "i:s "), + new Ia32Syscall ("ustat", 62, 2, "i:ip "), + new Ia32Syscall ("dup2", 63, 2, "i:ii "), + new Ia32Syscall ("getppid", 64, 0, "i: "), + new Ia32Syscall ("getpgrp", 65, 0, "i: "), + new Ia32Syscall ("setsid", 66, 0, "i: "), + new Ia32Syscall ("sigaction", 67, 3, "i:ipp "), + new Ia32Syscall ("sgetmask", 68), + new Ia32Syscall ("ssetmask", 69), + new Ia32Syscall ("setreuid", 70, 2, "i:ii "), + new Ia32Syscall ("setregid", 71, 2, "i:ii "), + new Ia32Syscall ("sigsuspend", 72, 1, "i:p "), + new Ia32Syscall ("sigpending", 73, 1, "i:p "), + new Ia32Syscall ("sethostname", 74, 2, "i:pi "), + new Ia32Syscall ("setrlimit", 75, 2, "i:ip "), + new Ia32Syscall ("getrlimit", 76, 2, "i:ip "), + new Ia32Syscall ("getrusage", 77, 2, "i:ip "), + new Ia32Syscall ("gettimeofday", 78, 2, "i:PP "), + new Ia32Syscall ("settimeofday", 79, 2, "i:PP "), + new Ia32Syscall ("getgroups", 80, 2, "i:ip "), + new Ia32Syscall ("setgroups", 81, 2, "i:ip "), + new Ia32Syscall ("select", 82, 5, "i:iPPPP "), + new Ia32Syscall ("symlink", 83, 2, "i:ss "), + new Ia32Syscall ("oldlstat", 84, 2, "i:pp "), + new Ia32Syscall ("readlink", 85, 3, "i:spi "), + new Ia32Syscall ("uselib", 86, 1, "i:s "), + new Ia32Syscall ("swapon", 87, 2, "i:si "), + new Ia32Syscall ("reboot", 88, 1, "i:i "), + new Ia32Syscall (89), + new Ia32Syscall ("mmap", 90, 6, "b:aniiii "), + new Ia32Syscall ("munmap", 91, 2, "i:ai "), + new Ia32Syscall ("truncate", 92, 2, "i:si "), + new Ia32Syscall ("ftruncate", 93, 2, "i:ii "), + new Ia32Syscall ("fchmod", 94, 2, "i:ii "), + new Ia32Syscall ("fchown", 95, 3, "i:iii "), + new Ia32Syscall ("getpriority", 96, 2, "i:ii "), + new Ia32Syscall ("setpriority", 97, 3, "i:iii "), + new Ia32Syscall ("profil", 98, 4, "i:piii "), + new Ia32Syscall ("statfs", 99, 2, "i:sp "), + new Ia32Syscall ("fstatfs", 100, 2, "i:ip "), + new Ia32Syscall ("ioperm", 101, 3, "i:iii "), + new Ia32Syscall ("socketcall", 102, 2, "i:ip "), + new Ia32Syscall ("klogctl", 103, 3, "i:isi "), + new Ia32Syscall ("setitimer", 104, 3, "i:ipp "), + new Ia32Syscall ("getitimer", 105, 2, "i:ip "), + new Ia32Syscall ("sys_stat", 106, 2, "i:sp "), + new Ia32Syscall ("sys_lstat", 107, 2, "i:sp "), + new Ia32Syscall ("sys_fstat", 108, 2, "i:ip "), + new Ia32Syscall ("old_uname", 109, 1, "i:p "), + new Ia32Syscall ("iopl", 110, 1, "i:i "), + new Ia32Syscall ("vhangup", 111, 1, "i:i "), + new Ia32Syscall ("idle", 112, 0, "i: "), + new Ia32Syscall (113), + new Ia32Syscall ("wait4", 114, 4, "i:iWiP "), + new Ia32Syscall ("swapoff", 115, 1, "i:s "), + new Ia32Syscall ("sysinfo", 116, 1, "i:p "), + new Ia32Syscall ("ipc", 117, 6, "i:iiiipi "), + new Ia32Syscall ("fsync", 118, 1, "i:i "), + new Ia32Syscall ("sigreturn", 119), + new Ia32Syscall ("clone", 120, 2, "i:ip "), + new Ia32Syscall ("setdomain", 121, 2, "i:si "), + new Ia32Syscall ("uname", 122, 1, "i:p "), + new Ia32Syscall ("modify_ldt", 123, 3, "i:ipi "), + new Ia32Syscall ("adjtimex", 124, 1, "i:p "), + new Ia32Syscall ("mprotect", 125, 3, "i:aii "), + new Ia32Syscall ("sigprocmask", 126, 3, "i:ipp "), + new Ia32Syscall ("create_module", 127, 3), + new Ia32Syscall ("init_module", 128, 5), + new Ia32Syscall ("delete_module", 129, 3), + new Ia32Syscall ("get_kernel_syms", 130, 1, "i:p "), + new Ia32Syscall ("quotactl", 131, 4, "i:isip "), + new Ia32Syscall ("getpgid", 132, 1, "i:i "), + new Ia32Syscall ("fchdir", 133, 1, "i:i "), + new Ia32Syscall ("bdflush", 134, 2, "i:ii "), + new Ia32Syscall ("sysfs", 135, 1, "i:i "), + new Ia32Syscall ("personality", 136, 1, "i:i "), + new Ia32Syscall ("afs_syscall", 137), + new Ia32Syscall ("setfsuid", 138, 1, "i:i "), + new Ia32Syscall ("setfsgid", 139, 1, "i:i "), + new Ia32Syscall ("llseek", 140, 5, "i:iuupi "), + new Ia32Syscall ("s_getdents", 141, 3, "i:ipi "), + new Ia32Syscall ("select", 142, 5, "i:iPPPP "), + new Ia32Syscall ("flock", 143, 2, "i:ii "), + new Ia32Syscall ("msync", 144, 3, "i:aii "), + new Ia32Syscall ("readv", 145, 3, "i:ipi "), + new Ia32Syscall ("writev", 146, 3, "i:ipi "), + new Ia32Syscall ("getsid", 147, 1, "i:i "), + new Ia32Syscall ("fdatasync", 148, 1, "i:i "), + new Ia32Syscall ("sysctl", 149, 1, "i:p "), + new Ia32Syscall ("mlock", 150, 2, "i:bn "), + new Ia32Syscall ("munlock", 151, 2, "i:ai "), + new Ia32Syscall ("mlockall", 152, 1, "i:i "), + new Ia32Syscall ("munlockall", 153, 0, "i: "), + new Ia32Syscall ("sched_setp", 154, 2, "i:ip "), + new Ia32Syscall ("sched_getp", 155, 2, "i:ip "), + new Ia32Syscall ("sched_sets", 156, 3, "i:iip "), + new Ia32Syscall ("sched_gets", 157, 1, "i:i "), + new Ia32Syscall ("sched_yield", 158, 0, "i: "), + new Ia32Syscall ("sched_primax", 159, 1, "i:i "), + new Ia32Syscall ("sched_primin", 160, 1, "i:i "), + new Ia32Syscall ("sched_rr_gi", 161, 2, "i:ip "), + new Ia32Syscall ("nanosleep", 162, 2, "i:pp "), + new Ia32Syscall ("mremap", 163, 4, "b:aini "), + new Ia32Syscall ("setresuid", 164, 3, "i:iii "), + new Ia32Syscall ("getresuid", 165, 3, "i:ppp "), + new Ia32Syscall ("vm86", 166, 1, "i:p "), + new Ia32Syscall ("query_module", 167, 5, "i:sipip "), + new Ia32Syscall ("poll", 168, 3, "i:pii "), + new Ia32Syscall ("nfsservctl", 169, 3, "i:ipp "), + new Ia32Syscall ("setresgid", 170, 3, "i:iii "), + new Ia32Syscall ("getresgid", 171, 3, "i:ppp "), + new Ia32Syscall ("prctl", 172, 5, "i:iiiii "), + new Ia32Syscall ("rt_sigreturn", 173), + new Ia32Syscall ("rt_sigaction", 174), + new Ia32Syscall ("rt_sigprocmask", 175), + new Ia32Syscall ("rt_sigpending", 176), + new Ia32Syscall ("rt_sigtimedwait", 177), + new Ia32Syscall ("rt_sigqueueinfo", 178), + new Ia32Syscall ("rt_sigsuspend", 179), + new Ia32Syscall ("pread64", 180), + new Ia32Syscall ("pwrite64", 181), + new Ia32Syscall ("chown", 182, 3, "i:sii "), + new Ia32Syscall ("getcwd", 183, 2, "i:bi "), + new Ia32Syscall ("capget", 184, 2, "i:pp "), + new Ia32Syscall ("capset", 185, 2, "i:pp "), + new Ia32Syscall ("sigaltstack", 186, 2, "i:PP "), + new Ia32Syscall ("sendfile", 187, 4, "i:iipi "), + new Ia32Syscall ("getpmsg", 188), + new Ia32Syscall ("putpmsg", 189), + new Ia32Syscall ("vfork", 190, 0, "i: "), + new Ia32Syscall ("ugetrlimit", 191), + new Ia32Syscall ("mmap", 192, 6, "b:aniiii "), + new Ia32Syscall ("truncate64", 193, 3, "i:shl "), + new Ia32Syscall ("ftruncate64", 194, 3, "i:ihl "), + new Ia32Syscall ("stat64", 195, 2, "i:sp "), + new Ia32Syscall ("lstat64", 196, 2, "i:sp "), + new Ia32Syscall ("fstat64", 197, 2, "i:ip "), + new Ia32Syscall ("lchown32", 198, 3, "i:sii "), + new Ia32Syscall ("getuid32", 199), + new Ia32Syscall ("getgid32", 200), + new Ia32Syscall ("geteuid32", 201), + new Ia32Syscall ("getegid32", 202), + new Ia32Syscall ("setreuid32", 203, 2, "i:ii "), + new Ia32Syscall ("setregid32", 204, 2, "i:ii "), + new Ia32Syscall ("getgroups32", 205, 2, "i:ip "), + new Ia32Syscall ("setgroups32", 206, 2, "i:ip "), + new Ia32Syscall ("fchown32", 207, 3, "i:iii "), + new Ia32Syscall ("setresuid32", 208, 3, "i:iii "), + new Ia32Syscall ("getresuid32", 209, 3, "i:ppp "), + new Ia32Syscall ("setresgid32", 210, 3, "i:iii "), + new Ia32Syscall ("getresgid32", 211, 3, "i:ppp "), + new Ia32Syscall ("chown32", 212, 3, "i:sii "), + new Ia32Syscall ("setuid32", 213, 1, "i:i "), + new Ia32Syscall ("setgid32", 214, 1, "i:i "), + new Ia32Syscall ("setfsuid32", 215, 1, "i:i "), + new Ia32Syscall ("setfsgid32", 216, 1, "i:i "), + new Ia32Syscall ("pivot_root", 217, 2, "i:ss "), + new Ia32Syscall ("mincore", 218, 3, "i:anV "), + new Ia32Syscall ("madvise", 219, 3, "i:pii "), + new Ia32Syscall ("getdents64", 220, 3, "i:ipi "), + new Ia32Syscall ("fcntl64", 221, 3, "i:iip "), + new Ia32Syscall (222), + new Ia32Syscall (223), + new Ia32Syscall ("gettid", 224, 0), + new Ia32Syscall ("readahead", 225, 4, "i:ihli "), + new Ia32Syscall ("setxattr", 226), + new Ia32Syscall ("lsetxattr", 227), + new Ia32Syscall ("fsetxattr", 228), + new Ia32Syscall ("getxattr", 229), + new Ia32Syscall ("lgetxattr", 230), + new Ia32Syscall ("fgetxattr", 231), + new Ia32Syscall ("listxattr", 232), + new Ia32Syscall ("llistxattr", 233), + new Ia32Syscall ("flistxattr", 234), + new Ia32Syscall ("removexattr", 235), + new Ia32Syscall ("lremovexattr", 236), + new Ia32Syscall ("fremovexattr", 237), + new Ia32Syscall ("tkill", 238, 2, "i:ii "), + new Ia32Syscall ("sendfile64", 239, 4, "i:iipi "), + new Ia32Syscall ("futex", 240, 4, "i:piip "), + new Ia32Syscall ("sched_setaffinity", 241), + new Ia32Syscall ("sched_getaffinity", 242), + new Ia32Syscall ("set_thread_area", 243, 1, "i:p "), + new Ia32Syscall ("get_thread_area", 244, 1, "i:p "), + new Ia32Syscall ("io_setup", 245, 2, "i:ip "), + new Ia32Syscall ("io_destroy", 246, 1, "i:i "), + new Ia32Syscall ("io_getevents", 247, 5, "i:iiipp "), + new Ia32Syscall ("io_submit", 248, 3, "i:iip "), + new Ia32Syscall ("io_cancel", 249, 3, "i:ipp "), + new Ia32Syscall ("fadvise64", 250), + new Ia32Syscall (251), + new Ia32Syscall ("exit_group", 252, 1, " :i ", true), + new Ia32Syscall ("lookup_dcookie", 253), + new Ia32Syscall ("epoll_create", 254), + new Ia32Syscall ("epoll_ctl", 255), + new Ia32Syscall ("epoll_wait", 256), + new Ia32Syscall ("remap_file_pages", 257), + new Ia32Syscall ("set_tid_address", 258), + new Ia32Syscall ("timer_create", 259), + new Ia32Syscall ("timer_settime", 260), + new Ia32Syscall ("timer_gettime", 261), + new Ia32Syscall ("timer_getoverrun", 262), + new Ia32Syscall ("timer_delete", 263), + new Ia32Syscall ("clock_settime", 264), + new Ia32Syscall ("clock_gettime", 265), + new Ia32Syscall ("clock_getres", 266), + new Ia32Syscall ("clock_nanosleep", 267), + new Ia32Syscall ("statfs64", 268), + new Ia32Syscall ("fstatfs64", 269), + new Ia32Syscall ("tgkill", 270), + new Ia32Syscall ("utimes", 271), + new Ia32Syscall ("fadvise64_64", 272) + }; + + + static class SocketSubSyscall + extends Ia32Syscall + { + SocketSubSyscall (String name, int number) + { + super (name, number); + } + SocketSubSyscall (String name, int number, int numArgs, String argList) + { + super (name, number, numArgs, argList); + } + + public long getArguments (Task task, int n) + { + /** Arguments in socket subcalls are dereferenced. */ + Isa isa; + try + { + isa = task.getIsa(); + } + catch (Exception e) + { + throw new RuntimeException ("Could not get isa"); + } + long base = isa.getRegisterByName("ecx").get (task); + + //System.out.println(Long.toHexString(base) + " " + n); + return task.memory.getInt(base + (n-1) * isa.getWordSize()); + } + } + + static Syscall[] socketSubcallList = { + new SocketSubSyscall ("", SOCKET_NUM), + new SocketSubSyscall ("socket", SOCKET_NUM, 3, "i:iii"), + new SocketSubSyscall ("bind", SOCKET_NUM, 3, "i:ipi "), + new SocketSubSyscall ("connect", SOCKET_NUM, 3, "i:ipi "), + new SocketSubSyscall ("listen", SOCKET_NUM, 2, "i:ii "), + new SocketSubSyscall ("accept", SOCKET_NUM, 3, "i:ipp "), + new SocketSubSyscall ("getsockname",SOCKET_NUM, 3, "i:ipp "), + new SocketSubSyscall ("getpeername",SOCKET_NUM, 4, "i:iiip "), + new SocketSubSyscall ("socketpair", SOCKET_NUM, 4, "i:iiip "), + new SocketSubSyscall ("send", SOCKET_NUM, 4, "i:ipii "), + new SocketSubSyscall ("recv", SOCKET_NUM, 4, "i:ipii "), + new SocketSubSyscall ("sendto", SOCKET_NUM, 6, "i:ipiipi"), + new SocketSubSyscall ("recvfrom", SOCKET_NUM, 6, "i:ipiipp "), + new SocketSubSyscall ("shutdown", SOCKET_NUM, 2, "i:ii "), + new SocketSubSyscall ("setsockopt", SOCKET_NUM, 5, "i:iiipp "), + new SocketSubSyscall ("getsockopt", SOCKET_NUM, 5, "i:iiipp "), + new SocketSubSyscall ("sendmsg", SOCKET_NUM, 5, "i:iiipp "), + new SocketSubSyscall ("recvmsg", SOCKET_NUM, 5, "i:iiipp ") + }; + + + static class IpcSubSyscall + extends Ia32Syscall + { + IpcSubSyscall (String name, int number) + { + super (name, number); + } + IpcSubSyscall (String name, int number, int numArgs, String argList) + { + super (name, number, numArgs, argList); + } + public long getArguments (Task task, int n) + { + if (n == 0) + return super.getArguments (task, 0); + else + // these arguements are shifted by one. + return super.getArguments (task, n+1); + } + + } + /**FIXME: No argument list here.*/ + static Syscall[] ipcSubcallList = { + new IpcSubSyscall ("semop", IPC_NUM), + new IpcSubSyscall ("semget", IPC_NUM), + new IpcSubSyscall ("semctl", IPC_NUM), + new IpcSubSyscall ("semtimedop", IPC_NUM), + new IpcSubSyscall ("", IPC_NUM), + new IpcSubSyscall ("", IPC_NUM), + new IpcSubSyscall ("", IPC_NUM), + new IpcSubSyscall ("", IPC_NUM), + new IpcSubSyscall ("", IPC_NUM), + new IpcSubSyscall ("", IPC_NUM), + new IpcSubSyscall ("msgsnd", IPC_NUM), + new IpcSubSyscall ("msgrcv", IPC_NUM), + new IpcSubSyscall ("msgget", IPC_NUM), + new IpcSubSyscall ("msgctl", IPC_NUM), + new IpcSubSyscall ("", IPC_NUM), + new IpcSubSyscall ("", IPC_NUM), + new IpcSubSyscall ("", IPC_NUM), + new IpcSubSyscall ("", IPC_NUM), + new IpcSubSyscall ("", IPC_NUM), + new IpcSubSyscall ("", IPC_NUM), + new IpcSubSyscall ("shmat", IPC_NUM), + new IpcSubSyscall ("shmdt", IPC_NUM), + new IpcSubSyscall ("shmget", IPC_NUM), + new IpcSubSyscall ("shmctl", IPC_NUM) + }; + + public static Syscall syscallByNum (Task task, int number) + { + if (number != SOCKET_NUM && number != IPC_NUM) + return Syscall.syscallByNum (number, task); + else + { + /** sub syscall number is in %ebx. */ + int subSyscallNumber = 0; + try + { + subSyscallNumber = (int) task.getIsa().getRegisterByName("ebx").get (task); + } + catch (Exception e) + { + throw new RuntimeException ("Could not get isa"); + } + + if (number == SOCKET_NUM) + { + return socketSubcallList[subSyscallNumber]; + } + else + { + return ipcSubcallList[subSyscallNumber]; + } + } + } +} --- /dev/null 2006-09-01 16:42:34.468363500 +0800 +++ frysk-core/frysk/proc/LinuxEMT64Syscall.java 2006-09-13 17:29:38.000000000 +0800 @@ -0,0 +1,383 @@ +// This file is part of the program FRYSK. +// +// Copyright 2005, 2006 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. + +package frysk.proc; + +import java.util.HashMap; + +public class LinuxEMT64Syscall +{ + + // This is used to keep track of syscalls whose number we do not + // know. + static HashMap unknownSyscalls; + + static class EMT64Syscall + extends Syscall + { + EMT64Syscall (String name, int number, int numArgs, + String argList, boolean noreturn) + { + super (name, number, numArgs, argList, noreturn); + } + EMT64Syscall (String name, int number, int numArgs, String argList) + { + super (name, number, numArgs, argList); + } + EMT64Syscall (String name, int number, int numArgs) + { + super (name, number, numArgs); + } + EMT64Syscall (String name, int number) + { + super (name, number); + } + EMT64Syscall (int number) + { + super (number); + } + public long getArguments (Task task, int n) + { + Isa isa; + try + { + isa = task.getIsa(); + } + catch (Exception e) + { + throw new RuntimeException ("Could not get isa"); + } + + switch (n) { + case 0: + return isa.getRegisterByName ("orig_rax").get(task); + case 1: + return isa.getRegisterByName("rdi").get(task); + case 2: + return isa.getRegisterByName("rsi").get (task); + case 3: + return isa.getRegisterByName("rdx").get (task); + case 4: + return isa.getRegisterByName("r10").get (task); + case 5: + return isa.getRegisterByName("r8").get (task); + case 6: + return isa.getRegisterByName("r9").get (task); + default: + throw new RuntimeException ("unknown syscall arg"); + } + } + public long getReturnCode (Task task) + { + Isa isa; + try + { + isa = task.getIsa(); + } + catch (Exception e) + { + throw new RuntimeException ("Could not get isa"); + } + return isa.getRegisterByName ("rax").get (task); + } + } + static Syscall[] syscallList = { + new EMT64Syscall ("read", 0, 3, "i:ibn "), + new EMT64Syscall ("write", 1, 3, "i:ibn "), + new EMT64Syscall ("open", 2, 3, "i:siv "), + new EMT64Syscall ("close", 3, 1, "i:i "), + new EMT64Syscall ("stat", 4, 2, "i:sp "), + new EMT64Syscall ("fstat", 5, 2, "i:ip "), + new EMT64Syscall ("lstat", 6, 2, "i:sp "), + new EMT64Syscall ("poll", 7, 3, "i:pii "), + new EMT64Syscall ("lseek", 8, 3, "i:iii "), + new EMT64Syscall ("mmap", 9, 6, "b:aniiii "), + new EMT64Syscall ("mprotect", 10, 3, "i:aii "), + new EMT64Syscall ("munmap", 11, 2, "i:ai "), + new EMT64Syscall ("brk", 12, 1, "i:p "), + new EMT64Syscall ("rt_sigaction", 13), + new EMT64Syscall ("rt_sigprocmask", 14), + new EMT64Syscall ("rt_sigreturn", 15), + new EMT64Syscall ("ioctl", 16, 3, "i:iiI "), + new EMT64Syscall ("pread64", 17), + new EMT64Syscall ("pwrite64", 18), + new EMT64Syscall ("readv", 19, 3, "i:ipi "), + new EMT64Syscall ("writev", 20, 3, "i:ipi "), + new EMT64Syscall ("access", 21, 2, "i:si "), + new EMT64Syscall ("pipe", 22, 1, "i:f "), + new EMT64Syscall ("select", 23, 5, "i:iPPPP "), + new EMT64Syscall ("sched_yield", 24, 0, "i: "), + new EMT64Syscall ("mremap", 25, 4, "b:aini "), + new EMT64Syscall ("msync", 26, 3, "i:aii "), + new EMT64Syscall ("mincore", 27, 3, "i:anV "), + new EMT64Syscall ("madvise", 28, 3, "i:pii "), + new EMT64Syscall ("shmget", 29, 3, "i:iii "), + new EMT64Syscall ("shmat", 30, 3, "p:ipi "), + new EMT64Syscall ("shmctl", 31, 3, "i:iip "), + new EMT64Syscall ("dup", 32, 1, "i:i "), + new EMT64Syscall ("dup2", 33, 2, "i:ii "), + new EMT64Syscall ("pause", 34, 0, "i: "), + new EMT64Syscall ("nanosleep", 35, 2, "i:pp "), + new EMT64Syscall ("getitimer", 36, 2, "i:ip "), + new EMT64Syscall ("alarm", 37, 1, "i:i "), + new EMT64Syscall ("setitimer", 38, 3, "i:ipp "), + new EMT64Syscall ("getpid", 39, 0, "i: "), + new EMT64Syscall ("sendfile", 40, 4, "i:iipi "), + new EMT64Syscall ("socket", 41, 3, "i:iii "), + new EMT64Syscall ("connect", 42), + new EMT64Syscall ("accept", 43), + new EMT64Syscall ("sendto", 44), + new EMT64Syscall ("recvfrom", 45), + new EMT64Syscall ("sendmsg", 46), + new EMT64Syscall ("recvmsg", 47), + new EMT64Syscall ("shutdown", 48), + new EMT64Syscall ("bind", 49, 3, "i:ipi "), + new EMT64Syscall ("listen", 50, 2, "i:ii "), + new EMT64Syscall ("getsockname", 51, 3, "i:ipp "), + new EMT64Syscall ("getpeername", 52, 4, "i:iiip "), + new EMT64Syscall ("socketpair", 53, 4, "i:iiip "), + new EMT64Syscall ("setsockopt", 54, 5, "i:iiipp "), + new EMT64Syscall ("getsockopt", 55, 5, "i:iiipp "), + new EMT64Syscall ("clone", 56, 2, "i:ip "), + new EMT64Syscall (58), + new EMT64Syscall ("fork", 57, 0, "i: "), + new EMT64Syscall ("execve", 59, 3, "i:ppp "), + new EMT64Syscall ("exit", 60, 1), + new EMT64Syscall ("wait4", 61, 4, "i:iWiP "), + new EMT64Syscall ("kill", 62, 2, "i:ii "), + new EMT64Syscall ("uname", 63, 1, "i:p "), + new EMT64Syscall ("semget", 64), + new EMT64Syscall ("semop", 65), + new EMT64Syscall ("semctl", 66), + new EMT64Syscall ("shmdt", 67), + new EMT64Syscall ("msgget", 68), + new EMT64Syscall ("msgsnd", 69), + new EMT64Syscall ("msgrcv", 70), + new EMT64Syscall ("msgctl", 71), + new EMT64Syscall ("fcntl", 72, 3, "i:iiF "), + new EMT64Syscall ("flock", 73, 2, "i:ii "), + new EMT64Syscall ("fsync", 74, 1, "i:i "), + new EMT64Syscall ("fdatasync", 75, 1, "i:i "), + new EMT64Syscall ("truncate", 76, 2, "i:si "), + new EMT64Syscall ("ftruncate", 77, 2, "i:ii "), + new EMT64Syscall ("getdents", 78), + new EMT64Syscall ("getcwd", 79, 2, "i:bi "), + new EMT64Syscall ("chdir", 80, 1, "i:s "), + new EMT64Syscall ("fchdir", 81, 1, "i:i "), + new EMT64Syscall ("rename", 82, 2, "i:ss "), + new EMT64Syscall ("mkdir", 83, 2, "i:si "), + new EMT64Syscall ("rmdir", 84, 1, "i:s "), + new EMT64Syscall ("creat", 85, 2, "i:sv"), + new EMT64Syscall ("link", 86, 2, "i:ss "), + new EMT64Syscall ("unlink", 87, 1, "i:s "), + new EMT64Syscall ("symlink", 88, 2, "i:ss "), + new EMT64Syscall ("readlink", 89, 3, "i:spi "), + new EMT64Syscall ("chmod", 90, 2, "i:si "), + new EMT64Syscall ("fchmod", 91, 2, "i:ii "), + new EMT64Syscall ("chown", 92, 3, "i:sii "), + new EMT64Syscall ("fchown", 93, 3, "i:iii "), + new EMT64Syscall ("lchown", 94, 3, "i:sii "), + new EMT64Syscall ("umask", 95, 1, "i:i "), + new EMT64Syscall ("gettimeofday", 96, 2, "i:PP "), + new EMT64Syscall ("getrlimit", 97, 2, "i:ip "), + new EMT64Syscall ("getrusage", 98, 2, "i:ip "), + new EMT64Syscall ("sysinfo", 99, 1, "i:p "), + new EMT64Syscall ("times", 100, 1, "i:p "), + new EMT64Syscall ("ptrace", 101, 4, "i:iiii "), + new EMT64Syscall ("getuid", 102, 0, "i: "), + new EMT64Syscall ("syslog", 103), + new EMT64Syscall ("getgid", 104, 0, "i: "), + new EMT64Syscall ("setuid", 105, 1, "i:i "), + new EMT64Syscall ("setgid", 106, 1, "i:i "), + new EMT64Syscall ("geteuid", 107, 0, "i: "), + new EMT64Syscall ("getegid", 108, 0, "i: "), + new EMT64Syscall ("setpgid", 109, 2, "i:ii "), + new EMT64Syscall ("getppid", 110, 0, "i: "), + new EMT64Syscall ("getpgrp", 111, 0, "i: "), + new EMT64Syscall ("setsid", 112, 0, "i: "), + new EMT64Syscall ("setreuid", 113, 2, "i:ii "), + new EMT64Syscall ("setregid", 114, 2, "i:ii "), + new EMT64Syscall ("getgroups", 115, 2, "i:ip "), + new EMT64Syscall ("setgroups", 116, 2, "i:ip "), + new EMT64Syscall ("setresuid", 117, 3, "i:iii "), + new EMT64Syscall ("getresuid", 118, 3, "i:ppp "), + new EMT64Syscall ("setresgid", 119, 3, "i:iii "), + new EMT64Syscall ("getresgid", 120, 3, "i:ppp "), + new EMT64Syscall ("getpgid", 121, 1, "i:i "), + new EMT64Syscall ("setfsuid", 122, 1, "i:i "), + new EMT64Syscall ("setfsgid", 123, 1, "i:i "), + new EMT64Syscall ("getsid", 124, 1, "i:i "), + new EMT64Syscall ("capget", 125, 2, "i:pp "), + new EMT64Syscall ("capset", 126, 2, "i:pp "), + new EMT64Syscall ("rt_sigpending", 127, 2, "i:pi "), + new EMT64Syscall ("rt_sigtimedwait", 128, 4, "i:pppi " ), + new EMT64Syscall ("rt_sigqueueinfo", 129 ), + new EMT64Syscall ("rt_sigsuspend", 130 ), + new EMT64Syscall ("sigaltstack", 131, 2, "i:PP "), + new EMT64Syscall ("utime", 132, 2, "i:sP "), + new EMT64Syscall ("mknod", 133, 3, "i:sii "), + new EMT64Syscall ("uselib", 134, 1, "i:s "), + new EMT64Syscall ("personality", 135, 1, "i:i "), + new EMT64Syscall ("ustat", 136, 2, "i:ip "), + new EMT64Syscall ("statfs", 137, 2, "i:sp "), + new EMT64Syscall ("fstatfs", 138, 2, "i:ip "), + new EMT64Syscall ("sysfs", 139, 1, "i:i "), + new EMT64Syscall ("getpriority", 140, 2, "i:ii "), + new EMT64Syscall ("setpriority", 141, 3, "i:iii "), + new EMT64Syscall ("sched_setparam", 142), + new EMT64Syscall ("sched_getparam", 143), + new EMT64Syscall ("sched_setscheduler", 144), + new EMT64Syscall ("sched_getscheduler", 145), + new EMT64Syscall ("sched_get_priority_max", 146), + new EMT64Syscall ("sched_get_priority_min", 147), + new EMT64Syscall ("sched_rr_get_interval", 148), + new EMT64Syscall ("mlock", 149, 2, "i:bn "), + new EMT64Syscall ("munlock", 150, 2, "i:ai "), + new EMT64Syscall ("mlockall", 151, 1, "i:i "), + new EMT64Syscall ("munlockall", 152, 0, "i: "), + new EMT64Syscall ("vhangup", 153, 1, "i:i "), + new EMT64Syscall ("modify_ldt", 154, 3, "i:ipi "), + new EMT64Syscall ("pivot_root", 155, 2, "i:ss "), + new EMT64Syscall ("_sysctl", 156), + new EMT64Syscall ("prctl", 157, 5, "i:iiiii "), + new EMT64Syscall ("arch_prctl", 158), + new EMT64Syscall ("adjtimex", 159, 1, "i:p "), + new EMT64Syscall ("setrlimit", 160, 2, "i:ip "), + new EMT64Syscall ("chroot", 161, 1, "i:s "), + new EMT64Syscall ("sync", 162, 0, "i: "), + new EMT64Syscall ("acct", 163, 1, "i:S "), + new EMT64Syscall ("settimeofday", 164, 2, "i:PP "), + new EMT64Syscall ("mount", 165, 5, "i:sssip "), + new EMT64Syscall ("umount2", 166, 2, "i:si "), + new EMT64Syscall ("swapon", 167, 2, "i:si "), + new EMT64Syscall ("swapoff", 168, 1, "i:s "), + new EMT64Syscall ("reboot", 169, 1, "i:i "), + new EMT64Syscall ("sethostname", 170, 2, "i:pi "), + new EMT64Syscall ("setdomainname", 171), + new EMT64Syscall ("iopl", 172, 1, "i:i "), + new EMT64Syscall ("ioperm", 173, 3, "i:iii "), + new EMT64Syscall ("create_module", 174, 3), + new EMT64Syscall ("init_module", 175, 5), + new EMT64Syscall ("delete_module", 176, 3), + new EMT64Syscall ("get_kernel_syms", 177, 1, "i:p "), + new EMT64Syscall ("query_module", 178, 5, "i:sipip "), + new EMT64Syscall ("quotactl", 179, 4, "i:isip "), + new EMT64Syscall ("nfsservctl", 180, 3, "i:ipp "), + new EMT64Syscall ("getpmsg", 181), + new EMT64Syscall ("putpmsg", 182), + new EMT64Syscall ("afs_syscall", 183), + new EMT64Syscall ("tuxcall", 184), + new EMT64Syscall ("security", 185), + new EMT64Syscall ("gettid", 186, 0), + new EMT64Syscall ("readahead", 187, 4, "i:ihli "), + new EMT64Syscall ("setxattr", 188), + new EMT64Syscall ("lsetxattr", 189 ), + new EMT64Syscall ("fsetxattr", 190 ), + new EMT64Syscall ("getxattr", 191 ), + new EMT64Syscall ("lgetxattr", 192 ), + new EMT64Syscall ("fgetxattr", 193 ), + new EMT64Syscall ("listxattr", 194 ), + new EMT64Syscall ("llistxattr", 195 ), + new EMT64Syscall ("flistxattr", 196 ), + new EMT64Syscall ("removexattr", 197 ), + new EMT64Syscall ("lremovexattr", 198 ), + new EMT64Syscall ("fremovexattr", 199 ), + new EMT64Syscall ("tkill", 200, 2, "i:ii "), + new EMT64Syscall ("time", 201, 1, "i:P "), + new EMT64Syscall ("futex", 202, 4, "i:piip "), + new EMT64Syscall ("sched_setaffinity", 203 ), + new EMT64Syscall ("sched_getaffinity", 204 ), + new EMT64Syscall ("set_thread_area", 205, 1, "i:p "), + new EMT64Syscall ("io_setup", 206, 2, "i:ip "), + new EMT64Syscall ("io_destroy", 207, 1, "i:i "), + new EMT64Syscall ("io_getevents", 208, 5, "i:iiipp "), + new EMT64Syscall ("io_submit", 209, 3, "i:iip "), + new EMT64Syscall ("io_cancel", 210, 3, "i:ipp "), + new EMT64Syscall ("get_thread_area", 211, 1, "i:p "), + new EMT64Syscall ("lookup_dcookie", 212), + new EMT64Syscall ("epoll_create", 213), + new EMT64Syscall ("epoll_ctl_old", 214), + new EMT64Syscall ("epoll_wait_old", 215), + new EMT64Syscall ("remap_file_pages", 216), + new EMT64Syscall ("getdents64", 217, 3, "i:ipi "), + new EMT64Syscall ("set_tid_address", 218), + new EMT64Syscall ("restart_syscall", 219), + new EMT64Syscall ("semtimedop", 220), + new EMT64Syscall ("fadvise64", 221), + new EMT64Syscall ("timer_create", 222), + new EMT64Syscall ("timer_settime", 223), + new EMT64Syscall (224), + new EMT64Syscall (225), + new EMT64Syscall ("timer_delete", 226), + new EMT64Syscall ("clock_settime", 227), + new EMT64Syscall ("clock_gettime", 228), + new EMT64Syscall ("clock_getres", 229), + new EMT64Syscall ("clock_nanosleep", 230), + new EMT64Syscall ("exit_group", 231, 1, " :i "), + new EMT64Syscall ("epoll_wait", 232), + new EMT64Syscall ("epoll_ctl", 233), + new EMT64Syscall ("tgkill", 234), + new EMT64Syscall ("utimes", 235), + new EMT64Syscall ("vserver", 236), + new EMT64Syscall ("mbind", 237), + new EMT64Syscall ("set_mempolicy", 238), + new EMT64Syscall ("get_mempolicy", 239), + new EMT64Syscall ("mq_open", 240), + new EMT64Syscall ("mq_unlink", 241), + new EMT64Syscall ("mq_timedsend", 242), + new EMT64Syscall ("mq_timedreceive", 243), + new EMT64Syscall ("mq_notify", 244), + new EMT64Syscall ("mq_getsetattr", 245), + new EMT64Syscall ("kexec_load", 246), + new EMT64Syscall ("waitid", 247), + new EMT64Syscall ("add_key", 248), + new EMT64Syscall ("request_key", 249), + new EMT64Syscall ("keyctl", 250), + new EMT64Syscall ("ioprio_set", 251), + new EMT64Syscall ("ioprio_get", 252), + new EMT64Syscall ("inotify_init", 253), + new EMT64Syscall ("inotify_add_watch", 254), + new EMT64Syscall ("inotify_rm_watch", 255) + }; + + public static Syscall syscallByNum (Task task, int number) + { + return Syscall.syscallByNum (number, task); + } +}