Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mtouch] Put 'mono_profiler_startup_log' in the symbol list. Fixes #58778. #2501

Merged
merged 1 commit into from
Aug 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions tests/mtouch/MTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,59 @@ public enum Profile { iOS, tvOS, watchOS }
[TestFixture]
public class MTouch
{
[Test]
//[TestCase (Profile.iOS)] // tested as part of the watchOS case below, since that builds both for iOS and watchOS.
[TestCase (Profile.tvOS)]
[TestCase (Profile.watchOS)]
public void Profiling (Profile profile)
{
using (var mtouch = new MTouchTool ()) {
var tmpdir = mtouch.CreateTemporaryDirectory ();
MTouchTool ext = null;
if (profile == Profile.watchOS) {
mtouch.Profile = Profile.iOS;

ext = new MTouchTool ();
ext.Profile = profile;
ext.Profiling = true;
ext.SymbolList = Path.Combine (tmpdir, "extsymbollist.txt");
ext.CreateTemporaryWatchKitExtension ();
ext.CreateTemporaryDirectory ();
mtouch.AppExtensions.Add (ext);
ext.AssertExecute (MTouchAction.BuildDev, "ext build");
} else {
mtouch.Profile = profile;
}
mtouch.CreateTemporaryApp ();
mtouch.CreateTemporaryCacheDirectory ();

mtouch.DSym = false; // faster test
mtouch.MSym = false; // faster test
mtouch.NoStrip = true; // faster test

mtouch.Profiling = true;
mtouch.SymbolList = Path.Combine (tmpdir, "symbollist.txt");
mtouch.AssertExecute (MTouchAction.BuildDev, "build");

var profiler_symbol = "_mono_profiler_startup_log";

var symbols = File.ReadAllLines (mtouch.SymbolList);
Assert.That (symbols, Contains.Item (profiler_symbol), profiler_symbol);

symbols = ExecutionHelper.Execute ("nm", StringUtils.Quote (mtouch.NativeExecutablePath), hide_output: true).Split ('\n');
Assert.That (symbols, Has.Some.EndsWith (" T " + profiler_symbol), $"{profiler_symbol} nm");

if (ext != null) {
symbols = File.ReadAllLines (ext.SymbolList);
Assert.That (symbols, Contains.Item (profiler_symbol), $"{profiler_symbol} - extension");

symbols = ExecutionHelper.Execute ("nm", StringUtils.Quote (ext.NativeExecutablePath), hide_output: true).Split ('\n');
Assert.That (symbols, Has.Some.EndsWith (" T " + profiler_symbol), $"{profiler_symbol} extension nm");

}
}
}

[Test]
public void ExceptionMarshaling ()
{
Expand Down
8 changes: 8 additions & 0 deletions tests/mtouch/MTouchTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ class MTouchTool : Tool, IDisposable
public string AotOtherArguments;
public string [] LinkSkip;
public string [] XmlDefinitions;
public bool? Profiling;
public string SymbolList;

#pragma warning restore 649

Expand Down Expand Up @@ -307,6 +309,12 @@ string BuildArguments (MTouchAction action)
}
}

if (Profiling.HasValue)
sb.Append (" --profiling:").Append (Profiling.Value ? "true" : "false");

if (!string.IsNullOrEmpty (SymbolList))
sb.Append (" --symbollist=").Append (StringUtils.Quote (SymbolList));

if (MSym.HasValue)
sb.Append (" --msym:").Append (MSym.Value ? "true" : "false");

Expand Down
8 changes: 0 additions & 8 deletions tools/common/CompilerFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ public HashSet<string> AllLibraries {
}
}

public void ReferenceSymbol (string symbol)
{
if (UnresolvedSymbols == null)
UnresolvedSymbols = new HashSet<string> ();

UnresolvedSymbols.Add (symbol);
}

public void ReferenceSymbols (IEnumerable<Symbol> symbols)
{
if (UnresolvedSymbols == null)
Expand Down
5 changes: 5 additions & 0 deletions tools/common/Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ public void CollectAllSymbols ()
dynamic_symbols.AddFunction ("xamarin_dyn_objc_msgSendSuper_stret");
}

#if MONOTOUCH
if (App.EnableProfiling && App.LibProfilerLinkMode == AssemblyBuildTarget.StaticObject)
dynamic_symbols.AddFunction ("mono_profiler_startup_log");
#endif

dynamic_symbols.Save (cache_location);
}

Expand Down
2 changes: 0 additions & 2 deletions tools/mtouch/Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1396,8 +1396,6 @@ public void NativeLink (BuildTasks build_tasks)
case AssemblyBuildTarget.StaticObject:
libprofiler = Path.Combine (libdir, "libmono-profiler-log.a");
linker_flags.AddLinkWith (libprofiler);
if (!App.EnableBitCode)
linker_flags.ReferenceSymbol ("mono_profiler_startup_log");
break;
case AssemblyBuildTarget.Framework: // We don't ship the profiler as a framework, so this should be impossible.
default:
Expand Down