* [Bug python/27021] Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer': when using pretty-printer
2020-12-05 7:35 [Bug python/27021] New: Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer': when using pretty-printer ppluzhnikov at google dot com
@ 2020-12-05 16:40 ` ppluzhnikov at google dot com
2020-12-06 15:08 ` z49x2vmq at gmail dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ppluzhnikov at google dot com @ 2020-12-05 16:40 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=27021
Paul Pluzhnikov <ppluzhnikov at google dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|9.1 |HEAD
--- Comment #1 from Paul Pluzhnikov <ppluzhnikov at google dot com> ---
Simpler test case (no need for two files):
#include <stdlib.h>
#include <map>
std::map<int, int> foo_map;
int main()
{
foo_map[1] = 10;
foo_map[2] = 20;
abort();
}
Also confirmed that current head:
GNU gdb (GDB) 11.0.50.20201205-git
is affected.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug python/27021] Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer': when using pretty-printer
2020-12-05 7:35 [Bug python/27021] New: Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer': when using pretty-printer ppluzhnikov at google dot com
2020-12-05 16:40 ` [Bug python/27021] " ppluzhnikov at google dot com
@ 2020-12-06 15:08 ` z49x2vmq at gmail dot com
2020-12-06 16:58 ` ppluzhnikov at google dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: z49x2vmq at gmail dot com @ 2020-12-06 15:08 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=27021
z49x2vmq at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |z49x2vmq at gmail dot com
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug python/27021] Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer': when using pretty-printer
2020-12-05 7:35 [Bug python/27021] New: Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer': when using pretty-printer ppluzhnikov at google dot com
2020-12-05 16:40 ` [Bug python/27021] " ppluzhnikov at google dot com
2020-12-06 15:08 ` z49x2vmq at gmail dot com
@ 2020-12-06 16:58 ` ppluzhnikov at google dot com
2020-12-08 1:05 ` z49x2vmq at gmail dot com
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ppluzhnikov at google dot com @ 2020-12-06 16:58 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=27021
--- Comment #2 from Paul Pluzhnikov <ppluzhnikov at google dot com> ---
There is a very similar failure when the current frame is in the correct ELF
image, but has the "wrong" language:
--- main.cc ---
#include <map>
extern "C" int foo();
static std::map<int, int> foo_map;
int main()
{
foo_map[1] = 10;
foo_map[2] = 20;
return foo();
}
--- foo.c --- // Note: plain "C"
#include <stdlib.h>
int foo() { abort(); }
gcc -g -c foo.c && g++ -g main.cc foo.o && ./a.out
gdb ./a.out core
GNU gdb (GDB) 11.0.50.20201205-git
...
Reading symbols from a.out...
[New LWP 228379]
Core was generated by `./a.out'.
Program terminated with signal SIGABRT, Aborted.
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) up
#1 0x00007fb556b98537 in __GI_abort () at abort.c:79
79 abort.c: No such file or directory.
(gdb)
#2 0x000055732abe9942 in foo () at foo.c:3
3 int foo() { abort(); }
(gdb) p foo_map
Python Exception <type 'exceptions.AttributeError'> 'NoneType' object has no
attribute 'pointer':
$1 = std::map with 2 elements
(gdb) info symbol foo
foo in section .text of /tmp/a.out
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug python/27021] Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer': when using pretty-printer
2020-12-05 7:35 [Bug python/27021] New: Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer': when using pretty-printer ppluzhnikov at google dot com
` (2 preceding siblings ...)
2020-12-06 16:58 ` ppluzhnikov at google dot com
@ 2020-12-08 1:05 ` z49x2vmq at gmail dot com
2020-12-08 1:11 ` z49x2vmq at gmail dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: z49x2vmq at gmail dot com @ 2020-12-08 1:05 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=27021
--- 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.
When "print foo_map" is executed from c++ frame, val.type is of:
"std::map<int, int, std::less<int>, std::allocator<std::pair<int const,
int> > >"
But when "print foo_map" is executed from c frame, val.type is of:
"class std::map<int, int, std::less<int>, std::allocator<std::pair<int
const, int> > >"
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 == language_c || language == language_minimal)
> {
> if (type->code () == TYPE_CODE_UNION)
> fprintf_filtered (stream, "union ");
> else if (type->code () == TYPE_CODE_STRUCT)
> {
> if (TYPE_DECLARED_CLASS (type))
> fprintf_filtered (stream, "class ");
> ...
Looks like "class " is prepended if "language == language_c".
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]
# 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=13615.
def find_type(orig, name):
typ = orig.strip_typedefs()
while True:
# Strip cv-qualifiers. PR 67440.
search = '%s::%s' % (typ.unqualified(), name)
search = 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=13615.
def find_type(orig, name):
typ = orig.strip_typedefs()
while True:
# Strip cv-qualifiers. PR 67440.
search = '%s::%s' % (typ.unqualified(), name)
search = re.sub(r'^(class|struct|enum|union) ', "", search)
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug python/27021] Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer': when using pretty-printer
2020-12-05 7:35 [Bug python/27021] New: Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer': when using pretty-printer ppluzhnikov at google dot com
` (3 preceding siblings ...)
2020-12-08 1:05 ` z49x2vmq at gmail dot com
@ 2020-12-08 1:11 ` z49x2vmq at gmail dot com
2020-12-08 18:31 ` simark at simark dot ca
2020-12-16 12:33 ` rae.kim at gmail dot com
6 siblings, 0 replies; 8+ messages in thread
From: z49x2vmq at gmail dot com @ 2020-12-08 1:11 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=27021
--- Comment #4 from z49x2vmq at gmail dot com ---
[2]
def lookup_templ_spec(templ, *args):
"""
Lookup template specialization templ<args...>
"""
t = '{}<{}>'.format(templ, ', '.join([re.sub(r'^(class|struct|enum|union)
', "", str(a)) for a in args]))
print(t)
try:
return gdb.lookup_type(t)
except gdb.error as e:
# Type not found, try again in versioned namespace.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug python/27021] Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer': when using pretty-printer
2020-12-05 7:35 [Bug python/27021] New: Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer': when using pretty-printer ppluzhnikov at google dot com
` (4 preceding siblings ...)
2020-12-08 1:11 ` z49x2vmq at gmail dot com
@ 2020-12-08 18:31 ` simark at simark dot ca
2020-12-16 12:33 ` rae.kim at gmail dot com
6 siblings, 0 replies; 8+ messages in thread
From: simark at simark dot ca @ 2020-12-08 18:31 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=27021
Simon Marchi <simark at simark dot ca> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |simark at simark dot ca
--- Comment #5 from Simon Marchi <simark at simark dot ca> ---
I don't have time to dig into this, but I think I've seen the same issue when
trying to print an std::list when debugging GDB itself.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug python/27021] Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer': when using pretty-printer
2020-12-05 7:35 [Bug python/27021] New: Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer': when using pretty-printer ppluzhnikov at google dot com
` (5 preceding siblings ...)
2020-12-08 18:31 ` simark at simark dot ca
@ 2020-12-16 12:33 ` rae.kim at gmail dot com
6 siblings, 0 replies; 8+ messages in thread
From: rae.kim at gmail dot com @ 2020-12-16 12:33 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=27021
--- Comment #6 from Rae Kim <rae.kim at gmail dot com> ---
When "info variables foo_map" is executed returned type string doesn't have
"class "
> (gdb) info variables foo_map
> All variables matching regular expression "foo_map":
>
> File main.c:
> 4: std::map<int, int, std::less<int>, std::allocator<std::pair<int const, int> > > foo_map;
Language is changed to the m_language of the symbol during "info variables
foo_map".
(scoped_switch_to_sym_language_if_auto l (sym))
symtab.c:
> 4883 static void
> 4884 print_symbol_info (enum search_domain kind,
> 4885 struct symbol *sym,
> 4886 int block, const char *last)
> 4887 {
> 4888 scoped_switch_to_sym_language_if_auto l (sym);
> 4889 struct symtab *s = symbol_symtab (sym);
> 4890
> 4891 if (last != NULL)
> 4892 {
Is it possible to apply something like "scoped_switch_to_sym_language_if_auto"
to pretty print?
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread