Index: embios/trunk/tools/libembios.py |
— | — | @@ -763,7 +763,7 @@ |
764 | 764 | <silent> = 0: Process information struct version, Process information table size
|
765 | 765 | <silent> = 1: nothing
|
766 | 766 | """
|
767 | | -
|
| 767 | + # inline functions ----------------------------------------------
|
768 | 768 | def procinfotolist(processinfo, structver):
|
769 | 769 | if (structver == 1): # Process information struct version == 1
|
770 | 770 | ptr = 0
|
— | — | @@ -770,41 +770,43 @@ |
771 | 771 | process_n = 0
|
772 | 772 | retval = []
|
773 | 773 | while ptr < len(processinfo):
|
| 774 | + if struct.unpack("<I", processinfo[ptr:ptr + 4])[0] == 0: continue # THREAD_FREE
|
| 775 | +
|
774 | 776 | retval.append({})
|
775 | 777 |
|
776 | 778 | retval[process_n]['regs'] = struct.unpack("<IIIIIIIIIIIIIIII", processinfo[ptr:ptr + 64])
|
777 | 779 | ptr += 16 * 0x4
|
778 | | - retval[process_n]['cpsr'] = int(struct.unpack("<I", processinfo[ptr:ptr + 4])[0])
|
| 780 | + retval[process_n]['cpsr'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
779 | 781 | ptr += 1 * 0x4
|
780 | | - retval[process_n]['state'] = int(struct.unpack("<I", processinfo[ptr:ptr + 4])[0])
|
| 782 | + retval[process_n]['state'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
781 | 783 | ptr += 1 * 0x4
|
782 | | - retval[process_n]['name_ptr'] = int(struct.unpack("<I", processinfo[ptr:ptr + 4])[0])
|
| 784 | + retval[process_n]['name_ptr'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
783 | 785 | ptr += 1 * 0x4
|
784 | | - retval[process_n]['cputime_current'] = int(struct.unpack("<I", processinfo[ptr:ptr + 4])[0])
|
| 786 | + retval[process_n]['cputime_current'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
785 | 787 | ptr += 1 * 0x4
|
786 | 788 | retval[process_n]['cputime_total'] = struct.unpack("<Q", processinfo[ptr:ptr + 8])[0]
|
787 | 789 | ptr += 1 * 0x8
|
788 | | - retval[process_n]['startusec'] = int(struct.unpack("<I", processinfo[ptr:ptr + 4])[0])
|
| 790 | + retval[process_n]['startusec'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
789 | 791 | ptr += 1 * 0x4
|
790 | | - retval[process_n]['queue_next_ptr'] = int(struct.unpack("<I", processinfo[ptr:ptr + 4])[0])
|
| 792 | + retval[process_n]['queue_next_ptr'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
791 | 793 | ptr += 1 * 0x4
|
792 | | - retval[process_n]['timeout'] = int(struct.unpack("<I", processinfo[ptr:ptr + 4])[0])
|
| 794 | + retval[process_n]['timeout'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
793 | 795 | ptr += 1 * 0x4
|
794 | | - retval[process_n]['blocked_since'] = int(struct.unpack("<I", processinfo[ptr:ptr + 4])[0])
|
| 796 | + retval[process_n]['blocked_since'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
795 | 797 | ptr += 1 * 0x4
|
796 | | - retval[process_n]['blocked_by_ptr'] = int(struct.unpack("<I", processinfo[ptr:ptr + 4])[0])
|
| 798 | + retval[process_n]['blocked_by_ptr'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
797 | 799 | ptr += 1 * 0x4
|
798 | | - retval[process_n]['stack_ptr'] = int(struct.unpack("<I", processinfo[ptr:ptr + 4])[0])
|
| 800 | + retval[process_n]['stack_ptr'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
799 | 801 | ptr += 1 * 0x4
|
800 | | - retval[process_n]['err_no'] = int(struct.unpack("<I", processinfo[ptr:ptr + 4])[0])
|
| 802 | + retval[process_n]['err_no'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
801 | 803 | ptr += 1 * 0x4
|
802 | | - retval[process_n]['block_type'] = int(struct.unpack("<B", processinfo[ptr:ptr + 1])[0])
|
| 804 | + retval[process_n]['block_type'] = struct.unpack("<B", processinfo[ptr:ptr + 1])[0]
|
803 | 805 | ptr += 1 * 0x1
|
804 | | - retval[process_n]['thread_type'] = int(struct.unpack("<B", processinfo[ptr:ptr + 1])[0])
|
| 806 | + retval[process_n]['thread_type'] = struct.unpack("<B", processinfo[ptr:ptr + 1])[0]
|
805 | 807 | ptr += 1 * 0x1
|
806 | | - retval[process_n]['priority'] = int(struct.unpack("<B", processinfo[ptr:ptr + 1])[0])
|
| 808 | + retval[process_n]['priority'] = struct.unpack("<B", processinfo[ptr:ptr + 1])[0]
|
807 | 809 | ptr += 1 * 0x1
|
808 | | - retval[process_n]['cpuload'] = int(struct.unpack("<B", processinfo[ptr:ptr + 1])[0])
|
| 810 | + retval[process_n]['cpuload'] = struct.unpack("<B", processinfo[ptr:ptr + 1])[0]
|
809 | 811 | ptr += 1 * 0x1
|
810 | 812 |
|
811 | 813 | process_n += 1
|
— | — | @@ -812,28 +814,35 @@ |
813 | 815 | return retval
|
814 | 816 |
|
815 | 817 |
|
816 | | - def state2name(state):
|
817 | | - if state == 0: return "THREAD_FREE"
|
818 | | - elif state == 1: return "THREAD_SUSPENDED"
|
819 | | - elif state == 2: return "THREAD_READY"
|
820 | | - elif state == 3: return "THREAD_RUNNING"
|
821 | | - elif state == 4: return "THREAD_BLOCKED"
|
822 | | - elif state == 5: return "THREAD_DEFUNCT"
|
823 | | - elif state == 6: return "THREAD_DEFUNCT_ACK"
|
| 818 | + def state2name(state, structver):
|
| 819 | + if structver == 1:
|
| 820 | + if state == 0: return "THREAD_FREE"
|
| 821 | + elif state == 1: return "THREAD_SUSPENDED"
|
| 822 | + elif state == 2: return "THREAD_READY"
|
| 823 | + elif state == 3: return "THREAD_RUNNING"
|
| 824 | + elif state == 4: return "THREAD_BLOCKED"
|
| 825 | + elif state == 5: return "THREAD_DEFUNCT"
|
| 826 | + elif state == 6: return "THREAD_DEFUNCT_ACK"
|
| 827 | + else: return "UNKNOWN"
|
824 | 828 | else: return "UNKNOWN"
|
825 | 829 |
|
826 | | - def blocktype2name(blocktype):
|
827 | | - if blocktype == 0: return "THREAD_NOT_BLOCKED"
|
828 | | - elif blocktype == 1: return "THREAD_BLOCK_SLEEP"
|
829 | | - elif blocktype == 2: return "THREAD_BLOCK_MUTEX"
|
830 | | - elif blocktype == 3: return "THREAD_BLOCK_WAKEUP"
|
831 | | - elif blocktype == 4: return "THREAD_DEFUNCT_STKOV"
|
832 | | - elif blocktype == 5: return "THREAD_DEFUNCT_PANIC"
|
| 830 | + def blocktype2name(blocktype, structver):
|
| 831 | + if structver == 1:
|
| 832 | + if blocktype == 0: return "THREAD_NOT_BLOCKED"
|
| 833 | + elif blocktype == 1: return "THREAD_BLOCK_SLEEP"
|
| 834 | + elif blocktype == 2: return "THREAD_BLOCK_MUTEX"
|
| 835 | + elif blocktype == 3: return "THREAD_BLOCK_WAKEUP"
|
| 836 | + elif blocktype == 4: return "THREAD_DEFUNCT_STKOV"
|
| 837 | + elif blocktype == 5: return "THREAD_DEFUNCT_PANIC"
|
| 838 | + else: return "UNKNOWN"
|
833 | 839 | else: return "UNKNOWN"
|
834 | 840 |
|
835 | | - def threadtype2name (threadtype):
|
836 | | - if threadtype == 0: return "USER_THREAD"
|
837 | | - elif threadtype == 1: return "SYSTEM_THREAD"
|
| 841 | + def threadtype2name (threadtype, structver):
|
| 842 | + if structver == 1:
|
| 843 | + if threadtype == 0: return "USER_THREAD"
|
| 844 | + elif threadtype == 1: return "OS_THREAD"
|
| 845 | + elif threadtype == 2: return "CORE_THREAD"
|
| 846 | + else: return "UNKNOWN"
|
838 | 847 | else: return "UNKNOWN"
|
839 | 848 |
|
840 | 849 | def procinfotostring(procinfolist, structver):
|
— | — | @@ -850,7 +859,7 @@ |
851 | 860 | + "R12: 0x%08x, SP: 0x%08x, LR: 0x%08x, PC: 0x%08x\n" \
|
852 | 861 | % (procinfolist[ptr]['regs'][12], procinfolist[ptr]['regs'][13], procinfolist[ptr]['regs'][14], procinfolist[ptr]['regs'][15])
|
853 | 862 | processinfoprint += "cpsr: 0x%08x " % (procinfolist[ptr]['cpsr'])
|
854 | | - processinfoprint += "state: %s " % (state2name([procinfolist[ptr]['state']]))
|
| 863 | + processinfoprint += "state: %s " % (state2name([procinfolist[ptr]['state']], structver))
|
855 | 864 | processinfoprint += "nameptr: 0x%08x\n" % (procinfolist[ptr]['name_ptr'])
|
856 | 865 | processinfoprint += "current cpu time: 0x%08x " % (procinfolist[ptr]['cputime_current'])
|
857 | 866 | processinfoprint += "total cpu time: 0x%016x\n" % (procinfolist[ptr]['cputime_total'])
|
— | — | @@ -860,8 +869,8 @@ |
861 | 870 | processinfoprint += "blocked since: 0x%08x " % (procinfolist[ptr]['blocked_since'])
|
862 | 871 | processinfoprint += "blocked by ptr: 0x%08x\n" % (procinfolist[ptr]['blocked_by_ptr'])
|
863 | 872 | processinfoprint += "err_no: 0x%08x " % (procinfolist[ptr]['err_no'])
|
864 | | - processinfoprint += "block type: %s\n" % (blocktype2name([procinfolist[ptr]['block_type']]))
|
865 | | - processinfoprint += "thread type: %s\n" % (threadtype2name([procinfolist[ptr]['thread_type']]))
|
| 873 | + processinfoprint += "block type: %s\n" % (blocktype2name([procinfolist[ptr]['block_type']], structver))
|
| 874 | + processinfoprint += "thread type: %s\n" % (threadtype2name([procinfolist[ptr]['thread_type']], structver))
|
866 | 875 | processinfoprint += "priority: 0x%02x " % (procinfolist[ptr]['priority'])
|
867 | 876 | processinfoprint += "cpu load: 0x%02x\n" % (procinfolist[ptr]['cpuload'])
|
868 | 877 |
|
— | — | @@ -871,7 +880,7 @@ |
872 | 881 |
|
873 | 882 | return processinfoprint
|
874 | 883 |
|
875 | | -
|
| 884 | + # reading code --------------------------------------------------
|
876 | 885 | self.__myprint("Retrieving process information...", silent)
|
877 | 886 |
|
878 | 887 | offset = 0
|