Changeset b117be8 in rtems-tools for tools/gdb/python/threads.py


Ignore:
Timestamp:
Mar 17, 2015, 2:11:57 AM (4 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, master
Children:
dfc5994
Parents:
a30ec56
git-author:
Chris Johns <chrisj@…> (03/17/15 02:11:57)
git-committer:
Chris Johns <chrisj@…> (03/17/15 02:12:15)
Message:

gdb/python: Update the support to a recent RTEMS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gdb/python/threads.py

    ra30ec56 rb117be8  
    11# RTEMS Tools Project (http://www.rtems.org/)
    2 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     2# Copyright 2010-2015 Chris Johns (chrisj@rtems.org)
    33# All rights reserved.
    44#
     
    3737import objects
    3838import percpu
     39import rbtrees
     40import time
    3941
    4042def task_chain(chain):
    4143    tasks = []
    42     node = chain.first()
     44    if not chain.empty():
     45        node = chain.first()
     46        while not node.null():
     47            t = control(node.cast('Thread_Control'))
     48            tasks.append(t)
     49            node = node(node.next())
     50    return tasks
     51
     52def task_tree(tree):
     53    tasks = []
     54    node = tree.first(rbtrees.rbt_left)
    4355    while not node.null():
    4456        tasks.append(control(node.cast('Thread_Control')))
    45         node.next()
     57        node = node.next(rbtrees.rbt_left)
    4658    return tasks
    4759
     
    129141        return s[:-1]
    130142
     143class cpu_usage():
     144
     145    def __init__(self, time_):
     146        self.time = time.time(time_)
     147
     148    def __str__(self):
     149        return self.time.tostring()
     150
     151    def get(self):
     152        return self.time.get()
     153
    131154class wait_info():
    132155
     
    165188            return float(self.regs[reg])
    166189        return int(self.regs[reg])
    167 
    168190
    169191    def format(self, reg):
     
    209231
    210232    def __init__(self, ctrl):
    211         self.reference = ctrl
    212         self.ctrl = ctrl.dereference()
     233        if ctrl.type.code == gdb.TYPE_CODE_PTR:
     234            self.reference = ctrl
     235            self.ctrl = ctrl.dereference()
     236        else:
     237            self.ctrl = ctrl
     238            self.reference = ctrl.address
    213239        self.object = objects.control(ctrl['Object'])
    214240        self._executing = percpu.thread_active(self.reference)
     
    246272
    247273    def cpu_time_used(self):
    248         return self.ctrl['cpu_time_used']
     274        return cpu_usage(self.ctrl['cpu_time_used'])
    249275
    250276    def preemptible(self):
     
    259285    def registers(self):
    260286        return registers(self.ctrl['Registers'])
     287
     288    def is_idle(self):
     289        return (self.id() & 0xff000000) == 0x90000000
    261290
    262291    def brief(self):
     
    267296    """Manage the Thread_queue_Control."""
    268297
    269     priority_headers = 4
    270 
    271298    def __init__(self, que):
    272         self.que = que
     299        if que.type.code == gdb.TYPE_CODE_PTR:
     300            self.reference = que
     301            self.que = que.dereference()
     302        else:
     303            self.que = que
     304            self.reference = que.address
    273305
    274306    def fifo(self):
     
    285317            t = task_chain(chains.control(self.que['Queues']['Fifo']))
    286318        else:
    287             t = []
    288             for ph in range(0, self.priority_headers):
    289                 t.extend(task_chain(chains.control( \
    290                     self.que['Queues']['Priority'][ph])))
     319            t =  task_tree(rbtrees.control(self.que['Queues']['Priority']))
    291320        return t
Note: See TracChangeset for help on using the changeset viewer.