Use Architecture information in WatchPromptWindow.

- We now check what types of watchpoints the target CPU supports
  and limit the UI accordingly.
This commit is contained in:
Rene Gollent 2012-11-12 20:22:47 -05:00
parent 6be4555f92
commit 5ad155d720
3 changed files with 43 additions and 15 deletions

View File

@ -261,8 +261,9 @@ TeamWindow::MessageReceived(BMessage* message)
} }
try { try {
WatchPromptWindow* window = WatchPromptWindow::Create(address, WatchPromptWindow* window = WatchPromptWindow::Create(
type, length, fListener); fTeam->GetArchitecture(), address, type, length,
fListener);
window->Show(); window->Show();
} catch (...) { } catch (...) {
// TODO: notify user // TODO: notify user

View File

@ -15,38 +15,43 @@
#include <ExpressionParser.h> #include <ExpressionParser.h>
#include "Architecture.h"
#include "MessageCodes.h" #include "MessageCodes.h"
#include "UserInterface.h" #include "UserInterface.h"
#include "Watchpoint.h" #include "Watchpoint.h"
WatchPromptWindow::WatchPromptWindow(target_addr_t address, uint32 type, WatchPromptWindow::WatchPromptWindow(Architecture* architecture,
int32 length, UserInterfaceListener* listener) target_addr_t address, uint32 type, int32 length,
UserInterfaceListener* listener)
: :
BWindow(BRect(), "Edit Watchpoint", B_FLOATING_WINDOW, BWindow(BRect(), "Edit Watchpoint", B_FLOATING_WINDOW,
B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE), B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
fInitialAddress(address), fInitialAddress(address),
fInitialType(type), fInitialType(type),
fInitialLength(length), fInitialLength(length),
fArchitecture(architecture),
fAddressInput(NULL), fAddressInput(NULL),
fLengthInput(NULL), fLengthInput(NULL),
fTypeField(NULL), fTypeField(NULL),
fListener(listener) fListener(listener)
{ {
fArchitecture->AcquireReference();
} }
WatchPromptWindow::~WatchPromptWindow() WatchPromptWindow::~WatchPromptWindow()
{ {
fArchitecture->ReleaseReference();
} }
WatchPromptWindow* WatchPromptWindow*
WatchPromptWindow::Create(target_addr_t address, uint32 type, int32 length, WatchPromptWindow::Create(Architecture* architecture, target_addr_t address,
UserInterfaceListener* listener) uint32 type, int32 length, UserInterfaceListener* listener)
{ {
WatchPromptWindow* self = new WatchPromptWindow(address, type, length, WatchPromptWindow* self = new WatchPromptWindow(architecture, address,
listener); type, length, listener);
try { try {
self->_Init(); self->_Init();
@ -69,10 +74,29 @@ WatchPromptWindow::_Init()
text.SetToFormat("%" B_PRId32, fInitialLength); text.SetToFormat("%" B_PRId32, fInitialLength);
fLengthInput = new BTextControl("Length:", text, NULL); fLengthInput = new BTextControl("Length:", text, NULL);
int32 maxDebugRegisters = 0;
int32 maxBytesPerRegister = 0;
uint8 debugCapabilityFlags = 0;
fArchitecture->GetWatchpointDebugCapabilities(maxDebugRegisters,
maxBytesPerRegister, debugCapabilityFlags);
BMenu* typeMenu = new BMenu("Watch Type"); BMenu* typeMenu = new BMenu("Watch Type");
typeMenu->AddItem(new BMenuItem("Read", NULL));
typeMenu->AddItem(new BMenuItem("Write", NULL)); BMenuItem* watchTypeItem = new BMenuItem("Read", NULL);
typeMenu->AddItem(new BMenuItem("Read/Write", NULL)); watchTypeItem->SetEnabled(
(debugCapabilityFlags & WATCHPOINT_CAPABILITY_FLAG_READ) != 0);
typeMenu->AddItem(watchTypeItem);
watchTypeItem = new BMenuItem("Write", NULL);
watchTypeItem->SetEnabled(
(debugCapabilityFlags & WATCHPOINT_CAPABILITY_FLAG_WRITE) != 0);
typeMenu->AddItem(watchTypeItem);
watchTypeItem = new BMenuItem("Read/Write", NULL);
watchTypeItem->SetEnabled(
(debugCapabilityFlags & WATCHPOINT_CAPABILITY_FLAG_READ_WRITE) != 0);
typeMenu->AddItem(watchTypeItem);
fTypeField = new BMenuField("Type:", typeMenu); fTypeField = new BMenuField("Type:", typeMenu);
BLayoutItem* labelItem = fTypeField->CreateLabelLayoutItem(); BLayoutItem* labelItem = fTypeField->CreateLabelLayoutItem();
labelItem->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); labelItem->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

View File

@ -11,6 +11,7 @@
#include "types/Types.h" #include "types/Types.h"
class Architecture;
class BTextControl; class BTextControl;
class Watchpoint; class Watchpoint;
class BMenuField; class BMenuField;
@ -20,14 +21,15 @@ class UserInterfaceListener;
class WatchPromptWindow : public BWindow class WatchPromptWindow : public BWindow
{ {
public: public:
// edit existing watchpoint WatchPromptWindow(Architecture* architecture,
WatchPromptWindow(target_addr_t address, target_addr_t address, uint32 type,
uint32 type, int32 length, int32 length,
UserInterfaceListener* listener); UserInterfaceListener* listener);
~WatchPromptWindow(); ~WatchPromptWindow();
static WatchPromptWindow* Create(target_addr_t address, uint32 type, static WatchPromptWindow* Create(Architecture* architecture,
target_addr_t address, uint32 type,
int32 length, int32 length,
UserInterfaceListener* listener); UserInterfaceListener* listener);
// throws // throws
@ -45,6 +47,7 @@ private:
target_addr_t fInitialAddress; target_addr_t fInitialAddress;
uint32 fInitialType; uint32 fInitialType;
int32 fInitialLength; int32 fInitialLength;
Architecture* fArchitecture;
BTextControl* fAddressInput; BTextControl* fAddressInput;
BTextControl* fLengthInput; BTextControl* fLengthInput;
BMenuField* fTypeField; BMenuField* fTypeField;