You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by wangyz <wa...@tongtech.com> on 2008/02/27 10:35:27 UTC

how to debug module using gdb

hello everyone:
I am learning
EnhydraDirector(http://www.enhydra.org/tech/director/index.html) which
is apache plugin .but i met a difficult question. during debugging this
plugin,if i met hook function such as ap_hook_post_config,
ap_hook_handler. i can not went into EnhydraDirector code. gdb hint me
config.c did not be found.

my env:
linux 2.4.20-8.

this is my process.
1. compile and install apache2.0.54.this is my command.
./configure --prefix=/home/build/http2054 --enable-rule=SHARED_CORE
--enable-module=so --enable-maintainer-mode
make
make install.
2. using apache's "-X" option to start the server in single process mode:
httpd -X
3. gdb attach httpd and set breakpoints

hope your answer. thanks in advance





Re: [邮件隔离]Re: [可能是垃圾邮件] Re: [可能是垃圾邮件] Re: how to debug module using gdb

Posted by wangyz <wa...@tongtech.com>.
Pitchaimani Muthuveeran wrote:
>
> ----- Original Message ----- From: "wangyz" <wa...@tongtech.com>
> To: <mo...@httpd.apache.org>
> Sent: Friday, February 29, 2008 12:59 PM
> Subject: Re: [可能是垃圾邮件] Re: [可能是垃圾邮件] Re: how to debug
> module using gdb
>
>
>> hi meendar:
>> i am a new monkey at apache. can you give me a detail explanation
>> .thanks you
>>
>> meendar wrote:
>>> wangyz wrote:
>>>
>>>> thanks again.
>>>> I sure that i had compiled a debug version. and gdb had load the
>>>> library.
>>>>
>>>>
>>>> Jarek Kucypera wrote:
>>>>
>>>>
>>>>>> I have done as you said. start httpd within gdb.
>>>>>> but it seemed that it is not useful. i can not still step into my
>>>>>> function.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> Hmm, have you compiled your module with debug info ? Are you sure
>>>>> httpd
>>>>> loads your module ?
>>>>> I use gdb 6.7.1 on linux and it nicely delays setting breakpoints in
>>>>> not-yet-existing code until particuar
>>>>> shared library is loaded (i.e. when setting such breakpoint, it
>>>>> stores
>>>>> it as "unresolved" and resolves
>>>>> it while loading the library).
>>>>>
>>>>> J.K.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>> Make sure you compile with optimization level 0, that is *O0* flag in
>>> your gcc, by default apache configure_vars.mk having *O2* level.
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>
>
> Do not Top Post!
>
> If you compiling your module with apxs, then change the variable
> EXTRA_CFLAGS to "-g O0 -pthread" <Apache Dist
> Dir>/build/config_vars.mk and compile again.
>
> Else if you are compiling your module along with apache, then change
> environment <ApacheSRCDir>/config_vars.mk as flag O2 to O0 in same
> variable given above and compile it.
>
> Thanks!
>
> Mani
>
>
>
>
>
>
everything is ok. after change o2 to o0 ,
thanks everyone




Re: [可能是垃圾邮件] Re: [可能是垃圾邮件] Re: how to debug module using gdb

Posted by Pitchaimani Muthuveeran <pm...@msys-tech.com>.
----- Original Message ----- 
From: "wangyz" <wa...@tongtech.com>
To: <mo...@httpd.apache.org>
Sent: Friday, February 29, 2008 12:59 PM
Subject: Re: [可能是垃圾邮件] Re: [可能是垃圾邮件] Re: how to debug module 
using gdb


> hi meendar:
> i am a new monkey at apache. can you give me a detail explanation
> .thanks you
>
> meendar wrote:
>> wangyz wrote:
>>
>>> thanks again.
>>> I sure that i had compiled a debug version. and gdb had load the 
>>> library.
>>>
>>>
>>> Jarek Kucypera wrote:
>>>
>>>
>>>>> I have done as you said. start httpd within gdb.
>>>>> but it seemed that it is not useful. i can not still step into my 
>>>>> function.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>> Hmm, have you compiled your module with debug info ? Are you sure httpd
>>>> loads your module ?
>>>> I use gdb 6.7.1 on linux and it nicely delays setting breakpoints in
>>>> not-yet-existing code until particuar
>>>> shared library is loaded (i.e. when setting such breakpoint, it stores
>>>> it as "unresolved" and resolves
>>>> it while loading the library).
>>>>
>>>> J.K.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>> Make sure you compile with optimization level 0, that is *O0* flag in
>> your gcc, by default apache configure_vars.mk having *O2* level.
>>
>>
>>
>>
>
>
>
>


Do not Top Post!

If you compiling your module with apxs, then change the variable 
EXTRA_CFLAGS to "-g O0 -pthread"  <Apache Dist Dir>/build/config_vars.mk and 
compile again.

Else if you are compiling your module along with apache, then change 
environment <ApacheSRCDir>/config_vars.mk as flag O2 to O0 in same variable 
given above and compile it.

Thanks!

Mani




Re: [可能是垃圾邮件] Re: [可能是垃圾邮件] Re: how to debug module using gdb

Posted by wangyz <wa...@tongtech.com>.
hi meendar:
i am a new monkey at apache. can you give me a detail explanation
.thanks you

meendar wrote:
> wangyz wrote:
>   
>> thanks again.
>> I sure that i had compiled a debug version. and gdb had load the library.
>>
>>
>> Jarek Kucypera wrote:
>>   
>>     
>>>> I have done as you said. start httpd within gdb.
>>>> but it seemed that it is not useful. i can not still step into my function.
>>>>
>>>>   
>>>>     
>>>>       
>>>>         
>>> Hmm, have you compiled your module with debug info ? Are you sure httpd
>>> loads your module ?
>>> I use gdb 6.7.1 on linux and it nicely delays setting breakpoints in
>>> not-yet-existing code until particuar
>>> shared library is loaded (i.e. when setting such breakpoint, it stores
>>> it as "unresolved" and resolves
>>> it while loading the library).
>>>
>>> J.K.
>>>
>>>
>>>
>>>   
>>>     
>>>       
>>
>>
>>   
>>     
> Make sure you compile with optimization level 0, that is *O0* flag in
> your gcc, by default apache configure_vars.mk having *O2* level.
>
>
>
>   




Re: [可能是垃圾邮件] Re: how to debug module using gdb

Posted by meendar <me...@gmail.com>.
wangyz wrote:
> thanks again.
> I sure that i had compiled a debug version. and gdb had load the library.
>
>
> Jarek Kucypera wrote:
>   
>>> I have done as you said. start httpd within gdb.
>>> but it seemed that it is not useful. i can not still step into my function.
>>>
>>>   
>>>     
>>>       
>> Hmm, have you compiled your module with debug info ? Are you sure httpd
>> loads your module ?
>> I use gdb 6.7.1 on linux and it nicely delays setting breakpoints in
>> not-yet-existing code until particuar
>> shared library is loaded (i.e. when setting such breakpoint, it stores
>> it as "unresolved" and resolves
>> it while loading the library).
>>
>> J.K.
>>
>>
>>
>>   
>>     
>
>
>
>
>   
Make sure you compile with optimization level 0, that is *O0* flag in
your gcc, by default apache configure_vars.mk having *O2* level.

Re: [可能是垃圾邮件] Re: how to debug module using gdb

Posted by wangyz <wa...@tongtech.com>.
thanks again.
I sure that i had compiled a debug version. and gdb had load the library.


Jarek Kucypera wrote:
>> I have done as you said. start httpd within gdb.
>> but it seemed that it is not useful. i can not still step into my function.
>>
>>   
>>     
> Hmm, have you compiled your module with debug info ? Are you sure httpd
> loads your module ?
> I use gdb 6.7.1 on linux and it nicely delays setting breakpoints in
> not-yet-existing code until particuar
> shared library is loaded (i.e. when setting such breakpoint, it stores
> it as "unresolved" and resolves
> it while loading the library).
>
> J.K.
>
>
>
>   




Re: [可能是垃圾邮件] Re: how to debug module using gdb

Posted by Jarek Kucypera <ja...@netstellar.com>.
> I have done as you said. start httpd within gdb.
> but it seemed that it is not useful. i can not still step into my function.
>
>   
Hmm, have you compiled your module with debug info ? Are you sure httpd
loads your module ?
I use gdb 6.7.1 on linux and it nicely delays setting breakpoints in
not-yet-existing code until particuar
shared library is loaded (i.e. when setting such breakpoint, it stores
it as "unresolved" and resolves
it while loading the library).

J.K.

Re: [可能是垃圾邮件] Re: how to debug module using gdb

Posted by wangyz <wa...@tongtech.com>.
thanks J.K.

I have done as you said. start httpd within gdb.
but it seemed that it is not useful. i can not still step into my function.


for example i want to debug these code.
static void apache_register_hooks(apr_pool_t *p)
{
ap_hook_post_config(myfunction, NULL, NULL, APR_HOOK_MIDDLE);
}

this is my process :
1. gdb httpd
2. b apache_register_hooks
3. b myfunction
4. run -X -d /apache2.0.54
5. I make a request from another window

after i done . gdb only stop at apache_register_hooks,but it can not
stop at myfunction





Jarek Kucypera wrote:
>> 3. gdb attach httpd and set breakpoints
>>   
>>     
> If you attach to running httpd, all config hooks have already executed,
> try starting httpd from within gdb.
>
> J.K.
>
>
>
>
>   




Re: how to debug module using gdb

Posted by Jarek Kucypera <ja...@netstellar.com>.
> 3. gdb attach httpd and set breakpoints
>   
If you attach to running httpd, all config hooks have already executed,
try starting httpd from within gdb.

J.K.