Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Greetings
I Did the following to Enable GUI Debugging of Mod_Perl (Apache::Registry) scripts (I got this Information from different places ) ,
I have documented the steps followed and want to put it under the appropriate section (Suggest appropriate section) in perlmonks ,
This is my first attempt to writing a Setup Guide so am seeking the wise monks Inputs on the same.
Please let me know your Feedback/Opinions and any suggestions

Steps Followed


Installed the following packages from CPAN
1.Tk Graphical User Interface ToolKit from CPAN (Tk-804.027.tar)
2. Installed the Apache-DB-0.09
3. Installed the Devel-ptkdb-1.1091.tar.gz

Open the Apache::DB.pm file and change
#require 'Apache/perl5db.pl'; Comment this line
require 'Devel/ptkdb.pm';

Save the below code as file Db.patch


################################################################# --- DB.pm 2003/07/23 16:59:07 1.1 +++ DB.pm 2003/07/23 17:03:29 @@ -39,6 +39,34 @@ return 0; } + +sub ptkdb ($$) { + my ($class,$r) = @_; + + init(); + + # need to have a list of authorized remote hosts + $ENV{DISPLAY} = $r->get_remote_host.':0.0'; + $DB::connection_refused = 0; # try try again + require 'Devel/ptkdb.pm'; + $DB::single = 1; +# bug workaround? Pressing "Return" button at toplevel makes ptkdb h +ang. + $DB::subroutine_depth = 0 ; + $DB::step_over_depth = -1 ; + + if (ref $r) { + $SIG{INT} = \&DB::dbint_handler; + $r->register_cleanup(sub { + $SIG{INT} = \&DB::ApacheSIGINT(); + $DB::single = 0; # do not debug during withdraw + $DB::window->close_ptkdb_window; + }); + } + + return 0; +} + + 1; __END__ #################################################################

Save the below code as file Ptkdb.patch


################################################################# --- ptkdb.pm 2003/07/23 17:05:20 1.1 +++ ptkdb.pm 2003/07/23 17:51:09 @@ -1105,8 +1105,21 @@ # Main Window - +eval { $self->{main_window} = MainWindow->new() ; +}; +if ($@) { + my $err = $@; + my $r = eval { Apache->request }; # check if running under mod_per +l + undef $@; + if ($r && $err =~ m/Xlib: connection .*? refused|Xlib: Client is no +t authorized|couldn't connect to display/) { + $DB::connection_refused = 1; + $self->{main_window} = undef; + warn($err); # log the problem + return; + } + die $err; +} $self->{main_window}->geometry($ENV{'PTKDB_GEOMETRY'} || "800x600") + ; $self->setup_options() ; # must be done after MainWindow and before + other frames are setup @@ -1237,8 +1250,9 @@ $DB::window->{'event'} = 'run' ; $self->{current_file} = "" ; # force a file reset - $self->{'main_window'}->destroy ; + $self->{'main_window'}->destroy if $self->{'main_window'}; $self->{'main_window'} = undef ; + $DB::connection_refused = undef; # allow another try } sub setup_menu_bar { @@ -4048,7 +4062,12 @@ $^W = $saveW ; unless( $DB::ptkdb::isInitialized ) { - return if( $filename ne $0 ) ; # not in our target file + if ( $filename ne $0 ) { # not in our target file + # check if running under mod_perl + my $r = eval { Apache->request }; + undef $@; + return unless $r; + } &DB::Initialize($filename) ; } @@ -4063,6 +4082,11 @@ return ; } + if ( $DB::connection_refused ) { # X to remote host failed + $@ = $DB::save_err ; + return ; + } + $DB::window->setup_main_window() unless $DB::window->{'main_window'} + ; $DB::window->EnterActions() ; #################################################################

Install the DB.pm Patch


Note Find the path of DB.pm and ptkdb.pm (on Linux You can use Locate command)
patch <PATH ON SYSTEM>/Apache/DB.pm < Db.patch
Install the ptkdb patch
patch <PATH ON SYSTEM>/Devel/ptkdb.pm < Ptkdb.patch


Add the Following Lines in Httpd.conf
<IfDefine PERLDB> <Perl> use Apache::DB (); Apache::DB->init; </Perl> <Location /> PerlFixupHandler Apache::DB->ptkdb </Location> </IfDefine>

Start the Httpd with the Following Command (this starts apache in a Single mode)
/usr/local/apache/bin/httpd -X -D PERLDB

Enable the X-Windows (there are some security considerations ..man xhost for more details.) xhost +
When a request is sent the GUI pops up and we can go through the script (for the scripts that we run under Apache::Registry )
We need to step in on the below Line below
eval & {$cv}($r, @_) } if $r->seqno;

If your server is Linux and u are working on Windows you can do the same by using xterm

Install cygwin

Open cygwin
export DISPLAY=localhost:0.0
X -multiwindow &
xhost +
xterm -display localhost:0 &
ssh -X -l root <LINUX SERVER>
export DISPLAY=localhost:0.0
xhost +

2004-12-03 Janitored by Arunbear - added readmore tags, as per Monastery guidelines

Updated Steve_p - moved to Tutorials per consideration


In reply to Enabling GUI Debugging under Mod_Perl by mkirank

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (3)
    As of 2020-05-27 04:05 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      If programming languages were movie genres, Perl would be:















      Results (152 votes). Check out past polls.

      Notices?