View Full Version : Linux and wine as great debugging aids

12-04-2017, 08:51 AM
You may think your code is fine, and it may even work, but how could you know there are no horrible blunders under the hood, waiting for the next version of Windows to awaken like a hung over Chthulhu pissed at noisy neighbors?
Well, porting your project to Linux is one way to ensure there are no such horrors lying in wait.

In this particular case, I was calling TCriticalSection.Leave twice. Windows swallowed it. Linux...? Bam! EInOutError.

Even if you can't/won't port to Linux, there is wine (https://www.winehq.org/) . Many instances of crap code that manage to work in real Windows (which is too too forgiving) crash and burn when launched in wine. Critical sections are one example, yes.

I learned all of that the hard way, heh.

12-04-2017, 09:55 AM
Indeed. Porting to linux showed me a lot of hidden bugs that worked fine in windows. It's also worth to valgrind the heck out of your program.

13-04-2017, 02:17 AM
Another great linux tool that helps a lot is oprofile sampling profiler. I wasn't able to find any working* profiler for 64bit FPC programs on windows, so I profile under Linux all the time.

* sampling + properly loads symbols from debug info

Ñuño Martínez
08-05-2017, 10:59 AM
Also Linux recover from segment violations better than Windows (later Windows seems to recover better than older ones, but they still do weird things after a few segment violations ).

[I]Fun fact: When I began programming on Windows 3.1 it was so common to break it with a segment violation (I used C only in those days) that it was quite hard to work with. Then I discovered OS/2 run Windows 3.1 programs in a similar way Wine does on Linux (actually Wine started with code from the OS/2-Windows compatability layer) so I used OS/2 because it was really unbreackable (I've never seen an OS/2 Warp or later blocked. Never). Only when the program was complete and debugged I moved it to Windows 3.1 to see if it worked, and it did always.

The OS/2-Windows compatability was so good and OS/2 was so stable that even bugged programs that didn't work on Win3.1 worked on OS/2 (f.e. Win3.0 or Win2.0 with compatability problems).