OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
ProximDisassemblyGridTablecodeTable_
 Grid table which handles on-the-fly disassembly of the loaded program.
 
std::map< unsigned, std::string > menuCommand_
 A map which contains command strings for context menu items.
 

Static Private Attributes

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

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.

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}
ProximDisassemblyGridTable * codeTable_
Grid table which handles on-the-fly disassembly of the loaded program.
wxGrid * codeGrid_
The grid disapleying the disassembly.

◆ ~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 =
190}
#define assert(condition)
find Finds info of the inner loops in the program
void loadProgram(const TTAProgram::Program &program)
void setStopPointManager(StopPointManager &manager)
static TracedSimulatorFrontend * frontend()
StopPointManager & stopPointManager()

References assert, codeTable_, ProximToolbox::frontend(), DisassemblyGridTable::loadProgram(), program, resetGrid(), ProximDisassemblyGridTable::setCurrentInstruction(), ProximDisassemblyGridTable::setStopPointManager(), ProximDisassemblyGridTable::showPCArrow(), and SimulatorFrontend::stopPointManager().

Referenced by onProgramLoaded().

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}
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)
std::map< unsigned, std::string > menuCommand_
A map which contains command strings for context menu items.

References AssocTools::containsKey(), and menuCommand_.

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}
void loadProgram(const TTAProgram::Program &program)
static const TTAProgram::Program & program()

References loadProgram(), and 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}
virtual InstructionAddress address() const
Definition Breakpoint.cc:86
static std::string toString(const T &source)
unsigned int stopPointCount()
const StopPoint & stopPointWithHandleConst(unsigned int handle) const
unsigned int stopPointHandle(unsigned int index)
virtual bool isEnabled() const
Definition StopPoint.cc:73
static wxString toWxString(const std::string &source)

References Breakpoint::address(), DisassemblyGridTable::addressOfRow(), codeGrid_, codeTable_, ProximToolbox::frontend(), StopPoint::isEnabled(), MENU_ID_FIRST_MAPPED, MENU_ID_RUN_UNTIL, MENU_ID_SET_BP, MENU_ID_SET_TEMP_BP, menuCommand_, 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}
static const std::string SCL_RUN_UNTIL
Command for running until specified instruciton is encoutnered.

References DisassemblyGridTable::addressOfRow(), codeGrid_, codeTable_, 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}
static const std::string SCL_SET_BREAKPOINT
Command for setting breakpoints in the simulator control language.

References DisassemblyGridTable::addressOfRow(), codeGrid_, codeTable_, 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}
static const std::string SCL_SET_TEMP_BP
Command for setting temporary breakpointss in the sim.con.language.

References DisassemblyGridTable::addressOfRow(), codeGrid_, codeTable_, 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}

References codeGrid_.

◆ 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}
ProximDisasmAttrProvider * moveCellAttrProvider() const

References codeGrid_, codeTable_, ProximDisassemblyGridTable::moveCellAttrProvider(), ProximDisassemblyGridTable::setCurrentInstruction(), and ProximDisasmAttrProvider::update().

Here is the call graph for this function:

◆ 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}

References codeGrid_, and codeTable_.

◆ 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}

References codeGrid_, and codeTable_.

Referenced by loadProgram().

◆ 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}
void setMoveCellAttrProvider(ProximDisasmAttrProvider *attrProvider)

References codeTable_, and ProximDisassemblyGridTable::setMoveCellAttrProvider().

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

Here is the call graph for this function:

◆ 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}
int rowOfAddress(Word address)

References codeGrid_, codeTable_, and DisassemblyGridTable::rowOfAddress().

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

Here is the call graph for this function:

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.

Referenced by onRightClick(), onRunUntil(), onSetBreakpoint(), onSetTempBp(), onSimulatorCommand(), onSimulatorStop(), reset(), resetGrid(), and showAddress().

◆ 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.

Referenced by loadProgram(), onRightClick(), onRunUntil(), onSetBreakpoint(), onSetTempBp(), onSimulatorStop(), reset(), resetGrid(), setMoveAttrProvider(), and showAddress().

◆ 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.

Referenced by onMappedMenuCommand(), and onRightClick().


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