You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by barries <ba...@slaysys.com> on 2001/05/04 20:44:26 UTC

gdb & mod_perl-2.0?

Should I be able to use gdb-5.0 (or even 19991004) to single-step into
and out of mod_perl-2.0's code? I see support for running the test
server under gdb, so I'm hopeful.  Running glibc-2.1.3 on va-linux's
tweaked RedHat 6.2, FWIW. Typical gdb-5.0 session below, the 19941004
gdb that came installed on his box behaves similarly.

The reason I'm going down this trail is to get more familiar with
mod_perl-2.0's internals. My puzzle du jour is why a
PerlOutputFilterHandler like

   sub handler {
       my $filter = shift ;

       my $r = $filter->r ;
       my $fn = $r->filename ;

       my $mtime = (stat $fn)[9] ;

       $filter->print(
	   map "$_\n",
	   $fn,
	   $mtime,
	   $r->mtime,
	   scalar localtime $mtime,
	   scalar localtime $filter->r->mtime,
       ) ;

       while ($filter->read(my $buffer, 1024)) {
	   $filter->print(lc $buffer);
       }

       0;
   }

doesn't print the same mtime twice:

   /home/barries/2.0/www/htdocs/index.html.en
   988998777
   952717376
   Fri May  4 13:52:57 2001
   Fri Mar 10 14:42:56 2000
   ...snip...

- Barrie


[barries@//sizzle] www$ ~/gdb-5.0/gdb/b': ~/gdb-5.0/gdb/gdb bin/httpd
GNU gdb 5.0
Copyright 2000 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 "i686-pc-linux-gnu"...
(gdb) set args -D ONE_PROCESS
(gdb) list prefork.c:800
...snip...
(gdb) b 824
Breakpoint 1 at 0x8071b1e: file prefork.c, line 824.
(gdb) r
Starting program: /home/barries/2.0/www/bin/httpd -D ONE_PROCESS
[New Thread 1024 (runnable)]
mod_perl trace flags dump:
 d On  (directive processing)
 f On  (filters)
 g On  (Perl runtime interaction)
 h On  (handlers)
 i On  (interpreter pool management)
 m On  (memory allocations)
 s On  (perl sections)
 t On  (benchmark-ish timings)
modperl_config_dir_new: 0x810a964
modperl_cmd_output_filter_handlers: push @PerlOutputFilterHandler, Foo
modperl_handler_new: new handler Foo
modperl_cmd_push_handlers: created handler stack
modperl_cmd_push_handlers: pushed handler: Foo
[Switching to Thread 1024 (runnable)]

Breakpoint 1, child_main (child_num_arg=0) at prefork.c:824
824                 ap_process_connection(current_conn);
(gdb) s
ap_process_connection (c=0x810e404) at connection.c:212
212         ap_update_vhost_given_ip(c);
(gdb) n
214         ap_run_pre_connection(c);
(gdb) s
0x807a3f6 in ap_run_pre_connection (c=0x810e404) at connection.c:81
81      AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_connection,(conn_rec *c),(c),OK,DECLINED)
(gdb) s
modperl_hook_pre_connection (c=0x810e404) at mod_perl.c:239
239         return modperl_input_filter_register_connection(c);
(gdb) s
modperl_input_filter_register_connection (c=0x810e404) at modperl_filter.c:392
392         modperl_config_dir_t *dcfg =
(gdb) n
396         if ((av = dcfg->handlers_per_dir[MP_INPUT_FILTER_HANDLER])) {
(gdb) n
419         MP_TRACE_h(MP_FUNC, "no InputFilter handlers configured (connection)\n");
(gdb) n
421         return DECLINED;
(gdb) s
422     }
(gdb) s
0x401d5310 in modperl_hook_pre_connection (c=0x810e404) at mod_perl.c:240
240     }
(gdb) s



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: gcc -g -O2 ==> gdb stepping problems [Was: gdb & mod_perl-2.0?]

Posted by "Roy T. Fielding" <fi...@ebuilt.com>.
> Should the apr/configure.in prevent -O... options when it notes a -g?
> Seems like it's an awkward "reasonable default" for debug / maintainer
> mode.

I don't think it should default to anything, but then I am not Gnu.
I've never had any problems stepping through -O2 code, but that was
before all the hooks turned into macros.

....Roy


Re: gcc -g -O2 ==> gdb stepping problems [Was: gdb & mod_perl-2.0?]

Posted by "Roy T. Fielding" <fi...@ebuilt.com>.
> Should the apr/configure.in prevent -O... options when it notes a -g?
> Seems like it's an awkward "reasonable default" for debug / maintainer
> mode.

I don't think it should default to anything, but then I am not Gnu.
I've never had any problems stepping through -O2 code, but that was
before all the hooks turned into macros.

....Roy


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: gcc -g -O2 ==> gdb stepping problems [Was: gdb & mod_perl-2.0?]

Posted by barries <ba...@slaysys.com>.
On Thu, May 10, 2001 at 08:37:38PM -0700, Roy T. Fielding wrote:
> 
> Yes, that is the standard "reasonable default" per the Gnu project's
> makefile standards, which is why autoconf sets it.  As you discovered,
> it can be overridden by setting any value for CFLAGS prior to running
> configure.

Should the apr/configure.in prevent -O... options when it notes a -g?
Seems like it's an awkward "reasonable default" for debug / maintainer
mode.

Thanks,

Barrie

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: gcc -g -O2 ==> gdb stepping problems [Was: gdb & mod_perl-2.0?]

Posted by barries <ba...@slaysys.com>.
On Thu, May 10, 2001 at 08:37:38PM -0700, Roy T. Fielding wrote:
> 
> Yes, that is the standard "reasonable default" per the Gnu project's
> makefile standards, which is why autoconf sets it.  As you discovered,
> it can be overridden by setting any value for CFLAGS prior to running
> configure.

Should the apr/configure.in prevent -O... options when it notes a -g?
Seems like it's an awkward "reasonable default" for debug / maintainer
mode.

Thanks,

Barrie

Re: gcc -g -O2 ==> gdb stepping problems [Was: gdb & mod_perl-2.0?]

Posted by "Roy T. Fielding" <fi...@ebuilt.com>.
> Ok, got back to playing with this today: looks like the default CFLAGS
> setting for autoconf (created by AC_PROG_CC) is "-g -O2".  That seems
> like an odd combination to me, but it's as-installed on two RedHats and
> a FreeBSD.

Yes, that is the standard "reasonable default" per the Gnu project's
makefile standards, which is why autoconf sets it.  As you discovered,
it can be overridden by setting any value for CFLAGS prior to running
configure.

....Roy


Re: gcc -g -O2 ==> gdb stepping problems [Was: gdb & mod_perl-2.0?]

Posted by "Roy T. Fielding" <fi...@ebuilt.com>.
> Ok, got back to playing with this today: looks like the default CFLAGS
> setting for autoconf (created by AC_PROG_CC) is "-g -O2".  That seems
> like an odd combination to me, but it's as-installed on two RedHats and
> a FreeBSD.

Yes, that is the standard "reasonable default" per the Gnu project's
makefile standards, which is why autoconf sets it.  As you discovered,
it can be overridden by setting any value for CFLAGS prior to running
configure.

....Roy


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: gcc -g -O2 ==> gdb stepping problems [Was: gdb & mod_perl-2.0?]

Posted by Doug MacEachern <do...@covalent.net>.
On Thu, 10 May 2001, barries wrote:

> [cross-posting to new-httpd, since that's the more appropriate forum]
> 
> Background: I had trouble single-stepping through the routine defined by
> 
>    AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_connection,(conn_rec *c),(c),OK,DECLINED)

seems like the rest of your message missing?  i suspect you're having
trouble because you will not see the code normally expanded by cpp when
debugging with gdb.  the only work around i know of is to run the file
through gcc -E to get the expanded output, paste the expanded macro into
the .c file in place of the macro call and recompile.



Re: gcc -g -O2 ==> gdb stepping problems [Was: gdb & mod_perl-2.0?]

Posted by Doug MacEachern <do...@covalent.net>.
On Thu, 10 May 2001, barries wrote:

> [cross-posting to new-httpd, since that's the more appropriate forum]
> 
> Background: I had trouble single-stepping through the routine defined by
> 
>    AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_connection,(conn_rec *c),(c),OK,DECLINED)

