Hi guys,
I'm working on a rather big project right now, and a problem occured - it just freezes every now and then. No error message whatsoever, the game just stops. So I guess there's an infinite loop somewhere, but I can't tell at what point exactly, and I don't want to go through 8k lines of code command by command in order to find out what exactly might not be working. On top of that, the game crashes on a different PC regularly, also without giving me any information why that happens.
DBPs debug mode doesn't work (it always just crashes as soon as the exe is executed), so I have to find my own way to deal with the problem.
My first idea was to basically log somehow what the program is doing, i.e. multiple times throughout the main loop log a number (or string), so that when the game crashes, I'll be able to see what part of the program was responsible by the last number that was logged. Now there may be several ways to do this.
1. Using the Windows Clipboard (
write to clipboard, then simply using CTRL+V to find out what was logged last) - this works, but I don't like the idea of writing stuff to the clipboard several thousand times a second. That just doesn't seem right.
2. Writing everything to a file. Not a good idea, as the file would get really huge. Also I'm not sure if the file would even be readable and complete afterwards, as obviously no
close file command is executed when the program crashes.
3. And that in theory is my favorite method, but it doesn't work (yet): Using shared memory and a second exe to check what's logged there. Should basically behave like this:
-1. the game allocates memory (e.g. an integer, i.e. p = make memory(4))
-2. it creates a file and writes the pointer adress to that file (open to write 1, "myfile" : write long 1, p : close file 1)
-3. The second program waits until "myfile" exists, then opens the file, gets the pointer
-4. From then on the second exe constantly outputs that value (do : cls : v = *p : print v : loop)
As opposed to the other two methods (possibly), that wouldn't have any effect on the game's performance whatsoever as it would just write a bunch of values to the RAM each frame. Unfortunately, it doesn't work though, as the memory created with make memory(4) isn't shared. Hence the second exe simply crashes because it tries to access memory it's not allowed to read.
Now, I have no idea how to set up a block of shared memory in DBP. Apparently matrix1utils 1 has shared memory banks, but I can't find anything about how to create one in the help files. There's a
get bank shared name$() function, and that's all I could find.
Can anybody help me out? Either with how to properly create and use shared memory in DBP, or with a better solution to my debugging problem. Would be highly appreciated.
Thanks in advance,
Shellfish Games