-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ClrMDExports (from Kevin Gosse) to allow lldb/WinDBG extension
- Loading branch information
Christophe Nasarre
committed
Feb 24, 2019
1 parent
f48122e
commit ae0de2b
Showing
18 changed files
with
209 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace ClrMDExports | ||
{ | ||
internal class Init | ||
{ | ||
[RGiesecke.DllExport.DllExport("DebugExtensionInitialize")] | ||
public static int DebugExtensionInitialize(ref uint version, ref uint flags) | ||
{ | ||
var extensionFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); | ||
|
||
try | ||
{ | ||
var file = Path.Combine(extensionFolder, "ClrMDExports.dll"); | ||
|
||
var assemblyName = AssemblyName.GetAssemblyName(file); | ||
|
||
ForceAssemblyLoad(assemblyName); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine("Could not load ClrMDExports: " + ex); | ||
} | ||
|
||
InitializeDebuggingContext(); | ||
|
||
// Set the extension version to 1, which expects exports with this signature: | ||
// void _stdcall function(IDebugClient *client, const char *args) | ||
version = DEBUG_EXTENSION_VERSION(1, 0); | ||
flags = 0; | ||
return 0; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static void InitializeDebuggingContext() | ||
{ | ||
Private.Initialization.IsWinDbg = true; | ||
} | ||
|
||
private static void ForceAssemblyLoad(AssemblyName assemblyName) | ||
{ | ||
var codeBase = assemblyName.CodeBase; | ||
|
||
if (codeBase.StartsWith("file://")) | ||
{ | ||
codeBase = codeBase.Substring(8).Replace('/', '\\'); | ||
} | ||
|
||
ResolveEventHandler assemblyResolve = (sender, args) => args.Name == assemblyName.FullName ? Assembly.LoadFrom(codeBase) : null; | ||
|
||
AppDomain.CurrentDomain.AssemblyResolve += assemblyResolve; | ||
|
||
Assembly.Load(assemblyName.FullName); | ||
|
||
AppDomain.CurrentDomain.AssemblyResolve -= assemblyResolve; | ||
} | ||
|
||
static uint DEBUG_EXTENSION_VERSION(uint major, uint minor) | ||
{ | ||
return ((((major) & 0xffff) << 16) | ((minor) & 0xffff)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.