---
title: "IL2CPP Line Numbers"
description: "Learn how the SDK provides line numbers to issues from IL2CPP builds."
url: https://docs.sentry.io/platforms/unity/configuration/il2cpp/
---

# IL2CPP Line Numbers for Unity

Sentry can provide line numbers for thrown C# exceptions in IL2CPP builds on Unity 2021.3 or later. This works for release builds by default. For development builds, enable **Upload Dev Symbols** in the [debug symbol upload settings](https://docs.sentry.io/platforms/unity/configuration/options/cli-options.md).

Unity provides you the option to select [IL2CPP](https://docs.unity3d.com/Manual/IL2CPP.html) as your scripting backend. This leads to C++ code being generated from your compiled C# (IL) code, hence the name `IL to CPP`.

The Sentry SDK provides line number support for IL2CPP builds for the following platforms:

* Windows
* macOS
* Linux
* Android
* iOS
* Xbox
* PlayStation 5

WebGL and Nintendo Switch don't support line numbers for IL2CPP builds.

When you build with IL2CPP, errors in your game will happen in the native code. Also, the mapping between your C# code and the generated C++ code is part of the build process and isn't shipped with your game. That means the event the Sentry SDK reports can only contain the native stack trace. To provide you with C# line numbers, the Sentry server needs to have access to that line mapping through [Debug Information Files](https://docs.sentry.io/platforms/unity/data-management/debug-files.md).

The support for line numbers in C# Exceptions with IL2CPP relies on the debug symbol upload. With the automated debug symbol upload enabled, the [Sentry SDK uploads the line mapping automatically](https://docs.sentry.io/platforms/unity/native-support.md#debug-symbols).

To create the line mapping, the SDK adds `--emit-source-mapping` to **Player Settings > Additional IL2CPP Arguments** before each IL2CPP build. On Unity 6.5 and later, it also adds `--link-symbols` to the UnityLinker arguments. If you turn the feature off, the SDK removes these arguments on the next build.

This feature adds C# source lines to the stack trace of a thrown exception. To do this, the SDK reads native stack frames from the exception and Sentry uses the uploaded line mapping to find the matching C# source.

It doesn't add source lines to `SentrySdk.CaptureMessage` or `Debug.LogError`. Those are message events, not exceptions. `Debug.LogError` can still include source lines that Unity provides in its own stack trace when `AttachStacktrace` is enabled. `Debug.LogException(new Exception("message"))` also cannot be mapped because the newly constructed exception has no stack frames. See [known limitations](https://docs.sentry.io/platforms/unity/troubleshooting/known-limitations.md#stack-traces) for details.

**This feature is enabled by default**. You can opt out of it through the editor configuration window by selecting **Tools -> Sentry -> Advanced -> IL2CPP line numbers** or [programmatically](https://docs.sentry.io/platforms/unity/configuration/options.md#programmatic-configuration).

```csharp
// If you need to disable this feature, you can set it to 'false':
options.Il2CppLineNumberSupportEnabled = false;
```

### [Known Limitations](https://docs.sentry.io/platforms/unity/configuration/il2cpp.md#known-limitations)

Currently, line number support is limited when programmatically subscribing to button click events via `Button.onClick.AddListener`. However, you can set up callbacks through the editor to work around this.
