sentry-dart icon indicating copy to clipboard operation
sentry-dart copied to clipboard

Support symbolication for pure Dart apps

Open marandaneto opened this issue 2 years ago • 10 comments
trafficstars

Description

dart compile aot-snapshot bin/example.dart --save-debugging-info=symbols

❯ sentry-cli debug-files check symbols Debug Info File Check Type: elf debug companion Contained debug identifiers: > Debug ID: fb476760-7669-109c-74f1-2bb8baa6e321 Code ID: 606747fb69769c1074f12bb8baa6e321 Arch: arm64 Contained debug information: > symtab, debug Usable: yes

Right now symbolication only works for Android, iOS/macOS, and Flutter web. To make that work, we'd need to be able to collect the list of loaded images for pure Dart apps as well, on Android and iOS/macOS, we get the list directly from the Native SDKs https://github.com/getsentry/sentry-dart/blob/main/flutter/lib/src/integrations/load_image_list_integration.dart

For pure Dart apps running on macOS, Windows, and Linux, we probably have to integrate https://github.com/getsentry/sentry-native first or do it via ffi. Relates to https://github.com/getsentry/sentry-dart/issues/433

marandaneto avatar Jun 06 '23 11:06 marandaneto

I don't know if the Dart stdlib provides an API to read the image address of all the loaded libraries in memory.

currentMirrorSystem().libraries via dart:mirrors give you the libraries, but I've not found a way to get the addresses, ideas @vaind or @ueman ?

marandaneto avatar Jul 27 '23 09:07 marandaneto

dart:mirrors isn't supported on Flutter, since it's basically reflection, which Flutter doesn't support. Unfortunately, I'm not aware of anything else.

ueman avatar Jul 27 '23 09:07 ueman

@ueman this is about pure Dart apps, Flutter is already using The Native SDKs to read all the loaded libraries in memory. Obviously, it'd be nice if the Dart stdlib would have such ability in all the platforms, so we could replace those integrations as well.

marandaneto avatar Jul 27 '23 09:07 marandaneto

dart:mirrors isn't supported for AOT anyway, as far as I know.

I think you can either integrate our native SDK and let it load the libs, or do the same as our native SDK does, but through dart FFI.

I'm unaware of any way to list all libraries loaded by dart. I'm sure @mraleph would know if there's any way to do so.

vaind avatar Jul 27 '23 09:07 vaind

regarding dart:mirrors and libraries. You should not confuse dynamic libraries (as in: object files loaded by runtime linker like ld or dyld) and Dart libraries (which is just a unit of organization of Dart source).

FWIW a stack trace in DWARF mode should contain enough information (e.g. build-id and various base addresses) so it should not be necessary to iterate loaded dynamic libraries. I think isolate_dso_base and vm_dso_base are what you are looking for. In most cases they are just going to be the same value pointing to the base load address of the AOT snapshot.

mraleph avatar Jul 27 '23 21:07 mraleph

@mraleph indeed, I meant the dynamic libraries as in images.

I'll take a look if we can symbolicate without this internally, and try to use isolate_dso_base and/or vm_dso_base instead.

What I was looking for is the instruction_addr, not sure if its possible without it (maybe isolate_dso_base and/or vm_dso_base will help here).

Thank you.

marandaneto avatar Aug 07 '23 07:08 marandaneto

We can create a synthetic https://develop.sentry.dev/sdk/event-payloads/debugmeta#attributes with the addresses gotten from the stack trace, we will test it out.

marandaneto avatar Aug 17 '23 13:08 marandaneto