<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>[PowerShell Script] PowerDbg v2.3 - Using PowerShell to Control WinDbg</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2007/12/17/powershell-script-powerdbg-v2-0-using-powershell-to-control-windbg.aspx</link><description>It has been a while since my previous blog post. I’ve been busy with other tasks, including the new PowerDbg version 2.3. There’s a lot of new stuff on this new version and my estimate is that about 80% of the most used Windbg commands have been covered</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: [PowerShell Script] PowerDbg v2.0 - Using PowerShell to Control WinDbg</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2007/12/17/powershell-script-powerdbg-v2-0-using-powershell-to-control-windbg.aspx#6831712</link><pubDate>Sat, 22 Dec 2007 04:36:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6831712</guid><dc:creator>Roberto Farah</dc:creator><description>&lt;p&gt;I just fixed two bugs. This new version is 2.1&lt;/p&gt;</description></item><item><title>re: [PowerShell Script] PowerDbg v2.0 - Using PowerShell to Control WinDbg</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2007/12/17/powershell-script-powerdbg-v2-0-using-powershell-to-control-windbg.aspx#6927075</link><pubDate>Tue, 01 Jan 2008 03:37:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6927075</guid><dc:creator>Roberto Farah</dc:creator><description>&lt;p&gt;Another bug fixed. This new version is 2.2&lt;/p&gt;</description></item><item><title>re: [PowerShell Script] PowerDbg v2.2 - Using PowerShell to Control WinDbg</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2007/12/17/powershell-script-powerdbg-v2-0-using-powershell-to-control-windbg.aspx#7143096</link><pubDate>Thu, 17 Jan 2008 22:29:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7143096</guid><dc:creator>nativecpp</dc:creator><description>&lt;p&gt;For the latest powershell-script,&lt;/p&gt;
&lt;p&gt;1)Can I download from somewhere ? Or do I have to copy and paste ?&lt;/p&gt;
&lt;p&gt;2)Can you tell me the environment requirements for using this library ?&lt;/p&gt;
&lt;p&gt;Keep up the good work.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;</description></item><item><title>re: [PowerShell Script] PowerDbg v2.2 - Using PowerShell to Control WinDbg</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2007/12/17/powershell-script-powerdbg-v2-0-using-powershell-to-control-windbg.aspx#7143929</link><pubDate>Fri, 18 Jan 2008 00:41:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7143929</guid><dc:creator>Roberto Farah</dc:creator><description>&lt;P&gt;Hi nativecpp,&lt;/P&gt;
&lt;P&gt;1- For now you cannot download it. You have to copy and paste it. If you use MS Word and save the file as text file, it should not add extra spaces between lines. This approach works fine.&lt;/P&gt;
&lt;P&gt;2- The environment is:&lt;/P&gt;
&lt;P&gt;PowerShell v 1.0&lt;/P&gt;
&lt;P&gt;.NET Framework 2.0&lt;/P&gt;
&lt;P&gt;Debugging Tools For Windows&lt;/P&gt;
&lt;P&gt;Attention to that:&lt;/P&gt;
&lt;P&gt;a) The PowerDbg library should be in your $profile file. From PS if you type notepad $profile you'll be able to now the location of this file and the name. You'll need to create it if it doesn't exist.&lt;/P&gt;
&lt;P&gt;In my case the code for the PowerDbg library is here:&lt;/P&gt;
&lt;P&gt;C:\Users\rafarah\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1&lt;/P&gt;
&lt;P&gt;So, my Microsoft.PowerShell_profile.ps1 has the code posted in this blog article.&lt;/P&gt;
&lt;P&gt;Because the PowerDbg is into the $profile, you can call the commandlets from any place.&lt;/P&gt;
&lt;P&gt;b) After updating the $profile you need to close and reopen PS again. Doing that, the PowerShell will recognize the updates.&lt;/P&gt;
&lt;P&gt;c) The Windbg window must have its title changed to PowerDbg. Rememember: because PowerDbg simulates a user using WinDbg, you cannot change the windows focus during the time it is interacting with WinDbg. If you do that the PowerDbg and PowerDbg scripts won't be able to "talk" with WinDbg.&lt;/P&gt;
&lt;P&gt;d) If you get errors, most of the time they are related to timing issues. To solve that you just need to run the script again after making sure the WinDbg stopped to process the command or increase the start-sleep delay. It usually happens when you send a "k" command from Send-PowerDbgCommand and it takes too much time to solve the symbols. Anyway, it not happens that often.&lt;/P&gt;
&lt;P&gt;If you have any other questions, doubts or problems, let me know! I'll be happy to help you because I want my readers to have a good experience using my little toys. :)&lt;/P&gt;
&lt;P&gt;Any suggestions for future cmdlets or scrips are welcome.&lt;/P&gt;</description></item><item><title>re: [PowerShell Script] PowerDbg v2.2 - Using PowerShell to Control WinDbg</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2007/12/17/powershell-script-powerdbg-v2-0-using-powershell-to-control-windbg.aspx#7229080</link><pubDate>Fri, 25 Jan 2008 02:42:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7229080</guid><dc:creator>Roberto Farah</dc:creator><description>&lt;p&gt;Version 2.3 - My co-worker Cristhian Uribe asked me to put in red the threads doing unknown activity when running Analyze-PowerDbgThreads and I added two more API calls based on his feedback.&lt;/p&gt;</description></item><item><title>re: [PowerShell Script] PowerDbg v2.3 - Using PowerShell to Control WinDbg</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2007/12/17/powershell-script-powerdbg-v2-0-using-powershell-to-control-windbg.aspx#7349840</link><pubDate>Thu, 31 Jan 2008 16:02:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7349840</guid><dc:creator>solidstore</dc:creator><description>&lt;p&gt;Sorry for being dumb! But i dont see the source code? Can you re-post it please.&lt;/p&gt;</description></item><item><title>re: [PowerShell Script] PowerDbg v2.3 - Using PowerShell to Control WinDbg</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2007/12/17/powershell-script-powerdbg-v2-0-using-powershell-to-control-windbg.aspx#7355027</link><pubDate>Thu, 31 Jan 2008 21:48:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7355027</guid><dc:creator>Roberto Farah</dc:creator><description>&lt;p&gt;Hi solidstore! You are not dumb, I am! :) For some reason I changed the code and didn't paste it.&lt;/p&gt;
&lt;p&gt;I'm going to do that between today and tomorrow.&lt;/p&gt;
&lt;p&gt;Thanks for letting me know!&lt;/p&gt;</description></item><item><title>re: [PowerShell Script] PowerDbg v2.3 - Using PowerShell to Control WinDbg</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2007/12/17/powershell-script-powerdbg-v2-0-using-powershell-to-control-windbg.aspx#7850687</link><pubDate>Fri, 22 Feb 2008 23:13:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7850687</guid><dc:creator>Ed F</dc:creator><description>&lt;p&gt;I added a function to return the results of ~*e !clrstack -p&lt;/p&gt;
&lt;p&gt;The output is something like this:&lt;/p&gt;
&lt;p&gt;0x1184 82 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{SomeNameSpace.SomeManagedFunction, SomeNameSpace...&lt;/p&gt;
&lt;p&gt;0x1360 175 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {SomeNameSpace.SomeManagedFunction, SomeNameSpace...&lt;/p&gt;
&lt;p&gt;0x228 33 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {}&lt;/p&gt;
&lt;p&gt;0x928 201 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{SomeNameSpace.SomeManagedFunction, SomeNameSpace...&lt;/p&gt;
&lt;p&gt;0x12bc 91 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{SomeNameSpace.SomeManagedFunction, SomeNameSpace...&lt;/p&gt;
&lt;p&gt;0x11a8 105 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {SomeNameSpace.SomeManagedFunction, SomeNameSpace...&lt;/p&gt;
&lt;p&gt;0x894 202 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{SomeNameSpace.SomeManagedFunction, SomeNameSpace...&lt;/p&gt;
&lt;p&gt;0x11bc 49 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{SomeNameSpace.SomeManagedFunction, SomeNameSpace...&lt;/p&gt;
&lt;p&gt;0x10a4 68 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{SomeNameSpace.SomeManagedFunction, SomeNameSpace...&lt;/p&gt;
&lt;p&gt;0xf20 75 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {SomeNameSpace.SomeManagedFunction, SomeNameSpace...&lt;/p&gt;
&lt;p&gt;0xde8 57 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {SomeNameSpace.SomeManagedFunction, SomeNameSpace...&lt;/p&gt;
&lt;p&gt;0x1468 185 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {SomeNameSpace.SomeManagedFunction, SomeNameSpace...&lt;/p&gt;
&lt;p&gt;0x1474 130 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {SomeNameSpace.SomeManagedFunction, SomeNameSpace...&lt;/p&gt;
&lt;p&gt;0x17c4 120 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {SomeNameSpace.SomeManagedFunction, SomeNameSpace...&lt;/p&gt;
&lt;p&gt;0x7c8 34 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {SomeNameSpace.SomeManagedFunction, SomeNameSpace...&lt;/p&gt;
&lt;p&gt;Which is useful for me, because I can then use it like this:&lt;/p&gt;
&lt;p&gt;$res = Analyze-PowerDbgClrThreads&lt;/p&gt;
&lt;p&gt;$res.keys | %{$res[$_].&amp;quot;SomeNameSpace.SomeManagedFunction&amp;quot;.this}&lt;/p&gt;
&lt;p&gt;Which gives me a list of object addresses like this:&lt;/p&gt;
&lt;p&gt;0x1dbcb630&lt;/p&gt;
&lt;p&gt;0x1e2f2c78&lt;/p&gt;
&lt;p&gt;0x0927793c&lt;/p&gt;
&lt;p&gt;0x0a302de4&lt;/p&gt;
&lt;p&gt;0x0a280308&lt;/p&gt;
&lt;p&gt;########################################################################################################&lt;/p&gt;
&lt;p&gt;# Function: &amp;nbsp; &amp;nbsp;Analyze-PowerDbgClrThreads&lt;/p&gt;
&lt;p&gt;#&lt;/p&gt;
&lt;p&gt;# Parameters: &amp;nbsp;None.&lt;/p&gt;
&lt;p&gt;# &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/p&gt;
&lt;p&gt;# Return: &amp;nbsp; &amp;nbsp; &amp;nbsp;hash by thread id by method name of hashtables&lt;/p&gt;
&lt;p&gt;#&lt;/p&gt;
&lt;p&gt;# Purpose: &amp;nbsp; &amp;nbsp; &lt;/p&gt;
&lt;p&gt;#&lt;/p&gt;
&lt;p&gt;# Changes History: 01/25/08 - Threads with unknown symbol appear in red color.&lt;/p&gt;
&lt;p&gt;#&lt;/p&gt;
&lt;p&gt;# Ed Fancher&lt;/p&gt;
&lt;p&gt;# All my functions are provided &amp;quot;AS IS&amp;quot; with no warranties, and confer no rights. &lt;/p&gt;
&lt;p&gt;########################################################################################################&lt;/p&gt;
&lt;p&gt;function Analyze-PowerDbgClrThreads()&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;	$ThreadRegEx = &amp;quot;OS\s+Thread\s+Id:\s+(0x[0-9a-fA-F]+)\s\((\d+)\)&amp;quot;&lt;/p&gt;
&lt;p&gt;	$ParameterLineRegEx = &amp;quot;\s+(\w+)\s+=\s+(.*)&amp;quot;&lt;/p&gt;
&lt;p&gt;	#a real regex, since $matches was behaving funny.&lt;/p&gt;
&lt;p&gt;	$FunctionRegEx = [regex] &amp;quot;([0-9a-fA-F]+)\s+([0-9a-fA-F]+)\s+(?&amp;lt;fname&amp;gt;[^(]+)&amp;quot;&lt;/p&gt;
&lt;p&gt;	$FrameRegex = &amp;quot;([0-9a-fA-F]+)\s+([0-9a-fA-F]+)\s+\[[A-Fa-f0-9: ]+\]&amp;quot;&lt;/p&gt;
&lt;p&gt;	Send-PowerDbgCommand &amp;quot;~*e !clrstack -p&amp;quot;&lt;/p&gt;
&lt;p&gt;	sleep 120&lt;/p&gt;
&lt;p&gt;	#get the log written out by powerdbg.&lt;/p&gt;
&lt;p&gt;	write-host $global:g_fileCommandOutput&lt;/p&gt;
&lt;p&gt;	$pdl = get-content $global:g_fileCommandOutput&lt;/p&gt;
&lt;p&gt;	$currentThread = &amp;quot;&amp;quot;;&lt;/p&gt;
&lt;p&gt;	$currentFunction = &amp;quot;&amp;quot;;&lt;/p&gt;
&lt;p&gt;	$threads = @{};&lt;/p&gt;
&lt;p&gt;	return;&lt;/p&gt;
&lt;p&gt;	#loop through each line&lt;/p&gt;
&lt;p&gt;	for($i=0; $i -lt $pdl.length;$i++)&lt;/p&gt;
&lt;p&gt;	{&lt;/p&gt;
&lt;p&gt;		#if this matches, we've seen a thread.&lt;/p&gt;
&lt;p&gt;		if ($pdl[$i] -match $ThreadRegEx)&lt;/p&gt;
&lt;p&gt;		{&lt;/p&gt;
&lt;p&gt;			$currentThread = $matches[1] + &amp;quot; &amp;quot; + $matches[2];&lt;/p&gt;
&lt;p&gt;			$threads[$currentThread] = @{};&lt;/p&gt;
&lt;p&gt;		}&lt;/p&gt;
&lt;p&gt;		if ($currentThread -eq &amp;quot;&amp;quot;)&lt;/p&gt;
&lt;p&gt;		{&lt;/p&gt;
&lt;p&gt;			continue;&lt;/p&gt;
&lt;p&gt;		}&lt;/p&gt;
&lt;p&gt;		#ignore frames, since I'm not usually interested in them.&lt;/p&gt;
&lt;p&gt;		if ($pdl[$i] -match $FrameRegex)&lt;/p&gt;
&lt;p&gt;		{&lt;/p&gt;
&lt;p&gt;			continue;&lt;/p&gt;
&lt;p&gt;		}&lt;/p&gt;
&lt;p&gt;		#if this matches, we have a function so add it onto the last found thread.&lt;/p&gt;
&lt;p&gt;		$fmatch = $FunctionRegEx.Match($pdl[$i]);&lt;/p&gt;
&lt;p&gt;		if ($fmatch.success)&lt;/p&gt;
&lt;p&gt;		{&lt;/p&gt;
&lt;p&gt;			$currentFunction = $fmatch.Groups[&amp;quot;fname&amp;quot;].Value;&lt;/p&gt;
&lt;p&gt;			$threads[$currentThread][$currentFunction] = @{};&lt;/p&gt;
&lt;p&gt;		}&lt;/p&gt;
&lt;p&gt;		if ($currentFunction &amp;nbsp;-eq &amp;quot;&amp;quot;)&lt;/p&gt;
&lt;p&gt;		{&lt;/p&gt;
&lt;p&gt;			continue;&lt;/p&gt;
&lt;p&gt;		}&lt;/p&gt;
&lt;p&gt;		#if there are any parameters add them on the the last found method.&lt;/p&gt;
&lt;p&gt;		if ($pdl[$i] -match $ParameterLineRegEx)&lt;/p&gt;
&lt;p&gt;		{&lt;/p&gt;
&lt;p&gt;			$threads[$currentThread][$currentFunction][$matches[1]] = $matches[2];&lt;/p&gt;
&lt;p&gt;		}&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	$threads;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;</description></item><item><title>re: [PowerShell Script] PowerDbg v2.3 - Using PowerShell to Control WinDbg</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2007/12/17/powershell-script-powerdbg-v2-0-using-powershell-to-control-windbg.aspx#7850834</link><pubDate>Fri, 22 Feb 2008 23:40:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7850834</guid><dc:creator>Roberto Farah</dc:creator><description>&lt;p&gt;Hey Ed, congratulations! This is an awesome cmdlet! :)&lt;/p&gt;
&lt;p&gt;Thanks for sharing with us!&lt;/p&gt;</description></item></channel></rss>