From 5474c672709cc0fa65443dea8a35d95ad13c8a98 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 3 May 2015 22:46:00 -0400 Subject: [PATCH] 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. --- .../gui/inspector_window/InspectorWindow.cpp | 28 ++++++++++++++++++- .../gui/inspector_window/InspectorWindow.h | 7 ++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.cpp b/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.cpp index 1bb68386d08..d3d0d68d9ac 100644 --- a/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.cpp +++ b/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #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; } diff --git a/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.h b/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.h index 039e087b58e..0c320131653 100644 --- a/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.h +++ b/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.h @@ -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 @@ 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;