views:

412

answers:

4

Hi, I have my SNMP Extension Agent DLL that is called by the Windows SNMP Service (snmp.exe) everytime i do an snmpwalk (another console application) .I want to step into my DLL code that is called from the above Windows Service. How do i go about doing that?

Thanks Som

+2  A: 

Normally, you'd attach your debugger to the running process that uses your DLL and then interact with the debugger as you'd normally do.

In Visual Studio 2008, you'd do that by using Debug > Attach To Process, then select the correct process. At least that's how I vaguely remember doing it before.

Timo Geusch
Hi Thanks for the reply, but in this case i do NOT have the src code nor the solution for the process (which infact is the standard Windows SNMP Service) from which my DLL is invoked,I do not want have src code for the console application either which calls into the SNMP service
As Dmitriy Matveev points out, you don't need the source code for the application using your DLL, but you'll still be able to see the source code and variables in your DLL, just not outside of it.
Timo Geusch
A: 

Hi , Thanks for the reply. In this case i do NOT have the src code nor the solution for the process (which infact is the standard Windows SNMP Service) from which my DLL is invoked,I do not want have src code for the console application either which calls into the SNMP service – somjk

+1  A: 

You can attach to running service from visual studio as Timo Geusch suggests. After that you can set a breakpoint in your code. You also can add call to DebugBreak function in the place you want to debug your library. This can help you if the code you want to debug is executed before you can attach to process (if your code executed in handler of service start event for example).

EDIT: You can attach to any service, even if you don't have debugging information for it, but in this case you wouldn't be able to see stack trace above your function call.

Dmitriy Matveev
A: 

Can i attach to the running service even if it is not built in Debug mode?

yes you can. Your dll should be in debug mode though in order to use breakpoints. If you're using VS, you might need to check the checkbox "show processes from all users" as the service should be running under the SYSTEM user (or LocalService).
hakan