| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | # Copyright (C) 2011-2015 Rocky Bernstein <rocky@cpan.org> | 
| 2 | 13 |  |  | 13 |  | 77642 | use Exporter; | 
|  | 13 |  |  |  |  | 37 |  | 
|  | 13 |  |  |  |  | 521 |  | 
| 3 | 13 |  |  | 13 |  | 76 | use warnings; | 
|  | 13 |  |  |  |  | 29 |  | 
|  | 13 |  |  |  |  | 419 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 13 |  |  | 13 |  | 75 | use rlib '../../..'; | 
|  | 13 |  |  |  |  | 31 |  | 
|  | 13 |  |  |  |  | 66 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | package Devel::Trepan::CmdProcessor; | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 13 |  |  | 13 |  | 5680 | use if !@ISA, Devel::Trepan::Options; | 
|  | 13 |  |  |  |  | 41 |  | 
|  | 13 |  |  |  |  | 95 |  | 
| 10 | 13 |  |  |  |  | 984 | use vars qw(@EXPORT $HAVE_DATA_DUMPER_CONCISE $HAVE_DATA_PRINT | 
| 11 | 13 |  |  | 13 |  | 1730 | $HAVE_PERLTIDY @DISPLAY_TYPES); | 
|  | 13 |  |  |  |  | 32 |  | 
| 12 |  |  |  |  |  |  | @EXPORT = qw(default_eval_display $HAVE_DATA_DUMPER_CONCISE | 
| 13 |  |  |  |  |  |  | $HAVE_DATA_PRINT $HAVE_PERLTIDY | 
| 14 |  |  |  |  |  |  | @DISPLAY_TYPES); | 
| 15 |  |  |  |  |  |  |  | 
| 16 | 13 |  |  | 13 |  | 212 | use strict; | 
|  | 13 |  |  |  |  | 29 |  | 
|  | 13 |  |  |  |  | 1792 |  | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | our @ISA; | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | BEGIN { | 
| 21 | 13 | 50 |  | 13 |  | 1065 | $HAVE_DATA_PRINT = | 
|  | 13 |  |  | 13 |  | 9154 |  | 
|  | 13 |  |  |  |  | 528100 |  | 
|  | 13 |  |  |  |  | 129 |  | 
| 22 |  |  |  |  |  |  | eval("use Data::Printer { colored => 1, deparse => 1, sort_keys => 1 }; 1") ? | 
| 23 |  |  |  |  |  |  | 1 : 0; | 
| 24 | 13 | 50 |  | 13 |  | 1053 | $HAVE_DATA_DUMPER_CONCISE = | 
|  | 13 |  |  |  |  | 6755 |  | 
|  | 13 |  |  |  |  | 13240 |  | 
|  | 13 |  |  |  |  | 670 |  | 
| 25 |  |  |  |  |  |  | eval("use Data::Dumper::Concise; 1") ? | 
| 26 |  |  |  |  |  |  | 1 : 0; | 
| 27 | 13 | 50 |  |  |  | 44 | $HAVE_PERLTIDY   = eval { | 
| 28 | 13 |  |  |  |  | 2752 | require Data::Dumper::Perltidy; | 
| 29 |  |  |  |  |  |  | } ? 1 : 0; | 
| 30 | 13 |  |  |  |  | 87 | @DISPLAY_TYPES = ('dumper'); | 
| 31 | 13 | 50 |  |  |  | 66 | push @DISPLAY_TYPES, 'ddp'  if $HAVE_DATA_PRINT; | 
| 32 | 13 | 50 |  |  |  | 58 | push @DISPLAY_TYPES, 'tidy'    if $HAVE_PERLTIDY; | 
| 33 | 13 | 50 |  |  |  | 2810 | push @DISPLAY_TYPES, 'concise' if $HAVE_DATA_DUMPER_CONCISE; | 
| 34 |  |  |  |  |  |  | } | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | # Return what to use for evaluation display | 
| 37 |  |  |  |  |  |  | sub default_eval_display() { | 
| 38 | 13 | 50 |  | 13 | 0 | 53 | if ($HAVE_DATA_PRINT) { | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
| 39 | 13 |  |  |  |  | 90 | return 'ddp'; | 
| 40 |  |  |  |  |  |  | } elsif ($HAVE_PERLTIDY) { | 
| 41 | 0 |  |  |  |  |  | return 'tidy'; | 
| 42 |  |  |  |  |  |  | } elsif ($HAVE_DATA_DUMPER_CONCISE) { | 
| 43 | 0 |  |  |  |  |  | return 'concise'; | 
| 44 |  |  |  |  |  |  | } else { | 
| 45 | 0 |  |  |  |  |  | return 'dumper'; | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  | } | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | use constant DEFAULT_SETTINGS => { | 
| 51 |  |  |  |  |  |  | abbrev        => 1,      # Allow abbreviations of debugger commands? | 
| 52 |  |  |  |  |  |  | autoeval      => 1,      # Perl eval non-debugger commands | 
| 53 |  |  |  |  |  |  | autoirb       => 0,      # Go into IRB in debugger command loop | 
| 54 |  |  |  |  |  |  | autolist      => 0,      # Run 'list' before entering command loop? | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | basename      => 0,      # Show basename of filenames only | 
| 57 |  |  |  |  |  |  | confirm       => 1,      # Confirm potentially dangerous operations? | 
| 58 |  |  |  |  |  |  | cmddir        => [],     # Additional directories to load commands | 
| 59 |  |  |  |  |  |  | # from | 
| 60 |  |  |  |  |  |  | different     => 0,      # stop *only* when  different position? | 
| 61 |  |  |  |  |  |  | displayop     => !$ENV{AUTOMATED_TESTING}, | 
| 62 |  |  |  |  |  |  | # If set, show OP address in location | 
| 63 |  |  |  |  |  |  | debugdbgr     => 0,      # Debugging the debugger | 
| 64 |  |  |  |  |  |  | debugexcept   => 1,      # Internal debugging of command exceptions | 
| 65 |  |  |  |  |  |  | debugmacro    => 0,      # debugging macros | 
| 66 |  |  |  |  |  |  | debugskip     => 0,      # Internal debugging of step/next skipping | 
| 67 |  |  |  |  |  |  | directory     =>         # last-resort path-search for files | 
| 68 |  |  |  |  |  |  | '$cdir:$cwd',            # that are not fully qualified. | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | displayeval   => default_eval_display(), | 
| 71 |  |  |  |  |  |  | # use Data::Dumper (dumper) or | 
| 72 |  |  |  |  |  |  | # Data::Dumper::Perltidy::dumper (tidy) ? | 
| 73 |  |  |  |  |  |  | hidestack     => -1,     # Fixnum. How many hidden outer | 
| 74 |  |  |  |  |  |  | # debugger stack frames to hide? | 
| 75 |  |  |  |  |  |  | # -1 means compute value. 0 | 
| 76 |  |  |  |  |  |  | # means hide none. Less than 0 means show | 
| 77 |  |  |  |  |  |  | # all stack entries. | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | highlight     => Devel::Trepan::Options::default_term(), | 
| 80 |  |  |  |  |  |  | # Use terminal highlight? 0 or undef if off. | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | maxlines      => 1,      # Number of context lines in location, | 
| 83 |  |  |  |  |  |  | maxlist       => 10,     # Number of source lines to list | 
| 84 |  |  |  |  |  |  | maxstack      => 10,     # backtrace limit | 
| 85 |  |  |  |  |  |  | maxstring     => 150,    # Strings which are larger than this | 
| 86 |  |  |  |  |  |  | # will be truncated to this length when | 
| 87 |  |  |  |  |  |  | # printed | 
| 88 | 13 |  | 50 |  |  | 68 | maxwidth      => ($ENV{'COLUMNS'} || 80), | 
| 89 |  |  |  |  |  |  | prompt        => 'trepanpl', # core part of prompt. Additional info like | 
| 90 |  |  |  |  |  |  | # debug nesting and thread added later | 
| 91 |  |  |  |  |  |  | reload        => 0,      # Reread source file if we determine | 
| 92 |  |  |  |  |  |  | # it has changed? | 
| 93 |  |  |  |  |  |  | save_cmdfile  => 0,      # If set, debugger command file to be | 
| 94 |  |  |  |  |  |  | # used on restart | 
| 95 |  |  |  |  |  |  | timer         => 0,      # show elapsed time between events | 
| 96 |  |  |  |  |  |  | traceprint    => 0,      # event tracing printing | 
| 97 |  |  |  |  |  |  | tracebuffer   => 0,      # save events to a trace buffer. | 
| 98 |  |  |  |  |  |  | ##    user_cmd_dir  => File.join(%W(#{Trepan::HOME_DIR} trepan command)), | 
| 99 |  |  |  |  |  |  | ##                                 # User command directory | 
| 100 | 13 |  |  | 13 |  | 96 | }; | 
|  | 13 |  |  |  |  | 31 |  | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | unless (caller) { | 
| 103 |  |  |  |  |  |  | # Show it: | 
| 104 |  |  |  |  |  |  | require Data::Dumper; | 
| 105 |  |  |  |  |  |  | print Data::Dumper::Dumper(DEFAULT_SETTINGS), "\n"; | 
| 106 |  |  |  |  |  |  | print '-' x 20, "\n"; | 
| 107 |  |  |  |  |  |  | print join(', ', @DISPLAY_TYPES), "\n"; | 
| 108 |  |  |  |  |  |  | } | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | 1; |