| Line 1157... |
Line 1157... |
| 1157 |
if entry.attributes & 0x10: size = "DIR"
|
1157 |
if entry.attributes & 0x10: size = "DIR"
|
| 1158 |
else: size = locale.format("%d", entry.size, True).rjust(13)
|
1158 |
else: size = locale.format("%d", entry.size, True).rjust(13)
|
| 1159 |
self.logger.info(entry.name.ljust(50) + " - " + size + "\n")
|
1159 |
self.logger.info(entry.name.ljust(50) + " - " + size + "\n")
|
| 1160 |
except: break
|
1160 |
except: break
|
| 1161 |
self.emcore.dir_close(handle)
|
1161 |
self.emcore.dir_close(handle)
|
| - |
|
1162 |
|
| - |
|
1163 |
@command
|
| - |
|
1164 |
def malloc(self, size):
|
| - |
|
1165 |
""" Allocates <size> bytes and returns a pointer to the allocated memory """
|
| - |
|
1166 |
size = self._hexint(size)
|
| - |
|
1167 |
self.logger.info("Allocating %d bytes of memory\n" % size)
|
| - |
|
1168 |
addr = self.emcore.malloc(size)
|
| - |
|
1169 |
self.logger.info("Allocated %d bytes of memory at 0x%x\n" % (size, addr))
|
| - |
|
1170 |
|
| - |
|
1171 |
@command
|
| - |
|
1172 |
def memalign(self, align, size):
|
| - |
|
1173 |
""" Allocates <size> bytes aligned to <align> and returns a pointer to the allocated memory """
|
| - |
|
1174 |
align = self._hexint(align)
|
| - |
|
1175 |
size = self._hexint(size)
|
| - |
|
1176 |
self.logger.info("Allocating %d bytes of memory aligned to 0x%x\n" % (size, align))
|
| - |
|
1177 |
addr = self.emcore.memalign(align, size)
|
| - |
|
1178 |
self.logger.info("Allocated %d bytes of memory at 0x%x\n" % (size, addr))
|
| - |
|
1179 |
|
| - |
|
1180 |
@command
|
| - |
|
1181 |
def realloc(self, ptr, size):
|
| - |
|
1182 |
""" The size of the memory block pointed to by <ptr> is changed to the <size> bytes,
|
| - |
|
1183 |
expanding or reducing the amount of memory available in the block.
|
| - |
|
1184 |
Returns a pointer to the reallocated memory.
|
| - |
|
1185 |
"""
|
| - |
|
1186 |
ptr = self._hexint(ptr)
|
| - |
|
1187 |
size = self._hexint(size)
|
| - |
|
1188 |
self.logger.info("Reallocating 0x%x to have the new size %d\n" % (ptr, size))
|
| - |
|
1189 |
addr = self.emcore.realloc(ptr, size)
|
| - |
|
1190 |
self.logger.info("Reallocated memory at 0x%x to 0x%x with the new size %d\n" % (ptr, addr, size))
|
| - |
|
1191 |
|
| - |
|
1192 |
@command
|
| - |
|
1193 |
def reownalloc(self, ptr, owner):
|
| - |
|
1194 |
""" Changes the owner of the memory allocation <ptr> to the thread struct at addr <owner> """
|
| - |
|
1195 |
ptr = self._hexint(ptr)
|
| - |
|
1196 |
owner = self._hexint(owner)
|
| - |
|
1197 |
self.logger.info("Changing owner of the memory region 0x%x to 0x%x" % (ptr, owner))
|
| - |
|
1198 |
self.emcore.reownalloc(ptr, owner)
|
| - |
|
1199 |
self.logger.info("Successfully changed owner of 0x%x to 0x%x" % (ptr, owner))
|
| - |
|
1200 |
|
| - |
|
1201 |
@command
|
| - |
|
1202 |
def free(self, ptr):
|
| - |
|
1203 |
""" Frees the memory space pointed to by 'ptr' """
|
| - |
|
1204 |
ptr = self._hexint(ptr)
|
| - |
|
1205 |
self.logger.info("Freeing the memory region at 0x%x\n" % ptr)
|
| - |
|
1206 |
self.emcore.free(ptr)
|
| - |
|
1207 |
self.logger.info("Successfully freed the memory region at 0x%x\n" % ptr)
|
| - |
|
1208 |
|
| - |
|
1209 |
@command
|
| - |
|
1210 |
def free_all(self):
|
| - |
|
1211 |
""" Frees all memory allocations created by the monitor thread """
|
| - |
|
1212 |
self.logger.info("Freeing all memory allocations created by the monitor thread\n")
|
| - |
|
1213 |
self.emcore.free_all()
|
| - |
|
1214 |
self.logger.info("Successfully freed all memory allocations created by the monitor thread\n")
|
| - |
|
1215 |
|
| 1162 |
|
1216 |
|
| 1163 |
if __name__ == "__main__":
|
1217 |
if __name__ == "__main__":
|
| 1164 |
if len(sys.argv) < 2:
|
1218 |
if len(sys.argv) < 2:
|
| 1165 |
usage("No command specified")
|
1219 |
usage("No command specified")
|
| 1166 |
try:
|
1220 |
try:
|