Skip to content

Commit

Permalink
Merge branch 'release/v0.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
GregTheDev committed Dec 31, 2018
2 parents 893a22e + 8ff749a commit c250128
Show file tree
Hide file tree
Showing 24 changed files with 790 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DbgHelp.MinidumpFiles</RootNamespace>
<AssemblyName>DbgHelp.MinidumpFiles</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -46,6 +47,7 @@
<RunCodeAnalysis>true</RunCodeAnalysis>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
Expand Down Expand Up @@ -89,6 +91,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Formatters.cs" />
<Compile Include="MiniDumpCommentStreamW.cs" />
<Compile Include="MiniDumpDirectory.cs" />
<Compile Include="MiniDumpMemoryInfo.cs" />
<Compile Include="MiniDumpException.cs" />
Expand All @@ -113,6 +116,8 @@
<Compile Include="MiniDumpSystemPerformanceInformation.cs" />
<Compile Include="MiniDumpThreadInfo.cs" />
<Compile Include="MiniDumpThread.cs" />
<Compile Include="MiniDumpThreadName.cs" />
<Compile Include="MiniDumpThreadNamesStream.cs" />
<Compile Include="MiniDumpType.cs" />
<Compile Include="MiniDumpHeader.cs" />
<Compile Include="MiniDumpUnloadedModule.cs" />
Expand Down
20 changes: 20 additions & 0 deletions MinidumpExplorer/DbgHelp.MinidumpFiles/MiniDumpCommentStreamW.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace DbgHelp.MinidumpFiles
{
/// <summary>
/// The comment string that was written to the dump file.
/// </summary>
public class MiniDumpCommentStreamW
{
internal MiniDumpCommentStreamW()
{
this.Comment = null;
}

internal MiniDumpCommentStreamW(string comment)
{
this.Comment = comment;
}

public string Comment { get; private set; }
}
}
57 changes: 53 additions & 4 deletions MinidumpExplorer/DbgHelp.MinidumpFiles/MiniDumpFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,45 @@ public MiniDumpSystemMemoryInfo ReadSystemMemoryInfo()
return new MiniDumpSystemMemoryInfo(systemMemoryInfo, this);
}

public MiniDumpThreadNamesStream ReadThreadNamesStream()
{
MINIDUMP_THREAD_NAME_LIST threadNameStream;
IntPtr streamPointer;
uint streamSize;

if (!this.ReadStream<MINIDUMP_THREAD_NAME_LIST>(MINIDUMP_STREAM_TYPE.ThreadNamesStream, out threadNameStream, out streamPointer, out streamSize))
{
return new MiniDumpThreadNamesStream(); // Return empty result
}

// Advance the stream pointer past the header
streamPointer += Marshal.SizeOf(threadNameStream.NumberOfThreadNames);

// Now read the information
MINIDUMP_THREAD_NAME[] threadNames = ReadArray<MINIDUMP_THREAD_NAME>(streamPointer, (int)threadNameStream.NumberOfThreadNames);

return new MiniDumpThreadNamesStream(threadNameStream, threadNames, this);
}

/// <summary>
/// Reads the MINIDUMP_STREAM_TYPE.CommentStreamW stream.
/// </summary>
/// <returns><see cref="MiniDumpCommentStreamW"/> containing the comment for the minidump. If stream data is not present then <see cref="MiniDumpCommentStreamW"/> is returned with a null Comment property.</returns>
public MiniDumpCommentStreamW ReadCommentStreamW()
{
IntPtr streamPointer;
uint streamSize;

if (!this.ReadStream(MINIDUMP_STREAM_TYPE.CommentStreamW, out streamPointer, out streamSize))
{
return new MiniDumpCommentStreamW(); // Return empty result
}

string comment = Marshal.PtrToStringAuto(streamPointer, (int)streamSize);

return new MiniDumpCommentStreamW(comment);
}

