Skip to content

Commit

Permalink
Version 3.5.0-79.0.dev
Browse files Browse the repository at this point in the history
Merge b1b3e34 into dev
  • Loading branch information
Dart CI committed Apr 19, 2024
2 parents 3e139f5 + b1b3e34 commit 1c49f17
Show file tree
Hide file tree
Showing 32 changed files with 1,621 additions and 418 deletions.
2 changes: 2 additions & 0 deletions pkg/dart2wasm/bin/run_wasm.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ if (isD8) {
var zeroTimerQueue = [];

function addTimer(f, ms) {
ms = Math.max(0, ms);
var id = timerIdCounter++;
// A callback can be scheduled at most once.
console.assert(f.$timerId === undefined);
Expand Down Expand Up @@ -284,6 +285,7 @@ if (isD8) {
}

function addInterval(f, ms) {
ms = Math.max(0, ms);
var id = timerIdCounter++;
function repeat() {
// Reactivate with the same id.
Expand Down
5 changes: 5 additions & 0 deletions pkg/native_stack_traces/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.5.7

- Translates non-symbolic stack traces that include information for
deferred loading units.

## 0.5.6

- Added retrieval of the static symbol table contents for use in Dart tests.
Expand Down
60 changes: 59 additions & 1 deletion pkg/native_stack_traces/bin/decode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ final ArgParser _dumpParser = ArgParser(allowTrailingOptions: true)

final ArgParser _translateParser =
_createBaseDebugParser(ArgParser(allowTrailingOptions: true))
..addMultiOption('unit_debug',
abbr: 'u',
help: 'filename containing debugging information'
' for a deferred loading unit',
valueHelp: 'FILE')
..addMultiOption('unit_id_debug',
help: 'ID and filename containing debugging information'
' for a deferred loading unit',
valueHelp: 'N=FILE')
..addOption('input',
abbr: 'i', help: 'Filename for processed input', valueHelp: 'FILE')
..addOption('output',
Expand Down Expand Up @@ -90,6 +99,23 @@ generated by the VM when executing a snapshot compiled with the
non-symbolic stack traces converted to symbolic stack traces that contain
function names, file names, and line numbers.
If there are deferred loading units and their loading unit ids are known, then
the debugging information for the deferred loading units can be specified
using the --unit_id_debug command line option. E.g., if the debugging
information for loading unit 5 is in debug_5.so and the information for
loading unit 6 in debug_6.so, then the following command line arguments can
be used:
--unit_id_debug 5=debug_5.so --unit_id_debug 6=debug_6.so
or
--unit_id_debug 5=debug_5.so,6=debug_6.so
If the loading unit ids are not known, but the build IDs in the debugging
information match those of the deferred units, then the --unit_debug command
line option (which can be abbreviated as -u) can be used:
-u debug_5.so -u debug_6.so
or
-u debug_5.so,debug_6.so
Options shared by all commands:
${_argParser.usage}
Expand Down Expand Up @@ -285,6 +311,8 @@ void find(ArgResults options) {
}
}

final RegExp _unitDebugRE = RegExp(r'(\d+)=(.*)');

Future<void> translate(ArgResults options) async {
void usageError(String message) =>
errorWithUsage(message, command: 'translate');
Expand All @@ -302,11 +330,41 @@ Future<void> translate(ArgResults options) async {
final input = options['input'] != null
? io.File(path.canonicalize(path.normalize(options['input']))).openRead()
: io.stdin;
Map<int, Dwarf>? dwarfByUnitId;
if (options['unit_id_debug'] != null) {
dwarfByUnitId = <int, Dwarf>{};
for (final unitArg in options['unit_id_debug']!) {
final match = _unitDebugRE.firstMatch(unitArg);
if (match == null) {
usageError('Expected N=FILE where N is an integer, got $unitArg');
return;
}
final unitId = int.parse(match[1]!);
final filename = match[2]!;
final dwarf = _loadFromFile(filename, usageError);
if (dwarf == null) return;
dwarfByUnitId[unitId] = dwarf;
}
}
List<Dwarf>? unitDwarfs;
if (options['unit_debug'] != null) {
unitDwarfs = <Dwarf>[];
for (final filename in options['unit_debug']!) {
final dwarf = _loadFromFile(filename, usageError);
if (dwarf == null) return;
unitDwarfs.add(dwarf);
}
}

final convertedStream = input
.transform(utf8.decoder)
.transform(const LineSplitter())
.transform(DwarfStackTraceDecoder(dwarf, includeInternalFrames: verbose))
.transform(DwarfStackTraceDecoder(
dwarf,
includeInternalFrames: verbose,
dwarfByUnitId: dwarfByUnitId,
unitDwarfs: unitDwarfs,
))
.map((s) => '$s\n')
.transform(utf8.encoder);

Expand Down
3 changes: 3 additions & 0 deletions pkg/native_stack_traces/lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ const String isolateSymbolName = '_kDartIsolateSnapshotInstructions';

// The dynamic symbol name for the isolate data section.
const String isolateDataSymbolName = '_kDartIsolateSnapshotData';

// The ID for the root loading unit.
const int rootLoadingUnitId = 1;
Loading

0 comments on commit 1c49f17

Please sign in to comment.