--On 23 August 2005 21:48 +0200, Matthias Kilian wrote:
Rebuild libdb with debugging enabled:
$ cd /usr/ports/databases/db/v4
$ make uninstall
$ DEBUG=-g make install
Thanks, that's helpful.
# gdb /tmp/ex_env
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "powerpc-unknown-openbsd3.8"...
(gdb) break __db_tas_mutex_lock
Function "__db_tas_mutex_lock" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (__db_tas_mutex_lock) pending.
(gdb) r
Starting program: /tmp/ex_env
Breakpoint 2 at 0x262e9b30: file ../mutex/mut_tas.c, line 99.
Pending breakpoint "__db_tas_mutex_lock" resolved
Setup env
Breakpoint 2, __db_tas_mutex_lock (dbenv=0x2d57b000, mutexp=0x27f92000)
at ../mutex/mut_tas.c:99
99 if (F_ISSET(dbenv, DB_ENV_NOLOCKING) || F_ISSET(mutexp,
MUTEX_IGNORE))
(gdb) s
108 max_ms = F_ISSET(mutexp, MUTEX_LOGICAL_LOCK) ? 10 : 25;
(gdb)
107 ms = 1;
(gdb)
108 max_ms = F_ISSET(mutexp, MUTEX_LOGICAL_LOCK) ? 10 : 25;
(gdb)
111 for (nspins = dbenv->tas_spins; nspins > 0; --nspins) {
(gdb)
585 mutex.h: No such file or directory.
in mutex.h
(gdb)
582 in mutex.h
(gdb)
111 for (nspins = dbenv->tas_spins; nspins > 0; --nspins) {
(gdb)
169 __os_yield(NULL, ms * USEC_PER_MS);
(gdb)
170 if ((ms <<= 1) > max_ms)
(gdb)
169 __os_yield(NULL, ms * USEC_PER_MS);
(gdb)
__os_yield (dbenv=0x27f92000, usecs=1000) at ../os/os_spin.c:107
107 if (DB_GLOBAL(j_yield) != NULL && DB_GLOBAL(j_yield)()
== 0)
(gdb)
106 {
(gdb)
107 if (DB_GLOBAL(j_yield) != NULL && DB_GLOBAL(j_yield)()
== 0)
(gdb)
112 (void)__os_sleep(dbenv, 0, usecs);
(gdb)
__os_sleep (dbenv=0x0, secs=0, usecs=1000) at ../os/os_sleep.c:59
59 for (; usecs >= 1000000; usecs -= 1000000)
<and again...etc...>
/usr/ports/databases/db/v4/w-db-4.2.52p2/db-4.2.52/dbinc/mutex.h line
585 is PPC assembly code, it's the "asm volatile" line in this -
static inline int
MUTEX_SET(int *tsl) {
int __r;
int __tmp = (int)tsl;
asm volatile (
"0: \n\t"
" lwarx %0,0,%2 \n\t"
" cmpwi %0,0 \n\t"
" bne- 1f \n\t"
" stwcx. %2,0,%2 \n\t"
" isync \n\t"
" beq+ 2f \n\t"
" b 0b \n\t"
"1: \n\t"
" li %1, 0 \n\t"
"2: \n\t"
: "=&r" (__r), "=r" (tsl)
: "r" (__tmp)
: "cr0", "memory");
return (int)tsl;
}
I've done enough learning for today (I started by sprinkling printf
through the code which annoyed me sufficiently to make me learn gdb
basics) so I'll leave it for tonight, but thought I'd post what I've
found so far in case it helps anyone else before I look at it again.