Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
telecomadm1145 committed Dec 15, 2024
1 parent e4de1fc commit 9de5789
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
48 changes: 31 additions & 17 deletions CasioEmuMsvc/Gui/CallAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ struct CallAnalysis : public UIWindow {
OnCallFunction(sender, ea.pc, ea.lr);
});
}
inline static std::string lookup_symbol(uint32_t addr) {
auto iter = std::lower_bound(g_labels.begin(), g_labels.end(), addr,
[](const Label& label, uint32_t addr) { return label.address < addr; });

if (iter == g_labels.end() || iter->address > addr) {
if (iter != g_labels.begin())
--iter;
else {
char buf[20];
return SDL_ltoa(addr, buf, 16);
}
}

if (addr == iter->address) {
return iter->name;
}
else {
char buf[20];
return iter->name + "+" + SDL_ltoa(addr - iter->address, buf, 16);
}
}
void OnCallFunction(casioemu::CPU& sender, uint32_t pc, uint32_t lr) {
if (is_call_recoding) {
if (check_caller)
Expand Down Expand Up @@ -66,15 +87,15 @@ struct CallAnalysis : public UIWindow {
funcs.clear();
}
ImGui::Separator();
if (ImGui::BeginTable("##records", 3, pretty_table)) {
if (ImGui::BeginTable("##records", 2, pretty_table)) {
ImGui::TableSetupColumn(
#if LANGUAGE == 2
"函数"
#else
"Function"
#endif
,
ImGuiTableColumnFlags_WidthFixed, 80);
ImGuiTableColumnFlags_WidthStretch, 80);
ImGui::TableSetupColumn(
#if LANGUAGE == 2
"调用计数"
Expand All @@ -83,12 +104,12 @@ struct CallAnalysis : public UIWindow {
#endif
,
ImGuiTableColumnFlags_WidthFixed, 80);
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch, 1);
//ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch, 1);
ImGui::TableHeadersRow();
for (auto& func : funcs) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%06x", func.first);
ImGui::Text("%s", lookup_symbol(func.first).c_str());
ImGui::TableNextColumn();
ImGui::Text("%d", (int)func.second.size());
ImGui::TableNextColumn();
Expand Down Expand Up @@ -235,15 +256,15 @@ struct CallAnalysis : public UIWindow {
// ImGui::SameLine();
// ImGui::Checkbox("ER2", &er2);
// ImGui::Separator();
if (ImGui::BeginTable("##records", 3, pretty_table)) {
if (ImGui::BeginTable("##records", 2, pretty_table)) {
ImGui::TableSetupColumn(
#if LANGUAGE == 2
"函数"
#else
"Function"
#endif
,
ImGuiTableColumnFlags_WidthFixed, 80);
ImGuiTableColumnFlags_WidthStretch, 80);
ImGui::TableSetupColumn(
#if LANGUAGE == 2
"调用计数"
Expand All @@ -252,26 +273,19 @@ struct CallAnalysis : public UIWindow {
#endif
,
ImGuiTableColumnFlags_WidthFixed, 80);
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch, 1);
ImGui::TableHeadersRow();
int i = 0;
for (auto& func : funcs) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%06x", func.first);

if (ImGui::Button(lookup_symbol(func.first).c_str())) {
viewing_calls = func.second;
}
ImGui::TableNextColumn();
ImGui::Text("%d", (int)func.second.size());
ImGui::TableNextColumn();
ImGui::PushID(i++);
if (ImGui::Button(
#if LANGUAGE == 2
"展示所有调用记录"
#else
"Show all records"
#endif
)) {
viewing_calls = func.second;
}
ImGui::PopID();
}
ImGui::EndTable();
Expand Down
1 change: 0 additions & 1 deletion CasioEmuMsvc/Gui/Ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ int test_gui(bool* guiCreated, SDL_Window* wnd, SDL_Renderer* rnd) {
new VariableWindow(),
new HwController(),
new LabelViewer(),
new CasioData(),
new WatchWindow(),
CreateCallAnalysisWindow(),
code_viewer = new CodeViewer(),
Expand Down
2 changes: 1 addition & 1 deletion CasioEmuMsvc/Gui/ui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ class UIWindow {

}
};
inline constexpr ImGuiTableFlags pretty_table = ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_Reorderable;
inline constexpr ImGuiTableFlags pretty_table = ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Resizable;

0 comments on commit 9de5789

Please sign in to comment.