Changeset 3162858 in rtems-tools


Ignore:
Timestamp:
Aug 26, 2014, 4:57:57 AM (5 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, master
Children:
543a4d1
Parents:
4dbd0db
Message:

gdb-python: Update so 'rtems task' lists the classic tasks.

This is a first pass at cleaning up the support. To use:

$ waf configure --prefix=$HOME/development/rtems/4.11
$ waf build install

Start GDB and break at Init:

(gdb) py import rtems
(gdb) rtems task

will list the classic API tasks.

Location:
tools/gdb/python
Files:
2 added
14 edited

Legend:

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

    r4dbd0db r3162858  
     1# RTEMS Tools Project (http://www.rtems.org/)
     2# Copyright 2014 Chris Johns (chrisj@rtems.org)
     3# All rights reserved.
     4#
     5# This file is part of the RTEMS Tools package in 'rtems-tools'.
     6#
     7# Redistribution and use in source and binary forms, with or without
     8# modification, are permitted provided that the following conditions are met:
     9#
     10# 1. Redistributions of source code must retain the above copyright notice,
     11# this list of conditions and the following disclaimer.
     12#
     13# 2. Redistributions in binary form must reproduce the above copyright notice,
     14# this list of conditions and the following disclaimer in the documentation
     15# and/or other materials provided with the distribution.
     16#
     17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
     21# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27# POSSIBILITY OF SUCH DAMAGE.
     28#
    129
    2 if __name__ == "__main__":
    3     import sys
    4     import os.path
    5     sys.path.append(os.path.dirname(__file__))
    6     import main
     30import gdb
     31import rtems
    732
    8     print 'RTEMS GDB Support loaded'
     33def get_architure():
     34    frame = gdb.selected_frame()
     35    arch = frame.architecture()
     36    return arch.name()
     37
     38_cmds = rtems.create()
     39
     40print 'RTEMS GDB Support'
  • tools/gdb/python/chains.py

    r4dbd0db r3162858  
     1# RTEMS Tools Project (http://www.rtems.org/)
     2# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# All rights reserved.
     4#
     5# This file is part of the RTEMS Tools package in 'rtems-tools'.
     6#
     7# Redistribution and use in source and binary forms, with or without
     8# modification, are permitted provided that the following conditions are met:
     9#
     10# 1. Redistributions of source code must retain the above copyright notice,
     11# this list of conditions and the following disclaimer.
     12#
     13# 2. Redistributions in binary form must reproduce the above copyright notice,
     14# this list of conditions and the following disclaimer in the documentation
     15# and/or other materials provided with the distribution.
     16#
     17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
     21# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27# POSSIBILITY OF SUCH DAMAGE.
     28#
     29
    130#
    231# RTEMS Chains Support
    3 # Copyright 2010 Chris Johns (chrisj@rtems.org)
    4 #
    5 # $Id$
    632#
    733
  • tools/gdb/python/classic.py

    r4dbd0db r3162858  
     1# RTEMS Tools Project (http://www.rtems.org/)
     2# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# All rights reserved.
     4#
     5# This file is part of the RTEMS Tools package in 'rtems-tools'.
     6#
     7# Redistribution and use in source and binary forms, with or without
     8# modification, are permitted provided that the following conditions are met:
     9#
     10# 1. Redistributions of source code must retain the above copyright notice,
     11# this list of conditions and the following disclaimer.
     12#
     13# 2. Redistributions in binary form must reproduce the above copyright notice,
     14# this list of conditions and the following disclaimer in the documentation
     15# and/or other materials provided with the distribution.
     16#
     17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
     21# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27# POSSIBILITY OF SUCH DAMAGE.
     28#
     29
    130#
    231# RTEMS Classic API Support
    3 # Copyright 2010 Chris Johns (chrisj@rtems.org)
    4 #
    5 # $Id$
    632#
    733
     
    1743import heaps
    1844import supercore
    19 import sparc
    2045
    2146class attribute:
     
    111136
    112137    def __init__(self, obj):
    113         self.object = obj
     138        self.reference = obj
     139        self.object = obj.dereference()
    114140        self.object_control = objects.control(self.object['Object'])
    115141        self.attr = attribute(self.object['attribute_set'], 'semaphore')
     
    153179
    154180    def __init__(self, obj):
    155         self.object = obj
    156         self.task = \
    157             threads.control(self.object)
     181        self.reference = obj
     182        self.object = obj.dereference()
     183        self.task = threads.control(self.reference)
    158184        self.wait_info = self.task.wait_info()
    159         # ToDo: Insert platform dep. code here.
    160         self.regs = sparc.register(self.object['Registers'])
    161 
    162     def show(self, from_tty):
    163         print '     Name:', self.task.name()
    164         print '    State:', self.task.current_state()
    165         print '  Current:', self.task.current_priority()
    166         print '     Real:', self.task.real_priority()
    167         print '  Preempt:', self.task.preemptible()
    168         print ' T Budget:', self.task.cpu_time_budget()
    169         print ' Regsters:'
    170         self.regs.show()
    171 
     185        self.regs = self.task.registers()
     186        #self.regs = sparc.register(self.object['Registers'])
     187
     188    def show(self, from_tty):
     189        cpu = self.task.executing()
     190        if cpu == -1:
     191            cpu = 'not executing'
     192        print '         Id:', '0x%08x' % (self.task.id())
     193        print '       Name:', self.task.name()
     194        print ' Active CPU:', cpu
     195        print '      State:', self.task.current_state()
     196        print '    Current:', self.task.current_priority()
     197        print '       Real:', self.task.real_priority()
     198        print '    Preempt:', self.task.preemptible()
     199        print '   T Budget:', self.task.cpu_time_budget()
     200        print '       Time:', self.task.cpu_time_used()
     201        print '  Resources:', self.task.resource_count()
     202        print '  Regsters:'
     203        for name in self.regs.names():
     204            val = self.regs.get(name)
     205            print '    %20s: %08x (%d)' % (name, val, val)
    172206
    173207class message_queue:
    174208    "Print classic messege queue"
    175209
    176     def __init__(self,obj):
    177         self.object = obj
     210    def __init__(self, obj):
     211        self.reference = obj
     212        self.object = obj.dereference()
    178213        self.object_control = objects.control(self.object['Object'])
    179214        self.attr = attribute(self.object['attribute_set'], \
     
    194229
    195230    def __init__(self, obj):
    196         self.object = obj
     231        self.reference = obj
     232        self.object = obj.dereference()
    197233        self.object_control = objects.control(self.object['Object'])
    198234        self.watchdog = watchdog.control(self.object['Ticker'])
     
    206242
    207243    def __init__(self, obj):
    208         self.object = obj
     244        self.reference = obj
     245        self.object = obj.dereference()
    209246        self.object_control = objects.control(self.object['Object'])
    210247        self.attr = attribute(self.object['attribute_set'], 'partition')
     
    225262    "prints a classic region"
    226263
    227     def __init__(self,obj):
    228         self.object = obj
     264    def __init__(self, obj):
     265        self.reference = obj
     266        self.object = obj.dereference()
    229267        self.object_control = objects.control(self.object['Object'])
    230268        self.attr = attribute(self.object['attribute_set'], 'region')
     
    242280    '''classic barrier abstraction'''
    243281
    244     def __init__(self,obj):
    245         self.object = obj
     282    def __init__(self, obj):
     283        self.reference = obj
     284        self.object = obj.dereference()
    246285        self.object_control = objects.control(self.object['Object'])
    247286        self.attr = attribute(self.object['attribute_set'],'barrier')
     
    258297        print '  Waiting:',self.core_b_control.waiting_threads()
    259298        helper.tasks_printer_routine(self.core_b_control.tasks())
    260 
    261 
  • tools/gdb/python/heaps.py

    r4dbd0db r3162858  
     1# RTEMS Tools Project (http://www.rtems.org/)
     2# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# All rights reserved.
     4#
     5# This file is part of the RTEMS Tools package in 'rtems-tools'.
     6#
     7# Redistribution and use in source and binary forms, with or without
     8# modification, are permitted provided that the following conditions are met:
     9#
     10# 1. Redistributions of source code must retain the above copyright notice,
     11# this list of conditions and the following disclaimer.
     12#
     13# 2. Redistributions in binary form must reproduce the above copyright notice,
     14# this list of conditions and the following disclaimer in the documentation
     15# and/or other materials provided with the distribution.
     16#
     17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
     21# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27# POSSIBILITY OF SUCH DAMAGE.
     28#
     29
    130#
    231# RTEMS heap
  • tools/gdb/python/helper.py

    r4dbd0db r3162858  
     1# RTEMS Tools Project (http://www.rtems.org/)
     2# All rights reserved.
     3#
     4# This file is part of the RTEMS Tools package in 'rtems-tools'.
     5#
     6# Redistribution and use in source and binary forms, with or without
     7# modification, are permitted provided that the following conditions are met:
     8#
     9# 1. Redistributions of source code must retain the above copyright notice,
     10# this list of conditions and the following disclaimer.
     11#
     12# 2. Redistributions in binary form must reproduce the above copyright notice,
     13# this list of conditions and the following disclaimer in the documentation
     14# and/or other materials provided with the distribution.
     15#
     16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     17# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
     20# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26# POSSIBILITY OF SUCH DAMAGE.
     27#
     28
    129#
    230# RTEMS GDB support helper routins.
     31#
    332
    433import gdb
  • tools/gdb/python/objects.py

    r4dbd0db r3162858  
     1# RTEMS Tools Project (http://www.rtems.org/)
     2# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# All rights reserved.
     4#
     5# This file is part of the RTEMS Tools package in 'rtems-tools'.
     6#
     7# Redistribution and use in source and binary forms, with or without
     8# modification, are permitted provided that the following conditions are met:
     9#
     10# 1. Redistributions of source code must retain the above copyright notice,
     11# this list of conditions and the following disclaimer.
     12#
     13# 2. Redistributions in binary form must reproduce the above copyright notice,
     14# this list of conditions and the following disclaimer in the documentation
     15# and/or other materials provided with the distribution.
     16#
     17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
     21# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27# POSSIBILITY OF SUCH DAMAGE.
     28#
     29
    130#
    231# RTEMS Objects Support
    3 # Copyright 2010 Chris Johns (chrisj@rtems.org)
    4 #
    5 # $Id$
    632#
    733
     
    1036import re
    1137
    12 class infotables:
     38class infotables():
    1339    """Manage the object information tables."""
    1440
     
    3763
    3864    def name(self, api, _class):
    39         return api + '/' + _class
     65        return '%s/%s' % (api, _class)
    4066
    4167    def load(self, n):
     
    5076            return self.tables[n]
    5177        return None
     78
     79    def minimum_id(self, api, _class):
     80        n = self.name(api, _class)
     81        self.load(n)
     82        return int(self.tables[n]['minimum_id'])
     83
     84    def maximum_id(self, api, _class):
     85        n = self.name(api, _class)
     86        self.load(n)
     87        return int(self.tables[n]['maximum_id'])
    5288
    5389    def maximum(self, api, _class):
     
    72108        n = self.name(api, _class)
    73109        self.load(n)
    74 
    75110        table_type = self.tables_types[n]
    76 
    77111        if api == 'internal':
    78             expr = '(' + table_type[0] + ')' + table_type[1]
    79 
     112            expr = '(%s) %s' % (table_type[0], table_type[1])
    80113        else:
    81114            max = self.maximum(api, _class)
    82115            if index > max:
    83116                raise IndexError('object index out of range (%d)' % (max))
    84             expr = '(' + table_type[0] + '*)' + \
    85                 table_type[1] + '.local_table[' + str(index) + ']'
     117            expr = '(%s*) %s.local_table[%d]' % (table_type[0], table_type[1], index)
    86118        return gdb.parse_and_eval(expr)
    87119
     
    99131information = infotables()
    100132
    101 class ident:
     133class ident():
    102134    "An RTEMS object id with support for its bit fields."
    103135
     
    114146
    115147    OBJECT_16_BITS = 0
    116     OBJECT_31_BITS = 1
     148    OBJECT_32_BITS = 1
    117149
    118150    api_labels = [
     
    120152        'internal',
    121153        'classic',
    122         'posix',
    123         'itron'
     154        'posix'
    124155        ]
    125156
     
    151182                   'spinlocks',
    152183                   'rwlocks'),
    153         'itron' : ('none',
    154                    'tasks',
    155                    'eventflags',
    156                    'mailboxes',
    157                    'message_buffers',
    158                    'ports',
    159                    'semaphores',
    160                    'variable_memory_pools',
    161                    'fixed_memory_pools')
    162184        }
    163185
     
    171193            self.idSize = self.OBJECT_16_BITS
    172194        else:
    173             self.idSize = self.OBJECT_31_BITS
     195            self.idSize = self.OBJECT_32_BITS
    174196
    175197    def get(self, field):
     
    213235        return self.api() != 'none' and self._class() != 'invalid'
    214236
    215 class name:
     237class name():
    216238    """The Objects_Name can either be told what the name is or can take a
    217239    guess."""
     
    221243        if is_string == None:
    222244            self.is_string = 'auto'
     245            try:
     246                self.name_p = self.name['name_p']
     247            except gdb.Error:
     248                self.is_string = 'no'
    223249        else:
    224250            if is_string:
     
    228254
    229255    def __str__(self):
     256        return self.get()
     257
     258    def get(self):
    230259        if self.is_string != 'yes':
    231260            u32 = int(self.name['name_u32'])
    232             s = chr((u32 >> 24) & 0xff) + \
    233                 chr((u32 >> 16) & 0xff) + chr((u32 >> 8) & 0xff) + \
    234                 chr(u32 & 0xff)
    235             for c in range(0,4):
    236                 if s[c] < ' ' or s[c] > '~':
    237                     s = None
    238                     break
    239             if s:
    240                 return s
    241         return str(self.name['name_p'].dereference())
    242 
    243 class control:
     261            if u32 != 0:
     262                s = chr((u32 >> 24) & 0xff) + \
     263                    chr((u32 >> 16) & 0xff) + \
     264                    chr((u32 >> 8) & 0xff) + \
     265                    chr(u32 & 0xff)
     266                for c in range(0, 4):
     267                    if s[c] < ' ' or s[c] > '~':
     268                        s = None
     269                        break
     270                if s:
     271                    return s
     272            if self.is_string == 'xno':
     273                return None
     274        try:
     275            name_p = self.name['name_p']
     276            return str(name_p.dereference())
     277        except gdb.Error:
     278            pass
     279        return None
     280
     281class control():
    244282    """The Objects_Control structure."""
    245283
     
    247285        self.object = object
    248286        self._id = ident(self.object['id'])
     287        self._name = name(self.object['name'],
     288                          information.is_string(self._id.api(), self._id._class()))
    249289
    250290    def node(self):
     
    255295
    256296    def name(self):
    257         is_string = information.is_string(self._id.api(), self._id._class())
    258         val = str(name(self.object['name'],is_string))
    259 
    260         # Normal comaprision is a bit tricky with quotes
    261         # 0 '\000' in hex == '3020275c30303027'
    262         if val.encode('hex') == '3020275c30303027':
    263             val = ""
    264 
    265         return val
     297        return self._name.get()
  • tools/gdb/python/pretty.py

    r4dbd0db r3162858  
     1# RTEMS Tools Project (http://www.rtems.org/)
     2# All rights reserved.
     3#
     4# This file is part of the RTEMS Tools package in 'rtems-tools'.
     5#
     6# Redistribution and use in source and binary forms, with or without
     7# modification, are permitted provided that the following conditions are met:
     8#
     9# 1. Redistributions of source code must retain the above copyright notice,
     10# this list of conditions and the following disclaimer.
     11#
     12# 2. Redistributions in binary form must reproduce the above copyright notice,
     13# this list of conditions and the following disclaimer in the documentation
     14# and/or other materials provided with the distribution.
     15#
     16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     17# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
     20# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26# POSSIBILITY OF SUCH DAMAGE.
     27#
     28
    129#
    230# RTEMS pretty printers
    331#
     32
    433import re
    534import helper
  • tools/gdb/python/rtems.py

    r4dbd0db r3162858  
     1# RTEMS Tools Project (http://www.rtems.org/)
     2# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# All rights reserved.
     4#
     5# This file is part of the RTEMS Tools package in 'rtems-tools'.
     6#
     7# Redistribution and use in source and binary forms, with or without
     8# modification, are permitted provided that the following conditions are met:
     9#
     10# 1. Redistributions of source code must retain the above copyright notice,
     11# this list of conditions and the following disclaimer.
     12#
     13# 2. Redistributions in binary form must reproduce the above copyright notice,
     14# this list of conditions and the following disclaimer in the documentation
     15# and/or other materials provided with the distribution.
     16#
     17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
     21# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27# POSSIBILITY OF SUCH DAMAGE.
     28#
     29
    130#
    231# RTEMS Pretty Printers
    3 # Copyright 2010 Chris Johns (chrisj@rtems.org)
    4 #
    5 # $Id$
    632#
    733
     
    3056
    3157    objects = {
    32         'classic/semaphores': lambda obj: classic.semaphore(obj),
    33         'classic/tasks': lambda obj: classic.task(obj),
     58        'classic/semaphores':     lambda obj: classic.semaphore(obj),
     59        'classic/tasks':          lambda obj: classic.task(obj),
    3460        'classic/message_queues': lambda obj: classic.message_queue(obj),
    35         'classic/timers' : lambda obj: classic.timer(obj),
    36         'classic/partitions' : lambda obj: classic.partition(obj),
    37         'classic/regions' : lambda obj: classic.region(obj),
    38         'classic/barriers' : lambda obj: classic.barrier(obj)
    39         }
    40 
    41     def __init__(self):
    42         self.__doc__ = 'Display the RTEMS object given a numeric ID \
    43                                             (Or a reference to rtems_object).'
     61        'classic/timers' :        lambda obj: classic.timer(obj),
     62        'classic/partitions' :    lambda obj: classic.partition(obj),
     63        'classic/regions' :       lambda obj: classic.region(obj),
     64        'classic/barriers' :      lambda obj: classic.barrier(obj)
     65    }
     66
     67    def __init__(self):
     68        self.__doc__ = 'Display the RTEMS object given a numeric ID' \
     69                       '(Or a reference to the object).'
    4470        super(rtems_object, self).__init__('rtems object',
    4571                                           gdb.COMMAND_DATA,
     
    80106                                           gdb.COMPLETE_NONE)
    81107
    82     def instance(self,obj):
    83         '''Returns a n instance of corresponding object, the child should extend this'''
     108    def instance(self, obj):
     109        '''Returns a n instance of corresponding object, the child should extend
     110           this'''
    84111        return obj
    85112
    86113    def invoke(self, arg, from_tty):
    87         for val in arg.split():
    88             try:
    89                 index = int(val)
    90             except ValueError:
    91                 print "error: %s is not an index" % (val)
    92                 return
    93             try:
    94                 obj = objects.information.object_return( self.api,
    95                                                          self._class,
    96                                                          index ).dereference()
    97             except IndexError:
    98                 print "error: index %s is invalid" % (index)
    99                 return
    100 
    101             instance = self.instance(obj)
    102             instance.show(from_tty)
    103         objects.information.invalidate()
    104 
     114        maximum = objects.information.maximum(self.api, self._class)
     115        minimum_id = objects.ident(objects.information.minimum_id(self.api, self._class))
     116        maximum_id = objects.ident(objects.information.minimum_id(self.api, self._class))
     117        args = arg.split()
     118        if len(args):
     119            for val in args:
     120                try:
     121                    index = int(val, base = 0)
     122                    if index < maximum:
     123                        if index < minimum_id.index():
     124                            print "error: %s is not an index (min is %d)" % (val,
     125                                                                             minimum_id.index())
     126                            return
     127                    else:
     128                        index = objects.ident(index).index()
     129                except ValueError:
     130                    print "error: %s is not an index" % (val)
     131                    return
     132                try:
     133                    obj = objects.information.object_return(self.api,
     134                                                            self._class,
     135                                                            index)
     136                except IndexError:
     137                    print "error: index %s is invalid" % (index)
     138                    return
     139                instance = self.instance(obj)
     140                instance.show(from_tty)
     141            objects.information.invalidate()
     142        else:
     143            print '-' * 70
     144            print ' %s: %d [%08x -> %08x]' % (objects.information.name(self.api, self._class),
     145                                             maximum, minimum_id.value(), maximum_id.value())
     146            for index in range(minimum_id.index(), minimum_id.index() + maximum):
     147                print '-' * 70
     148                self.invoke(str(index), from_tty)
    105149
    106150class rtems_semaphore(rtems_index):
     
    112156        super(rtems_semaphore, self).__init__('rtems semaphore')
    113157
    114     def instance(self,obj):
     158    def instance(self, obj):
    115159        return classic.semaphore(obj)
    116160
     
    124168        super(rtems_task,self).__init__('rtems task')
    125169
    126     def instance(self,obj):
     170    def instance(self, obj):
    127171        return classic.task(obj)
    128 
    129172
    130173class rtems_message_queue(rtems_index):
     
    137180        super(rtems_message_queue,self).__init__('rtems mqueue')
    138181
    139     def instance(self,obj):
     182    def instance(self, obj):
    140183        return classic.message_queue(obj)
    141184
     
    149192        super(rtems_timer, self).__init__('rtems timer')
    150193
    151     def instance(self,obj):
     194    def instance(self, obj):
    152195        return classic.timer(obj)
    153196
     
    253296        super(rtems_wsec, self).__init__('rtems wdseconds')
    254297
     298def create():
     299    return (rtems(),
     300            rtems_object(),
     301            rtems_semaphore(),
     302            rtems_task(),
     303            rtems_message_queue(),
     304            rtems_tod(),
     305            rtems_wdt(),
     306            rtems_wsec())
  • tools/gdb/python/sparc.py

    r4dbd0db r3162858  
    7474            return val
    7575
    76     def __init__(self,reg):
     76    def __init__(self, reg):
    7777        self.reg = reg
    7878
  • tools/gdb/python/supercore.py

    r4dbd0db r3162858  
     1# RTEMS Tools Project (http://www.rtems.org/)
     2# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# All rights reserved.
     4#
     5# This file is part of the RTEMS Tools package in 'rtems-tools'.
     6#
     7# Redistribution and use in source and binary forms, with or without
     8# modification, are permitted provided that the following conditions are met:
     9#
     10# 1. Redistributions of source code must retain the above copyright notice,
     11# this list of conditions and the following disclaimer.
     12#
     13# 2. Redistributions in binary form must reproduce the above copyright notice,
     14# this list of conditions and the following disclaimer in the documentation
     15# and/or other materials provided with the distribution.
     16#
     17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
     21# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27# POSSIBILITY OF SUCH DAMAGE.
     28#
     29
    130#
    231# RTEMS Supercore Objects
  • tools/gdb/python/supercore_printer.py

    r4dbd0db r3162858  
     1# RTEMS Tools Project (http://www.rtems.org/)
     2# All rights reserved.
     3#
     4# This file is part of the RTEMS Tools package in 'rtems-tools'.
     5#
     6# Redistribution and use in source and binary forms, with or without
     7# modification, are permitted provided that the following conditions are met:
     8#
     9# 1. Redistributions of source code must retain the above copyright notice,
     10# this list of conditions and the following disclaimer.
     11#
     12# 2. Redistributions in binary form must reproduce the above copyright notice,
     13# this list of conditions and the following disclaimer in the documentation
     14# and/or other materials provided with the distribution.
     15#
     16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     17# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
     20# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26# POSSIBILITY OF SUCH DAMAGE.
     27#
     28
    129#
    230# RTEMS Supercore pretty printers for GDB
    331#
     32
    433import objects
    534import itertools
  • tools/gdb/python/threads.py

    r4dbd0db r3162858  
     1# RTEMS Tools Project (http://www.rtems.org/)
     2# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# All rights reserved.
     4#
     5# This file is part of the RTEMS Tools package in 'rtems-tools'.
     6#
     7# Redistribution and use in source and binary forms, with or without
     8# modification, are permitted provided that the following conditions are met:
     9#
     10# 1. Redistributions of source code must retain the above copyright notice,
     11# this list of conditions and the following disclaimer.
     12#
     13# 2. Redistributions in binary form must reproduce the above copyright notice,
     14# this list of conditions and the following disclaimer in the documentation
     15# and/or other materials provided with the distribution.
     16#
     17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
     21# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27# POSSIBILITY OF SUCH DAMAGE.
     28#
     29
    130#
    231# RTEMS Threads Support
    3 # Copyright 2010 Chris Johns (chrisj@rtems.org)
    4 #
    5 # $Id$
    632#
    733
    834import gdb
     35
    936import chains
    1037import objects
     38import percpu
    1139
    1240def task_chain(chain):
     
    1846    return tasks
    1947
    20 class state:
     48class state():
    2149
    2250    ALL_SET = 0x000fffff
     
    101129        return s[:-1]
    102130
    103 class wait_info:
     131class wait_info():
    104132
    105133    def __init__(self, info):
     
    124152        return task_chain(chains.control(self.info['queue']))
    125153
    126 class control:
     154class registers():
     155
     156    def __init__(self, regs):
     157        self.regs = regs
     158
     159    def names(self):
     160        return [field.name for field in self.regs.type.fields()]
     161
     162    def get(self, reg):
     163        t = str(self.regs[reg].type)
     164        if t in ['double']:
     165            return float(self.regs[reg])
     166        return int(self.regs[reg])
     167
     168
     169    def format(self, reg):
     170        t = self.regs[reg].type
     171        if t in ['uint32_t', 'unsigned', 'unsigned long']:
     172            return '%08x (%d)' % (val)
     173
     174class control():
     175    '''
     176    Thread_Control has the following fields:
     177      Object              Objects_Control
     178      RBNode              RBTree_Node
     179      current_state       States_Control
     180      current_priority    Priority_Control
     181      real_priority       Priority_Control
     182      resource_count      uint32_t
     183      Wait                Thread_Wait_information
     184      Timer               Watchdog_Control
     185      receive_packet      MP_packet_Prefix*                   X
     186      lock_mutex          Chain_Control                       X
     187      Resource_node       Resource_Node                       X
     188      is_global           bool                                X
     189      is_preemptible      bool
     190      Scheduler           Thread_Scheduler_control
     191      rtems_ada_self      void*                               X
     192      cpu_time_budget     uint32_t
     193      budget_algorithm    Thread_CPU_budget_algorithms
     194      budget_callout      Thread_CPU_budget_algorithm_callout
     195      cpu_time_used       Thread_CPU_usage_t
     196      Start               Thread_Start_information
     197      Post_switch_actions Thread_Action_control
     198      Registers           Context_Control
     199      fp_context          Context_Control_fp*                 X
     200      libc_reent          struct _reent*
     201      API_Extensions      void*[THREAD_API_LAST + 1]
     202      task_variables      rtems_task_variable_t*              X
     203      Key_Chain           Chain_Control
     204      Life                Thread_Life_control
     205      extensions          void*[RTEMS_ZERO_LENGTH_ARRAY]
     206
     207    where 'X' means the field is condition and may no exist.
     208    '''
    127209
    128210    def __init__(self, ctrl):
    129         self.ctrl = ctrl
     211        self.reference = ctrl
     212        self.ctrl = ctrl.dereference()
    130213        self.object = objects.control(ctrl['Object'])
     214        self._executing = percpu.thread_active(self.reference)
     215        self._heir = percpu.thread_heir(self.reference)
    131216
    132217    def id(self):
     
    139224        return val
    140225
     226    def executing(self):
     227        return self._executing
     228
     229    def heir(self):
     230        return self._heir
     231
    141232    def current_state(self):
    142233        return state(self.ctrl['current_state']).to_string()
     
    148239        return self.ctrl['real_priority']
    149240
     241    def resource_count(self):
     242        return self.ctrl['resource_count']
     243
     244    def cpu_time_budget(self):
     245        return self.ctrl['cpu_time_budget']
     246
     247    def cpu_time_used(self):
     248        return self.ctrl['cpu_time_used']
     249
    150250    def preemptible(self):
    151251        return self.ctrl['is_preemptible']
     
    156256    def wait_info(self):
    157257        return wait_info(self.ctrl['Wait'])
     258
     259    def registers(self):
     260        return registers(self.ctrl['Registers'])
    158261
    159262    def brief(self):
     
    161264            (self.name(), self.current_priority(), self.real_priority())
    162265
    163 class queue:
     266class queue():
    164267    """Manage the Thread_queue_Control."""
    165268
     
    187290                    self.que['Queues']['Priority'][ph])))
    188291        return t
    189 
    190 
    191 
  • tools/gdb/python/watchdog.py

    r4dbd0db r3162858  
     1# RTEMS Tools Project (http://www.rtems.org/)
     2# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# All rights reserved.
     4#
     5# This file is part of the RTEMS Tools package in 'rtems-tools'.
     6#
     7# Redistribution and use in source and binary forms, with or without
     8# modification, are permitted provided that the following conditions are met:
     9#
     10# 1. Redistributions of source code must retain the above copyright notice,
     11# this list of conditions and the following disclaimer.
     12#
     13# 2. Redistributions in binary form must reproduce the above copyright notice,
     14# this list of conditions and the following disclaimer in the documentation
     15# and/or other materials provided with the distribution.
     16#
     17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
     21# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27# POSSIBILITY OF SUCH DAMAGE.
     28#
     29
    130#
    231# RTEMS Watchdog Support
    3 # Copyright 2010 Chris Johns (chrisj@rtems.org)
    4 #
    5 # $Id$
    632#
    733
  • tools/gdb/python/wscript

    r4dbd0db r3162858  
    77
    88def build(bld):
    9     bld.install_files('${PREFIX}/share/gdb/python/rtems',
    10                       ['chains.py',
    11                        'classic.py',
    12                        'classic_printer.py',
    13                        'heaps.py',
    14                        'helper.py',
    15                        'main.py',
    16                        'objects.py',
    17                        'pretty.py',
    18                        'rtems.py',
    19                        'sparc.py',
    20                        'supercore.py',
    21                        'supercore_printer.py',
    22                        'threads.py',
    23                        'watchdog.py'])
     9    source = ['__init__.py',
     10              'chains.py',
     11              'classic.py',
     12              'classic_printer.py',
     13              'configuration.py',
     14              'heaps.py',
     15              'helper.py',
     16              'main.py',
     17              'objects.py',
     18              'percpu.py',
     19              'pretty.py',
     20              'rtems.py',
     21              'sparc.py',
     22              'supercore.py',
     23              'supercore_printer.py',
     24              'threads.py',
     25              'watchdog.py']
     26    bld(features = 'py', source = source, install_path = None)
     27    bld.install_files('${PREFIX}/share/gdb/python/rtems', source)
Note: See TracChangeset for help on using the changeset viewer.