mirror of
https://git.rtems.org/rtems-tools/
synced 2025-10-17 14:12:39 +08:00
Add subcommand
rtems tod - prints the time of day.
This commit is contained in:

committed by
Chris Johns

parent
a0bf9f207a
commit
a245635a2e
@@ -17,3 +17,4 @@ rtems.rtems_object()
|
|||||||
rtems.rtems_semaphore()
|
rtems.rtems_semaphore()
|
||||||
rtems.rtems_task()
|
rtems.rtems_task()
|
||||||
rtems.rtems_message_queue()
|
rtems.rtems_message_queue()
|
||||||
|
rtems.rtems_tod()
|
@@ -13,6 +13,8 @@ class infotables:
|
|||||||
"""Manage the object information tables."""
|
"""Manage the object information tables."""
|
||||||
|
|
||||||
tables_types = {
|
tables_types = {
|
||||||
|
'internal/time' : ('TOD_Control', '_TOD'),
|
||||||
|
|
||||||
'classic/tasks' : ('Thread_Control', '_RTEMS_tasks_Information'),
|
'classic/tasks' : ('Thread_Control', '_RTEMS_tasks_Information'),
|
||||||
'classic/timers' : ('Timer_Control', '_Timer_Information'),
|
'classic/timers' : ('Timer_Control', '_Timer_Information'),
|
||||||
'classic/semaphores' : ('Semaphore_Control', '_Semaphore_Information'),
|
'classic/semaphores' : ('Semaphore_Control', '_Semaphore_Information'),
|
||||||
@@ -64,15 +66,21 @@ class infotables:
|
|||||||
index = id.index()
|
index = id.index()
|
||||||
return self.object_return(api, _class, index)
|
return self.object_return(api, _class, index)
|
||||||
|
|
||||||
def object_return(self, api, _class, index):
|
def object_return(self, api, _class, index=-1):
|
||||||
n = self.name(api, _class)
|
n = self.name(api, _class)
|
||||||
self.load(n)
|
self.load(n)
|
||||||
max = self.maximum(api, _class)
|
|
||||||
if index > max:
|
|
||||||
raise IndexError('object index out of range (%d)' % (max))
|
|
||||||
table_type = self.tables_types[n]
|
table_type = self.tables_types[n]
|
||||||
expr = '(' + table_type[0] + '*)' + \
|
|
||||||
table_type[1] + '.local_table[' + str(index) + ']'
|
if api == 'internal':
|
||||||
|
expr = '(' + 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) + ']'
|
||||||
return gdb.parse_and_eval(expr)
|
return gdb.parse_and_eval(expr)
|
||||||
|
|
||||||
def is_string(self, api, _class):
|
def is_string(self, api, _class):
|
||||||
|
@@ -10,6 +10,7 @@ import re
|
|||||||
|
|
||||||
import objects
|
import objects
|
||||||
import threads
|
import threads
|
||||||
|
import supercore
|
||||||
import classic
|
import classic
|
||||||
|
|
||||||
|
|
||||||
@@ -184,3 +185,23 @@ class rtems_barrier(rtems_index):
|
|||||||
def instance(self, obj):
|
def instance(self, obj):
|
||||||
return classic.barrier(obj)
|
return classic.barrier(obj)
|
||||||
|
|
||||||
|
class rtems_tod(gdb.Command):
|
||||||
|
'''Print rtems time of day'''
|
||||||
|
|
||||||
|
api = 'internal'
|
||||||
|
_class = 'time'
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.__doc__ = 'Display RTEMS time of day'
|
||||||
|
super(rtems_tod, self).__init__ \
|
||||||
|
('rtems tod', gdb.COMMAND_STATUS,gdb.COMPLETE_NONE)
|
||||||
|
|
||||||
|
def invoke(self, arg, from_tty):
|
||||||
|
|
||||||
|
if arg:
|
||||||
|
print "warning: commad takes no arguments!"
|
||||||
|
|
||||||
|
obj = objects.information.object_return(self.api,self._class)
|
||||||
|
instance = supercore.time_of_day(obj)
|
||||||
|
instance.show()
|
||||||
|
objects.information.invalidate()
|
||||||
|
@@ -5,6 +5,31 @@
|
|||||||
import threads
|
import threads
|
||||||
import helper
|
import helper
|
||||||
|
|
||||||
|
class time_of_day:
|
||||||
|
'''Manage time of day object'''
|
||||||
|
|
||||||
|
def __init__(self, tod):
|
||||||
|
self.tod = tod
|
||||||
|
|
||||||
|
def now(self):
|
||||||
|
return self.tod['now']
|
||||||
|
|
||||||
|
def timer(self):
|
||||||
|
return self.tod['uptime']
|
||||||
|
|
||||||
|
def is_set(self):
|
||||||
|
return bool(self.tod['is_set'])
|
||||||
|
|
||||||
|
def show(self):
|
||||||
|
print ' Time Of Day'
|
||||||
|
|
||||||
|
if not self.is_set():
|
||||||
|
print ' Application has not set a TOD'
|
||||||
|
|
||||||
|
print ' Now:', self.now()
|
||||||
|
print ' Uptime:', self.timer()
|
||||||
|
|
||||||
|
|
||||||
class message_queue:
|
class message_queue:
|
||||||
'''Manage a Supercore message_queue'''
|
'''Manage a Supercore message_queue'''
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user