yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::emu::debug::DisassemblyViewer Class Reference

Advanced disassembly viewer with sparse storage and interactive features. More...

#include <disassembly_viewer.h>

Public Member Functions

 DisassemblyViewer ()=default
 
 ~DisassemblyViewer ()=default
 
void RecordInstruction (uint32_t address, uint8_t opcode, const std::vector< uint8_t > &operands, const std::string &mnemonic, const std::string &operand_str)
 Record an instruction execution.
 
void Render (uint32_t current_pc, const std::vector< uint32_t > &breakpoints)
 Render the disassembly viewer UI.
 
void Clear ()
 Clear all recorded instructions.
 
size_t GetInstructionCount () const
 Get the number of unique instructions recorded.
 
bool ExportToFile (const std::string &filepath) const
 Export disassembly to file.
 
void JumpToAddress (uint32_t address)
 Jump to a specific address in the viewer.
 
void SetAutoScroll (bool enabled)
 Set whether to auto-scroll to current PC.
 
std::vector< uint32_t > GetSortedAddresses () const
 Get sorted list of addresses for rendering.
 
bool IsAvailable () const
 Check if the disassembly viewer is available.
 
void SetRecording (bool enabled)
 Enable/disable recording (for performance)
 
bool IsRecording () const
 
void SetMaxInstructions (size_t max)
 Set maximum number of instructions to keep.
 
void TrimToSize (size_t target_size)
 Clear old instructions to save memory.
 

Private Member Functions

void RenderToolbar ()
 
void RenderDisassemblyTable (uint32_t current_pc, const std::vector< uint32_t > &breakpoints)
 
void RenderContextMenu (uint32_t address)
 
void RenderSearchBar ()
 
ImVec4 GetAddressColor (const DisassemblyEntry &entry, uint32_t current_pc) const
 
ImVec4 GetMnemonicColor (const DisassemblyEntry &entry) const
 
std::string FormatHexDump (const DisassemblyEntry &entry) const
 
bool PassesFilter (const DisassemblyEntry &entry) const
 

Private Attributes

std::map< uint32_t, DisassemblyEntryinstructions_
 
bool recording_enabled_ = true
 
size_t max_instructions_ = 10000
 
char search_filter_ [256] = ""
 
uint32_t selected_address_ = 0
 
uint32_t scroll_to_address_ = 0
 
bool auto_scroll_ = true
 
bool show_execution_counts_ = true
 
bool show_hex_dump_ = true
 

Detailed Description

Advanced disassembly viewer with sparse storage and interactive features.

This viewer provides a professional disassembly interface similar to modern debuggers and ROM hacking tools. Features include:

  • Sparse address-based storage (only stores executed instructions)
  • Optimized ImGui table rendering with virtual scrolling
  • Clickable addresses, opcodes, and operands
  • Context menus for setting breakpoints, jumping to addresses, etc.
  • Highlighting of current PC, breakpoints, and hot paths
  • Search and filter capabilities
  • Export to assembly file

Definition at line 50 of file disassembly_viewer.h.

Constructor & Destructor Documentation

◆ DisassemblyViewer()

yaze::emu::debug::DisassemblyViewer::DisassemblyViewer ( )
default

◆ ~DisassemblyViewer()

yaze::emu::debug::DisassemblyViewer::~DisassemblyViewer ( )
default

Member Function Documentation

◆ RecordInstruction()

void yaze::emu::debug::DisassemblyViewer::RecordInstruction ( uint32_t  address,
uint8_t  opcode,
const std::vector< uint8_t > &  operands,
const std::string &  mnemonic,
const std::string &  operand_str 
)

◆ Render()

void yaze::emu::debug::DisassemblyViewer::Render ( uint32_t  current_pc,
const std::vector< uint32_t > &  breakpoints 
)

Render the disassembly viewer UI.

Parameters
current_pcCurrent program counter (24-bit)
breakpointsList of breakpoint addresses

Definition at line 89 of file disassembly_viewer.cc.

References instructions_, RenderDisassemblyTable(), RenderSearchBar(), and RenderToolbar().

Here is the call graph for this function:

◆ Clear()

void yaze::emu::debug::DisassemblyViewer::Clear ( )

Clear all recorded instructions.

Definition at line 418 of file disassembly_viewer.cc.

References instructions_, scroll_to_address_, and selected_address_.

Referenced by RenderToolbar().

◆ GetInstructionCount()

size_t yaze::emu::debug::DisassemblyViewer::GetInstructionCount ( ) const
inline

Get the number of unique instructions recorded.

Definition at line 83 of file disassembly_viewer.h.

References instructions_.

Referenced by yaze::emu::ui::RenderCpuInstructionLog().

◆ ExportToFile()

bool yaze::emu::debug::DisassemblyViewer::ExportToFile ( const std::string &  filepath) const

Export disassembly to file.

Parameters
filepathPath to output file
Returns
true if successful

Definition at line 424 of file disassembly_viewer.cc.

References FormatHexDump(), GetSortedAddresses(), and instructions_.

Referenced by RenderToolbar().

Here is the call graph for this function:

◆ JumpToAddress()

void yaze::emu::debug::DisassemblyViewer::JumpToAddress ( uint32_t  address)

Jump to a specific address in the viewer.

Parameters
addressAddress to jump to

Definition at line 451 of file disassembly_viewer.cc.

References auto_scroll_, scroll_to_address_, and selected_address_.

Referenced by RenderContextMenu().

◆ SetAutoScroll()

void yaze::emu::debug::DisassemblyViewer::SetAutoScroll ( bool  enabled)
inline

Set whether to auto-scroll to current PC.

Definition at line 101 of file disassembly_viewer.h.

References auto_scroll_.

◆ GetSortedAddresses()

