Subversion Repositories freemyipod

Rev

Rev 602 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 602 Rev 609
Line 31... Line 31...
31
import ctypes
31
import ctypes
32
import usb.core
32
import usb.core
33
import base64
33
import base64
34
 
34
 
35
from libemcoredata import *
35
from libemcoredata import *
36
from misc import Logger, Bunch, Error, ArgumentError, gethwname
36
from misc import Logger, Bunch, remote_pointer, Error, ArgumentError, getthread, gethwname
37
from functools import wraps
37
from functools import wraps
38
 
38
 
39
class DeviceNotFoundError(Error):
39
class DeviceNotFoundError(Error):
40
    pass
40
    pass
41
 
41
 
Line 391... Line 391...
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
            if threadstruct.block_type == "THREAD_BLOCK_MUTEX":
-
 
397
                blocked_by_struct = mutex
-
 
398
            elif threadstruct.block_type == "THREAD_BLOCK_WAKEUP":
-
 
399
                blocked_by_struct = wakeup
-
 
400
            else:
-
 
401
                blocked_by_struct = None
-
 
402
            if blocked_by_struct != None:
-
 
403
                blocked_by_data = self.read(threadstruct.blocked_by, ctypes.sizeof(blocked_by_struct))
-
 
404
                blocked_by = blocked_by_struct()
-
 
405
                blocked_by._from_string(blocked_by_data)
-
 
406
                threadstruct.blocked_by = remote_pointer(threadstruct.blocked_by, blocked_by._to_bunch())
-
 
407
            else:
-
 
408
                threadstruct.blocked_by = 0
396
            threads.append(threadstruct)
409
            threads.append(threadstruct)
397
            id += 1
410
            id += 1
398
            structptr = threadstruct.thread_next
411
            structptr = threadstruct.thread_next
399
        self.lockscheduler(schedulerstate)
412
        self.lockscheduler(schedulerstate)
-
 
413
        
-
 
414
        for thread in threads:
-
 
415
            if thread.block_type == "THREAD_BLOCK_MUTEX":
-
 
416
                thread.blocked_by.owner = remote_pointer(thread.blocked_by.owner, getthread(thread.blocked_by.owner, threads))
-
 
417
            if thread.block_type == "THREAD_BLOCK_WAKEUP":
-
 
418
                thread.blocked_by.waiter = remote_pointer(thread.blocked_by.waiter, getthread(thread.blocked_by.waiter, threads))
400
        return threads
419
        return threads
401
    
420
    
402
    @command()
421
    @command()
403
    def lockscheduler(self, freeze=True):
422
    def lockscheduler(self, freeze=True):
404
        """ Freezes/Unfreezes the scheduler """
423
        """ Freezes/Unfreezes the scheduler """