-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't pipeline directory contents to Mount-DbgDumpFile #66
Comments
You can dismount dump files, but there is a documentation / discoverability problem: you can use To clarify about the piping, you would want all the dumps to be mounted at the same time? |
I don't have a strong opinion either way - I'm generally going to want to run more thing against a set of dumps, but whether that means mount -> command -> dismount or mount all -> enumerate targets -> command isn't particularly important to me. |
About the documentation problem, there is also #22, to address making it easier to add cmdlet help, in addition actually adding more cmdlet help, so I'm going to consider that part of this issue covered by that one. Also, I discovered that there is also a But:
(emphasis added) Are you talking about something like: you currently have a dump mounted at Dbg:\MyApp, and then you want to mount another dump at the same path (because that's the auto-chosen path), so you want to detach the first dump and attach the second, instead of getting an error about the target name already being used? My gut reaction is that it wouldn't be good to do by default... but perhaps with a prompt, which could be suppressed by an option? But that wouldn't be high on my priority list to implement.
In that case, I would recommend against trying to deal with multiple dumps mounted at the same time, unless you need to for some reason. DbgEng's API supports the concept of being attached to multiple targets, but IIRC it does not work very well for dump files (I think I've got comments in the code complaining about it). Since the dbgeng threading model basically limits you to linear processing anyway, I would just do them one at a time. |
Let me clarify: I just want this (or similar equivalent) to work; I am simply not particular about the details of how, and I may have misinterpreted why it doesn't work.
|
Ah, I see. I think you must have some modifications to your version, because it seems like you should have hit different problems first with those commands. The first thing to note is that So you'd want to do something more like this (it's slightly prettier if you have the commit I just made to allow piping the output of Get-ChildItem 'C:\temp\Dumps' -File | %{
#Mount-DbgDumpFile $_ | Out-Null
Mount-DbgDumpFile $_.FullName.ToString() | Out-Null
try {
# do analysis here
Get-DbgModuleInfo ntdll
} finally {
.detach
}
} That pattern could easily be packaged up into a |
<#
.SYNOPSIS
For each dump file path, this command mounts the dump file, runs the supplied
ScriptBlock, then detaches.
#>
function ForEach-DbgDumpFile
{
[CmdletBinding()]
param( [Parameter( Mandatory = $false,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true )]
[Alias( 'PSPath' )] # Allows piping in output of "dir"
[string] $DumpFilePath,
[Parameter( Mandatory = $true, Position = 0 )]
[ScriptBlock] $ScriptBlock
)
process
{
try
{
# Note that we suppress/ignore all the output you normally get when you load a
# dump file.
Mount-DbgDumpFile $DumpFilePath | Out-Null
& $ScriptBlock
}
finally
{
.detach
}
}
} Example usage:
|
ForEach-DbgDumpFile is great! I had noticed (and forgotten) that the commands would run twice for the final dump but I hadn't tried to figure out why. Is there an easy way to tack a |
You could of course tack on such properties manually in your script block, using Note that I noticed a formatting bug (#71), so be aware of that when directly examining your output in DbgShell. |
I suspected something like that was possible, but it exceeded my familiarity with PowerShell. Fortunately, the way I did come up with (adding a |
This would be to run an analysis script on all of the dump files in a folder.
Also helpful for that would be a way to automatically dismount dump files (or even actually dismount them at all) so you don't get target name conflicts if your script errors out and you have to restart it
The text was updated successfully, but these errors were encountered: