Skip to content

Commit

Permalink
[mtouch] Update code that only considered .mdb (not .pdb) (#2003)
Browse files Browse the repository at this point in the history
Also stop using `mdb` as the name for debug symbols and remove

> static MdbReader mdb_reader;

since we're not mkbundl'ing mtouch anymore.

Related to #2002 for mmp
  • Loading branch information
spouliot authored and rolfbjarne committed Apr 17, 2017
1 parent e1bd566 commit d9fc5cf
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 35 deletions.
32 changes: 16 additions & 16 deletions tools/mtouch/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ public partial class Application

public bool EnableCxx;
public bool EnableProfiling;
bool? package_mdb;
public bool PackageMdb {
get { return package_mdb.Value; }
set { package_mdb = value; }
bool? package_managed_debug_symbols;
public bool PackageManagedDebugSymbols {
get { return package_managed_debug_symbols.Value; }
set { package_managed_debug_symbols = value; }
}
bool? enable_msym;
public bool EnableMSym {
Expand Down Expand Up @@ -1222,10 +1222,10 @@ void Initialize ()
DeploymentTarget = new Version (8, 0);
}

if (!package_mdb.HasValue) {
package_mdb = EnableDebug;
} else if (package_mdb.Value && IsLLVM) {
ErrorHelper.Warning (3007, "Debug info files (*.mdb) will not be loaded when llvm is enabled.");
if (!package_managed_debug_symbols.HasValue) {
package_managed_debug_symbols = EnableDebug;
} else if (package_managed_debug_symbols.Value && IsLLVM) {
ErrorHelper.Warning (3007, "Debug info files (*.mdb / *.pdb) will not be loaded when llvm is enabled.");
}

if (!enable_msym.HasValue)
Expand Down Expand Up @@ -1875,7 +1875,7 @@ public void BuildMSymDirectory ()
// copy aot data must be done BEFORE we do copy the msym one
CopyAotData (msymdir, target_directory);

// copy all assemblies under mvid and with the dll and mdb
// copy all assemblies under mvid and with the dll and mdb/pdb
var tmpdir = Path.Combine (msymdir, "Msym", "tmp");
if (!Directory.Exists (tmpdir))
Directory.CreateDirectory (tmpdir);
Expand Down Expand Up @@ -1969,7 +1969,7 @@ public void StripNativeCode ()

public void BundleAssemblies ()
{
var strip = ManagedStrip && IsDeviceBuild && !EnableDebug && !PackageMdb;
var strip = ManagedStrip && IsDeviceBuild && !EnableDebug && !PackageManagedDebugSymbols;

var grouped = Targets.SelectMany ((Target t) => t.Assemblies).GroupBy ((Assembly asm) => asm.Identity);
foreach (var @group in grouped) {
Expand All @@ -1993,10 +1993,10 @@ public void BundleAssemblies ()
case AssemblyBuildTarget.StaticObject:
case AssemblyBuildTarget.DynamicLibrary:
if (size_specific) {
assemblies [0].CopyToDirectory (assemblies [0].Target.AppTargetDirectory, copy_mdb: PackageMdb, strip: strip, only_copy: true);
assemblies [1].CopyToDirectory (assemblies [1].Target.AppTargetDirectory, copy_mdb: PackageMdb, strip: strip, only_copy: true);
assemblies [0].CopyToDirectory (assemblies [0].Target.AppTargetDirectory, copy_debug_symbols: PackageManagedDebugSymbols, strip: strip, only_copy: true);
assemblies [1].CopyToDirectory (assemblies [1].Target.AppTargetDirectory, copy_debug_symbols: PackageManagedDebugSymbols, strip: strip, only_copy: true);
} else {
assemblies [0].CopyToDirectory (AppDirectory, copy_mdb: PackageMdb, strip: strip, only_copy: true);
assemblies [0].CopyToDirectory (AppDirectory, copy_debug_symbols: PackageManagedDebugSymbols, strip: strip, only_copy: true);
}
foreach (var asm in assemblies)
asm.CopyAotDataFilesToDirectory (size_specific ? asm.Target.AppTargetDirectory : AppDirectory);
Expand All @@ -2008,10 +2008,10 @@ public void BundleAssemblies ()
var target_name = assemblies [0].BuildTargetName;
var resource_directory = Path.Combine (AppDirectory, "Frameworks", $"{target_name}.framework", "MonoBundle");
if (size_specific) {
assemblies [0].CopyToDirectory (Path.Combine (resource_directory, Path.GetFileName (assemblies [0].Target.AppTargetDirectory)), copy_mdb: PackageMdb, strip: strip, only_copy: true);
assemblies [1].CopyToDirectory (Path.Combine (resource_directory, Path.GetFileName (assemblies [1].Target.AppTargetDirectory)), copy_mdb: PackageMdb, strip: strip, only_copy: true);
assemblies [0].CopyToDirectory (Path.Combine (resource_directory, Path.GetFileName (assemblies [0].Target.AppTargetDirectory)), copy_debug_symbols: PackageManagedDebugSymbols, strip: strip, only_copy: true);
assemblies [1].CopyToDirectory (Path.Combine (resource_directory, Path.GetFileName (assemblies [1].Target.AppTargetDirectory)), copy_debug_symbols: PackageManagedDebugSymbols, strip: strip, only_copy: true);
} else {
assemblies [0].CopyToDirectory (resource_directory, copy_mdb: PackageMdb, strip: strip, only_copy: true);
assemblies [0].CopyToDirectory (resource_directory, copy_debug_symbols: PackageManagedDebugSymbols, strip: strip, only_copy: true);
}
foreach (var asm in assemblies)
asm.CopyAotDataFilesToDirectory (size_specific ? Path.Combine (resource_directory, Path.GetFileName (asm.Target.AppTargetDirectory)) : resource_directory);
Expand Down
10 changes: 5 additions & 5 deletions tools/mtouch/Assembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void ComputeDependencyMap (List<Exception> exceptions)
}

// returns false if the assembly was not copied (because it was already up-to-date).
public bool CopyAssembly (string source, string target, bool copy_mdb = true, bool strip = false)
public bool CopyAssembly (string source, string target, bool copy_debug_symbols = true, bool strip = false)
{
var copied = false;

Expand All @@ -117,7 +117,7 @@ public bool CopyAssembly (string source, string target, bool copy_mdb = true, bo
}

// Update the debug symbols file even if the assembly didn't change.
if (copy_mdb) {
if (copy_debug_symbols) {
if (File.Exists (source + ".mdb"))
Application.UpdateFile (source + ".mdb", target + ".mdb", true);

Expand All @@ -134,7 +134,7 @@ public bool CopyAssembly (string source, string target, bool copy_mdb = true, bo
return copied;
}

public void CopyMdbToDirectory (string directory)
public void CopyDebugSymbolsToDirectory (string directory)
{
string mdb_src = FullPath + ".mdb";
if (File.Exists (mdb_src)) {
Expand Down Expand Up @@ -184,7 +184,7 @@ public void CopyConfigToDirectory (string directory)
// Aot data is copied separately, because we might want to copy aot data
// even if we don't want to copy the assembly (if 32/64-bit assemblies are identical,
// only one is copied, but we still want the aotdata for both).
public void CopyToDirectory (string directory, bool reload = true, bool check_case = false, bool only_copy = false, bool copy_mdb = true, bool strip = false)
public void CopyToDirectory (string directory, bool reload = true, bool check_case = false, bool only_copy = false, bool copy_debug_symbols = true, bool strip = false)
{
var target = Path.Combine (directory, FileName);

Expand All @@ -197,7 +197,7 @@ public void CopyToDirectory (string directory, bool reload = true, bool check_ca

// our Copy code deletes the target (so copy'ing over itself is a bad idea)
if (directory != Path.GetDirectoryName (FullPath))
CopyAssembly (FullPath, target, copy_mdb: copy_mdb, strip: strip);
CopyAssembly (FullPath, target, copy_debug_symbols: copy_debug_symbols, strip: strip);

CopySatellitesToDirectory (directory);

Expand Down
5 changes: 4 additions & 1 deletion tools/mtouch/BuildTasks.mtouch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
Expand Down Expand Up @@ -208,6 +208,9 @@ public override IEnumerable<string> FileDependencies {
var mdb = Assembly.FullPath + ".mdb";
if (File.Exists (mdb))
inputs.Add (mdb);
var pdb = Path.ChangeExtension (Assembly.FullPath, ".pdb");
if (File.Exists (pdb))
inputs.Add (pdb);
var config = Assembly.FullPath + ".config";
if (File.Exists (config))
inputs.Add (config);
Expand Down
20 changes: 7 additions & 13 deletions tools/mtouch/mtouch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// mtouch.cs: A tool to generate the necessary code to boot a Mono
// application on the iPhone
//
Expand Down Expand Up @@ -58,7 +58,7 @@

using Mono.Options;
using Mono.Cecil;
using Mono.Cecil.Mdb;
using Mono.Cecil.Cil;
using Mono.Tuner;

using MonoTouch.Tuner;
Expand Down Expand Up @@ -130,13 +130,6 @@ public static bool Dot {
}
}

//
// We need to put a hard dep on Mono.Cecil.Mdb.dll so that it get's mkbundled
//
#pragma warning disable 169
static MdbReader mdb_reader;
#pragma warning restore 169

static int GetDefaultVerbosity ()
{
var v = 0;
Expand Down Expand Up @@ -460,7 +453,7 @@ public static string GetAotArguments (Application app, string filename, Abi abi,
bool enable_llvm = (abi & Abi.LLVM) != 0;
bool enable_thumb = (abi & Abi.Thumb) != 0;
bool enable_debug = app.EnableDebug;
bool enable_mdb = app.PackageMdb;
bool enable_debug_symbols = app.PackageManagedDebugSymbols;
bool llvm_only = app.EnableLLVMOnlyBitCode;
string arch = abi.AsArchString ();

Expand All @@ -487,7 +480,7 @@ public static string GetAotArguments (Application app, string filename, Abi abi,

if (enable_llvm)
args.Append ("nodebug,");
else if (!(enable_debug || enable_mdb))
else if (!(enable_debug || enable_debug_symbols))
args.Append ("nodebug,");
else if (app.DebugAll || app.DebugAssemblies.Contains (fname) || !sdk_or_product)
args.Append ("soft-debug,");
Expand Down Expand Up @@ -662,7 +655,7 @@ public static string GenerateMain (Application app, IEnumerable<Assembly> assemb

if (app.EnableDebug)
sw.WriteLine ("\txamarin_gc_pump = {0};", app.DebugTrack.Value ? "TRUE" : "FALSE");
sw.WriteLine ("\txamarin_init_mono_debug = {0};", app.PackageMdb ? "TRUE" : "FALSE");
sw.WriteLine ("\txamarin_init_mono_debug = {0};", app.PackageManagedDebugSymbols ? "TRUE" : "FALSE");
sw.WriteLine ("\txamarin_executable_name = \"{0}\";", assembly_name);
sw.WriteLine ("\tmono_use_llvm = {0};", enable_llvm ? "TRUE" : "FALSE");
sw.WriteLine ("\txamarin_log_level = {0};", verbose);
Expand Down Expand Up @@ -1161,7 +1154,8 @@ static Application ParseArguments (string [] args, out Action a)
}
}
},
{ "package-mdb:", "Specify whether debug info files (*.mdb) should be packaged in the app. Default is 'true' for debug builds and 'false' for release builds.", v => app.PackageMdb = ParseBool (v, "package-mdb") },
{ "package-mdb:", "Specify whether debug info files (*.mdb) should be packaged in the app. Default is 'true' for debug builds and 'false' for release builds.", v => app.PackageManagedDebugSymbols = ParseBool (v, "package-mdb"), true },
{ "package-debug-symbols:", "Specify whether debug info files (*.mdb / *.pdb) should be packaged in the app. Default is 'true' for debug builds and 'false' for release builds.", v => app.PackageManagedDebugSymbols = ParseBool (v, "package-debug-symbols") },
{ "msym:", "Specify whether managed symbolication files (*.msym) should be created. Default is 'false' for debug builds and 'true' for release builds.", v => app.EnableMSym = ParseBool (v, "msym") },
{ "extension", v => app.IsExtension = true },
{ "app-extension=", "The path of app extensions that are included in the app. This must be specified once for each app extension.", v => app.Extensions.Add (v), true /* MSBuild-internal for now */ },
Expand Down

0 comments on commit d9fc5cf

Please sign in to comment.