Skip to content

Instantly share code, notes, and snippets.

@ghotz
Created July 11, 2014 06:14
Show Gist options
  • Save ghotz/12af5831135c27be42bc to your computer and use it in GitHub Desktop.
Save ghotz/12af5831135c27be42bc to your computer and use it in GitHub Desktop.
Parse unique stacks from WinDBG output generated with !uniqstack
# Parse WinDBG !uniqstack output
$file = 'SQLDump0008.uniqstack.txt';
$SearchLog = [regex] '\.\s{0,2}(?<thread>\d{1,4}).*?\r\n.*?\r\n.*?\r\n.*?\r\n.{8}`.{8} .{8}`.{8} (?<topstack>.*)\r\n';
$log = [io.file]::ReadAllText($file);
$match = $SearchLog.Match($log);
$logentries = @();
while ($match.Success) {
$logentry = new-object System.Object;
$logentry | add-member -membertype noteproperty -name thread -value $match.Groups['thread'].Value;
$logentry | add-member -membertype noteproperty -name topstack -value $match.Groups['topstack'].Value;
$logentries += $logentry
$match = $match.NextMatch();
};
$logentries | Export-Csv 'SQLDump0008.uniqstack.csv' -Delimiter ";" -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment