dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.3k stars 1.59k forks source link

DDC source maps product excellence #30939

Open matanlurey opened 7 years ago

matanlurey commented 7 years ago

Thanks to hard work by many, the DDC stack traces in the latest SDK look good 🤞

There are still some minor things, though, for example around closures:

test('...', () {
  expect(...);
});

Emits:

package:test            expect
foo_test.dart 216:9  test$.test.dart.fn

I never wrote test$.test.dart.fn. It would be nice for this to say:

package:test           expect
foo_test.dart 216:9 test
vsmenon commented 7 years ago

Technical, it's not test, but an anonymous closure in test. I think we end up naming these dart.fn.

Should be easy to name / stack-map to something else.

matanlurey commented 7 years ago

@vsmenon Is this still an issue?

jmesserly commented 6 years ago

anonymous functions are still auto-detected by Chrome as dart.fn It's because we must tag their types:

// compiled JS:
test.test(..., dart.fn(() => { ... }));

We can't avoid tagging the type.

We could have a longer name for dart.fn like dart.anonymous. We could give the function a name like anonymous. We could see that the anonymous function is an argument to the Dart function named test, and use that name ... we won't have names like that in general, but we could find them in this example. I don't know if that's actually more helpful, though?

All of these will increase code size.

In our new debugger prototype, we can detect and render anonymous Dart functions differently in the web inspector. So that's an idea.

I'm not sure what (if anything) to do here.

jmesserly commented 6 years ago

@alan-knight this may be fixable now in the new Debugger UI?

alan-knight commented 6 years ago

We wouldn't be able to do anything about printed stack traces there, but we could tweak the stack frame display in the debugger. It's not obvious to me why the function is getting the dynamically containing function name prepended to it. I'd expect to see something with the statically containing scope. But I think it's basically happening here https://cs.chromium.org/chromium/src/third_party/blink/renderer/devtools/front_end/sources/CallStackSidebarPane.js?rcl=3df5254f608bfec7ee6407faed8c7232b935f318&l=256

but it might be some work to get the information we'd need to name it appropriately. We can get the containing file and line number, but more than that I don't know.