mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Display the memory changes in different color in the memory view.
This commit is contained in:
parent
16803793a6
commit
83ea6524dc
6 changed files with 186 additions and 18 deletions
|
@ -1,3 +1,11 @@
|
|||
2002-10-20 Mikhail Khodjaiants
|
||||
Display the memory changes in different color in the memory view.
|
||||
* MemoryControlArea.java
|
||||
* MemoryPresentation.java
|
||||
* MemoryText.java
|
||||
* MemoryViewer.java
|
||||
* MemoryViewEventHandler.java
|
||||
|
||||
2002-10-18 Mikhail Khodjaiants
|
||||
Implementing the memory view support:
|
||||
Images for the view's actions:
|
||||
|
|
|
@ -174,7 +174,7 @@ public class MemoryControlArea extends Composite
|
|||
refresh();
|
||||
}
|
||||
|
||||
private void refresh()
|
||||
protected void refresh()
|
||||
{
|
||||
fAddressText.setText( ( getPresentation() != null ) ? getPresentation().getAddressExpression() : "" );
|
||||
fMemoryText.refresh();
|
||||
|
@ -244,6 +244,9 @@ public class MemoryControlArea extends Composite
|
|||
getNumberOfColumns(),
|
||||
getPaddingChar() ) );
|
||||
getPresentation().setMemoryBlock( getMemoryBlock() );
|
||||
|
||||
//getMemoryBlock().setFrozen( false );
|
||||
|
||||
}
|
||||
setMemoryTextState();
|
||||
}
|
||||
|
|
|
@ -101,17 +101,35 @@ public class MemoryPresentation
|
|||
|
||||
public Point[] getAddressZones()
|
||||
{
|
||||
return (Point[])fAddressZones.toArray( new Point[0] );
|
||||
return (Point[])fAddressZones.toArray( new Point[fAddressZones.size()] );
|
||||
}
|
||||
|
||||
public Point[] getChangedZones()
|
||||
{
|
||||
return (Point[])fChangedZones.toArray( new Point[0] );
|
||||
fChangedZones.clear();
|
||||
Long[] changedAddresses = getChangedAddresses();
|
||||
for ( int i = 0; i < changedAddresses.length; ++i )
|
||||
{
|
||||
int dataOffset = getDataItemOffsetByAddress( changedAddresses[i] );
|
||||
if ( dataOffset != -1 )
|
||||
{
|
||||
fChangedZones.add( new Point( dataOffset, dataOffset + getDataItemLength() - 1 ) );
|
||||
}
|
||||
if ( displayASCII() )
|
||||
{
|
||||
int asciiOffset = getAsciiOffsetByAddress( changedAddresses[i] );
|
||||
if ( asciiOffset != -1 )
|
||||
{
|
||||
fChangedZones.add( new Point( asciiOffset, asciiOffset ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
return (Point[])fChangedZones.toArray( new Point[fChangedZones.size()] );
|
||||
}
|
||||
|
||||
public Point[] getDirtyZones()
|
||||
{
|
||||
return (Point[])fDirtyZones.toArray( new Point[0] );
|
||||
return (Point[])fDirtyZones.toArray( new Point[fDirtyZones.size()] );
|
||||
}
|
||||
|
||||
public String getStartAddress()
|
||||
|
@ -361,4 +379,61 @@ public class MemoryPresentation
|
|||
return getMemoryBlock().getFormat();
|
||||
return -1;
|
||||
}
|
||||
|
||||
private Long[] getChangedAddresses()
|
||||
{
|
||||
return ( getMemoryBlock() != null ) ? getMemoryBlock().getChangedAddresses() : new Long[0];
|
||||
}
|
||||
|
||||
private int getDataItemOffsetByAddress( Long address )
|
||||
{
|
||||
if ( getMemoryBlock() != null )
|
||||
{
|
||||
IFormattedMemoryBlockRow[] rows = getMemoryBlock().getRows();
|
||||
for ( int i = 0; i < rows.length; ++i )
|
||||
{
|
||||
int wordSize = getMemoryBlock().getWordSize();
|
||||
int numberOfColumns = getMemoryBlock().getNumberOfColumns();
|
||||
if ( address.longValue() >= rows[i].getAddress() &&
|
||||
address.longValue() < rows[i].getAddress() + (wordSize * numberOfColumns) )
|
||||
{
|
||||
for ( int j = 1; j < numberOfColumns; ++j )
|
||||
{
|
||||
if ( address.longValue() >= rows[i].getAddress() + ((j - 1) * wordSize) &&
|
||||
address.longValue() < rows[i].getAddress() + (j * wordSize) )
|
||||
{
|
||||
return (i * getRowLength()) + ((j - 1) * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS)) + getAddressLength() + INTERVAL_BETWEEN_ADDRESS_AND_DATA;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int getAsciiOffsetByAddress( Long address )
|
||||
{
|
||||
if ( getMemoryBlock() != null )
|
||||
{
|
||||
IFormattedMemoryBlockRow[] rows = getMemoryBlock().getRows();
|
||||
if ( rows.length > 0 )
|
||||
{
|
||||
IFormattedMemoryBlockRow firstRow = rows[0];
|
||||
IFormattedMemoryBlockRow lastRow = rows[rows.length - 1];
|
||||
if ( address.longValue() >= firstRow.getAddress() && address.longValue() <= lastRow.getAddress() )
|
||||
{
|
||||
int asciiOffset = (int)(address.longValue() - firstRow.getAddress());
|
||||
int asciiRowlength = getMemoryBlock().getWordSize() * getMemoryBlock().getNumberOfColumns();
|
||||
int numberOfRows = asciiOffset / asciiRowlength;
|
||||
int offsetInRow = asciiOffset % asciiRowlength;
|
||||
return (numberOfRows * getRowLength()) +
|
||||
getAddressLength() + INTERVAL_BETWEEN_ADDRESS_AND_DATA +
|
||||
(getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS) * getMemoryBlock().getNumberOfColumns() +
|
||||
INTERVAL_BETWEEN_DATA_AND_ASCII + offsetInRow;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,26 +99,31 @@ public class MemoryText
|
|||
fText.setBackground( getBackgroundColor() );
|
||||
fText.setForeground( getForegroundColor() );
|
||||
fText.setText( fPresentation.getText() );
|
||||
List list = new LinkedList();
|
||||
Point[] zones = fPresentation.getChangedZones();
|
||||
for ( int i = 0; i < zones.length; ++i )
|
||||
list.add( new StyleRange( zones[i].x,
|
||||
zones[i].y - zones[i].x + 1,
|
||||
getChangedColor(),
|
||||
getBackgroundColor() ) );
|
||||
{
|
||||
fText.setStyleRange( new StyleRange( zones[i].x,
|
||||
zones[i].y - zones[i].x + 1,
|
||||
getChangedColor(),
|
||||
getBackgroundColor() ) );
|
||||
|
||||
}
|
||||
zones = fPresentation.getAddressZones();
|
||||
for ( int i = 0; i < zones.length; ++i )
|
||||
list.add( new StyleRange( zones[i].x,
|
||||
zones[i].y - zones[i].x + 1,
|
||||
getAddressColor(),
|
||||
getBackgroundColor() ) );
|
||||
{
|
||||
fText.setStyleRange( new StyleRange( zones[i].x,
|
||||
zones[i].y - zones[i].x + 1,
|
||||
getAddressColor(),
|
||||
getBackgroundColor() ) );
|
||||
}
|
||||
zones = fPresentation.getDirtyZones();
|
||||
for ( int i = 0; i < zones.length; ++i )
|
||||
list.add( new StyleRange( zones[i].x,
|
||||
zones[i].y - zones[i].x + 1,
|
||||
getDirtyColor(),
|
||||
getBackgroundColor() ) );
|
||||
fText.setStyleRanges( (StyleRange[])list.toArray( new StyleRange[list.size()] ) );
|
||||
{
|
||||
fText.setStyleRange( new StyleRange( zones[i].x,
|
||||
zones[i].y - zones[i].x + 1,
|
||||
getDirtyColor(),
|
||||
getBackgroundColor() ) );
|
||||
}
|
||||
fText.redraw();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.views.memory;
|
||||
|
||||
import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler;
|
||||
import org.eclipse.debug.core.DebugEvent;
|
||||
import org.eclipse.debug.ui.AbstractDebugView;
|
||||
|
@ -32,5 +33,43 @@ public class MemoryViewEventHandler extends AbstractDebugEventHandler
|
|||
*/
|
||||
protected void doHandleDebugEvents( DebugEvent[] events )
|
||||
{
|
||||
for( int i = 0; i < events.length; i++ )
|
||||
{
|
||||
DebugEvent event = events[i];
|
||||
switch( event.getKind() )
|
||||
{
|
||||
case DebugEvent.CHANGE:
|
||||
if ( event.getSource() instanceof IFormattedMemoryBlock && event.getDetail() == DebugEvent.CONTENT )
|
||||
{
|
||||
refresh( event.getSource() );
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the given element in the viewer - must be called in UI thread.
|
||||
*/
|
||||
protected void refresh( Object element )
|
||||
{
|
||||
if ( isAvailable() )
|
||||
{
|
||||
getView().showViewer();
|
||||
((MemoryViewer)getViewer()).refresh( element );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the viewer - must be called in UI thread.
|
||||
*/
|
||||
public void refresh()
|
||||
{
|
||||
if ( isAvailable() )
|
||||
{
|
||||
getView().showViewer();
|
||||
getViewer().refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
package org.eclipse.cdt.debug.internal.ui.views.memory;
|
||||
|
||||
import org.eclipse.cdt.debug.core.ICMemoryManager;
|
||||
import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
import org.eclipse.jface.viewers.ContentViewer;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
|
@ -92,7 +93,23 @@ public class MemoryViewer extends ContentViewer
|
|||
* @see org.eclipse.jface.viewers.Viewer#refresh()
|
||||
*/
|
||||
public void refresh()
|
||||
{
|
||||
CTabItem[] tabItems = fTabFolder.getItems();
|
||||
for ( int i = 0; i < tabItems.length; ++i )
|
||||
if ( tabItems[i].getControl() instanceof MemoryControlArea )
|
||||
((MemoryControlArea)tabItems[i].getControl()).refresh();
|
||||
}
|
||||
|
||||
public void refresh( Object element )
|
||||
{
|
||||
if ( element instanceof IFormattedMemoryBlock )
|
||||
{
|
||||
MemoryControlArea mca = getMemoryControlArea( (IFormattedMemoryBlock)element );
|
||||
if ( mca != null )
|
||||
{
|
||||
mca.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -120,4 +137,25 @@ public class MemoryViewer extends ContentViewer
|
|||
{
|
||||
return fTabFolder;
|
||||
}
|
||||
|
||||
private MemoryControlArea getMemoryControlArea( int index )
|
||||
{
|
||||
CTabItem item = fTabFolder.getItem( index );
|
||||
return ( item != null ) ? (MemoryControlArea)item.getControl() : null;
|
||||
}
|
||||
|
||||
private MemoryControlArea getMemoryControlArea( IFormattedMemoryBlock block )
|
||||
{
|
||||
CTabItem[] tabItems = fTabFolder.getItems();
|
||||
for ( int i = 0; i < tabItems.length; ++i )
|
||||
{
|
||||
if ( tabItems[i].getControl() instanceof MemoryControlArea &&
|
||||
block != null &&
|
||||
block.equals( ((MemoryControlArea)tabItems[i].getControl()).getMemoryBlock() ) )
|
||||
{
|
||||
return (MemoryControlArea)tabItems[i].getControl();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue