PCWATCH to multithreaded application
hello everybody.
i've written an utility to trace a process, similar to truss, but with additional features, using procfs.
the problem i've got is the following:
i'm trying to intercept some function calls, so i installed a watchpoints on those functions in debuggee's address space. it worked fine for single-threaded apps, but when i did that for multithreaded ones, both debuggee and debugger stucked.
no idea why that's happened.
the PWCSTOP command was set to be synchronous.
debugger was stucked while waiting in write(PCWSTOP) into process' ctl file,
and debuggee seemed to eat all the CPU.
i found that this happened if i write any single PCWATCH command into process's ctl file, setting watchpoint to any virtual address (i set WA_EXEC only)
here's the sequence of actions:
write(ctl, PCSTOP)
write(ctl, PCSET (PR_RLC | PR_FORK) )
write(ctl, PCSEXIT)
write(ctl, PCSFAULT (FLTWATCH))
write(ctl, PCWATCH(some virtual addr with len 4 bytes))
write(ctl, PCRUN(PRCFAULT))
for (;;) {
write(ctl, PCWSTOP)
write(ctl, PCRUN (PRCFAULT))
}
my environment:
SunOS goblin 5.6 Generic_105181-21 sun4u sparc SUNW,Ultra-5_10
compiler : gcc 2.95, workshop cc 4.2