Resolving symbol in Windows debugger CDB
Asked Answered
R

0

11

I am attempting to invoke a C++ function in a process that I attach to, via the Windows debugger CDB.

The function is defined as:

void LockerImpl<IsForMMAPV1>::dump() const { ... }

The symbols are found in CDB as the following, using the CDB command

x mongod!*dump

00007ff6`2d006be0 mongod!mongo::LockerImpl<0>::dump (void)
00007ff6`2d006640 mongod!mongo::LockerImpl<1>::dump (void)

x /v mongod!mongo::LockerImpl<0>::dump
prv func   00007ff6`cfcf6be0  597 mongod!mongo::LockerImpl<0>::dump (void)          

x /v mongod!mongo::LockerImpl<1>::dump
prv func   00007ff6`cfcf6640  597 mongod!mongo::LockerImpl<1>::dump (void)

Invoking these symbols produces an error:

.call /v mongod!mongo::LockerImpl<0>::dump()

Couldn't resolve error at 'mongod!mongo::LockerImpl<0>::dump()'

I also tried to invoke it using the "decorated name", but had the same result. Other variations also failed:

.call /v @!("mongod!mongo::LockerImpl<1>::dump()")

.call /v mongod!mongo::LockerImpl<0>::dump(mongod!mongo::`anonymous namespace'::globalLockManager)

Couldn't resolve error at 'mongod!mongo::LockerImpl<0>::dump(mongod!mongo::`anonymous namespace'::globalLockManager)'

I have also tried to pass the address of the instance of globalLockManager, i.e.,

u mongod!mongo::getGlobalLockManager
mongod!mongo::getGlobalLockManager [c:\data\mci\c286593757a3793e6b070bc761c736b0\src\src\mongo\db\concurrency\lock_state.cpp @ 940]:
00007ff6`cfcf76a0 488d0539b0e301  lea     rax,[mongod!mongo::`anonymous namespace'::globalLockManager (00007ff6`d1b326e0)]

ln 0x00007ff6d1b326e0
(00007ff6`d1b326e0)   mongod!mongo::`anonymous namespace'::globalLockManager   |  (00007ff6`d1b326f0)   mongod!mongo::`anonymous namespace'::unusedLockCleaner
Exact matches:

The invoking it with the globalLockManager instance address:

.call /v mongod!mongo::LockerImpl<0>::dump(0x00007ff6d1b326e0)

Couldn't resolve error at 'mongod!mongo::LockerImpl<0>::dump(0x00007ff6d1b326e0)'

The other types of note are:

typedef LockerImpl<false> DefaultLockerImpl;
typedef LockerImpl<true> MMAPV1LockerImpl;

Note the function can be invoked from Linux/GDB as follows:

call ('mongo::(anonymous namespace)::globalLockManager').dump()
Ragland answered 6/2, 2017 at 15:21 Comment(10)
Are you sure you need parentheses with @!"" ?Kwangju
Tried it without the parenthesis .call /v @!"mongod!mongo::LockerImpl<1>::dump()" Couldn't resolve error at '@!"mongod!mongo::LockerImpl<1>::dump()"'Ragland
Oops, I didn't notice at the start that this was a non-static member function. You need to pass this (that is, the address of the object you want to call the method on) as the first parameter.Kwangju
Try something like .call /v mongod!mongo::LockerImpl<0>::dump(mongod!mongo::`anonymous namespace'::globalLockManager).Kwangju
@Kwangju Thanks for your suggestion. I did try it, see update in post. It seems I am getting closer, but still have a symbol resolve error.Ragland
What about calling the method by its address instead of its name?Stud
As Thomas Weller suggested, try something like .call /s @"mongod!mongo::LockerImpl<0>::dump" 0x00007ff62d006be0(0x00007ff6d1b326e0), where the first address is the address of the function and the second is the this object for it.Kwangju
@Kwangju As suggested, I tried the following: .call /s @"mongod!mongo::LockerImpl<0>::dump" 0x00007ff62d006be0(0x00007ff6d1b326e0) which returns Bad register error at '@"mongod!mongo::LockerImpl<0>::dump" 0x00007ff62d006be0(0x00007ff6d1b326e0)'Ragland
@Kwangju I have also tried .call /s mongo::LockerImpl<0>::dump 0x00007ff62d006be0(0x00007ff6d1b326e0) which returns Couldn't resolve error at 'mongo::LockerImpl<0>::dump 0x00007ff62d006be0(0x00007ff6d1b326e0)'Ragland
Another variation tried .call /v 0x00007ff62d006be0(0x00007ff6d1b326e0) returns Couldn't resolve '.call 0x00007ff62d006be0(0x00007ff6d1b326e0)'Ragland

© 2022 - 2024 — McMap. All rights reserved.