public unsafe void CopyMemoryFromOffset(ulong rva, IntPtr destination, uint size)
{
try
Expand Down Expand Up @@ -445,8 +484,21 @@ protected unsafe bool ReadStream<T>(MINIDUMP_STREAM_TYPE streamToRead, out T str

protected unsafe bool ReadStream<T>(MINIDUMP_STREAM_TYPE streamToRead, out T streamData, out IntPtr streamPointer, out uint streamSize)
{
MINIDUMP_DIRECTORY directory = new MINIDUMP_DIRECTORY();
streamData = default(T);

if (ReadStream(streamToRead, out streamPointer, out streamSize))
{
streamData = (T)Marshal.PtrToStructure(streamPointer, typeof(T));

return true;
}

return false;
}

protected unsafe bool ReadStream(MINIDUMP_STREAM_TYPE streamToRead, out IntPtr streamPointer, out uint streamSize)
{
MINIDUMP_DIRECTORY directory = new MINIDUMP_DIRECTORY();
streamPointer = IntPtr.Zero;
streamSize = 0;

Expand All @@ -469,9 +521,6 @@ protected unsafe bool ReadStream<T>(MINIDUMP_STREAM_TYPE streamToRead, out T str
else
throw new Win32Exception(lastError);
}

streamData = (T)Marshal.PtrToStructure(streamPointer, typeof(T));

}
finally
{
Expand Down
2 changes: 2 additions & 0 deletions MinidumpExplorer/DbgHelp.MinidumpFiles/MiniDumpStreamType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public enum MiniDumpStreamType
SystemMemoryInfoStream = 21,
ProcessVmCountersStream = 22,

ThreadNamesStream = 24,

LastReservedStream = 0xffff
}
}
27 changes: 27 additions & 0 deletions MinidumpExplorer/DbgHelp.MinidumpFiles/MiniDumpThreadName.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DbgHelp.MinidumpFiles.Native;

namespace DbgHelp.MinidumpFiles
{
/// <summary>
/// Contains information about a thread's name/description.
/// </summary>
public class MiniDumpThreadName
{
private MINIDUMP_THREAD_NAME _threadName;
private MiniDumpFile _owner;

internal MiniDumpThreadName(MINIDUMP_THREAD_NAME threadName, MiniDumpFile owner)
{
this._threadName = threadName;
this._owner = owner;
}

public uint ThreadId => _threadName.ThreadId;
public string Name => _owner.ReadString(_threadName.RvaOfThreadName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using DbgHelp.MinidumpFiles.Native;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DbgHelp.MinidumpFiles
{
/// <summary>
/// The thread names stream in a minidump, containing information about each thread's name/description (if available).
/// </summary>
public class MiniDumpThreadNamesStream
{
private MINIDUMP_THREAD_NAME_LIST _threadNamesList;
private List<MiniDumpThreadName> _threadNameEntries;

internal MiniDumpThreadNamesStream()
{
_threadNamesList = new MINIDUMP_THREAD_NAME_LIST();
_threadNameEntries = new List<MiniDumpThreadName>();
}

internal MiniDumpThreadNamesStream(MINIDUMP_THREAD_NAME_LIST threadNamesList, MINIDUMP_THREAD_NAME[] threadNameEntries, MiniDumpFile owner)
{
_threadNamesList = threadNamesList;
_threadNameEntries = new List<MiniDumpThreadName>(threadNameEntries.Select(x => new MiniDumpThreadName(x, owner)));
}

public IReadOnlyCollection<MiniDumpThreadName> Entries => _threadNameEntries;
}
}
3 changes: 2 additions & 1 deletion MinidumpExplorer/DbgHelp.MinidumpFiles/MiniDumpType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ public enum MiniDumpType
MiniDumpFilterTriage = 0x00100000,

MiniDumpWithAvxXStateContext = 0x00200000,
MiniDumpValidTypeFlags = 0x003fffff
MiniDumpWithIptTrace = 0x00400000,
MiniDumpValidTypeFlags = 0x007fffff

}
}
28 changes: 28 additions & 0 deletions MinidumpExplorer/DbgHelp.MinidumpFiles/Native/dbghelp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,32 @@ internal struct MINIDUMP_SYSTEM_PERFORMANCE_INFORMATION
public UInt64 SharedCommittedPages;
}


/*
typedef struct _MINIDUMP_THREAD_NAME_LIST {
ULONG NumberOfThreadNames;
MINIDUMP_THREAD_NAME ThreadNames[0]; // Variable size buffer
} MINIDUMP_THREAD_NAME_LIST, *PMINIDUMP_THREAD_NAME_LIST;
*/
[StructLayout(LayoutKind.Sequential, Pack = 4)]
internal struct MINIDUMP_THREAD_NAME_LIST
{
public uint NumberOfThreadNames;
}

/*
typedef struct _MINIDUMP_THREAD_NAME {
ULONG ThreadId;
RVA64 RvaOfThreadName;
} MINIDUMP_THREAD_NAME, *PMINIDUMP_THREAD_NAME;
*/
[StructLayout(LayoutKind.Sequential, Pack = 4)]
internal struct MINIDUMP_THREAD_NAME
{
public uint ThreadId;
public uint RvaOfThreadName;
}

public enum MINIDUMP_STREAM_TYPE : uint
{
UnusedStream = 0,
Expand Down Expand Up @@ -1050,6 +1076,8 @@ public enum MINIDUMP_STREAM_TYPE : uint
SystemMemoryInfoStream = 21,
ProcessVmCountersStream = 22,

ThreadNamesStream = 24,

LastReservedStream = 0xffff
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DbgHelp.MinidumpFiles")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.7.0.0")]
[assembly: AssemblyFileVersion("0.7.0.0")]
[assembly: AssemblyVersion("0.8.0.0")]
[assembly: AssemblyFileVersion("0.8.0.0")]
10 changes: 5 additions & 5 deletions MinidumpExplorer/MinidumpExplorer/App.config
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="MinidumpExplorer.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="MinidumpExplorer.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
<userSettings>
<MinidumpExplorer.Properties.Settings>
Expand All @@ -15,4 +15,4 @@
</setting>
</MinidumpExplorer.Properties.Settings>
</userSettings>
</configuration>
</configuration>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions MinidumpExplorer/MinidumpExplorer/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ private void CmdDisplayStream(string streamName)
numberOfItems = threadInfoData.Length;
viewToDisplay = new ThreadInfoListView(threadInfoData);
break;
case "ThreadNames":
nodeText = "ThreadNames";
MiniDumpThreadNamesStream threadNamesStream = this._miniDumpFile.ReadThreadNamesStream();
numberOfItems = threadNamesStream.Entries.Count;
viewToDisplay = new ThreadNamesView(threadNamesStream);
break;
case "Memory":
nodeText = "Memory";
MiniDumpMemoryDescriptor[] memoryData = this._miniDumpFile.ReadMemoryList();
Expand Down Expand Up @@ -262,6 +268,12 @@ private void CmdDisplayStream(string streamName)
numberOfItems = 1;
viewToDisplay = new SystemMemoryInfoView(systemMemoryInfo);
break;
case "CommentW":
nodeText = "CommentW";
MiniDumpCommentStreamW commentWStream = this._miniDumpFile.ReadCommentStreamW();
numberOfItems = string.IsNullOrEmpty(commentWStream.Comment) ? 0 : 1;
viewToDisplay = new CommentStreamWView(commentWStream);
break;
}

if (viewToDisplay != null)
Expand Down
Loading

0 comments on commit c250128

Please sign in to comment.