Skip to content

Commit

Permalink
Debugger: Add page protection indicator to inspector.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
anevilyak committed May 23, 2015
1 parent 82bf490 commit 5474c67
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Expand Up @@ -14,6 +14,7 @@
#include <ControlLook.h>
#include <LayoutBuilder.h>
#include <ScrollView.h>
#include <StringView.h>
#include <TextControl.h>

#include "Architecture.h"
Expand All @@ -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),
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
}
@@ -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
Expand All @@ -18,6 +18,7 @@
class BButton;
class BMenuField;
class BMessenger;
class BStringView;
class BTextControl;
class GuiTeamUiSettings;
class SourceLanguage;
Expand Down Expand Up @@ -75,12 +76,16 @@ class InspectorWindow : public BWindow, private Team::Listener,
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;
Expand Down

0 comments on commit 5474c67

Please sign in to comment.