Fix debugger traces containing multiple vardecls on one line.
Internally, SkSL breaks apart multiple vardecls into individual vardecls wrapped inside an unscoped Block. Previously, the Debugger did not properly distinguish a scoped Block from an unscoped one, and the variables inside unscoped Block would be considered as "out-of-scope" as soon as the unscoped Block was closed. This would make them vanish from the Local Variables pane of the debugger at the end of the vardecl statement. (Note that this transformation also means that Step stops once for each individual variable, but that isn't a big deal.) Change-Id: I2ee2409e8556d77b58d7645658bd497f87c31e39 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/497278 Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
62bb436301
commit
418557a96a
@ -1820,13 +1820,17 @@ skvm::Val SkVMGenerator::writeConditionalStore(skvm::Val lhs, skvm::Val rhs, skv
|
||||
|
||||
void SkVMGenerator::writeBlock(const Block& b) {
|
||||
skvm::I32 mask = this->mask();
|
||||
this->emitTraceScope(mask, +1);
|
||||
if (b.isScope()) {
|
||||
this->emitTraceScope(mask, +1);
|
||||
}
|
||||
|
||||
for (const std::unique_ptr<Statement>& stmt : b.children()) {
|
||||
this->writeStatement(*stmt);
|
||||
}
|
||||
|
||||
this->emitTraceScope(mask, -1);
|
||||
if (b.isScope()) {
|
||||
this->emitTraceScope(mask, -1);
|
||||
}
|
||||
}
|
||||
|
||||
void SkVMGenerator::writeBreakStatement() {
|
||||
|
@ -251,7 +251,7 @@ DEF_TEST(SkSLTracePlayerVariables, r) {
|
||||
sk_sp<SkSL::SkVMDebugTrace> trace = make_trace(r,
|
||||
R"( // Line 1
|
||||
float func() { // Line 2
|
||||
float z = 456; // Line 3
|
||||
float x = 4, y = 5, z = 6; // Line 3
|
||||
return z; // Line 4
|
||||
} // Line 5
|
||||
int main() { // Line 6
|
||||
@ -266,7 +266,7 @@ int main() { // Line 6
|
||||
SkSL::SkVMDebugTracePlayer player;
|
||||
player.reset(trace);
|
||||
|
||||
REPORTER_ASSERT(r, player.getLineNumbersReached() == LineNumberMap({{3, 1}, {4, 1}, {7, 1},
|
||||
REPORTER_ASSERT(r, player.getLineNumbersReached() == LineNumberMap({{3, 3}, {4, 1}, {7, 1},
|
||||
{8, 1}, {9, 1}, {10, 1},
|
||||
{11, 1}, {12, 1}}));
|
||||
player.step();
|
||||
@ -291,15 +291,25 @@ int main() { // Line 6
|
||||
REPORTER_ASSERT(r, make_local_vars_string(*trace, player) == "");
|
||||
player.step();
|
||||
|
||||
REPORTER_ASSERT(r, player.getCurrentLine() == 3);
|
||||
REPORTER_ASSERT(r, make_stack_string(*trace, player) == "int main() -> float func()");
|
||||
REPORTER_ASSERT(r, make_local_vars_string(*trace, player) == "##x = 4");
|
||||
player.step();
|
||||
|
||||
REPORTER_ASSERT(r, player.getCurrentLine() == 3);
|
||||
REPORTER_ASSERT(r, make_stack_string(*trace, player) == "int main() -> float func()");
|
||||
REPORTER_ASSERT(r, make_local_vars_string(*trace, player) == "##y = 5, x = 4");
|
||||
player.step();
|
||||
|
||||
REPORTER_ASSERT(r, player.getCurrentLine() == 4);
|
||||
REPORTER_ASSERT(r, make_stack_string(*trace, player) == "int main() -> float func()");
|
||||
REPORTER_ASSERT(r, make_local_vars_string(*trace, player) == "##z = 456");
|
||||
REPORTER_ASSERT(r, make_local_vars_string(*trace, player) == "##z = 6, y = 5, x = 4");
|
||||
player.step();
|
||||
|
||||
REPORTER_ASSERT(r, player.getCurrentLine() == 9);
|
||||
REPORTER_ASSERT(r, make_stack_string(*trace, player) == "int main()");
|
||||
REPORTER_ASSERT(r, make_local_vars_string(*trace, player) ==
|
||||
"##[func].result = 456, b = true, a = 123");
|
||||
"##[func].result = 6, b = true, a = 123");
|
||||
player.step();
|
||||
|
||||
REPORTER_ASSERT(r, player.getCurrentLine() == 10);
|
||||
|
Loading…
Reference in New Issue
Block a user