Load debug symbols (.mdb on mono only; .pdb) for mods if they are present
This commit is contained in:
@@ -27,6 +27,7 @@ namespace OpenRA
|
|||||||
readonly Cache<string, Type> typeCache;
|
readonly Cache<string, Type> typeCache;
|
||||||
readonly Cache<Type, ConstructorInfo> ctorCache;
|
readonly Cache<Type, ConstructorInfo> ctorCache;
|
||||||
readonly Pair<Assembly, string>[] assemblies;
|
readonly Pair<Assembly, string>[] assemblies;
|
||||||
|
readonly bool isMonoRuntime = Type.GetType("Mono.Runtime") != null;
|
||||||
|
|
||||||
public ObjectCreator(Assembly a)
|
public ObjectCreator(Assembly a)
|
||||||
{
|
{
|
||||||
@@ -55,13 +56,18 @@ namespace OpenRA
|
|||||||
Assembly assembly;
|
Assembly assembly;
|
||||||
if (!ResolvedAssemblies.TryGetValue(hash, out assembly))
|
if (!ResolvedAssemblies.TryGetValue(hash, out assembly))
|
||||||
{
|
{
|
||||||
Stream debugStream = null;
|
Stream symbolStream = null;
|
||||||
if (Type.GetType("Mono.Runtime") != null && modFiles.TryOpen(path + ".mdb", out debugStream))
|
var hasSymbols = false;
|
||||||
assembly = Assembly.Load(data, debugStream.ReadAllBytes());
|
|
||||||
else if (modFiles.TryOpen(path.Substring(0, path.Length - 4) + ".pdb", out debugStream))
|
// Mono has its own symbol format.
|
||||||
assembly = Assembly.Load(data, debugStream.ReadAllBytes());
|
if (isMonoRuntime)
|
||||||
else
|
hasSymbols = modFiles.TryOpen(path + ".mdb", out symbolStream);
|
||||||
assembly = Assembly.Load(data);
|
|
||||||
|
// .NET and newer mono versions can load portable .pdb files.
|
||||||
|
if (!hasSymbols)
|
||||||
|
hasSymbols = modFiles.TryOpen(path.Substring(0, path.Length - 4) + ".pdb", out symbolStream);
|
||||||
|
|
||||||
|
assembly = hasSymbols ? Assembly.Load(data, symbolStream.ReadAllBytes()) : Assembly.Load(data);
|
||||||
ResolvedAssemblies.Add(hash, assembly);
|
ResolvedAssemblies.Add(hash, assembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user