Last active 2 years ago

  1. 2 years ago
    Sun Jul 10 15:13:35 2016

    I typically use MinGW to compile and link.

  2. Sat Jul 2 13:24:31 2016
    Arkathorn started the conversation C++ Custom Toolchain; Proper use of dependencies.

    I wish to use the C++ side of Polycode, but both cannot and do not want to use Microsoft Visual Studio. As such, I am attempting to construct a setup wherein I can compile and subsequently run the code from a specific folder, using batch files. How would I go about doing this? I have tried several things, but it seem that it would be much more productive to have an idea what to do.

  3. Thu Jun 30 14:50:47 2016
    Arkathorn posted in How to debug programs without IDE.

    As there are some notable features (namely networking) that are only available to the C++ API, I've decided to start developing that way instead. I'll post my findings thus so far on the debugging protocol, and I may return to the project on a future date.

    Firstly, there was absolutely no need to develop such a program using Love2D, and I was only doing so because I had some libraries built up in it. It is far more practical to simply use a Lua program, parsed by some simple C++.

    The protocol is completely accessible to standard UDP libraries (such as LuaSocket, which I used), and is bound to "".

    Upon startup, a Polycode program begins to broadcast pings every second. These pings differ only by a single byte, which counts what number ping it is (not the number of seconds elapsed).

    When a print statement is executed, or an error occurs, it is added to a list of packets sent every cycle (one second). These packets are all sent simultaneously, but in order.


    print("This is the first print statement.")
    print("This is the second print statement.")

    After the first three or so pings (the time it takes to initialize the program, at least on my computer), this sequence will be sent every second:

    Print Statement 1
    Print Statement 2

    When an uncaught error occurs, a similar process transpires. Packets will continue being sent, even though program execution has halted, until the application is closed.

    I have not yet analysed the print statement packets, but my analysis of the error packets follows:

    Errors queue two packets: The error and the backtrace.

    The error packet contains at least three relevant data points: The line the error occurred on, the message the error returned, and the file the error occurred in. It may also contain the length of the backtrace, but this is unconfirmed.

    The line and message are a fixed length from the start of the datagram:

    The line number is the twenty-first (21st) byte in the datagram.
    The error message starts on the twenty-fifth (25th) byte, and is null-terminated (is immediately followed by a zero byte, which can be used to detect the length of the message).

    The file path is a bit trickier. The position of this data within the datagram is variable, so it must be detected by string operations. I used the following line to extract it:

    local file = data:match("%g*%.lua")

    Where 'data' is the datagram string.

    I have not yet analysed any of the rest of the protocol, but I have some additional insights.

    As the datagram contains unprintable characters, it cannot be printed. It should instead be passed to a function that translates all unprintable characters to a readable, unique format. This is the function I used:

    local function fixstring(str)
    	local ret = ""
    	for i=1,str:len() do
    		local c = str:sub(i,i)
    		if not c:find("[%w%p]") then
    			ret = ret.."_"..c:byte().."_"
    			ret = ret..c
    	return ret

    Some errors (such as a 'require' error) will not pass the same text to the debugging protocol as they would to a console output. As a result these errors are entirely uninformative, so I advise finding some way to capture the true error using 'pcall' and/or 'xpcall' (There is also a character limit on the print messages sent to the protocol, so you may need to separate the error into smaller strings.).

  4. Sat Jun 25 11:14:32 2016
    Arkathorn posted in How to debug programs without IDE.

    Hmm... Okay. I think I'll try and make a debugger application with Love2D and LuaSocket. Is there any reason that wouldn't work?

    On a side note, does this mean that every Polycode application uses port 4630 on the loopback address?

  5. Fri Jun 24 20:52:23 2016
    Arkathorn posted in How to debug programs without IDE.

    I'm trying to set up a toolchain using batch files and Sublime Text. As such, it would be nice to be able to link the debugger that the IDE uses to a running program, so I can read the error (and maybe debug?) messages from my code. Is this possible? How?

  6. Fri Jun 24 20:48:29 2016
    Arkathorn joined the forum.