Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WinDbg and htrace command usage

616 views
Skip to first unread message

Anitha

unread,
Feb 9, 2009, 9:48:01 AM2/9/09
to
Hi,
I am trying to use the htrace command to detect handle leak in my program.I
created a sample program in C# that creates events and leak event handles.
I can see the leaking handles but I am not able to get the function call
track/code which causes the handles to leak.

Following is what I did
1) Open Gflags.exe and set the image name,checked the Enable Application
verifier and set the stackBacktrace to 10
2)Open Windbg and set the symbol path,source path and image path
3)Opened my application through windbg
4) gave the !htrace -enable command
5) Allowed the application to run to create handle leak
6)gave the !htrace -diff command
7)The output was someting like this
0:005> !htrace -diff
Handle tracing information snapshot successfully taken.
0x79 new stack traces since the previous snapshot.
Ignoring handles that were already closed...
Outstanding handles opened since the previous snapshot:
--------------------------------------
Handle = 0x00000000000001d4 - OPEN
Thread ID = 0x0000000000001190, Process ID = 0x00000000000011a8

0x0000000077ef0e6a: ntdll!NtCreateEvent+0x000000000000000a
--------------------------------------
Displayed 0x1 stack traces for outstanding handles opened since the previous
snapshot.

how can I see the sourcecode/function calls of my code which lead to the
event creation?

cap...@yahoo.co.uk

unread,
Feb 9, 2009, 11:07:41 AM2/9/09
to

!htrace <handle>

Anitha

unread,
Feb 10, 2009, 4:43:01 AM2/10/09
to
Hi,
I had tried !htrace <handle> command. But it doesn't give the function call
tree/ source code. Following is the output

Output of !htrace -diff
Handle = 0x0000000000000340 - OPEN
Thread ID = 0x00000000000013c8, Process ID = 0x0000000000001198
0x0000000077ef0e6a: ntdll!NtCreateEvent+0x000000000000000a

Output of !htrace <handle> command for teh above handle
0:003> !htrace 0x0000000000000340
Handle = 0x0000000000000340 - OPEN
Thread ID = 0x00000000000013c8, Process ID = 0x0000000000001198
0x0000000077ef0e6a: ntdll!NtCreateEvent+0x000000000000000a
Parsed 0x404 stack traces.
Dumped 0x1 stack traces.

Any help on what I am missing/doing wrong that these commands are not giving
the expected output

Thanks
Anitha

"cap...@yahoo.co.uk" wrote:

> On 9 Feb, 14:48, Anitha <Ani...@discussions.microsoft.com> wrote:
> > Hi,
> > I am trying to use the htrace command to detect handle leak in my program.I

> > created a sample program in C# that creates events and leak event handles..

cap...@yahoo.co.uk

unread,
Feb 10, 2009, 6:03:15 AM2/10/09
to
On 10 Feb, 09:43, Anitha <Ani...@discussions.microsoft.com> wrote:
> Hi,
> > !htrace <handle>- Hide quoted text -
>
> - Show quoted text -

lookis like you have a native frame:
0x0000000077ef0e6a: ntdll!NtCreateEvent+0x000000000000000a

thats it load the right SOS and check !clrstack works then try again

Dan Mihai [MSFT]

unread,
Feb 20, 2009, 6:43:20 PM2/20/09
to
I am not sure you can get much help from !htrace for a managed app. !htrace
knows only about pointers from the stack trace so I guess it will be hard to
match those pointers with the managed source code.

What Windows version are you using? I expect deeper stack traces than the
ones from your example below only on Windows Vista SP1 or newer OS versions
for x64 systems. x86 worked better even before Vista SP1.

Dan
−−
This posting is provided "AS IS" with no warranties, and confers no rights.


"Anitha" <Ani...@discussions.microsoft.com> wrote in message
news:15BE83DF-D4BB-4B18...@microsoft.com...

0 new messages