seems like the rest of your message missing?  i suspect you're having
trouble because you will not see the code normally expanded by cpp when
debugging with gdb.  the only work around i know of is to run the file
through gcc -E to get the expanded output, paste the expanded macro into
the .c file in place of the macro call and recompile.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


gcc -g -O2 ==> gdb stepping problems [Was: gdb & mod_perl-2.0?]

Posted by barries <ba...@slaysys.com>.
[cross-posting to new-httpd, since that's the more appropriate forum]

Background: I had trouble single-stepping through the routine defined by

   AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_connection,(conn_rec *c),(c),OK,DECLINED)

.

On Fri, May 04, 2001 at 02:21:25PM -0700, Doug MacEachern wrote:
> 
> it looks fine to me, what is the problem exactly?

Ok, got back to playing with this today: looks like the default CFLAGS
setting for autoconf (created by AC_PROG_CC) is "-g -O2".  That seems
like an odd combination to me, but it's as-installed on two RedHats and
a FreeBSD.

When running httpd-2.0's ./configure with either of --with-debug
--enable-maintainer-mode, the pesky -O2 remains, causing my
single-stepping problems. Doing the oddball

   CFLAGS=-g ./configure --with-maintainer-mode ...

gets rid of the -O2 and single stepping seems to work nicely.

Playing with gcc a bit, it seems (not sure) that -O sets
-fomit-frame-pointer which (at the least) prevents gdb from being able
to step back into a routine defined by a macro from subroutines it
calls.

Is this a real issue, or am I or my system confused somehow? How do
others handle this?

- Barrie

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


gcc -g -O2 ==> gdb stepping problems [Was: gdb & mod_perl-2.0?]

Posted by barries <ba...@slaysys.com>.
[cross-posting to new-httpd, since that's the more appropriate forum]

Background: I had trouble single-stepping through the routine defined by

   AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_connection,(conn_rec *c),(c),OK,DECLINED)

.

On Fri, May 04, 2001 at 02:21:25PM -0700, Doug MacEachern wrote:
> 
> it looks fine to me, what is the problem exactly?

Ok, got back to playing with this today: looks like the default CFLAGS
setting for autoconf (created by AC_PROG_CC) is "-g -O2".  That seems
like an odd combination to me, but it's as-installed on two RedHats and
a FreeBSD.

When running httpd-2.0's ./configure with either of --with-debug
--enable-maintainer-mode, the pesky -O2 remains, causing my
single-stepping problems. Doing the oddball

   CFLAGS=-g ./configure --with-maintainer-mode ...

gets rid of the -O2 and single stepping seems to work nicely.

Playing with gcc a bit, it seems (not sure) that -O sets
-fomit-frame-pointer which (at the least) prevents gdb from being able
to step back into a routine defined by a macro from subroutines it
calls.

Is this a real issue, or am I or my system confused somehow? How do
others handle this?

- Barrie

Re: gdb & mod_perl-2.0?

Posted by barries <ba...@slaysys.com>.
On Fri, May 04, 2001 at 02:21:25PM -0700, Doug MacEachern wrote:
> > Running glibc-2.1.3 on va-linux's
> > tweaked RedHat 6.2, FWIW. Typical gdb-5.0 session below, the 19941004
> > gdb that came installed on his box behaves similarly.
> 
> it looks fine to me, what is the problem exactly?

Sorry, edit goof: I cut the part out that said that the final 's'
behaves like a 'c', and httpd execution resumes, going through all of
the other steps and emitting content.  When I request a new page, I hit
the breakpoint again.

> > 	   $r->mtime,
> 
> i see the problem, apr_time_t is not the same as time_t so some conversion
> is needed.  fix is in cvs now.

Cool, thanks.

- Barrie

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: gdb & mod_perl-2.0?

Posted by Doug MacEachern <do...@covalent.net>.
On Fri, 4 May 2001, barries wrote:

> Should I be able to use gdb-5.0 (or even 19991004) to single-step into
> and out of mod_perl-2.0's code?

yes.

> Running glibc-2.1.3 on va-linux's
> tweaked RedHat 6.2, FWIW. Typical gdb-5.0 session below, the 19941004
> gdb that came installed on his box behaves similarly.

it looks fine to me, what is the problem exactly?
 
> 	   $r->mtime,

i see the problem, apr_time_t is not the same as time_t so some conversion
is needed.  fix is in cvs now.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org