Skip to content
Snippets Groups Projects
Commit 83b75511 authored by Bruno Larsen's avatar Bruno Larsen
Browse files

gdb/testsuite: add regression test for per-objfile typeprinters


PR python/17136 reported an unhandled exception when using typeprinters
only valid on some objfiles, rather than being a global typeprinter. The
fix was accepted without a regression test, and we've been carrying one
out-of-tree for a while but I think it's worth upstreaming. The code
itself was developed by Jan Kratochvil.

Co-Authored-By: default avatarJan Kratochvil <jkratochvil@azul.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17136


Reviewed-By: default avatarAndrew Burgess <aburgess@redhat.com>
Approved-By: default avatarTom Tromey <tom@tromey.com>
parent 349a125d
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,12 @@ templ<basic_string> s; ...@@ -31,6 +31,12 @@ templ<basic_string> s;
basic_string bs; basic_string bs;
class Other
{
};
Other ovar;
int main() int main()
{ {
return 0; return 0;
......
...@@ -48,3 +48,7 @@ gdb_test_no_output "enable type-printer string" ...@@ -48,3 +48,7 @@ gdb_test_no_output "enable type-printer string"
gdb_test "whatis bs" "string" "whatis with enabled printer" gdb_test "whatis bs" "string" "whatis with enabled printer"
gdb_test "whatis s" "templ<string>" gdb_test "whatis s" "templ<string>"
gdb_test "info type-printers" "Type printers for \[^\r\n\]*/py-typeprint:\r\n *other\r\n.*" \
"info type-printers for other"
gdb_test "whatis ovar" "type = Another"
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
import gdb import gdb
class StringRecognizer(object):
class Recognizer(object):
def __init__(self): def __init__(self):
self.enabled = True self.enabled = True
...@@ -32,7 +31,27 @@ class StringTypePrinter(object): ...@@ -32,7 +31,27 @@ class StringTypePrinter(object):
self.enabled = True self.enabled = True
def instantiate(self): def instantiate(self):
return Recognizer() return StringRecognizer()
gdb.type_printers.append(StringTypePrinter()) gdb.type_printers.append(StringTypePrinter())
class OtherRecognizer(object):
def __init__(self):
self.enabled = True
def recognize(self, type_obj):
if type_obj.tag == 'Other':
return 'Another'
return None
class OtherTypePrinter(object):
def __init__(self):
self.name = 'other'
self.enabled = True
def instantiate(self):
return OtherRecognizer()
import gdb.types
gdb.types.register_type_printer(gdb.objfiles()[0], OtherTypePrinter())
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