dart-lang / stack_trace

A package for manipulating stack traces and printing them readably.
https://pub.dev/packages/stack_trace
BSD 3-Clause "New" or "Revised" License
129 stars 22 forks source link

Trace.format is removing some information #71

Closed ahmaducg closed 2 months ago

ahmaducg commented 4 years ago

When using Trace.format, some of the Stack Trace isn't being formatted right.

In the example below, "# 8" doesn't get formatted right, removing the line number and file name.

Stack :

#0      Crashlytics.crash (package:alyamin/utils/crashlytics/firebase_crashlytics.dart:53:5)
#1      HomePage.buildLayout.<anonymous closure> (package:alyamin/ui/home/HomePage.dart:81:44)
#2      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
#3      DoubleTapGestureRecognizer._checkUp (package:flutter/src/gestures/multitap.dart:307:7)
#4      DoubleTapGestureRecognizer._registerSecondTap (package:flutter/src/gestures/multitap.dart:280:5)
#5      DoubleTapGestureRecognizer._handleEvent (package:flutter/src/gestures/multitap.dart:208:9)
#6      PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
#7      PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9)
#8      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
#9      PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
#10     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
#11     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
#12     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
#13     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
#14     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
#15     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
#16     _rootRunUnary (dart:async/zone.dart:1206:13)
#17     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#18     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
#19     _invoke1 (dart:ui/hooks.dart:281:10)
#20     _dispatchPointerDataPacket (dart:ui/hooks.dart:190:5)

After Trace.format(stack) :

package:alyamin/utils/crashlytics/firebase_crashlytics.dart 53:5  Crashlytics.crash
package:alyamin/ui/home/HomePage.dart 81:44                       HomePage.buildLayout.<fn>
package:flutter/src/gestures/recognizer.dart 182:24               GestureRecognizer.invokeCallback
package:flutter/src/gestures/multitap.dart 307:7               DoubleTapGestureRecognizer._checkUp
package:flutter/src/gestures/multitap.dart 280:5                  DoubleTapGestureRecognizer._registerSecondTap
package:flutter/src/gestures/multitap.dart 208:9                  DoubleTapGestureRecognizer._handleEvent
package:flutter/src/gestures/pointer_router.dart 76:12            PointerRouter._dispatch
package:flutter/src/gestures/pointer_router.dart 122:9            PointerRouter._dispatchEventToRoutes.<fn>
dart:collection                                                   _LinkedHashMapMixin.forEach
package:flutter/src/gestures/pointer_router.dart 120:18           PointerRouter._dispatchEventToRoutes
package:flutter/src/gestures/pointer_router.dart 106:7            PointerRouter.route
package:flutter/src/gestures/binding.dart 218:19                  GestureBinding.handleEvent
package:flutter/src/gestures/binding.dart 198:22                  GestureBinding.dispatchEvent
package:flutter/src/gestures/binding.dart 156:7                   GestureBinding._handlePointerEvent
package:flutter/src/gestures/binding.dart 102:7                   GestureBinding._flushPointerEventQueue
package:flutter/src/gestures/binding.dart 86:7                    GestureBinding._handlePointerDataPacket
[✓] Flutter (Channel master, 1.19.0-2.0.pre.131, on Mac OS X 10.15.4 19E287, locale en-SY)
    • Flutter version 1.19.0-2.0.pre.131 at /Users/ucgmacmini/Library/flutter
    • Framework revision 478d4c9c1a (6 hours ago), 2020-05-19 20:22:01 -0700
    • Engine revision 2d4e83921d
    • Dart version 2.9.0 (build 2.9.0-9.0.dev 40f7a11d89)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/ucgmacmini/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C505
    • CocoaPods version 1.9.1

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.8052
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[!] IntelliJ IDEA Community Edition (version 2020.1.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[!] VS Code (version 1.45.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (1 available)
    • iPhone 11 Pro Max • 56BDDC91-4D51-4DCC-9F6D-0E92E3C77794 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)

! Doctor found issues in 2 categories.

patkujawa-wf commented 3 years ago

If you're using terse, I believe that is the expected behavior, because that's from the dart: namespace:

8 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)

If you're not using terse, it might still be expected, I'm not sure.

osa1 commented 2 months ago

This only happens in terse mode and it seems to be by design, because we have tests for it. Example: https://github.com/dart-lang/stack_trace/blob/5b829650d47c66a3b6786256fd955403cd56a169/test/trace_test.dart#L553-L572

This checks that the line/column number of future.dart is dropped.

There are other tests as well.

If you don't want to lose any information you should use the non-terse format (the default).