in reply to Debugging Windows Services created with Win32::Daemon
I have two suggestions.
The thing to remember is that everything inside the SERVICE_RUNNING branch of the top level if/then/elsif/else cascade (which is better replaced by a dispatch table!), is just "normal" code, except that it usually doesn't have access to a console.
If you put your main logic within a subroutine and call it from that branch of the cascade (or dispatch to it), and you put that sub into a separate module, then writing a test harness that just loads that module and invokes the sub is trivial. You also get access to a console and can use what ever debug techniques (from print on up) that you would normally use to get your logic right.
Once you are satisfied with your logic running as a console app, moving back to running it as a Service is easy. It will also highlight any problems that arise as a result of running as a service.
Get yourself to http://www.smidgeonsoft.com/, and download PEBrowse Professional Interactive. And be sure to read the tutorial. There is a link to it at the bottom of that page.
It will allow you to attach to the running Service, set break points, disassemble the code and supports using symbol files if you tell it where to look.
Be warned. It operates at the assembler level, not the Perl source level, which takes some getting used to, but if you have thoroughly debugged your code before making it a Service, there are a limited number of thing s you will need to look at, and they are fairly simple to decipher at the assembler level.
|
|---|