------- Comment #16 from bkoz at gcc dot gnu dot org 2006-10-06 09:52 -------
When you get to "break here" this is what your mutex should look like in gdb:
Breakpoint 2, add () at lock_test.cc:14
(gdb) p test_mutex
$4 = {_M_mutex = {__data = {__lock = 1, __count = 0, __owner = 14845,
__kind = 0, __nusers = 1, {__spins = 0, __list = {__next = 0x0}}},
__size =
"\001\000\000\000\000\000\000\000ý9\000\000\000\000\000\000\001\000\000\000\000\000\000",
__align = 1}}
Or, something like this (I see this on x86/linux.)
Actually, if you edit my example a bit and
void* add(void*)
{
{
__gnu_cxx::__scoped_lock sentry(test_mutex);
++i; // break here
}
return 0; // break here
}
On the return statement, you'll see:
(gdb) p test_mutex
$4 = {_M_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __kind = 0,
__nusers = 0, {__spins = 0, __list = {__next = 0x0}}},
__size = '\0' <repeats 23 times>, __align = 0}}
If this is not happening, then there is something wrong with mutex usage.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29118