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

#0  
_D7dsymbol6symbol7DSymbol__T17getFirstPartNamedTSQBvQBqQBmZQBfMNgFSQCn16string_interning14Interned
tringZPNgSQEdQDyQDu (this=, name={
   data = "*constructor*"
})
         at dsymbol/src/dsymbol/symbol.d:234
#1  
dsymbol.conversion.first.FirstPass.visit(const(dparse.ast.StructBody)) (this=,
structBody=)
         at dsymbol/src/dsymbol/conversion/first.d:401
#2  
_D6dparse3ast17StructDeclaration6acceptMxFCQBpQBl10ASTVisitorZv 
(this=, visitor=)
         at libdparse/src/dparse/ast.d-mixin-2757:2759
#3  
_D7dsymbol10conversion5first9FirstPass__T25visitAggregateDeclarationTxC6dparse3ast17StructDeclarationZQCjMFxQBmEQEg6symb
l14CompletionKindZv (this=, kind=115 's', dec=)
         at dsymbol/src/dsymbol/conversion/first.d:809
#4  
dsymbol.conversion.first.FirstPass.visit(const(dparse.ast.StructDeclaration))
(this=, dec=)
         at dsymbol/src/dsymbol/conversion/first.d:184
#5  _D6dparse3ast11Declaration6acceptMxFCQBjQBf10ASTVisitorZv 
(this=, visitor=)
         at libdparse/src/dparse/ast.d:1244
#6  
dsymbol.conversion.first.FirstPass.visit(const(dparse.ast.Declaration)) (this=,
dec=)
         at dsymbol/src/dsymbol/conversion/first.d:315
#7  _D6dparse3ast6Module6acceptMxFCQBdQz10ASTVisitorZv (this=, 
visitor=)
         at libdparse/src/dparse/ast.d-mixin-2196:2198
#8  
dsymbol.conversion.first.FirstPass.visit(const(dparse.ast.Module)) (this=, mod=)
         at dsymbol/src/dsymbol/conversion/first.d:338
#9  dsymbol.conversion.first.FirstPass.run() (this=) at 
dsymbol/src/dsymbol/conversion/first.d:91
#10 
_D7dsymbol11modulecache11ModuleCache11cacheModuleMFAyaZPSQCd6symbol7DSymbol
(this=, location="/usr/include/dmd/phobos/etc/c/odbc/sqltypes.d")
         at dsymbol/src/dsymbol/modulecache.d:236
#11 
_D7dsymbol10conversion6second13resolveImportFPSQBt6symbol7DSymbolKS10containers12unrolledlist__T12UnrolledListTPSQEh11type_lookup10TypeLookupTS4stdx9allocator10mallocator10MallocatorVbi0Vmi64ZQDsKSQHn11module
ache11ModuleCacheZv (cache=, typeLookups=, acSymbol=)
         at dsymbol/src/dsymbol/conversion/second.d:142
#12 
_D7dsymbol10conversion6second10secondPassFPSQBq8semantic14SemanticSymbolPSQCu6scope_5ScopeKSQDm11module
ache11ModuleCacheZv (cache=, moduleScope=, currentSymbol=)
         at dsymbol/src/dsymbol/conversion/second.d:61
#13 
_D7dsymbol10conversion6second10secondPassFPSQBq8semantic14SemanticSymbolPSQCu6scope_5ScopeKSQDm11module
ache11ModuleCacheZv (cache=, moduleScope=, currentSymbol=)
         at dsymbol/src/dsymbol/conversion/second.d:77
#14 
_D7dsymbol11modulecache11ModuleCache11cacheModuleMFAyaZPSQCd6symbol7DSymbol
(this=, location="/usr/include/dmd/phobos/etc/c/odbc/sql.d")
         at dsymbol/src/dsymbol/modulecache.d:238
#15 
_D7dsymbol10conversion6second13resolveImportFPSQBt6symbol7DSymbolKS10containers12unrolledlist__T12UnrolledListTPSQEh11type_lookup10TypeLookupTS4stdx9allocator10mallocator10MallocatorVbi0Vmi64ZQDsKSQHn11module
ache11ModuleCacheZv (cache=, typeLookups=, acSymbol=)
         at dsymbol/src/dsymbol/conversion/second.d:142
#16 
_D7dsymbol10conversion6second10secondPassFPSQBq8semantic14SemanticSymbolPSQCu6scope_5ScopeKSQDm11module
ache11ModuleCacheZv (cache=, moduleScope=, currentSymbol=)
         at dsymbol/src/dsymbol/conversion/second.d:61
#17 
_D7dsymbol10conversion6second10secondPassFPSQBq8semantic14SemanticSymbolPSQCu6scope_5ScopeKSQDm11module
ache11ModuleCacheZv (cache=, moduleScope=, currentSymbol=)
         at dsymbol/src/dsymbol/conversion/second.d:77
#18 
_D7dsymbol11modulecache11ModuleCache11cacheModuleMFAyaZPSQCd6symbol7DSymbol
(this=, location="/usr/include/dmd/phobos/etc/c/odbc/sqlext.d")
         at dsymbol/src/dsymbol/modulecache.d:238
#19 
_D7dsymbol11modulecache11ModuleCache14addImportPathsMFxAAyaZ8scanFromMFxQqZv
(this=, root="/usr/include/dmd/phobos/etc/c/odbc")
         at dsymbol/src/dsymbol/modulecache.d:123
#20 
_D7dsymbol11modulecache11ModuleCache14addImportPathsMFxAAyaZ8scanFromMFxQqZv
(this=, root="/usr/include/dmd/phobos/etc/c")
         at dsymbol/src/dsymbol/modulecache.d:125
#21 
_D7dsymbol11modulecache11ModuleCache14addImportPathsMFxAAyaZ8scanFromMFxQqZv
(this=, root="/usr/include/dmd/phobos/etc")
         at dsymbol/src/dsymbol/modulecache.d:125
#22 
_D7dsymbol11modulecache11ModuleCache14addImportPathsMFxAAyaZ8scanFromMFxQqZv
(this=, root="/usr/include/dmd/phobos/")
         at dsymbol/src/dsymbol/modulecache.d:125
#23 
dsymbol.modulecache.ModuleCache.addImportPaths(const(immutable(char)[][]))
(this=, paths={[0] = "/usr/include/dmd/phobos/"})
         at dsymbol/src/dsymbol/modulecache.d:129
#24 D main (args={[0] = "/endlessos/develop/DCD/bin/dcd-server"}) 
at src/dcd/server/main.d:167


You can see some readable messages like

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

and some unreadable

#22 
_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
 
 #23
 dsymbol.modulecache.ModuleCache.addImportPaths(const(immutable(char)[][]))
 (this=, paths={[0] = "/usr/include/dmd/phobos/"})
 
 and some unreadable
 
 #22
 _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