[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Framework for Memory info in the debugger
|
Putting the framework for the memory view to access
memory via gdb/mi command -data-read-memory. Update is not
done yet.
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.5
diff -u -r1.5 ChangeLog
--- ChangeLog 12 Oct 2002 23:51:24 -0000 1.5
+++ ChangeLog 13 Oct 2002 01:45:23 -0000
@@ -1,5 +1,27 @@
2002-10-12 Alain Magloire
+ The memory block is implemented with
+ -data-read-memory (MIDataReadMemory)
+ Since the ICDIMemoryBlock only have
+ byte[] getBytes()
+ We will always issue:
+ -data-read-memory address x 1 1 length
+ The CDI upper layer will deal with any conversions
+
+ The problem now is how to send changedEvent when
+ an element of the memory changed.
+
+ * cdi/MemoryBlock.java (getLength): Implemented
+ (getBytes): Implemented
+ (getStartAddress): Implemented
+
+ * cdi/MemoryManager.java: Implemented.
+
+ * command/MIDataReadMemory (getMIDataReadMemoryInfo):
+ New helper method.
+
+2002-10-12 Alain Magloire
+
* cdi/Location (getInstructions): Methods removed
no longer define in ICDILocation.
Index: MIDataReadMemory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIDataReadMemory.java,v
retrieving revision 1.4
diff -u -r1.4 MIDataReadMemory.java
--- MIDataReadMemory.java 8 Aug 2002 04:07:00 -0000 1.4
+++ MIDataReadMemory.java 13 Oct 2002 01:45:46 -0000
@@ -129,6 +129,10 @@
}
}
+ public MIDataReadMemoryInfo getMIDataReadMemoryInfo() throws MIException {
+ return (MIDataReadMemoryInfo)getMIInfo();
+ }
+
public MIInfo getMIInfo() throws MIException {
MIInfo info = null;
MIOutput out = getMIOutput();
Index: MemoryBlock.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/MemoryBlock.java,v
retrieving revision 1.1
diff -u -r1.1 MemoryBlock.java
--- MemoryBlock.java 17 Sep 2002 03:56:44 -0000 1.1
+++ MemoryBlock.java 13 Oct 2002 01:46:21 -0000
@@ -1,67 +1,79 @@
package org.eclipse.cdt.debug.mi.core.cdi;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
+import org.eclipse.cdt.debug.mi.core.output.MIDataReadMemoryInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIMemory;
/**
- * @author alain
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
- * To enable and disable the creation of type comments go to
- * Window>Preferences>Java>Code Generation.
*/
public class MemoryBlock extends CObject implements ICDIMemoryBlock {
- public MemoryBlock(CTarget target) {
+ MIDataReadMemoryInfo mem;
+ boolean frozen;
+
+ public MemoryBlock(CTarget target, MIDataReadMemoryInfo info) {
super(target);
+ mem = info;
+ frozen = true;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock#getBytes()
*/
public byte[] getBytes() throws CDIException {
- return null;
+ MIMemory[] miMem = mem.getMemories();
+ List aList = new ArrayList();
+ for (int i = 0; i < miMem.length; i++) {
+ long[] data = miMem[i].getData();
+ for (int j = 0; j < data.length; j++) {
+ aList.add(new Long(data[j]));
+ }
+ }
+ byte[] bytes = new byte[aList.size()];
+ for (int i = 0; i < aList.size(); i++) {
+ Long l = (Long)aList.get(i);
+ bytes[i] = l.byteValue();
+ }
+ return bytes;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock#getLength()
*/
public long getLength() {
- return 0;
+ return mem.getTotalBytes();
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock#getStartAddress()
*/
public long getStartAddress() {
- return 0;
+ return mem.getAddress();
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock#isFrozen()
*/
public boolean isFrozen() {
- return false;
+ return frozen;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock#setFrozen(boolean)
*/
public void setFrozen(boolean frozen) {
+ this.frozen = frozen;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock#setValue(long, byte[])
*/
public void setValue(long offset, byte[] bytes) throws CDIException {
- }
-
- /**
- * @see org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock#supportsValueModification()
- */
- public boolean supportsValueModification() {
- return false;
+ throw new CDIException("Not supported");
}
}
Index: MemoryManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/MemoryManager.java,v
retrieving revision 1.5
diff -u -r1.5 MemoryManager.java
--- MemoryManager.java 2 Oct 2002 04:43:07 -0000 1.5
+++ MemoryManager.java 13 Oct 2002 01:46:38 -0000
@@ -5,54 +5,69 @@
*/
package org.eclipse.cdt.debug.mi.core.cdi;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
+import org.eclipse.cdt.debug.mi.core.MIException;
+import org.eclipse.cdt.debug.mi.core.MIFormat;
+import org.eclipse.cdt.debug.mi.core.MISession;
+import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
+import org.eclipse.cdt.debug.mi.core.command.MIDataReadMemory;
+import org.eclipse.cdt.debug.mi.core.output.MIDataReadMemoryInfo;
/**
- * @author alain
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
- * To enable and disable the creation of type comments go to
- * Window>Preferences>Java>Code Generation.
*/
public class MemoryManager extends SessionObject implements ICDIMemoryManager {
+ List blockList;
+
public MemoryManager(CSession session) {
super(session);
- }
-
- /**
- * @see org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager#addBlock(ICDIMemoryBlock)
- */
- public void addBlock(ICDIMemoryBlock memoryBlock) throws CDIException {
+ blockList = new ArrayList();
}
/**
- * @see org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager#getBlock(String)
+ * @see org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager#createMemoryBlock(long, int)
*/
- public ICDIMemoryBlock getBlock(String id) throws CDIException {
- return null;
+ public ICDIMemoryBlock createMemoryBlock(long address, int length)
+ throws CDIException {
+ MISession mi = getCSession().getMISession();
+ CommandFactory factory = mi.getCommandFactory();
+ String addr = "0x" + Long.toHexString(address);
+ MIDataReadMemory mem = factory.createMIDataReadMemory(0, addr, MIFormat.HEXADECIMAL, 1, 1, length, null);
+ try {
+ mi.postCommand(mem);
+ MIDataReadMemoryInfo info = mem.getMIDataReadMemoryInfo();
+ MemoryBlock block = new MemoryBlock(getCSession().getCTarget(), info);
+ blockList.add(block);
+ return block;
+ } catch (MIException e) {
+ throw new CDIException(e.getMessage());
+ }
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager#getBlocks()
*/
- public ICDIMemoryBlock[] getBlocks() throws CDIException {
- return null;
+ public ICDIMemoryBlock[] getMemoryBlocks() throws CDIException {
+ return (ICDIMemoryBlock[])blockList.toArray(new ICDIMemoryBlock[0]);
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager#removeAllBlocks()
*/
public void removeAllBlocks() throws CDIException {
+ blockList.clear();
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager#removeBlock(ICDIMemoryBlock)
*/
- public void removeBlock(ICDIMemoryBlock memoryBlock) {
+ public void removeBlock(ICDIMemoryBlock memoryBlock) throws CDIException {
+ blockList.remove(memoryBlock);
}
/**
@@ -60,6 +75,9 @@
*/
public void removeBlocks(ICDIMemoryBlock[] memoryBlocks)
throws CDIException {
+ for (int i = 0; i < memoryBlocks.length; i++) {
+ removeBlock(memoryBlocks[i]);
+ }
}
}
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/ChangeLog,v
retrieving revision 1.11
diff -u -r1.11 ChangeLog
--- ChangeLog 12 Oct 2002 23:48:57 -0000 1.11
+++ ChangeLog 13 Oct 2002 01:30:30 -0000
@@ -1,5 +1,13 @@
2002-10-12 Alain Magloire
+ * core/cdi/model/ICDIMemoryBlock (supportValueModification):
+ Remove the method, it should be part of a ICDIConfiguration.
+
+ * core/cdi/ICDIMemoryManager (getBlock): Rename to getMemoryBlock
+ (createMemoryBlock): New method to get a memory block.
+
+2002-10-12 Alain Magloire
+
* core/cdi/ICDILocation (getInstructions): Methods
removed is now part of SourceManager.
Index: src/org/eclipse/cdt/debug/core/cdi/ICDIMemoryManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDIMemoryManager.java,v
retrieving revision 1.2
diff -u -r1.2 ICDIMemoryManager.java
--- src/org/eclipse/cdt/debug/core/cdi/ICDIMemoryManager.java 2 Oct 2002 21:10:35 -0000 1.2
+++ src/org/eclipse/cdt/debug/core/cdi/ICDIMemoryManager.java 13 Oct 2002 01:30:31 -0000
@@ -17,20 +17,22 @@
public interface ICDIMemoryManager extends ICDISessionObject
{
/**
- * Adds the given memory block to the debug session.
+ * Returns a memory block specified by given identifier.
*
- * @param memoryBlock - the memory block to be added
- * @exception CDIException on failure. Reasons include:
+ * @param address
+ * @param length - how much for address
+ * @return a memory block with the specified identifier
+ * @throws CDIException on failure. Reasons include:
*/
- void addBlock( ICDIMemoryBlock memoryBlock ) throws CDIException;
-
+ ICDIMemoryBlock createMemoryBlock(long address, int length) throws CDIException;
+
/**
* Removes the given memory block from the debug session.
*
* @param memoryBlock - the memory block to be removed
* @exception CDIException on failure. Reasons include:
*/
- void removeBlock( ICDIMemoryBlock memoryBlock );
+ void removeBlock(ICDIMemoryBlock memoryBlock) throws CDIException;
/**
* Removes the given array of memory blocks from the debug session.
@@ -38,7 +40,7 @@
* @param memoryBlock - the array of memory blocks to be removed
* @exception CDIException on failure. Reasons include:
*/
- void removeBlocks( ICDIMemoryBlock[] memoryBlocks ) throws CDIException;;
+ void removeBlocks(ICDIMemoryBlock[] memoryBlocks) throws CDIException;;
/**
* Removes all memory blocks from the debug session.
@@ -47,14 +49,6 @@
*/
void removeAllBlocks() throws CDIException;
- /**
- * Returns a memory block specified by given identifier.
- *
- * @param id - the block identifier
- * @return a memory block with the specified identifier
- * @throws CDIException on failure. Reasons include:
- */
- ICDIMemoryBlock getBlock( String id ) throws CDIException;
/**
* Returns an array of all memory blocks set for this debug session.
@@ -62,5 +56,5 @@
* @return an array of all memory blocks set for this debug session
* @throws CDIException on failure. Reasons include:
*/
- ICDIMemoryBlock[] getBlocks() throws CDIException;
+ ICDIMemoryBlock[] getMemoryBlocks() throws CDIException;
}
Index: src/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlock.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlock.java,v
retrieving revision 1.2
diff -u -r1.2 ICDIMemoryBlock.java
--- src/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlock.java 15 Aug 2002 05:56:15 -0000 1.2
+++ src/org/eclipse/cdt/debug/core/cdi/model/ICDIMemoryBlock.java 13 Oct 2002 01:30:31 -0000
@@ -46,13 +46,6 @@
byte[] getBytes() throws CDIException;
/**
- * Returns whether this memory block supports value modification
- *
- * @return whether this memory block supports value modification
- */
- boolean supportsValueModification();
-
- /**
* Sets the value of the bytes in this memory block at the specified
* offset within this memory block to the spcified bytes.
* The offset is zero based.
@@ -69,9 +62,9 @@
* beyond the end of this memory block (index of out of range)</li>
* </ul>
*/
- void setValue( long offset, byte[] bytes ) throws CDIException;
+ void setValue(long offset, byte[] bytes) throws CDIException;
boolean isFrozen();
- void setFrozen( boolean frozen );
+ void setFrozen(boolean frozen);
}