www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.debugger - GDB demangling

reply ANtlord <antlord92 gmail.com> writes:
Hello!

Short time ago I created a plugin that demangles D symbols in 
call stack. I'm gonna to add the code to upstream. After a little 
research mail lists and code of gdb I see a couple of mentions 
about demangling of D code. Also, I found threads in the forum 
about support of the demangling that was implemented by GDC team. 
But I see partially demangling when I'm debugging my favorite 
project DCD. Look at the call stack


_D7dsymbol6symbol7DSymbol__T17getFirstPartNamedTSQBvQBqQBmZQBfMNgFSQCn16string_interning14Interned
tringZPNgSQEdQDyQDu (this=, name={
   data = "*constructor*"
})
         at dsymbol/src/dsymbol/symbol.d:234

dsymbol.conversion.first.FirstPass.visit(const(dparse.ast.StructBody)) (this=,
structBody=)
         at dsymbol/src/dsymbol/conversion/first.d:401

_D6dparse3ast17StructDeclaration6acceptMxFCQBpQBl10ASTVisitorZv 
(this=, visitor=)
         at libdparse/src/dparse/ast.d-mixin-2757:2759

_D7dsymbol10conversion5first9FirstPass__T25visitAggregateDeclarationTxC6dparse3ast17StructDeclarationZQCjMFxQBmEQEg6symb
l14CompletionKindZv (this=, kind=115 's', dec=)
         at dsymbol/src/dsymbol/conversion/first.d:809

dsymbol.conversion.first.FirstPass.visit(const(dparse.ast.StructDeclaration))
(this=, dec=)
         at dsymbol/src/dsymbol/conversion/first.d:184

(this=, visitor=)
         at libdparse/src/dparse/ast.d:1244

dsymbol.conversion.first.FirstPass.visit(const(dparse.ast.Declaration)) (this=,
dec=)
         at dsymbol/src/dsymbol/conversion/first.d:315

visitor=)
         at libdparse/src/dparse/ast.d-mixin-2196:2198

dsymbol.conversion.first.FirstPass.visit(const(dparse.ast.Module)) (this=, mod=)
         at dsymbol/src/dsymbol/conversion/first.d:338

dsymbol/src/dsymbol/conversion/first.d:91

_D7dsymbol11modulecache11ModuleCache11cacheModuleMFAyaZPSQCd6symbol7DSymbol
(this=, location="/usr/include/dmd/phobos/etc/c/odbc/sqltypes.d")
         at dsymbol/src/dsymbol/modulecache.d:236

_D7dsymbol10conversion6second13resolveImportFPSQBt6symbol7DSymbolKS10containers12unrolledlist__T12UnrolledListTPSQEh11type_lookup10TypeLookupTS4stdx9allocator10mallocator10MallocatorVbi0Vmi64ZQDsKSQHn11module
ache11ModuleCacheZv (cache=, typeLookups=, acSymbol=)
         at dsymbol/src/dsymbol/conversion/second.d:142

_D7dsymbol10conversion6second10secondPassFPSQBq8semantic14SemanticSymbolPSQCu6scope_5ScopeKSQDm11module
ache11ModuleCacheZv (cache=, moduleScope=, currentSymbol=)
         at dsymbol/src/dsymbol/conversion/second.d:61

_D7dsymbol10conversion6second10secondPassFPSQBq8semantic14SemanticSymbolPSQCu6scope_5ScopeKSQDm11module
ache11ModuleCacheZv (cache=, moduleScope=, currentSymbol=)
         at dsymbol/src/dsymbol/conversion/second.d:77

_D7dsymbol11modulecache11ModuleCache11cacheModuleMFAyaZPSQCd6symbol7DSymbol
(this=, location="/usr/include/dmd/phobos/etc/c/odbc/sql.d")
         at dsymbol/src/dsymbol/modulecache.d:238

_D7dsymbol10conversion6second13resolveImportFPSQBt6symbol7DSymbolKS10containers12unrolledlist__T12UnrolledListTPSQEh11type_lookup10TypeLookupTS4stdx9allocator10mallocator10MallocatorVbi0Vmi64ZQDsKSQHn11module
ache11ModuleCacheZv (cache=, typeLookups=, acSymbol=)
         at dsymbol/src/dsymbol/conversion/second.d:142

_D7dsymbol10conversion6second10secondPassFPSQBq8semantic14SemanticSymbolPSQCu6scope_5ScopeKSQDm11module
ache11ModuleCacheZv (cache=, moduleScope=, currentSymbol=)
         at dsymbol/src/dsymbol/conversion/second.d:61

