ibuclaw / gdb

Fork of GDB with D-related fixes.
GNU General Public License v2.0
16 stars 4 forks source link

d-demangle: add support for back references and other grammar changes #8

Closed rainers closed 4 years ago

rainers commented 6 years ago

This didn't turn out as easy as I hoped...

When running the original d-demangle.c on the 127177 symbols of the phobos unittest map file without back references (as of dmd 2.076), I got 420 symbols where demangling failed (disregarding the TyeInfo symbols). This version reduces that number to 69.

On a current phobos unittest build, it fails to demangle 267 of 140653 symbols, about 120k of them with back references. core.demangle fails on 32.

I've added most of the back reference tests from core.demangle to the test suite, but 2 still failed.

ibuclaw commented 6 years ago

😱

OK, you were quicker than me to get the bulk of this done (I only got as far as adding a state parameter that's passed around everywhere).

Question, how would you like to contribute this upstream? You have two choices, please read the link below and let me know.

https://gcc.gnu.org/contribute.html

rainers commented 6 years ago

Question, how would you like to contribute this upstream? You have two choices, please read the link below and let me know.

Whatever is simpler. I suspect that it's the "copyright disclaimer" but I didn't find any information other than "The copyright disclaimer form is different than an employer disclaimer form." Is it good enough to have it somewhere in the patch?

rainers commented 6 years ago

BTW: I just ran it through gcc 7.3 and noticed a missing forward declaration. I suspect older/stricter compilers might also complain about other stuff. Do you know what's the mimum version that should be able to compile this?

ibuclaw commented 6 years ago

This is supposed to be compilable by some fairly old compilers, I couldn't give a precise version but there is one build server running Solaris 2.4 if I recall right.

ibuclaw commented 6 years ago

Whatever is simpler. I suspect that it's the "copyright disclaimer"

You mean you would prefer to put this change in the public domain?

It's probably best to email me so I can send the relevant information.

rainers commented 5 years ago

@ibuclaw Hi. With all the stuff you are doing for gcc integration, is this still on your radar? Paper work has been completed last year.

ibuclaw commented 5 years ago

@rainers, gcc-9 is now branched. This'll definitely need to be addressed before gcc-10, with stage1 now being open again.

thinkingerrol commented 5 years ago

I find this PR super valuable. Tested the demangling on one of our non-trivial projects, and this version is better than the latest release, GDB 8.3. Even though the latter provides nice colorful output, "when the program's wrong and the debug's on" it is much more important to not be distracted by mangled symbols. Thanks for this work and I'm looking forward to the merge. Please post here a link if there is another PR based on a newer GDB. Cheers!

John-Colvin commented 5 years ago

Is there any progress on this?

Will it be in gcc 10?

ibuclaw commented 4 years ago

@John-Colvin - If you hear nothing before the end of the week, send reminders until I say patch posted (with evidence).

Have you been applying this patch locally yourself?

ibuclaw commented 4 years ago

Quite a few bits of the testsuite fail, so it's not exactly a clean patch...

rainers commented 4 years ago

Quite a few bits of the testsuite fail, so it's not exactly a clean patch...

What failures do you mean? I just tried d-demangle-expected and test-demangle passes on it.

ibuclaw commented 4 years ago

I rebased it on master, there are a few new tests that this regresses on. Some are ambiguous symbols, others expect type modifiers to be added to symbols but they aren't present.

I've rebased, stepped through and fixed these up, also fixed the failures of other back reference symbol tests in core.demangle.

ibuclaw commented 4 years ago

Running this branch without any modifications.

./test-demangle < ../../../libiberty/testsuite/d-demangle-expected
FAIL at line 890, options --format=dlang:
in:  _D8demangle4testMxFZv
out: demangle.test()
exp: demangle.test() const
FAIL at line 894, options --format=dlang:
in:  _D8demangle4testMyFZv
out: demangle.test()
exp: demangle.test() immutable
FAIL at line 898, options --format=dlang:
in:  _D8demangle4testMNgFZv
out: demangle.test()
exp: demangle.test() inout
FAIL at line 902, options --format=dlang:
in:  _D8demangle4testMNgxFZv
out: demangle.test()
exp: demangle.test() inout const
FAIL at line 906, options --format=dlang:
in:  _D8demangle4testMOFZv
out: demangle.test()
exp: demangle.test() shared
FAIL at line 910, options --format=dlang:
in:  _D8demangle4testMOxFZv
out: demangle.test()
exp: demangle.test() shared const
FAIL at line 914, options --format=dlang:
in:  _D8demangle4testMONgFZv
out: demangle.test()
exp: demangle.test() shared inout
FAIL at line 918, options --format=dlang:
in:  _D8demangle4testMONgxFZv
out: demangle.test()
exp: demangle.test() shared inout const
FAIL at line 1300, options :
in:  --format=dlang
out: (null)
exp: _D4core4stdc5errnoQgFZi
FAIL at line 1304: unknown demangling style core.stdc.errno.errno()
FAIL at line 1308: unknown demangling style test(structname, structname)
FAIL at line 1312: unknown demangling style std.parallelism.Task!(unittest.cmp, immutable(char)[], immutable(char)[]).Task.~this()
FAIL at line 1316: unknown demangling style testexpansion.s!(testexpansion.s!(int).s(int).Result).s(testexpansion.s!(int).s(int).Result).Result.foo()
FAIL at line 1320: unknown demangling style testexpansion.s!(testexpansion.s!(int).s(int).Result).s(testexpansion.s!(int).s(int).Result).Result.foo()
FAIL at line 1324: unknown demangling style std.conv.enumRep!(immutable(char[]), std.experimental.allocator.building_blocks.stats_collector.Options, 64).enumRep
FAIL at line 1328: unknown demangling style std.experimental.allocator.common.reallocate!(std.experimental.allocator.building_blocks.kernighan_ritchie.KRRegion!(std.experimental.allocator.building_blocks.null_allocator.NullAllocator).KRRegion).reallocate(ref std.experimental.allocator.building_blocks.kernighan_ritchie.KRRegion!(std.experimental.allocator.building_blocks.null_allocator.NullAllocator).KRRegion, ref void[], ulong)
FAIL at line 1332: unknown demangling style std.exception.doesPointTo!(std.regex.internal.ir.NamedGroup[], std.regex.internal.ir.NamedGroup[], void).doesPointTo(ref const(std.regex.internal.ir.NamedGroup[]), ref const(std.regex.internal.ir.NamedGroup[]))
FAIL at line 1336: unknown demangling style std.algorithm.iteration.SplitterResult!(std.uni.isWhite(dchar), immutable(char)[]).SplitterResult.__xtoHash(ref const(std.algorithm.iteration.SplitterResult!(std.uni.isWhite, immutable(char)[]).SplitterResult))
FAIL at line 1340: unknown demangling style std.typecons.Typedef!(std.typecons.__unittestL6513_208().MyClass, null, null).Typedef.this(std.typecons.__unittestL6513_208().MyClass)
FAIL at line 1344: unknown demangling style std.regex.internal.kickstart.ShiftOr!(char).ShiftOr.ShiftThread.set!(std.regex.internal.kickstart.ShiftOr!(char).ShiftOr.ShiftThread.setInvMask(uint, uint)).set(dchar)
FAIL at line 1347: unknown demangling style std.stdio.File.lockImpl!(LockFileEx, immutable(uint)).lockImpl(ulong, ulong, immutable(uint))
./test-demangle: 333 tests, 21 failures
ibuclaw commented 4 years ago

After rebasing branch:

./test-demangle < ../../../libiberty/testsuite/d-demangle-expected
FAIL at line 890, options --format=dlang:
in:  _D8demangle13__T4testTFZaZ6mangleFZv
out: demangle.test!(char() ).mangle()
exp: demangle.test!(char() function).mangle()
FAIL at line 894, options --format=dlang:
in:  _D8demangle4testMxFZv
out: demangle.test()
exp: demangle.test() const
FAIL at line 898, options --format=dlang:
in:  _D8demangle4testMyFZv
out: demangle.test()
exp: demangle.test() immutable
FAIL at line 902, options --format=dlang:
in:  _D8demangle4testMNgFZv
out: demangle.test()
exp: demangle.test() inout
FAIL at line 906, options --format=dlang:
in:  _D8demangle4testMNgxFZv
out: demangle.test()
exp: demangle.test() inout const
FAIL at line 910, options --format=dlang:
in:  _D8demangle4testMOFZv
out: demangle.test()
exp: demangle.test() shared
FAIL at line 914, options --format=dlang:
in:  _D8demangle4testMOxFZv
out: demangle.test()
exp: demangle.test() shared const
FAIL at line 918, options --format=dlang:
in:  _D8demangle4testMONgFZv
out: demangle.test()
exp: demangle.test() shared inout
FAIL at line 922, options --format=dlang:
in:  _D8demangle4testMONgxFZv
out: demangle.test()
exp: demangle.test() shared inout const
FAIL at line 1256, options --format=dlang:
in:  _D8demangle32__T2fnTS3symVS3valS1a4_6e756c6cZ3fun13__T8positionZ13__T8confusesZ8demangleFDFxaZvZv
out: (null)
exp: demangle.fn!(sym, val("null")).fun.position!().confuses!().demangle(void(const(char)) delegate)
FAIL at line 1308, options --format=dlang:
in:  _D4core8demangle16__T6mangleTFZPvZ6mangleFNaNbNfAxaAaZ11DotSplitter5emptyMxFNaNbNdNiNfZb
out: core.demangle.mangle!(void*() ).mangle(const(char)[], char[]).DotSplitter.empty()
exp: core.demangle.mangle!(void*() function).mangle(const(char)[], char[]).DotSplitter.empty() const
FAIL at line 1332, options :
in:  --format=dlang
out: (null)
exp: _D4core4stdc5errnoQgFZi
FAIL at line 1336: unknown demangling style core.stdc.errno.errno()
FAIL at line 1340: unknown demangling style test(structname, structname)
FAIL at line 1344: unknown demangling style std.parallelism.Task!(unittest.cmp, immutable(char)[], immutable(char)[]).Task.~this()
FAIL at line 1348: unknown demangling style testexpansion.s!(testexpansion.s!(int).s(int).Result).s(testexpansion.s!(int).s(int).Result).Result.foo()
FAIL at line 1352: unknown demangling style testexpansion.s!(testexpansion.s!(int).s(int).Result).s(testexpansion.s!(int).s(int).Result).Result.foo()
FAIL at line 1356: unknown demangling style std.conv.enumRep!(immutable(char[]), std.experimental.allocator.building_blocks.stats_collector.Options, 64).enumRep
FAIL at line 1360: unknown demangling style std.experimental.allocator.common.reallocate!(std.experimental.allocator.building_blocks.kernighan_ritchie.KRRegion!(std.experimental.allocator.building_blocks.null_allocator.NullAllocator).KRRegion).reallocate(ref std.experimental.allocator.building_blocks.kernighan_ritchie.KRRegion!(std.experimental.allocator.building_blocks.null_allocator.NullAllocator).KRRegion, ref void[], ulong)
FAIL at line 1364: unknown demangling style std.exception.doesPointTo!(std.regex.internal.ir.NamedGroup[], std.regex.internal.ir.NamedGroup[], void).doesPointTo(ref const(std.regex.internal.ir.NamedGroup[]), ref const(std.regex.internal.ir.NamedGroup[]))
FAIL at line 1368: unknown demangling style std.algorithm.iteration.SplitterResult!(std.uni.isWhite(dchar), immutable(char)[]).SplitterResult.__xtoHash(ref const(std.algorithm.iteration.SplitterResult!(std.uni.isWhite, immutable(char)[]).SplitterResult))
FAIL at line 1372: unknown demangling style std.typecons.Typedef!(std.typecons.__unittestL6513_208().MyClass, null, null).Typedef.this(std.typecons.__unittestL6513_208().MyClass)
FAIL at line 1376: unknown demangling style std.regex.internal.kickstart.ShiftOr!(char).ShiftOr.ShiftThread.set!(std.regex.internal.kickstart.ShiftOr!(char).ShiftOr.ShiftThread.setInvMask(uint, uint)).set(dchar)
FAIL at line 1379: unknown demangling style std.stdio.File.lockImpl!(LockFileEx, immutable(uint)).lockImpl(ulong, ulong, immutable(uint))
./test-demangle: 341 tests, 24 failures
ibuclaw commented 4 years ago

After some stylist clean-ups from rebase, and added more tests.

./test-demangle < ../../../libiberty/testsuite/d-demangle-expected
FAIL at line 890, options --format=dlang:
in:  _D8demangle13__T4testTFZaZ6mangleFZv
out: demangle.test!(char() ).mangle()
exp: demangle.test!(char() function).mangle()
FAIL at line 894, options --format=dlang:
in:  _D8demangle4testMxFZv
out: demangle.test()
exp: demangle.test() const
FAIL at line 898, options --format=dlang:
in:  _D8demangle4testMyFZv
out: demangle.test()
exp: demangle.test() immutable
FAIL at line 902, options --format=dlang:
in:  _D8demangle4testMNgFZv
out: demangle.test()
exp: demangle.test() inout
FAIL at line 906, options --format=dlang:
in:  _D8demangle4testMNgxFZv
out: demangle.test()
exp: demangle.test() inout const
FAIL at line 910, options --format=dlang:
in:  _D8demangle4testMOFZv
out: demangle.test()
exp: demangle.test() shared
FAIL at line 914, options --format=dlang:
in:  _D8demangle4testMOxFZv
out: demangle.test()
exp: demangle.test() shared const
FAIL at line 918, options --format=dlang:
in:  _D8demangle4testMONgFZv
out: demangle.test()
exp: demangle.test() shared inout
FAIL at line 922, options --format=dlang:
in:  _D8demangle4testMONgxFZv
out: demangle.test()
exp: demangle.test() shared inout const
FAIL at line 1256, options --format=dlang:
in:  _D8demangle32__T2fnTS3symVS3valS1a4_6e756c6cZ3fun13__T8positionZ13__T8confusesZ8demangleFDFxaZvZv
out: (null)
exp: demangle.fn!(sym, val("null")).fun.position!().confuses!().demangle(void(const(char)) delegate)
FAIL at line 1308, options --format=dlang:
in:  _D4core8demangle16__T6mangleTFZPvZ6mangleFNaNbNfAxaAaZ11DotSplitter5emptyMxFNaNbNdNiNfZb
out: core.demangle.mangle!(void*() ).mangle(const(char)[], char[]).DotSplitter.empty()
exp: core.demangle.mangle!(void*() function).mangle(const(char)[], char[]).DotSplitter.empty() const
FAIL at line 1332, options --format=dlang:
in:  _D3std5range15__T4iotaTtTtTtZ4iotaFtttZ6Result7opIndexMNgFNaNbNiNfmZNgt
out: std.range.iota!(ushort, ushort, ushort).iota(ushort, ushort, ushort).Result.opIndex(ulong)
exp: std.range.iota!(ushort, ushort, ushort).iota(ushort, ushort, ushort).Result.opIndex(ulong) inout
FAIL at line 1384, options --format=dlang:
in:  _D3std6getopt__TQkTAyaTDFNaNbNiNfQoZvTQtTDQsZQBnFNfKAQBiQBlQBkQBrQyZSQCpQCo12GetoptResult
out: (null)
exp: std.getopt.getopt!(immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate, immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate).getopt(ref immutable(char)[][], immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate, immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate)
FAIL at line 1396, options --format=dlang:
in:  _D3std9algorithm9iteration__T12FilterResultSQBq8typecons__T5TupleTiVAyaa1_61TiVQla1_62TiVQva1_63ZQBm__T6renameVHiQBtA2i0a1_63i2a1_61ZQBeMFNcZ9__lambda1TAiZQEw9__xtoHashFNbNeKxSQGsQGrQGk__TQGdSQHiQFs__TQFmTiVQFja1_61TiVQFua1_62TiVQGfa1_63ZQGx__TQFlVQFhA2i0a1_63i2a1_61ZQGjMFNcZQFfTQEyZQJvZm
out: (null)
exp: std.algorithm.iteration.FilterResult!(std.typecons.Tuple!(int, "a", int, "b", int, "c").Tuple.rename!([0:"c", 2:"a"]).rename().__lambda1, int[]).FilterResult.__xtoHash(ref const(std.algorithm.iteration.FilterResult!(std.typecons.Tuple!(int, "a", int, "b", int, "c").Tuple.rename!([0:"c", 2:"a"]).rename().__lambda1, int[]).FilterResult))
./test-demangle: 346 tests, 14 failures
ibuclaw commented 4 years ago

After re-adding the printing of tpye modifiers.

./test-demangle < ../../../libiberty/testsuite/d-demangle-expected
FAIL at line 890, options --format=dlang:
in:  _D8demangle13__T4testTFZaZ6mangleFZv
out: demangle.test!(char() ).mangle()
exp: demangle.test!(char() function).mangle()
FAIL at line 1256, options --format=dlang:
in:  _D8demangle32__T2fnTS3symVS3valS1a4_6e756c6cZ3fun13__T8positionZ13__T8confusesZ8demangleFDFxaZvZv
out: (null)
exp: demangle.fn!(sym, val("null")).fun.position!().confuses!().demangle(void(const(char)) delegate)
FAIL at line 1308, options --format=dlang:
in:  _D4core8demangle16__T6mangleTFZPvZ6mangleFNaNbNfAxaAaZ11DotSplitter5emptyMxFNaNbNdNiNfZb
out: core.demangle.mangle!(void*() ).mangle(const(char)[], char[]).DotSplitter.empty() const
exp: core.demangle.mangle!(void*() function).mangle(const(char)[], char[]).DotSplitter.empty() const
FAIL at line 1384, options --format=dlang:
in:  _D3std6getopt__TQkTAyaTDFNaNbNiNfQoZvTQtTDQsZQBnFNfKAQBiQBlQBkQBrQyZSQCpQCo12GetoptResult
out: (null)
exp: std.getopt.getopt!(immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate, immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate).getopt(ref immutable(char)[][], immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate, immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate)
FAIL at line 1396, options --format=dlang:
in:  _D3std9algorithm9iteration__T12FilterResultSQBq8typecons__T5TupleTiVAyaa1_61TiVQla1_62TiVQva1_63ZQBm__T6renameVHiQBtA2i0a1_63i2a1_61ZQBeMFNcZ9__lambda1TAiZQEw9__xtoHashFNbNeKxSQGsQGrQGk__TQGdSQHiQFs__TQFmTiVQFja1_61TiVQFua1_62TiVQGfa1_63ZQGx__TQFlVQFhA2i0a1_63i2a1_61ZQGjMFNcZQFfTQEyZQJvZm
out: (null)
exp: std.algorithm.iteration.FilterResult!(std.typecons.Tuple!(int, "a", int, "b", int, "c").Tuple.rename!([0:"c", 2:"a"]).rename().__lambda1, int[]).FilterResult.__xtoHash(ref const(std.algorithm.iteration.FilterResult!(std.typecons.Tuple!(int, "a", int, "b", int, "c").Tuple.rename!([0:"c", 2:"a"]).rename().__lambda1, int[]).FilterResult))
./test-demangle: 346 tests, 5 failures
ibuclaw commented 4 years ago

After a little refactor of the dlang_*_backref functions (nothing actually fixed, just commonizes type and symbol back reference handling).

./test-demangle < ../../../libiberty/testsuite/d-demangle-expected
FAIL at line 890, options --format=dlang:
in:  _D8demangle13__T4testTFZaZ6mangleFZv
out: demangle.test!(char() ).mangle()
exp: demangle.test!(char() function).mangle()
FAIL at line 1256, options --format=dlang:
in:  _D8demangle32__T2fnTS3symVS3valS1a4_6e756c6cZ3fun13__T8positionZ13__T8confusesZ8demangleFDFxaZvZv
out: (null)
exp: demangle.fn!(sym, val("null")).fun.position!().confuses!().demangle(void(const(char)) delegate)
FAIL at line 1308, options --format=dlang:
in:  _D4core8demangle16__T6mangleTFZPvZ6mangleFNaNbNfAxaAaZ11DotSplitter5emptyMxFNaNbNdNiNfZb
out: core.demangle.mangle!(void*() ).mangle(const(char)[], char[]).DotSplitter.empty() const
exp: core.demangle.mangle!(void*() function).mangle(const(char)[], char[]).DotSplitter.empty() const
FAIL at line 1384, options --format=dlang:
in:  _D3std6getopt__TQkTAyaTDFNaNbNiNfQoZvTQtTDQsZQBnFNfKAQBiQBlQBkQBrQyZSQCpQCo12GetoptResult
out: (null)
exp: std.getopt.getopt!(immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate, immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate).getopt(ref immutable(char)[][], immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate, immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate)
FAIL at line 1396, options --format=dlang:
in:  _D3std9algorithm9iteration__T12FilterResultSQBq8typecons__T5TupleTiVAyaa1_61TiVQla1_62TiVQva1_63ZQBm__T6renameVHiQBtA2i0a1_63i2a1_61ZQBeMFNcZ9__lambda1TAiZQEw9__xtoHashFNbNeKxSQGsQGrQGk__TQGdSQHiQFs__TQFmTiVQFja1_61TiVQFua1_62TiVQGfa1_63ZQGx__TQFlVQFhA2i0a1_63i2a1_61ZQGjMFNcZQFfTQEyZQJvZm
out: (null)
exp: std.algorithm.iteration.FilterResult!(std.typecons.Tuple!(int, "a", int, "b", int, "c").Tuple.rename!([0:"c", 2:"a"]).rename().__lambda1, int[]).FilterResult.__xtoHash(ref const(std.algorithm.iteration.FilterResult!(std.typecons.Tuple!(int, "a", int, "b", int, "c").Tuple.rename!([0:"c", 2:"a"]).rename().__lambda1, int[]).FilterResult))
./test-demangle: 346 tests, 5 failures
ibuclaw commented 4 years ago

After removing dlang_type_nofunction and replacing all calls with dlang_type.

./test-demangle < ../../../libiberty/testsuite/d-demangle-expected
FAIL at line 1256, options --format=dlang:
in:  _D8demangle32__T2fnTS3symVS3valS1a4_6e756c6cZ3fun13__T8positionZ13__T8confusesZ8demangleFDFxaZvZv
out: (null)
exp: demangle.fn!(sym, val("null")).fun.position!().confuses!().demangle(void(const(char)) delegate)
FAIL at line 1384, options --format=dlang:
in:  _D3std6getopt__TQkTAyaTDFNaNbNiNfQoZvTQtTDQsZQBnFNfKAQBiQBlQBkQBrQyZSQCpQCo12GetoptResult
out: (null)
exp: std.getopt.getopt!(immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate, immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate).getopt(ref immutable(char)[][], immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate, immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate)
FAIL at line 1396, options --format=dlang:
in:  _D3std9algorithm9iteration__T12FilterResultSQBq8typecons__T5TupleTiVAyaa1_61TiVQla1_62TiVQva1_63ZQBm__T6renameVHiQBtA2i0a1_63i2a1_61ZQBeMFNcZ9__lambda1TAiZQEw9__xtoHashFNbNeKxSQGsQGrQGk__TQGdSQHiQFs__TQFmTiVQFja1_61TiVQFua1_62TiVQGfa1_63ZQGx__TQFlVQFhA2i0a1_63i2a1_61ZQGjMFNcZQFfTQEyZQJvZm
out: (null)
exp: std.algorithm.iteration.FilterResult!(std.typecons.Tuple!(int, "a", int, "b", int, "c").Tuple.rename!([0:"c", 2:"a"]).rename().__lambda1, int[]).FilterResult.__xtoHash(ref const(std.algorithm.iteration.FilterResult!(std.typecons.Tuple!(int, "a", int, "b", int, "c").Tuple.rename!([0:"c", 2:"a"]).rename().__lambda1, int[]).FilterResult))
./test-demangle: 346 tests, 3 failures
ibuclaw commented 4 years ago

After refactoring dlang_call_convention_p to not check for 'this' reference or modifiers (not a bug fix, but matches how things are done in upstream gcc).

./test-demangle < ../../../libiberty/testsuite/d-demangle-expected
FAIL at line 1256, options --format=dlang:
in:  _D8demangle32__T2fnTS3symVS3valS1a4_6e756c6cZ3fun13__T8positionZ13__T8confusesZ8demangleFDFxaZvZv
out: (null)
exp: demangle.fn!(sym, val("null")).fun.position!().confuses!().demangle(void(const(char)) delegate)
FAIL at line 1384, options --format=dlang:
in:  _D3std6getopt__TQkTAyaTDFNaNbNiNfQoZvTQtTDQsZQBnFNfKAQBiQBlQBkQBrQyZSQCpQCo12GetoptResult
out: (null)
exp: std.getopt.getopt!(immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate, immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate).getopt(ref immutable(char)[][], immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate, immutable(char)[], void(immutable(char)[]) pure nothrow @nogc @safe delegate)
FAIL at line 1396, options --format=dlang:
in:  _D3std9algorithm9iteration__T12FilterResultSQBq8typecons__T5TupleTiVAyaa1_61TiVQla1_62TiVQva1_63ZQBm__T6renameVHiQBtA2i0a1_63i2a1_61ZQBeMFNcZ9__lambda1TAiZQEw9__xtoHashFNbNeKxSQGsQGrQGk__TQGdSQHiQFs__TQFmTiVQFja1_61TiVQFua1_62TiVQGfa1_63ZQGx__TQFlVQFhA2i0a1_63i2a1_61ZQGjMFNcZQFfTQEyZQJvZm
out: (null)
exp: std.algorithm.iteration.FilterResult!(std.typecons.Tuple!(int, "a", int, "b", int, "c").Tuple.rename!([0:"c", 2:"a"]).rename().__lambda1, int[]).FilterResult.__xtoHash(ref const(std.algorithm.iteration.FilterResult!(std.typecons.Tuple!(int, "a", int, "b", int, "c").Tuple.rename!([0:"c", 2:"a"]).rename().__lambda1, int[]).FilterResult))
./test-demangle: 346 tests, 3 failures
ibuclaw commented 4 years ago

After fix for back references in delegate types (can there be back references in function types too @rainers ?)

./test-demangle < ../../../libiberty/testsuite/d-demangle-expected
FAIL at line 1256, options --format=dlang:
in:  _D8demangle32__T2fnTS3symVS3valS1a4_6e756c6cZ3fun13__T8positionZ13__T8confusesZ8demangleFDFxaZvZv
out: (null)
exp: demangle.fn!(sym, val("null")).fun.position!().confuses!().demangle(void(const(char)) delegate)
FAIL at line 1396, options --format=dlang:
in:  _D3std9algorithm9iteration__T12FilterResultSQBq8typecons__T5TupleTiVAyaa1_61TiVQla1_62TiVQva1_63ZQBm__T6renameVHiQBtA2i0a1_63i2a1_61ZQBeMFNcZ9__lambda1TAiZQEw9__xtoHashFNbNeKxSQGsQGrQGk__TQGdSQHiQFs__TQFmTiVQFja1_61TiVQFua1_62TiVQGfa1_63ZQGx__TQFlVQFhA2i0a1_63i2a1_61ZQGjMFNcZQFfTQEyZQJvZm
out: (null)
exp: std.algorithm.iteration.FilterResult!(std.typecons.Tuple!(int, "a", int, "b", int, "c").Tuple.rename!([0:"c", 2:"a"]).rename().__lambda1, int[]).FilterResult.__xtoHash(ref const(std.algorithm.iteration.FilterResult!(std.typecons.Tuple!(int, "a", int, "b", int, "c").Tuple.rename!([0:"c", 2:"a"]).rename().__lambda1, int[]).FilterResult))
./test-demangle: 346 tests, 2 failures
ibuclaw commented 4 years ago

After fix for handling back references in template value parameters.

./test-demangle < ../../../libiberty/testsuite/d-demangle-expected
FAIL at line 1256, options --format=dlang:
in:  _D8demangle32__T2fnTS3symVS3valS1a4_6e756c6cZ3fun13__T8positionZ13__T8confusesZ8demangleFDFxaZvZv
out: (null)
exp: demangle.fn!(sym, val("null")).fun.position!().confuses!().demangle(void(const(char)) delegate)
./test-demangle: 346 tests, 1 failures
ibuclaw commented 4 years ago

After reapplying an upstream fix that got removed by the original implementation of this patch.

./test-demangle < ../../../libiberty/testsuite/d-demangle-expected
./test-demangle: 346 tests, 0 failures
ibuclaw commented 4 years ago

Fixed a couple for format issues with the patch, I'll stop for now.

@rainers can you check the bits that have changed after your initial commits?

rainers commented 4 years ago

Great work @ibuclaw . LGTM but I'm a bit unsure about the removal of dlang_type_nofunction. IIRC there was some ambiguity, Did the removal of Pascal calling convention eliminate that? Wasn't there something similar with Objective-C?

ibuclaw commented 4 years ago

As I recall, I did away with special casing of pascal and did this check instead.

https://github.com/ibuclaw/gdb/commit/0c7ea22da6b72698c8b47c4910676b6d76d60b49

Actually, I think the upstream condition is stronger, where it reverts even if the next character is wrong, not just null or zero.

rainers commented 4 years ago

Regardless of the discussed ambiguity I think you can merge this as is and leave improvements for separate commits. As noted in the description, even core.demangle doesn't manage to decode all symbols,

John-Colvin commented 4 years ago

Am I doing something silly or does this branch not build due to TYPE_TAG_NAME not existing any more?

rainers commented 4 years ago

Am I doing something silly or does this branch not build due to TYPE_TAG_NAME not existing any more?

It seems TYPE_TAG_NAME has been removed and replaced by TYPE_NAME elsewhere.

ibuclaw commented 4 years ago

I don't expect this branch to build, a lot of the additions to it should either be abandoned or redeveloped from the top. I'm only taking the libiberty changes and applying them to gcc - later for syncing with gdb.

ibuclaw commented 4 years ago

Committed to upstream gcc.

John-Colvin commented 4 years ago

Just wanted to drop in here and say thanks, I just built upstream gdb and my horrendous stack overflow backtraces are now much more readable :smile:

nordlow commented 4 years ago

Just wanted to drop in here and say thanks, I just built upstream gdb and my horrendous stack overflow backtraces are now much more readable smile

Building gdb upstream master fails for me as described at https://stackoverflow.com/questions/63094586/cannot-build-gdb-master-jul-9-2020-on-ubuntu-20-04. Any clue what might be wrong?

thinkingerrol commented 4 years ago

Just wanted to drop in here and say thanks, I just built upstream gdb and my horrendous stack overflow backtraces are now much more readable smile

Building gdb upstream master fails for me as described at https://stackoverflow.com/questions/63094586/cannot-build-gdb-master-jul-9-2020-on-ubuntu-20-04. Any clue what might be wrong?

I've just tried it out on a clean virtualized Ubuntu 20.04 and answered your question: found no such inherent problem (not with current master, not with latest master from 2020-07-09), so it must be system-specific.