From d3491c29798fca867d5961c4dcc3d64313fc8433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-R=C3=A9my=20Buchs?= Date: Sat, 4 Mar 2017 12:38:07 +0100 Subject: [PATCH 1/6] Load debug symbols for mods if they are loaded from the filesystem --- OpenRA.Game/ObjectCreator.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/ObjectCreator.cs b/OpenRA.Game/ObjectCreator.cs index 52c165aa3e..075b89d29a 100644 --- a/OpenRA.Game/ObjectCreator.cs +++ b/OpenRA.Game/ObjectCreator.cs @@ -11,6 +11,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Reflection; using OpenRA.Primitives; @@ -54,7 +55,14 @@ namespace OpenRA Assembly assembly; if (!ResolvedAssemblies.TryGetValue(hash, out assembly)) { - assembly = Assembly.Load(data); + using (Stream stream = modFiles.Open(path)) + { + if (stream.GetType() == typeof(FileStream)) + assembly = Assembly.LoadFile(((FileStream)stream).Name); + else + assembly = Assembly.Load(data); + } + ResolvedAssemblies.Add(hash, assembly); } From 19616c059cfccbcc9277baed94148df28c4946f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-R=C3=A9my=20Buchs?= Date: Sat, 4 Mar 2017 14:20:16 +0100 Subject: [PATCH 2/6] Load debug symbols for mods if they are present --- OpenRA.Game/ObjectCreator.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/OpenRA.Game/ObjectCreator.cs b/OpenRA.Game/ObjectCreator.cs index 075b89d29a..dc95ae7b57 100644 --- a/OpenRA.Game/ObjectCreator.cs +++ b/OpenRA.Game/ObjectCreator.cs @@ -55,14 +55,11 @@ namespace OpenRA Assembly assembly; if (!ResolvedAssemblies.TryGetValue(hash, out assembly)) { - using (Stream stream = modFiles.Open(path)) - { - if (stream.GetType() == typeof(FileStream)) - assembly = Assembly.LoadFile(((FileStream)stream).Name); - else - assembly = Assembly.Load(data); - } - + Stream debugStream = null; + if (modFiles.TryOpen(path + ".mdb", out debugStream)) + assembly = Assembly.Load(data, debugStream.ReadAllBytes()); + else + assembly = Assembly.Load(data); ResolvedAssemblies.Add(hash, assembly); } From a0598d2b9cf935c6f44c27669cdf4994de94e96a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-R=C3=A9my=20Buchs?= Date: Sat, 4 Mar 2017 17:37:40 +0100 Subject: [PATCH 3/6] Load debug symbols (.mdb .pdb) for mods if they are present --- OpenRA.Game/ObjectCreator.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenRA.Game/ObjectCreator.cs b/OpenRA.Game/ObjectCreator.cs index dc95ae7b57..f22dca37cb 100644 --- a/OpenRA.Game/ObjectCreator.cs +++ b/OpenRA.Game/ObjectCreator.cs @@ -58,6 +58,8 @@ namespace OpenRA Stream debugStream = null; if (modFiles.TryOpen(path + ".mdb", out debugStream)) assembly = Assembly.Load(data, debugStream.ReadAllBytes()); + else if (modFiles.TryOpen(path + ".pdb", out debugStream)) + assembly = Assembly.Load(data, debugStream.ReadAllBytes()); else assembly = Assembly.Load(data); ResolvedAssemblies.Add(hash, assembly); From f999001cafd85d6d446a2eaff25d5eb3408b67e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-R=C3=A9my=20Buchs?= Date: Tue, 7 Mar 2017 18:30:08 +0100 Subject: [PATCH 4/6] Load debug symbols (.mdb on mono only; .pdb) for mods if they are present --- OpenRA.Game/ObjectCreator.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRA.Game/ObjectCreator.cs b/OpenRA.Game/ObjectCreator.cs index f22dca37cb..5db2276be4 100644 --- a/OpenRA.Game/ObjectCreator.cs +++ b/OpenRA.Game/ObjectCreator.cs @@ -56,9 +56,9 @@ namespace OpenRA if (!ResolvedAssemblies.TryGetValue(hash, out assembly)) { Stream debugStream = null; - if (modFiles.TryOpen(path + ".mdb", out debugStream)) + if (Type.GetType("Mono.Runtime") != null && modFiles.TryOpen(path + ".mdb", out debugStream)) assembly = Assembly.Load(data, debugStream.ReadAllBytes()); - else if (modFiles.TryOpen(path + ".pdb", out debugStream)) + else if (modFiles.TryOpen(path.Substring(0, path.Length - 4) + ".pdb", out debugStream)) assembly = Assembly.Load(data, debugStream.ReadAllBytes()); else assembly = Assembly.Load(data); From 28cd480225adff922edba04a5f799ff7e880ebf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-R=C3=A9my=20Buchs?= Date: Wed, 8 Mar 2017 20:11:41 +0100 Subject: [PATCH 5/6] Load debug symbols (.mdb on mono only; .pdb) for mods if they are present --- OpenRA.Game/ObjectCreator.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/OpenRA.Game/ObjectCreator.cs b/OpenRA.Game/ObjectCreator.cs index 5db2276be4..238a4a920b 100644 --- a/OpenRA.Game/ObjectCreator.cs +++ b/OpenRA.Game/ObjectCreator.cs @@ -27,6 +27,7 @@ namespace OpenRA readonly Cache typeCache; readonly Cache ctorCache; readonly Pair[] assemblies; + readonly bool isMonoRuntime = Type.GetType("Mono.Runtime") != null; public ObjectCreator(Assembly a) { @@ -55,13 +56,18 @@ namespace OpenRA Assembly assembly; if (!ResolvedAssemblies.TryGetValue(hash, out assembly)) { - Stream debugStream = null; - if (Type.GetType("Mono.Runtime") != null && modFiles.TryOpen(path + ".mdb", out debugStream)) - assembly = Assembly.Load(data, debugStream.ReadAllBytes()); - else if (modFiles.TryOpen(path.Substring(0, path.Length - 4) + ".pdb", out debugStream)) - assembly = Assembly.Load(data, debugStream.ReadAllBytes()); - else - assembly = Assembly.Load(data); + Stream symbolStream = null; + var hasSymbols = false; + + // Mono has its own symbol format. + if (isMonoRuntime) + hasSymbols = modFiles.TryOpen(path + ".mdb", out symbolStream); + + // .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); } From fbd3a2efeaa35c644cd5306d8990454c44e579cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-R=C3=A9my=20Buchs?= Date: Thu, 16 Mar 2017 17:22:59 +0100 Subject: [PATCH 6/6] Load debug symbols (.mdb on mono only; .pdb on .NET only) for mods if they are present --- OpenRA.Game/ObjectCreator.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRA.Game/ObjectCreator.cs b/OpenRA.Game/ObjectCreator.cs index 238a4a920b..c9c3c0aa03 100644 --- a/OpenRA.Game/ObjectCreator.cs +++ b/OpenRA.Game/ObjectCreator.cs @@ -63,8 +63,8 @@ namespace OpenRA if (isMonoRuntime) hasSymbols = modFiles.TryOpen(path + ".mdb", out symbolStream); - // .NET and newer mono versions can load portable .pdb files. - if (!hasSymbols) + // .NET uses .pdb files. + else hasSymbols = modFiles.TryOpen(path.Substring(0, path.Length - 4) + ".pdb", out symbolStream); assembly = hasSymbols ? Assembly.Load(data, symbolStream.ReadAllBytes()) : Assembly.Load(data);