|
@@ -6,10 +6,12 @@ class DebugStdio
|
|
|
var inDebugger:Bool;
|
|
|
var inputThread:Thread;
|
|
|
var debugQueue:Deque<Dynamic>;
|
|
|
+ var files:Array<String>;
|
|
|
|
|
|
|
|
|
public function new()
|
|
|
{
|
|
|
+ files = Debugger.getFiles();
|
|
|
inDebugger = false;
|
|
|
Debugger.setHandler(onDebug);
|
|
|
debugQueue= new Deque<Dynamic>();
|
|
@@ -18,6 +20,7 @@ class DebugStdio
|
|
|
|
|
|
function onDebug()
|
|
|
{
|
|
|
+ Sys.println("stopped.");
|
|
|
inDebugger = true;
|
|
|
while(inDebugger)
|
|
|
{
|
|
@@ -51,6 +54,42 @@ class DebugStdio
|
|
|
Sys.println("Frame " + inI + " : " + result );
|
|
|
}
|
|
|
|
|
|
+ function showFiles()
|
|
|
+ {
|
|
|
+ if (files!=null)
|
|
|
+ for(idx in 0...files.length)
|
|
|
+ Sys.println("file " + idx + " : " + files[idx] );
|
|
|
+ }
|
|
|
+
|
|
|
+ function showBreakpoints()
|
|
|
+ {
|
|
|
+ var bps = Debugger.getBreakpoints();
|
|
|
+ if (bps!=null)
|
|
|
+ for(idx in 0...bps.length)
|
|
|
+ Sys.println("breakpoint " + idx + " : " + bps[idx] );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ function addBreakpoint(inFile:String, inLine:String)
|
|
|
+ {
|
|
|
+ var id = Std.parseInt(inFile);
|
|
|
+ if (id==null)
|
|
|
+ {
|
|
|
+ for(idx in 0...files.length)
|
|
|
+ if (files[idx]==inFile)
|
|
|
+ {
|
|
|
+ id = idx;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (id==null)
|
|
|
+ Sys.println("Could not find file for " + inFile );
|
|
|
+ else
|
|
|
+ Debugger.addBreakpoint(id,Std.parseInt(inLine));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
function inputLoop()
|
|
|
{
|
|
@@ -60,27 +99,40 @@ class DebugStdio
|
|
|
Sys.print("debug >");
|
|
|
var command = input.readLine();
|
|
|
var words = command.split(" ");
|
|
|
- if (words.length>0) switch(words[0])
|
|
|
+ switch(words[0])
|
|
|
{
|
|
|
- case "exit":
|
|
|
- Debugger.exit();
|
|
|
+ case "":
|
|
|
+ // Do nothing
|
|
|
|
|
|
- case "break":
|
|
|
- if (inDebugger)
|
|
|
- Sys.println("already stopped.");
|
|
|
- else
|
|
|
- {
|
|
|
- Debugger.setBreak(Debugger.BRK_ASAP,inputThread);
|
|
|
- waitDebugger();
|
|
|
- }
|
|
|
+ case "exit","quit":
|
|
|
+ Debugger.exit();
|
|
|
|
|
|
- case "cont":
|
|
|
+ case "break","b":
|
|
|
+ if (words.length==1)
|
|
|
+ {
|
|
|
+ if (inDebugger)
|
|
|
+ Sys.println("already stopped.");
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Debugger.setBreak(Debugger.BRK_ASAP,inputThread);
|
|
|
+ waitDebugger();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (words.length==3)
|
|
|
+ {
|
|
|
+ addBreakpoint(words[1],words[2]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ Sys.println("Usage: break [file line] - pause execution of one thread [when at certain point]");
|
|
|
+
|
|
|
+
|
|
|
+ case "cont","c":
|
|
|
if (!inDebugger)
|
|
|
Sys.println("Already running.");
|
|
|
else
|
|
|
debugQueue.add( function() inDebugger = false );
|
|
|
|
|
|
- case "vars":
|
|
|
+ case "vars","v":
|
|
|
if (!inDebugger)
|
|
|
Sys.println("Must break first.");
|
|
|
else
|
|
@@ -91,7 +143,7 @@ class DebugStdio
|
|
|
}
|
|
|
|
|
|
|
|
|
- case "where":
|
|
|
+ case "where","w":
|
|
|
if (!inDebugger)
|
|
|
Sys.println("Must break first.");
|
|
|
else
|
|
@@ -100,16 +152,37 @@ class DebugStdio
|
|
|
waitDebugger();
|
|
|
}
|
|
|
|
|
|
- case "help":
|
|
|
+ case "files","f":
|
|
|
+ showFiles();
|
|
|
+
|
|
|
+ case "breakpoints","bp":
|
|
|
+ showBreakpoints();
|
|
|
+
|
|
|
+ case "delete","d":
|
|
|
+ if (words[1]==null)
|
|
|
+ {
|
|
|
+ Sys.println("Usage : delete N");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var i = Std.parseInt(words[1]);
|
|
|
+ Debugger.deleteBreakpoint(i);
|
|
|
+ }
|
|
|
+
|
|
|
+ case "help","h","?":
|
|
|
Sys.println("help - print this message");
|
|
|
- Sys.println("break - pause execution of one thread");
|
|
|
+ Sys.println("break [file line] - pause execution of one thread [when at certain point]");
|
|
|
+ Sys.println("breakpoints - list breakpoints");
|
|
|
+ Sys.println("delete N - delete breakpoint N");
|
|
|
Sys.println("cont - continue execution");
|
|
|
Sys.println("where - print call stack");
|
|
|
+ Sys.println("files - print file list that may be used with breakpoints");
|
|
|
Sys.println("vars N - print local vars for frame N");
|
|
|
Sys.println("exit - exit programme");
|
|
|
|
|
|
+
|
|
|
default:
|
|
|
- Sys.println("Unknown command:" + command);
|
|
|
+ Sys.println("Unknown command:" + words);
|
|
|
}
|
|
|
}
|
|
|
}
|