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()
.call /v @!"mongod!mongo::LockerImpl<1>::dump()"
Couldn't resolve error at '@!"mongod!mongo::LockerImpl<1>::dump()"' – Raglandthis
(that is, the address of the object you want to call the method on) as the first parameter. – Kwangju.call /v mongod!mongo::LockerImpl<0>::dump(mongod!mongo::`anonymous namespace'::globalLockManager)
. – Kwangju.call /s @"mongod!mongo::LockerImpl<0>::dump" 0x00007ff62d006be0(0x00007ff6d1b326e0)
, where the first address is the address of the function and the second is thethis
object for it. – Kwangju.call /s @"mongod!mongo::LockerImpl<0>::dump" 0x00007ff62d006be0(0x00007ff6d1b326e0)
which returns Bad register error at '@"mongod!mongo::LockerImpl<0>::dump" 0x00007ff62d006be0(0x00007ff6d1b326e0)' – Ragland.call /s mongo::LockerImpl<0>::dump 0x00007ff62d006be0(0x00007ff6d1b326e0)
which returns Couldn't resolve error at 'mongo::LockerImpl<0>::dump 0x00007ff62d006be0(0x00007ff6d1b326e0)' – Ragland.call /v 0x00007ff62d006be0(0x00007ff6d1b326e0)
returns Couldn't resolve '.call 0x00007ff62d006be0(0x00007ff6d1b326e0)' – Ragland