Handle compound node values in variables view.

- If the node we're looking at is a compound node, retrieve its location
  and show that as the value with an indicator to clarify that it's an object.

- Minor tweaks to tooltip format.
- Style cleanups.
This commit is contained in:
Rene Gollent
2012-07-18 18:44:56 -04:00
parent 666222d3fd
commit 3a5779744e
@@ -314,10 +314,12 @@ protected:
targetView); targetView);
return; return;
} }
} else if (value.Type() == B_STRING_TYPE) {
fField.SetString(value.ToString());
} else {
// fall back to drawing an empty string
fField.SetString("");
} }
// fall back to drawing an empty string
fField.SetString("");
fField.SetWidth(Width()); fField.SetWidth(Width());
fColumn.DrawField(&fField, rect, targetView); fColumn.DrawField(&fField, rect, targetView);
} }
@@ -1112,8 +1114,29 @@ VariablesView::VariableTableModel::GetValueAt(void* object, int32 columnIndex,
_value.SetTo(node->Name(), B_VARIANT_DONT_COPY_DATA); _value.SetTo(node->Name(), B_VARIANT_DONT_COPY_DATA);
return true; return true;
case 1: case 1:
if (node->GetValue() == NULL) if (node->GetValue() == NULL) {
ValueLocation* location = node->NodeChild()->Location();
if (location == NULL)
return false;
Type* nodeChildRawType = node->NodeChild()->Node()->GetType()
->ResolveRawType(false);
if (nodeChildRawType->Kind() == TYPE_COMPOUND)
{
if (location->CountPieces() > 1)
return false;
BString data;
ValuePieceLocation piece = location->PieceAt(0);
if (piece.type != VALUE_PIECE_LOCATION_MEMORY)
return false;
data.SetToFormat("[@ 0x%llx]", piece.address);
_value.SetTo(data);
return true;
}
return false; return false;
}
_value.SetTo(node, VALUE_NODE_TYPE); _value.SetTo(node, VALUE_NODE_TYPE);
return true; return true;
@@ -1178,29 +1201,35 @@ VariablesView::VariableTableModel::GetToolTipForTablePath(
return false; return false;
ValueLocation* location = node->NodeChild()->Location(); ValueLocation* location = node->NodeChild()->Location();
BString tipData("Location piece(s):"); BString tipData;
for (int32 i = 0; i < location->CountPieces(); i++) { for (int32 i = 0; i < location->CountPieces(); i++) {
ValuePieceLocation piece = location->PieceAt(i); ValuePieceLocation piece = location->PieceAt(i);
BString pieceData; BString pieceData;
switch (piece.type) { switch (piece.type) {
case VALUE_PIECE_LOCATION_MEMORY: case VALUE_PIECE_LOCATION_MEMORY:
pieceData.SetToFormat("\n\t(%ld): Address: 0x%llx, Size: " pieceData.SetToFormat("(%ld): Address: 0x%llx, Size: "
"%lld bytes", i, piece.address, piece.size); "%lld bytes", i, piece.address, piece.size);
break; break;
case VALUE_PIECE_LOCATION_REGISTER: case VALUE_PIECE_LOCATION_REGISTER:
{ {
Architecture* architecture = fThread->GetTeam()->GetArchitecture(); Architecture* architecture = fThread->GetTeam()->GetArchitecture();
pieceData.SetToFormat("\n\t(%ld): Register (%s)", pieceData.SetToFormat("(%ld): Register (%s)",
i, architecture->Registers()[piece.reg].Name()); i, architecture->Registers()[piece.reg].Name());
break; break;
} }
default: default:
break; break;
} }
tipData += pieceData; tipData += pieceData;
if (i < location->CountPieces() - 1)
tipData += "\n";
} }
if (tipData.IsEmpty())
return false;
*_tip = new(std::nothrow) BTextToolTip(tipData); *_tip = new(std::nothrow) BTextToolTip(tipData);
if (*_tip == NULL) if (*_tip == NULL)
return false; return false;