* Re-enable 64-bit representation.
* Clean up various drawing issues in the memory view's rendering code that were causing scrolling artifacts. * Fix stupid mistake whereby the data being visualized was in fact from the Debugger's address space, and not the target team's. This would likely also have caused some crashes. * Highlight the data pointed to by the current target address. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42212 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
6a80f55b25
commit
98a61309e7
@ -81,13 +81,11 @@ InspectorWindow::_Init()
|
||||
message->ReplaceInt32("mode", HexMode32BitInt);
|
||||
item = new BMenuItem("32-bit integer", message, '3');
|
||||
hexMenu->AddItem(item);
|
||||
// TODO: enable once problem with 64-bit hex string formatting is found
|
||||
/*
|
||||
message = new BMessage(*message);
|
||||
message->ReplaceInt32("mode", HexMode64BitInt);
|
||||
item = new BMenuItem("64-bit integer", message, '3');
|
||||
item = new BMenuItem("64-bit integer", message, '4');
|
||||
hexMenu->AddItem(item);
|
||||
*/
|
||||
|
||||
|
||||
BMenu* textMenu = new BMenu("Text Mode");
|
||||
message = new BMessage(MSG_SET_TEXT_MODE);
|
||||
|
@ -90,15 +90,15 @@ MemoryView::AttachedToWindow()
|
||||
fCharWidth = be_fixed_font->StringWidth("a");
|
||||
font_height fontHeight;
|
||||
be_fixed_font->GetHeight(&fontHeight);
|
||||
fLineHeight = fontHeight.ascent + fontHeight.descent
|
||||
+ fontHeight.leading;
|
||||
fLineHeight = ceilf(fontHeight.ascent + fontHeight.descent
|
||||
+ fontHeight.leading);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MemoryView::Draw(BRect rect)
|
||||
{
|
||||
BView::Draw(rect);
|
||||
rect = Bounds();
|
||||
|
||||
float divider = 9 * fCharWidth;
|
||||
StrokeLine(BPoint(divider, rect.top),
|
||||
@ -107,9 +107,10 @@ MemoryView::Draw(BRect rect)
|
||||
if (fTargetBlock == NULL)
|
||||
return;
|
||||
|
||||
uint32 hexBlockSize = 1 << fHexMode;
|
||||
uint32 hexBlockSize = (1 << fHexMode) + 1;
|
||||
uint32 blockByteSize = hexBlockSize / 2;
|
||||
if (fHexMode != HexModeNone && fTextMode != TextModeNone) {
|
||||
divider += (fHexBlocksPerLine * (hexBlockSize + 1) + 1) * fCharWidth;
|
||||
divider += (fHexBlocksPerLine * hexBlockSize + 1) * fCharWidth;
|
||||
StrokeLine(BPoint(divider, rect.top),
|
||||
BPoint(divider, rect.bottom));
|
||||
}
|
||||
@ -117,29 +118,32 @@ MemoryView::Draw(BRect rect)
|
||||
char buffer[32];
|
||||
char textbuffer[512];
|
||||
|
||||
int32 startLine = int32(rect.top / fLineHeight) - 1;
|
||||
if (startLine < 0)
|
||||
startLine = 0;
|
||||
int32 endLine = int32(rect.bottom / fLineHeight) + 1;
|
||||
int32 startByte = fHexBlocksPerLine * hexBlockSize * startLine;
|
||||
const char* currentAddress = (const char*)(fTargetBlock->BaseAddress()
|
||||
+ startByte);
|
||||
const char* maxAddress = (const char*)(fTargetBlock->BaseAddress()
|
||||
int32 startLine = int32(rect.top / fLineHeight);
|
||||
const char* currentAddress = (const char*)(fTargetBlock->Data()
|
||||
+ fHexBlocksPerLine * blockByteSize * startLine);
|
||||
const char* maxAddress = (const char*)(fTargetBlock->Data()
|
||||
+ fTargetBlock->Size());
|
||||
const char* targetAddress = (const char *)fTargetBlock->Data()
|
||||
+ fTargetAddress - fTargetBlock->BaseAddress();
|
||||
BPoint drawPoint(1.0, (startLine + 1) * fLineHeight);
|
||||
int32 currentBlocksPerLine = fHexBlocksPerLine;
|
||||
int32 currentCharsPerLine = fTextCharsPerLine;
|
||||
rgb_color addressColor = tint_color(HighColor(), B_LIGHTEN_1_TINT);
|
||||
rgb_color dataColor = HighColor();
|
||||
for (int32 i = startLine; i <= endLine && currentAddress < maxAddress;
|
||||
i++, drawPoint.y += fLineHeight) {
|
||||
font_height fh;
|
||||
GetFontHeight(&fh);
|
||||
uint32 lineAddress = (uint32)fTargetBlock->BaseAddress() + startLine
|
||||
* currentCharsPerLine;
|
||||
for (; currentAddress < maxAddress && drawPoint.y < rect.bottom
|
||||
+ fLineHeight; drawPoint.y += fLineHeight) {
|
||||
drawPoint.x = 1.0;
|
||||
snprintf(buffer, sizeof(buffer), "%" B_PRIx32,
|
||||
(uint32)currentAddress);
|
||||
SetHighColor(addressColor);
|
||||
lineAddress);
|
||||
PushState();
|
||||
SetHighColor(tint_color(HighColor(), B_LIGHTEN_1_TINT));
|
||||
DrawString(buffer, drawPoint);
|
||||
drawPoint.x += fCharWidth * 10;
|
||||
SetHighColor(dataColor);
|
||||
PopState();
|
||||
|
||||
if (fHexMode != HexModeNone) {
|
||||
if (currentAddress + (currentBlocksPerLine * hexBlockSize)
|
||||
@ -150,12 +154,29 @@ MemoryView::Draw(BRect rect)
|
||||
}
|
||||
|
||||
for (int32 j = 0; j < currentBlocksPerLine; j++) {
|
||||
const char* blockAddress = currentAddress + (j
|
||||
* blockByteSize);
|
||||
_GetNextHexBlock(buffer,
|
||||
std::min(hexBlockSize + 1, sizeof(buffer)),
|
||||
currentAddress + (j * hexBlockSize / 2));
|
||||
std::min(hexBlockSize, sizeof(buffer)),
|
||||
blockAddress);
|
||||
DrawString(buffer, drawPoint);
|
||||
drawPoint.x += fCharWidth * (hexBlockSize + 1);
|
||||
if (targetAddress >= blockAddress && targetAddress <
|
||||
blockAddress + blockByteSize) {
|
||||
PushState();
|
||||
SetHighColor(B_TRANSPARENT_COLOR);
|
||||
SetDrawingMode(B_OP_INVERT);
|
||||
FillRect(BRect(drawPoint.x, drawPoint.y - fh.ascent,
|
||||
drawPoint.x + (hexBlockSize - 1) * fCharWidth,
|
||||
drawPoint.y + fh.descent));
|
||||
PopState();
|
||||
}
|
||||
|
||||
drawPoint.x += fCharWidth * hexBlockSize;
|
||||
}
|
||||
|
||||
if (currentBlocksPerLine < fHexBlocksPerLine)
|
||||
drawPoint.x += fCharWidth * hexBlockSize
|
||||
* (fHexBlocksPerLine - currentBlocksPerLine);
|
||||
}
|
||||
if (fTextMode != TextModeNone) {
|
||||
drawPoint.x += fCharWidth;
|
||||
@ -166,11 +187,30 @@ MemoryView::Draw(BRect rect)
|
||||
}
|
||||
textbuffer[fTextCharsPerLine] = '\0';
|
||||
DrawString(textbuffer, drawPoint);
|
||||
if (targetAddress >= currentAddress && targetAddress
|
||||
< currentAddress + currentCharsPerLine) {
|
||||
PushState();
|
||||
SetHighColor(B_TRANSPARENT_COLOR);
|
||||
SetDrawingMode(B_OP_INVERT);
|
||||
float startX = drawPoint.x + fCharWidth * (targetAddress
|
||||
- currentAddress);
|
||||
float endX = startX;
|
||||
if (fHexMode != HexModeNone)
|
||||
endX += fCharWidth * ((hexBlockSize - 1) / 2);
|
||||
else
|
||||
endX += fCharWidth;
|
||||
FillRect(BRect(startX, drawPoint.y - fh.ascent, endX,
|
||||
drawPoint.y + fh.descent));
|
||||
PopState();
|
||||
}
|
||||
}
|
||||
if (currentBlocksPerLine > 0)
|
||||
currentAddress += currentBlocksPerLine * hexBlockSize / 2;
|
||||
else
|
||||
if (currentBlocksPerLine > 0) {
|
||||
currentAddress += currentBlocksPerLine * blockByteSize;
|
||||
lineAddress += currentBlocksPerLine * blockByteSize;
|
||||
} else {
|
||||
currentAddress += fTextCharsPerLine;
|
||||
lineAddress += fTextCharsPerLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,7 +305,7 @@ MemoryView::_RecalcScrollBars()
|
||||
fHexBlocksPerLine = nybblesPerLine / sizeFactor;
|
||||
fHexBlocksPerLine &= ~1;
|
||||
if (fTextMode != TextModeNone)
|
||||
fTextCharsPerLine = fHexBlocksPerLine * (hexDigits / 2);
|
||||
fTextCharsPerLine = fHexBlocksPerLine * hexDigits / 2;
|
||||
} else if (fTextMode != TextModeNone)
|
||||
fTextCharsPerLine = int32(textWidth / fCharWidth);
|
||||
|
||||
@ -273,7 +313,7 @@ MemoryView::_RecalcScrollBars()
|
||||
float totalHeight = 0.0;
|
||||
if (fHexBlocksPerLine > 0) {
|
||||
lineCount = fTargetBlock->Size() / (fHexBlocksPerLine
|
||||
* hexDigits);
|
||||
* hexDigits / 2);
|
||||
} else if (fTextCharsPerLine > 0)
|
||||
lineCount = fTargetBlock->Size() / fTextCharsPerLine;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user