Daniel Jacobowitz wrote:
> On Mon, Mar 18, 2002 at 03:21:53PM +0800, Stas Bekman wrote:
> 
>>Daniel Jacobowitz wrote:
>>
>>>On Sun, Mar 17, 2002 at 03:22:04AM +0800, Stas Bekman wrote:
>>>
>>>
>>>>Thanks Daniel,
>>>>
>>>>I guess first of all we are after being able to use the debugger with 
>>>>threads at all, next working on the speed. If I knew how to make gdb 
>>>>automatically switch to the thread which I want that would be a first 
>>>>big step (i don't know which thread number do I want). What I see 
>>>>currently is this: (I'm running on dual-proc smp kernel) I've a bp set 
>>>>and I press 'continue' and at random I get my thread which runs the code 
>>>>but most of the time not. I suppose this has to do with threads 
>>>>scheduling and its interaction with the debugger.
>>>>
>>>>
>>>Well, the same code is being called in the thread you want and another? 
>>>How do you know which thread you want?
>>>
>>>GDB supports both thread-specific breakpoints and conditional
>>>breakpoints.  From the manual, you can do things like:
>>> (gdb) break main thread 1 if a == 2
>>>
>>>So if you can express the condition that says "this is my thread", you
>>>can do
>>> (gdb) break apr_poll if thread->magic == MY_MAGIC
>>>or whatever.
>>>
>>Interesting. Has anybody an idea what would be the condition in httpd 
>>threads? looking through worker.c I cannot see any variables I can have 
>>in the scope of the running thread. How do I refer to the thread, while 
>>I'm inside of it so I can get get to its local storage?
>>
> 
> The same way the thread figures out what its local storage is
> (remember, you can make function calls from GDB...).

of course :) I was asking what tls data can I use for indentification of
the desired thread, strictly a modperl specific question.

I think that the best way to work with threads is to have only one 
breakpoint, so once I reach the point I want to start debugging from I 
think I should disable all the temp breakpoints. And then the debugger 
will never start switching between threads. Currently if I still have 
apr_poll bp set, while I'm already inside my working thread, and step 
through it with step/next once in a while I get switched to other 
threads which call apr_poll. Cannot use tbreak here, since I need to 
call them a few times. So I guess I'll try to use disable/delete instead.

Indeed this startup script's version seems to work perfectly with 
threads without any workarounds:

file /home/stas/httpd/worker/bin/httpd
handle SIGPIPE nostop
handle SIGPIPE pass

define myrun
     tbreak main
     break ap_run_pre_config
     run -d `pwd`/t -f `pwd`/t/conf/httpd.conf \
     -DONE_PROCESS -DNO_DETATCH -DAPACHE2 -DPERL_USEITHREADS
     set auto-solib-add 0
     continue
end

define gopoll
     b apr_poll
     continue
     continue
end

define mybp
     # load Apache/Filter.so
     sharedlibrary Filter
     b mpxs_Apache__Filter_print
     # no longer needed and they just make debugging harder under threads
     disable 2
     disable 3
     continue
end

myrun
gopoll
mybp


_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to