_D7dsymbol10conversion6second10secondPassFPSQBq8semantic14SemanticSymbolPSQCu6scope_5ScopeKSQDm11module
ache11ModuleCacheZv (cache=, moduleScope=, currentSymbol=)
         at dsymbol/src/dsymbol/conversion/second.d:77

_D7dsymbol11modulecache11ModuleCache11cacheModuleMFAyaZPSQCd6symbol7DSymbol
(this=, location="/usr/include/dmd/phobos/etc/c/odbc/sqlext.d")
         at dsymbol/src/dsymbol/modulecache.d:238

_D7dsymbol11modulecache11ModuleCache14addImportPathsMFxAAyaZ8scanFromMFxQqZv
(this=, root="/usr/include/dmd/phobos/etc/c/odbc")
         at dsymbol/src/dsymbol/modulecache.d:123

_D7dsymbol11modulecache11ModuleCache14addImportPathsMFxAAyaZ8scanFromMFxQqZv
(this=, root="/usr/include/dmd/phobos/etc/c")
         at dsymbol/src/dsymbol/modulecache.d:125

_D7dsymbol11modulecache11ModuleCache14addImportPathsMFxAAyaZ8scanFromMFxQqZv
(this=, root="/usr/include/dmd/phobos/etc")
         at dsymbol/src/dsymbol/modulecache.d:125

_D7dsymbol11modulecache11ModuleCache14addImportPathsMFxAAyaZ8scanFromMFxQqZv
(this=, root="/usr/include/dmd/phobos/")
         at dsymbol/src/dsymbol/modulecache.d:125

dsymbol.modulecache.ModuleCache.addImportPaths(const(immutable(char)[][]))
(this=, paths={[0] = "/usr/include/dmd/phobos/"})
         at dsymbol/src/dsymbol/modulecache.d:129

at src/dcd/server/main.d:167


You can see some readable messages like


dsymbol.modulecache.ModuleCache.addImportPaths(const(immutable(char)[][]))
(this=, paths={[0] = "/usr/include/dmd/phobos/"})

and some unreadable


_D7dsymbol11modulecache11ModuleCache14addImportPathsMFxAAyaZ8scanFromMFxQqZv
(this=, root="/usr/include/dmd/phobos/")

So please make me clear with the state of the demangling. Is it 
supported?
Dec 03 2018
parent reply Rainer Schuetze <r.sagitario gmx.de> writes:
On 03/12/2018 12:29, ANtlord wrote:
 You can see some readable messages like
 

 dsymbol.modulecache.ModuleCache.addImportPaths(const(immutable(char)[][]))
 (this=, paths={[0] = "/usr/include/dmd/phobos/"})
 
 and some unreadable
 

 _D7dsymbol11modulecache11ModuleCache14addImportPathsMFxAAyaZ8scanFromMFxQqZv
 (this=, root="/usr/include/dmd/phobos/")
 
 So please make me clear with the state of the demangling. Is it supported?
The mangling has changed with dmd 2.077 to reduce the size of symbols. There is a patch for gdb/libiberty but it hasn't been merged yet AFAICT: https://github.com/ibuclaw/gdb/pull/8
Dec 03 2018
parent reply ANtlord <antlord92 gmail.com> writes:
On Monday, 3 December 2018 at 22:36:43 UTC, Rainer Schuetze wrote:

 There is a patch for gdb/libiberty but it hasn't been merged 
 yet AFAICT: https://github.com/ibuclaw/gdb/pull/8
What is the state of the PR? As far as I see hasn't been updated since 10 May. Also, can't we use D code in gdb? It helps to synchronize the demangling with the latest changes. Or it's impossible because GDB's demangling should support several versions of dlang compiler?
Dec 04 2018
parent Rainer Schuetze <r.sagitario gmx.de> writes:
On 04/12/2018 09:28, ANtlord wrote:
 On Monday, 3 December 2018 at 22:36:43 UTC, Rainer Schuetze wrote:
 
 There is a patch for gdb/libiberty but it hasn't been merged yet
 AFAICT: https://github.com/ibuclaw/gdb/pull/8
What is the state of the PR? As far as I see hasn't been updated since 10 May.
Some paperwork had to be done with the FSF but that is completed. I guess Iain will merge the PR before the next major update. Also, can't we use D code in gdb? I doubt this is allowed before GDC is part of the official GNU compiler suite. This is expected to happen early next year. It helps to synchronize the
 demangling with the latest changes. Or it's impossible because GDB's
 demangling should support several versions of dlang compiler?
The new mangling is a superset of the old mangling, so demangling works for both old and new versions.
Dec 04 2018