OpenASIP  2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ProximDisassemblyWindow Class Reference

#include <ProximDisassemblyWindow.hh>

Inheritance diagram for ProximDisassemblyWindow:
Inheritance graph
Collaboration diagram for ProximDisassemblyWindow:
Collaboration graph

Public Member Functions

 ProximDisassemblyWindow (ProximMainFrame *parent, int id)
 
virtual ~ProximDisassemblyWindow ()
 
virtual void reset ()
 
void loadProgram (const TTAProgram::Program &program)
 
void showAddress (unsigned address)
 
void setMoveAttrProvider (ProximDisasmAttrProvider *attrProvider)
 

Private Types

enum  { MENU_ID_SET_BP = 10000, MENU_ID_SET_TEMP_BP, MENU_ID_RUN_UNTIL, MENU_ID_FIRST_MAPPED }
 Context menu command IDs. More...
 

Private Member Functions

void initialize ()
 
void resetGrid ()
 
void onProgramLoaded (const SimulatorEvent &event)
 
void onSimulatorStop (const SimulatorEvent &event)
 
void onSimulatorCommand (SimulatorEvent &event)
 
void onRightClick (wxGridEvent &event)
 
void onSetBreakpoint (wxCommandEvent &event)
 
void onSetTempBp (wxCommandEvent &event)
 
void onRunUntil (wxCommandEvent &event)
 
void onMappedMenuCommand (wxCommandEvent &event)
 

Private Attributes

wxGrid * codeGrid_
 The grid disapleying the disassembly. More...
 
ProximDisassemblyGridTablecodeTable_
 Grid table which handles on-the-fly disassembly of the loaded program. More...
 
std::map< unsigned, std::string > menuCommand_
 A map which contains command strings for context menu items. More...
 

Static Private Attributes

static const unsigned INFO_COLUMN_WIDTH = 30
 Width of the column displaying the arrow pointign current instruction. More...
 
static const unsigned ADDRESS_COLUMN_WIDTH = 60
 Width of the instruction address column. More...
 
static const unsigned BP_COLUMN_WIDTH = 80
 Width of the breakpoint info column. More...
 
