add better debugging capabilities, add native to enable debugging OTF
This commit is contained in:
parent
a094bcff5d
commit
e28ad23a7f
1 changed files with 27 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.net.BindException;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -761,6 +762,16 @@ public class ISBPL {
|
||||||
throw new ISBPLError("IO", e.getMessage());
|
throw new ISBPLError("IO", e.getMessage());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
break;
|
||||||
|
case "_enable_debug":
|
||||||
|
func = (File file) -> {
|
||||||
|
if(debuggerIPC.threadID == -1) {
|
||||||
|
new ISBPLDebugger(this).start();
|
||||||
|
stack.push(new ISBPLObject(getType("int"), 1));
|
||||||
|
}
|
||||||
|
stack.push(new ISBPLObject(getType("int"), 0));
|
||||||
|
};
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
functionStack.peek().put(name, func);
|
functionStack.peek().put(name, func);
|
||||||
}
|
}
|
||||||
|
@ -1260,7 +1271,21 @@ class ISBPLDebugger extends Thread {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
ServerSocket socket = new ServerSocket(Integer.parseInt(System.getenv("DEBUG")));
|
ServerSocket socket = null;
|
||||||
|
try {
|
||||||
|
socket = new ServerSocket(Integer.parseInt(System.getenv().getOrDefault("DEBUG", "9736")));
|
||||||
|
System.err.println("Debugger listening on :" + socket.getLocalPort());
|
||||||
|
}
|
||||||
|
catch (BindException e) {
|
||||||
|
while (socket == null) {
|
||||||
|
try {
|
||||||
|
socket = new ServerSocket((int) (Math.random() * 5000 + 5000));
|
||||||
|
System.err.println("Debugger listening on :" + socket.getLocalPort());
|
||||||
|
}
|
||||||
|
catch (BindException ignored) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isbpl.debuggerIPC.threadID = Thread.currentThread().getId();
|
||||||
while (true) {
|
while (true) {
|
||||||
Socket s = socket.accept();
|
Socket s = socket.accept();
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
|
||||||
|
@ -1371,7 +1396,7 @@ class ISBPLDebugger extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
static class IPC {
|
static class IPC {
|
||||||
long threadID;
|
long threadID = -1;
|
||||||
String until = null;
|
String until = null;
|
||||||
int run = -1;
|
int run = -1;
|
||||||
Stack<ISBPLObject> stack = null;
|
Stack<ISBPLObject> stack = null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue