Skip to content

Commit a7b5768

Browse files
authored
[native] Native call tracing infra + native build system overhaul (#8857)
Context: #8800 Context: 8bc7a3e Context: 6836818 Context: libunwind/libunwind#702 Begin adding native method call tracing infrastructure based on [libunwind][0], initially used in tracing the reasons for why [Blazor][1] apps break when LLVM marshal methods are enabled (8bc7a3e, 6836818). The utility of such infrastructure, however, is beyond just that particular task; it should be available for general use by both us and applications. Method call tracing support is not enabled by default. To enable it, set the `$(_AndroidEnableNativeStackTracing)` MSBuild property to `true`. This will enable the ability to print native, managed and Java stack traces by invoking the `monodroid_log_traces` function from either managed or native application code. Additionally, change the directory layout for native code. Previously, `src/monodroid` would produce *five* native libs: * `libmono-android.debug.so` * `libmono-android.release.so` * `libxa-internal-api.so` * `libxamarin-app.so` * `libxamarin-debug-app-helper.so` This made for a large `src/monodroid/CMakeLists.txt`, complicating maintenance. We had considered trying to move these into separate `src/LIBRARY-NAME` directories, but it makes things easier with CMake if we introduce an intermediate directory. Introduce a new `src/native` directory, to hold native binaries: * `src/native/monodroid`: new location for `libmono-android.*.so` * `src/native/xamarin-debug-app-helper`: source for `libxamarin-debug-app-helper.so`, containing code moved from previous `src/monodroid` * `src/native/xamarin-app-stub`: source for the "stub" `libxamarin-app.so`; the "real" one is produced in the app build. Some `src/native/*` directories produce libraries (`.so` files). and some produce *static* archives (`.a` files) to simplify using code across native libraries. A [cmake-presets file][2] is processed by `xaprepare`, to create a `src/native/CMakePresets.json` which contains all the version-specific bits replacements such as Android API levels, paths to utilities etc. Developers can create a `src/native/CMakeUserPresets.json` file to provide local modifications to config options within `src/native/CMakePresets.json.in`. Other changes: * `src/native/libunwind/fixes/aarch64/Gos-linux.c` is an altered copy of [`libunwind/src/aarch64/Gos-linux.c`][3] in order to workaround libunwind/libunwind#702. * *Begin* turning some instance member functions into static member functions, as we don't otherwise need instances of those classes. * Begin using `std::source_location` for better crash messages, instead of using `__FILE__` and `__LINE__`. * Fix endless recursion from a typo in `Util::ends_with()` overload. [0]: https://github.com/libunwind/libunwind [1]: https://learn.microsoft.com/aspnet/core/blazor/hybrid/tutorials/maui?view=aspnetcore-8.0 [2]: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html [3]: https://github.com/libunwind/libunwind/blob/9cc4d98b22ae57bc1d8c253988feb85d4298a634/src/aarch64/Gos-linux.c
1 parent 478de4c commit a7b5768

File tree

132 files changed

+4561
-3072
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+4561
-3072
lines changed

.gdn/policheck/source.gdnsuppress

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"default": {
1010
"name": "default",
1111
"createdDate": "2023-02-22 23:55:29Z",
12-
"lastUpdatedDate": "2024-02-22 21:40:38Z"
12+
"lastUpdatedDate": "2024-04-22 13:40:30Z"
1313
}
1414
},
1515
"results": {
@@ -101,43 +101,43 @@
101101
"justification": "Reference to an Android logging function.",
102102
"createdDate": "2023-02-22 23:55:29Z"
103103
},
104-
"a2b4d032c59a9d1211d218c3cd550cf8febb369941d70284d07d03ebee855bc0": {
105-
"signature": "a2b4d032c59a9d1211d218c3cd550cf8febb369941d70284d07d03ebee855bc0",
104+
"bca629d8e7888af4116b013c6585b78d0908d248a80138339e0eb1620832eb10": {
105+
"signature": "bca629d8e7888af4116b013c6585b78d0908d248a80138339e0eb1620832eb10",
106106
"alternativeSignatures": [
107-
"9feaec8a73b72e0d212c0e18d863e4fe16ff010c5d33cf8d47d8b0f465cc4c5e"
107+
"f35d63032e4f346c1afcc299d50eb17a0a05ecea81ba3025f14c7fbf78b10100"
108108
],
109109
"memberOf": [
110110
"default"
111111
],
112112
"justification": "Reference to find first set bit function.",
113113
"createdDate": "2023-02-22 23:55:29Z"
114114
},
115-
"1c87b45a6044d205dc3f3562f349c238f7cabe22b4609da762df9dc44151e9fb": {
116-
"signature": "1c87b45a6044d205dc3f3562f349c238f7cabe22b4609da762df9dc44151e9fb",
115+
"dc43990fd9fa6a44f2fb2fffcb0497571af4379f23090482035d79a98970e7ae": {
116+
"signature": "dc43990fd9fa6a44f2fb2fffcb0497571af4379f23090482035d79a98970e7ae",
117117
"alternativeSignatures": [
118-
"9feaec8a73b72e0d212c0e18d863e4fe16ff010c5d33cf8d47d8b0f465cc4c5e"
118+
"f35d63032e4f346c1afcc299d50eb17a0a05ecea81ba3025f14c7fbf78b10100"
119119
],
120120
"memberOf": [
121121
"default"
122122
],
123123
"justification": "Reference to find first set bit function.",
124124
"createdDate": "2023-02-22 23:55:29Z"
125125
},
126-
"a6639098c4785509a4215c9e2fc10f82c06fce461915dc11a00227ddec558845": {
127-
"signature": "a6639098c4785509a4215c9e2fc10f82c06fce461915dc11a00227ddec558845",
126+
"eb60d4f1e48ca85ad5fa4a413d8ff76c4975bccb12931f51179d67c24a82f354": {
127+
"signature": "eb60d4f1e48ca85ad5fa4a413d8ff76c4975bccb12931f51179d67c24a82f354",
128128
"alternativeSignatures": [
129-
"9feaec8a73b72e0d212c0e18d863e4fe16ff010c5d33cf8d47d8b0f465cc4c5e"
129+
"f35d63032e4f346c1afcc299d50eb17a0a05ecea81ba3025f14c7fbf78b10100"
130130
],
131131
"memberOf": [
132132
"default"
133133
],
134134
"justification": "Reference to find first set bit function.",
135135
"createdDate": "2023-02-22 23:55:29Z"
136136
},
137-
"f94ede7b396cb54934db2084f0879cd31a17ce2584eb01e0bfcd35324a724c31": {
138-
"signature": "f94ede7b396cb54934db2084f0879cd31a17ce2584eb01e0bfcd35324a724c31",
137+
"bb80a900ad96e4833eb7f54f55723a3425e846a290dd62b709d4714952cd9d45": {
138+
"signature": "bb80a900ad96e4833eb7f54f55723a3425e846a290dd62b709d4714952cd9d45",
139139
"alternativeSignatures": [
140-
"9feaec8a73b72e0d212c0e18d863e4fe16ff010c5d33cf8d47d8b0f465cc4c5e"
140+
"f35d63032e4f346c1afcc299d50eb17a0a05ecea81ba3025f14c7fbf78b10100"
141141
],
142142
"memberOf": [
143143
"default"

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@
2828
[submodule "external/constexpr-xxh3"]
2929
path = external/constexpr-xxh3
3030
url = https://github.com/chys87/constexpr-xxh3.git
31+
[submodule "external/libunwind"]
32+
path = external/libunwind
33+
url = https://github.com/libunwind/libunwind.git
34+
branch = master

Configuration.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@
104104
<IgnoreMaxMonoVersion Condition=" '$(IgnoreMaxMonoVersion)' == '' ">True</IgnoreMaxMonoVersion>
105105
<OpenTKSourceDirectory>$(MSBuildThisFileDirectory)external\opentk</OpenTKSourceDirectory>
106106
<SqliteSourceDirectory Condition=" '$(SqliteSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\sqlite</SqliteSourceDirectory>
107+
<LibUnwindSourceDirectory Condition=" '$(LibUnwindSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\libunwind</LibUnwindSourceDirectory>
108+
<LibUnwindGeneratedHeadersDirectory Condition=" '$(LibUnwindGeneratedHeadersDirectory)' == '' ">$(BootstrapOutputDirectory)\libunwind</LibUnwindGeneratedHeadersDirectory>
109+
<LZ4SourceDirectory Condition=" '$(LZ4SourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\lz4</LZ4SourceDirectory>
107110
<XamarinAndroidSourcePath>$(MSBuildThisFileDirectory)</XamarinAndroidSourcePath>
108111
<ThirdPartySourcePath>$(MSBuildThisFileDirectory)src-ThirdParty\</ThirdPartySourcePath>
109112
<AllSupported32BitTargetAndroidAbis>armeabi-v7a;x86</AllSupported32BitTargetAndroidAbis>
@@ -144,6 +147,9 @@
144147
<JavaInteropFullPath>$([System.IO.Path]::GetFullPath ('$(JavaInteropSourceDirectory)'))</JavaInteropFullPath>
145148
<MonoSourceFullPath>$([System.IO.Path]::GetFullPath ('$(MonoSourceDirectory)'))</MonoSourceFullPath>
146149
<SqliteSourceFullPath>$([System.IO.Path]::GetFullPath ('$(SqliteSourceDirectory)'))</SqliteSourceFullPath>
150+
<LibUnwindSourceFullPath>$([System.IO.Path]::GetFullPath ('$(LibUnwindSourceDirectory)'))</LibUnwindSourceFullPath>
151+
<LibUnwindGeneratedHeadersFullPath>$([System.IO.Path]::GetFullPath ('$(LibUnwindGeneratedHeadersDirectory)'))</LibUnwindGeneratedHeadersFullPath>
152+
<LZ4SourceFullPath>$([System.IO.Path]::GetFullPath ('$(LZ4SourceDirectory)'))</LZ4SourceFullPath>
147153
<OpenTKSourceFullPath>$([System.IO.Path]::GetFullPath ('$(OpenTKSourceDirectory)'))</OpenTKSourceFullPath>
148154
<JavaInteropTargetFrameworkVersion>net8.0</JavaInteropTargetFrameworkVersion>
149155
</PropertyGroup>

Xamarin.Android.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.Tools.Diagnost
4747
EndProject
4848
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}"
4949
EndProject
50-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "monodroid", "src\monodroid\monodroid.csproj", "{53EE4C57-1C03-405A-8243-8DA539546C88}"
50+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "native", "src\native\native.csproj", "{53EE4C57-1C03-405A-8243-8DA539546C88}"
5151
EndProject
5252
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{CAB438D8-B0F5-4AF0-BEBD-9E2ADBD7B483}"
5353
EndProject

build-tools/cmake/xa_common.cmake

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)