From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 019C03854832; Tue, 8 Dec 2020 01:05:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 019C03854832 From: "z49x2vmq at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug python/27021] Python Exception 'NoneType' object has no attribute 'pointer': when using pretty-printer Date: Tue, 08 Dec 2020 01:05:06 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: python X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: z49x2vmq at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Dec 2020 01:05:07 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D27021 --- Comment #3 from z49x2vmq at gmail dot com --- In /usr/share/gcc-10/python/libstdcxx/v6/printers.py, StdMapPrinter.__init_= _() accepts val, which is type of gdb.Value.=20 When "print foo_map" is executed from c++ frame, val.type is of:=20 "std::map, std::allocator > >" But when "print foo_map" is executed from c frame, val.type is of: "class std::map, std::allocator > >" Substring "class " is probablly causing the problem. And "class " comes from c-typeprint.c: > static void > c_type_print_base_1 (struct type *type, struct ui_file *stream, > int show, int level, > enum language language, > const struct type_print_options *flags, > struct print_offset_data *podata) > { > . > . > . > if (language =3D=3D language_c || language =3D=3D language_minimal) > { > if (type->code () =3D=3D TYPE_CODE_UNION) > fprintf_filtered (stream, "union "); > else if (type->code () =3D=3D TYPE_CODE_STRUCT) > { > if (TYPE_DECLARED_CLASS (type)) > fprintf_filtered (stream, "class "); > ... Looks like "class " is prepended if "language =3D=3D language_c".=20 I don't know if this should be considered as gdb bug. Since /usr/share/gcc-10/python/libstdcxx/v6/printers.py belongs to "libstdc= ++" package(Fedora), you might file a bug in libstdc++. Quick workaround would be manually removing "class ", "struct ", "union ", = and "enum " in printers.py: [1]=20 # Starting with the type ORIG, search for the member type NAME. This # handles searching upward through superclasses. This is needed to # work around http://sourceware.org/bugzilla/show_bug.cgi?id=3D13615. def find_type(orig, name): typ =3D orig.strip_typedefs() while True: # Strip cv-qualifiers. PR 67440. search =3D '%s::%s' % (typ.unqualified(), name) search =3D re.sub(r'^(class|struct|enum|union) ', "", search) [2] # Starting with the type ORIG, search for the member type NAME. This # handles searching upward through superclasses. This is needed to # work around http://sourceware.org/bugzilla/show_bug.cgi?id=3D13615. def find_type(orig, name): typ =3D orig.strip_typedefs() while True: # Strip cv-qualifiers. PR 67440. search =3D '%s::%s' % (typ.unqualified(), name) search =3D re.sub(r'^(class|struct|enum|union) ', "", search) --=20 You are receiving this mail because: You are on the CC list for the bug.=