This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug python/22686] gdb.lookup_type fails for array types
- From: "jwakely.gcc at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Wed, 10 Jan 2018 22:47:33 +0000
- Subject: [Bug python/22686] gdb.lookup_type fails for array types
- Auto-submitted: auto-generated
- References: <bug-22686-4717@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=22686
--- Comment #4 from Jonathan Wakely <jwakely.gcc at gmail dot com> ---
Actually the recognizers do get used for arrays and compound types, but with
inconsistent results. The recognizer only gets used for the name of the type,
but the full definition of the type is still printed out.
##########
cat > x.cc << EOT
struct X { int i; };
int main()
{
X x;
X x2[2];
return 0;
}
EOT
cat > xprinter.py << EOT
import gdb
class XPrinter(gdb.types.TypePrinter):
def __init__(self):
super(XPrinter, self).__init__('X')
def instantiate(self):
return self._recognizer()
class _recognizer:
def recognize(self, typ):
if typ.name == 'X':
return '__X__'
return None
gdb.types.register_type_printer(gdb.current_objfile(), XPrinter())
EOT
g++ -g x.cc
gdb -q -ex 'py sys.path.insert(0, ".")' -ex "py import xprinter" \
-ex start -ex "ptype x" -ex "ptype x2" -ex cont -ex quit a.out
##########
The GDB output is:
Reading symbols from a.out...done.
Temporary breakpoint 1 at 0x4004ab: file x.cc, line 7.
Starting program: /tmp/a.out
Temporary breakpoint 1, main () at x.cc:7
7 return 0;
type = __X__
type = struct __X__ {
int i;
} [2]
Continuing.
[Inferior 1 (process 29374) exited normally]
The first ptype has the expected result, but the second prints:
type = struct __X__ {
int i;
} [2]
I expected it to be something like "__X__ [2]" instead.
--
You are receiving this mail because:
You are on the CC list for the bug.