| 1 | # -*- coding: utf-8 -*- | ||||||||||
| 2 | # Copyright (C) 2011-2012, 2014 Rocky Bernstein <rocky@cpan.org> | ||||||||||
| 3 | 12 | ▶ | use warnings; no warnings 'redefine'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 12 | ▶ | use rlib '../../../..'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | # Our local modules | ||||||||||
| 8 | ## use Devel::Trepan::Options; or is it default | ||||||||||
| 9 | 12 | ▶ | use Devel::Trepan::Interface::Server; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | package Devel::Trepan::CmdProcessor::Command::Server; | ||||||||||
| 12 | 12 | ▶ | use Cwd 'abs_path'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 12 | ▶ | use Getopt::Long qw(GetOptionsFromArray); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 12 | ▶ | use if !@ISA, Devel::Trepan::CmdProcessor::Command ; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 1 | ▶ | unless (@ISA) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 0 | ▶ | eval <<'EOE'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | use constant CATEGORY => 'support'; | ||||||||||
| 19 | use constant SHORT_HELP => 'Allow remote debugger connections'; | ||||||||||
| 20 | use constant MIN_ARGS => 0; # Need at least this many | ||||||||||
| 21 | use constant MAX_ARGS => undef; # Need at most this many - undef -> unlimited. | ||||||||||
| 22 | EOE | ||||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 12 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | |||||||||||
| 27 | 12 | ▶ | use vars qw(@ISA); @ISA = qw(Devel::Trepan::CmdProcessor::Command); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 12 | ▶ | use vars @CMD_VARS; # Value inherited from parent | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | |||||||||||
| 30 | 1 | $NAME = set_name(); | |||||||||
| 31 | =pod | ||||||||||
| 32 | |||||||||||
| 33 | =head2 Synopsis: | ||||||||||
| 34 | |||||||||||
| 35 | =cut | ||||||||||
| 36 | 1 | $HELP = <<'HELP'; | |||||||||
| 37 | =pod | ||||||||||
| 38 | |||||||||||
| 39 | B<server> [I<options>] | ||||||||||
| 40 | |||||||||||
| 41 | options: | ||||||||||
| 42 | |||||||||||
| 43 | -p | --port NUMBER | ||||||||||
| 44 | -a | --address | ||||||||||
| 45 | |||||||||||
| 46 | Suspends interactive debugger session and puts debugger in server mode | ||||||||||
| 47 | which opens a socket for debugger connections. | ||||||||||
| 48 | |||||||||||
| 49 | =cut | ||||||||||
| 50 | HELP | ||||||||||
| 51 | |||||||||||
| 52 | # FIXME: put back in help. | ||||||||||
| 53 | # Note that the command startup file ${Devel::Trepan::CMD_INITFILE_BASE} is read automatically | ||||||||||
| 54 | # via a ${NAME} command the debugger is started. | ||||||||||
| 55 | |||||||||||
| 56 | 1 | my $DEFAULT_OPTIONS = { | |||||||||
| 57 | port => 1954, | ||||||||||
| 58 | host => '127.0.0.1', | ||||||||||
| 59 | }; | ||||||||||
| 60 | |||||||||||
| 61 | # sub complete($$) { | ||||||||||
| 62 | # my ($self, $prefix) = @_; | ||||||||||
| 63 | # my $files = Readline::FILENAME_COMPLETION_PROC.call(prefix) || [] | ||||||||||
| 64 | # my $opts = (qw(-c --continue --no-continue -N --no -y --yes | ||||||||||
| 65 | # --verbose --no-verbose), $files); | ||||||||||
| 66 | # Devel::Trepan::Complete::complete_token($opts, $prefix) ; | ||||||||||
| 67 | # } | ||||||||||
| 68 | |||||||||||
| 69 | sub parse_options($$) | ||||||||||
| 70 | 0 | ▶ | { | ||||||||
|
Subroutine
parse_options: not called CC=1 SCAR=6.9
Subroutine
parse_options: not called CC=1 SCAR=6.9
Pod
undocumented
Pod
undocumented
| |||||||||||
| 71 | 0 | ▶ | my ($self, $args) = @_; | ||||||||
|
Subroutine
parse_options: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 72 | 0 | my $seen_yes_no = 0; | |||||||||
| 73 | 0 | my %opts = %{$DEFAULT_OPTIONS}; | |||||||||
| 74 | my $result = &GetOptionsFromArray($args, | ||||||||||
| 75 | 'port:n' => \$opts{port}, | ||||||||||
| 76 | 'host:s' => \$opts{host}, | ||||||||||
| 77 | 0 | ); | |||||||||
| 78 | 0 | \%opts; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | sub run($$) | ||||||||||
| 82 | 0 | ▶ | { | ||||||||
|
Subroutine
run: not called CC=1 SCAR=1.6
Subroutine
run: not called CC=1 SCAR=1.6
Pod
undocumented
Pod
undocumented
| |||||||||||
| 83 | 0 | my ($self, $args) = @_; | |||||||||
| 84 | 0 | my @args = @$args; | |||||||||
| 85 | 0 | my $proc = $self->{proc}; | |||||||||
| 86 | 0 | my $options = parse_options($self, \@args); | |||||||||
| 87 | 0 | my $intf = $proc->{interfaces}; | |||||||||
| 88 | 0 | $options->{logger} = $intf->[-1]{output}{output}; | |||||||||
| 89 | # Push a new server interface. | ||||||||||
| 90 | 0 | my $script_intf = Devel::Trepan::Interface::Server->new(undef, undef, | |||||||||
| 91 | $options); | ||||||||||
| 92 | 0 | push @{$intf}, $script_intf; | |||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | |||||||||||
| 96 | # Demo it | ||||||||||
| 97 | 1 | ▶ | unless (caller) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 98 | # require_relative '../mock' | ||||||||||
| 99 | # dbgr, cmd = MockDebugger::setup | ||||||||||
| 100 | # %w(--quiet -q --no-quiet --continue --no-continue -c -v --verbose | ||||||||||
| 101 | # --no-verbose).each do |opt| | ||||||||||
| 102 | # puts "parsing ${opt}" | ||||||||||
| 103 | # options = | ||||||||||
| 104 | # cmd.parse_options(Trepan::Command::SourceCommand::DEFAULT_OPTIONS.dup, | ||||||||||
| 105 | # opt) | ||||||||||
| 106 | # p options | ||||||||||
| 107 | # } | ||||||||||
| 108 | |||||||||||
| 109 | # if ARGV.size >= 1 | ||||||||||
| 110 | # puts "running... ${cmd.name} ${ARGV}" | ||||||||||
| 111 | # cmd.run([cmd.name, *ARGV]) | ||||||||||
| 112 | # } | ||||||||||
| 113 | } | ||||||||||
| 114 | |||||||||||
| 115 | 1 | 1; | |||||||||