Changeset 8d035f8 in rtems-tools


Ignore:
Timestamp:
Aug 20, 2013, 4:17:22 PM (6 years ago)
Author:
Dhananjay Balan <mb.dhananjay@…>
Branches:
4.10, 4.11, master
Children:
d4fc2d5
Parents:
2c25dc5
git-author:
Dhananjay Balan <mb.dhananjay@…> (08/20/13 16:17:22)
git-committer:
Chris Johns <chrisj@…> (08/24/14 23:52:41)
Message:

Refactor

  • pretty printers moved to pretty module
  • command and subcommands get own module
Location:
tools/gdb/python
Files:
2 added
3 edited

Legend:

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

    r2c25dc5 r8d035f8  
    44    import os.path
    55    sys.path.append(os.path.dirname(__file__))
    6     import supercore
    7     import chains
    8     import rtems
    9     import classic
    10     import objects
    11     import threads
    12 
    13     import supercore_printer
    14     import classic_printer
    15 
    16     # Needed inorder to reload code from inside gdb
    17     reload(supercore)
    18     reload(chains)
    19     reload(rtems)
    20     reload(classic)
    21     reload(objects)
    22     reload(threads)
    23     reload(supercore_printer)
    24     reload(classic_printer)
     6    import main
    257
    268    print 'RTEMS GDB Support loaded'
  • tools/gdb/python/helper.py

    r2c25dc5 r8d035f8  
    11#
    22# RTEMS GDB support helper routins.
     3
     4import gdb
    35
    46def tasks_printer_routine(wait_queue):
     
    79    for t in range(0, len(tasks)):
    810        print '      ', tasks[t].brief(), ' (%08x)' % (tasks[t].id())
     11
     12def type_from_value(val):
     13    type = val.type;
     14    # If it points to a reference, get the reference.
     15    if type.code == gdb.TYPE_CODE_REF:
     16        type = type.target ()
     17    # Get the unqualified type
     18    return type.unqualified ()
  • tools/gdb/python/rtems.py

    r2c25dc5 r8d035f8  
    1313import classic
    1414
    15 # ToDo: Move every printing out
    16 import supercore_printer
    17 import classic_printer
    18 
    19 nesting = 0
    20 
    21 def type_from_value(val):
    22     type = val.type;
    23     # If it points to a reference, get the reference.
    24     if type.code == gdb.TYPE_CODE_REF:
    25         type = type.target ()
    26     # Get the unqualified type
    27     return type.unqualified ()
    28 
    29 def register_rtems_printers (obj):
    30     "Register RTEMS pretty-printers with objfile Obj."
    31 
    32     if obj == None:
    33         obj = gdb
    34 
    35     obj.pretty_printers.append (lookup_function)
    36 
    37 def lookup_function (val):
    38     "Look-up and return a pretty-printer that can print val."
    39 
    40     global nesting
    41 
    42     typename = str(type_from_value(val))
    43 
    44     for function in pp_dict:
    45         if function.search (typename):
    46             nesting += 1
    47             result = pp_dict[function] (val)
    48             nesting -= 1
    49             if nesting == 0:
    50                 objects.information.invalidate()
    51             return result
    52 
    53     # Cannot find a pretty printer.  Return None.
    54     return None
    55 
    56 def build_rtems_dict():
    57     pp_dict[re.compile('^rtems_id$')]   = lambda val: supercore_printer.id(val)
    58     pp_dict[re.compile('^Objects_Id$')] = lambda val: supercore_printer.id(val)
    59     pp_dict[re.compile('^Objects_Name$')] = lambda val: supercore_printer.name(val)
    60     pp_dict[re.compile('^Objects_Control$')] = lambda val: supercore_printer.control(val)
    61     pp_dict[re.compile('^States_Control$')] = lambda val: supercore_printer.state(val)
    62     pp_dict[re.compile('^rtems_attribute$')] = lambda val: classic_printer.attribute(val)
    63     pp_dict[re.compile('^Semaphore_Control$')] = lambda val: classic_printer.semaphore(val)
    6415
    6516class rtems(gdb.Command):
     
    158109                index = int(val)
    159110            except ValueError:
    160                 print "error: %s is not an index" % (val)
    161                 return
     111                raise gdb.GdbError( "Value is not an integer")
    162112
    163113            try:
     
    199149                return
    200150
    201             print "Ahi"
    202151            instance = classic.message_queue(obj)
    203152            instance.show(from_tty)
    204153        objects.information.invalidate()
    205 
    206 
    207 #
    208 # Main
    209 #
    210 pp_dict = {}
    211 build_rtems_dict()
    212 gdb.pretty_printers = []
    213 gdb.pretty_printers.append (lookup_function)
    214 rtems()
    215 rtems_object()
    216 rtems_semaphore()
    217 rtems_task()
    218 rtems_message_queue()
Note: See TracChangeset for help on using the changeset viewer.