diff --git a/pkg/dart2wasm/lib/code_generator.dart b/pkg/dart2wasm/lib/code_generator.dart index aa79933825d8..c99a52c13243 100644 --- a/pkg/dart2wasm/lib/code_generator.dart +++ b/pkg/dart2wasm/lib/code_generator.dart @@ -187,7 +187,8 @@ abstract class AstCodeGenerator final location = source.getLocation(fileUri, fileOffset); final old = _sourceMapFileOffset; _sourceMapFileOffset = fileOffset; - b.startSourceMapping(fileUri, location.line - 1, location.column - 1, null); + b.startSourceMapping(fileUri, location.line - 1, location.column - 1, + enclosingMember.name.text); return old; } diff --git a/tests/web/wasm/source_map_simple_lib.dart b/tests/web/wasm/source_map_simple_lib.dart index 212883d405e6..53a34935de1a 100644 --- a/tests/web/wasm/source_map_simple_lib.dart +++ b/tests/web/wasm/source_map_simple_lib.dart @@ -18,12 +18,13 @@ void g() { runtimeFalse() => int.parse('1') == 0; -// `expectedFrames` is (String, line, column) of the frames we check. +// `expectedFrames` is (file, line, column, name) of the frames we check. // // Information we don't check are "null": we don't want to check line/column // of standard library functions to avoid breaking the test with unrelated // changes to the standard library. -void testMain(String testName, List<(String?, int?, int?)?> expectedFrames) { +void testMain( + String testName, List<(String?, int?, int?, String?)?> expectedFrames) { // Use `f` and `g` in a few places to make sure wasm-opt won't inline them // in the test. final fTearOff = f; @@ -69,7 +70,8 @@ void testMain(String testName, List<(String?, int?, int?)?> expectedFrames) { } if ((expected.$1 != null && actual.$1 != expected.$1) || (expected.$2 != null && actual.$2 != expected.$2) || - (expected.$3 != null && actual.$3 != expected.$3)) { + (expected.$3 != null && actual.$3 != expected.$3) || + (expected.$4 != null && actual.$4 != expected.$4)) { throw 'Mismatch:\n Expected: $expected\n Actual: $actual'; } } @@ -112,9 +114,9 @@ Mapping getSourceMapping(String testName) { return allMappings; } -List<(String?, int?, int?)?> parseStack( +List<(String?, int?, int?, String?)?> parseStack( String testName, Mapping mapping, String stackTraceString) { - final parsed = <(String?, int?, int?)?>[]; + final parsed = <(String?, int?, int?, String?)?>[]; for (final line in stackTraceString.split('\n')) { if (line.contains('.mjs') || line.contains('.js')) { parsed.add(null); @@ -145,7 +147,8 @@ List<(String?, int?, int?)?> parseStack( final filename = span.sourceUrl!.pathSegments.last; final lineNumber = span.start.line; final columnNumber = span.start.column; - parsed.add((filename, 1 + lineNumber, 1 + columnNumber)); + final symbolName = span.text; + parsed.add((filename, 1 + lineNumber, 1 + columnNumber, symbolName)); } return parsed; } diff --git a/tests/web/wasm/source_map_simple_optimized_test.dart b/tests/web/wasm/source_map_simple_optimized_test.dart index 2c068ce5a841..bda94e3b6512 100644 --- a/tests/web/wasm/source_map_simple_optimized_test.dart +++ b/tests/web/wasm/source_map_simple_optimized_test.dart @@ -10,11 +10,11 @@ void main() { Lib.testMain('source_map_simple_optimized', frameDetails); } -const List<(String?, int?, int?)?> frameDetails = [ - ('errors_patch.dart', null, null), // _throwWithCurrentStackTrace - ('source_map_simple_lib.dart', 16, 3), // g - ('source_map_simple_lib.dart', 12, 3), // f - ('source_map_simple_lib.dart', 38, 5), // testMain, inlined in main +const List<(String?, int?, int?, String?)?> frameDetails = [ + ('errors_patch.dart', null, null, '_throwWithCurrentStackTrace'), + ('source_map_simple_lib.dart', 16, 3, 'g'), + ('source_map_simple_lib.dart', 12, 3, 'f'), + ('source_map_simple_lib.dart', 39, 5, 'testMain'), ]; /* diff --git a/tests/web/wasm/source_map_simple_test.dart b/tests/web/wasm/source_map_simple_test.dart index b4833d52028e..c83b4b63dc10 100644 --- a/tests/web/wasm/source_map_simple_test.dart +++ b/tests/web/wasm/source_map_simple_test.dart @@ -10,12 +10,12 @@ void main() { Lib.testMain('source_map_simple', frameDetails); } -const List<(String?, int?, int?)?> frameDetails = [ - ('errors_patch.dart', null, null), // _throwWithCurrentStackTrace - ('source_map_simple_lib.dart', 16, 3), // g - ('source_map_simple_lib.dart', 12, 3), // f - ('source_map_simple_lib.dart', 38, 5), // testMain - ('source_map_simple_test.dart', 10, 7), // main +const List<(String?, int?, int?, String?)?> frameDetails = [ + ('errors_patch.dart', null, null, '_throwWithCurrentStackTrace'), + ('source_map_simple_lib.dart', 16, 3, 'g'), + ('source_map_simple_lib.dart', 12, 3, 'f'), + ('source_map_simple_lib.dart', 39, 5, 'testMain'), + ('source_map_simple_test.dart', 10, 7, 'main'), null, // main tear-off, compiler generated, not mapped // The rest of the stack is dependent on the compiler mode. ];