mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
[208278] endian cleanup
This commit is contained in:
parent
0d914fc773
commit
4cecd6c03d
4 changed files with 51 additions and 34 deletions
|
@ -30,7 +30,7 @@ public class DataPane extends AbstractPane
|
|||
protected String getCellText(MemoryByte bytes[])
|
||||
{
|
||||
return fRendering.getRadixText(bytes, fRendering.getRadix(), fRendering
|
||||
.isLittleEndian());
|
||||
.isTargetLittleEndian());
|
||||
}
|
||||
|
||||
protected void editCell(BigInteger address, int subCellPosition,
|
||||
|
@ -75,7 +75,7 @@ public class DataPane extends AbstractPane
|
|||
if(isSigned)
|
||||
byteData[byteLen - 1] |= 128;
|
||||
|
||||
if(fRendering.isLittleEndian() != bytes[0].isBigEndian())
|
||||
if(fRendering.isTargetLittleEndian() != bytes[0].isBigEndian())
|
||||
{
|
||||
byte[] byteDataSwapped = new byte[byteData.length];
|
||||
for(int i = 0; i < byteData.length; i++)
|
||||
|
|
|
@ -103,9 +103,9 @@ public class Rendering extends Composite implements IDebugEventSetListener
|
|||
|
||||
private int fColumnsSetting = COLUMNS_AUTO_SIZE_TO_FIT;
|
||||
|
||||
private boolean fLittleEndian = false;
|
||||
private boolean fIsTargetLittleEndian = false;
|
||||
|
||||
private boolean fCheckedLittleEndian = false;
|
||||
private boolean fIsDisplayLittleEndian = false;
|
||||
|
||||
// constants used to identify radix
|
||||
protected final static int RADIX_HEX = 1;
|
||||
|
@ -765,18 +765,10 @@ public class Rendering extends Composite implements IDebugEventSetListener
|
|||
for(int i = 0; i < readBytes.length; i++)
|
||||
cachedBytes[i] = new MemoryByte(readBytes[i].getValue(), readBytes[i].getFlags());
|
||||
|
||||
// we need to set the default endianess. before it was set to BE
|
||||
// by default which wasn't very useful for LE targets. now we will
|
||||
// query the first byte to get the endianess. if not known then we'll
|
||||
// leave it as BE. note that we only do this when reading the first
|
||||
// bit of memory for this rendering. what happens when scrolling
|
||||
// through memory and it changes endianess? for now we just leave
|
||||
// it in the original endianess.
|
||||
if (!fCheckedLittleEndian && cachedBytes.length > 0) {
|
||||
// derive the target endian from the read MemoryBytes.
|
||||
if (cachedBytes.length > 0) {
|
||||
if (cachedBytes[0].isEndianessKnown()) {
|
||||
fLittleEndian = !cachedBytes[0].isBigEndian();
|
||||
fCheckedLittleEndian = true;
|
||||
fParent.bytesAreLittleEndian(fLittleEndian);
|
||||
setTargetLittleEndian(!cachedBytes[0].isBigEndian());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1515,21 +1507,43 @@ public class Rendering extends Composite implements IDebugEventSetListener
|
|||
return 1;
|
||||
}
|
||||
|
||||
protected boolean isLittleEndian()
|
||||
protected boolean isTargetLittleEndian()
|
||||
{
|
||||
return fLittleEndian;
|
||||
return fIsTargetLittleEndian;
|
||||
}
|
||||
|
||||
protected void setLittleEndian(boolean enable)
|
||||
protected void setTargetLittleEndian(boolean littleEndian)
|
||||
{
|
||||
if(fLittleEndian == enable)
|
||||
if(fIsTargetLittleEndian == littleEndian)
|
||||
return;
|
||||
|
||||
fLittleEndian = enable;
|
||||
fireSettingsChanged();
|
||||
layoutPanes();
|
||||
fParent.setTargetMemoryLittleEndian(littleEndian);
|
||||
fIsTargetLittleEndian = littleEndian;
|
||||
Display.getDefault().asyncExec(new Runnable() {
|
||||
public void run()
|
||||
{
|
||||
fireSettingsChanged();
|
||||
layoutPanes();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isDisplayLittleEndian()
|
||||
{
|
||||
return fIsDisplayLittleEndian;
|
||||
}
|
||||
|
||||
public void setDisplayLittleEndian(boolean littleEndian)
|
||||
{
|
||||
if(fIsDisplayLittleEndian = littleEndian)
|
||||
return;
|
||||
|
||||
fIsDisplayLittleEndian = littleEndian;
|
||||
|
||||
fireSettingsChanged();
|
||||
layoutPanes();
|
||||
}
|
||||
|
||||
protected void setBytesPerColumn(int byteCount)
|
||||
{
|
||||
if(fBytesPerColumn != byteCount)
|
||||
|
@ -1627,8 +1641,7 @@ public class Rendering extends Composite implements IDebugEventSetListener
|
|||
// and we want to view in LE then we need to swap. if the bytes
|
||||
// are LE and we want to view BE then we need to swap.
|
||||
boolean needsSwap = false;
|
||||
boolean bytesAreLittleEndian = !bytes[0].isBigEndian();
|
||||
if ((isLittleEndian && !bytesAreLittleEndian) || (!isLittleEndian && bytesAreLittleEndian))
|
||||
if ((isDisplayLittleEndian() && !isTargetLittleEndian()) || (!isDisplayLittleEndian() && isTargetLittleEndian()))
|
||||
needsSwap = true;
|
||||
|
||||
switch(radix)
|
||||
|
|
|
@ -35,7 +35,7 @@ public class TextPane extends AbstractPane
|
|||
protected String getCellText(MemoryByte bytes[])
|
||||
{
|
||||
return fRendering.formatText(bytes, fRendering
|
||||
.isLittleEndian(), fRendering.getTextMode());
|
||||
.isTargetLittleEndian(), fRendering.getTextMode());
|
||||
}
|
||||
|
||||
protected void editCell(BigInteger address, int subCellPosition,
|
||||
|
@ -219,7 +219,7 @@ public class TextPane extends AbstractPane
|
|||
|
||||
final int columns = fRendering.getColumnCount();
|
||||
|
||||
final boolean isLittleEndian = fRendering.isLittleEndian();
|
||||
final boolean isLittleEndian = fRendering.isTargetLittleEndian();
|
||||
|
||||
gc.setForeground(fRendering.getTraditionalRendering().getColorBackground());
|
||||
gc.fillRectangle(columns * cellWidth, 0, this.getBounds().width, this
|
||||
|
|
|
@ -722,10 +722,10 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe
|
|||
public void run()
|
||||
{
|
||||
TraditionalRendering.this.fRendering
|
||||
.setLittleEndian(false);
|
||||
.setDisplayLittleEndian(false);
|
||||
}
|
||||
};
|
||||
displayEndianBigAction.setChecked(!this.fRendering.isLittleEndian());
|
||||
displayEndianBigAction.setChecked(!this.fRendering.isTargetLittleEndian());
|
||||
|
||||
displayEndianLittleAction = new Action(
|
||||
TraditionalRenderingMessages
|
||||
|
@ -735,10 +735,10 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe
|
|||
public void run()
|
||||
{
|
||||
TraditionalRendering.this.fRendering
|
||||
.setLittleEndian(true);
|
||||
.setDisplayLittleEndian(true);
|
||||
}
|
||||
};
|
||||
displayEndianLittleAction.setChecked(this.fRendering.isLittleEndian());
|
||||
displayEndianLittleAction.setChecked(this.fRendering.isTargetLittleEndian());
|
||||
|
||||
// radix
|
||||
|
||||
|
@ -1008,12 +1008,16 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe
|
|||
});
|
||||
}
|
||||
|
||||
protected void bytesAreLittleEndian(boolean areLE)
|
||||
protected void setTargetMemoryLittleEndian(boolean littleEndian)
|
||||
{
|
||||
// once we actually read memory we can determine the
|
||||
// endianess and need to set these actions accordingly.
|
||||
displayEndianBigAction.setChecked(!areLE);
|
||||
displayEndianLittleAction.setChecked(areLE);
|
||||
displayEndianBigAction.setChecked(!littleEndian);
|
||||
displayEndianLittleAction.setChecked(littleEndian);
|
||||
|
||||
// when target endian changes, force display endian to track.
|
||||
// user can then change display endian if desired.
|
||||
fRendering.setDisplayLittleEndian(littleEndian);
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
|
@ -1157,7 +1161,7 @@ class CopyAction extends Action
|
|||
|
||||
final int radix = fRendering.getRadix();
|
||||
final int bytesPerColumn = fRendering.getBytesPerColumn();
|
||||
final boolean isLittleEndian = fRendering.isLittleEndian();
|
||||
final boolean isLittleEndian = fRendering.isTargetLittleEndian();
|
||||
final int bytesPerCharacter = fRendering.getBytesPerCharacter();
|
||||
|
||||
final int addressWidth = fRendering.getAddressString(start)
|
||||
|
|
Loading…
Add table
Reference in a new issue