104 if (ImGui::BeginTable(
"##DisasmToolbar", 6, ImGuiTableFlags_None)) {
105 ImGui::TableNextColumn();
109 if (ImGui::IsItemHovered()) {
110 ImGui::SetTooltip(
"Clear all recorded instructions");
113 ImGui::TableNextColumn();
118 if (ImGui::IsItemHovered()) {
119 ImGui::SetTooltip(
"Export disassembly to file");
122 ImGui::TableNextColumn();
126 if (ImGui::IsItemHovered()) {
127 ImGui::SetTooltip(
"Auto-scroll to current PC");
130 ImGui::TableNextColumn();
134 if (ImGui::IsItemHovered()) {
135 ImGui::SetTooltip(
"Show execution counts");
138 ImGui::TableNextColumn();
142 if (ImGui::IsItemHovered()) {
143 ImGui::SetTooltip(
"Show hex dump of instruction bytes");
146 ImGui::TableNextColumn();
165 const std::vector<uint32_t>& breakpoints) {
167 ImGuiTableFlags flags =
168 ImGuiTableFlags_Borders |
169 ImGuiTableFlags_RowBg |
170 ImGuiTableFlags_ScrollY |
171 ImGuiTableFlags_Resizable |
172 ImGuiTableFlags_Sortable |
173 ImGuiTableFlags_Reorderable |
174 ImGuiTableFlags_Hideable;
177 int column_count = 4;
181 if (!ImGui::BeginTable(
"##DisasmTable", column_count, flags, ImVec2(0.0f, 0.0f))) {
186 ImGui::TableSetupColumn(
ICON_MD_CIRCLE, ImGuiTableColumnFlags_WidthFixed, 25.0f);
187 ImGui::TableSetupColumn(
"Address", ImGuiTableColumnFlags_WidthFixed, 80.0f);
189 ImGui::TableSetupColumn(
"Hex", ImGuiTableColumnFlags_WidthFixed, 100.0f);
191 ImGui::TableSetupColumn(
"Mnemonic", ImGuiTableColumnFlags_WidthFixed, 80.0f);
192 ImGui::TableSetupColumn(
"Operand", ImGuiTableColumnFlags_WidthStretch);
194 ImGui::TableSetupColumn(
ICON_MD_TRENDING_UP " Count", ImGuiTableColumnFlags_WidthFixed, 80.0f);
197 ImGui::TableSetupScrollFreeze(0, 1);
198 ImGui::TableHeadersRow();
201 ImGuiListClipper clipper;
203 clipper.Begin(sorted_addrs.size());
205 while (clipper.Step()) {
206 for (
int row = clipper.DisplayStart; row < clipper.DisplayEnd; row++) {
207 uint32_t addr = sorted_addrs[row];
215 ImGui::TableNextRow();
218 if (entry.is_current_pc) {
219 ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0,
220 ImGui::GetColorU32(ImVec4(0.3f, 0.0f, 0.0f, 0.5f)));
224 ImGui::TableNextColumn();
225 if (entry.is_breakpoint) {
228 ImGui::TextDisabled(
" ");
232 ImGui::TableNextColumn();
235 std::string addr_str = absl::StrFormat(
"$%02X:%04X",
236 (addr >> 16) & 0xFF, addr & 0xFFFF);
238 ImGuiSelectableFlags_SpanAllColumns)) {
243 if (ImGui::BeginPopupContextItem()) {
250 ImGui::TableNextColumn();
251 ImGui::TextColored(kColorOpcode,
"%s",
FormatHexDump(entry).c_str());
255 ImGui::TableNextColumn();
257 if (ImGui::Selectable(entry.mnemonic.c_str(),
false)) {
260 if (ImGui::IsItemHovered()) {
261 ImGui::SetTooltip(
"Click for instruction documentation");
265 ImGui::TableNextColumn();
266 ImGui::TextColored(kColorOperand,
"%s", entry.operand_str.c_str());
270 ImGui::TableNextColumn();
273 ImVec4 count_color = kColorComment;
274 if (entry.execution_count > 10000) {
275 count_color = kColorHotPath;
276 }
else if (entry.execution_count > 1000) {
277 count_color = ImVec4(0.8f, 0.8f, 0.3f, 1.0f);
280 ImGui::TextColored(count_color,
"%llu", entry.execution_count);
288 auto it = std::find(sorted_addrs.begin(), sorted_addrs.end(), current_pc);
289 if (it != sorted_addrs.end()) {
290 int row_index = std::distance(sorted_addrs.begin(), it);
291 ImGui::SetScrollY((row_index * ImGui::GetTextLineHeightWithSpacing()) -
292 (ImGui::GetWindowHeight() * 0.5f));
390 std::transform(filter_lower.begin(), filter_lower.end(),
391 filter_lower.begin(), ::tolower);
394 std::string addr_str = absl::StrFormat(
"%06x", entry.
address);
395 if (addr_str.find(filter_lower) != std::string::npos) {
400 std::string mnemonic_lower = entry.
mnemonic;
401 std::transform(mnemonic_lower.begin(), mnemonic_lower.end(),
402 mnemonic_lower.begin(), ::tolower);
403 if (mnemonic_lower.find(filter_lower) != std::string::npos) {
409 std::transform(operand_lower.begin(), operand_lower.end(),
410 operand_lower.begin(), ::tolower);
411 if (operand_lower.find(filter_lower) != std::string::npos) {
Represents a single disassembled instruction with metadata.