pkg:native_stack_traces - Migrate to pkg:lints, fix new failures

Change-Id: I54aa779471c3cfb723be99238650bc786cf84643
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216690
Auto-Submit: Kevin Moore <kevmoo@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
This commit is contained in:
Kevin Moore 2021-10-14 07:35:43 +00:00 committed by commit-bot@chromium.org
parent ca00a4b27e
commit 0fb4f647cc
8 changed files with 39 additions and 37 deletions

View file

@ -1,4 +1,4 @@
# Changelog
## 0.4.5-dev
## 0.4.4

View file

@ -1 +1 @@
include: package:pedantic/analysis_options.1.9.0.yaml
include: package:lints/recommended.yaml

View file

@ -232,7 +232,7 @@ void find(ArgResults options) {
final locations = <PCOffset>[];
for (final String s in options['location'] + options.rest) {
final location = convertAddress(header, s);
if (location == null) return usageError('could not parse PC address ${s}');
if (location == null) return usageError('could not parse PC address $s');
locations.add(location);
}
if (locations.isEmpty) return usageError('no PC addresses to find');
@ -244,7 +244,7 @@ void find(ArgResults options) {
?.map((CallInfo c) => ' ' + c.toString());
final addrString =
addr > 0 ? '0x' + addr.toRadixString(16) : addr.toString();
print('For virtual address ${addrString}:');
print('For virtual address $addrString:');
if (frames == null) {
print(' Invalid virtual address.');
} else if (frames.isEmpty) {

View file

@ -9,7 +9,7 @@ import 'constants.dart' as constants;
import 'dwarf.dart';
String _stackTracePiece(CallInfo call, int depth) =>
'#${depth.toString().padRight(6)} ${call}';
'#${depth.toString().padRight(6)} $call';
// A pattern matching the last line of the non-symbolic stack trace header.
//

View file

@ -174,7 +174,7 @@ class _Attribute {
final intValue = value as int;
final unresolvedValue = paddedHex(intValue, 4);
final name = unit?.nameOfOrigin(intValue) ?? '<unresolved>';
return '0x${unresolvedValue} (origin: ${name})';
return '0x$unresolvedValue (origin: $name)';
}
}
}
@ -188,8 +188,8 @@ class _Abbreviation {
_Abbreviation._(this.code, this.tag, this.children, this.attributes);
// Constants from the DWARF specification.
static const _DW_CHILDREN_no = 0x00;
static const _DW_CHILDREN_yes = 0x01;
static const _dwChildrenNo = 0x00;
static const _dwChildrenYes = 0x01;
static _Abbreviation? fromReader(Reader reader) {
final code = reader.readLEB128EncodedInteger();
@ -200,11 +200,11 @@ class _Abbreviation {
}
final tag = _tags[tagInt]!;
final childrenByte = reader.readByte();
if (childrenByte != _DW_CHILDREN_no && childrenByte != _DW_CHILDREN_yes) {
if (childrenByte != _dwChildrenNo && childrenByte != _dwChildrenYes) {
throw FormatException('Expected DW_CHILDREN_no or DW_CHILDREN_yes: '
'${childrenByte}');
'$childrenByte');
}
final children = childrenByte == _DW_CHILDREN_yes;
final children = childrenByte == _dwChildrenYes;
final attributes = reader.readRepeated(_Attribute.fromReader).toList();
return _Abbreviation._(code, tag, children, attributes);
}
@ -258,7 +258,7 @@ class _AbbreviationsTable {
..write(key)
..writeln(':');
abbreviation.writeToStringBuffer(buffer);
buffer..writeln();
buffer.writeln();
});
}
@ -703,7 +703,7 @@ class FileInfo {
}
class LineNumberState {
final defaultIsStatement;
final bool defaultIsStatement;
late int address;
late int fileIndex;
@ -789,7 +789,7 @@ class LineNumberProgramHeader {
final isStmtByte = reader.readByte();
if (isStmtByte < 0 || isStmtByte > 1) {
throw FormatException(
'Unexpected value for default_is_stmt: ${isStmtByte}');
'Unexpected value for default_is_stmt: $isStmtByte');
}
final defaultIsStatement = isStmtByte == 1;
final lineBase = reader.readByte(signed: true);
@ -938,7 +938,7 @@ class LineNumberProgram {
'DW_LNE_define_file instruction not handled');
default:
throw FormatException(
'Extended opcode ${subOpcode} not in DWARF 2');
'Extended opcode $subOpcode not in DWARF 2');
}
break;
case 1: // DW_LNS_copy
@ -971,7 +971,7 @@ class LineNumberProgram {
state.address += reader.readBytes(2);
break;
default:
throw FormatException('Standard opcode ${opcode} not in DWARF 2');
throw FormatException('Standard opcode $opcode not in DWARF 2');
}
}
}
@ -1022,7 +1022,7 @@ class LineNumberProgram {
buffer.writeln('Results of line number program:');
for (final state in calculatedMatrix) {
buffer..writeln(state);
buffer.writeln(state);
}
}
@ -1178,7 +1178,7 @@ class StubCallInfo extends CallInfo {
}
@override
String toString() => '${name}+0x${offset.toRadixString(16)}';
String toString() => '$name+0x${offset.toRadixString(16)}';
}
/// The instructions section in which a program counter address is located.

View file

@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// ignore_for_file: constant_identifier_names
import 'dart:typed_data';
import 'reader.dart';
@ -119,7 +121,7 @@ class ElfHeader {
if (fileSize < calculatedHeaderSize) {
throw FormatException('ELF file too small for header: '
'file size ${fileSize} < '
'file size $fileSize < '
'calculated header size $calculatedHeaderSize');
}
@ -168,11 +170,11 @@ class ElfHeader {
if (reader.offset != headerSize) {
throw FormatException('Only read ${reader.offset} bytes, not the '
'full header size ${headerSize}');
'full header size $headerSize');
}
if (headerSize != calculatedHeaderSize) {
throw FormatException('Stored ELF header size ${headerSize} != '
throw FormatException('Stored ELF header size $headerSize != '
'calculated ELF header size $calculatedHeaderSize');
}
if (fileSize < programHeaderOffset) {
@ -220,10 +222,10 @@ class ElfHeader {
..write(' bits');
switch (endian) {
case Endian.little:
buffer..writeln(' and little-endian');
buffer.writeln(' and little-endian');
break;
case Endian.big:
buffer..writeln(' and big-endian');
buffer.writeln(' and big-endian');
break;
}
buffer
@ -756,23 +758,23 @@ class Symbol {
..write('" =>');
switch (bind) {
case SymbolBinding.STB_GLOBAL:
buffer..write(' a global');
buffer.write(' a global');
break;
case SymbolBinding.STB_LOCAL:
buffer..write(' a local');
buffer.write(' a local');
break;
}
switch (visibility) {
case SymbolVisibility.STV_DEFAULT:
break;
case SymbolVisibility.STV_HIDDEN:
buffer..write(' hidden');
buffer.write(' hidden');
break;
case SymbolVisibility.STV_INTERNAL:
buffer..write(' internal');
buffer.write(' internal');
break;
case SymbolVisibility.STV_PROTECTED:
buffer..write(' protected');
buffer.write(' protected');
break;
}
buffer
@ -857,7 +859,7 @@ class DynamicTable extends Section {
// We don't use DynamicTableTag for the key so that we can handle ELF files
// that may use unknown (to us) tags.
final Map<int, int> _entries;
final _wordSize;
final int _wordSize;
DynamicTable._(SectionHeaderEntry entry, this._entries, this._wordSize)
: super._(entry);
@ -1040,13 +1042,13 @@ class Elf {
sections[sectionHeaderStringTableEntry] as StringTable?;
if (sectionHeaderStringTable == null) {
throw FormatException(
'No section for entry ${sectionHeaderStringTableEntry}');
'No section for entry $sectionHeaderStringTableEntry');
}
final sectionsByName = <String, Set<Section>>{};
for (final entry in sectionHeader.entries) {
final section = sections[entry];
if (section == null) {
throw FormatException('No section found for entry ${entry}');
throw FormatException('No section found for entry $entry');
}
entry.setName(sectionHeaderStringTable);
sectionsByName.putIfAbsent(entry.name, () => {}).add(section);
@ -1068,7 +1070,7 @@ class Elf {
final stringTable = stringTableMap[entry];
if (stringTable == null) {
throw FormatException(
'String table not found at section header entry ${link}');
'String table not found at section header entry $link');
}
symbolTable._cacheNames(stringTable);
}

View file

@ -58,7 +58,7 @@ class Reader {
int readBytes(int size, {bool signed = false}) {
if (_offset + size > length) {
throw ArgumentError('attempt to read ${size} bytes with only '
throw ArgumentError('attempt to read $size bytes with only '
'${length - _offset} bytes remaining in the reader');
}
final start = _offset;
@ -196,7 +196,7 @@ class Reader {
..write(' (')
..write(length)
..writeln(')');
buffer..writeln('Bytes around current position:');
buffer.writeln('Bytes around current position:');
writeCurrentReaderPosition(buffer, maxSize: 256);
return buffer.toString();
}

View file

@ -1,11 +1,11 @@
name: native_stack_traces
description: Utilities for working with non-symbolic stack traces.
version: 0.4.4
version: 0.4.5-dev
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/native_stack_traces
environment:
sdk: '>=2.12.0-0 <3.0.0'
sdk: '>=2.12.0 <3.0.0'
executables:
decode:
@ -15,4 +15,4 @@ dependencies:
path: ^1.8.0
dev_dependencies:
pedantic: ^1.10.0
lints: ^1.0.0