- pretty printers moved to pretty module
 - command and subcommands get own module
This commit is contained in:
Dhananjay Balan
2013-08-20 21:47:22 +05:30
committed by Chris Johns
parent 2c25dc56ed
commit 8d035f8556
5 changed files with 86 additions and 87 deletions

View File

@@ -12,55 +12,6 @@ import objects
import threads
import classic
# ToDo: Move every printing out
import supercore_printer
import classic_printer
nesting = 0
def type_from_value(val):
type = val.type;
# If it points to a reference, get the reference.
if type.code == gdb.TYPE_CODE_REF:
type = type.target ()
# Get the unqualified type
return type.unqualified ()
def register_rtems_printers (obj):
"Register RTEMS pretty-printers with objfile Obj."
if obj == None:
obj = gdb
obj.pretty_printers.append (lookup_function)
def lookup_function (val):
"Look-up and return a pretty-printer that can print val."
global nesting
typename = str(type_from_value(val))
for function in pp_dict:
if function.search (typename):
nesting += 1
result = pp_dict[function] (val)
nesting -= 1
if nesting == 0:
objects.information.invalidate()
return result
# Cannot find a pretty printer. Return None.
return None
def build_rtems_dict():
pp_dict[re.compile('^rtems_id$')] = lambda val: supercore_printer.id(val)
pp_dict[re.compile('^Objects_Id$')] = lambda val: supercore_printer.id(val)
pp_dict[re.compile('^Objects_Name$')] = lambda val: supercore_printer.name(val)
pp_dict[re.compile('^Objects_Control$')] = lambda val: supercore_printer.control(val)
pp_dict[re.compile('^States_Control$')] = lambda val: supercore_printer.state(val)
pp_dict[re.compile('^rtems_attribute$')] = lambda val: classic_printer.attribute(val)
pp_dict[re.compile('^Semaphore_Control$')] = lambda val: classic_printer.semaphore(val)
class rtems(gdb.Command):
"""Prefix command for RTEMS."""
@@ -157,8 +108,7 @@ class rtems_task(gdb.Command):
try:
index = int(val)
except ValueError:
print "error: %s is not an index" % (val)
return
raise gdb.GdbError( "Value is not an integer")
try:
obj = objects.information.object_return(self.api,
@@ -198,21 +148,6 @@ class rtems_message_queue(gdb.Command):
print "error: index %s is invalid" % (index)
return
print "Ahi"
instance = classic.message_queue(obj)
instance.show(from_tty)
objects.information.invalidate()
#
# Main
#
pp_dict = {}
build_rtems_dict()
gdb.pretty_printers = []
gdb.pretty_printers.append (lookup_function)
rtems()
rtems_object()
rtems_semaphore()
rtems_task()
rtems_message_queue()
objects.information.invalidate()