Debugger: Add page protection indicator to inspector.

InspectorWindow:
- We now display a label indicating if the currently inspected block
  is writable or not, so the user knows whether it's possible to modify
  the contents.
This commit is contained in:
Rene Gollent 2015-05-03 22:46:00 -04:00
parent 82bf490fa6
commit 5474c67270
2 changed files with 33 additions and 2 deletions

View File

@ -14,6 +14,7 @@
#include <ControlLook.h>
#include <LayoutBuilder.h>
#include <ScrollView.h>
#include <StringView.h>
#include <TextControl.h>
#include "Architecture.h"
@ -37,11 +38,12 @@ InspectorWindow::InspectorWindow(::Team* team, UserInterfaceListener* listener,
BHandler* target)
:
BWindow(BRect(100, 100, 700, 500), "Inspector", B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS),
B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
fListener(listener),
fAddressInput(NULL),
fHexMode(NULL),
fTextMode(NULL),
fWritableBlockIndicator(NULL),
fMemoryView(NULL),
fCurrentBlock(NULL),
fCurrentAddress(0LL),
@ -163,6 +165,11 @@ InspectorWindow::_Init()
.End()
.Add(scrollView = new BScrollView("memory scroll",
NULL, 0, false, true), 3.0f)
.AddGroup(B_HORIZONTAL)
.Add(fWritableBlockIndicator = new BStringView("writableIndicator",
_GetCurrentWritableIndicator()))
.AddGlue()
.End()
.End();
fHexMode->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@ -514,4 +521,23 @@ InspectorWindow::_SetCurrentBlock(TeamMemoryBlock* block)
fCurrentBlock = block;
fMemoryView->SetTargetAddress(fCurrentBlock, fCurrentAddress);
_UpdateWritableIndicator();
}
void
InspectorWindow::_UpdateWritableIndicator()
{
fWritableBlockIndicator->SetText(_GetCurrentWritableIndicator());
}
const char*
InspectorWindow::_GetCurrentWritableIndicator() const
{
static char buffer[32];
snprintf(buffer, sizeof(buffer), "Writable: %s", fCurrentBlock == NULL
? "N/A" : fCurrentBlock->IsWritable() ? "Yes" : "No");
return buffer;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2011-2014, Rene Gollent, rene@gollent.com. All rights reserved.
* Copyright 2011-2015, Rene Gollent, rene@gollent.com. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef INSPECTOR_WINDOW_H
@ -18,6 +18,7 @@
class BButton;
class BMenuField;
class BMessenger;
class BStringView;
class BTextControl;
class GuiTeamUiSettings;
class SourceLanguage;
@ -75,12 +76,16 @@ private:
void _SetToAddress(target_addr_t address);
void _SetCurrentBlock(TeamMemoryBlock* block);
void _UpdateWritableIndicator();
const char* _GetCurrentWritableIndicator() const;
private:
UserInterfaceListener* fListener;
BTextControl* fAddressInput;
BMenuField* fHexMode;
BMenuField* fEndianMode;
BMenuField* fTextMode;
BStringView* fWritableBlockIndicator;
MemoryView* fMemoryView;
BButton* fPreviousBlockButton;
BButton* fNextBlockButton;