Skip to content
Snippets Groups Projects
Commit f36ae5d0 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "lrdp-v2: improve handling of unsupported python versions"

parents ae0e3fc2 76fe732d
No related branches found
No related tags found
No related merge requests found
...@@ -211,7 +211,7 @@ class GdbMI(object): ...@@ -211,7 +211,7 @@ class GdbMI(object):
def get_enum_lookup_table(self, enum, upperbound): def get_enum_lookup_table(self, enum, upperbound):
"""Return a table translating enum values to human readable strings.""" """Return a table translating enum values to human readable strings."""
table = [] table = []
for i in xrange(0, upperbound): for i in range(0, upperbound):
result = self._run_for_first( result = self._run_for_first(
'print ((enum {0}){1})'.format(enum, i)) 'print ((enum {0}){1})'.format(enum, i))
parts = result.split(' ') parts = result.split(' ')
...@@ -239,18 +239,18 @@ class GdbMI(object): ...@@ -239,18 +239,18 @@ class GdbMI(object):
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) != 3: if len(sys.argv) != 3:
print 'Usage: gdbmi.py gdb_path elf' print('Usage: gdbmi.py gdb_path elf')
sys.exit(1) sys.exit(1)
gdb_path, elf = sys.argv[1:] gdb_path, elf = sys.argv[1:]
with GdbMI(gdb_path, elf) as g: with GdbMI(gdb_path, elf) as g:
print 'GDB Version:', g.version() print('GDB Version: ' + g.version())
print 'ion_buffer.heap offset:', g.field_offset('struct ion_buffer', 'heap') print('ion_buffer.heap offset: ' + str(g.field_offset('struct ion_buffer', 'heap')))
print 'atomic_t.counter offset:', g.field_offset('atomic_t', 'counter') print('atomic_t.counter offset: ' + str(g.field_offset('atomic_t', 'counter')))
print 'sizeof(struct ion_buffer):', g.sizeof('struct ion_buffer') print('sizeof(struct ion_buffer): ' + str(g.sizeof('struct ion_buffer')))
addr = g.address_of('kernel_config_data') addr = g.address_of('kernel_config_data')
print 'address of kernel_config_data:', hex(addr) print('address of kernel_config_data: ' + hex(addr))
symbol = g.get_symbol_info(addr) symbol = g.get_symbol_info(addr)
print 'symbol at', hex(addr), ':', symbol.symbol, \ print('symbol at ' + hex(addr) + ' : ' + symbol.symbol + \
'which is in section', symbol.section ' which is in section ' + symbol.section)
...@@ -9,7 +9,10 @@ ...@@ -9,7 +9,10 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
from collections import OrderedDict try:
from collections import OrderedDict
except ImportError:
from ordereddict import OrderedDict
from print_out import print_out_str from print_out import print_out_str
from register import Register from register import Register
......
...@@ -585,7 +585,7 @@ class Armv8MMU(MMU): ...@@ -585,7 +585,7 @@ class Armv8MMU(MMU):
tl_index=(20,12), tl_index=(20,12),
page_index=(11,0)) page_index=(11,0))
fl_desc = self.do_fl_sl_level_lookup(self.ttbr, virt_r.fl_index, 12, 30) fl_desc = self.do_fl_sl_level_lookup(self.ttbr, virt_r.fl_index, 12, 30)
if fl_desc.dtype == Armv8MMU.DESCRIPTOR_BLOCK: if fl_desc.dtype == Armv8MMU.DESCRIPTOR_BLOCK:
return self.fl_block_desc_2_phys(fl_desc, virt_r) return self.fl_block_desc_2_phys(fl_desc, virt_r)
...@@ -598,7 +598,7 @@ class Armv8MMU(MMU): ...@@ -598,7 +598,7 @@ class Armv8MMU(MMU):
except: except:
return None return None
if sl_desc.dtype == Armv8MMU.DESCRIPTOR_BLOCK: if sl_desc.dtype == Armv8MMU.DESCRIPTOR_BLOCK:
r = self.sl_block_desc_2_phys(sl_desc, virt_r) r = self.sl_block_desc_2_phys(sl_desc, virt_r)
return r return r
......
#!/usr/bin/python #!/usr/bin/env python2
# Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. # Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
# #
...@@ -11,6 +11,13 @@ ...@@ -11,6 +11,13 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# this script requires python2. However, we'd like to be able to print
# an informative message to a user who might be unknowingly running
# python3 so we can't allow any python2 print statements to sneak in
# since they result in syntax errors in python3. By importing
# print_function we are requiring ourselves to use the python3 syntax.
from __future__ import print_function
import sys import sys
import os import os
import re import re
...@@ -23,6 +30,27 @@ from print_out import print_out_str, set_outfile, print_out_section ...@@ -23,6 +30,27 @@ from print_out import print_out_str, set_outfile, print_out_section
# Please update version when something is changed!' # Please update version when something is changed!'
VERSION = '2.0' VERSION = '2.0'
# quick check of system requirements:
major, minor = sys.version_info[:2]
if major != 2:
print("This script requires python2 to run!\n")
print("You seem to be running: " + sys.version)
print()
sys.exit(1)
if minor != 7 and '--force-26' not in sys.argv:
from textwrap import dedent
print(dedent("""
Warning! This script is developed and tested with Python 2.7.
You might be able to get things working on 2.6 by installing
a few dependencies (most notably, OrderedDict [1])
and then passing --force-26 to bypass this version check, but
the recommended and supported approach is to install python2.7.
[1] https://pypi.python.org/pypi/ordereddict"""))
sys.exit(1)
if '--force-26' in sys.argv:
sys.argv.remove('--force-26')
def parse_ram_file(option, opt_str, value, parser): def parse_ram_file(option, opt_str, value, parser):
a = getattr(parser.values, option.dest) a = getattr(parser.values, option.dest)
...@@ -223,8 +251,8 @@ if __name__ == '__main__': ...@@ -223,8 +251,8 @@ if __name__ == '__main__':
arm64=options.arm64) arm64=options.arm64)
if options.shell or options.classic_shell: if options.shell or options.classic_shell:
print "Entering interactive shell mode." print("Entering interactive shell mode.")
print "The RamDump instance is available in the `dump' variable\n" print("The RamDump instance is available in the `dump' variable\n")
do_fallback = options.classic_shell do_fallback = options.classic_shell
if not do_fallback: if not do_fallback:
try: try:
......
...@@ -27,7 +27,10 @@ working with common sizes. ...@@ -27,7 +27,10 @@ working with common sizes.
""" """
import math import math
from collections import OrderedDict try:
from collections import OrderedDict
except ImportError:
from ordereddict import OrderedDict
SZ_1 = 0x00000001 SZ_1 = 0x00000001
SZ_2 = 0x00000002 SZ_2 = 0x00000002
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment