Function toFrame

Converts a stack trace line to a Frame structure

Frame toFrame (
  string line
);

Example

Get the main frame info from linux format

auto line = `generated.d:45 _Dmain [0x8e80c4]`;

auto frame = line.toFrame;

frame.invalid.should.equal(false);
frame.moduleName.should.equal("");
frame.file.should.equal("generated.d");
frame.line.should.equal(45);
frame.name.should.equal("_Dmain");
frame.address.should.equal("0x8e80c4");
frame.index.should.equal(-1);
frame.offset.should.equal("");

Example

Get a function frame info from linux format

auto line = `lifecycle/trial/runner.d:106 trial.interfaces.SuiteResult[] trial.runner.runTests(const(trial.interfaces.TestCase)[], immutable(char)[]) [0x8b0ec1]`;
auto frame = line.toFrame;

frame.invalid.should.equal(false);
frame.moduleName.should.equal("");
frame.file.should.equal("lifecycle/trial/runner.d");
frame.line.should.equal(106);
frame.name.should.equal("trial.interfaces.SuiteResult[] trial.runner.runTests(const(trial.interfaces.TestCase)[], immutable(char)[])");
frame.address.should.equal("0x8b0ec1");
frame.index.should.equal(-1);
frame.offset.should.equal("");

Example

Get an external function frame info from linux format

auto line = `../../.dub/packages/fluent-asserts-0.6.6/fluent-asserts/core/fluentasserts/core/base.d:39 void fluentasserts.core.base.Result.perform() [0x8f4b47]`;
auto frame = line.toFrame;

frame.invalid.should.equal(false);
frame.moduleName.should.equal("");
frame.file.should.equal("../../.dub/packages/fluent-asserts-0.6.6/fluent-asserts/core/fluentasserts/core/base.d");
frame.line.should.equal(39);
frame.name.should.equal("void fluentasserts.core.base.Result.perform()");
frame.address.should.equal("0x8f4b47");
frame.index.should.equal(-1);
frame.offset.should.equal("");

Example

Get an external function frame info from linux format

auto line = `lifecycle/trial/discovery/unit.d:268 _D5trial9discovery4unit17UnitTestDiscovery231__T12addTestCasesVAyaa62_2f686f6d652f626f737a2f776f726b73706163652f64746573742f6c6966656379636c652f747269616c2f6578656375746f722f706172616c6c656c2e64VAyaa23_747269616c2e6578656375746f722e706172616c6c656cS245trial8executor8parallelZ12addTestCasesMFZ9__lambda4FZv [0x872000]`;
auto frame = line.toFrame;

frame.invalid.should.equal(false);
frame.moduleName.should.equal("");
frame.file.should.equal("lifecycle/trial/discovery/unit.d");
frame.line.should.equal(268);
frame.name.should.equal("_D5trial9discovery4unit17UnitTestDiscovery231__T12addTestCasesVAyaa62_2f686f6d652f626f737a2f776f726b73706163652f64746573742f6c6966656379636c652f747269616c2f6578656375746f722f706172616c6c656c2e64VAyaa23_747269616c2e6578656375746f722e706172616c6c656cS245trial8executor8parallelZ12addTestCasesMFZ9__lambda4FZv");
frame.address.should.equal("0x872000");
frame.index.should.equal(-1);
frame.offset.should.equal("");

Example

Get an internal function frame info from linux format

auto line = `../../../../../fluent-asserts/source/fluentasserts/core/operations/arrayEqual.d:26 nothrow @safe fluentasserts.core.results.IResult[] fluentasserts.core.operations.arrayEqual.arrayEqual(ref fluentasserts.core.evaluation.Evaluation) [0x27a57ce]`;
auto frame = line.toFrame;

frame.invalid.should.equal(false);
frame.moduleName.should.equal("");
frame.file.should.equal("../../../../../fluent-asserts/source/fluentasserts/core/operations/arrayEqual.d");
frame.line.should.equal(26);
frame.name.should.equal("nothrow @safe fluentasserts.core.results.IResult[] fluentasserts.core.operations.arrayEqual.arrayEqual(ref fluentasserts.core.evaluation.Evaluation)");
frame.address.should.equal("0x27a57ce");
frame.index.should.equal(-1);
frame.offset.should.equal("");

Example

Get an missing info function frame info from linux format

auto line = `??:? __libc_start_main [0x174bbf44]`;
auto frame = line.toFrame;

frame.invalid.should.equal(false);
frame.moduleName.should.equal("");
frame.file.should.equal("");
frame.line.should.equal(-1);
frame.name.should.equal("__libc_start_main");
frame.address.should.equal("0x174bbf44");
frame.index.should.equal(-1);
frame.offset.should.equal("");