* 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:
@@ -81,13 +81,11 @@ InspectorWindow::_Init()
|
|||||||
message->ReplaceInt32("mode", HexMode32BitInt);
|
message->ReplaceInt32("mode", HexMode32BitInt);
|
||||||
item = new BMenuItem("32-bit integer", message, '3');
|
item = new BMenuItem("32-bit integer", message, '3');
|
||||||
hexMenu->AddItem(item);
|
hexMenu->AddItem(item);
|
||||||
// TODO: enable once problem with 64-bit hex string formatting is found
|
|
||||||
/*
|
|
||||||
message = new BMessage(*message);
|
message = new BMessage(*message);
|
||||||
message->ReplaceInt32("mode", HexMode64BitInt);
|
message->ReplaceInt32("mode", HexMode64BitInt);
|
||||||
item = new BMenuItem("64-bit integer", message, '3');
|
item = new BMenuItem("64-bit integer", message, '4');
|
||||||
hexMenu->AddItem(item);
|
hexMenu->AddItem(item);
|
||||||
*/
|
|
||||||
|
|
||||||
BMenu* textMenu = new BMenu("Text Mode");
|
BMenu* textMenu = new BMenu("Text Mode");
|
||||||
message = new BMessage(MSG_SET_TEXT_MODE);
|
message = new BMessage(MSG_SET_TEXT_MODE);
|
||||||
|
|||||||
@@ -90,15 +90,15 @@ MemoryView::AttachedToWindow()
|
|||||||
fCharWidth = be_fixed_font->StringWidth("a");
|
fCharWidth = be_fixed_font->StringWidth("a");
|
||||||
font_height fontHeight;
|
font_height fontHeight;
|
||||||
be_fixed_font->GetHeight(&fontHeight);
|
be_fixed_font->GetHeight(&fontHeight);
|
||||||
fLineHeight = fontHeight.ascent + fontHeight.descent
|
fLineHeight = ceilf(fontHeight.ascent + fontHeight.descent
|
||||||
+ fontHeight.leading;
|
+ fontHeight.leading);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MemoryView::Draw(BRect rect)
|
MemoryView::Draw(BRect rect)
|
||||||
{
|
{
|
||||||
BView::Draw(rect);
|
rect = Bounds();
|
||||||
|
|
||||||
float divider = 9 * fCharWidth;
|
float divider = 9 * fCharWidth;
|
||||||
StrokeLine(BPoint(divider, rect.top),
|
StrokeLine(BPoint(divider, rect.top),
|
||||||
@@ -107,9 +107,10 @@ MemoryView::Draw(BRect rect)
|
|||||||
if (fTargetBlock == NULL)
|
if (fTargetBlock == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32 hexBlockSize = 1 << fHexMode;
|
uint32 hexBlockSize = (1 << fHexMode) + 1;
|
||||||
|
uint32 blockByteSize = hexBlockSize / 2;
|
||||||
if (fHexMode != HexModeNone && fTextMode != TextModeNone) {
|
if (fHexMode != HexModeNone && fTextMode != TextModeNone) {
|
||||||
divider += (fHexBlocksPerLine * (hexBlockSize + 1) + 1) * fCharWidth;
|
divider += (fHexBlocksPerLine * hexBlockSize + 1) * fCharWidth;
|
||||||
StrokeLine(BPoint(divider, rect.top),
|
StrokeLine(BPoint(divider, rect.top),
|
||||||
BPoint(divider, rect.bottom));
|
BPoint(divider, rect.bottom));
|
||||||
}
|
}
|
||||||
@@ -117,29 +118,32 @@ MemoryView::Draw(BRect rect)
|
|||||||
char buffer[32];
|
char buffer[32];
|
||||||
char textbuffer[512];
|
char textbuffer[512];
|
||||||
|
|
||||||
int32 startLine = int32(rect.top / fLineHeight) - 1;
|
int32 startLine = int32(rect.top / fLineHeight);
|
||||||
if (startLine < 0)
|
const char* currentAddress = (const char*)(fTargetBlock->Data()
|
||||||
startLine = 0;
|
+ fHexBlocksPerLine * blockByteSize * startLine);
|
||||||
int32 endLine = int32(rect.bottom / fLineHeight) + 1;
|
const char* maxAddress = (const char*)(fTargetBlock->Data()
|
||||||
int32 startByte = fHexBlocksPerLine * hexBlockSize * startLine;
|
|
||||||
const char* currentAddress = (const char*)(fTargetBlock->BaseAddress()
|
|
||||||
+ startByte);
|
|
||||||
const char* maxAddress = (const char*)(fTargetBlock->BaseAddress()
|
|
||||||
+ fTargetBlock->Size());
|
+ fTargetBlock->Size());
|
||||||
|
const char* targetAddress = (const char *)fTargetBlock->Data()
|
||||||
|
+ fTargetAddress - fTargetBlock->BaseAddress();
|
||||||
BPoint drawPoint(1.0, (startLine + 1) * fLineHeight);
|
BPoint drawPoint(1.0, (startLine + 1) * fLineHeight);
|
||||||
int32 currentBlocksPerLine = fHexBlocksPerLine;
|
int32 currentBlocksPerLine = fHexBlocksPerLine;
|
||||||
int32 currentCharsPerLine = fTextCharsPerLine;
|
int32 currentCharsPerLine = fTextCharsPerLine;
|
||||||
rgb_color addressColor = tint_color(HighColor(), B_LIGHTEN_1_TINT);
|
rgb_color addressColor = tint_color(HighColor(), B_LIGHTEN_1_TINT);
|
||||||
rgb_color dataColor = HighColor();
|
rgb_color dataColor = HighColor();
|
||||||
for (int32 i = startLine; i <= endLine && currentAddress < maxAddress;
|
font_height fh;
|
||||||
i++, drawPoint.y += fLineHeight) {
|
GetFontHeight(&fh);
|
||||||
|
uint32 lineAddress = (uint32)fTargetBlock->BaseAddress() + startLine
|
||||||
|
* currentCharsPerLine;
|
||||||
|
for (; currentAddress < maxAddress && drawPoint.y < rect.bottom
|
||||||
|
+ fLineHeight; drawPoint.y += fLineHeight) {
|
||||||
drawPoint.x = 1.0;
|
drawPoint.x = 1.0;
|
||||||
snprintf(buffer, sizeof(buffer), "%" B_PRIx32,
|
snprintf(buffer, sizeof(buffer), "%" B_PRIx32,
|
||||||
(uint32)currentAddress);
|
lineAddress);
|
||||||
SetHighColor(addressColor);
|
PushState();
|
||||||
|
SetHighColor(tint_color(HighColor(), B_LIGHTEN_1_TINT));
|
||||||
DrawString(buffer, drawPoint);
|
DrawString(buffer, drawPoint);
|
||||||
drawPoint.x += fCharWidth * 10;
|
drawPoint.x += fCharWidth * 10;
|
||||||
SetHighColor(dataColor);
|
PopState();
|
||||||
|
|
||||||
if (fHexMode != HexModeNone) {
|
if (fHexMode != HexModeNone) {
|
||||||
if (currentAddress + (currentBlocksPerLine * hexBlockSize)
|
if (currentAddress + (currentBlocksPerLine * hexBlockSize)
|
||||||
@@ -150,12 +154,29 @@ MemoryView::Draw(BRect rect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int32 j = 0; j < currentBlocksPerLine; j++) {
|
for (int32 j = 0; j < currentBlocksPerLine; j++) {
|
||||||
|
const char* blockAddress = currentAddress + (j
|
||||||
|
* blockByteSize);
|
||||||
_GetNextHexBlock(buffer,
|
_GetNextHexBlock(buffer,
|
||||||
std::min(hexBlockSize + 1, sizeof(buffer)),
|
std::min(hexBlockSize, sizeof(buffer)),
|
||||||
currentAddress + (j * hexBlockSize / 2));
|
blockAddress);
|
||||||
DrawString(buffer, drawPoint);
|
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) {
|
if (fTextMode != TextModeNone) {
|
||||||
drawPoint.x += fCharWidth;
|
drawPoint.x += fCharWidth;
|
||||||
@@ -166,11 +187,30 @@ MemoryView::Draw(BRect rect)
|
|||||||
}
|
}
|
||||||
textbuffer[fTextCharsPerLine] = '\0';
|
textbuffer[fTextCharsPerLine] = '\0';
|
||||||
DrawString(textbuffer, drawPoint);
|
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)
|
if (currentBlocksPerLine > 0) {
|
||||||
currentAddress += currentBlocksPerLine * hexBlockSize / 2;
|
currentAddress += currentBlocksPerLine * blockByteSize;
|
||||||
else
|
lineAddress += currentBlocksPerLine * blockByteSize;
|
||||||
|
} else {
|
||||||
currentAddress += fTextCharsPerLine;
|
currentAddress += fTextCharsPerLine;
|
||||||
|
lineAddress += fTextCharsPerLine;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +305,7 @@ MemoryView::_RecalcScrollBars()
|
|||||||
fHexBlocksPerLine = nybblesPerLine / sizeFactor;
|
fHexBlocksPerLine = nybblesPerLine / sizeFactor;
|
||||||
fHexBlocksPerLine &= ~1;
|
fHexBlocksPerLine &= ~1;
|
||||||
if (fTextMode != TextModeNone)
|
if (fTextMode != TextModeNone)
|
||||||
fTextCharsPerLine = fHexBlocksPerLine * (hexDigits / 2);
|
fTextCharsPerLine = fHexBlocksPerLine * hexDigits / 2;
|
||||||
} else if (fTextMode != TextModeNone)
|
} else if (fTextMode != TextModeNone)
|
||||||
fTextCharsPerLine = int32(textWidth / fCharWidth);
|
fTextCharsPerLine = int32(textWidth / fCharWidth);
|
||||||
|
|
||||||
@@ -273,7 +313,7 @@ MemoryView::_RecalcScrollBars()
|
|||||||
float totalHeight = 0.0;
|
float totalHeight = 0.0;
|
||||||
if (fHexBlocksPerLine > 0) {
|
if (fHexBlocksPerLine > 0) {
|
||||||
lineCount = fTargetBlock->Size() / (fHexBlocksPerLine
|
lineCount = fTargetBlock->Size() / (fHexBlocksPerLine
|
||||||
* hexDigits);
|
* hexDigits / 2);
|
||||||
} else if (fTextCharsPerLine > 0)
|
} else if (fTextCharsPerLine > 0)
|
||||||
lineCount = fTargetBlock->Size() / fTextCharsPerLine;
|
lineCount = fTargetBlock->Size() / fTextCharsPerLine;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user