Debugger: add Inspect context item to Registers view.

- Allows one to treat the value of a register as a memory
  address and jump directly to inspecting said address.
This commit is contained in:
Rene Gollent
2013-09-14 17:55:33 +02:00
parent 20c5fc4aa6
commit 729075a5e8
2 changed files with 53 additions and 1 deletions
@@ -1,6 +1,6 @@
/*
* Copyright 2009-2012, Ingo Weinhold, [email protected].
* Copyright 2011, Rene Gollent, [email protected].
* Copyright 2011-2013, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License.
*/
@@ -11,12 +11,17 @@
#include <new>
#include <ControlLook.h>
#include <MenuItem.h>
#include <PopUpMenu.h>
#include <Window.h>
#include "table/TableColumns.h"
#include "Architecture.h"
#include "AutoDeleter.h"
#include "CpuState.h"
#include "GuiSettingsUtils.h"
#include "MessageCodes.h"
#include "Register.h"
#include "UiUtils.h"
@@ -229,6 +234,48 @@ RegistersView::TableRowInvoked(Table* table, int32 rowIndex)
}
void
RegistersView::TableCellMouseDown(Table* table, int32 rowIndex,
int32 columnIndex, BPoint screenWhere, uint32 buttons)
{
if ((buttons & B_SECONDARY_MOUSE_BUTTON) == 0)
return;
BVariant value;
if (!fRegisterTableModel->GetValueAt(rowIndex, columnIndex, value))
return;
BPopUpMenu* menu = new(std::nothrow)BPopUpMenu("Options");
if (menu == NULL)
return;
ObjectDeleter<BPopUpMenu> menuDeleter(menu);
BMessage* message = new(std::nothrow)BMessage(MSG_SHOW_INSPECTOR_WINDOW);
if (message == NULL)
return;
message->AddUInt64("address", value.ToUInt64());
ObjectDeleter<BMessage> messageDeleter(message);
BMenuItem* item = new(std::nothrow)BMenuItem("Inspect", message);
if (item == NULL)
return;
messageDeleter.Detach();
ObjectDeleter<BMenuItem> itemDeleter(item);
if (!menu->AddItem(item))
return;
itemDeleter.Detach();
menu->SetTargetForItems(Window());
menuDeleter.Detach();
BRect mouseRect(screenWhere, screenWhere);
mouseRect.InsetBy(-4.0, -4.0);
menu->Go(screenWhere, true, false, mouseRect, true);
}
void
RegistersView::_Init()
{
@@ -1,5 +1,6 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Copyright 2013, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef REGISTERS_VIEW_H
@@ -35,6 +36,10 @@ private:
// TableListener
virtual void TableRowInvoked(Table* table, int32 rowIndex);
virtual void TableCellMouseDown(Table* table, int32 rowIndex,
int32 columnIndex, BPoint screenWhere,
uint32 buttons);
void _Init();
private: