All files / binary101/analyzers/dwarf lines.ts

100% Statements 39/39
71.42% Branches 5/7
100% Functions 1/1
100% Lines 39/39

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 401x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 84x 84x 84x 84x 84x 84x 84x 84x 84x 84x 84x 84x 84x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 84x 84x 75x 84x 84x  
import { DwarfStringReader } from "./strings.js";
"use strict";
 
import { executeDwarfLineProgram } from "./line-machine.js";
import { parseDwarfLineHeader } from "./line-header.js";
import type {
  DwarfLineProgram,
  DwarfSectionSource
} from "./types.js";
 
export const parseDwarfLines = async (
  source: DwarfSectionSource,
  sections: Map<string, DwarfSectionSource>,
  littleEndian: boolean,
  issues: string[], strings = new DwarfStringReader(sections, littleEndian ? "little" : "big", issues)
): Promise<DwarfLineProgram[]> => {
  const programs: DwarfLineProgram[] = [];
  let offset = 0;
  while (offset < source.section.size) {
    const header = await parseDwarfLineHeader(
      source, sections, offset, littleEndian, issues, strings
    );
    if (!header) break;
    const machine = await executeDwarfLineProgram(source, header, littleEndian, issues);
    programs.push({
      offset: header.offset,
      length: header.length,
      format: header.format,
      version: header.version,
      addressSize: machine.addressSize,
      directories: header.directories,
      files: machine.files,
      rows: machine.rows
    });
    if (header.end <= offset) break;
    offset = header.end;
  }
  return programs;
};