Ticket #8286: debugger_tooltip.2.patch

File debugger_tooltip.2.patch, 7.7 KB (added by anevilyak, 12 years ago)

Implements support for tooltips and showing addresses of compound address nodes as value.

  • src/apps/debuganalyzer/gui/table/TreeTable.cpp

    diff --git a/src/apps/debuganalyzer/gui/table/TreeTable.cpp b/src/apps/debuganalyzer/gui/table/TreeTable.cpp
    index 0c20843..851342a 100644
    a b  
    11/*
    22 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
     3 * Copyright 2012, Rene Gollent, rene@gollent.com.
    34 * Distributed under the terms of the MIT License.
    45 */
    56
    TreeTableModel::NotifyNodesChanged(const TreeTablePath& path, int32 childIndex,  
    226227}
    227228
    228229
     230// #pragma mark - TreeTableToolTipProvider
     231
     232
     233TreeTableToolTipProvider::~TreeTableToolTipProvider()
     234{
     235}
     236
     237
    229238// #pragma mark - TreeTableListener
    230239
    231240
    TreeTable::TreeTable(const char* name, uint32 flags, border_style borderStyle,  
    650659    :
    651660    AbstractTable(name, flags, borderStyle, showHorizontalScrollbar),
    652661    fModel(NULL),
     662    fToolTipProvider(NULL),
    653663    fRootNode(NULL),
    654664    fSelectionModel(this),
    655665    fIgnoreSelectionChange(0)
    TreeTable::SetTreeTableModel(TreeTableModel* model)  
    731741}
    732742
    733743
     744void
     745TreeTable::SetToolTipProvider(TreeTableToolTipProvider* toolTipProvider)
     746{
     747    fToolTipProvider = toolTipProvider;
     748}
     749
     750
    734751TreeTableSelectionModel*
    735752TreeTable::SelectionModel()
    736753{
    TreeTable::RemoveTreeTableListener(TreeTableListener* listener)  
    810827}
    811828
    812829
     830bool
     831TreeTable::GetToolTipAt(BPoint point, BToolTip** _tip)
     832{
     833    if (fToolTipProvider == NULL)
     834        return AbstractTable::GetToolTipAt(point, _tip);
     835
     836    // get the table row
     837    BRow* row = RowAt(point);
     838    if (row == NULL)
     839        return AbstractTable::GetToolTipAt(point, _tip);
     840
     841    TreeTableRow* treeRow = dynamic_cast<TreeTableRow*>(row);
     842    // get the table column
     843    BColumn* column = ColumnAt(point);
     844
     845    int32 columnIndex = column != NULL ? column->LogicalFieldNum() : -1;
     846
     847    TreeTablePath path;
     848    _GetPathForNode(treeRow->Node(), path);
     849
     850    return fToolTipProvider->GetToolTipForTablePath(path, columnIndex,
     851        _tip);
     852}
     853
     854
    813855void
    814856TreeTable::SelectionChanged()
    815857{
  • src/apps/debuganalyzer/gui/table/TreeTable.h

    diff --git a/src/apps/debuganalyzer/gui/table/TreeTable.h b/src/apps/debuganalyzer/gui/table/TreeTable.h
    index a475869..b006e08 100644
    a b  
    11/*
    22 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
     3 * Copyright 2012, Rene Gollent, rene@gollent.com.
    34 * Distributed under the terms of the MIT License.
    45 */
    56#ifndef TREE_TABLE_H
    private:  
    122123};
    123124
    124125
     126class TreeTableToolTipProvider {
     127public:
     128    virtual                     ~TreeTableToolTipProvider();
     129
     130    virtual bool                GetToolTipForTablePath(
     131                                    const TreeTablePath& path,
     132                                    int32 columnIndex, BToolTip** _tip) = 0;
     133                                    // columnIndex can be -1, if not in a column
     134};
     135
     136
    125137class TreeTableListener {
    126138public:
    127139    virtual                     ~TreeTableListener();
    public:  
    157169            bool                SetTreeTableModel(TreeTableModel* model);
    158170            TreeTableModel*     GetTreeTableModel() const   { return fModel; }
    159171
     172            void                SetToolTipProvider(
     173                                    TreeTableToolTipProvider* toolTipProvider);
     174            TreeTableToolTipProvider* ToolTipProvider() const
     175                                    { return fToolTipProvider; }
     176
    160177            TreeTableSelectionModel* SelectionModel();
    161178
    162179            void                SelectNode(const TreeTablePath& path,
    public:  
    177194                                    TreeTableListener* listener);
    178195
    179196protected:
     197    virtual bool                GetToolTipAt(BPoint point, BToolTip** _tip);
     198
    180199    virtual void                SelectionChanged();
    181200
    182201    virtual AbstractColumn*     CreateColumn(TableColumn* column);
    private:  
    226245
    227246private:
    228247            TreeTableModel*     fModel;
     248            TreeTableToolTipProvider* fToolTipProvider;
    229249            TreeTableNode*      fRootNode;
    230250            TreeTableSelectionModel fSelectionModel;
    231251            ListenerList        fListeners;
  • src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp

    diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
    index 04ad5d4..ece5836 100644
    a b  
    1313
    1414#include <Looper.h>
    1515#include <PopUpMenu.h>
     16#include <ToolTip.h>
    1617
    1718#include <AutoDeleter.h>
    1819#include <AutoLocker.h>
     
    2526#include "FunctionInstance.h"
    2627#include "GUISettingsUtils.h"
    2728#include "MessageCodes.h"
     29#include "Register.h"
    2830#include "SettingsMenu.h"
    2931#include "StackFrame.h"
    3032#include "StackFrameValues.h"
    protected:  
    345347// #pragma mark - VariableTableModel
    346348
    347349
    348 class VariablesView::VariableTableModel : public TreeTableModel {
     350class VariablesView::VariableTableModel : public TreeTableModel,
     351    public TreeTableToolTipProvider {
    349352public:
    350353                                VariableTableModel();
    351354                                ~VariableTableModel();
    public:  
    379382            void                NotifyNodeChanged(ModelNode* node);
    380383            void                NotifyNodeHidden(ModelNode* node);
    381384
     385    virtual bool                GetToolTipForTablePath(
     386                                    const TreeTablePath& path,
     387                                    int32 columnIndex, BToolTip** _tip);
     388
    382389private:
    383390            struct NodeHashDefinition {
    384391                typedef ValueNodeChild* KeyType;
    VariablesView::VariableTableModel::NotifyNodeHidden(ModelNode* node)  
    11591166}
    11601167
    11611168
     1169bool
     1170VariablesView::VariableTableModel::GetToolTipForTablePath(
     1171    const TreeTablePath& path, int32 columnIndex, BToolTip** _tip)
     1172{
     1173    ModelNode* node = (ModelNode*)NodeForPath(path);
     1174    if (node == NULL)
     1175        return false;
     1176
     1177    if (node->NodeChild()->LocationResolutionState() != B_OK)
     1178        return false;
     1179
     1180    ValueLocation* location = node->NodeChild()->Location();
     1181    BString tipData("Location piece(s):");
     1182    for (int32 i = 0; i < location->CountPieces(); i++) {
     1183        ValuePieceLocation piece = location->PieceAt(i);
     1184        BString pieceData;
     1185        switch (piece.type) {
     1186        case VALUE_PIECE_LOCATION_MEMORY:
     1187            pieceData.SetToFormat("\n\t(%ld): Address: 0x%llx, Size: "
     1188                "%lld bytes", i, piece.address, piece.size);
     1189            break;
     1190        case VALUE_PIECE_LOCATION_REGISTER:
     1191        {
     1192            Architecture* architecture = fThread->GetTeam()->GetArchitecture();
     1193            pieceData.SetToFormat("\n\t(%ld): Register (%s)",
     1194                i, architecture->Registers()[piece.reg].Name());
     1195
     1196            break;
     1197        }
     1198        default:
     1199            break;
     1200        }
     1201        tipData += pieceData;
     1202    }
     1203
     1204    *_tip = new(std::nothrow) BTextToolTip(tipData);
     1205    if (*_tip == NULL)
     1206        return false;
     1207
     1208    return true;
     1209}
     1210
     1211
    11621212status_t
    11631213VariablesView::VariableTableModel::_AddNode(Variable* variable,
    11641214    ModelNode* parent, ValueNodeChild* nodeChild, bool isPresentationNode,
    VariablesView::_Init()  
    17341784    if (fVariableTableModel->Init() != B_OK)
    17351785        throw std::bad_alloc();
    17361786    fVariableTable->SetTreeTableModel(fVariableTableModel);
     1787    fVariableTable->SetToolTipProvider(fVariableTableModel);
    17371788
    17381789    fContainerListener = new ContainerListener(this);
    17391790    fVariableTableModel->SetContainerListener(fContainerListener);
  • src/apps/debugger/value/value_nodes/CompoundValueNode.cpp

    diff --git a/src/apps/debugger/value/value_nodes/CompoundValueNode.cpp b/src/apps/debugger/value/value_nodes/CompoundValueNode.cpp
    index ee375de..80cec89 100644
    a b  
    11/*
     2 * Copyright 2012, Rene Gollent, rene@gollent.com.
    23 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
    34 * Distributed under the terms of the MIT License.
    45 */
     
    89
    910#include <new>
    1011
     12#include "AddressValue.h"
    1113#include "Architecture.h"
    1214#include "IntegerValue.h"
    1315#include "Tracing.h"
    CompoundValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,  
    186188    location->AcquireReference();
    187189    _location = location;
    188190    _value = NULL;
     191    if (location->CountPieces() == 1) {
     192        ValuePieceLocation piece = location->PieceAt(0);
     193        if (piece.type == VALUE_PIECE_LOCATION_MEMORY) {
     194            _value = new(std::nothrow) AddressValue(piece.address);
     195            if (_value == NULL)
     196                return B_NO_MEMORY;
     197        }
     198    }
     199
    189200    return B_OK;
    190201}
    191202