Skip to content
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
31fa878
Some debug messages
grendello Mar 28, 2023
40646c5
Merge branch 'main' into blazor-hang
grendello Mar 28, 2023
a89f45b
Marshal methods tracing
grendello Mar 28, 2023
fd06651
Native backtrace implementation
grendello Mar 29, 2023
2193db1
Merge branch 'main' into blazor-hang
grendello Mar 30, 2023
0564634
[WIP] Stack unwinding (doesn't build yet)
grendello Mar 30, 2023
3732378
Build and use our own libunwind
grendello Mar 31, 2023
8b05e39
Merge branch 'main' into blazor-hang
grendello Apr 3, 2023
97c5127
Make lld really ignore missing symbols + other stuff
grendello Apr 3, 2023
d37a22a
Eliminate the need to use NDK when enabling marshal methods tracing
grendello Apr 4, 2023
1ca486a
Merge branch 'main' into blazor-hang
grendello Apr 5, 2023
fb7f7e6
Java stack trace implemented
grendello Apr 5, 2023
2f58b13
Merge branch 'main' into blazor-hang
grendello Apr 6, 2023
e3d2649
Add signal handlers to the report
grendello Apr 6, 2023
581194e
Merge branch 'main' into blazor-hang
grendello Apr 7, 2023
0ba212e
Day spent debugging
grendello Apr 7, 2023
a512324
Merge branch 'main' into blazor-hang
grendello Apr 11, 2023
8c1b27f
Merge branch 'main' into blazor-hang
grendello Apr 11, 2023
b8cb13d
Tracing code is going to live in a separate DSO
grendello Apr 11, 2023
0cf46bd
Merge branch 'main' into blazor-hang
grendello Apr 12, 2023
61f2114
Merge branch 'main' into blazor-hang
grendello Apr 12, 2023
d0ef3e7
Put tracing code in a separate library
grendello Apr 12, 2023
469e752
Merge branch 'main' into blazor-hang
grendello Apr 12, 2023
1076ed5
Don't package the tracing DSO unless told so
grendello Apr 13, 2023
d9d869c
Merge branch 'main' into blazor-hang
grendello Apr 14, 2023
c291dc4
Spent the day tracking registered and executed methods
grendello Apr 17, 2023
35be489
A small TODO
grendello Apr 17, 2023
4b595a8
Merge branch 'main' into blazor-hang
grendello Apr 24, 2023
4288baf
Make sure invariant culture is used
grendello Apr 24, 2023
b68b512
Merge branch 'main' into blazor-hang
grendello Apr 25, 2023
7eb75e3
Merge branch 'main' into blazor-hang
grendello Apr 27, 2023
caae9e9
Add some Java tracing + Java.Interop tracing
grendello Apr 27, 2023
6a48e52
Merge branch 'main' into blazor-hang
grendello Apr 28, 2023
72abfa3
More tracing, perhaps getting closer
grendello Apr 28, 2023
4b45d5f
Merge branch 'main' into blazor-hang
grendello May 4, 2023
48f4b6a
Base code for parameter and return value logging
grendello May 4, 2023
212f6ef
Different approach to printing params
grendello May 5, 2023
bc5b0f8
Progress towards supporting variadic functions
grendello May 8, 2023
7600af1
Well, it generates correct code now
grendello May 8, 2023
788bd63
Merge branch 'main' into blazor-hang
grendello May 9, 2023
19e79a2
Generated code not complete, won't compile
grendello May 9, 2023
cae9bb0
Merge branch 'main' into blazor-hang
grendello May 10, 2023
cae0bd8
Way too much time spent on this...
grendello May 10, 2023
9fd0b07
Merge branch 'main' into blazor-hang
grendello May 11, 2023
fd3eefd
Found and fixed an issue with marshal methods
grendello May 11, 2023
fde3078
asprintf call & co is complete
grendello May 12, 2023
46fe18b
Merge branch 'main' into blazor-hang
grendello May 15, 2023
79cf274
Merge branch 'main' into blazor-hang
grendello May 16, 2023
d942663
Function parameter and return value tracing works
grendello May 16, 2023
37c401a
Merge branch 'main' into blazor-hang
grendello May 17, 2023
a74882f
Preparations for better argument logging
grendello May 17, 2023
3673a3a
Merge branch 'main' into blazor-hang
grendello May 18, 2023
37b16d3
Third iteration... done for today
grendello May 18, 2023
9af8f8e
Merge branch 'main' into blazor-hang
grendello May 19, 2023
8f86bc7
Cul-de-sac, dead end, wrong way, doh
grendello May 19, 2023
f6df472
Merge branch 'main' into blazor-hang
grendello May 22, 2023
135744c
New approach to LLVM IR generation
grendello May 22, 2023
58965d1
Merge branch 'main' into blazor-hang
grendello May 23, 2023
ef27fe5
More steps towards new LLVM IR generator
grendello May 23, 2023
c9cb983
Merge branch 'main' into blazor-hang
grendello May 24, 2023
12b8a61
Moving forward with the new LLVM IR generator
grendello May 24, 2023
49b7d63
Rearchitecting things for simpler use
grendello May 25, 2023
c67fbb9
Merge branch 'main' into blazor-hang
grendello May 26, 2023
3d5e073
New generator is alive
grendello May 26, 2023
603afbb
Merge branch 'main' into blazor-hang
grendello May 29, 2023
ec099cf
Data generation progressing nicely.
grendello May 29, 2023
db5be23
Structures written fine, onto structure arrays tomorrow
grendello May 30, 2023
42437cd
Structure arrays done
grendello May 31, 2023
0f39485
Phew, array and structure handling simplified and unified
grendello Jun 1, 2023
c937202
Merge branch 'main' into blazor-hang
grendello Jun 2, 2023
f81fa85
ApplicationConfigNativeAssemblyGenerator switched to the new LLVM IR …
grendello Jun 2, 2023
0da112c
Merge branch 'main' into blazor-hang
grendello Jun 5, 2023
09fbf9c
Moving on with new LLVM IR generator
grendello Jun 5, 2023
fd93c1f
Merge branch 'main' into blazor-hang
grendello Jun 6, 2023
c32dc33
Release TypeMap composer converted to the new generator
grendello Jun 6, 2023
55aec7d
Merge branch 'main' into blazor-hang
grendello Jun 7, 2023
f35855b
Debug typemap generator converted
grendello Jun 7, 2023
2990041
Compressed assemblies composer converted
grendello Jun 7, 2023
cd4584b
Merge branch 'main' into blazor-hang
grendello Jun 12, 2023
d126d26
JNI remapping composer converted
grendello Jun 12, 2023
0de8a6f
Merge branch 'main' into blazor-hang
grendello Jun 13, 2023
7a23158
Data portion of the marshal methods generator done
grendello Jun 13, 2023
0fea526
Merge branch 'main' into blazor-hang
grendello Jun 14, 2023
3d27e22
Beginnings of code generation
grendello Jun 14, 2023
fb63716
Merge branch 'main' into blazor-hang
grendello Jun 15, 2023
5e98bc3
Code generation works
grendello Jun 15, 2023
11bf0a7
Merge branch 'main' into blazor-hang
grendello Jun 16, 2023
1ddf89f
Halfway through code generation
grendello Jun 16, 2023
80c510a
Merge branch 'main' into blazor-hang
grendello Jun 19, 2023
5c17d76
`call` sorted out, tomorrow onto `phi`
grendello Jun 19, 2023
76e4d0c
Merge branch 'main' into blazor-hang
grendello Jun 20, 2023
33c9ac3
Conversion to the new LLVM IR complete for everything except tracing
grendello Jun 20, 2023
69bd75e
Merge branch 'main' into blazor-hang
grendello Jun 21, 2023
4d8d4dc
Cleanup
grendello Jun 21, 2023
6799989
A bit more cleanup
grendello Jun 21, 2023
60b0a13
Merge branch 'main' into blazor-hang
grendello Jun 22, 2023
580aae9
Update libunwind to 1.7.0
grendello Jun 22, 2023
944b73b
Tracing progress
grendello Jun 22, 2023
2c74196
Merge branch 'main' into blazor-hang
grendello Jun 23, 2023
95d423d
asprintf progress, new style
grendello Jun 23, 2023
1ef3255
Add some more tracing capabilities
grendello Jun 26, 2023
e148e1b
Merge branch 'main' into blazor-hang
grendello Jun 27, 2023
5316425
More tracing improvements
grendello Jun 27, 2023
c11f03b
Merge branch 'main' into blazor-hang
grendello Jun 28, 2023
b864253
asprintf simpler, general `call` improvements, assorted fixes
grendello Jun 28, 2023
c1cad61
Merge branch 'main' into blazor-hang
grendello Jun 28, 2023
b5fc35f
Merge branch 'main' into blazor-hang
grendello Mar 8, 2024
76cd39a
Fixups after merge
grendello Mar 8, 2024
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
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@
path = external/xamarin-android-tools
url = https://github.com/xamarin/xamarin-android-tools
branch = main
[submodule "external/libunwind"]
path = external/libunwind
url = https://github.com/libunwind/libunwind.git
branch = v1.7-stable
4 changes: 4 additions & 0 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@
<MingwZlibRootDirectory64>$(MingwZlibRootDirectory)\x86_64-w64-mingw32</MingwZlibRootDirectory64>
<MingwZlibLibraryName>libz.a</MingwZlibLibraryName>
<SqliteSourceDirectory Condition=" '$(SqliteSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\sqlite</SqliteSourceDirectory>
<LibUnwindSourceDirectory Condition=" '$(LibUnwindSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\libunwind</LibUnwindSourceDirectory>
<LibUnwindGeneratedHeadersDirectory Condition=" '$(LibUnwindGeneratedHeadersDirectory)' == '' ">$(BootstrapOutputDirectory)\libunwind</LibUnwindGeneratedHeadersDirectory>
<XamarinAndroidSourcePath>$(MSBuildThisFileDirectory)</XamarinAndroidSourcePath>
<ThirdPartySourcePath>$(MSBuildThisFileDirectory)src-ThirdParty\</ThirdPartySourcePath>
<AllSupported32BitTargetAndroidAbis>armeabi-v7a;x86</AllSupported32BitTargetAndroidAbis>
Expand Down Expand Up @@ -175,6 +177,8 @@
<MonoSourceFullPath>$([System.IO.Path]::GetFullPath ('$(MonoSourceDirectory)'))</MonoSourceFullPath>
<LinkerSourceFullPath>$([System.IO.Path]::GetFullPath ('$(LinkerSourceDirectory)'))</LinkerSourceFullPath>
<SqliteSourceFullPath>$([System.IO.Path]::GetFullPath ('$(SqliteSourceDirectory)'))</SqliteSourceFullPath>
<LibUnwindSourceFullPath>$([System.IO.Path]::GetFullPath ('$(LibUnwindSourceDirectory)'))</LibUnwindSourceFullPath>
<LibUnwindGeneratedHeadersFullPath>$([System.IO.Path]::GetFullPath ('$(LibUnwindGeneratedHeadersDirectory)'))</LibUnwindGeneratedHeadersFullPath>
<OpenTKSourceFullPath>$([System.IO.Path]::GetFullPath ('$(OpenTKSourceDirectory)'))</OpenTKSourceFullPath>
</PropertyGroup>
<PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions Xamarin.Android.sln
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.Tools.Diagnost
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.Tools.Cecil", "external\Java.Interop\src\Java.Interop.Tools.Cecil\Java.Interop.Tools.Cecil.csproj", "{D48EE8D0-0A0A-4493-AEF5-DAF5F8CF86AD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "libunwind", "src\libunwind-xamarin\libunwind-xamarin.csproj", "{F8E4961B-C427-47F9-92D6-0BEB5B76B3D7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "monodroid", "src\monodroid\monodroid.csproj", "{53EE4C57-1C03-405A-8243-8DA539546C88}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.NUnitLite", "src\Xamarin.Android.NUnitLite\Xamarin.Android.NUnitLite.csproj", "{4D603AA3-3BFD-43C8-8050-0CD6C2601126}"
Expand Down
2 changes: 2 additions & 0 deletions build-tools/create-packs/Microsoft.Android.Runtime.proj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ projects that use the Microsoft.Android framework in .NET 6+.
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libmono-android.debug.so" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libmono-android.release.so" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libxamarin-debug-app-helper.so" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libmarshal-methods-tracing.a" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libclang_rt.builtins-*-android.a" />
<FrameworkListFileClass Include="@(_AndroidRuntimePackAssemblies->'%(Filename)%(Extension)')" Profile="Android" />
<FrameworkListFileClass Include="@(_AndroidRuntimePackAssets->'%(Filename)%(Extension)')" Profile="Android" />
</ItemGroup>
Expand Down
8 changes: 8 additions & 0 deletions build-tools/installers/create-installers.targets
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,20 @@
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)ManifestOverlays\Timing.xml" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm64\libc.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm64\libm.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm64\libdl.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm64\liblog.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm\libc.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm\libm.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm\libdl.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm\liblog.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x64\libc.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x64\libm.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x64\libdl.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x64\liblog.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x86\libc.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x86\libm.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x86\libdl.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x86\liblog.so" />
</ItemGroup>
<ItemGroup>
<_MSBuildTargetsSrcFiles Include="$(MSBuildTargetsSrcDir)\Xamarin.Android.AvailableItems.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ void GenerateShellConfig (Context context, StreamWriter sw)
{ "@NinjaPath@", "${NINJA}" },
{ "@OUTPUT_DIRECTORY@", "${__OUTPUT_DIR}" },
{ "@SOURCE_DIRECTORY@", "${MONODROID_SOURCE_DIR}" },
{ "@LibUnwindSourceFullPath@", "${LIBUNWIND_SOURCE_FULL_PATH}" },
{ "@LibUnwindGeneratedHeadersFullPath@", "${LIBUNWIND_HEADERS_FULL_PATH}" },
};

var androidRuntimeReplacements = new Dictionary<string, string> (StringComparer.Ordinal) {
Expand Down Expand Up @@ -98,6 +100,8 @@ void GenerateShellConfig (Context context, StreamWriter sw)
sw.WriteLine ($"NINJA=\"{context.Properties.GetRequiredValue(KnownProperties.NinjaPath)}\"");
sw.WriteLine ($"XA_BUILD_CONFIGURATION={context.Configuration}");
sw.WriteLine ($"XA_INSTALL_DIR=\"{Configurables.Paths.InstallMSBuildDir}/lib\"");
sw.WriteLine ($"LIBUNWIND_SOURCE_FULL_PATH=\"{context.Properties.GetRequiredValue(KnownProperties.LibUnwindSourceFullPath)}\"");
sw.WriteLine ($"LIBUNWIND_HEADERS_FULL_PATH=\"{context.Properties.GetRequiredValue(KnownProperties.LibUnwindGeneratedHeadersFullPath)}\"");
sw.WriteLine ();

string indent = "\t";
Expand Down Expand Up @@ -329,6 +333,8 @@ void GenerateMonodroidTargets (Context context, StreamWriter sw)
{ "@BUILD_TYPE@", "" },
{ "@CONFIGURATION@", "" },
{ "@SOURCE_DIRECTORY@", $"$(MSBuildThisFileDirectory){sourceDir}" },
{ "@LibUnwindSourceFullPath@", "$(LibUnwindSourceFullPath)" },
{ "@LibUnwindGeneratedHeadersFullPath@", "$(LibUnwindGeneratedHeadersFullPath)" },
};

