1 11 12 package org.eclipse.debug.internal.ui.views.memory.renderings; 13 14 import java.math.BigInteger ; 15 16 import org.eclipse.debug.core.DebugException; 17 import org.eclipse.debug.core.model.IMemoryBlock; 18 import org.eclipse.debug.core.model.IMemoryBlockExtension; 19 20 public class TableRenderingContentDescriptor{ 21 private AbstractBaseTableRendering fRendering; 22 private int fPreBuffer; private int fPostBuffer; private BigInteger fLoadAddress; private int fNumLines; private BigInteger fMemoryBlockBaseAddress; private BigInteger fStartAddress; 28 private BigInteger fEndAddress; 29 30 private int fAddressSize = -1; 31 private int fAddressableSize = -1; 32 33 private boolean fAlignAddress = true; 34 35 private boolean fIsDynamicLoad; 36 37 public TableRenderingContentDescriptor(AbstractBaseTableRendering rendering) 38 { 39 fRendering = rendering; 40 } 41 42 public int getPostBuffer() { 43 return fPostBuffer; 44 } 45 public int getPreBuffer() { 46 return fPreBuffer; 47 } 48 public BigInteger getLoadAddress() { 49 return fLoadAddress; 50 } 51 52 public IMemoryBlock getMemoryBlock() 53 { 54 return fRendering.getMemoryBlock(); 55 } 56 public void setPostBuffer(int postBuffer) { 57 fPostBuffer = postBuffer; 58 } 59 public void setPreBuffer(int preBuffer) { 60 fPreBuffer = preBuffer; 61 } 62 63 public void setLoadAddress(BigInteger address) 64 { 65 fLoadAddress = address; 66 } 67 public BigInteger getContentBaseAddress() { 68 69 if (fMemoryBlockBaseAddress == null) 70 { 71 try { 72 updateContentBaseAddress(); 73 } catch (DebugException e) { 74 fMemoryBlockBaseAddress = new BigInteger ("0"); } 76 } 77 78 return fMemoryBlockBaseAddress; 79 } 80 81 public void updateContentBaseAddress() throws DebugException { 82 IMemoryBlock memoryBlock = fRendering.getMemoryBlock(); 83 if (memoryBlock instanceof IMemoryBlockExtension) 84 fMemoryBlockBaseAddress = ((IMemoryBlockExtension)memoryBlock).getBigBaseAddress(); 85 else 86 fMemoryBlockBaseAddress = BigInteger.valueOf(memoryBlock.getStartAddress()); 87 } 88 89 92 public BigInteger getStartAddress() 93 { 94 if (fStartAddress == null) 95 { 96 try { 97 IMemoryBlock memoryBlock = fRendering.getMemoryBlock(); 98 if(memoryBlock instanceof IMemoryBlockExtension) 99 { 100 BigInteger startAddress = ((IMemoryBlockExtension)memoryBlock).getMemoryBlockStartAddress(); 101 if (startAddress != null) 102 fStartAddress = startAddress; 103 } 104 } catch (DebugException e) { 105 fStartAddress = BigInteger.valueOf(0); 107 } 108 109 if (fStartAddress == null) 110 fStartAddress = BigInteger.valueOf(0); 111 } 112 return fStartAddress; 113 } 114 115 118 public BigInteger getEndAddress() 119 { 120 if (fEndAddress == null) 121 { 122 IMemoryBlock memoryBlock = fRendering.getMemoryBlock(); 123 if(memoryBlock instanceof IMemoryBlockExtension) 124 { 125 BigInteger endAddress; 126 try { 127 endAddress = ((IMemoryBlockExtension)memoryBlock).getMemoryBlockEndAddress(); 128 if (endAddress != null) 129 fEndAddress = endAddress; 130 } catch (DebugException e) { 131 fEndAddress = null; 132 } 133 134 if (fEndAddress == null) 135 { 136 int addressSize; 137 try { 138 addressSize = ((IMemoryBlockExtension)memoryBlock).getAddressSize(); 139 } catch (DebugException e) { 140 addressSize = 4; 141 } 142 143 endAddress = BigInteger.valueOf(2); 144 endAddress = endAddress.pow(addressSize*8); 145 endAddress = endAddress.subtract(BigInteger.valueOf(1)); 146 fEndAddress = endAddress; 147 } 148 } 149 150 if (fEndAddress == null) 151 fEndAddress = BigInteger.valueOf(Integer.MAX_VALUE); 152 } 153 return fEndAddress; 154 } 155 156 public int getNumLines() 157 { 158 return fNumLines; 159 } 160 161 public void setNumLines(int numLines) 162 { 163 fNumLines = numLines; 164 } 165 166 public AbstractBaseTableRendering getRendering() 167 { 168 return fRendering; 169 } 170 171 public int getAddressableSize() { 172 return fAddressableSize; 173 } 174 175 public void setAddressableSize(int addressableSize) { 176 fAddressableSize = addressableSize; 177 } 178 179 public int getAddressSize() { 180 return fAddressSize; 181 } 182 183 public void setAddressSize(int addressSize) { 184 fAddressSize = addressSize; 185 } 186 187 public void setDynamicLoad(boolean dynamic) 188 { 189 fIsDynamicLoad = dynamic; 190 } 191 192 public boolean isDynamicLoad() 193 { 194 return fIsDynamicLoad; 195 } 196 197 public boolean isMemoryBlockBaseAddressInitialized() 198 { 199 return (fMemoryBlockBaseAddress != null); 200 } 201 202 public boolean isAlignAddressToBoundary() 203 { 204 return fAlignAddress; 205 } 206 207 public void setAlignAddressToBoundary(boolean align) 208 { 209 fAlignAddress = align; 210 } 211 212 } 213 | Popular Tags |