Re: How to connect to children process



Hi Oleg,

I very much appreciate your time and any help you provide to me.

Sorry if my message was not clear. I will try again.

Process "A" from time to time starts process "B" (several times in one debug
session) and process "B" dynamically links to DLL "C". I'm creating several
DLLs "C".

Now debug procedure is as follow:

1. I'm creating code with int 3 in place that I'm willing debug.
2. Software works on remote PC starting in Kernel mode debugger
with WinDbg and VS2003 running on separate host PC
3. When execution stops on int 3, I'm loading symbols (.reload /user)
and do debug and corrections in code
4. Then I break remote machine (Ctrl+Break) and reload symbols again
(.reload /user) for unlock .PDB file
5. Then project is rebuild in VS 2003 and target DLL is copied to remote PC

The above procedure is too much time consuming in my case. Ideally I would
like:

1. Debug on the same platform (and ideally whithin of VS 2003)
Thanks to your help I'm able now using WinDbg on local machine.
2. Get symbols load automatically
3. Get symbols unlock automatically
4. Get possibility to set break points on particular function as usually
using
function symbol instead of using embedded int 3.

I'm not sure if VS debugger provides any API, but WinDbg certainly does.
Question: Do you know how to add code (and which code to add) to DLL for get
DLL symbols reload at each DLL startup, break-points set in VS 2003 applied
to started instance and DLL PDB unlocked for write.




"Oleg Starodumov" wrote:


Hi Al,

I'm sorry but it looks like I can't understand what you are trying to do.
Could you please try to describe the whole sequence of actions
you are currently doing, and how/what you would like to be improved there?

Oleg

"Metek" <Metek@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:E918DCE4-E723-4341-A75A-6A7CCAEB160E@xxxxxxxxxxxxxxxx
Hi Oleg,

Thank you very much for the hint. The WinDbg approach is clear for me.

I also read your article - it's really very interesting and helpful - thank
you very much. I have another small question to you related to my debug
situation.

For your understanding: I have neither source nor symbols for process "A"
and "B". My task is to create several (about 200) DLLs "C". Process "A" is
almost always working (however this is a User process in Administrative
account).

Because of huge number of DLLs, I need to decrease amount of manual
operations to minimum.

DLLs are created in VS2003 with huge amount of tracings and breaks to
debugger at any place that can require debug. However connection to debugger
is time consuming. Right now I'm using remote PC and WinDbg started in kernel
mode. This mode is not ideal since VS2003 and WinDbg always try to lock DLL
.PDB file and I have to reload symbols to WinDbg after each rebuild. I would
prefer to use VS debugger or WinDbg on local PC, if possible.

I'm looking for the method that allow to start debugger and load proper
symbols for DLL automatically (either at DLL WinMain or at first break). It
could be some code added to checked version of DLL and dealing with Debug API
or any kind of script in debugger.

Do you have any experience with such kind of tasks? Can you indicate any
sample of code that doing similar task?

With best regards,

Al


"Oleg Starodumov" wrote:


I have following debug situation:

Process "A" randomly starts process "B". Process "B" works for short (2-5
sec) time and during execution links dynamically to DLL "C". I debug DLL "C"
and need catch debug tracing from it.

The problem is that I cannot start process "B" in debugger (since I do not
start it directly) and cannot attach to running process since ptocess "B"
appears in the list of running process for very short time.

Any recommendation how configure Visual Studio debugger and/or WinDbg will
be highly appreciated.


There are many ways to achieve it. The easiest but intrusive way is to
suspend the dll "C" temporarily while it is called (using MessageBox or Sleep)
and use this timeout to attach debugger. DebugBreak and the like can also
be used to break into that process.

If you don't want to modify the code to be able to debug, the easiest approach
is with WinDbg. Attach debugger to process "A" and use '.childdbg 1' command
to enable debugging of child processes. After this command, WinDbg will
automatically start debugging any process launched by process "A".

Visual Studio does not support .childdbg-like approach, but similar effect
still can be achieved e.g. using IFEO approach. You can find more details about it here:
http://www.debuginfo.com/articles/debugstartup.html

--
Oleg
[VC++ MVP http://www.debuginfo.com/]









.



Relevant Pages

  • Re: tracking down error in MFC42.dll
    ... (I used WinDbg to do that, but the same can be done ... The same could be done for your dll if it would be built with debug ... If you put symbols of your dll on the target system (in the same ... what the call stack shows. ...
    (microsoft.public.vc.mfc)
  • Re: Access violation in MSXML.dll ???
    ... Are you building your DLL with fully debug or with retail? ... the code gets executed just enough for the debugger to be able to figure out ... Below is the destructor for XML module: ...
    (microsoft.public.windowsce.embedded)
  • Re: Symbols not loaded for DLLs
    ... I tried WinDbg 6.5.3.7 and was able to load symbols and debug the DLL ... The only thing I had to do was set the symbol path to point to my pdb ... Debug Data Dirs: Type Size VA Pointer ...
    (microsoft.public.vc.debugger)
  • Re: no symbols have been loaded for dll
    ... The dll is called by non msvc application, ... debug | attach to process and select my application. ... In order for the debugger to associate source file lines to actual machine ... the debugger finds the incorrect .pdb file. ...
    (microsoft.public.vc.ide_general)
  • Re: Need help troubleshooting perfmon extension dll
    ... same code into a 32-bit dll, and install it on a 32-bit OS (XP, to begin ... The debug output ... Shouldn't the debugger get the first chance, ...
    (microsoft.public.win32.programmer.kernel)

Loading