diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..fceb480 --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..68b32d5 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + PAva-P1 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3a21537 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/bin/build.xml b/bin/build.xml new file mode 100644 index 0000000..e69de29 diff --git a/src/build.xml b/src/build.xml new file mode 100644 index 0000000..e69de29 diff --git a/src/ist/meic/pa/DebuggerCLI.java b/src/ist/meic/pa/DebuggerCLI.java new file mode 100644 index 0000000..d577785 --- /dev/null +++ b/src/ist/meic/pa/DebuggerCLI.java @@ -0,0 +1,94 @@ +package ist.meic.pa; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +public class DebuggerCLI { + + public static void main(String[] args) { + + String programToDebug = args[0]; + + try { + + + // TODO: ir buscar class 'a classpool + + // Get class of the program to debug + Class program = Class.forName(programToDebug); + // Get the method 'main' of the program to debug + Method main = program.getMethod("main", String[].class); + + // main_args: arguments of the program to debug + String[] main_args = new String[args.length - 1]; + + // Get the arguments + for(int i = 1; i < args.length; i++){ + main_args[i - 1] = args[i]; + } + + // Invoke the main method with the respective arguments + main.invoke(null, (Object) main_args); + + + } catch (InvocationTargetException ite){ + + System.out.print("DebuggerCLI:> "); + String input = System.console().readLine(); + System.out.println("Command: " + input); + + String[] split_input = input.split(" "); + String command = split_input[0]; + + // Abort: + // Terminates the execution of the application + if (command.equals("Abort")){ + return; + + // Info: + // Presents detailed information about the called object, its fields, + // and the call stack. The presented information follows the format + // described in the next section. + } else if (command.equals("Info")){ + + // Throw: + // Re-throws the exception, so that it may be handled by the next handler. + } else if (command.equals("Throw")){ + + // Return : + // Ignores the exception and continues the execution of the application + // assuming that the current method call returned . For calls to methods + // returning void the is ignored. Note that should be of a + // primitive type. + } else if (command.equals("Return")) { + + String value = split_input[1]; + + } else if(command.equals("Get")){ + + } else if(command.equals("Set")){ + + } else if(command.equals("Retry")){ + + } else { + System.out.println("Unrecognized command"); + return; + } + + } catch(ArrayIndexOutOfBoundsException aiobe){ + + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + + } + +} diff --git a/src/ist/meic/pa/package-info.java b/src/ist/meic/pa/package-info.java new file mode 100644 index 0000000..1f4d29a --- /dev/null +++ b/src/ist/meic/pa/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author ASUS + * + */ +package ist.meic.pa; \ No newline at end of file diff --git a/src/ist/meic/pa/test/Test01.java b/src/ist/meic/pa/test/Test01.java new file mode 100644 index 0000000..90d47b5 --- /dev/null +++ b/src/ist/meic/pa/test/Test01.java @@ -0,0 +1,24 @@ +package ist.meic.pa.test; + +public class Test01 { + + public static void a() throws ArrayIndexOutOfBoundsException{ b(); } + + public static void b() throws ArrayIndexOutOfBoundsException { c(); } + + public static void c() { throw new ArrayIndexOutOfBoundsException(); } + + public static void main(String[] args){ + + // Print arguments + for(int i = 0; i < args.length; i++){ + + System.out.println("Argument " + i + ": " + args[i]); + + } + + a(); + + } + +} diff --git a/src/ist/meic/pa/test/package-info.java b/src/ist/meic/pa/test/package-info.java new file mode 100644 index 0000000..df700d8 --- /dev/null +++ b/src/ist/meic/pa/test/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author ASUS + * + */ +package ist.meic.pa.test; \ No newline at end of file