std::vector< uint32_t > yaze::emu::debug::DisassemblyViewer::GetSortedAddresses ( ) const

Get sorted list of addresses for rendering.

Definition at line 457 of file disassembly_viewer.cc.

References instructions_.

Referenced by ExportToFile(), and RenderDisassemblyTable().

◆ IsAvailable()

bool yaze::emu::debug::DisassemblyViewer::IsAvailable ( ) const
inline

Check if the disassembly viewer is available.

Definition at line 111 of file disassembly_viewer.h.

References instructions_.

◆ SetRecording()

void yaze::emu::debug::DisassemblyViewer::SetRecording ( bool  enabled)
inline

Enable/disable recording (for performance)

Definition at line 116 of file disassembly_viewer.h.

References recording_enabled_.

◆ IsRecording()

bool yaze::emu::debug::DisassemblyViewer::IsRecording ( ) const
inline

Definition at line 117 of file disassembly_viewer.h.

References recording_enabled_.

Referenced by yaze::emu::ui::RenderCpuInstructionLog().

◆ SetMaxInstructions()

void yaze::emu::debug::DisassemblyViewer::SetMaxInstructions ( size_t  max)
inline

Set maximum number of instructions to keep.

Definition at line 122 of file disassembly_viewer.h.

References max_instructions_.

◆ TrimToSize()

void yaze::emu::debug::DisassemblyViewer::TrimToSize ( size_t  target_size)

Clear old instructions to save memory.

Definition at line 66 of file disassembly_viewer.cc.

References instructions_.

Referenced by RecordInstruction().

◆ RenderToolbar()

void yaze::emu::debug::DisassemblyViewer::RenderToolbar ( )
private
Todo:
Open file dialog and export

Definition at line 103 of file disassembly_viewer.cc.

References auto_scroll_, Clear(), ExportToFile(), ICON_MD_CLEAR_ALL, ICON_MD_MEMORY, ICON_MD_SAVE, instructions_, show_execution_counts_, and show_hex_dump_.

Referenced by Render().

Here is the call graph for this function:

◆ RenderDisassemblyTable()

void yaze::emu::debug::DisassemblyViewer::RenderDisassemblyTable ( uint32_t  current_pc,
const std::vector< uint32_t > &  breakpoints 
)
private

◆ RenderContextMenu()

void yaze::emu::debug::DisassemblyViewer::RenderContextMenu ( uint32_t  address)
private
Todo:
Implement breakpoint toggle callback
Todo:
Show detailed instruction info

Definition at line 300 of file disassembly_viewer.cc.

References ICON_MD_CONTENT_COPY, ICON_MD_FLAG, ICON_MD_INFO, ICON_MD_MY_LOCATION, instructions_, and JumpToAddress().

Referenced by RenderDisassemblyTable().

Here is the call graph for this function:

◆ RenderSearchBar()

void yaze::emu::debug::DisassemblyViewer::RenderSearchBar ( )
private

Definition at line 155 of file disassembly_viewer.cc.

References ICON_MD_SEARCH, and search_filter_.

Referenced by Render().

◆ GetAddressColor()

ImVec4 yaze::emu::debug::DisassemblyViewer::GetAddressColor ( const DisassemblyEntry entry,
uint32_t  current_pc 
) const
private

◆ GetMnemonicColor()

ImVec4 yaze::emu::debug::DisassemblyViewer::GetMnemonicColor ( const DisassemblyEntry entry) const
private

◆ FormatHexDump()

std::string yaze::emu::debug::DisassemblyViewer::FormatHexDump ( const DisassemblyEntry entry) const
private

◆ PassesFilter()

bool yaze::emu::debug::DisassemblyViewer::PassesFilter ( const DisassemblyEntry entry) const
private

Member Data Documentation

◆ instructions_

std::map<uint32_t, DisassemblyEntry> yaze::emu::debug::DisassemblyViewer::instructions_
private

◆ recording_enabled_

bool yaze::emu::debug::DisassemblyViewer::recording_enabled_ = true
private

Definition at line 134 of file disassembly_viewer.h.

Referenced by IsRecording(), RecordInstruction(), and SetRecording().

◆ max_instructions_

size_t yaze::emu::debug::DisassemblyViewer::max_instructions_ = 10000
private

Definition at line 135 of file disassembly_viewer.h.

Referenced by RecordInstruction(), and SetMaxInstructions().

◆ search_filter_

char yaze::emu::debug::DisassemblyViewer::search_filter_[256] = ""
private

Definition at line 138 of file disassembly_viewer.h.

Referenced by PassesFilter(), and RenderSearchBar().

◆ selected_address_

uint32_t yaze::emu::debug::DisassemblyViewer::selected_address_ = 0
private

Definition at line 139 of file disassembly_viewer.h.

Referenced by Clear(), JumpToAddress(), and RenderDisassemblyTable().

◆ scroll_to_address_

uint32_t yaze::emu::debug::DisassemblyViewer::scroll_to_address_ = 0
private

Definition at line 140 of file disassembly_viewer.h.

Referenced by Clear(), JumpToAddress(), and RenderDisassemblyTable().

◆ auto_scroll_

bool yaze::emu::debug::DisassemblyViewer::auto_scroll_ = true
private

◆ show_execution_counts_

bool yaze::emu::debug::DisassemblyViewer::show_execution_counts_ = true
private

Definition at line 142 of file disassembly_viewer.h.

Referenced by RenderDisassemblyTable(), and RenderToolbar().

◆ show_hex_dump_

bool yaze::emu::debug::DisassemblyViewer::show_hex_dump_ = true
private

Definition at line 143 of file disassembly_viewer.h.

Referenced by RenderDisassemblyTable(), and RenderToolbar().


The documentation for this class was generated from the following files: