From 04a52040aef69910e9ac2218fea48077e34d4017 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 12 Nov 2015 11:15:23 +0100 Subject: Python 3 compatibility --- tools/gdb/python/__init__.py | 2 +- tools/gdb/python/classic.py | 82 +++++++++++++++++++++---------------------- tools/gdb/python/heaps.py | 12 +++---- tools/gdb/python/helper.py | 4 +-- tools/gdb/python/rtems.py | 32 ++++++++--------- tools/gdb/python/sparc.py | 34 +++++++++--------- tools/gdb/python/supercore.py | 8 ++--- tools/gdb/python/watchdog.py | 2 +- 8 files changed, 88 insertions(+), 88 deletions(-) (limited to 'tools') diff --git a/tools/gdb/python/__init__.py b/tools/gdb/python/__init__.py index 58c8625..0ea5fb2 100644 --- a/tools/gdb/python/__init__.py +++ b/tools/gdb/python/__init__.py @@ -37,4 +37,4 @@ def get_architure(): _cmds = rtems.create() -print 'RTEMS GDB Support' +print('RTEMS GDB Support') diff --git a/tools/gdb/python/classic.py b/tools/gdb/python/classic.py index 7c004db..b5aacf8 100644 --- a/tools/gdb/python/classic.py +++ b/tools/gdb/python/classic.py @@ -147,29 +147,29 @@ class semaphore: def show(self, from_tty): if self.object_control.id() != 0: - print ' Name:', self.object_control.name() - print ' Id: 0x%08x (@ 0x%08x)' % (self.object_control.id(), - self.reference) - print ' Attr:', self.attr.to_string() + print(' Name:', self.object_control.name()) + print(' Id: 0x%08x (@ 0x%08x)' % (self.object_control.id(), + self.reference)) + print(' Attr:', self.attr.to_string()) if self.attr.test('semaphore-type', 'bin-sema') or \ self.attr.test('semaphore-type', 'simple-bin-sema'): core_mutex = mutex.control(self.object['Core_control']['mutex']) - print ' Nesting:', core_mutex.nest_count() - print ' Holder:', + print(' Nesting:', core_mutex.nest_count()) + print(' Holder:',) holder = core_mutex.holder() if holder: - print '%s (id 0x%08x)' % (holder.brief(), holder.id()) + print('%s (id 0x%08x)' % (holder.brief(), holder.id())) else: - print 'no holder (unlocked)' + print('no holder (unlocked)') wait_queue = core_mutex.wait_queue() tasks = wait_queue.tasks() - print ' Queue: len = %d, state = %s' % (len(tasks), - wait_queue.state()) + print(' Queue: len = %d, state = %s' % (len(tasks), + wait_queue.state())) if len(tasks) > 0: - print ' Tasks:' - print ' Name (c:current, r:real), (id)' + print(' Tasks:') + print(' Name (c:current, r:real), (id)') for t in range(0, len(tasks)): - print ' ', tasks[t].brief(), ' (%08x)' % (tasks[t].id()) + print(' ', tasks[t].brief(), ' (%08x)' % (tasks[t].id())) return True return False @@ -189,21 +189,21 @@ class task: cpu = self.task.executing() if cpu == -1: cpu = 'not executing' - print ' Id:', '0x%08x (@ 0x%08x)' % (self.task.id(), - self.task.reference) - 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:' + print(' Id:', '0x%08x (@ 0x%08x)' % (self.task.id(), + self.task.reference)) + 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) + print(' %20s: %08x (%d)' % (name, val, val)) return True return False @@ -222,8 +222,8 @@ class message_queue: self.core_control = supercore.message_queue(self.object['message_queue']) def show(self, from_tty): - print ' Name:', self.object_control.name() - print ' Attr:', self.attr.to_string() + print(' Name:', self.object_control.name()) + print(' Attr:', self.attr.to_string()) self.core_control.show() @@ -237,7 +237,7 @@ class timer: self.watchdog = watchdog.control(self.object['Ticker']) def show(self, from_tty): - print ' Name:', self.object_control.name() + print(' Name:', self.object_control.name()) self.watchdog.show() class partition: @@ -255,11 +255,11 @@ class partition: def show(self, from_tty): # ToDo: the printing still somewhat crude. - print ' Name:', self.object_control.name() - print ' Attr:', self.attr.to_string() - print ' Length:', self.length - print ' B Size:', self.buffer_size - print ' U Blocks:', self.used_blocks + print(' Name:', self.object_control.name()) + print(' Attr:', self.attr.to_string()) + print(' Length:', self.length) + print(' B Size:', self.buffer_size) + print(' U Blocks:', self.used_blocks) class region: "prints a classic region" @@ -273,10 +273,10 @@ class region: self.heap = heaps.control(self.object['Memory']) def show(self, from_tty): - print ' Name:', self.object_control.name() - print ' Attr:', self.attr.to_string() + print(' Name:', self.object_control.name()) + print(' Attr:', self.attr.to_string()) helper.tasks_printer_routine(self.wait_queue) - print ' Memory:' + print(' Memory:') self.heap.show() class barrier: @@ -290,12 +290,12 @@ class barrier: self.core_b_control = supercore.barrier_control(self.object['Barrier']) def show(self,from_tty): - print ' Name:',self.object_control.name() - print ' Attr:',self.attr.to_string() + print(' Name:',self.object_control.name()) + print(' Attr:',self.attr.to_string()) if self.attr.test('barrier','barrier-auto-release'): max_count = self.core_b_control.max_count() - print 'Aut Count:', max_count + print('Aut Count:', max_count) - print ' Waiting:',self.core_b_control.waiting_threads() + print(' Waiting:',self.core_b_control.waiting_threads()) helper.tasks_printer_routine(self.core_b_control.tasks()) diff --git a/tools/gdb/python/heaps.py b/tools/gdb/python/heaps.py index e843f33..14238e3 100644 --- a/tools/gdb/python/heaps.py +++ b/tools/gdb/python/heaps.py @@ -73,9 +73,9 @@ class stats: return self.stat['free_size'] def show(self): - print ' Instance:',self.inst() - print ' Avail:',self.avail() - print ' Free:',self.free() + print(' Instance:',self.inst()) + print(' Avail:',self.avail()) + print(' Free:',self.free()) # ToDo : incorporate others @@ -105,9 +105,9 @@ class control: fi = self.first() la = self.last() - print ' First:', fi.val() - print ' Last:', la.val() + print(' First:', fi.val()) + print(' Last:', la.val()) stats = self.stat() - print ' stats:' + print(' stats:') stats.show() diff --git a/tools/gdb/python/helper.py b/tools/gdb/python/helper.py index 5efcf02..e9fe2f8 100644 --- a/tools/gdb/python/helper.py +++ b/tools/gdb/python/helper.py @@ -34,9 +34,9 @@ import gdb def tasks_printer_routine(wait_queue): tasks = wait_queue.tasks() - print ' Queue: len = %d, state = %s' % (len(tasks),wait_queue.state()) + print(' Queue: len = %d, state = %s' % (len(tasks),wait_queue.state())) for t in range(0, len(tasks)): - print ' ', tasks[t].brief(), ' (%08x)' % (tasks[t].id()) + print(' ', tasks[t].brief(), ' (%08x)' % (tasks[t].id())) def type_from_value(val): type = val.type; diff --git a/tools/gdb/python/rtems.py b/tools/gdb/python/rtems.py index d4317ff..a097797 100644 --- a/tools/gdb/python/rtems.py +++ b/tools/gdb/python/rtems.py @@ -78,15 +78,15 @@ class rtems_object(gdb.Command): val = gdb.parse_and_eval(num) num = int(val) except: - print 'error: "%s" is not a number' % (num) + print('error: "%s" is not a number' % (num)) return True id = objects.ident(num) if not id.valid(): - print 'Invalid object id' + print('Invalid object id') return True - print 'API:%s Class:%s Node:%d Index:%d Id:%08X' % \ - (id.api(), id._class(), id.node(), id.index(), id.value()) + print('API:%s Class:%s Node:%d Index:%d Id:%08X' % \ + (id.api(), id._class(), id.node(), id.index(), id.value())) objectname = id.api() + '/' + id._class() obj = objects.information.object(id).dereference() @@ -124,32 +124,32 @@ class rtems_index(gdb.Command): 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()) + 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) + 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) + print("error: index %s is invalid" % (index)) return instance = self.instance(obj) valid = 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()) + print('-' * 70) + print(' %s: %d [%08x -> %08x]' % (objects.information.name(self.api, self._class), + maximum, minimum_id.value(), maximum_id.value())) valid = True for index in range(minimum_id.index(), minimum_id.index() + maximum): if valid: - print '-' * 70 + print('-' * 70) valid = self.invoke(str(index), from_tty) return valid @@ -249,7 +249,7 @@ class rtems_tod(gdb.Command): def invoke(self, arg, from_tty): if arg: - print "warning: commad takes no arguments!" + print("warning: commad takes no arguments!") obj = objects.information.object_return(self.api, self._class) instance = supercore.time_of_day(obj) instance.show() @@ -271,15 +271,15 @@ class rtems_watchdog_chain(gdb.Command): inst = chains.control(obj) if inst.empty(): - print ' error: empty chain' + print(' error: empty chain') return nd = inst.first() i = 0 while not nd.null(): wd = watchdog.control(nd.cast('Watchdog_Control')) - print ' #'+str(i) - print wd.to_string() + print(' #'+str(i)) + print(wd.to_string()) nd.next() i += 1 diff --git a/tools/gdb/python/sparc.py b/tools/gdb/python/sparc.py index 41b6fec..38f19b7 100644 --- a/tools/gdb/python/sparc.py +++ b/tools/gdb/python/sparc.py @@ -114,29 +114,29 @@ class register: return self.psr(self.reg['psr']) def show(self): - print ' Global Regs:', - print ' [', + print(' Global Regs:',) + print(' [',) for i in self.global_regs(): - print str(i)+',', - print '\b\b ]' + print(str(i)+',',) + print('\b\b ]') - print ' Local Regs:', - print ' [', + print(' Local Regs:',) + print(' [',) for i in self.local_regs(): - print str(i)+',', - print '\b\b ]' + print(str(i)+',',) + print('\b\b ]') - print ' In Regs:', - print ' [', + print(' In Regs:',) + print(' [',) for i in self.in_regs(): - print str(i)+',', - print '\b\b ]' + print(str(i)+',',) + print('\b\b ]') - print ' Out Regs:', - print ' [', + print(' Out Regs:',) + print(' [',) for i in self.out_regs(): - print str(i)+',', - print '\b\b ]' + print(str(i)+',',) + print('\b\b ]') sr = self.status() - print sr.to_string() + print(sr.to_string()) diff --git a/tools/gdb/python/supercore.py b/tools/gdb/python/supercore.py index 0790cc9..318ebb7 100644 --- a/tools/gdb/python/supercore.py +++ b/tools/gdb/python/supercore.py @@ -50,13 +50,13 @@ class time_of_day: return bool(self.tod['is_set']) def show(self): - print ' Time Of Day' + print(' Time Of Day') if not self.is_set(): - print ' Application has not set a TOD' + print(' Application has not set a TOD') - print ' Now:', self.now() - print ' Uptime:', self.timer() + print(' Now:', self.now()) + print(' Uptime:', self.timer()) class message_queue: diff --git a/tools/gdb/python/watchdog.py b/tools/gdb/python/watchdog.py index dfa57a0..6a80421 100644 --- a/tools/gdb/python/watchdog.py +++ b/tools/gdb/python/watchdog.py @@ -89,4 +89,4 @@ class control: return val def show(self): - print self.to_string() + print(self.to_string()) -- cgit v1.2.3