Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
- Loading branch information