var androidRuntimeReplacements = new Dictionary<string, string> (StringComparer.Ordinal) {
Expand Down Expand Up @@ -445,6 +451,8 @@ void GenerateMSBuildProps (Context context, StreamWriter sw)
{ "@AndroidNdkDirectory@", "$(AndroidNdkDirectory)" },
{ "@MonoSourceFullPath@", "$(MonoSourceFullPath)" },
{ "@AndroidToolchainPath@", GetRelativeToolchainDefinitionPath () },
{ "@LibUnwindSourceFullPath@", "$(LibUnwindSourceFullPath)" },
{ "@LibUnwindGeneratedHeadersFullPath@", "$(LibUnwindGeneratedHeadersFullPath)" },
};

var MSBuildMingwReplacements = new Dictionary<string, string> (StringComparer.Ordinal) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ static class KnownProperties
public const string JavaInteropFullPath = "JavaInteropFullPath";
public const string JavaSdkDirectory = "JavaSdkDirectory";
public const string JdkIncludePath = "JdkIncludePath";
public const string LibUnwindGeneratedHeadersFullPath = nameof (LibUnwindGeneratedHeadersFullPath);
public const string LibUnwindSourceFullPath = nameof (LibUnwindSourceFullPath);
public const string LibZipSourceFullPath = "LibZipSourceFullPath";
public const string ManagedRuntime = "ManagedRuntime";
public const string MicrosoftAndroidSdkOutDir = "MicrosoftAndroidSdkOutDir";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ namespace Xamarin.Android.Prepare
properties.Add (KnownProperties.JavaInteropFullPath, StripQuotes (@"@JavaInteropFullPath@"));
properties.Add (KnownProperties.JavaSdkDirectory, StripQuotes (@"@JavaSdkDirectory@"));
properties.Add (KnownProperties.JdkIncludePath, StripQuotes (@"@JdkIncludePath@"));
properties.Add (KnownProperties.LibUnwindGeneratedHeadersFullPath, StripQuotes (@"@LibUnwindGeneratedHeadersFullPath@"));
properties.Add (KnownProperties.LibUnwindSourceFullPath, StripQuotes (@"@LibUnwindSourceFullPath"));
properties.Add (KnownProperties.LibZipSourceFullPath, StripQuotes (@"@LibZipSourceFullPath@"));
properties.Add (KnownProperties.ManagedRuntime, StripQuotes (@"@ManagedRuntime@"));
properties.Add (KnownProperties.MicrosoftAndroidSdkOutDir, StripQuotes (@"@MicrosoftAndroidSdkOutDir@"));
Expand Down
8 changes: 6 additions & 2 deletions build-tools/xaprepare/xaprepare/ConfigAndData/CmakeBuilds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@ public sealed class RuntimeCommand
"-GNinja",
"-DCMAKE_MAKE_PROGRAM=\"@NinjaPath@\"",
"-DXA_BUILD_CONFIGURATION=@XA_BUILD_CONFIGURATION@",
"-DXA_LIB_TOP_DIR=@XA_LIB_TOP_DIR@",
"-DXA_LIB_TOP_DIR=\"@XA_LIB_TOP_DIR@\"",
"-DLIBUNWIND_SOURCE_DIR=\"@LibUnwindSourceFullPath@\"",
"-DLIBUNWIND_HEADERS_DIR=\"@LibUnwindGeneratedHeadersFullPath@\"",
};

public static readonly List<string> AndroidFlags = new List<string> {
"-DANDROID_STL=\"none\"",
"-DANDROID_CPP_FEATURES=\"no-rtti no-exceptions\"",
"-DANDROID_TOOLCHAIN=clang",
"-DCMAKE_TOOLCHAIN_FILE=\"@AndroidNdkDirectory@@AndroidToolchainPath@\"",
"-DANDROID_NDK=@AndroidNdkDirectory@"
"-DANDROID_NDK=@AndroidNdkDirectory@",
"-DLIBUNWIND_SOURCE_DIR=\"@LibUnwindSourceFullPath@\"",
"-DLIBUNWIND_HEADERS_DIR=\"@LibUnwindGeneratedHeadersFullPath@\"",
};

public static readonly List<string> MonodroidCommonDefines = new List<string> {
Expand Down
1 change: 1 addition & 0 deletions build-tools/xaprepare/xaprepare/xaprepare.targets
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<Replacement Include="@JavaInteropFullPath@=$(JavaInteropFullPath)" />
<Replacement Include="@JavaSdkDirectory@=$(JavaSdkDirectory)" />
<Replacement Include="@JdkIncludePath@=$(JavaIncludePath)" />
<Replacement Include="@LibUnwindSourceFullPath@=$(LibUnwindSourceFullPath)" />
<Replacement Include="@LibZipSourceFullPath@=$(LibZipSourceFullPath)" />
<Replacement Include="@ManagedRuntime@=$(ManagedRuntime)" />
<Replacement Include="@MicrosoftAndroidSdkOutDir@=$(MicrosoftAndroidSdkOutDir)" />
Expand Down
1 change: 1 addition & 0 deletions external/libunwind
Submodule libunwind added at 74ab1e
4 changes: 3 additions & 1 deletion src/Mono.Android/Java.Interop/TypeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ static Exception CreateJavaLocationException ()

if (!JNIEnvInit.IsRunningOnDesktop) {
// Miss message is logged in the native runtime
if (JNIEnvInit.LogAssemblyCategory)
if (JNIEnvInit.LogAssemblyCategory) {
JNIEnv.LogTypemapTrace (new System.Diagnostics.StackTrace (true));
RuntimeNativeMethods.monodroid_log (LogLevel.Warn, LogCategories.Assembly, CreateJavaLocationException ().ToString ());
}
return null;
}

Expand Down
22 changes: 1 addition & 21 deletions src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void Run (DirectoryAssemblyResolver res, bool useMarshalMethods)
targetPaths.Add (Path.Combine (IntermediateOutputDirectory, "linked"));
} else {
foreach (string abi in SupportedAbis) {
targetPaths.Add (Path.Combine (IntermediateOutputDirectory, AbiToRid (abi), "linked"));
targetPaths.Add (Path.Combine (IntermediateOutputDirectory, MonoAndroidHelper.AbiToRid (abi), "linked"));
}
}
}
Expand Down Expand Up @@ -432,26 +432,6 @@ void StoreMarshalAssemblyPath (string name, ITaskItem asm)

