| Line 283... |
Line 283... |
| 283 |
@command()
|
283 |
@command()
|
| 284 |
def readstring(self, addr, maxlength = 256, replacement = "."):
|
284 |
def readstring(self, addr, maxlength = 256, replacement = "."):
|
| 285 |
""" Reads a zero terminated string from memory
|
285 |
""" Reads a zero terminated string from memory
|
| 286 |
Reads only a maximum of 'maxlength' chars.
|
286 |
Reads only a maximum of 'maxlength' chars.
|
| 287 |
"""
|
287 |
"""
|
| 288 |
if addr == 0: return "<NULL>"
|
288 |
if addr == 0: return "<NULL>"
|
| 289 |
cin_maxsize = self.lib.dev.packetsizelimit.cin - self.lib.headersize
|
289 |
cin_maxsize = self.lib.dev.packetsizelimit.cin - self.lib.headersize
|
| 290 |
string = ""
|
290 |
string = ""
|
| 291 |
done = False
|
291 |
done = False
|
| 292 |
while not done and (len(string) < maxlength or maxlength < 0):
|
292 |
while not done and (len(string) < maxlength or maxlength < 0):
|
| 293 |
data = self._readmem(addr, min(maxlength - len(string), cin_maxsize))
|
293 |
data = self._readmem(addr, min(maxlength - len(string), cin_maxsize))
|
| 294 |
length = data.find(b"\0")
|
294 |
length = data.find(b"\0")
|
| 295 |
if length >= 0:
|
295 |
if length >= 0:
|
| 296 |
data = data[:length]
|
296 |
data = data[:length]
|
| 297 |
done = True
|
297 |
done = True
|
| 298 |
for i in range(len(data)):
|
298 |
for i in range(len(data)):
|
| 299 |
byte = ord(data[i : i + 1])
|
299 |
byte = ord(data[i : i + 1])
|
| 300 |
if byte < 0x20: string = string + replacement
|
300 |
if byte < 0x20: string = string + replacement
|
| 301 |
else: string = string + chr(byte)
|
301 |
else: string = string + chr(byte)
|
| 302 |
addr += cin_maxsize
|
302 |
addr += cin_maxsize
|
| 303 |
return string
|
303 |
return string
|
| 304 |
|
304 |
|
| 305 |
@command()
|
305 |
@command()
|
| Line 387... |
Line 387... |
| 387 |
threaddata = self.read(structptr, ctypes.sizeof(scheduler_thread))
|
387 |
threaddata = self.read(structptr, ctypes.sizeof(scheduler_thread))
|
| 388 |
threadstruct._from_string(threaddata)
|
388 |
threadstruct._from_string(threaddata)
|
| 389 |
threadstruct = threadstruct._to_bunch()
|
389 |
threadstruct = threadstruct._to_bunch()
|
| 390 |
threadstruct.id = id # only for the purpose of detecting the idle thread as it is always the first one
|
390 |
threadstruct.id = id # only for the purpose of detecting the idle thread as it is always the first one
|
| 391 |
threadstruct.addr = structptr
|
391 |
threadstruct.addr = structptr
|
| 392 |
if threadstruct.name != 0:
|
392 |
if threadstruct.name != 0:
|
| 393 |
threadstruct.name = self.readstring(threadstruct.name)
|
393 |
threadstruct.name = self.readstring(threadstruct.name)
|
| 394 |
else: threadstruct.name = "[Thread %08X]" % structptr
|
394 |
else: threadstruct.name = "[Thread %08X]" % structptr
|
| 395 |
threadstruct.state = thread_state(threadstruct.state)
|
395 |
threadstruct.state = thread_state(threadstruct.state)
|
| 396 |
threads.append(threadstruct)
|
396 |
threads.append(threadstruct)
|
| 397 |
id += 1
|
397 |
id += 1
|
| 398 |
structptr = threadstruct.thread_next
|
398 |
structptr = threadstruct.thread_next
|