c++ - Print or examine semaphore count value in GDB -


i trying implement thread pool using ace semaphore library. not provide api sem_getvalue in posix semaphore. need debug flow not behaving expected. can examine semaphore in gdb. using centos os.

i initialized 2 semaphores using default constructor providing count 0 , 10. have declared them static in class , initialized in cpp file as

dp_semaphore threadpool::availablethreads(10); dp_semaphore threadpool::availablework(0); 

but when printing semaphore in gdb using print command, getting similar output

(gdb) p this->availablework $7 = {   sema = {     semaphore_ = {       sema_ = 0x6fe5a0,       name_ = 0x0     },     removed_ = false   } } (gdb) p this->availablethreads $8 = {   sema = {     semaphore_ = {       sema_ = 0x6fe570,       name_ = 0x0     },     removed_ = false   } } 

is there tool can me here, or shall switch posix thread , re-write code.

edit: requested @timrau output of call this->availablework->dump()

(gdb) p this->availablework.dump() [switching thread 0x2aaaae97e940 (lwp 28609)] program stopped in thread while making function call gdb. evaluation of expression containing function (dp_semaphore::dump()) abandoned. when function done executing, gdb silently stop. (gdb) call this->availablework.dump() [switching thread 0x2aaaaf37f940 (lwp 28612)] program stopped in thread while making function call gdb. evaluation of expression containing function (dp_semaphore::dump()) abandoned. when function done executing, gdb silently stop. (gdb) info threads [new thread 0x2aaaafd80940 (lwp 28613)]   6 thread 0x2aaaafd80940 (lwp 28613)  0x00002aaaac10a61e in __lll_lock_wait_private ()    /lib64/libpthread.so.0 * 5 thread 0x2aaaaf37f940 (lwp 28612)  threadpool::fetchwork (this=0x78fef0, worker=0x2aaaaf37f038)     @ ../../callmanager/src/dp_callcontroltask.cpp:1043   4 thread 0x2aaaae97e940 (lwp 28609)  dp_semaphore::dump (this=0x6e1460) @ ../../common/src/dp_semaphore.cpp:21   2 thread 0x2aaaad57c940 (lwp 28607)  0x00002aaaabe01ff3 in __find_specmb () /lib64/libc.so.6   1 thread 0x2aaaacb7b070 (lwp 28604)  0x00002aaaac1027c0 in __nptl_create_event () /lib64/libpthread.so.0 (gdb) 

sema.semaphore_.sema_ in code looks pointer. try find it's type in ace headers, convert type , print:

(gdb) p *((sem_t)0x6fe570) 

update: try convert address within structure posted sem_t. if use linux, ace should using posix semaphores, type sem_t must visible gdb.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -