Struct Frame

Represents a stack frame

struct Frame ;

Fields

NameTypeDescription
address string
file string
index int
invalid bool
line int
moduleName string
name string
offset string
raw string

Example

The frame should convert a frame to string

Frame(10, "some.module", "0xffffff", "name", "offset", "file.d", 120).toString.should.equal(
  `10  0xffffff name at some.module + offset (file.d:120)`
);

Example

The frame should not output an index < 0 or a line < 0

Frame(-1, "some.module", "0xffffff", "name", "offset", "file.d", -1).toString.should.equal(
  `0xffffff name at some.module + offset (file.d)`
);

Example

The frame should not output the file if it is missing from the stack

Frame(-1, "some.module", "0xffffff", "name", "offset", "", 10).toString.should.equal(
  `0xffffff name at some.module + offset`
);

Example

The frame should not output the module if it is missing from the stack

Frame(-1, "", "0xffffff", "name", "offset", "", 10).toString.should.equal(
  `0xffffff name + offset`
);

Example

The frame should not output the offset if it is missing from the stack

Frame(-1, "", "0xffffff", "name", "", "", 10).toString.should.equal(
  `0xffffff name`
);

Example

The frame should display ???? when the name is missing

Frame(-1, "", "0xffffff", "", "", "", 10).toString.should.equal(
  `0xffffff ????`
);

Example

The frame should print all fields

auto printer = new MockPrinter;
Frame(10, "some.module", "0xffffff", "name", "offset", "file.d", 120).print(printer);

printer.buffer.should.equal(
  `[info:10  ]0xffffff [info:name] at [info:some.module] + [info:offset] ([info:file.d]:[info:120])`
);

Example

The frame should not print an index < 0 or a line < 0

auto printer = new MockPrinter;
Frame(-1, "some.module", "0xffffff", "name", "offset", "file.d", -1).print(printer);

printer.buffer.should.equal(
  `0xffffff [info:name] at [info:some.module] + [info:offset] ([info:file.d])`
);

Example

The frame should not print the file if it's missing

auto printer = new MockPrinter;
Frame(-1, "some.module", "0xffffff", "name", "offset", "", 10).print(printer);

printer.buffer.should.equal(
  `0xffffff [info:name] at [info:some.module] + [info:offset]`
);

Example

The frame should not print the module if it's missing

auto printer = new MockPrinter;
Frame(-1, "", "0xffffff", "name", "offset", "", 10).print(printer);

printer.buffer.should.equal(
  `0xffffff [info:name] + [info:offset]`
);

Example

The frame should not print the offset if it's missing

auto printer = new MockPrinter;
Frame(-1, "", "0xffffff", "name", "", "", 10).print(printer);

printer.buffer.should.equal(
  `0xffffff [info:name]`
);

Example

The frame should print ???? when the name is missing

auto printer = new MockPrinter;
Frame(-1, "", "0xffffff", "", "", "", 10).print(printer);

printer.buffer.should.equal(
  `0xffffff [info:????]`
);