OpenASIP 2.2
Loading...
Searching...
No Matches
ProximBreakpointWindow.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file ProximBreakpointWindow.cc
26 *
27 * Implementation of ProximBreakpointWindow class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#include <wx/statline.h>
34#include <wx/spinctrl.h>
35#include <wx/notebook.h>
36#include <wx/listctrl.h>
37
39#include "Application.hh"
40#include "StopPointManager.hh"
41#include "StopPoint.hh"
42#include "Breakpoint.hh"
43#include "Watch.hh"
44#include "Proxim.hh"
47#include "WxConversion.hh"
48#include "SimulatorEvent.hh"
49#include "ProximToolbox.hh"
53#include "AddWatchDialog.hh"
54#include "ErrorDialog.hh"
56
72
73
74/**
75 * The Constructor.
76 *
77 * @param parent Parent window of the frame.
78 * @param id Window ID.
79 */
81 ProximMainFrame* parent, wxWindowID id):
82 ProximSimulatorWindow(parent, id, wxDefaultPosition, wxDefaultSize, 0),
83 breakpointList_(NULL),
84 watchList_(NULL) {
85
86 createContents(this, true, true);
87
88 breakpointList_->InsertColumn(0, _T("Handle"), wxLIST_FORMAT_LEFT, 100);
89 breakpointList_->InsertColumn(1, _T("Enabled"), wxLIST_FORMAT_CENTER, 80);
90 breakpointList_->InsertColumn(2, _T("Address"), wxLIST_FORMAT_LEFT, 300);
91
92 watchList_->InsertColumn(0, _T("Handle"), wxLIST_FORMAT_LEFT, 100);
93 watchList_->InsertColumn(1, _T("Enabled"), wxLIST_FORMAT_CENTER, 80);
94 watchList_->InsertColumn(2, _T("Expression"), wxLIST_FORMAT_LEFT, 300);
95
97
98 if (simulation->isSimulationInitialized() ||
99 simulation->isSimulationRunning() ||
100 simulation->isSimulationStopped() ||
101 simulation->hasSimulationEnded()) {
102
103 refreshStopPoints();
104 }
105
106 // Disable conditional buttons initially.
107 FindWindow(ID_DELETE_BREAKPOINT)->Disable();
108 FindWindow(ID_LOOKUP_BREAKPOINT)->Disable();
109 FindWindow(ID_BREAKPOINT_PROPERTIES)->Disable();
110 FindWindow(ID_DELETE_WATCH)->Disable();
111 FindWindow(ID_BREAKPOINT_ENABLED)->Disable();
112 FindWindow(ID_WATCH_ENABLED)->Disable();
113 FindWindow(ID_WATCH_PROPERTIES)->Disable();
114}
115
116/**
117 * The Destructor.
118 */
121
122/**
123 * Event handler for the close button.
124 *
125 * Closes the window.
126 */
127void
129 GetParent()->Close();
130}
131
132
133/**
134 * Opens dialog displaying properties of the selected breakpoint when the
135 * Properties-button is pressed.
136 */
137void
139
140 long item = breakpointList_->GetNextItem(
141 -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
142
143 if (item == -1) {
144 return;
145 }
146
147 StopPointManager& manager =
148 wxGetApp().simulation()->frontend()->stopPointManager();
149
150 int handle = bpListItemHandle_[item];
151
152 BreakpointPropertiesDialog dialog(this, manager, handle);
153 dialog.ShowModal();
154
156}
157
158/**
159 * Called when the simulator resets program, machine or memory model.
160 */
161void
165
166/**
167 * Opens dialog displaying properties of the selected watch when the
168 * Properties-button is pressed in the watches tab.
169 */
170void
172
173 long item = watchList_->GetNextItem(
174 -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
175
176 if (item == -1) {
177 return;
178 }
179
180 StopPointManager& manager =
181 wxGetApp().simulation()->frontend()->stopPointManager();
182
183 int handle = watchListItemHandle_[item];
184
185 WatchPropertiesDialog dialog(this, -1, manager, handle);
186 dialog.ShowModal();
187
189}
190
191/**
192 * Updates the lists of breakpoints and watches.
193 */
194void
196
197 breakpointList_->DeleteAllItems();
198 watchList_->DeleteAllItems();
199
200 // Clear "list item to handle" mapping.
201 bpListItemHandle_.clear();
202 watchListItemHandle_.clear();
203
205
206 if (frontend == NULL ||
207 !(frontend->isSimulationInitialized() ||
208 frontend->isSimulationRunning() ||
209 frontend->isSimulationStopped() ||
210 frontend->hasSimulationEnded())) {
211
212 // Simulation not initiailized.
213 return;
214 }
215
216 StopPointManager& manager = frontend->stopPointManager();
217
218 int bpRow = 0;
219 int watchRow = 0;
220
221
222 // Add all stoppoints to appropriate lists.
223 for (unsigned i = 0; i < manager.stopPointCount(); i++) {
224
225 unsigned handle = manager.stopPointHandle(i);
226 const StopPoint* stoppoint =
227 &manager.stopPointWithHandleConst(handle);
228
229
230 // Check if the stoppoint is breakpoint.
231 const Breakpoint* breakpoint =
232 dynamic_cast<const Breakpoint*>(stoppoint);
233
234 if (breakpoint != NULL) {
235 // Stoppoint is breakpoint.
236 bpListItemHandle_.insert(
237 std::pair<unsigned, unsigned>(bpRow, handle));
238 breakpointList_->InsertItem(
239 bpRow, WxConversion::toWxString(handle));
240
241 if (breakpoint->isEnabled()) {
242 breakpointList_->SetItem(bpRow, 1, _T("X"));
243
244 }
245 InstructionAddress address = breakpoint->address();
246 breakpointList_->SetItem(
247 bpRow, 2, WxConversion::toWxString(address));
248 bpRow++;
249 continue;
250 }
251
252
253 // Check if the stoppoint is watch.
254 const Watch* watch = dynamic_cast<const Watch*>(stoppoint);
255
256 if (watch != NULL) {
257 // Stoppoint is watch.
259 std::pair<unsigned, unsigned>(watchRow, handle));
260 watchList_->InsertItem(0, WxConversion::toWxString(handle));
261 if (watch->isEnabled()) {
262 watchList_->SetItem(bpRow, 1, _T("X"));
263 }
264 std::string expression = watch->expression().script()[0];
265 watchList_->SetItem(0, 2, WxConversion::toWxString(expression));
266 watchRow++;
267 continue;
268 }
269
270 }
271
272 // Update enabled/disabled state of the dialog buttons.
273 wxListEvent dummy;
275}
276
277
278/**
279 * Deletes the breakpoint selected in the breakpoint list.
280 */
281void
283
284 long item = breakpointList_->GetNextItem(
285 -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
286
287 if (item == -1) {
288 return;
289 }
290
291 StopPointManager& manager =
292 wxGetApp().simulation()->frontend()->stopPointManager();
293
294 int handle = bpListItemHandle_[item];
295 manager.deleteStopPoint(handle);
297}
298
299
300/**
301 * Enables and disables delete buttons for stop points according to
302 * stop point list selections.
303 */
304void
306
307 if (breakpointList_->GetSelectedItemCount() > 0) {
311 } else {
315 }
316
317 if (watchList_->GetSelectedItemCount() > 0) {
318 FindWindow(ID_DELETE_WATCH)->Enable();
320 } else {
321 FindWindow(ID_DELETE_WATCH)->Disable();
323 }
324}
325
326
327/**
328 * Refreshes the breakpoint list when breakpoints are modified.
329 *
330 * @param event Event to handle.
331 */
332void
335 // Skip event so it's passed to the parent class.
336 event.Skip();
337}
338
339
340/**
341 * Deletes the watch selected in the watch list.
342 */
343void
345
346 long item = watchList_->GetNextItem(
347 -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
348
349 if (item == -1) {
350 return;
351 }
352
353 StopPointManager& manager =
354 wxGetApp().simulation()->frontend()->stopPointManager();
355
356 int handle = watchListItemHandle_[item];
357 manager.deleteStopPoint(handle);
359}
360
361/**
362 * Shows the selected breakpoint location in the program disassembly window.
363 */
364void
366
367 long item = breakpointList_->GetNextItem(
368 -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
369
370 if (item == -1) {
371 return;
372 }
373
374 StopPointManager& manager =
375 wxGetApp().simulation()->frontend()->stopPointManager();
376
377 int handle = bpListItemHandle_[item];
378 const Breakpoint& breakpoint = dynamic_cast<const Breakpoint&>(
379 manager.stopPointWithHandleConst(handle));
380 unsigned address = breakpoint.address();
382}
383
384/**
385 * Opens a dialog for adding a new breakpoint.
386 */
387void
389
391
392 if (simulation->isSimulationInitialized() ||
393 simulation->isSimulationRunning() ||
394 simulation->isSimulationStopped()) {
395
396 AddBreakpointDialog dialog(this, -1);
397 dialog.ShowModal();
398 } else {
399 wxString message = _T("Simulation not initialized.");
400 ErrorDialog error(this, message);
401 error.ShowModal();
402 }
403}
404
405/**
406 * Opens a dialog for adding a new watch.
407 */
408void
410
412
413 if (simulation->isSimulationInitialized() ||
414 simulation->isSimulationRunning() ||
415 simulation->isSimulationStopped()) {
416
417 AddWatchDialog dialog(this, -1);
418 if (dialog.ShowModal() == wxID_OK) {
420 }
421
422 } else {
423 wxString message = _T("Simulation not initialized.");
424 ErrorDialog error(this, message);
425 error.ShowModal();
426 }
427}
428
429
430/**
431 * Creates the window contents.
432 */
433wxSizer*
435 wxWindow *parent, bool call_fit, bool set_sizer) {
436
437 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
438
439 wxNotebook *item2 = new wxNotebook( parent, ID_NOTEBOOK, wxDefaultPosition, wxSize(600,450), 0 );
440#if !wxCHECK_VERSION(2,5,2)
441 wxNotebookSizer *item1 = new wxNotebookSizer( item2 );
442#else
443 wxWindow *item1 = item2;
444#endif
445
446 wxPanel *item3 = new wxPanel( item2, -1 );
447 createBreakpointTab( item3, FALSE );
448 item2->AddPage( item3, wxT("Breakpoints") );
449
450 wxPanel *item4 = new wxPanel( item2, -1 );
451 createWatchTab( item4, FALSE );
452 item2->AddPage( item4, wxT("Watches") );
453
454 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
455
456 wxStaticLine *item5 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
457 item0->Add( item5, 0, wxGROW|wxALL, 5 );
458
459 wxGridSizer *item6 = new wxGridSizer( 2, 0, 0 );
460
461 wxButton *item7 = new wxButton( parent, ID_HELP, wxT("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
462 item6->Add( item7, 0, wxALL, 5 );
463
464 wxButton *item8 = new wxButton( parent, ID_CLOSE, wxT("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
465 item6->Add( item8, 0, wxALIGN_RIGHT|wxALL, 5 );
466
467 item0->Add( item6, 0, wxGROW|wxALL, 5 );
468
469 if (set_sizer)
470 {
471 parent->SetSizer( item0 );
472 if (call_fit)
473 item0->SetSizeHints( parent );
474 }
475
476 return item0;
477}
478
479/**
480 * Creates the breakpoint tab.
481 */
482wxSizer*
484 wxWindow *parent, bool call_fit, bool set_sizer) {
485
486 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
487
488 wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
489
490 wxBoxSizer *item2 = new wxBoxSizer( wxVERTICAL );
491
492 wxButton *item3 = new wxButton( parent, ID_BREAKPOINT_PROPERTIES, wxT("Properties..."), wxDefaultPosition, wxDefaultSize, 0 );
493 item2->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
494
495 wxButton *item4 = new wxButton( parent, ID_LOOKUP_BREAKPOINT, wxT("Lookup"), wxDefaultPosition, wxDefaultSize, 0 );
496 item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
497
498 wxButton *item5 = new wxButton( parent, ID_DELETE_BREAKPOINT, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
499 item2->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
500
501 wxCheckBox *item6 = new wxCheckBox( parent, ID_BREAKPOINT_ENABLED, wxT("Enabled"), wxDefaultPosition, wxDefaultSize, 0 );
502 item2->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
503
504 item1->Add( item2, 0, wxALL, 5 );
505
506 breakpointList_ = new wxListCtrl( parent, ID_BREAKPOINT_LIST, wxDefaultPosition, wxSize(400,300), wxLC_REPORT|wxSUNKEN_BORDER );
507 item1->Add( breakpointList_, 0, wxALIGN_CENTER|wxALL, 5 );
508
509 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
510
511 wxButton *item8 = new wxButton( parent, ID_ADD_BREAKPOINT, wxT("Add breakpoint..."), wxDefaultPosition, wxDefaultSize, 0 );
512 item0->Add( item8, 0, wxALL, 5 );
513
514 if (set_sizer)
515 {
516 parent->SetSizer( item0 );
517 if (call_fit)
518 item0->SetSizeHints( parent );
519 }
520
521 return item0;
522}
523
524/**
525 * Creates the watches tab.
526 */
527wxSizer*
529 wxWindow *parent, bool call_fit, bool set_sizer) {
530
531 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
532
533 wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
534
535 wxBoxSizer *item2 = new wxBoxSizer( wxVERTICAL );
536
537 wxButton *item3 = new wxButton( parent, ID_WATCH_PROPERTIES, wxT("Properties..."), wxDefaultPosition, wxDefaultSize, 0 );
538 item2->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
539
540 wxButton *item4 = new wxButton( parent, ID_DELETE_WATCH, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
541 item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
542
543 wxCheckBox *item5 = new wxCheckBox( parent, ID_WATCH_ENABLED, wxT("Enabled"), wxDefaultPosition, wxDefaultSize, 0 );
544 item2->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
545
546 item1->Add( item2, 0, wxALL, 5 );
547
548 watchList_ = new wxListCtrl( parent, ID_WATCH_LIST, wxDefaultPosition, wxSize(400,300), wxLC_REPORT|wxSUNKEN_BORDER );
549 item1->Add( watchList_, 0, wxALIGN_CENTER|wxALL, 5 );
550
551 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
552
553 wxButton *item7 = new wxButton( parent, ID_ADD_WATCH, wxT("Add watch..."), wxDefaultPosition, wxDefaultSize, 0 );
554 item0->Add( item7, 0, wxALL, 5 );
555
556 if (set_sizer)
557 {
558 parent->SetSizer( item0 );
559 if (call_fit)
560 item0->SetSizeHints( parent );
561 }
562
563 return item0;
564}
565
UInt32 InstructionAddress
Definition BaseType.hh:175
END_EVENT_TABLE() using namespace IDF
FUImplementationDialog::onAddExternalPort FUImplementationDialog::onDeleteExternalPort FUImplementationDialog::onArchPortSelection EVT_LIST_ITEM_DESELECTED(ID_ARCH_PORT_LIST, FUImplementationDialog::onArchPortSelection) EVT_LIST_ITEM_ACTIVATED(ID_ARCH_PORT_LIST
FUImplementationDialog::onAddExternalPort FUImplementationDialog::onDeleteExternalPort FUImplementationDialog::onArchPortSelection FUImplementationDialog::onArchPortActivation EVT_LIST_ITEM_SELECTED(ID_EXTERNAL_PORT_LIST, FUImplementationDialog::onExternalPortSelection) EVT_LIST_ITEM_ACTIVATED(ID_EXTERNAL_PORT_LIST
EVT_BUTTON(ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort) EVT_BUTTON(ID_ADD_EXTERNAL_PORT
const string FALSE
Value used for false in attribute and element values.
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
#define EVT_SIMULATOR_COMMAND_DONE(id, fn)
virtual InstructionAddress address() const
Definition Breakpoint.cc:86
void onBreakpointSelection(wxListEvent &event)
wxSizer * createBreakpointTab(wxWindow *parent, bool call_fit=true, bool set_sizer=true)
void onClose(wxCommandEvent &event)
void onAddWatch(wxCommandEvent &event)
std::map< unsigned, unsigned > watchListItemHandle_
Map for translating watch list item numbers to stop point handles.
void onBreakpointsModified(SimulatorEvent &event)
void onBreakpointProperties(wxCommandEvent &event)
void onAddBreakpoint(wxCommandEvent &event)
wxListCtrl * breakpointList_
List widget for breakpoints.
void onDeleteBreakpoint(wxCommandEvent &event)
wxSizer * createWatchTab(wxWindow *parent, bool call_fit=true, bool set_sizer=true)
void onWatchProperties(wxCommandEvent &event)
void onBreakpointLookup(wxCommandEvent &event)
std::map< unsigned, unsigned > bpListItemHandle_
Map for translating breakpoint list item numbers to stop point handles.
void onDeleteWatch(wxCommandEvent &event)
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
wxListCtrl * watchList_
List widget for watches.
void showAddress(unsigned address)
static TracedSimulatorFrontend * frontend()
static ProximDisassemblyWindow * disassemblyWindow()
virtual std::vector< std::string > script() const
Definition Script.cc:106
bool hasSimulationEnded() const
bool isSimulationInitialized() const
bool isSimulationStopped() const
StopPointManager & stopPointManager()
bool isSimulationRunning() const
unsigned int stopPointCount()
void deleteStopPoint(unsigned int handle)
const StopPoint & stopPointWithHandleConst(unsigned int handle) const
unsigned int stopPointHandle(unsigned int index)
virtual bool isEnabled() const
Definition StopPoint.cc:73
Definition Watch.hh:48
virtual const ExpressionScript & expression() const
Definition Watch.cc:88
static wxString toWxString(const std::string &source)