1AnyEvent::Debug(3)    User Contributed Perl Documentation   AnyEvent::Debug(3)
2
3
4

NAME

6       AnyEvent::Debug - debugging utilities for AnyEvent
7

SYNOPSIS

9          use AnyEvent::Debug;
10
11          # create an interactive shell into the program
12          my $shell = AnyEvent::Debug::shell "unix/", "/home/schmorp/myshell";
13          # then on the shell: "socat readline /home/schmorp/myshell"
14

DESCRIPTION

16       This module provides functionality hopefully useful for debugging.
17
18       At the moment, "only" an interactive shell is implemented. This shell
19       allows you to interactively "telnet into" your program and execute Perl
20       code, e.g. to look at global variables.
21

FUNCTIONS

23       $shell = AnyEvent;::Debug::shell $host, $service
24           This function binds on the given host and service port and returns
25           a shell object, whcih determines the lifetime of the shell. Any
26           number of conenctions are accepted on the port, and they will give
27           you a very primitive shell that simply executes every line you
28           enter.
29
30           All commands will be executed "blockingly" with the socket
31           "select"ed for output. For a less "blocking" interface see
32           Coro::Debug.
33
34           The commands will be executed in the "AnyEvent::Debug::shell"
35           package, which is initially empty and up to use by all shells. Code
36           is evaluated under "use strict 'subs'".
37
38           Consider the beneficial aspects of using more global (our)
39           variables than local ones (my) in package scope: Earlier all my
40           modules tended to hide internal variables inside "my" variables, so
41           users couldn't accidentally access them. Having interactive access
42           to your programs changed that: having internal variables still in
43           the global scope means you can debug them easier.
44
45           As no authenticsation is done, in most cases it is best not to use
46           a TCP port, but a unix domain socket, whcih cna be put wherever
47           youc an access it, but not others:
48
49              our $SHELL = AnyEvent::Debug::shell "unix/", "/home/schmorp/shell";
50
51           Then you can use a tool to connect to the shell, such as the ever
52           versatile "socat", which in addition can give you readline support:
53
54              socat readline /home/schmorp/shell
55              # or:
56              cd /home/schmorp; socat readline unix:shell
57
58           Socat can even give you a persistent history:
59
60              socat readline,history=.anyevent-history unix:shell
61
62           Binding on 127.0.0.1 (or "::1") might be a less secure but sitll
63           not totally insecure (on single-user machines) alternative to let
64           you use other tools, such as telnet:
65
66              our $SHELL = AnyEvent::Debug::shell "127.1", "1357";
67
68           And then:
69
70              telnet localhost 1357
71

AUTHOR

73        Marc Lehmann <schmorp@schmorp.de>
74        http://home.schmorp.de/
75
76
77
78perl v5.12.1                      2009-08-09                AnyEvent::Debug(3)
Impressum