static const unsigned DISASSEMBLY_COLUMN_WIDTH = 400
 Width of the instruction disassembly column. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ProximSimulatorWindow
 ProximSimulatorWindow (ProximMainFrame *mainFrame, wxWindowID id=-1, wxPoint pos=wxDefaultPosition, wxSize size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
 
virtual ~ProximSimulatorWindow ()
 

Detailed Description

A window which can be utilized to display disassembly of a program object model.

This class listens to SimulatorEvents and updates the window information automatically.

Definition at line 58 of file ProximDisassemblyWindow.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Context menu command IDs.

Enumerator
MENU_ID_SET_BP 
MENU_ID_SET_TEMP_BP 
MENU_ID_RUN_UNTIL 
MENU_ID_FIRST_MAPPED 

Definition at line 97 of file ProximDisassemblyWindow.hh.

97  {
98  MENU_ID_SET_BP = 10000,
101  MENU_ID_FIRST_MAPPED // Keep this as the last menu item.
102  };

Constructor & Destructor Documentation

◆ ProximDisassemblyWindow()

ProximDisassemblyWindow::ProximDisassemblyWindow ( ProximMainFrame parent,
int  id 
)

Constructor.

Parameters
parentParent window of the window.
idWindow identifier.

Definition at line 84 of file ProximDisassemblyWindow.cc.

85  :
86  ProximSimulatorWindow(parent, id),
87  codeGrid_(NULL),
88  codeTable_(NULL) {
89 
90  initialize();
91 }

◆ ~ProximDisassemblyWindow()

ProximDisassemblyWindow::~ProximDisassemblyWindow ( )
virtual

Destructor.

Definition at line 97 of file ProximDisassemblyWindow.cc.

97  {
98 }

Member Function Documentation

◆ initialize()

void ProximDisassemblyWindow::initialize ( )
private

Creates the window contents.

Definition at line 105 of file ProximDisassemblyWindow.cc.

105  {
106 
107  wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
108  SetSizer(sizer);
109 }

◆ loadProgram()

void ProximDisassemblyWindow::loadProgram ( const TTAProgram::Program program)

Loads a program model to the window.

Parameters
programProgram to load.

Definition at line 179 of file ProximDisassemblyWindow.cc.

179  {
180  assert(codeTable_ == NULL);
182 
184  resetGrid();
187  StopPointManager& bpManager =
189  codeTable_->setStopPointManager(bpManager);
190 }

References assert, ProximToolbox::frontend(), program, and SimulatorFrontend::stopPointManager().

Here is the call graph for this function:

◆ onMappedMenuCommand()

void ProximDisassemblyWindow::onMappedMenuCommand ( wxCommandEvent &  event)
private

Event handler for breakpoint submenus of the context menu.

Parameters
eventMenu event to handle.

Definition at line 373 of file ProximDisassemblyWindow.cc.

373  {
374 
375  if (!AssocTools::containsKey(menuCommand_, event.GetId())) {
376  // Menu item ID doesn't have command associated, the event is skipped.
377  event.Skip();
378  }
379 
380  string command = menuCommand_[event.GetId()];
381  wxGetApp().simulation()->lineReader().input(command);
382 }

References AssocTools::containsKey().

Here is the call graph for this function:

◆ onProgramLoaded()

void ProximDisassemblyWindow::onProgramLoaded ( const SimulatorEvent event)
private

Updates disassembly window when a program is loaded to the simulator.

Definition at line 198 of file ProximDisassemblyWindow.cc.

198  {
200 }

References ProximToolbox::program().

Here is the call graph for this function:

◆ onRightClick()

void ProximDisassemblyWindow::onRightClick ( wxGridEvent &  event)
private

Handles RMB clicks on the disassembly window.

A context menu is displayed at the cursor location.

Definition at line 209 of file ProximDisassemblyWindow.cc.

209  {
210 
211  codeGrid_->SelectRow(event.GetRow());
212 
213  wxMenu* contextMenu = new wxMenu();
214  Word address = codeTable_->addressOfRow(event.GetRow());
215  contextMenu->Append(MENU_ID_SET_BP, _T("Set breakpoint"));
216  contextMenu->Append(
217  MENU_ID_SET_TEMP_BP, _T("Set temporary breakpoint"));
218 
219  contextMenu->AppendSeparator();
220  contextMenu->Append(MENU_ID_RUN_UNTIL, _T("Run until"));
221  contextMenu->AppendSeparator();
222 
223  menuCommand_.clear();
224 
225  StopPointManager& bpManager =
227 
228  // Create submenu for each breakpoint at the selected line.
229  unsigned itemID = MENU_ID_FIRST_MAPPED;
230  for (unsigned i = 0; i < bpManager.stopPointCount(); i++) {
231 
232  unsigned handle = bpManager.stopPointHandle(i);
233  const Breakpoint* bp = dynamic_cast<const Breakpoint*>(
234  &bpManager.stopPointWithHandleConst(handle));
235 
236  if (bp != NULL) {
237  unsigned bpAddress = bp->address();
238  if (bpAddress == address) {
239 
240  wxMenu* bpSubMenu = new wxMenu();
241  string handleStr = Conversion::toString(handle);
242 
243  // Info menuitem.
244  menuCommand_[itemID] = "info breakpoints " + handleStr;
245  wxString infoLabel = _T("info");
246  bpSubMenu->Append(itemID, infoLabel);
247  itemID++;
248 
249 
250  // Delete menuitem.
251  menuCommand_[itemID] = "deletebp " + handleStr;
252  wxString deleteLabel = _T("delete");
253  bpSubMenu->Append(itemID, deleteLabel);
254  itemID++;
255 
256  // Enable/disable menuitem.
257  if (bp->isEnabled()) {
258  menuCommand_[itemID] =
259  "disablebp " + handleStr;
260  wxString disableLabel = _T("disable");
261  bpSubMenu->Append(itemID, disableLabel);
262  } else {
263  menuCommand_[itemID] =
264  "enablebp " + handleStr;
265  wxString enableLabel = _T("enable");
266  bpSubMenu->Append(itemID, enableLabel);
267  }
268  itemID++;
269  wxString menuLabel =
270  _T("breakpoint ") + WxConversion::toWxString(handle);
271 
272  contextMenu->Append(0, menuLabel, bpSubMenu);
273  }
274  }
275  }
276 
277  PopupMenu(contextMenu, event.GetPosition());
278 }

References Breakpoint::address(), ProximToolbox::frontend(), StopPoint::isEnabled(), MENU_ID_FIRST_MAPPED, StopPointManager::stopPointCount(), StopPointManager::stopPointHandle(), SimulatorFrontend::stopPointManager(), StopPointManager::stopPointWithHandleConst(), Conversion::toString(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ onRunUntil()

void ProximDisassemblyWindow::onRunUntil ( wxCommandEvent &  event)
private

Handles the context menu "run until" clicks.

Definition at line 314 of file ProximDisassemblyWindow.cc.

314  {
315  unsigned address =
316  codeTable_->addressOfRow(codeGrid_->GetSelectedRows().Item(0));
317  string command = ProximConstants::SCL_RUN_UNTIL + " " +
318  Conversion::toString(address);
319 
320  wxGetApp().simulation()->lineReader().input(command);
321 }

References ProximConstants::SCL_RUN_UNTIL, and Conversion::toString().

Here is the call graph for this function:

◆ onSetBreakpoint()

void ProximDisassemblyWindow::onSetBreakpoint ( wxCommandEvent &  event)
private

Handles the event of adding new breakpoint with the context menu.

Definition at line 286 of file ProximDisassemblyWindow.cc.

286  {
287  unsigned address =
288  codeTable_->addressOfRow(codeGrid_->GetSelectedRows().Item(0));
289  string command = ProximConstants::SCL_SET_BREAKPOINT + " " +
290  Conversion::toString(address);
291 
292  wxGetApp().simulation()->lineReader().input(command);
293 }

References ProximConstants::SCL_SET_BREAKPOINT, and Conversion::toString().

Here is the call graph for this function:

◆ onSetTempBp()

void ProximDisassemblyWindow::onSetTempBp ( wxCommandEvent &  event)
private

Handles the event of adding new temporary breakpoint with the context menu.

Definition at line 300 of file ProximDisassemblyWindow.cc.

300  {
301  unsigned address =
302  codeTable_->addressOfRow(codeGrid_->GetSelectedRows().Item(0));
303  string command = ProximConstants::SCL_SET_TEMP_BP + " " +
304  Conversion::toString(address);
305 
306  wxGetApp().simulation()->lineReader().input(command);
307 }

References ProximConstants::SCL_SET_TEMP_BP, and Conversion::toString().

Here is the call graph for this function:

◆ onSimulatorCommand()

void ProximDisassemblyWindow::onSimulatorCommand ( SimulatorEvent event)
private

Updates the disassembly window when a command is executed.

Parameters
eventEvent of a command execution.

Definition at line 346 of file ProximDisassemblyWindow.cc.

346  {
347  if (codeGrid_ != NULL) {
348  codeGrid_->ForceRefresh();
349  }
350  event.Skip();
351 }

◆ onSimulatorStop()

void ProximDisassemblyWindow::onSimulatorStop ( const SimulatorEvent event)
private

Updates the arrow displaying the current instruction when the simulation stops.

Definition at line 328 of file ProximDisassemblyWindow.cc.

328  {
329  Word pc = wxGetApp().simulation()->frontend()->programCounter();
330  if (codeTable_->moveCellAttrProvider() != NULL) {
332  }
334  codeGrid_->SelectRow(pc);
335  codeGrid_->MakeCellVisible(pc, 1);
336  codeGrid_->ForceRefresh();
337 }

◆ reset()

void ProximDisassemblyWindow::reset ( )
virtual

Called when the simulator program, machine and memory models are deleted.

Reimplemented from ProximSimulatorWindow.

Definition at line 155 of file ProximDisassemblyWindow.cc.

155  {
156 
157  wxSizer* sizer = GetSizer();
158 
159  if (codeGrid_ != NULL) {
160  sizer->Detach(codeGrid_);
161  sizer->Layout();
162  codeGrid_->Destroy();
163  codeGrid_ = NULL;
164  }
165 
166  if (codeTable_ != NULL) {
167  delete codeTable_;
168  codeTable_ = NULL;
169  }
170 }

◆ resetGrid()

void ProximDisassemblyWindow::resetGrid ( )
private

Resets the grid. This function has to be called if a new program is loaded to the window.

Definition at line 117 of file ProximDisassemblyWindow.cc.

117  {
118 
119  wxSizer* sizer = GetSizer();
120 
121  if (codeGrid_ != NULL) {
122  sizer->Detach(codeGrid_);
123  sizer->Layout();
124  codeGrid_->Destroy();
125  }
126 
127  codeGrid_ = new wxGrid(this, -1, wxDefaultPosition, wxDefaultSize);
128  codeGrid_->SetTable(codeTable_);
129 
130  codeGrid_->EnableEditing(false);
131  codeGrid_->DisableCellEditControl();
132  codeGrid_->SetSelectionMode(wxGrid::wxGridSelectRows);
133  codeGrid_->DisableDragGridSize();
134  codeGrid_->DisableDragRowSize();
135  codeGrid_->EnableGridLines(false);
136  codeGrid_->SetDefaultColSize(200);
137 
138  codeGrid_->SetColSize(0, 100);
139  codeGrid_->SetColSize(1, 80);
140 
141  codeGrid_->SetDefaultCellFont(*wxSMALL_FONT);
142  codeGrid_->SetGridCursor(0, 0);
143 
144  sizer->Add(codeGrid_, 1, wxGROW);
145 
146  Layout();
147 }

◆ setMoveAttrProvider()

void ProximDisassemblyWindow::setMoveAttrProvider ( ProximDisasmAttrProvider attrProvider)

Sets the move cell attribute provider.

Parameters
attrProviderNew attribute provider.

Definition at line 391 of file ProximDisassemblyWindow.cc.

392  {
393 
394  codeTable_->setMoveCellAttrProvider(attrProvider);
395 }

Referenced by ClearDisassemblyHighlightCmd::Do(), HighlightExecPercentageCmd::Do(), and HighlightTopExecCountsCmd::Do().

◆ showAddress()

void ProximDisassemblyWindow::showAddress ( unsigned  address)

Selects the instruction at given address.

Parameters
addressAddress of the isntruction to show.

Definition at line 359 of file ProximDisassemblyWindow.cc.

359  {
360  unsigned row = codeTable_->rowOfAddress(address);
361  codeGrid_->SelectRow(row);
362  codeGrid_->MakeCellVisible(row, 0);
363 
364 }

Referenced by ProximBreakpointWindow::onBreakpointLookup(), FindWindow::onFindNext(), FindWindow::onFindPrev(), FindWindow::onInputText(), and DisasmExecCountFrame::onSelection().

Member Data Documentation

◆ ADDRESS_COLUMN_WIDTH

const unsigned ProximDisassemblyWindow::ADDRESS_COLUMN_WIDTH = 60
staticprivate

Width of the instruction address column.

Definition at line 90 of file ProximDisassemblyWindow.hh.

◆ BP_COLUMN_WIDTH

const unsigned ProximDisassemblyWindow::BP_COLUMN_WIDTH = 80
staticprivate

Width of the breakpoint info column.

Definition at line 92 of file ProximDisassemblyWindow.hh.

◆ codeGrid_

wxGrid* ProximDisassemblyWindow::codeGrid_
private

The grid disapleying the disassembly.

Definition at line 80 of file ProximDisassemblyWindow.hh.

◆ codeTable_

ProximDisassemblyGridTable* ProximDisassemblyWindow::codeTable_
private

Grid table which handles on-the-fly disassembly of the loaded program.

Definition at line 82 of file ProximDisassemblyWindow.hh.

◆ DISASSEMBLY_COLUMN_WIDTH

const unsigned ProximDisassemblyWindow::DISASSEMBLY_COLUMN_WIDTH = 400
staticprivate

Width of the instruction disassembly column.

Definition at line 94 of file ProximDisassemblyWindow.hh.

◆ INFO_COLUMN_WIDTH

const unsigned ProximDisassemblyWindow::INFO_COLUMN_WIDTH = 30
staticprivate

Width of the column displaying the arrow pointign current instruction.

Definition at line 88 of file ProximDisassemblyWindow.hh.

◆ menuCommand_

std::map<unsigned, std::string> ProximDisassemblyWindow::menuCommand_
private

A map which contains command strings for context menu items.

Definition at line 85 of file ProximDisassemblyWindow.hh.


The documentation for this class was generated from the following files:
Breakpoint::address
virtual InstructionAddress address() const
Definition: Breakpoint.cc:86
ProximToolbox::frontend
static TracedSimulatorFrontend * frontend()
Definition: ProximToolbox.cc:223
WxConversion::toWxString
static wxString toWxString(const std::string &source)
Breakpoint
Definition: Breakpoint.hh:50
ProximDisassemblyWindow::codeGrid_
wxGrid * codeGrid_
The grid disapleying the disassembly.
Definition: ProximDisassemblyWindow.hh:80
AssocTools::containsKey
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)
DisassemblyGridTable::loadProgram
void loadProgram(const TTAProgram::Program &program)
Definition: DisassemblyGridTable.cc:224
DisassemblyGridTable::addressOfRow
Word addressOfRow(int row)
Definition: DisassemblyGridTable.cc:254
ProximDisassemblyWindow::MENU_ID_RUN_UNTIL
@ MENU_ID_RUN_UNTIL
Definition: ProximDisassemblyWindow.hh:100
ProximDisassemblyGridTable::moveCellAttrProvider
ProximDisasmAttrProvider * moveCellAttrProvider() const
Definition: ProximDisassemblyGridTable.cc:219
ProximToolbox::program
static const TTAProgram::Program & program()
Definition: ProximToolbox.cc:88
ProximDisasmAttrProvider::update
virtual void update()
Definition: ProximDisasmAttrProvider.cc:68
ProximDisassemblyWindow::menuCommand_
std::map< unsigned, std::string > menuCommand_
A map which contains command strings for context menu items.
Definition: ProximDisassemblyWindow.hh:85
ProximDisassemblyWindow::MENU_ID_SET_TEMP_BP
@ MENU_ID_SET_TEMP_BP
Definition: ProximDisassemblyWindow.hh:99
Conversion::toString
static std::string toString(const T &source)
ProximDisassemblyGridTable::showPCArrow
void showPCArrow()
Definition: ProximDisassemblyGridTable.cc:172
assert
#define assert(condition)
Definition: Application.hh:86
StopPointManager::stopPointCount
unsigned int stopPointCount()
Definition: StopPointManager.cc:269
ProximDisassemblyWindow::resetGrid
void resetGrid()
Definition: ProximDisassemblyWindow.cc:117
ProximConstants::SCL_RUN_UNTIL
static const std::string SCL_RUN_UNTIL
Command for running until specified instruciton is encoutnered.
Definition: ProximConstants.hh:163
StopPointManager::stopPointWithHandleConst
const StopPoint & stopPointWithHandleConst(unsigned int handle) const
Definition: StopPointManager.cc:248
StopPointManager
Definition: StopPointManager.hh:50
ProximDisassemblyWindow::MENU_ID_FIRST_MAPPED
@ MENU_ID_FIRST_MAPPED
Definition: ProximDisassemblyWindow.hh:101
ProximDisassemblyWindow::initialize
void initialize()
Definition: ProximDisassemblyWindow.cc:105
DisassemblyGridTable::rowOfAddress
int rowOfAddress(Word address)
Definition: DisassemblyGridTable.cc:266
ProximDisassemblyGridTable::setCurrentInstruction
void setCurrentInstruction(Word address)
Definition: ProximDisassemblyGridTable.cc:191
StopPoint::isEnabled
virtual bool isEnabled() const
Definition: StopPoint.cc:73
ProximConstants::SCL_SET_BREAKPOINT
static const std::string SCL_SET_BREAKPOINT
Command for setting breakpoints in the simulator control language.
Definition: ProximConstants.hh:151
ProximDisassemblyWindow::codeTable_
ProximDisassemblyGridTable * codeTable_
Grid table which handles on-the-fly disassembly of the loaded program.
Definition: ProximDisassemblyWindow.hh:82
ProximDisassemblyWindow::MENU_ID_SET_BP
@ MENU_ID_SET_BP
Definition: ProximDisassemblyWindow.hh:98
ProximDisassemblyWindow::loadProgram
void loadProgram(const TTAProgram::Program &program)
Definition: ProximDisassemblyWindow.cc:179
ProximDisassemblyGridTable::setStopPointManager
void setStopPointManager(StopPointManager &manager)
Definition: ProximDisassemblyGridTable.cc:71
ProximDisassemblyGridTable
Definition: ProximDisassemblyGridTable.hh:47
program
find Finds info of the inner loops in the program
Definition: InnerLoopFinder.cc:80
StopPointManager::stopPointHandle
unsigned int stopPointHandle(unsigned int index)
Definition: StopPointManager.cc:231
ProximDisassemblyGridTable::setMoveCellAttrProvider
void setMoveCellAttrProvider(ProximDisasmAttrProvider *attrProvider)
Definition: ProximDisassemblyGridTable.cc:204
SimulatorFrontend::stopPointManager
StopPointManager & stopPointManager()
Definition: SimulatorFrontend.cc:2108
ProximConstants::SCL_SET_TEMP_BP
static const std::string SCL_SET_TEMP_BP
Command for setting temporary breakpointss in the sim.con.language.
Definition: ProximConstants.hh:153
ProximSimulatorWindow::ProximSimulatorWindow
ProximSimulatorWindow(ProximMainFrame *mainFrame, wxWindowID id=-1, wxPoint pos=wxDefaultPosition, wxSize size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
Definition: ProximSimulatorWindow.cc:49