Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-16 14:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found