How do you debug this

I have an application that periodically stops working. Not only it stops operating, it does not respond to any input, there is no way to kill it - most of the time the operating system (W7) does not respond to ctl-alt-del and if it does it does not manage to kill it via the task manager. Actually nothing can be done except for pressing the OFF key until the PC turns off.
The program communicates with another piece of hardware so it might be something that has to do with communication, although I am not sure (every communication cycle is triggered by a timer, and the port is opened and closed on every cycle) .
What would be the debugging mechanism to trace this problem?

You add logging to the methods you suspect as culprit. The easiest way to log is with currentmethodname and then something like “start” and “stop” at the beginning and end of the method. I prefer logging to a file but the console should work, too. Does Windows have a console?

HTH

get the program called debugview on windows.

An easier version of Beatrix’s suggestion is explained here: http://blog.tempel.org/2013/08/debugging-tips-using-local-objects-to.html

Also, if you had a Basic license for my tool Arbed, you could use its scripting feature to add such a debug-line to each of your methods automatically. That might be overkill, though.

thomas… i didn’t know you can do that… adding debug-line automatically. what do i need to do??

Richard,
Get the latest Arbed beta first (it’s some 1.7.0 beta).

Next to the Arbed.exe there’s a Scripts folder.

There should be a “Add DebugLog to all methods.arbs” in there.

Open both that script and your project in Arbed. (Make sure you have a backup of your project, e.g. stored in Version Control, because once you modify your project with this procedure, it’ll be not so easy to remove the changes again, because there’s no script for that, yet, unless you write your own).

The script is set up to add

System.DebugLog CurrentMethodName

to all your methods, logging every method entry.

You could modify the script to invoke

dim myTmpObject as new MethodProfiler(CurrentMethodName)

instead, to get both method entries and exits logged.

If you want to use the MethodProfiler, I suggest changing the following script line:

textToAddToTopOfSource = "System.DebugLog CurrentMethodName" + EndOfLine
into:

textToAddToTopOfSource = "#if DebugBuild" + EndOfLine + "dim myTmpObject as new MethodProfiler(CurrentMethodName)" + EndOfLine + "#endif" + EndOfLine + EndOfLine
Then run the script and verify that your methods have gotten the intended line added.

Save the project and run it in the IDE. If you added the line with “MethodProfiler”, you will also have to add this MethodProfiler class to your project, of course. That class can be found in the demo project, see my blog article.

Now, if your modified project runs, it’ll write lots of log messages to the system console. which can be viewed with the “Console.app” on the Mac, or with the “DebugView” tool (google for that) on Windows. In case of Windows, you’ll have to launch DebugView before you run the program in the IDE.

work wonderfully… thanks Thomas.

Thanks to all of you.
At the moment I followed the recommendation form Beatrix - will see how it works.
Downloaded Debugview but could not figure out how to work with it.
Thomas’ site is blocked from my workplace - will check it later at home

debugview is used just to see see the thing you are debugging. In your XOJO program simply include command like “System.debuglog” following by the string.