Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreJoaquim committed Mar 23, 2015
1 parent c08adcc commit 9f92cb2
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>PAva-P1</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -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
Empty file added bin/build.xml
Empty file.
Empty file added src/build.xml
Empty file.
94 changes: 94 additions & 0 deletions src/ist/meic/pa/DebuggerCLI.java
Original file line number Diff line number Diff line change
@@ -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 <value>:
// Ignores the exception and continues the execution of the application
// assuming that the current method call returned <value>. For calls to methods
// returning void the <value> is ignored. Note that <value> 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();
}

}

}
8 changes: 8 additions & 0 deletions src/ist/meic/pa/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
*
*/
/**
* @author ASUS
*
*/
package ist.meic.pa;
24 changes: 24 additions & 0 deletions src/ist/meic/pa/test/Test01.java
Original file line number Diff line number Diff line change
@@ -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();

}

}
8 changes: 8 additions & 0 deletions src/ist/meic/pa/test/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
*
*/
/**
* @author ASUS
*
*/
package ist.meic.pa.test;

0 comments on commit 9f92cb2

Please sign in to comment.