Re: Debugging a Hung Program

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




> Any idea how to find out the thread stacks of a running but hung process
> (developed using Visual Studio 6.0, C++ environment)? In the Solaris/UNIX
> world there's a command called "pstack" that dumps out the stack of each
> thread given a process ID. Is there a tool that provides this kind of
> information on Windows either thru the visual studio environment or command
> line? Thanks in advance.
>

Yes, for example you can use CDB, which is available as part of Debugging Tools
for Windows package:
http://www.microsoft.com/whdc/ddk/debugging/default.mspx

The following command will attach to the application (by process id) and dump
call stacks of all threads:

cdb -pv -p <processid> -c "~*kb;q"

If you are debugging a hung application, it is even better to use it like this:

cdb -pv -p <processid> -c "~*kb;!locks;q"

(!locks command will display the information about all critical sections held by
the application's threads).

Good symbols for the operating system DLLs are usually required to get good call stacks.
You can set _NT_SYMBOL_PATH environment variable to the following value:
srv*c:\symbols*http://msdl.microsoft.com/download/symbols
Then CDB will automatically download the necessary symbols from symbol server
in Microsoft. (c:\symbols is a symbol cache, which can be any directory on your system).

You can find more information on these topics in Debugging Tools' documentation.

WinDbg debugger (also available with Debugging Tools) can run the same commands
from GUI.

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



.



Relevant Pages

  • Re: VMS in the medical field
    ... in that it was still tied to the days of stacks. ... command abbreviation typically allowed) because it is used everywhere. ... Oddity: _no_ declarations. ...
    (comp.os.vms)
  • RE: [SLE] Mantels 2.6.5-11 and 2.6.5-12 kernels and Nvidia
    ... > Was this done from the command line or using YaST ?. ... > I checked on the nvidia site and it recommended using YaST, ... I compiled it with Mantel's options and without 4K stacks. ... Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com ...
    (SuSE)
  • Re: tcp/ip will not reset
    ... The easiest and most effective utility for restoring TCP/IP Winsock ... stacks is the WinsockFix freeware tool by Option^Explicit. ... >run this command directly after a fresh boot up, it runs, ...
    (microsoft.public.windowsxp.network_web)
  • Re: tcp/ip will not reset
    ... The WinsockFix tool did the ... >stacks is the WinsockFix freeware tool by Option^Explicit. ... >>run this command directly after a fresh boot up, it runs, ...
    (microsoft.public.windowsxp.network_web)
  • Command to dump/restore user info OSR5
    ... the command on OpenServer that dumps all the user and group ... to restore from a dump file, but don't remember the command name. ... one's time defending scoundrels. ... oppressive laws are first aimed, and oppression must be stopped at the ...
    (comp.unix.sco.misc)