107 if (ImGui::BeginTable(
"##DisasmToolbar", 6, ImGuiTableFlags_None)) {
108 ImGui::TableNextColumn();
112 if (ImGui::IsItemHovered()) {
113 ImGui::SetTooltip(
"Clear all recorded instructions");
116 ImGui::TableNextColumn();
121 if (ImGui::IsItemHovered()) {
122 ImGui::SetTooltip(
"Export disassembly to file");
125 ImGui::TableNextColumn();
129 if (ImGui::IsItemHovered()) {
130 ImGui::SetTooltip(
"Auto-scroll to current PC");
133 ImGui::TableNextColumn();
137 if (ImGui::IsItemHovered()) {
138 ImGui::SetTooltip(
"Show execution counts");
141 ImGui::TableNextColumn();
145 if (ImGui::IsItemHovered()) {
146 ImGui::SetTooltip(
"Show hex dump of instruction bytes");
149 ImGui::TableNextColumn();
170 uint32_t current_pc,
const std::vector<uint32_t>& breakpoints) {
172 ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg |
173 ImGuiTableFlags_ScrollY | ImGuiTableFlags_Resizable |
174 ImGuiTableFlags_Sortable |
175 ImGuiTableFlags_Reorderable |
176 ImGuiTableFlags_Hideable;
179 int column_count = 4;
185 if (!ImGui::BeginTable(
"##DisasmTable", column_count, flags,
186 ImVec2(0.0f, 0.0f))) {
191 ImGui::TableSetupColumn(
ICON_MD_CIRCLE, ImGuiTableColumnFlags_WidthFixed,
193 ImGui::TableSetupColumn(
"Address", ImGuiTableColumnFlags_WidthFixed, 80.0f);
195 ImGui::TableSetupColumn(
"Hex", ImGuiTableColumnFlags_WidthFixed, 100.0f);
197 ImGui::TableSetupColumn(
"Mnemonic", ImGuiTableColumnFlags_WidthFixed, 80.0f);
198 ImGui::TableSetupColumn(
"Operand", ImGuiTableColumnFlags_WidthStretch);
201 ImGuiTableColumnFlags_WidthFixed, 80.0f);
204 ImGui::TableSetupScrollFreeze(0, 1);
205 ImGui::TableHeadersRow();
208 ImGuiListClipper clipper;
210 clipper.Begin(sorted_addrs.size());
212 while (clipper.Step()) {
213 for (
int row = clipper.DisplayStart; row < clipper.DisplayEnd; row++) {
214 uint32_t addr = sorted_addrs[row];
222 ImGui::TableNextRow();
225 if (entry.is_current_pc) {
226 ImGui::TableSetBgColor(
227 ImGuiTableBgTarget_RowBg0,
228 ImGui::GetColorU32(ImVec4(0.3f, 0.0f, 0.0f, 0.5f)));
232 ImGui::TableNextColumn();
233 if (entry.is_breakpoint) {
236 ImGui::TextDisabled(
" ");
240 ImGui::TableNextColumn();
243 std::string addr_str =
244 absl::StrFormat(
"$%02X:%04X", (addr >> 16) & 0xFF, addr & 0xFFFF);
246 ImGuiSelectableFlags_SpanAllColumns)) {
251 if (ImGui::BeginPopupContextItem()) {
258 ImGui::TableNextColumn();
259 ImGui::TextColored(kColorOpcode,
"%s",
FormatHexDump(entry).c_str());
263 ImGui::TableNextColumn();
265 if (ImGui::Selectable(entry.mnemonic.c_str(),
false)) {
268 if (ImGui::IsItemHovered()) {
269 ImGui::SetTooltip(
"Click for instruction documentation");
273 ImGui::TableNextColumn();
274 ImGui::TextColored(kColorOperand,
"%s", entry.operand_str.c_str());
278 ImGui::TableNextColumn();
281 ImVec4 count_color = kColorComment;
282 if (entry.execution_count > 10000) {
283 count_color = kColorHotPath;
284 }
else if (entry.execution_count > 1000) {
285 count_color = ImVec4(0.8f, 0.8f, 0.3f, 1.0f);
288 ImGui::TextColored(count_color,
"%llu", entry.execution_count);
296 auto it = std::find(sorted_addrs.begin(), sorted_addrs.end(), current_pc);
297 if (it != sorted_addrs.end()) {
298 int row_index = std::distance(sorted_addrs.begin(), it);
299 ImGui::SetScrollY((row_index * ImGui::GetTextLineHeightWithSpacing()) -
300 (ImGui::GetWindowHeight() * 0.5f));
400 std::transform(filter_lower.begin(), filter_lower.end(), filter_lower.begin(),
404 std::string addr_str = absl::StrFormat(
"%06x", entry.
address);
405 if (addr_str.find(filter_lower) != std::string::npos) {
410 std::string mnemonic_lower = entry.
mnemonic;
411 std::transform(mnemonic_lower.begin(), mnemonic_lower.end(),
412 mnemonic_lower.begin(), ::tolower);
413 if (mnemonic_lower.find(filter_lower) != std::string::npos) {
419 std::transform(operand_lower.begin(), operand_lower.end(),
420 operand_lower.begin(), ::tolower);
421 if (operand_lower.find(filter_lower) != std::string::npos) {
Represents a single disassembled instruction with metadata.