aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python/lib')
-rw-r--r--gdb/python/lib/gdb/__init__.py2
-rw-r--r--gdb/python/lib/gdb/command/explore.py22
-rw-r--r--gdb/python/lib/gdb/printer/bound_registers.py7
-rw-r--r--gdb/python/lib/gdb/printing.py9
-rw-r--r--gdb/python/lib/gdb/xmethod.py8
5 files changed, 14 insertions, 34 deletions
diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py
index 5f63bce..a52f6b4 100644
--- a/gdb/python/lib/gdb/__init__.py
+++ b/gdb/python/lib/gdb/__init__.py
@@ -22,7 +22,7 @@ from contextlib import contextmanager
# Python 3 moved "reload"
if sys.version_info >= (3, 4):
from importlib import reload
-elif sys.version_info[0] > 2:
+else:
from imp import reload
from _gdb import *
diff --git a/gdb/python/lib/gdb/command/explore.py b/gdb/python/lib/gdb/command/explore.py
index ea49c38..c03bef3 100644
--- a/gdb/python/lib/gdb/command/explore.py
+++ b/gdb/python/lib/gdb/command/explore.py
@@ -19,10 +19,6 @@
import gdb
import sys
-if sys.version_info[0] > 2:
- # Python 3 renamed raw_input to input
- raw_input = input
-
class Explorer(object):
"""Internal class which invokes other explorers."""
@@ -172,7 +168,7 @@ class Explorer(object):
so that the exploration session can shift back to the parent value.
Useful when exploring values.
"""
- raw_input("\nPress enter to return to parent value: ")
+ input("\nPress enter to return to parent value: ")
@staticmethod
def return_to_enclosing_type():
@@ -187,7 +183,7 @@ class Explorer(object):
so that the exploration session can shift back to the enclosing type.
Useful when exploring types.
"""
- raw_input("\nPress enter to return to enclosing type: ")
+ input("\nPress enter to return to enclosing type: ")
class ScalarExplorer(object):
@@ -244,7 +240,7 @@ class PointerExplorer(object):
"'%s' is a pointer to a value of type '%s'"
% (expr, str(value.type.target()))
)
- option = raw_input(
+ option = input(
"Continue exploring it as a pointer to a single " "value [y/n]: "
)
if option == "y":
@@ -264,13 +260,13 @@ class PointerExplorer(object):
)
return False
- option = raw_input("Continue exploring it as a pointer to an " "array [y/n]: ")
+ option = input("Continue exploring it as a pointer to an " "array [y/n]: ")
if option == "y":
while True:
index = 0
try:
index = int(
- raw_input(
+ input(
"Enter the index of the element you "
"want to explore in '%s': " % expr
)
@@ -338,7 +334,7 @@ class ArrayExplorer(object):
index = 0
try:
index = int(
- raw_input(
+ input(
"Enter the index of the element you want to "
"explore in '%s': " % expr
)
@@ -354,7 +350,7 @@ class ArrayExplorer(object):
str(element)
except gdb.MemoryError:
print("Cannot read value at index %d." % index)
- raw_input("Press enter to continue... ")
+ input("Press enter to continue... ")
return True
Explorer.explore_expr(
@@ -474,7 +470,7 @@ class CompoundExplorer(object):
print("")
if has_explorable_fields:
- choice = raw_input("Enter the field number of choice: ")
+ choice = input("Enter the field number of choice: ")
if choice in choice_to_compound_field_map:
Explorer.explore_expr(
choice_to_compound_field_map[choice][0],
@@ -550,7 +546,7 @@ class CompoundExplorer(object):
print("")
if len(choice_to_compound_field_map) > 0:
- choice = raw_input("Enter the field number of choice: ")
+ choice = input("Enter the field number of choice: ")
if choice in choice_to_compound_field_map:
if is_child:
new_name = "%s '%s' of %s" % (
diff --git a/gdb/python/lib/gdb/printer/bound_registers.py b/gdb/python/lib/gdb/printer/bound_registers.py
index f8ce9ea..7cb6e8f 100644
--- a/gdb/python/lib/gdb/printer/bound_registers.py
+++ b/gdb/python/lib/gdb/printer/bound_registers.py
@@ -18,11 +18,6 @@ import sys
import gdb.printing
-if sys.version_info[0] > 2:
- # Python 3 removed basestring and long
- basestring = str
- long = int
-
class MpxBound128Printer:
"""Adds size field to a mpx __gdb_builtin_type_bound128 type."""
@@ -33,7 +28,7 @@ class MpxBound128Printer:
def to_string(self):
upper = self.val["ubound"]
lower = self.val["lbound"]
- size = (long)((upper) - (lower))
+ size = upper - lower
if size > -1:
size = size + 1
result = "{lbound = %s, ubound = %s} : size %s" % (lower, upper, size)
diff --git a/gdb/python/lib/gdb/printing.py b/gdb/python/lib/gdb/printing.py
index 93d61f1..e208e88 100644
--- a/gdb/python/lib/gdb/printing.py
+++ b/gdb/python/lib/gdb/printing.py
@@ -21,11 +21,6 @@ import gdb.types
import re
import sys
-if sys.version_info[0] > 2:
- # Python 3 removed basestring and long
- basestring = str
- long = int
-
class PrettyPrinter(object):
"""A basic pretty-printer.
@@ -132,7 +127,7 @@ def register_pretty_printer(obj, printer, replace=False):
# Printers implemented as functions are old-style. In order to not risk
# breaking anything we do not check __name__ here.
if hasattr(printer, "name"):
- if not isinstance(printer.name, basestring):
+ if not isinstance(printer.name, str):
raise TypeError("printer name is not a string")
# If printer provides a name, make sure it doesn't contain ";".
# Semicolon is used by the info/enable/disable pretty-printer commands
@@ -232,7 +227,7 @@ class _EnumInstance:
def to_string(self):
flag_list = []
- v = long(self.val)
+ v = int(self.val)
any_found = False
for (e_name, e_value) in self.enumerators:
if v & e_value != 0:
diff --git a/gdb/python/lib/gdb/xmethod.py b/gdb/python/lib/gdb/xmethod.py
index 4c3a522..c69ea99 100644
--- a/gdb/python/lib/gdb/xmethod.py
+++ b/gdb/python/lib/gdb/xmethod.py
@@ -21,12 +21,6 @@ import re
import sys
-if sys.version_info[0] > 2:
- # Python 3 removed basestring and long
- basestring = str
- long = int
-
-
class XMethod(object):
"""Base class (or a template) for an xmethod description.
@@ -223,7 +217,7 @@ def _validate_xmethod_matcher(matcher):
return TypeError("Xmethod matcher is missing attribute: name")
if not hasattr(matcher, "enabled"):
return TypeError("Xmethod matcher is missing attribute: enabled")
- if not isinstance(matcher.name, basestring):
+ if not isinstance(matcher.name, str):
return TypeError("Attribute 'name' of xmethod matcher is not a " "string")
if matcher.name.find(";") >= 0:
return ValueError("Xmethod matcher name cannot contain ';' in it")