Open and parse Winboard.debug file while in use by Winboard

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
Stan Arts
Posts: 179
Joined: Fri Feb 14, 2014 9:53 pm
Location: the Netherlands

Open and parse Winboard.debug file while in use by Winboard

Post by Stan Arts » Sat May 06, 2017 11:39 am

So this morning I tried to create a simple Winboard.debug file parser in my Nemeton GUI so one can watch Winboard games in progress on a 3D board.

Easy enough. When I feed it a finished debug file it parses the games in there to the last current position.

Problem: Winboard or Windows denies acces to the file while being used by Winboard so this idea doesn't work.

But since text editors like Notepad can open Winboard.debug while in use there must be some way around it. Anyone know how? (In FreePascal?)

User avatar
hgm
Posts: 23723
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Open and parse Winboard.debug file while in use by Winbo

Post by hgm » Sat May 06, 2017 12:00 pm

Indeed there is something strange going on here. I also noticed that NotePad can open debug files while they are being written, but WordPad cannot. So it must have something to do with the program that tries to open the file. Perhaps Windows API has calls to open a file for exclusive use.

Note that the latest WinBoard has an undocumented feature, where an argument of the -debugfile option that starts with three slashes is not interpreted as the name of a file to write on, but as the name of an executable to launch and pipe the data to. This could conceivably be useful for what you want to do.

Stan Arts
Posts: 179
Joined: Fri Feb 14, 2014 9:53 pm
Location: the Netherlands

Re: Open and parse Winboard.debug file while in use by Winbo

Post by Stan Arts » Sun May 07, 2017 10:34 am

Thanks. Seems I might have a solution now and that the problem was actually my program putting on some sort of a lock when attempting to open to read, which Windows denies.
So Google suggests opening files as a stream with no locks to get around this problem and in FreePascal that can be done with the file handling functions of the SysUtils unit. FileOpen with the fmShareDenyNone argument and reading individual bytes from the file through FileRead.
Takes a bit of getting used to, can't even tell when a line ends yet..but I'm getting a stream of characters from the debug file now while Winboard runs. Hiep hiep hoera.

Yeah your later solution of being able to fire up an external executable to send the debug info to seems excellent. As sort of a third engine which can watch over the games or analyse as they happen which seems like a useful feature now we often have cores to spare.

jwes
Posts: 778
Joined: Sat Jul 01, 2006 5:11 am

Re: Open and parse Winboard.debug file while in use by Winbo

Post by jwes » Sun May 07, 2017 8:26 pm

Stan Arts wrote:Thanks. Seems I might have a solution now and that the problem was actually my program putting on some sort of a lock when attempting to open to read, which Windows denies.
So Google suggests opening files as a stream with no locks to get around this problem and in FreePascal that can be done with the file handling functions of the SysUtils unit. FileOpen with the fmShareDenyNone argument and reading individual bytes from the file through FileRead.
Takes a bit of getting used to, can't even tell when a line ends yet..but I'm getting a stream of characters from the debug file now while Winboard runs. Hiep hiep hoera.

Yeah your later solution of being able to fire up an external executable to send the debug info to seems excellent. As sort of a third engine which can watch over the games or analyse as they happen which seems like a useful feature now we often have cores to spare.
I have a debug tool that does something similar. I use it to replay games to try to recreate bugs when just analyzing a position does not reproduce it.

User avatar
hgm
Posts: 23723
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Open and parse Winboard.debug file while in use by Winbo

Post by hgm » Sun May 07, 2017 8:48 pm

Stan Arts wrote:Yeah your later solution of being able to fire up an external executable to send the debug info to seems excellent. As sort of a third engine which can watch over the games or analyse as they happen which seems like a useful feature now we often have cores to spare.
The intended application was live broadcasting of games. I made a broadcast engine that filters games and relevant PVs out of the debug stream, and uploads them to a website.

This is problematic when the internet connection somehow stalls, though: the pipe will fill up, and eventually cause WinBoard to stall too, when writing to it. So perhaps a file buffer, which can hold unlimited data, mught be better after all.

Post Reply