* [patch] Fix internal error on canonicalization of clang types [Re: why in cplus_demangle_operators operation sizeof is expected to be followed with space] [not found] ` <CAGj4m+46oBXSYQ-wx9g-P7yevZeMDnNNEjvADE8sRSdoWaRiVA@mail.gmail.com> @ 2012-09-17 6:27 ` Jan Kratochvil 2012-09-17 8:29 ` Vasyl Vavrychuk 0 siblings, 1 reply; 11+ messages in thread From: Jan Kratochvil @ 2012-09-17 6:27 UTC (permalink / raw) To: Vasyl Vavrychuk; +Cc: gdb-patches [-- Attachment #1: Type: text/plain, Size: 1625 bytes --] On Mon, 17 Sep 2012 07:49:16 +0200, Vasyl Vavrychuk wrote: > This looks to be not a symbol but type name. OK, reproduced [attached], patched DWARF of "int" in C++: void f(int i) {} > But I have found it directly in the binary. Line containing this text looks like readelf -wi <1><59>: Abbrev Number: 4 (DW_TAG_base_type) <5c> DW_AT_name : exact_unsigned_base_helper<sizeof(unsigned int) * 8> > Do you think the problem is in clang? Could you point out some > specification, so I can reference it while contacting clang people. Itanium C++ ABI does not say anything about spacing: http://www.swag.uwaterloo.ca/acd/docs/ItaniumC++ABI.htm (the original URL is 404 now) I guess so far it is only agreed upon between GCC and GDB, it is true GDB should accept any valid spacing of the language, this is also what cp_canonicalize_string is there for. Your patch would belons to the GCC mailing lists where libiberty/ is maintained. But I find more correct patch the one below. For a testcase could you provide a minimal C++ code to produce such type? No regressions on {x86_64,x86_64-m32,i686}-fedora18-linux-gnu. Thanks, Jan gdb/ 2012-09-17 Jan Kratochvil <jan.kratochvil@redhat.com> Fix internal error on canonicalization of clang types. * cp-name-parser.y (exp): Use "sizeof ". diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y index 6767fa5..c57ce64 100644 --- a/gdb/cp-name-parser.y +++ b/gdb/cp-name-parser.y @@ -1183,7 +1183,7 @@ exp : FLOAT ; exp : SIZEOF '(' type ')' %prec UNARY - { $$ = d_unary ("sizeof", $3); } + { $$ = d_unary ("sizeof ", $3); } ; /* C++. */ [-- Attachment #2: type.S --] [-- Type: text/plain, Size: 4890 bytes --] .file "type.C" .text .Ltext0: .globl _Z1fi .type _Z1fi, @function _Z1fi: .LFB0: .file 1 "type.C" # type.C:1 .loc 1 1 0 .cfi_startproc # BLOCK 2 seq:0 # PRED: ENTRY (fallthru) pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 movl %edi, -4(%rbp) # type.C:1 .loc 1 1 0 popq %rbp .cfi_def_cfa 7, 8 # SUCC: EXIT [100.0%] ret .cfi_endproc .LFE0: .size _Z1fi, .-_Z1fi .Letext0: .section .debug_info,"",@progbits .Ldebug_info0: .long 1f-2f # Length of Compilation Unit Info 2: .value 0x4 # DWARF version number .long .Ldebug_abbrev0 # Offset Into Abbrev. Section .byte 0x8 # Pointer Size (in bytes) .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit) .long .LASF0 # DW_AT_producer: "GNU C++ 4.7.1 20120720 (Red Hat 4.7.1-5) -mtune=generic -march=x86-64 -g" .byte 0x4 # DW_AT_language .long .LASF1 # DW_AT_name: "type.C" .long .LASF2 # DW_AT_comp_dir: "/home/jkratoch/t" .quad .Ltext0 # DW_AT_low_pc .quad .Letext0 # DW_AT_high_pc .long .Ldebug_line0 # DW_AT_stmt_list .uleb128 0x2 # (DIE (0x2d) DW_TAG_subprogram) # DW_AT_external .ascii "f\0" # DW_AT_name .byte 0x1 # DW_AT_decl_file (type.C) .byte 0x1 # DW_AT_decl_line .long .LASF3 # DW_AT_linkage_name: "_Z1fi" .quad .LFB0 # DW_AT_low_pc .quad .LFE0 # DW_AT_high_pc .uleb128 0x1 # DW_AT_frame_base .byte 0x9c # DW_OP_call_frame_cfa # DW_AT_GNU_all_call_sites .long 0x59 # DW_AT_sibling .uleb128 0x3 # (DIE (0x4c) DW_TAG_formal_parameter) .ascii "i\0" # DW_AT_name .byte 0x1 # DW_AT_decl_file (type.C) .byte 0x1 # DW_AT_decl_line .long 0x59 # DW_AT_type .uleb128 0x2 # DW_AT_location .byte 0x91 # DW_OP_fbreg .sleb128 -20 .byte 0 # end of children of DIE 0x2d .uleb128 0x4 # (DIE (0x59) DW_TAG_base_type) .byte 0x4 # DW_AT_byte_size .byte 0x5 # DW_AT_encoding #if 0 .ascii "int\0" # DW_AT_name #else .ascii "exact_unsigned_base_helper<sizeof(unsigned int) * 8>\0" # DW_AT_name #endif .byte 0 # end of children of DIE 0xb 1: .section .debug_abbrev,"",@progbits .Ldebug_abbrev0: .uleb128 0x1 # (abbrev code) .uleb128 0x11 # (TAG: DW_TAG_compile_unit) .byte 0x1 # DW_children_yes .uleb128 0x25 # (DW_AT_producer) .uleb128 0xe # (DW_FORM_strp) .uleb128 0x13 # (DW_AT_language) .uleb128 0xb # (DW_FORM_data1) .uleb128 0x3 # (DW_AT_name) .uleb128 0xe # (DW_FORM_strp) .uleb128 0x1b # (DW_AT_comp_dir) .uleb128 0xe # (DW_FORM_strp) .uleb128 0x11 # (DW_AT_low_pc) .uleb128 0x1 # (DW_FORM_addr) .uleb128 0x12 # (DW_AT_high_pc) .uleb128 0x1 # (DW_FORM_addr) .uleb128 0x10 # (DW_AT_stmt_list) .uleb128 0x17 # (DW_FORM_sec_offset) .byte 0 .byte 0 .uleb128 0x2 # (abbrev code) .uleb128 0x2e # (TAG: DW_TAG_subprogram) .byte 0x1 # DW_children_yes .uleb128 0x3f # (DW_AT_external) .uleb128 0x19 # (DW_FORM_flag_present) .uleb128 0x3 # (DW_AT_name) .uleb128 0x8 # (DW_FORM_string) .uleb128 0x3a # (DW_AT_decl_file) .uleb128 0xb # (DW_FORM_data1) .uleb128 0x3b # (DW_AT_decl_line) .uleb128 0xb # (DW_FORM_data1) .uleb128 0x6e # (DW_AT_linkage_name) .uleb128 0xe # (DW_FORM_strp) .uleb128 0x11 # (DW_AT_low_pc) .uleb128 0x1 # (DW_FORM_addr) .uleb128 0x12 # (DW_AT_high_pc) .uleb128 0x1 # (DW_FORM_addr) .uleb128 0x40 # (DW_AT_frame_base) .uleb128 0x18 # (DW_FORM_exprloc) .uleb128 0x2117 # (DW_AT_GNU_all_call_sites) .uleb128 0x19 # (DW_FORM_flag_present) .uleb128 0x1 # (DW_AT_sibling) .uleb128 0x13 # (DW_FORM_ref4) .byte 0 .byte 0 .uleb128 0x3 # (abbrev code) .uleb128 0x5 # (TAG: DW_TAG_formal_parameter) .byte 0 # DW_children_no .uleb128 0x3 # (DW_AT_name) .uleb128 0x8 # (DW_FORM_string) .uleb128 0x3a # (DW_AT_decl_file) .uleb128 0xb # (DW_FORM_data1) .uleb128 0x3b # (DW_AT_decl_line) .uleb128 0xb # (DW_FORM_data1) .uleb128 0x49 # (DW_AT_type) .uleb128 0x13 # (DW_FORM_ref4) .uleb128 0x2 # (DW_AT_location) .uleb128 0x18 # (DW_FORM_exprloc) .byte 0 .byte 0 .uleb128 0x4 # (abbrev code) .uleb128 0x24 # (TAG: DW_TAG_base_type) .byte 0 # DW_children_no .uleb128 0xb # (DW_AT_byte_size) .uleb128 0xb # (DW_FORM_data1) .uleb128 0x3e # (DW_AT_encoding) .uleb128 0xb # (DW_FORM_data1) .uleb128 0x3 # (DW_AT_name) .uleb128 0x8 # (DW_FORM_string) .byte 0 .byte 0 .byte 0 .section .debug_aranges,"",@progbits .long 0x2c # Length of Address Ranges Info .value 0x2 # DWARF Version .long .Ldebug_info0 # Offset of Compilation Unit Info .byte 0x8 # Size of Address .byte 0 # Size of Segment Descriptor .value 0 # Pad to 16 byte boundary .value 0 .quad .Ltext0 # Address .quad .Letext0-.Ltext0 # Length .quad 0 .quad 0 .section .debug_line,"",@progbits .Ldebug_line0: .section .debug_str,"MS",@progbits,1 .LASF1: .string "type.C" .LASF2: .string "/home/jkratoch/t" .LASF0: .string "GNU C++ 4.7.1 20120720 (Red Hat 4.7.1-5) -mtune=generic -march=x86-64 -g" .LASF3: .string "_Z1fi" .ident "GCC: (GNU) 4.7.1 20120720 (Red Hat 4.7.1-5)" .section .note.GNU-stack,"",@progbits ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Fix internal error on canonicalization of clang types [Re: why in cplus_demangle_operators operation sizeof is expected to be followed with space] 2012-09-17 6:27 ` [patch] Fix internal error on canonicalization of clang types [Re: why in cplus_demangle_operators operation sizeof is expected to be followed with space] Jan Kratochvil @ 2012-09-17 8:29 ` Vasyl Vavrychuk 2012-09-17 15:30 ` [patch] Fix internal error on canonicalization of clang types (+lib/gdb.exp internal error catch) Jan Kratochvil 0 siblings, 1 reply; 11+ messages in thread From: Vasyl Vavrychuk @ 2012-09-17 8:29 UTC (permalink / raw) To: Jan Kratochvil; +Cc: gdb-patches Problem happening for the file #include <cstdlib> #include <boost/uuid/uuid_generators.hpp> int main(int argc, char* argv[]) { boost::uuids::random_generator gen; return EXIT_SUCCESS; } clang++ -g -O0 sizeof-space-test.cpp readelf -wi a.out|grep exact_unsigned_base_helper <4072> DW_AT_name : (indirect string, offset: 0x3f3e): exact_unsigned_base_helper<sizeof(unsigned int) * 8> but if compiled with g++ there is no such typename in dwarf g++ -g -O0 sizeof-space-test.cpp readelf -wi a.out|grep exact_unsigned_base_helper Sorry, but I didn't succeed in further reducing mentioned test file. On Mon, Sep 17, 2012 at 9:26 AM, Jan Kratochvil <jan.kratochvil@redhat.com> wrote: > On Mon, 17 Sep 2012 07:49:16 +0200, Vasyl Vavrychuk wrote: >> This looks to be not a symbol but type name. > > OK, reproduced [attached], patched DWARF of "int" in C++: void f(int i) {} > > >> But I have found it directly in the binary. Line containing this text looks like > > readelf -wi > <1><59>: Abbrev Number: 4 (DW_TAG_base_type) > <5c> DW_AT_name : exact_unsigned_base_helper<sizeof(unsigned int) * 8> > > >> Do you think the problem is in clang? Could you point out some >> specification, so I can reference it while contacting clang people. > > Itanium C++ ABI does not say anything about spacing: > http://www.swag.uwaterloo.ca/acd/docs/ItaniumC++ABI.htm > (the original URL is 404 now) > > I guess so far it is only agreed upon between GCC and GDB, it is true GDB > should accept any valid spacing of the language, this is also what > cp_canonicalize_string is there for. > > Your patch would belons to the GCC mailing lists where libiberty/ is > maintained. > > But I find more correct patch the one below. > > For a testcase could you provide a minimal C++ code to produce such type? > > No regressions on {x86_64,x86_64-m32,i686}-fedora18-linux-gnu. > > > Thanks, > Jan > > > gdb/ > 2012-09-17 Jan Kratochvil <jan.kratochvil@redhat.com> > > Fix internal error on canonicalization of clang types. > * cp-name-parser.y (exp): Use "sizeof ". > > diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y > index 6767fa5..c57ce64 100644 > --- a/gdb/cp-name-parser.y > +++ b/gdb/cp-name-parser.y > @@ -1183,7 +1183,7 @@ exp : FLOAT > ; > > exp : SIZEOF '(' type ')' %prec UNARY > - { $$ = d_unary ("sizeof", $3); } > + { $$ = d_unary ("sizeof ", $3); } > ; > > /* C++. */ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Fix internal error on canonicalization of clang types (+lib/gdb.exp internal error catch) 2012-09-17 8:29 ` Vasyl Vavrychuk @ 2012-09-17 15:30 ` Jan Kratochvil 2012-09-17 15:40 ` Doug Evans 0 siblings, 1 reply; 11+ messages in thread From: Jan Kratochvil @ 2012-09-17 15:30 UTC (permalink / raw) To: Vasyl Vavrychuk; +Cc: gdb-patches On Mon, 17 Sep 2012 10:28:52 +0200, Vasyl Vavrychuk wrote: > Problem happening for the file > > #include <cstdlib> > #include <boost/uuid/uuid_generators.hpp> > int main(int argc, char* argv[]) { > boost::uuids::random_generator gen; > return EXIT_SUCCESS; > } > > clang++ -g -O0 sizeof-space-test.cpp > readelf -wi a.out|grep exact_unsigned_base_helper > <4072> DW_AT_name : (indirect string, offset: 0x3f3e): > exact_unsigned_base_helper<sizeof(unsigned int) * 8> Not reproducible for me with clang-3.1-9.fc18.x86_64 and boost-1.50.0-2.fc18.x86_64. > but if compiled with g++ there is no such typename in dwarf I believe it belongs into GCC PR Bug 49130 - discrepancies between DW_AT_name and demangler http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49130 as even GCC puts 'sizeof' into the (mangled) ELF function symbol but it does not put it into the (demangled) DWARF type name. So I have at least created a reproducer by hand. No regressions on {x86_64,x86_64-m32,i686}-fedora18-linux-gnu. I have also checked the whitespacing of the few other symbols from libiberty/cp-demangle.c in cp-name-parser.y matches. Thanks, Jan gdb/ 2012-09-17 Jan Kratochvil <jan.kratochvil@redhat.com> Fix internal error on canonicalization of clang types. * cp-name-parser.y (exp): Use "sizeof ". gdb/testsuite/ 2012-09-17 Jan Kratochvil <jan.kratochvil@redhat.com> Fix internal error on canonicalization of clang types. * gdb.dwarf2/dw2-canonicalize-type.S: New file. * gdb.dwarf2/dw2-canonicalize-type.exp: New file. * lib/gdb.exp (gdb_file_cmd): Catch also GDB internal error. diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y index 6767fa5..c57ce64 100644 --- a/gdb/cp-name-parser.y +++ b/gdb/cp-name-parser.y @@ -1183,7 +1183,7 @@ exp : FLOAT ; exp : SIZEOF '(' type ')' %prec UNARY - { $$ = d_unary ("sizeof", $3); } + { $$ = d_unary ("sizeof ", $3); } ; /* C++. */ diff --git a/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.S b/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.S new file mode 100644 index 0000000..dbf8f0a --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.S @@ -0,0 +1,102 @@ +/* Copyright 2012 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + + .text + .globl main +main: .byte 0 +.Lmain_end: + .section .debug_info +debug_start: + .4byte debug_end - 1f /* Length of Compilation Unit Info */ +1: + .2byte 0x3 /* DWARF version number */ + .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ + .byte 0x4 /* Pointer Size (in bytes) */ + .uleb128 0x1 /* (DIE (0xb) DW_TAG_compile_unit) */ + .ascii "GNU C 4.4.3\0" /* DW_AT_producer */ + .byte 0x4 /* DW_AT_language = DW_LANG_C_plus_plus */ + .ascii "1.c\0" /* DW_AT_name */ + .4byte main /* DW_AT_low_pc */ + .4byte .Lmain_end /* DW_AT_high_pc */ + .uleb128 0x4 /* (DIE (0x3c) DW_TAG_subprogram) */ + .ascii "f\0" /* DW_AT_name */ +/* Value 0 would require has_section_at_zero != 0 (which is true, though). */ + .4byte main /* DW_AT_low_pc */ + .4byte .Lmain_end /* DW_AT_high_pc */ + .byte 0x1 /* DW_AT_prototyped */ + .uleb128 0x5 /* (DIE (0x42) DW_TAG_formal_parameter) */ +/* Invalid value. */ + .4byte .Ltype_int - debug_start /* DW_AT_type */ + .ascii "param\0" /* DW_AT_name */ + .byte 0x0 /* end of children of DIE 0x3c */ +.Ltype_int: + .uleb128 3 /* Abbrev: DW_TAG_base_type */ + .ascii "typename<sizeof(int)>\0" /* DW_AT_name */ + .byte 4 /* DW_AT_byte_size */ + .byte 5 /* DW_AT_encoding */ + .byte 0x0 /* end of children of DIE 0xb */ +debug_end: + + .section .debug_abbrev +.Ldebug_abbrev0: + .uleb128 0x1 /* (abbrev code) */ + .uleb128 0x11 /* (TAG: DW_TAG_compile_unit) */ + .byte 0x1 /* DW_children_yes */ + .uleb128 0x25 /* (DW_AT_producer) */ + .uleb128 0x8 /* (DW_FORM_string) */ + .uleb128 0x13 /* (DW_AT_language) */ + .uleb128 0xb /* (DW_FORM_data1) */ + .uleb128 0x3 /* (DW_AT_name) */ + .uleb128 0x8 /* (DW_FORM_string) */ + .uleb128 0x11 /* (DW_AT_low_pc) */ + .uleb128 0x1 /* (DW_FORM_addr) */ + .uleb128 0x12 /* (DW_AT_high_pc) */ + .uleb128 0x1 /* (DW_FORM_addr) */ + .byte 0x0 + .byte 0x0 + .uleb128 3 /* Abbrev code */ + .uleb128 0x24 /* DW_TAG_base_type */ + .byte 0 /* has_children */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0xb /* DW_AT_byte_size */ + .uleb128 0xb /* DW_FORM_data1 */ + .uleb128 0x3e /* DW_AT_encoding */ + .uleb128 0xb /* DW_FORM_data1 */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + .uleb128 0x4 /* (abbrev code) */ + .uleb128 0x2e /* (TAG: DW_TAG_subprogram) */ + .byte 0x1 /* DW_children_yes */ + .uleb128 0x3 /* (DW_AT_name) */ + .uleb128 0x8 /* (DW_FORM_string) */ + .uleb128 0x11 /* (DW_AT_low_pc) */ + .uleb128 0x1 /* (DW_FORM_addr) */ + .uleb128 0x12 /* (DW_AT_high_pc) */ + .uleb128 0x1 /* (DW_FORM_addr) */ + .uleb128 0x27 /* (DW_AT_prototyped) */ + .uleb128 0xc /* (DW_FORM_flag) */ + .byte 0x0 + .byte 0x0 + .uleb128 0x5 /* (abbrev code) */ + .uleb128 0x5 /* (TAG: DW_TAG_formal_parameter) */ + .byte 0x0 /* DW_children_no */ + .uleb128 0x49 /* (DW_AT_type) */ + .uleb128 0x13 /* (DW_FORM_ref4) */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .byte 0x0 + .byte 0x0 + .byte 0x0 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.exp new file mode 100644 index 0000000..2591bc7 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.exp @@ -0,0 +1,29 @@ +# Copyright 2012 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +load_lib dwarf.exp + +# This test can only be run on targets which support DWARF-2 and use gas. +if {![dwarf2_support]} { + return 0 +} + +standard_testfile .S +set executable ${testfile} + +if [prepare_for_testing $testfile.exp $testfile $srcfile {nodebug}] { + return -1 +} + +gdb_test "ptype f" {type = void \(typename<sizeof \(int\)>\)} diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 0b4c679..8715c5e 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1277,6 +1277,11 @@ proc gdb_file_cmd { arg } { perror "($arg) No such file or directory" return -1 } + -re "A problem internal to GDB has been detected" { + fail "($arg) GDB internal error" + gdb_internal_error_resync + return -1 + } -re "$gdb_prompt $" { perror "couldn't load $arg into $GDB." return -1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Fix internal error on canonicalization of clang types (+lib/gdb.exp internal error catch) 2012-09-17 15:30 ` [patch] Fix internal error on canonicalization of clang types (+lib/gdb.exp internal error catch) Jan Kratochvil @ 2012-09-17 15:40 ` Doug Evans 2012-09-17 16:13 ` Jan Kratochvil 0 siblings, 1 reply; 11+ messages in thread From: Doug Evans @ 2012-09-17 15:40 UTC (permalink / raw) To: Jan Kratochvil; +Cc: Vasyl Vavrychuk, gdb-patches On Mon, Sep 17, 2012 at 8:29 AM, Jan Kratochvil <jan.kratochvil@redhat.com> wrote: > gdb/ > 2012-09-17 Jan Kratochvil <jan.kratochvil@redhat.com> > > Fix internal error on canonicalization of clang types. > * cp-name-parser.y (exp): Use "sizeof ". > > > diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y > index 6767fa5..c57ce64 100644 > --- a/gdb/cp-name-parser.y > +++ b/gdb/cp-name-parser.y > @@ -1183,7 +1183,7 @@ exp : FLOAT > ; > > exp : SIZEOF '(' type ')' %prec UNARY > - { $$ = d_unary ("sizeof", $3); } > + { $$ = d_unary ("sizeof ", $3); } > ; > > /* C++. */ I had to look hard to see the change here. Comment explaining "why things are they way they are" is required IMO. [I'm assuming the above change is in fact TRTTD.] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Fix internal error on canonicalization of clang types (+lib/gdb.exp internal error catch) 2012-09-17 15:40 ` Doug Evans @ 2012-09-17 16:13 ` Jan Kratochvil 2012-09-17 19:52 ` Tom Tromey 0 siblings, 1 reply; 11+ messages in thread From: Jan Kratochvil @ 2012-09-17 16:13 UTC (permalink / raw) To: Doug Evans; +Cc: Vasyl Vavrychuk, gdb-patches On Mon, 17 Sep 2012 17:40:00 +0200, Doug Evans wrote: > I had to look hard to see the change here. > Comment explaining "why things are they way they are" is required IMO. > [I'm assuming the above change is in fact TRTTD.] That makes sense. Also extended the testcase for other make_operator calls as removing and adding these spaces is a common patch topic here. I did not find a regression, I could not get working GDB from 2005 but the bug seems to be there since that time. commit c20637db7b29f4886af5f689e00fedfa1dc4ecd8 Author: Daniel Jacobowitz <dan@debian.org> Date: Fri Mar 11 02:24:23 2005 +0000 Thanks, Jan gdb/ 2012-09-17 Jan Kratochvil <jan.kratochvil@redhat.com> Fix internal error on canonicalization of clang types. * cp-name-parser.y (operator): New comment at make_operator call for new, delete, new[] and delete[]. * cp-name-parser.y (exp): Use "sizeof ". Add new comment at make_operator call. gdb/testsuite/ 2012-09-17 Jan Kratochvil <jan.kratochvil@redhat.com> Fix internal error on canonicalization of clang types. * gdb.dwarf2/dw2-canonicalize-type.S: New file. * gdb.dwarf2/dw2-canonicalize-type.exp: New file. * lib/gdb.exp (gdb_file_cmd): Catch also GDB internal error. diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y index 6767fa5..c218244 100644 --- a/gdb/cp-name-parser.y +++ b/gdb/cp-name-parser.y @@ -446,13 +446,29 @@ demangler_special ; operator : OPERATOR NEW - { $$ = make_operator ("new", 3); } + { + /* Match the whitespacing of cplus_demangle_operators. + It would abort on unrecognized string otherwise. */ + $$ = make_operator ("new", 3); + } | OPERATOR DELETE - { $$ = make_operator ("delete ", 1); } + { + /* Match the whitespacing of cplus_demangle_operators. + It would abort on unrecognized string otherwise. */ + $$ = make_operator ("delete ", 1); + } | OPERATOR NEW '[' ']' - { $$ = make_operator ("new[]", 3); } + { + /* Match the whitespacing of cplus_demangle_operators. + It would abort on unrecognized string otherwise. */ + $$ = make_operator ("new[]", 3); + } | OPERATOR DELETE '[' ']' - { $$ = make_operator ("delete[] ", 1); } + { + /* Match the whitespacing of cplus_demangle_operators. + It would abort on unrecognized string otherwise. */ + $$ = make_operator ("delete[] ", 1); + } | OPERATOR '+' { $$ = make_operator ("+", 2); } | OPERATOR '-' @@ -1183,7 +1199,11 @@ exp : FLOAT ; exp : SIZEOF '(' type ')' %prec UNARY - { $$ = d_unary ("sizeof", $3); } + { + /* Match the whitespacing of cplus_demangle_operators. + It would abort on unrecognized string otherwise. */ + $$ = d_unary ("sizeof ", $3); + } ; /* C++. */ diff --git a/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.S b/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.S new file mode 100644 index 0000000..2d1c7c3 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.S @@ -0,0 +1,146 @@ +/* Copyright 2012 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + + .text + .globl main +main: .byte 0 +.Lmain_end: + .section .debug_info +debug_start: + .4byte debug_end - 1f /* Length of Compilation Unit Info */ +1: + .2byte 0x3 /* DWARF version number */ + .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ + .byte 0x4 /* Pointer Size (in bytes) */ + .uleb128 0x1 /* (DIE (0xb) DW_TAG_compile_unit) */ + .ascii "GNU C 4.4.3\0" /* DW_AT_producer */ + .byte 0x4 /* DW_AT_language = DW_LANG_C_plus_plus */ + .ascii "1.c\0" /* DW_AT_name */ + .4byte main /* DW_AT_low_pc */ + .4byte .Lmain_end /* DW_AT_high_pc */ + .uleb128 0x4 /* (DIE (0x3c) DW_TAG_subprogram) */ + .ascii "f\0" /* DW_AT_name */ +/* Value 0 would require has_section_at_zero != 0 (which is true, though). */ + .4byte main /* DW_AT_low_pc */ + .4byte .Lmain_end /* DW_AT_high_pc */ + .byte 0x1 /* DW_AT_prototyped */ + + .uleb128 0x5 /* (DIE (0x42) DW_TAG_formal_parameter) */ + .4byte .Ltype_sizeof - debug_start /* DW_AT_type */ + .ascii "param_sizeof\0" /* DW_AT_name */ + + .uleb128 0x5 /* (DIE (0x42) DW_TAG_formal_parameter) */ + .4byte .Ltype_opnew - debug_start /* DW_AT_type */ + .ascii "param_opnew\0" /* DW_AT_name */ + + .uleb128 0x5 /* (DIE (0x42) DW_TAG_formal_parameter) */ + .4byte .Ltype_opdelete - debug_start /* DW_AT_type */ + .ascii "param_opdelete\0" /* DW_AT_name */ + + .uleb128 0x5 /* (DIE (0x42) DW_TAG_formal_parameter) */ + .4byte .Ltype_opnewarray - debug_start /* DW_AT_type */ + .ascii "param_opnewarray\0" /* DW_AT_name */ + + .uleb128 0x5 /* (DIE (0x42) DW_TAG_formal_parameter) */ + .4byte .Ltype_opdeletearray - debug_start /* DW_AT_type */ + .ascii "param_opdeletearray\0" /* DW_AT_name */ + .byte 0x0 /* end of children of DIE 0x3c */ + +.Ltype_sizeof: + .uleb128 3 /* Abbrev: DW_TAG_base_type */ + .ascii "typename<sizeof(int)>\0" /* DW_AT_name */ + .byte 4 /* DW_AT_byte_size */ + .byte 5 /* DW_AT_encoding */ + +.Ltype_opnew: + .uleb128 3 /* Abbrev: DW_TAG_base_type */ + .ascii "C::operator new(int)\0" /* DW_AT_name */ + .byte 4 /* DW_AT_byte_size */ + .byte 5 /* DW_AT_encoding */ + +.Ltype_opdelete: + .uleb128 3 /* Abbrev: DW_TAG_base_type */ + .ascii "C::operator delete(void *)\0" /* DW_AT_name */ + .byte 4 /* DW_AT_byte_size */ + .byte 5 /* DW_AT_encoding */ + +.Ltype_opnewarray: + .uleb128 3 /* Abbrev: DW_TAG_base_type */ + /* The correct new[] syntax is probably unsupported by GDB. */ + .ascii "C::operator new[](int)\0" /* DW_AT_name */ + .byte 4 /* DW_AT_byte_size */ + .byte 5 /* DW_AT_encoding */ + +.Ltype_opdeletearray: + .uleb128 3 /* Abbrev: DW_TAG_base_type */ + /* The correct delete[] syntax is probably unsupported by GDB. */ + .ascii "C::operator delete[](void *)\0" /* DW_AT_name */ + .byte 4 /* DW_AT_byte_size */ + .byte 5 /* DW_AT_encoding */ + + .byte 0x0 /* end of children of DIE 0xb */ +debug_end: + + .section .debug_abbrev +.Ldebug_abbrev0: + .uleb128 0x1 /* (abbrev code) */ + .uleb128 0x11 /* (TAG: DW_TAG_compile_unit) */ + .byte 0x1 /* DW_children_yes */ + .uleb128 0x25 /* (DW_AT_producer) */ + .uleb128 0x8 /* (DW_FORM_string) */ + .uleb128 0x13 /* (DW_AT_language) */ + .uleb128 0xb /* (DW_FORM_data1) */ + .uleb128 0x3 /* (DW_AT_name) */ + .uleb128 0x8 /* (DW_FORM_string) */ + .uleb128 0x11 /* (DW_AT_low_pc) */ + .uleb128 0x1 /* (DW_FORM_addr) */ + .uleb128 0x12 /* (DW_AT_high_pc) */ + .uleb128 0x1 /* (DW_FORM_addr) */ + .byte 0x0 + .byte 0x0 + .uleb128 3 /* Abbrev code */ + .uleb128 0x24 /* DW_TAG_base_type */ + .byte 0 /* has_children */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0xb /* DW_AT_byte_size */ + .uleb128 0xb /* DW_FORM_data1 */ + .uleb128 0x3e /* DW_AT_encoding */ + .uleb128 0xb /* DW_FORM_data1 */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + .uleb128 0x4 /* (abbrev code) */ + .uleb128 0x2e /* (TAG: DW_TAG_subprogram) */ + .byte 0x1 /* DW_children_yes */ + .uleb128 0x3 /* (DW_AT_name) */ + .uleb128 0x8 /* (DW_FORM_string) */ + .uleb128 0x11 /* (DW_AT_low_pc) */ + .uleb128 0x1 /* (DW_FORM_addr) */ + .uleb128 0x12 /* (DW_AT_high_pc) */ + .uleb128 0x1 /* (DW_FORM_addr) */ + .uleb128 0x27 /* (DW_AT_prototyped) */ + .uleb128 0xc /* (DW_FORM_flag) */ + .byte 0x0 + .byte 0x0 + .uleb128 0x5 /* (abbrev code) */ + .uleb128 0x5 /* (TAG: DW_TAG_formal_parameter) */ + .byte 0x0 /* DW_children_no */ + .uleb128 0x49 /* (DW_AT_type) */ + .uleb128 0x13 /* (DW_FORM_ref4) */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .byte 0x0 + .byte 0x0 + .byte 0x0 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.exp new file mode 100644 index 0000000..91d718e --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.exp @@ -0,0 +1,30 @@ +# Copyright 2012 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +load_lib dwarf.exp + +# This test can only be run on targets which support DWARF-2 and use gas. +if {![dwarf2_support]} { + return 0 +} + +standard_testfile .S +set executable ${testfile} + +if [prepare_for_testing $testfile.exp $testfile $srcfile {nodebug}] { + return -1 +} + +# The correct new[] and delete[] syntax is probably unsupported by GDB. +gdb_test "ptype f" {type = void \(typename<sizeof \(int\)>, C::operator new\(int\), C::operator delete\(void\*\), C::operator new\[\]\(int\), C::operator delete\[\]\(void\*\)\)} diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 0b4c679..8715c5e 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1277,6 +1277,11 @@ proc gdb_file_cmd { arg } { perror "($arg) No such file or directory" return -1 } + -re "A problem internal to GDB has been detected" { + fail "($arg) GDB internal error" + gdb_internal_error_resync + return -1 + } -re "$gdb_prompt $" { perror "couldn't load $arg into $GDB." return -1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Fix internal error on canonicalization of clang types (+lib/gdb.exp internal error catch) 2012-09-17 16:13 ` Jan Kratochvil @ 2012-09-17 19:52 ` Tom Tromey 2012-09-21 19:36 ` Jan Kratochvil 0 siblings, 1 reply; 11+ messages in thread From: Tom Tromey @ 2012-09-17 19:52 UTC (permalink / raw) To: Jan Kratochvil; +Cc: Doug Evans, Vasyl Vavrychuk, gdb-patches >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes: Jan> | OPERATOR DELETE Jan> - { $$ = make_operator ("delete ", 1); } Jan> + { Jan> + /* Match the whitespacing of cplus_demangle_operators. Jan> + It would abort on unrecognized string otherwise. */ The indentation here (and elsewhere) seems funny. Jan> +set executable ${testfile} This line shouldn't be needed. I think the rest is fine though. Tom ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Fix internal error on canonicalization of clang types (+lib/gdb.exp internal error catch) 2012-09-17 19:52 ` Tom Tromey @ 2012-09-21 19:36 ` Jan Kratochvil 2012-09-21 19:40 ` Tom Tromey 0 siblings, 1 reply; 11+ messages in thread From: Jan Kratochvil @ 2012-09-21 19:36 UTC (permalink / raw) To: Tom Tromey; +Cc: Doug Evans, Vasyl Vavrychuk, gdb-patches On Mon, 17 Sep 2012 21:52:08 +0200, Tom Tromey wrote: > >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes: > > Jan> | OPERATOR DELETE > Jan> - { $$ = make_operator ("delete ", 1); } > Jan> + { > Jan> + /* Match the whitespacing of cplus_demangle_operators. > Jan> + It would abort on unrecognized string otherwise. */ > > The indentation here (and elsewhere) seems funny. Sorry but I do not understand if it was a request for a change (and which change) or not. Thanks, Jan ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Fix internal error on canonicalization of clang types (+lib/gdb.exp internal error catch) 2012-09-21 19:36 ` Jan Kratochvil @ 2012-09-21 19:40 ` Tom Tromey 2012-09-21 19:52 ` Jan Kratochvil 0 siblings, 1 reply; 11+ messages in thread From: Tom Tromey @ 2012-09-21 19:40 UTC (permalink / raw) To: Jan Kratochvil; +Cc: Doug Evans, Vasyl Vavrychuk, gdb-patches >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes: Jan> - { $$ = make_operator ("delete ", 1); } Jan> + { Jan> + /* Match the whitespacing of cplus_demangle_operators. Jan> + It would abort on unrecognized string otherwise. */ >> >> The indentation here (and elsewhere) seems funny. Jan> Sorry but I do not understand if it was a request for a change (and which Jan> change) or not. At least from the patch it appears that the comment is over by the leftmost column, but I think the comment should be indented like the code is. Tom ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Fix internal error on canonicalization of clang types (+lib/gdb.exp internal error catch) 2012-09-21 19:40 ` Tom Tromey @ 2012-09-21 19:52 ` Jan Kratochvil 2012-09-21 19:57 ` Tom Tromey 0 siblings, 1 reply; 11+ messages in thread From: Jan Kratochvil @ 2012-09-21 19:52 UTC (permalink / raw) To: Tom Tromey; +Cc: Doug Evans, Vasyl Vavrychuk, gdb-patches On Fri, 21 Sep 2012 21:39:54 +0200, Tom Tromey wrote: > At least from the patch it appears that the comment is over by the > leftmost column, but I think the comment should be indented like the > code is. This is after patch from the mail, grep -3 xxx | expand, inserted into this mail. I see it has 81 columns but with the large tabs there this file has very common violation of > 80 columns; I can fix this patch, though. Thanks, Jan ------------------------------------------------------------------------------ operator : OPERATOR NEW { /* Match the whitespacing of cplus_demangle_operators. It would abort on unrecognized string otherwise. */ $$ = make_operator ("new", 3); } | OPERATOR DELETE { /* Match the whitespacing of cplus_demangle_operators. It would abort on unrecognized string otherwise. */ $$ = make_operator ("delete ", 1); } | OPERATOR NEW '[' ']' { /* Match the whitespacing of cplus_demangle_operators. It would abort on unrecognized string otherwise. */ $$ = make_operator ("new[]", 3); } | OPERATOR DELETE '[' ']' { /* Match the whitespacing of cplus_demangle_operators. It would abort on unrecognized string otherwise. */ $$ = make_operator ("delete[] ", 1); } -- exp : SIZEOF '(' type ')' %prec UNARY { /* Match the whitespacing of cplus_demangle_operators. It would abort on unrecognized string otherwise. */ $$ = d_unary ("sizeof ", $3); } ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Fix internal error on canonicalization of clang types (+lib/gdb.exp internal error catch) 2012-09-21 19:52 ` Jan Kratochvil @ 2012-09-21 19:57 ` Tom Tromey 2012-09-21 20:01 ` [commit] " Jan Kratochvil 0 siblings, 1 reply; 11+ messages in thread From: Tom Tromey @ 2012-09-21 19:57 UTC (permalink / raw) To: Jan Kratochvil; +Cc: Doug Evans, Vasyl Vavrychuk, gdb-patches Jan> This is after patch from the mail, grep -3 xxx | expand, inserted into this Jan> mail. Thanks, it looks ok now. Tom ^ permalink raw reply [flat|nested] 11+ messages in thread
* [commit] [patch] Fix internal error on canonicalization of clang types (+lib/gdb.exp internal error catch) 2012-09-21 19:57 ` Tom Tromey @ 2012-09-21 20:01 ` Jan Kratochvil 0 siblings, 0 replies; 11+ messages in thread From: Jan Kratochvil @ 2012-09-21 20:01 UTC (permalink / raw) To: Tom Tromey; +Cc: Doug Evans, Vasyl Vavrychuk, gdb-patches On Fri, 21 Sep 2012 21:56:56 +0200, Tom Tromey wrote: > Jan> This is after patch from the mail, grep -3 xxx | expand, inserted into this > Jan> mail. > > Thanks, it looks ok now. Checked in: http://sourceware.org/ml/gdb-cvs/2012-09/msg00124.html Thanks, Jan ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-09-21 20:01 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CAGj4m+4au-jiC2ueSyC+wEY76YRQ5zNuxfY+-mfZ39N4fnpN_g@mail.gmail.com>
[not found] ` <20120916080035.GA28890@host2.jankratochvil.net>
[not found] ` <CAGj4m+46oBXSYQ-wx9g-P7yevZeMDnNNEjvADE8sRSdoWaRiVA@mail.gmail.com>
2012-09-17 6:27 ` [patch] Fix internal error on canonicalization of clang types [Re: why in cplus_demangle_operators operation sizeof is expected to be followed with space] Jan Kratochvil
2012-09-17 8:29 ` Vasyl Vavrychuk
2012-09-17 15:30 ` [patch] Fix internal error on canonicalization of clang types (+lib/gdb.exp internal error catch) Jan Kratochvil
2012-09-17 15:40 ` Doug Evans
2012-09-17 16:13 ` Jan Kratochvil
2012-09-17 19:52 ` Tom Tromey
2012-09-21 19:36 ` Jan Kratochvil
2012-09-21 19:40 ` Tom Tromey
2012-09-21 19:52 ` Jan Kratochvil
2012-09-21 19:57 ` Tom Tromey
2012-09-21 20:01 ` [commit] " Jan Kratochvil
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox