Lines 11-25
Link Here
|
11 |
|
11 |
|
12 |
package org.eclipse.cdt.debug.internal.ui.views.memory; |
12 |
package org.eclipse.cdt.debug.internal.ui.views.memory; |
13 |
|
13 |
|
|
|
14 |
import java.math.BigInteger; |
14 |
import java.util.Arrays; |
15 |
import java.util.Arrays; |
15 |
import java.util.LinkedList; |
16 |
import java.util.LinkedList; |
16 |
import java.util.List; |
17 |
import java.util.List; |
17 |
|
18 |
|
|
|
19 |
import org.eclipse.cdt.core.IAddress; |
18 |
import org.eclipse.cdt.debug.core.CDebugUtils; |
20 |
import org.eclipse.cdt.debug.core.CDebugUtils; |
19 |
import org.eclipse.cdt.debug.core.ICMemoryManager; |
21 |
import org.eclipse.cdt.debug.core.ICMemoryManager; |
20 |
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock; |
22 |
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock; |
21 |
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlockRow; |
23 |
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlockRow; |
22 |
import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils; |
|
|
23 |
import org.eclipse.debug.core.DebugException; |
24 |
import org.eclipse.debug.core.DebugException; |
24 |
import org.eclipse.swt.graphics.Point; |
25 |
import org.eclipse.swt.graphics.Point; |
25 |
import org.eclipse.swt.widgets.Display; |
26 |
import org.eclipse.swt.widgets.Display; |
Lines 77-83
Link Here
|
77 |
{ |
78 |
{ |
78 |
int offset = sb.length(); |
79 |
int offset = sb.length(); |
79 |
sb.append( getRowText( rows[i] ) ); |
80 |
sb.append( getRowText( rows[i] ) ); |
80 |
fAddressZones.add( new Point( offset, offset + getAddressLength() ) ); |
81 |
fAddressZones.add( new Point( offset, offset + rows[i].getAddress().getCharsNum() ) ); |
81 |
} |
82 |
} |
82 |
return sb.toString(); |
83 |
return sb.toString(); |
83 |
} |
84 |
} |
Lines 104-110
Link Here
|
104 |
public Point[] getChangedZones() |
105 |
public Point[] getChangedZones() |
105 |
{ |
106 |
{ |
106 |
fChangedZones.clear(); |
107 |
fChangedZones.clear(); |
107 |
Long[] changedAddresses = getChangedAddresses(); |
108 |
IAddress[] changedAddresses = getChangedAddresses(); |
108 |
for ( int i = 0; i < changedAddresses.length; ++i ) |
109 |
for ( int i = 0; i < changedAddresses.length; ++i ) |
109 |
{ |
110 |
{ |
110 |
int dataOffset = getDataItemOffsetByAddress( changedAddresses[i] ); |
111 |
int dataOffset = getDataItemOffsetByAddress( changedAddresses[i] ); |
Lines 126-132
Link Here
|
126 |
|
127 |
|
127 |
public String getStartAddress() |
128 |
public String getStartAddress() |
128 |
{ |
129 |
{ |
129 |
return ( fBlock != null ) ? getAddressString( fBlock.getStartAddress() ) : ""; //$NON-NLS-1$ |
130 |
return ( fBlock != null ) ? fBlock.getRealStartAddress().toHexAddressString() : ""; //$NON-NLS-1$ |
130 |
} |
131 |
} |
131 |
|
132 |
|
132 |
public String getAddressExpression() |
133 |
public String getAddressExpression() |
Lines 141-155
Link Here
|
141 |
return new String( chars ); |
142 |
return new String( chars ); |
142 |
} |
143 |
} |
143 |
|
144 |
|
144 |
private String getAddressString( long address ) |
|
|
145 |
{ |
146 |
return CDebugUIUtils.toHexAddressString( address ); |
147 |
} |
148 |
|
149 |
private String getRowText( IFormattedMemoryBlockRow row ) |
145 |
private String getRowText( IFormattedMemoryBlockRow row ) |
150 |
{ |
146 |
{ |
151 |
StringBuffer result = new StringBuffer( getRowLength() ); |
147 |
StringBuffer result = new StringBuffer( getRowLength( ) ); |
152 |
result.append( getAddressString( row.getAddress() ) ); |
148 |
result.append( row.getAddress().toHexAddressString() ); |
153 |
result.append( getInterval( INTERVAL_BETWEEN_ADDRESS_AND_DATA ) ); |
149 |
result.append( getInterval( INTERVAL_BETWEEN_ADDRESS_AND_DATA ) ); |
154 |
String[] items = row.getData(); |
150 |
String[] items = row.getData(); |
155 |
for ( int i = 0; i < items.length; ++i ) |
151 |
for ( int i = 0; i < items.length; ++i ) |
Lines 175-183
Link Here
|
175 |
getDataBytesPerRow() : 0 ) + 1; |
171 |
getDataBytesPerRow() : 0 ) + 1; |
176 |
} |
172 |
} |
177 |
|
173 |
|
178 |
private int getAddressLength() |
174 |
|
179 |
{ |
175 |
private int getAddressLength() { |
180 |
return 10; |
176 |
return fBlock.getRealStartAddress().getCharsNum(); |
181 |
} |
177 |
} |
182 |
|
178 |
|
183 |
private boolean isInAsciiArea( int offset ) |
179 |
private boolean isInAsciiArea( int offset ) |
Lines 293-304
Link Here
|
293 |
return IFormattedMemoryBlock.MEMORY_FORMAT_HEX; |
289 |
return IFormattedMemoryBlock.MEMORY_FORMAT_HEX; |
294 |
} |
290 |
} |
295 |
|
291 |
|
296 |
private Long[] getChangedAddresses() |
292 |
private IAddress[] getChangedAddresses() |
297 |
{ |
293 |
{ |
298 |
return ( getMemoryBlock() != null ) ? getMemoryBlock().getChangedAddresses() : new Long[0]; |
294 |
return ( getMemoryBlock() != null ) ? getMemoryBlock().getChangedAddresses() : new IAddress[0]; |
299 |
} |
295 |
} |
300 |
|
296 |
|
301 |
private int getDataItemOffsetByAddress( Long address ) |
297 |
private int getDataItemOffsetByAddress( IAddress address ) |
302 |
{ |
298 |
{ |
303 |
if ( getMemoryBlock() != null ) |
299 |
if ( getMemoryBlock() != null ) |
304 |
{ |
300 |
{ |
Lines 307-321
Link Here
|
307 |
{ |
303 |
{ |
308 |
int wordSize = getMemoryBlock().getWordSize(); |
304 |
int wordSize = getMemoryBlock().getWordSize(); |
309 |
int numberOfColumns = getMemoryBlock().getNumberOfColumns(); |
305 |
int numberOfColumns = getMemoryBlock().getNumberOfColumns(); |
310 |
if ( address.longValue() >= rows[i].getAddress() && |
306 |
|
311 |
address.longValue() < rows[i].getAddress() + (wordSize * numberOfColumns) ) |
307 |
if( address.compareTo( rows[i].getAddress()) >=0 && |
|
|
308 |
address.compareTo( rows[i].getAddress().add(BigInteger.valueOf(wordSize * numberOfColumns))) <0) |
312 |
{ |
309 |
{ |
313 |
for ( int j = 1; j <= numberOfColumns; ++j ) |
310 |
for ( int j = 1; j <= numberOfColumns; ++j ) |
314 |
{ |
311 |
{ |
315 |
if ( address.longValue() >= rows[i].getAddress() + ((j - 1) * wordSize) && |
312 |
if( address.compareTo( rows[i].getAddress().add(BigInteger.valueOf( (j - 1) * wordSize))) >=0 && |
316 |
address.longValue() < rows[i].getAddress() + (j * wordSize) ) |
313 |
address.compareTo( rows[i].getAddress().add(BigInteger.valueOf( j * wordSize))) <0) |
317 |
{ |
314 |
{ |
318 |
return (i * getRowLength()) + ((j - 1) * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS)) + getAddressLength() + INTERVAL_BETWEEN_ADDRESS_AND_DATA; |
315 |
return (i * getRowLength()) + ((j - 1) * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS)) + address.getCharsNum() + INTERVAL_BETWEEN_ADDRESS_AND_DATA; |
319 |
} |
316 |
} |
320 |
} |
317 |
} |
321 |
} |
318 |
} |
Lines 325-331
Link Here
|
325 |
return -1; |
322 |
return -1; |
326 |
} |
323 |
} |
327 |
|
324 |
|
328 |
private int getAsciiOffsetByAddress( Long address ) |
325 |
private int getAsciiOffsetByAddress( IAddress address ) |
329 |
{ |
326 |
{ |
330 |
if ( getMemoryBlock() != null ) |
327 |
if ( getMemoryBlock() != null ) |
331 |
{ |
328 |
{ |
Lines 334-347
Link Here
|
334 |
{ |
331 |
{ |
335 |
IFormattedMemoryBlockRow firstRow = rows[0]; |
332 |
IFormattedMemoryBlockRow firstRow = rows[0]; |
336 |
IFormattedMemoryBlockRow lastRow = rows[rows.length - 1]; |
333 |
IFormattedMemoryBlockRow lastRow = rows[rows.length - 1]; |
337 |
if ( address.longValue() >= firstRow.getAddress() && address.longValue() <= lastRow.getAddress() ) |
334 |
|
|
|
335 |
if (address.compareTo( firstRow.getAddress()) >=0 && address.compareTo( lastRow.getAddress()) <=0) |
336 |
|
338 |
{ |
337 |
{ |
339 |
int asciiOffset = (int)(address.longValue() - firstRow.getAddress()); |
338 |
BigInteger asciiOffset = address.distance( firstRow.getAddress()); |
340 |
int asciiRowlength = getMemoryBlock().getWordSize() * getMemoryBlock().getNumberOfColumns(); |
339 |
int asciiRowlength = getMemoryBlock().getWordSize() * getMemoryBlock().getNumberOfColumns(); |
341 |
int numberOfRows = asciiOffset / asciiRowlength; |
340 |
int numberOfRows = asciiOffset.intValue() / asciiRowlength; |
342 |
int offsetInRow = asciiOffset % asciiRowlength; |
341 |
int offsetInRow = asciiOffset.intValue() % asciiRowlength; |
343 |
return (numberOfRows * getRowLength()) + |
342 |
return (numberOfRows * getRowLength()) + |
344 |
getAddressLength() + INTERVAL_BETWEEN_ADDRESS_AND_DATA + |
343 |
address.getCharsNum() + INTERVAL_BETWEEN_ADDRESS_AND_DATA + |
345 |
(getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS) * getMemoryBlock().getNumberOfColumns() + |
344 |
(getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS) * getMemoryBlock().getNumberOfColumns() + |
346 |
INTERVAL_BETWEEN_DATA_AND_ASCII + offsetInRow; |
345 |
INTERVAL_BETWEEN_DATA_AND_ASCII + offsetInRow; |
347 |
} |
346 |
} |
Lines 513-525
Link Here
|
513 |
{ |
512 |
{ |
514 |
if ( getMemoryBlock() != null ) |
513 |
if ( getMemoryBlock() != null ) |
515 |
{ |
514 |
{ |
516 |
int index = getDataItemIndex( offset ); |
515 |
int index = getDataItemIndex(offset ); |
517 |
if ( index != -1 ) |
516 |
if ( index != -1 ) |
518 |
{ |
517 |
{ |
519 |
char[] chars = getDataItemChars( index ); |
518 |
char[] chars = getDataItemChars( index ); |
520 |
if ( isInDataArea( offset ) ) |
519 |
if ( isInDataArea( offset ) ) |
521 |
{ |
520 |
{ |
522 |
int charIndex = getOffsetInDataItem( offset, index ); |
521 |
int charIndex = getOffsetInDataItem(offset, index ); |
523 |
chars[charIndex] = newChar; |
522 |
chars[charIndex] = newChar; |
524 |
} |
523 |
} |
525 |
if ( isInAsciiArea( offset ) ) |
524 |
if ( isInAsciiArea( offset ) ) |
Lines 539-545
Link Here
|
539 |
int index = getDataItemIndex( offset ); |
538 |
int index = getDataItemIndex( offset ); |
540 |
if ( index != -1 ) |
539 |
if ( index != -1 ) |
541 |
{ |
540 |
{ |
542 |
String newValue = getNewItemValue( offset, ch ); |
541 |
String newValue = getNewItemValue(offset, ch ); |
543 |
if ( newValue != null ) |
542 |
if ( newValue != null ) |
544 |
{ |
543 |
{ |
545 |
try |
544 |
try |