Show the stack trace in the Debugger slide.

Right now it is non-interactible, but it's still useful for keeping
track of the flow of execution.

http://screen/4b6WMGdw6j32AGc

Change-Id: I978d9b441c15674c6cae508b123579021c2ecc46
Bug: skia:12666
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/484076
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:
John Stiles 2021-12-14 10:09:07 -05:00 committed by SkCQ
parent 80d2a50d4b
commit 708f28f4b1
2 changed files with 42 additions and 3 deletions

View File

@ -84,6 +84,7 @@ void SkSLDebuggerSlide::showDebuggerGUI() {
fRefresh = true;
}
this->showStackTraceTable();
this->showVariableTable();
this->showCodeTable();
}
@ -134,6 +135,42 @@ void SkSLDebuggerSlide::showCodeTable() {
}
}
void SkSLDebuggerSlide::showStackTraceTable() {
constexpr ImGuiTableFlags kTableFlags =
ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter |
ImGuiTableFlags_BordersV | ImGuiTableFlags_NoHostExtendX;
constexpr ImGuiTableColumnFlags kColumnFlags =
ImGuiTableColumnFlags_NoReorder | ImGuiTableColumnFlags_NoHide |
ImGuiTableColumnFlags_NoSort;
std::vector<int> callStack = fPlayer.getCallStack();
ImVec2 contentRect = ImGui::GetContentRegionAvail();
ImVec2 stackViewSize = ImVec2(contentRect.x / 3.0f,
ImGui::GetTextLineHeightWithSpacing() * kNumTopRows);
if (ImGui::BeginTable("Call Stack", /*column=*/1, kTableFlags, stackViewSize)) {
ImGui::TableSetupColumn("Stack", kColumnFlags);
ImGui::TableHeadersRow();
ImGuiListClipper clipper;
clipper.Begin(callStack.size());
while (clipper.Step()) {
for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; row++) {
int funcIdx = callStack.rbegin()[row];
SkASSERT(funcIdx >= 0 && (size_t)funcIdx < fTrace->fFuncInfo.size());
const SkSL::SkVMFunctionInfo& funcInfo = fTrace->fFuncInfo[funcIdx];
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::Text("%s", funcInfo.name.c_str());
}
}
ImGui::EndTable();
}
ImGui::SameLine();
}
void SkSLDebuggerSlide::showVariableTable() {
constexpr ImGuiTableFlags kTableFlags =
ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter |
@ -152,8 +189,7 @@ void SkSLDebuggerSlide::showVariableTable() {
if (vars.empty()) {
return;
}
constexpr int kVarNumRows = 12;
ImVec2 varViewSize = ImVec2(0.0f, ImGui::GetTextLineHeightWithSpacing() * kVarNumRows);
ImVec2 varViewSize = ImVec2(0.0f, ImGui::GetTextLineHeightWithSpacing() * kNumTopRows);
if (ImGui::BeginTable("Variables", /*column=*/2, kTableFlags, varViewSize)) {
ImGui::TableSetupColumn("Variable", kColumnFlags);
ImGui::TableSetupColumn("Value", kColumnFlags);

View File

@ -32,8 +32,11 @@ private:
void showRootGUI();
void showLoadTraceGUI();
void showDebuggerGUI();
void showCodeTable();
void showStackTraceTable();
void showVariableTable();
void showCodeTable();
static constexpr int kNumTopRows = 12;
sk_sp<SkSL::SkVMDebugTrace> fTrace;
SkSL::SkVMDebugTracePlayer fPlayer;