You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Learn about diagnostics in Native AOT applications
2
+
title: Diagnostics and instrumentation on desktop platforms
3
+
description: Learn about diagnostics in Native AOT applications on desktop platforms
4
4
author: lakshanf
5
5
ms.author: lakshanf
6
6
ms.date: 08/07/2023
7
7
---
8
8
9
-
# Diagnostics and instrumentation
10
-
11
-
Native AOT shares some, but not all, diagnostics and instrumentation capabilities with CoreCLR. Because of CoreCLR's rich selection of diagnostic utilities, it's sometimes appropriate to diagnose and debug problems in CoreCLR. Apps that are [trim-compatible](../trimming/prepare-libraries-for-trimming.md) shouldn't have behavioral differences, so investigations often apply to both runtimes. Nonetheless, some information can only be gathered after publishing, so Native AOT also provides post-publish diagnostic tooling.
12
-
13
-
## .NET 8 Native AOT diagnostic support
14
-
15
-
The following table summarizes diagnostic features supported for Native AOT deployments:
# Native AOT diagnostic support on desktop platforms
24
10
25
11
## Observability and telemetry
26
12
27
-
As of .NET 8, the Native AOT runtime supports [EventPipe](../../diagnostics/eventpipe.md), which is the base layer used by many logging and tracing libraries. You can interface with EventPipe directly through APIs like `EventSource.WriteEvent` or you can use libraries built on top, like [OpenTelemetry](../../diagnostics/observability-with-otel.md). EventPipe support also allows .NET diagnostic tools like [dotnet-trace](../../diagnostics/dotnet-trace.md), [dotnet-counters](../../diagnostics/dotnet-counters.md), and [dotnet-monitor](../../diagnostics/dotnet-monitor.md) to work seamlessly with Native AOT or CoreCLR applications. EventPipe is an optional component in Native AOT. To include EventPipe support, set the `EventSourceSupport` MSBuild property to `true`.
13
+
As of .NET 8, the Native AOT runtime supports [EventPipe](../../../diagnostics/eventpipe.md), which is the base layer used by many logging and tracing libraries. You can interface with EventPipe directly through APIs like `EventSource.WriteEvent` or you can use libraries built on top, like [OpenTelemetry](../../../diagnostics/observability-with-otel.md). EventPipe support also allows .NET diagnostic tools like [dotnet-trace](../../../diagnostics/dotnet-trace.md), [dotnet-counters](../../../diagnostics/dotnet-counters.md), and [dotnet-monitor](../../../diagnostics/dotnet-monitor.md) to work seamlessly with Native AOT or CoreCLR applications. EventPipe is an optional component in Native AOT. To include EventPipe support, set the `EventSourceSupport` MSBuild property to `true`.
28
14
29
15
```xml
30
16
<PropertyGroup>
31
17
<EventSourceSupport>true</EventSourceSupport>
32
18
</PropertyGroup>
33
19
```
34
20
35
-
Native AOT provides partial support for some [well-known event providers](../../diagnostics/well-known-event-providers.md). Not all [runtime events](../../../fundamentals/diagnostics/runtime-events.md) are supported in Native AOT.
21
+
Native AOT provides partial support for some [well-known event providers](../../../diagnostics/well-known-event-providers.md). Not all [runtime events](../../../../fundamentals/diagnostics/runtime-events.md) are supported in Native AOT.
36
22
37
23
## Development-time diagnostics
38
24
@@ -55,7 +41,7 @@ The Native AOT compiler generates information about line numbers, types, locals,
55
41
To debug managed exceptions, set a breakpoint on the `RhThrowEx` method, which is called whenever a managed exception is thrown. The exception is stored in the `rcx` or `x0` register. If your debugger supports viewing C++ objects, you can cast
56
42
the register to `S_P_CoreLib_System_Exception*` to see more information about the exception.
57
43
58
-
Collecting a [dump](../../diagnostics/dumps.md) file for a Native AOT application involves some manual steps in .NET 8.
44
+
Collecting a [dump](../../../diagnostics/dumps.md) file for a Native AOT application involves some manual steps in .NET 8.
59
45
60
46
### Visual Studio-specific notes
61
47
@@ -69,12 +55,12 @@ To see what exception was thrown, start debugging (**Debug > Start Debugging** o
69
55
70
56
When publishing, the Native AOT compiler produces both an executable and a symbol file. Native debugging, and related activities like profiling, require access to the native symbol file. If this file isn't present, you might have degraded or broken results.
71
57
72
-
For information about the name and location of the symbol file, see [Native debug information](index.md#native-aot-deployment).
58
+
For information about the name and location of the symbol file, see [Native debug information](../index.md#native-aot-deployment).
73
59
74
60
## CPU profiling
75
61
76
62
Platform-specific tools like [PerfView](https://github.com/microsoft/perfview) and [Perf](https://perf.wiki.kernel.org/index.php/Main_Page) can be used to collect CPU samples of a Native AOT application.
77
63
78
64
## Heap analysis
79
65
80
-
Managed heap analysis isn't currently supported in Native AOT. Heap analysis tools like [dotnet-gcdump](../../diagnostics/dotnet-gcdump.md), [PerfView](https://github.com/microsoft/perfview), and Visual Studio heap analysis tools don't work in Native AOT in .NET 8.
66
+
Managed heap analysis isn't currently supported in Native AOT. Heap analysis tools like [dotnet-gcdump](../../../diagnostics/dotnet-gcdump.md), [PerfView](https://github.com/microsoft/perfview), and Visual Studio heap analysis tools don't work in Native AOT in .NET 8.
description: Learn about diagnostics in Native AOT applications
4
+
author: lakshanf
5
+
ms.author: lakshanf
6
+
ms.date: 08/07/2023
7
+
---
8
+
9
+
# Diagnostics and instrumentation
10
+
11
+
Native AOT shares some, but not all, diagnostics and instrumentation capabilities with CoreCLR on desktop platforms and Mono on mobile platforms. Because of CoreCLR's and Mono's rich selection of diagnostic utilities, it's sometimes appropriate to diagnose and debug problems in CoreCLR or Mono, rather than with Native AOT. Apps that are [trim-compatible](../../trimming/prepare-libraries-for-trimming.md) shouldn't have behavioral differences, so investigations often apply between runtimes. Nonetheless, some information can only be gathered after publishing, so Native AOT also provides post-publish diagnostic tooling.
12
+
13
+
## Native AOT diagnostic support
14
+
15
+
The following table summarizes diagnostic features supported for Native AOT deployments and a more detailed description of diagnostics support on different platforms can be found on dedicated pages:
title: Diagnostics and instrumentation on iOS-like platforms
3
+
description: Learn about diagnostics in Native AOT applications on iOS-like platforms
4
+
author: ivanpovazan
5
+
ms.author: ivanpovazan
6
+
ms.date: 11/11/2024
7
+
---
8
+
9
+
# Native AOT diagnostic support on iOS-like platforms
10
+
11
+
## Observability and telemetry
12
+
13
+
Tracing of .NET applications on mobile platforms is enabled through [dotnet-dsrouter](../../../diagnostics/dotnet-dsrouter.md) which connects diagnostic tooling with .NET mobile applications running on iOS-like platforms over TCP/IP. However, Native AOT is currently not compatible with this scenario as it does not support EventPipe/DiagnosticServer components built with TCP/IP stack.
14
+
15
+
## Development-time diagnostics
16
+
17
+
The .NET CLI tooling (`dotnet` SDK) offers separate commands for `build` and `publish`. `dotnet build` (or `Start Debugging (F5)` in VS Code), uses Mono by default when building or launching .NET MAUI iOS (or MacCatalyst) applications. Only `dotnet publish` creates a Native AOT application, if this deployment model is enabled in the project file. Publishing your app as Native AOT, produces an app that has been ahead-of-time (AOT) compiled to native code. As described in this document, not all diagnostic tools will work seamlessly with published Native AOT applications.
18
+
However, all applications that are trim and AOT-compatible, i.e., that do not produce any trim and AOT warnings during build time, shouldn't have behavioral differences between Mono and Native AOT.
19
+
Therefore, all .NET development-time diagnostic tools (like Hot Reload) are still available for developers during mobile app development cycle.
20
+
We recommend developing, debugging, and testing the applications as usual and publishing the working app with Native AOT as one of the last steps.
21
+
22
+
## Native debugging
23
+
24
+
When you run your .NET MAUI iOS (or MacCatalyst) app during development, like inside VS Code, or with `dotnet build -t:Run`, it runs on Mono by default. However, if `PublishAot` is present in the project file, the behavior is expected to be the same between Mono and Native AOT when the application is not producing any trim and AOT warnings upon build. This characteristic allows you to use the standard VS Code managed debugging engine for development and testing, if your application fulfils the mentioned requirement.
25
+
26
+
After publishing, Native AOT applications are true native binaries. The managed debugger won't work on them. However, the Native AOT compiler generates fully native executable files that you can debug with `lldb`. Debugging a MacCatalyst app with `lldb` is straight-forward, as it is executed on the same system. However, debugging NativeAOT iOS applications requires a few extra steps which are covered in the following subsection.
27
+
28
+
### Debugging .NET MAUI iOS applications with NativeAOT
29
+
30
+
.NET MAUI applications which are compatible with NativeAOT and are properly configured and published with this deployment model (for more information see: [Publish using Native AOT](https://learn.microsoft.com/en-us/dotnet/maui/deployment/nativeaot?view=net-maui-9.0#publish-using-native-aot), can be debugged in the following ways.
31
+
32
+
#### iOS
33
+
34
+
1. Publish your app with Native AOT targeting `ios-arm64` and store the following information:
35
+
36
+
- Application name - referenced bellow as `<app-name>`
37
+
- Bundle identifier - referenced bellow as `<bundle-identifier>`
38
+
- Path to the published application's archive *.ipa* file - referenced bellow as `<path-to-ipa>`
39
+
40
+
2. Discover physical device ID - referenced bellow as: `<device-identifier>`
xcrun devicectl device process launch --device <device-identifier> --start-stopped <bundle-identifier>
56
+
```
57
+
58
+
5. Open `lldb` and connect to your physical device
59
+
60
+
```bash
61
+
(lldb) device select<device-identifier>
62
+
(lldb) device process attach -n <app-name>
63
+
```
64
+
65
+
After successfully completing previous steps, you are all set to start debugging your Native AOT .NET MAUI iOS application with `lldb`.
66
+
67
+
### Importance of the symbol file
68
+
69
+
By default, debug symbols are stripped from the application's binary file into *.dSYM* files. This file is used by debuggers and post mortem analysis tools to show information about local variables, source line numbers, to recreate stack traces of crash dumps etc. Therefore, it is essential to preserve it before submitting your application to App Store.
70
+
71
+
## CPU profiling
72
+
73
+
[Xcode Instruments](https://developer.apple.com/download/) can be used to collect CPU samples of a Native AOT application.
Copy file name to clipboardExpand all lines: docs/core/deploying/native-aot/index.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,9 +113,9 @@ By default, Native AOT publishing produces debug information in a separate file:
113
113
114
114
- Linux: *.dbg*
115
115
- Windows: *.pdb*
116
-
-macOS: *.dSYM* folder
116
+
-MacOS/MacCatalyst/iOS/tvOS: *.dSYM* folder
117
117
118
-
The debug file is necessary for running the app under the [debugger or inspecting crash dumps](./diagnostics.md#importance-of-the-symbol-file). On Unix-like platforms, set the `StripSymbols` property to `false` to include the debug information in the native binary. Including debug information makes the native binary larger.
118
+
The debug file is necessary for running the app under the debugger or inspecting crash dumps on both: [desktop](./diagnostics/desktop-platforms.md#importance-of-the-symbol-file) and [mobile](./diagnostics/ios-like-platforms.md#importance-of-the-symbol-file) platforms. On Unix-like platforms, set the `StripSymbols` property to `false` to include the debug information in the native binary. Including debug information makes the native binary larger.
119
119
120
120
```xml
121
121
<PropertyGroup>
@@ -136,7 +136,7 @@ Native AOT apps have the following limitations:
136
136
- Apps include required runtime libraries (just like [self-contained apps](../index.md#publish-self-contained), increasing their size as compared to framework-dependent apps).
137
137
-<xref:System.Linq.Expressions> always use their interpreted form, which is slower than run-time generated compiled code.
138
138
- Not all the runtime libraries are fully annotated to be Native AOT compatible. That is, some warnings in the runtime libraries aren't actionable by end developers.
139
-
-[Diagnostic support for debugging and profiling](./diagnostics.md) with some limitations.
139
+
-[Diagnostic support for debugging and profiling](./diagnostics/index.md) with some limitations.
140
140
- Support for some ASP.NET Core features. For more information, see [ASP.NET Core support for Native AOT](/aspnet/core/fundamentals/native-aot/).
141
141
142
142
The publish process analyzes the entire project and its dependencies for possible limitations. Warnings are issued for each limitation the published app might encounter at run time.
Copy file name to clipboardExpand all lines: docs/core/diagnostics/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ ms.topic: overview
9
9
10
10
Software doesn't always behave as you would expect, but .NET Core has tools and APIs that will help you diagnose these issues quickly and effectively.
11
11
12
-
[Native AOT deployment](../../core/deploying/native-aot/index.md) is an application model that's been available since .NET 7. For information about .NET 8 diagnostic support for Native AOT apps, see [Native AOT diagnostics](../../core/deploying/native-aot/diagnostics.md).
12
+
[Native AOT deployment](../../core/deploying/native-aot/index.md) is an application model that's been available since .NET 7. For information about .NET 8 diagnostic support for Native AOT apps, see [Native AOT diagnostics](../../core/deploying/native-aot/diagnostics/index.md).
13
13
14
14
This article helps you find the various tools you need.
0 commit comments