You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by "Philippe M. Chiasson" <go...@ectoplasm.org> on 2004/09/25 00:03:07 UTC

[Patch] Report the _right_ gdb command to run on traces of static builds

If we encounter core dumps with the static build, this small fix 
recommends the right
gdb command to run, since the httpd binary is actually a libtool shell 
script wrapper

Re: [Patch] Report the _right_ gdb command to run on traces of static builds

Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:
> If we encounter core dumps with the static build, this small fix 
> recommends the right
> gdb command to run, since the httpd binary is actually a libtool shell 
> script wrapper

sweet, but:

- it's a huge waste of time to parse the script again and again, instead 
do it once, the first time you've got the path to httpd and store it in 
another attribute (e.g. httpd_real? httpd_bin? other?)
- can core_httpd have a more intuitive name?
- the style needs a bit of work (open/die should be more helpful and drop 
parantheses where they aren't needed).

> Index: Apache-Test/lib/Apache/TestRun.pm
> ===================================================================
> RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm,v
> retrieving revision 1.183
> diff -u -I$Id -r1.183 TestRun.pm
> --- Apache-Test/lib/Apache/TestRun.pm	22 Sep 2004 23:14:29 -0000	1.183
> +++ Apache-Test/lib/Apache/TestRun.pm	24 Sep 2004 21:59:37 -0000
> @@ -867,7 +867,7 @@
>              # more than once and each time it caused a segfault
>              $core_files{$core} = -M $core;
>              push @msg, "server dumped core, for stacktrace, run:\n" .
> -                "gdb $vars->{httpd} -core $core";
> +                "gdb ". $self->core_httpd ." -core $core";
>          }
>      }}, $vars->{top_dir});
>  
> @@ -875,6 +875,36 @@
>  
>  }
>  
> +sub core_httpd {
> +    my($self) = @_;
> +    my $vars = $self->{test_config}->{vars};
> +    my $httpd = $vars->{httpd};
> +    my $fh;
> +    my $header;
> +    open ($fh, "<$httpd") or die $!;
> +    sysread($fh, $header, 2);
> +    if ($header eq '#!') {
> +        my ($program, $progdir);
> +        while(<$fh>) {
> +            if (/program=(.*)/) {
> +                $program = $1;
> +            }
> +            if (/progdir=(.*)/) {
> +                $progdir = $1;
> +            }
> +            if ($progdir && $program) {
> +                my $path = dirname $httpd;
> +                $program =~ s/'//g;
> +                $progdir =~ s/'//g;
> +                $httpd = File::Spec->catfile($path, $progdir, $program);
> +                last;
> +            }
> +        }
> +    }
> +    close($fh);
> +    return $httpd;
> +}
> +
>  sub scan_core {
>      my $self = shift;
>      my $vars = $self->{test_config}->{vars};
> @@ -897,7 +927,7 @@
>              my $oh = oh();
>              my $again = $times++ ? "again" : "";
>              error "oh $oh, server dumped core $again";
> -            error "for stacktrace, run: gdb $vars->{httpd} -core $core";
> +            error "for stacktrace, run: gdb " . $self->core_httpd . " -core $core";
>          }
>      }}, $vars->{top_dir});
>  }


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

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