assemblyPaths.Add (asm.ItemSpec);
}

string AbiToRid (string abi)
{
switch (abi) {
case "arm64-v8a":
return "android-arm64";

case "armeabi-v7a":
return "android-arm";

case "x86":
return "android-x86";

case "x86_64":
return "android-x64";

default:
throw new InvalidOperationException ($"Internal error: unsupported ABI '{abi}'");
}
}
}

bool CreateJavaSources (IEnumerable<TypeDefinition> javaTypes, TypeDefinitionCache cache, MarshalMethodsClassifier classifier, bool useMarshalMethods)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class GeneratePackageManagerJava : AndroidTask
public override string TaskPrefix => "GPM";

Guid buildId = Guid.NewGuid ();
MarshalMethodsTracingMode mmTracingMode;

[Required]
public ITaskItem[] ResolvedAssemblies { get; set; }
Expand Down Expand Up @@ -66,6 +67,7 @@ public class GeneratePackageManagerJava : AndroidTask
public bool InstantRunEnabled { get; set; }

public bool EnableMarshalMethods { get; set; }
public string MarshalMethodsTracingMode { get; set; }
public string RuntimeConfigBinFilePath { get; set; }
public string BoundExceptionType { get; set; }

Expand All @@ -92,6 +94,8 @@ bool _Debug {

public override bool RunTask ()
{
mmTracingMode = MonoAndroidHelper.ParseMarshalMethodsTracingMode (MarshalMethodsTracingMode);

BuildId = buildId.ToString ();
Log.LogDebugMessage (" [Output] BuildId: {0}", BuildId);

Expand Down Expand Up @@ -410,7 +414,8 @@ void AddEnvironment ()
assemblyCount,
uniqueAssemblyNames,
marshalMethodsState?.MarshalMethods,
Log
Log,
mmTracingMode
);
} else {
marshalMethodsAsmGen = new MarshalMethodsNativeAssemblyGenerator (assemblyCount, uniqueAssemblyNames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ sealed class InputFiles
{
public List<string> ObjectFiles;
public string OutputSharedLibrary;
public List<string> ExtraLibraries;
}

[Required]
Expand All @@ -43,8 +44,16 @@ sealed class InputFiles
[Required]
public string AndroidBinUtilsDirectory { get; set; }

public string MarshalMethodsTracingMode { get; set; }

MarshalMethodsTracingMode mmTracingMode;
bool mmTracingEnabled;

public override System.Threading.Tasks.Task RunTaskAsync ()
{
mmTracingMode = MonoAndroidHelper.ParseMarshalMethodsTracingMode (MarshalMethodsTracingMode);
mmTracingEnabled = mmTracingMode != Tasks.MarshalMethodsTracingMode.None;

return this.WhenAll (GetLinkerConfigs (), RunLinker);
}

Expand Down Expand Up @@ -112,27 +121,29 @@ void RunLinker (Config config)

IEnumerable<Config> GetLinkerConfigs ()
{
string runtimeNativeLibsDir = Path.GetFullPath (Path.Combine (AndroidBinUtilsDirectory, "..", "..", "..", "lib"));
string runtimeNativeLibStubsDir = Path.GetFullPath (Path.Combine (runtimeNativeLibsDir, "..", "libstubs"));
var abis = new Dictionary <string, InputFiles> (StringComparer.Ordinal);
ITaskItem[] dsos = ApplicationSharedLibraries;
foreach (ITaskItem item in dsos) {
string abi = item.GetMetadata ("abi");
abis [abi] = GatherFilesForABI(item.ItemSpec, abi, ObjectFiles);
abis [abi] = GatherFilesForABI (item.ItemSpec, abi, ObjectFiles, runtimeNativeLibsDir, runtimeNativeLibStubsDir);
}

const string commonLinkerArgs =
"--unresolved-symbols=ignore-in-shared-libs " +
"--shared " +
"--allow-shlib-undefined " +
"--export-dynamic " +
"-soname libxamarin-app.so " +
"-z relro " +
"-z noexecstack " +
"--enable-new-dtags " +
"--eh-frame-hdr " +
"-shared " +
"--build-id " +
"--warn-shared-textrel " +
"--fatal-warnings";

string stripSymbolsArg = DebugBuild ? String.Empty : " -s";
string stripSymbolsArg = DebugBuild || mmTracingEnabled ? String.Empty : " -s";

string ld = Path.Combine (AndroidBinUtilsDirectory, MonoAndroidHelper.GetExecutablePath (AndroidBinUtilsDirectory, "ld"));
var targetLinkerArgs = new List<string> ();
Expand Down Expand Up @@ -177,6 +188,12 @@ IEnumerable<Config> GetLinkerConfigs ()
targetLinkerArgs.Add ("-o");
targetLinkerArgs.Add (QuoteFileName (inputs.OutputSharedLibrary));

if (inputs.ExtraLibraries != null) {
foreach (string lib in inputs.ExtraLibraries) {
targetLinkerArgs.Add (lib);
}
}

string targetArgs = String.Join (" ", targetLinkerArgs);
yield return new Config {
LinkerPath = ld,
Expand All @@ -186,11 +203,33 @@ IEnumerable<Config> GetLinkerConfigs ()
}
}

InputFiles GatherFilesForABI (string runtimeSharedLibrary, string abi, ITaskItem[] objectFiles)
InputFiles GatherFilesForABI (string runtimeSharedLibrary, string abi, ITaskItem[] objectFiles, string runtimeNativeLibsDir, string runtimeNativeLibStubsDir)
{
List<string> extraLibraries = null;

if (mmTracingEnabled) {
string RID = MonoAndroidHelper.AbiToRid (abi);
AndroidTargetArch targetArch = MonoAndroidHelper.AbiToTargetArch (abi);
string clangLibraryAbi = MonoAndroidHelper.ArchToClangLibraryAbi (targetArch);
string builtinsLibName = $"libclang_rt.builtins-{clangLibraryAbi}-android.a";
string libStubsPath = Path.Combine (runtimeNativeLibStubsDir, RID);
string runtimeLibsDir = Path.Combine (runtimeNativeLibsDir, RID);

extraLibraries = new List<string> {
Path.Combine (runtimeLibsDir, "libmarshal-methods-tracing.a"),
Path.Combine (runtimeLibsDir, "libunwind_xamarin.a"),
Path.Combine (runtimeLibsDir, builtinsLibName),
$"-L \"{libStubsPath}\"",
"-lc",
"-ldl",
"-llog", // tracing uses android logger
};
}

return new InputFiles {
OutputSharedLibrary = runtimeSharedLibrary,
ObjectFiles = GetItemsForABI (abi, objectFiles),
ExtraLibraries = extraLibraries,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Globalization;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Xamarin.Android.Tasks.LLVMIR
{
Expand Down Expand Up @@ -90,7 +89,7 @@ class LlvmIrFunction
uint localSlot = 0;
uint indentLevel = 1;

public LlvmIrFunction (string name, Type returnType, int attributeSetID, List<LlvmIrFunctionParameter>? parameters = null)
public LlvmIrFunction (string name, Type returnType, int attributeSetID, IList<LlvmIrFunctionParameter>? parameters = null)
{
if (String.IsNullOrEmpty (name)) {
throw new ArgumentException ("must not be null or empty", nameof (name));
Expand Down
Loading