diff options
author | rjvdboon <rjvdboon@gmail.com> | 2018-06-26 16:10:07 +0300 |
---|---|---|
committer | Alexander Köplinger <alex.koeplinger@outlook.com> | 2018-06-26 16:10:07 +0300 |
commit | 16e7e18a5303e93aa761424e550cc9051bc9e38c (patch) | |
tree | 3fea8e921a05696c032aa094cb0abf2e07bbdb63 /data/gdb-pre7.0 | |
parent | b826d40975fef7820b8a34f9b575b0160ad8fc9f (diff) |
Use positional parameters in calls to .format in gdb python scripts (#9311)
Omitting positional parameters works for gdb linked to python 2.7 / 3.1+. On older systems (e.g. redhat 6, centos 6) gdb might be linked to python 2.4-2.6 or 3.0, adding parameter ordinals enables proper backtraces on those systems.
Fixes #9292.
Diffstat (limited to 'data/gdb-pre7.0')
-rw-r--r-- | data/gdb-pre7.0/mono-gdb.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/data/gdb-pre7.0/mono-gdb.py b/data/gdb-pre7.0/mono-gdb.py index eda0ba36da7..4dea97b0da0 100644 --- a/data/gdb-pre7.0/mono-gdb.py +++ b/data/gdb-pre7.0/mono-gdb.py @@ -53,7 +53,7 @@ def stringify_class_name(ns, name): if ns == "": return name else: - return "{}.{}".format (ns, name) + return "{0}.{1}".format (ns, name) class ArrayPrinter: "Print a C# array" @@ -66,7 +66,7 @@ class ArrayPrinter: def to_string(self): obj = self.val.cast (gdb.lookup_type ("MonoArray").pointer ()).dereference () length = obj ['max_length'] - return "{} [{}]".format (stringify_class_name (self.class_ns, self.class_name [0:len (self.class_name) - 2]), int (length)) + return "{0} [{1}]".format (stringify_class_name (self.class_ns, self.class_name [0:len (self.class_name) - 2]), int (length)) class ObjectPrinter: "Print a C# object" @@ -96,7 +96,7 @@ class ObjectPrinter: return (field.name, self.obj [field.name]) except: # Superclass - return (field.name, self.obj.cast (gdb.lookup_type ("{}".format (field.name)))) + return (field.name, self.obj.cast (gdb.lookup_type ("{0}".format (field.name)))) def children(self): # FIXME: It would be easier if gdb.Value would support iteration itself @@ -109,7 +109,7 @@ class ObjectPrinter: class_name = obj ['vtable'].dereference ()['klass'].dereference ()['name'].string () if class_name [-2:len(class_name)] == "[]": return {}.__iter__ () - gdb_type = gdb.lookup_type ("struct {}_{}".format (class_ns.replace (".", "_"), class_name)) + gdb_type = gdb.lookup_type ("struct {0}_{1}".format (class_ns.replace (".", "_"), class_name)) return self._iterator(obj.cast (gdb_type)) except: print (sys.exc_info ()[0]) @@ -129,12 +129,12 @@ class ObjectPrinter: return ArrayPrinter (self.val,class_ns,class_name).to_string () if class_ns != "": try: - gdb_type = gdb.lookup_type ("struct {}.{}".format (class_ns, class_name)) + gdb_type = gdb.lookup_type ("struct {0}.{1}".format (class_ns, class_name)) except: # Maybe there is no debug info for that type - return "{}.{}".format (class_ns, class_name) + return "{0}.{1}".format (class_ns, class_name) #return obj.cast (gdb_type) - return "{}.{}".format (class_ns, class_name) + return "{0}.{1}".format (class_ns, class_name) return class_name except: print (sys.exc_info ()[0]) @@ -154,9 +154,9 @@ class MonoMethodPrinter: val = self.val.dereference () klass = val ["klass"].dereference () class_name = stringify_class_name (klass ["name_space"].string (), klass ["name"].string ()) - return "\"{}:{} ()\"".format (class_name, val ["name"].string ()) + return "\"{0}:{1} ()\"".format (class_name, val ["name"].string ()) # This returns more info but requires calling into the inferior - #return "\"{}\"".format (gdb.parse_and_eval ("mono_method_full_name ({}, 1)".format (str (int (self.val.cast (gdb.lookup_type ("guint64")))))).string ()) + #return "\"{0}\"".format (gdb.parse_and_eval ("mono_method_full_name ({0}, 1)".format (str (int (self.val.cast (gdb.lookup_type ("guint64")))))).string ()) class MonoClassPrinter: "Print a MonoClass structure" @@ -169,9 +169,9 @@ class MonoClassPrinter: return "0x0" klass = self.val.dereference () class_name = stringify_class_name (klass ["name_space"].string (), klass ["name"].string ()) - return "\"{}\"".format (class_name) + return "\"{0}\"".format (class_name) # This returns more info but requires calling into the inferior - #return "\"{}\"".format (gdb.parse_and_eval ("mono_type_full_name (&((MonoClass*){})->byval_arg)".format (str (int ((self.val).cast (gdb.lookup_type ("guint64"))))))) + #return "\"{0}\"".format (gdb.parse_and_eval ("mono_type_full_name (&((MonoClass*){0})->byval_arg)".format (str (int ((self.val).cast (gdb.lookup_type ("guint64"))))))) def lookup_pretty_printer(val): t = str (val.type) @@ -245,4 +245,4 @@ exec_file = gdb.current_objfile ().filename if os.stat (exec_file).st_size != os.lstat (exec_file).st_size: exec_file = os.readlink (exec_file) exec_dir = os.path.dirname (exec_file) -gdb.execute ("source {}/{}-gdbinit".format (exec_dir, os.path.basename (exec_file))) +gdb.execute ("source {0}/{1}-gdbinit".format (exec_dir, os.path.basename (exec_file))) |