Skip to content

console.log inside if/else branches is skipped by debugger session #85

@michaelsutton

Description

@michaelsutton

console.log(...) generally works in the debugger, including:

  • updated locals
  • struct/object values
  • values mutated inside a branch and logged afterward

What does not work is a console.log(...) located inside the branch body itself.

Minimal shape:

int sum = a + b;
console.log("start", sum);
if (sum > 5) {
    sum = sum + 10;
    console.log("then", sum);
} else {
    sum = sum - 1;
    console.log("else", sum);
}
console.log("after", sum);

Expected:

  • with (2, 5): start 7, then 17, after 17
  • with (2, 3): start 5, else 4, after 4

Actual debugger output:

  • with (2, 5): start 7, after 17
  • with (2, 3): start 5, after 4

So branch-local console logs are skipped, but branch-updated values are still propagated correctly.

Basic debugger-session steps used in the regression tests:

  1. compile contract with record_debug_infos: true
  2. create session with DebugSession::full(...)
  3. execute with stepping / opcode stepping
  4. collect emitted console output with take_console_output()

Relevant local tests on my branch:

  • passing: debug_session_console_logs_reflect_updated_variable_values
  • passing: debug_session_console_logs_reflect_branch_updated_values_after_if_else
  • failing/ignored: debug_session_console_logs_reflect_updated_values_inside_if_else

Repo / branch:
https://github.com/michaelsutton/silverscript/tree/console-log-regression

Direct link to the ignored failing regression:
https://github.com/michaelsutton/silverscript/blob/console-log-regression/debugger/session/tests/debug_session_tests.rs#L210

This looks like a debugger step/console emission issue for branch-local zero-width console steps, not a value propagation problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions