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]

Vasyl Vavrychuk
2012-09-17T08:29:23Z

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++. */