freemyipod r609 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r608‎ | r609 | r610 >
Date:17:28, 13 February 2011
Author:farthen
Status:new
Tags:
Comment:
emCORE tools/libemcore.py: getprocinfo: Download mutex and wakeup structs and store them in the thread information, too.
emcore.py: getprocinfo: Display the owner of a mutex and improve the representation of the block_type.
Modified paths:
  • /emcore/trunk/tools/emcore.py (modified) (history)
  • /emcore/trunk/tools/libemcore.py (modified) (history)

Diff [purge]

Index: emcore/trunk/tools/emcore.py
@@ -458,9 +458,12 @@
459459 self.logger.info("Thread type: %s\n" % thread.thread_type, 4)
460460 self.logger.info("Thread state: %s\n" % thread.state, 4)
461461 if thread.block_type != "THREAD_NOT_BLOCKED":
462 - self.logger.info("Block type: %s\n" % thread.block_type, 6)
463 - if thread.blocked_by != 0:
464 - self.logger.info("Blocked by: 0x%X\n" % thread.blocked_by, 6)
 462+ self.logger.info("Block type: %s\n" % thread.block_type, 4)
 463+ if thread.block_type == "THREAD_BLOCK_MUTEX":
 464+ self.logger.info("Blocked by mutex: 0x%X\n" % thread.blocked_by, 6)
 465+ self.logger.info("Owner: %s (0x%X)\n" % (thread.blocked_by.owner.name, thread.blocked_by.owner), 8)
 466+ elif thread.block_type == "THREAD_BLOCK_WAKEUP":
 467+ self.logger.info("Blocked by wakeup: 0x%X\n" % thread.blocked_by, 6)
465468 self.logger.info("Priority: %d/255\n" % thread.priority, 4)
466469 self.logger.info("Current CPU load: %.1f%%\n" % ((thread.cpuload * 100) / 255.), 4)
467470 self.logger.info("CPU time (total): %s\n" % datetime.timedelta(microseconds = thread.cputime_total), 4)
Index: emcore/trunk/tools/libemcore.py
@@ -33,7 +33,7 @@
3434 import base64
3535
3636 from libemcoredata import *
37 -from misc import Logger, Bunch, Error, ArgumentError, gethwname
 37+from misc import Logger, Bunch, remote_pointer, Error, ArgumentError, getthread, gethwname
3838 from functools import wraps
3939
4040 class DeviceNotFoundError(Error):
@@ -393,10 +393,29 @@
394394 threadstruct.name = self.readstring(threadstruct.name)
395395 else: threadstruct.name = "[Thread %08X]" % structptr
396396 threadstruct.state = thread_state(threadstruct.state)
 397+ if threadstruct.block_type == "THREAD_BLOCK_MUTEX":
 398+ blocked_by_struct = mutex
 399+ elif threadstruct.block_type == "THREAD_BLOCK_WAKEUP":
 400+ blocked_by_struct = wakeup
 401+ else:
 402+ blocked_by_struct = None
 403+ if blocked_by_struct != None:
 404+ blocked_by_data = self.read(threadstruct.blocked_by, ctypes.sizeof(blocked_by_struct))
 405+ blocked_by = blocked_by_struct()
 406+ blocked_by._from_string(blocked_by_data)
 407+ threadstruct.blocked_by = remote_pointer(threadstruct.blocked_by, blocked_by._to_bunch())
 408+ else:
 409+ threadstruct.blocked_by = 0
397410 threads.append(threadstruct)
398411 id += 1
399412 structptr = threadstruct.thread_next
400413 self.lockscheduler(schedulerstate)
 414+
 415+ for thread in threads:
 416+ if thread.block_type == "THREAD_BLOCK_MUTEX":
 417+ thread.blocked_by.owner = remote_pointer(thread.blocked_by.owner, getthread(thread.blocked_by.owner, threads))
 418+ if thread.block_type == "THREAD_BLOCK_WAKEUP":
 419+ thread.blocked_by.waiter = remote_pointer(thread.blocked_by.waiter, getthread(thread.blocked_by.waiter, threads))
401420 return threads
402421
403422 @command()