DB(3pm)

πŸ“¦
version 0.18 Β· 2 versions
, in ubuntu jammy

πŸ’– DB(3pm) β€” like, the Apache::DB manual page bestie πŸ’–

okay so this is the manual page for Apache::DB from the User Contributed Perl Documentation, and it's literally about running the interactive Perl debugger under mod_perl. Let's get into it 🫢


✨ NAME ✨

Apache::DB β€” Run the interactive Perl debugger under mod_perl


πŸŽ€ SYNOPSIS πŸŽ€

 <Location /perl>
  PerlFixupHandler +Apache::DB

  SetHandler perl-script
  PerlHandler +Apache::Registry
  Options +ExecCGI
 </Location>

πŸ¦‹ DESCRIPTION πŸ¦‹

So Perl ships with a very useful interactive debugger, right? Iconic. But the thing is β€” it does not run "out-of-the-box" in the Apache/mod_perl environment. It's giving stage fright. πŸ™ˆ

Apache::DB makes a few adjustments so the two will cooperate. Matchmaker energy fr fr. πŸ’…


🌸 FUNCTIONS 🌸

init

This function initializes the Perl debugger hooks without actually starting the interactive debugger. Lowkey important detail: if you wanna debug a certain piece of code, you have to call this function before the code you wish to debug is compiled. Order matters bestie, no cap.

For example, if you want to insert debugging symbols into code that's compiled at server startup, but you don't care to debug until request time β€” call this function from a PerlRequire'd file:

 #where db.pl is simply:
 # use Apache::DB ();
 # Apache::DB->init;
 PerlRequire conf/db.pl

 #where modules are loaded
 PerlRequire conf/init.pl

If you're using mod_perl 2.0 you will need to use the following as your db.pl:

  use APR::Pool ();
  use Apache::DB ();
  Apache::DB->init();

handler

This function will start the interactive debugger. And the way that it's so convenient β€” it will invoke Apache::DB::init if needed. ✨ Example configuration:

 <Location /my-handler>
  PerlFixupHandler Apache::DB
  SetHandler perl-script
  PerlHandler My::handler
 </Location>

πŸ”₯ SELinux πŸ”₯

Security-enhanced Linux (SELinux) is a mandatory access control system many linux distrobutions are implementing. This new security scheme can assist you with protecting a server, but it doesn't come without its own set of issues. Not the plot twist we wanted. πŸ’€

Debugging applications running on a box with SELinux on it takes a couple of extra steps, and unfortunately the instructions that follow have only been tested on RedHat/Fedora.

  1. You need to edit/create the file "local.te" and add the following:
if (httpd_tty_comm) {
    allow { httpd_t } admin_tty_type:chr_file { ioctl getattr }; }
  1. Reload your security policy.
  2. Run the command "setsebool httpd_tty_comm true".
Heads up bestie: as you debug applications on a system with SELinux, your code may very well be correct, but the system policy is denying your actions. It's not you, it's the policy. 😭

πŸ’€ CAVEATS πŸ’€

  • -X β€” The server must be started with the "-X" to use Apache::DB. Periodt.

filename/line info

The filename of Apache::Registry scripts is not displayed. Rip to that info, it's just not there. 🫠


🌈 SEE ALSO 🌈

perldebug(1)


πŸ‘‘ AUTHOR πŸ‘‘

Originally written by Doug MacEachern

Currently maintained by Dirk Lindner <lze@cpan.org>


πŸ’œ LICENSE πŸ’œ

This module is distributed under the same terms as Perl itself.


and that's the whole page, you ate that πŸ“βœ¨ This was perl v5.34.0, dated 2022-02-06 β€” ty for coming to my TED talk, mwah πŸ’…πŸ’–

πŸ“¦ where this page comes from