Breakpoint is a pair of filename-line number which specifies a location where debugger should pause the program
Debug server is a server that is launched within your Quail main process and which handles breakpoints and other debugger commands
Debug client is a program that is launched separately and which connects to debug server via a socket connection to deliver commands and grab program execution data
Debug server and debug client connect via sockets. Debug server should be started first and only then debug client should be launched.
Debug server and debug client exchange messages via sockets. Messages are
strings (not binary) that are separated by \n
. E.g. if you want to send
command stop
, you should do:
socketBufferedWriter.write("stop\n");
socketBufferedWriter.flush();
Following types of messages are supported (as of 2.0.0-alpha.6
):
Syntax: stop
Semantics: forces the program execution to stop
Syntax: next
Semantics: forces the program to resume execution and stop on the next line
Syntax: continue
Semantics: forces the program to resume until it encounters another breakpoint
Syntax: mem
Semantics: requests all contents of memory that are visible in current scope.
Returns messages:
memresult\n
\n
\n
variable;value
.\n
)endmem\n
Example:
Memory contains:
a = 15
b = 14
Request is:
mem
Answer is:
memresult
3
a;15 # but encoded in base64
b;14 # but encoded in base64
endmem
Syntax: eval
then code to evaluate encoded in base64 (in 2 separate messages)
Semantics: evaluate given expression in current runtime and scope
Returns messages:
evalresult
Expression is:
a = 14
Request is:
eval
a = 14 # but encoded in base64
Answer is:
evalresult
null # since a = 14 does not return anything
If connection is lost, debug server fill stop and program execution will continue as usual.
Filenames are interpreted only by Quail debug server, not by client, so relative paths would be relative to QRE.
To launch program in debug mode, change launch mode to debug
(See Chapter 12: Console operation)
Default port for debugging will be 4004. To change it add a flag
-G.debugPort=PORT
.
After launch, Quail will not start the program until debug client is connected
CLI client could be launched from your QDK with the following command:
java -jar qdk.jar debugClient host port
Where host and port should be substituted with host and port on which the Quail Debug Server runs. To connect to default address on which debug server runs write the following:
java -jar qdk.jar debugClient localhost 4004
When you launch CLI client, you will be asked to write breakpoints for files
in following format: 1 line per file, on each line you specify breakpoints
like this: filename;line1;line2...
(e.g. program.q;2;5;6
).
After that, when breakpoint is reached, a corresponding message will appear.
Now you can send following commands:
c
- continuenl
- next linestop
- stopmem
- memoryeval
- evalLearn more about debug commands in Chapter 14.2.1.
GUI client could be launched from your QDK with the following command:
java -jar qdk.jar debugClientGui
After that, you will be asked to provide address to connect
After entering address you should enter breakpoints in the same format as in CLI client
After that you will see a GUI.
In the first row connection information is displayed
In the second row you can enter an expression to evaluate (eval command). The results of evaluation will appear in the list on the left
In the third row you see information about current breakpoint location and can control the flow (commands: continue, next and stop)
On the right there is a table which will display memory contents (mem command)