summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2014-08-26 14:57:57 +1000
committerChris Johns <chrisj@rtems.org>2014-08-26 14:57:57 +1000
commit3162858a3a0ec414d2b5ce3d9153ca0efb2c9d27 (patch)
treec3e84f6cba14b44d519d302566c0c4b581b51c60 /tools
parent4dbd0db60d1d0a3af7c2311911d6a6a638ccca84 (diff)
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.
Diffstat (limited to 'tools')
-rw-r--r--tools/gdb/python/__init__.py44
-rw-r--r--tools/gdb/python/chains.py32
-rw-r--r--tools/gdb/python/classic.py95
-rw-r--r--tools/gdb/python/configuration.py110
-rw-r--r--tools/gdb/python/heaps.py31
-rw-r--r--tools/gdb/python/helper.py31
-rw-r--r--tools/gdb/python/objects.py126
-rw-r--r--tools/gdb/python/percpu.py57
-rw-r--r--tools/gdb/python/pretty.py29
-rw-r--r--tools/gdb/python/rtems.py126
-rw-r--r--tools/gdb/python/sparc.py4
-rw-r--r--tools/gdb/python/supercore.py29
-rw-r--r--tools/gdb/python/supercore_printer.py31
-rw-r--r--tools/gdb/python/threads.py122
-rw-r--r--tools/gdb/python/watchdog.py34
-rw-r--r--tools/gdb/python/wscript34
16 files changed, 778 insertions, 157 deletions
diff --git a/tools/gdb/python/__init__.py b/tools/gdb/python/__init__.py
index 36d2c06..58c8625 100644
--- a/tools/gdb/python/__init__.py
+++ b/tools/gdb/python/__init__.py
@@ -1,8 +1,40 @@
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2014 Chris Johns (chrisj@rtems.org)
+# All rights reserved.
+#
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
-if __name__ == "__main__":
- import sys
- import os.path
- sys.path.append(os.path.dirname(__file__))
- import main
+import gdb
+import rtems
- print 'RTEMS GDB Support loaded'
+def get_architure():
+ frame = gdb.selected_frame()
+ arch = frame.architecture()
+ return arch.name()
+
+_cmds = rtems.create()
+
+print 'RTEMS GDB Support'
diff --git a/tools/gdb/python/chains.py b/tools/gdb/python/chains.py
index ef33ed6..6ae2518 100644
--- a/tools/gdb/python/chains.py
+++ b/tools/gdb/python/chains.py
@@ -1,8 +1,34 @@
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# All rights reserved.
#
-# RTEMS Chains Support
-# Copyright 2010 Chris Johns (chrisj@rtems.org)
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
#
-# $Id$
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+#
+# RTEMS Chains Support
#
import gdb
diff --git a/tools/gdb/python/classic.py b/tools/gdb/python/classic.py
index e492657..44a92b4 100644
--- a/tools/gdb/python/classic.py
+++ b/tools/gdb/python/classic.py
@@ -1,8 +1,34 @@
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# All rights reserved.
#
-# RTEMS Classic API Support
-# Copyright 2010 Chris Johns (chrisj@rtems.org)
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
#
-# $Id$
+# RTEMS Classic API Support
#
import gdb
@@ -16,7 +42,6 @@ import threads
import watchdog
import heaps
import supercore
-import sparc
class attribute:
"""The Classic API attribute."""
@@ -110,7 +135,8 @@ class semaphore:
"Print a classic semaphore."
def __init__(self, obj):
- self.object = obj
+ self.reference = obj
+ self.object = obj.dereference()
self.object_control = objects.control(self.object['Object'])
self.attr = attribute(self.object['attribute_set'], 'semaphore')
@@ -152,29 +178,38 @@ class task:
"Print a classic task"
def __init__(self, obj):
- self.object = obj
- self.task = \
- threads.control(self.object)
+ self.reference = obj
+ self.object = obj.dereference()
+ self.task = threads.control(self.reference)
self.wait_info = self.task.wait_info()
- # ToDo: Insert platform dep. code here.
- self.regs = sparc.register(self.object['Registers'])
+ self.regs = self.task.registers()
+ #self.regs = sparc.register(self.object['Registers'])
def show(self, from_tty):
- print ' Name:', self.task.name()
- print ' State:', self.task.current_state()
- print ' Current:', self.task.current_priority()
- print ' Real:', self.task.real_priority()
- print ' Preempt:', self.task.preemptible()
- print ' T Budget:', self.task.cpu_time_budget()
- print ' Regsters:'
- self.regs.show()
-
+ cpu = self.task.executing()
+ if cpu == -1:
+ cpu = 'not executing'
+ print ' Id:', '0x%08x' % (self.task.id())
+ print ' Name:', self.task.name()
+ print ' Active CPU:', cpu
+ print ' State:', self.task.current_state()
+ print ' Current:', self.task.current_priority()
+ print ' Real:', self.task.real_priority()
+ print ' Preempt:', self.task.preemptible()
+ print ' T Budget:', self.task.cpu_time_budget()
+ print ' Time:', self.task.cpu_time_used()
+ print ' Resources:', self.task.resource_count()
+ print ' Regsters:'
+ for name in self.regs.names():
+ val = self.regs.get(name)
+ print ' %20s: %08x (%d)' % (name, val, val)
class message_queue:
"Print classic messege queue"
- def __init__(self,obj):
- self.object = obj
+ def __init__(self, obj):
+ self.reference = obj
+ self.object = obj.dereference()
self.object_control = objects.control(self.object['Object'])
self.attr = attribute(self.object['attribute_set'], \
'message_queue')
@@ -193,7 +228,8 @@ class timer:
'''Print a classic timer'''
def __init__(self, obj):
- self.object = obj
+ self.reference = obj
+ self.object = obj.dereference()
self.object_control = objects.control(self.object['Object'])
self.watchdog = watchdog.control(self.object['Ticker'])
@@ -205,7 +241,8 @@ class partition:
''' Print a rtems partition '''
def __init__(self, obj):
- self.object = obj
+ self.reference = obj
+ self.object = obj.dereference()
self.object_control = objects.control(self.object['Object'])
self.attr = attribute(self.object['attribute_set'], 'partition')
self.starting_addr = self.object['starting_address']
@@ -224,8 +261,9 @@ class partition:
class region:
"prints a classic region"
- def __init__(self,obj):
- self.object = obj
+ def __init__(self, obj):
+ self.reference = obj
+ self.object = obj.dereference()
self.object_control = objects.control(self.object['Object'])
self.attr = attribute(self.object['attribute_set'], 'region')
self.wait_queue = threads.queue(self.object['Wait_queue'])
@@ -241,8 +279,9 @@ class region:
class barrier:
'''classic barrier abstraction'''
- def __init__(self,obj):
- self.object = obj
+ def __init__(self, obj):
+ self.reference = obj
+ self.object = obj.dereference()
self.object_control = objects.control(self.object['Object'])
self.attr = attribute(self.object['attribute_set'],'barrier')
self.core_b_control = supercore.barrier_control(self.object['Barrier'])
@@ -257,5 +296,3 @@ class barrier:
print ' Waiting:',self.core_b_control.waiting_threads()
helper.tasks_printer_routine(self.core_b_control.tasks())
-
-
diff --git a/tools/gdb/python/configuration.py b/tools/gdb/python/configuration.py
new file mode 100644
index 0000000..d20224b
--- /dev/null
+++ b/tools/gdb/python/configuration.py
@@ -0,0 +1,110 @@
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2014 Chris Johns (chrisj@rtems.org)
+# All rights reserved.
+#
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+#
+# RTEMS Configuration Table
+#
+
+import gdb
+
+def _table():
+ return gdb.parse_and_eval('Configuration')
+
+def fields():
+ return [field.name for field in _table().type.fields()]
+
+def mp():
+ return '_Configuration_MP_table' in fields()
+
+def smp():
+ if 'smp_enabled' in fields():
+ return int(_table()['smp_enabled']) != 0
+ return False
+
+def maximum_processors():
+ if smp():
+ return int(_table()['maximum_processors'])
+ return 1
+
+def work_space_size():
+ return long(_table()['work_space_size'])
+
+def stack_space_size():
+ return long(_table()['stack_space_size'])
+
+def maximum_extensions():
+ return long(_table()['maximum_extensions'])
+
+def maximum_keys():
+ return long(_table()['maximum_keys'])
+
+def maximum_key_value_pairs():
+ return long(_table()['maximum_key_value_pairs'])
+
+def microseconds_per_tick():
+ return long(_table()['microseconds_per_tick'])
+
+def nanoseconds_per_tick():
+ return long(_table()['nanoseconds_per_tick'])
+
+def ticks_per_timeslice():
+ return long(_table()['ticks_per_timeslice'])
+
+def idle_task():
+ return long(_table()['idle_task'])
+
+def idle_task_stack_size():
+ return long(_table()['idle_task_stack_size'])
+
+def interrupt_stack_size():
+ return long(_table()['interrupt_stack_size'])
+
+def stack_allocate_init_hook():
+ return long(_table()['stack_allocate_init_hook'])
+
+def stack_allocate_hook():
+ return long(_table()['stack_allocate_hook'])
+
+def stack_free_hook():
+ return long(_table()['stack_free_hook'])
+
+def do_zero_of_workspace():
+ return int(_table()['do_zero_of_workspace']) != 0
+
+def unified_work_area():
+ return int(_table()['unified_work_area']) != 0
+
+def stack_allocator_avoids_work_space():
+ return long(_table()['stack_allocator_avoids_work_space'])
+
+def number_of_initial_extensions():
+ return int(_table()['number_of_initial_extensions'])
+
+def user_extension_table():
+ return _table()['User_extension_table']
diff --git a/tools/gdb/python/heaps.py b/tools/gdb/python/heaps.py
index 2cc7907..e843f33 100644
--- a/tools/gdb/python/heaps.py
+++ b/tools/gdb/python/heaps.py
@@ -1,3 +1,32 @@
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# All rights reserved.
+#
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
#
# RTEMS heap
#
@@ -81,4 +110,4 @@ class control:
stats = self.stat()
print ' stats:'
- stats.show() \ No newline at end of file
+ stats.show()
diff --git a/tools/gdb/python/helper.py b/tools/gdb/python/helper.py
index dfd01eb..5efcf02 100644
--- a/tools/gdb/python/helper.py
+++ b/tools/gdb/python/helper.py
@@ -1,5 +1,34 @@
+# RTEMS Tools Project (http://www.rtems.org/)
+# All rights reserved.
+#
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
#
# RTEMS GDB support helper routins.
+#
import gdb
@@ -18,4 +47,4 @@ def type_from_value(val):
return type.unqualified ()
def test_bit(val, pos):
- return bool(val & (1 << (pos-1))) \ No newline at end of file
+ return bool(val & (1 << (pos-1)))
diff --git a/tools/gdb/python/objects.py b/tools/gdb/python/objects.py
index ee59cbc..4898d81 100644
--- a/tools/gdb/python/objects.py
+++ b/tools/gdb/python/objects.py
@@ -1,15 +1,41 @@
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# All rights reserved.
#
-# RTEMS Objects Support
-# Copyright 2010 Chris Johns (chrisj@rtems.org)
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
#
-# $Id$
+# RTEMS Objects Support
#
import gdb
import itertools
import re
-class infotables:
+class infotables():
"""Manage the object information tables."""
tables_types = {
@@ -36,7 +62,7 @@ class infotables:
self.tables = {}
def name(self, api, _class):
- return api + '/' + _class
+ return '%s/%s' % (api, _class)
def load(self, n):
if n in self.tables_types:
@@ -50,6 +76,16 @@ class infotables:
return self.tables[n]
return None
+ def minimum_id(self, api, _class):
+ n = self.name(api, _class)
+ self.load(n)
+ return int(self.tables[n]['minimum_id'])
+
+ def maximum_id(self, api, _class):
+ n = self.name(api, _class)
+ self.load(n)
+ return int(self.tables[n]['maximum_id'])
+
def maximum(self, api, _class):
n = self.name(api, _class)
self.load(n)
@@ -71,18 +107,14 @@ class infotables:
def object_return(self, api, _class, index=-1):
n = self.name(api, _class)
self.load(n)
-
table_type = self.tables_types[n]
-
if api == 'internal':
- expr = '(' + table_type[0] + ')' + table_type[1]
-
+ expr = '(%s) %s' % (table_type[0], table_type[1])
else:
max = self.maximum(api, _class)
if index > max:
raise IndexError('object index out of range (%d)' % (max))
- expr = '(' + table_type[0] + '*)' + \
- table_type[1] + '.local_table[' + str(index) + ']'
+ expr = '(%s*) %s.local_table[%d]' % (table_type[0], table_type[1], index)
return gdb.parse_and_eval(expr)
def is_string(self, api, _class):
@@ -98,7 +130,7 @@ class infotables:
#
information = infotables()
-class ident:
+class ident():
"An RTEMS object id with support for its bit fields."
bits = [
@@ -113,14 +145,13 @@ class ident:
]
OBJECT_16_BITS = 0
- OBJECT_31_BITS = 1
+ OBJECT_32_BITS = 1
api_labels = [
'none',
'internal',
'classic',
- 'posix',
- 'itron'
+ 'posix'
]
class_labels = {
@@ -150,15 +181,6 @@ class ident:
'barriers',
'spinlocks',
'rwlocks'),
- 'itron' : ('none',
- 'tasks',
- 'eventflags',
- 'mailboxes',
- 'message_buffers',
- 'ports',
- 'semaphores',
- 'variable_memory_pools',
- 'fixed_memory_pools')
}
def __init__(self, id):
@@ -170,7 +192,7 @@ class ident:
if self.id.type.sizeof == 2:
self.idSize = self.OBJECT_16_BITS
else:
- self.idSize = self.OBJECT_31_BITS
+ self.idSize = self.OBJECT_32_BITS
def get(self, field):
if field in self.bits[self.idSize]:
@@ -212,7 +234,7 @@ class ident:
def valid(self):
return self.api() != 'none' and self._class() != 'invalid'
-class name:
+class name():
"""The Objects_Name can either be told what the name is or can take a
guess."""
@@ -220,6 +242,10 @@ class name:
self.name = name
if is_string == None:
self.is_string = 'auto'
+ try:
+ self.name_p = self.name['name_p']
+ except gdb.Error:
+ self.is_string = 'no'
else:
if is_string:
self.is_string = 'yes'
@@ -227,25 +253,39 @@ class name:
self.is_string = 'no'
def __str__(self):
+ return self.get()
+
+ def get(self):
if self.is_string != 'yes':
u32 = int(self.name['name_u32'])
- s = chr((u32 >> 24) & 0xff) + \
- chr((u32 >> 16) & 0xff) + chr((u32 >> 8) & 0xff) + \
- chr(u32 & 0xff)
- for c in range(0,4):
- if s[c] < ' ' or s[c] > '~':
- s = None
- break
- if s:
- return s
- return str(self.name['name_p'].dereference())
-
-class control:
+ if u32 != 0:
+ s = chr((u32 >> 24) & 0xff) + \
+ chr((u32 >> 16) & 0xff) + \
+ chr((u32 >> 8) & 0xff) + \
+ chr(u32 & 0xff)
+ for c in range(0, 4):
+ if s[c] < ' ' or s[c] > '~':
+ s = None
+ break
+ if s:
+ return s
+ if self.is_string == 'xno':
+ return None
+ try:
+ name_p = self.name['name_p']
+ return str(name_p.dereference())
+ except gdb.Error:
+ pass
+ return None
+
+class control():
"""The Objects_Control structure."""
def __init__(self, object):
self.object = object
self._id = ident(self.object['id'])
+ self._name = name(self.object['name'],
+ information.is_string(self._id.api(), self._id._class()))
def node(self):
return self.object['Node']
@@ -254,12 +294,4 @@ class control:
return self.object['id']
def name(self):
- is_string = information.is_string(self._id.api(), self._id._class())
- val = str(name(self.object['name'],is_string))
-
- # Normal comaprision is a bit tricky with quotes
- # 0 '\000' in hex == '3020275c30303027'
- if val.encode('hex') == '3020275c30303027':
- val = ""
-
- return val \ No newline at end of file
+ return self._name.get()
diff --git a/tools/gdb/python/percpu.py b/tools/gdb/python/percpu.py
new file mode 100644
index 0000000..991bdf8
--- /dev/null
+++ b/tools/gdb/python/percpu.py
@@ -0,0 +1,57 @@
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2014 Chris Johns (chrisj@rtems.org)
+# All rights reserved.
+#
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+#
+# RTEMS Per CPU Table
+#
+
+import gdb
+
+import configuration
+
+def _table(cpu):
+ max_cpus = configuration.maximum_processors()
+ if cpu >= max_cpus:
+ raise IndexError('cpu index out of range (%d)' % (max_cpus))
+ return gdb.parse_and_eval('_Per_CPU_Information[%d].per_cpu' % (cpu))
+
+def get(cpu):
+ return _table(cpu)
+
+def thread_active(thread):
+ for cpu in range(0, configuration.maximum_processors()):
+ if thread == _table(cpu)['executing']:
+ return cpu
+ return -1
+
+def thread_heir(thread):
+ for cpu in range(0, configuration.maximum_processors()):
+ if thread == _table(cpu)['heir']:
+ return cpu
+ return -1
diff --git a/tools/gdb/python/pretty.py b/tools/gdb/python/pretty.py
index 929c245..3cbe052 100644
--- a/tools/gdb/python/pretty.py
+++ b/tools/gdb/python/pretty.py
@@ -1,6 +1,35 @@
+# RTEMS Tools Project (http://www.rtems.org/)
+# All rights reserved.
+#
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
#
# RTEMS pretty printers
#
+
import re
import helper
import objects
diff --git a/tools/gdb/python/rtems.py b/tools/gdb/python/rtems.py
index 6c987cf..534cb0d 100644
--- a/tools/gdb/python/rtems.py
+++ b/tools/gdb/python/rtems.py
@@ -1,8 +1,34 @@
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# All rights reserved.
#
-# RTEMS Pretty Printers
-# Copyright 2010 Chris Johns (chrisj@rtems.org)
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
#
-# $Id$
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+#
+# RTEMS Pretty Printers
#
import gdb
@@ -29,18 +55,18 @@ class rtems_object(gdb.Command):
"""Object sub-command for RTEMS"""
objects = {
- 'classic/semaphores': lambda obj: classic.semaphore(obj),
- 'classic/tasks': lambda obj: classic.task(obj),
+ 'classic/semaphores': lambda obj: classic.semaphore(obj),
+ 'classic/tasks': lambda obj: classic.task(obj),
'classic/message_queues': lambda obj: classic.message_queue(obj),
- 'classic/timers' : lambda obj: classic.timer(obj),
- 'classic/partitions' : lambda obj: classic.partition(obj),
- 'classic/regions' : lambda obj: classic.region(obj),
- 'classic/barriers' : lambda obj: classic.barrier(obj)
- }
+ 'classic/timers' : lambda obj: classic.timer(obj),
+ 'classic/partitions' : lambda obj: classic.partition(obj),
+ 'classic/regions' : lambda obj: classic.region(obj),
+ 'classic/barriers' : lambda obj: classic.barrier(obj)
+ }
def __init__(self):
- self.__doc__ = 'Display the RTEMS object given a numeric ID \
- (Or a reference to rtems_object).'
+ self.__doc__ = 'Display the RTEMS object given a numeric ID' \
+ '(Or a reference to the object).'
super(rtems_object, self).__init__('rtems object',
gdb.COMMAND_DATA,
gdb.COMPLETE_SYMBOL)
@@ -79,29 +105,47 @@ class rtems_index(gdb.Command):
gdb.COMMAND_DATA,
gdb.COMPLETE_NONE)
- def instance(self,obj):
- '''Returns a n instance of corresponding object, the child should extend this'''
+ def instance(self, obj):
+ '''Returns a n instance of corresponding object, the child should extend
+ this'''
return obj
def invoke(self, arg, from_tty):
- for val in arg.split():
- try:
- index = int(val)
- except ValueError:
- print "error: %s is not an index" % (val)
- return
- try:
- obj = objects.information.object_return( self.api,
- self._class,
- index ).dereference()
- except IndexError:
- print "error: index %s is invalid" % (index)
- return
-
- instance = self.instance(obj)
- instance.show(from_tty)
- objects.information.invalidate()
-
+ maximum = objects.information.maximum(self.api, self._class)
+ minimum_id = objects.ident(objects.information.minimum_id(self.api, self._class))
+ maximum_id = objects.ident(objects.information.minimum_id(self.api, self._class))
+ args = arg.split()
+ if len(args):
+ for val in args:
+ try:
+ index = int(val, base = 0)
+ if index < maximum:
+ if index < minimum_id.index():
+ print "error: %s is not an index (min is %d)" % (val,
+ minimum_id.index())
+ return
+ else:
+ index = objects.ident(index).index()
+ except ValueError:
+ print "error: %s is not an index" % (val)
+ return
+ try:
+ obj = objects.information.object_return(self.api,
+ self._class,
+ index)
+ except IndexError:
+ print "error: index %s is invalid" % (index)
+ return
+ instance = self.instance(obj)
+ instance.show(from_tty)
+ objects.information.invalidate()
+ else:
+ print '-' * 70
+ print ' %s: %d [%08x -> %08x]' % (objects.information.name(self.api, self._class),
+ maximum, minimum_id.value(), maximum_id.value())
+ for index in range(minimum_id.index(), minimum_id.index() + maximum):
+ print '-' * 70
+ self.invoke(str(index), from_tty)
class rtems_semaphore(rtems_index):
'''semaphore subcommand'''
@@ -111,7 +155,7 @@ class rtems_semaphore(rtems_index):
self.__doc__ = 'Display RTEMS semaphore(s) by index(es)'
super(rtems_semaphore, self).__init__('rtems semaphore')
- def instance(self,obj):
+ def instance(self, obj):
return classic.semaphore(obj)
class rtems_task(rtems_index):
@@ -123,10 +167,9 @@ class rtems_task(rtems_index):
self.__doc__ = 'Display RTEMS task(s) by index(es)'
super(rtems_task,self).__init__('rtems task')
- def instance(self,obj):
+ def instance(self, obj):
return classic.task(obj)
-
class rtems_message_queue(rtems_index):
'''Message Queue subcommand'''
@@ -136,7 +179,7 @@ class rtems_message_queue(rtems_index):
self.__doc__ = 'Display RTEMS message_queue(s) by index(es)'
super(rtems_message_queue,self).__init__('rtems mqueue')
- def instance(self,obj):
+ def instance(self, obj):
return classic.message_queue(obj)
class rtems_timer(rtems_index):
@@ -148,7 +191,7 @@ class rtems_timer(rtems_index):
self.__doc__ = 'Display RTEMS timer(s) by index(es)'
super(rtems_timer, self).__init__('rtems timer')
- def instance(self,obj):
+ def instance(self, obj):
return classic.timer(obj)
class rtems_partition(rtems_index):
@@ -252,3 +295,12 @@ class rtems_wsec(rtems_watchdog_chain):
self.__doc__ = 'Display watchdog seconds chain'
super(rtems_wsec, self).__init__('rtems wdseconds')
+def create():
+ return (rtems(),
+ rtems_object(),
+ rtems_semaphore(),
+ rtems_task(),
+ rtems_message_queue(),
+ rtems_tod(),
+ rtems_wdt(),
+ rtems_wsec())
diff --git a/tools/gdb/python/sparc.py b/tools/gdb/python/sparc.py
index 70ef5d3..41b6fec 100644
--- a/tools/gdb/python/sparc.py
+++ b/tools/gdb/python/sparc.py
@@ -73,7 +73,7 @@ class register:
return val
- def __init__(self,reg):
+ def __init__(self, reg):
self.reg = reg
def global_regs(self):
@@ -139,4 +139,4 @@ class register:
print '\b\b ]'
sr = self.status()
- print sr.to_string() \ No newline at end of file
+ print sr.to_string()
diff --git a/tools/gdb/python/supercore.py b/tools/gdb/python/supercore.py
index 6116626..0790cc9 100644
--- a/tools/gdb/python/supercore.py
+++ b/tools/gdb/python/supercore.py
@@ -1,3 +1,32 @@
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# All rights reserved.
+#
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
#
# RTEMS Supercore Objects
#
diff --git a/tools/gdb/python/supercore_printer.py b/tools/gdb/python/supercore_printer.py
index 3ce8110..61241e3 100644
--- a/tools/gdb/python/supercore_printer.py
+++ b/tools/gdb/python/supercore_printer.py
@@ -1,6 +1,35 @@
+# RTEMS Tools Project (http://www.rtems.org/)
+# All rights reserved.
+#
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
#
# RTEMS Supercore pretty printers for GDB
#
+
import objects
import itertools
import threads
@@ -138,4 +167,4 @@ class node:
self.node = chains.node(node)
def to_string(self):
- return "Node: "+str(self.node)+" Next: "+str(self.node.next())+" Prev: "+str(self.node.previous()) \ No newline at end of file
+ return "Node: "+str(self.node)+" Next: "+str(self.node.next())+" Prev: "+str(self.node.previous())
diff --git a/tools/gdb/python/threads.py b/tools/gdb/python/threads.py
index 7098481..1719187 100644
--- a/tools/gdb/python/threads.py
+++ b/tools/gdb/python/threads.py
@@ -1,13 +1,41 @@
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# All rights reserved.
#
-# RTEMS Threads Support
-# Copyright 2010 Chris Johns (chrisj@rtems.org)
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
#
-# $Id$
+
+#
+# RTEMS Threads Support
#
import gdb
+
import chains
import objects
+import percpu
def task_chain(chain):
tasks = []
@@ -17,7 +45,7 @@ def task_chain(chain):
node.next()
return tasks
-class state:
+class state():
ALL_SET = 0x000fffff
READY = 0x00000000
@@ -100,7 +128,7 @@ class state:
s = self.masks[m] + ','
return s[:-1]
-class wait_info:
+class wait_info():
def __init__(self, info):
self.info = info
@@ -123,11 +151,68 @@ class wait_info:
def queue(self):
return task_chain(chains.control(self.info['queue']))
-class control:
+class registers():
+
+ def __init__(self, regs):
+ self.regs = regs
+
+ def names(self):
+ return [field.name for field in self.regs.type.fields()]
+
+ def get(self, reg):
+ t = str(self.regs[reg].type)
+ if t in ['double']:
+ return float(self.regs[reg])
+ return int(self.regs[reg])
+
+
+ def format(self, reg):
+ t = self.regs[reg].type
+ if t in ['uint32_t', 'unsigned', 'unsigned long']:
+ return '%08x (%d)' % (val)
+
+class control():
+ '''
+ Thread_Control has the following fields:
+ Object Objects_Control
+ RBNode RBTree_Node
+ current_state States_Control
+ current_priority Priority_Control
+ real_priority Priority_Control
+ resource_count uint32_t
+ Wait Thread_Wait_information
+ Timer Watchdog_Control
+ receive_packet MP_packet_Prefix* X
+ lock_mutex Chain_Control X
+ Resource_node Resource_Node X
+ is_global bool X
+ is_preemptible bool
+ Scheduler Thread_Scheduler_control
+ rtems_ada_self void* X
+ cpu_time_budget uint32_t
+ budget_algorithm Thread_CPU_budget_algorithms
+ budget_callout Thread_CPU_budget_algorithm_callout
+ cpu_time_used Thread_CPU_usage_t
+ Start Thread_Start_information
+ Post_switch_actions Thread_Action_control
+ Registers Context_Control
+ fp_context Context_Control_fp* X
+ libc_reent struct _reent*
+ API_Extensions void*[THREAD_API_LAST + 1]
+ task_variables rtems_task_variable_t* X
+ Key_Chain Chain_Control
+ Life Thread_Life_control
+ extensions void*[RTEMS_ZERO_LENGTH_ARRAY]
+
+ where 'X' means the field is condition and may no exist.
+ '''
def __init__(self, ctrl):
- self.ctrl = ctrl
+ self.reference = ctrl
+ self.ctrl = ctrl.dereference()
self.object = objects.control(ctrl['Object'])
+ self._executing = percpu.thread_active(self.reference)
+ self._heir = percpu.thread_heir(self.reference)
def id(self):
return self.object.id()
@@ -138,6 +223,12 @@ class control:
val = '*'
return val
+ def executing(self):
+ return self._executing
+
+ def heir(self):
+ return self._heir
+
def current_state(self):
return state(self.ctrl['current_state']).to_string()
@@ -147,6 +238,15 @@ class control:
def real_priority(self):
return self.ctrl['real_priority']
+ def resource_count(self):
+ return self.ctrl['resource_count']
+
+ def cpu_time_budget(self):
+ return self.ctrl['cpu_time_budget']
+
+ def cpu_time_used(self):
+ return self.ctrl['cpu_time_used']
+
def preemptible(self):
return self.ctrl['is_preemptible']
@@ -156,11 +256,14 @@ class control:
def wait_info(self):
return wait_info(self.ctrl['Wait'])
+ def registers(self):
+ return registers(self.ctrl['Registers'])
+
def brief(self):
return "'%s' (c:%d, r:%d)" % \
(self.name(), self.current_priority(), self.real_priority())
-class queue:
+class queue():
"""Manage the Thread_queue_Control."""
priority_headers = 4
@@ -186,6 +289,3 @@ class queue:
t.extend(task_chain(chains.control( \
self.que['Queues']['Priority'][ph])))
return t
-
-
-
diff --git a/tools/gdb/python/watchdog.py b/tools/gdb/python/watchdog.py
index 71a1816..dfa57a0 100644
--- a/tools/gdb/python/watchdog.py
+++ b/tools/gdb/python/watchdog.py
@@ -1,8 +1,34 @@
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# All rights reserved.
#
-# RTEMS Watchdog Support
-# Copyright 2010 Chris Johns (chrisj@rtems.org)
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
#
-# $Id$
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+#
+# RTEMS Watchdog Support
#
import gdb
@@ -63,4 +89,4 @@ class control:
return val
def show(self):
- print self.to_string() \ No newline at end of file
+ print self.to_string()
diff --git a/tools/gdb/python/wscript b/tools/gdb/python/wscript
index 22d44e8..a7f428c 100644
--- a/tools/gdb/python/wscript
+++ b/tools/gdb/python/wscript
@@ -6,18 +6,22 @@ def configure(conf):
conf.load('python')
def build(bld):
- bld.install_files('${PREFIX}/share/gdb/python/rtems',
- ['chains.py',
- 'classic.py',
- 'classic_printer.py',
- 'heaps.py',
- 'helper.py',
- 'main.py',
- 'objects.py',
- 'pretty.py',
- 'rtems.py',
- 'sparc.py',
- 'supercore.py',
- 'supercore_printer.py',
- 'threads.py',
- 'watchdog.py'])
+ source = ['__init__.py',
+ 'chains.py',
+ 'classic.py',
+ 'classic_printer.py',
+ 'configuration.py',
+ 'heaps.py',
+ 'helper.py',
+ 'main.py',
+ 'objects.py',
+ 'percpu.py',
+ 'pretty.py',
+ 'rtems.py',
+ 'sparc.py',
+ 'supercore.py',
+ 'supercore_printer.py',
+ 'threads.py',
+ 'watchdog.py']
+ bld(features = 'py', source = source, install_path = None)
+ bld.install_files('${PREFIX}/share/gdb/python/rtems', source)