trepanning 1.93.35 → 2.15.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. checksums.yaml +7 -0
  2. data/ChangeLog +491 -55
  3. data/LICENSE +1 -1
  4. data/NEWS +18 -14
  5. data/README.md +5 -22
  6. data/Rakefile +22 -1
  7. data/app/breakpoint.rb +5 -3
  8. data/app/core.rb +147 -179
  9. data/app/default.rb +47 -46
  10. data/app/file.rb +6 -7
  11. data/app/frame.rb +183 -176
  12. data/app/markdown.rb +2 -9
  13. data/app/options.rb +1 -1
  14. data/app/run.rb +71 -37
  15. data/interface/script.rb +8 -8
  16. data/io.rb +19 -20
  17. data/lib/trepanning.rb +292 -297
  18. data/processor.rb +332 -344
  19. data/processor/breakpoint.rb +98 -96
  20. data/processor/command/base/submgr.rb +9 -9
  21. data/processor/command/break.rb +40 -38
  22. data/processor/command/continue.rb +15 -10
  23. data/processor/command/debug.rb +6 -25
  24. data/processor/command/delete.rb +21 -12
  25. data/processor/command/directory.rb +15 -13
  26. data/processor/command/disable.rb +12 -9
  27. data/processor/command/disassemble.rb +80 -74
  28. data/processor/command/display.rb +15 -12
  29. data/processor/command/down.rb +8 -3
  30. data/processor/command/edit.rb +37 -23
  31. data/processor/command/enable.rb +11 -8
  32. data/processor/command/eval.rb +24 -22
  33. data/processor/command/finish.rb +50 -48
  34. data/processor/command/help.rb +1 -1
  35. data/processor/command/info_subcmd/breakpoints.rb +7 -7
  36. data/processor/command/info_subcmd/files.rb +195 -196
  37. data/processor/command/info_subcmd/frame.rb +7 -4
  38. data/processor/command/info_subcmd/locals.rb +29 -12
  39. data/processor/command/info_subcmd/program.rb +48 -39
  40. data/processor/command/info_subcmd/registers_subcmd/ep.rb +46 -0
  41. data/processor/command/info_subcmd/registers_subcmd/helper.rb +32 -35
  42. data/processor/command/info_subcmd/registers_subcmd/sp.rb +29 -23
  43. data/processor/command/info_subcmd/return.rb +28 -10
  44. data/processor/command/info_subcmd/variables_subcmd/class.rb +3 -3
  45. data/processor/command/info_subcmd/variables_subcmd/constants.rb +77 -0
  46. data/processor/command/info_subcmd/variables_subcmd/globals.rb +7 -7
  47. data/processor/command/info_subcmd/variables_subcmd/instance.rb +68 -22
  48. data/processor/command/info_subcmd/variables_subcmd/locals.rb +148 -67
  49. data/processor/command/list.rb +14 -8
  50. data/processor/command/macro.rb +1 -1
  51. data/processor/command/next.rb +1 -0
  52. data/processor/command/set_subcmd/auto.rb +3 -3
  53. data/processor/command/set_subcmd/different.rb +30 -29
  54. data/processor/command/set_subcmd/events.rb +74 -48
  55. data/processor/command/set_subcmd/max_subcmd/list.rb +12 -5
  56. data/processor/command/set_subcmd/max_subcmd/width.rb +28 -19
  57. data/processor/command/set_subcmd/register.rb +37 -0
  58. data/processor/command/set_subcmd/register_subcmd/pc.rb +67 -0
  59. data/processor/command/set_subcmd/register_subcmd/sp.rb +75 -0
  60. data/processor/command/set_subcmd/reload.rb +12 -10
  61. data/processor/command/set_subcmd/return.rb +68 -44
  62. data/processor/command/shell.rb +3 -2
  63. data/processor/command/show_subcmd/different.rb +17 -14
  64. data/processor/command/show_subcmd/events.rb +25 -25
  65. data/processor/default.rb +1 -1
  66. data/processor/eval.rb +14 -15
  67. data/processor/frame.rb +43 -36
  68. data/processor/help.rb +5 -5
  69. data/processor/hook.rb +26 -29
  70. data/processor/location.rb +54 -51
  71. data/processor/mock.rb +4 -3
  72. data/processor/running.rb +113 -103
  73. data/processor/validate.rb +401 -373
  74. data/test/data/debug.cmd +8 -0
  75. data/test/data/debug.right +13 -0
  76. data/test/data/debugger-stop.right +6 -4
  77. data/test/data/fname-with-blank.cmd +1 -1
  78. data/test/data/fname-with-blank.right +5 -0
  79. data/test/data/pc.cmd +8 -0
  80. data/test/data/pc.right +10 -0
  81. data/test/data/quit.right +3 -1
  82. data/test/data/trace.cmd +2 -2
  83. data/test/data/trace.right +41 -20
  84. data/test/example/assign.rb +6 -0
  85. data/test/functional/fn_helper.rb +11 -17
  86. data/test/functional/test-break-long.rb +15 -16
  87. data/test/functional/test-break.rb +6 -8
  88. data/test/functional/test-condition.rb +8 -10
  89. data/test/functional/test-debugger-call-bug.rb +21 -22
  90. data/test/functional/test-delete.rb +57 -59
  91. data/test/functional/test-eval.rb +101 -103
  92. data/test/functional/test-finish.rb +24 -33
  93. data/test/functional/test-immediate-step-bug.rb +6 -10
  94. data/test/functional/test-next.rb +64 -65
  95. data/test/functional/test-raise.rb +63 -64
  96. data/test/functional/test-recursive-bt.rb +81 -76
  97. data/test/functional/test-remap.rb +6 -7
  98. data/test/functional/test-return.rb +44 -38
  99. data/test/functional/test-step.rb +55 -53
  100. data/test/functional/test-stepbug.rb +6 -9
  101. data/test/functional/test-watchg.rb +40 -39
  102. data/test/integration/test-debug.rb +12 -0
  103. data/test/integration/test-debugger-stop.rb +7 -7
  104. data/test/integration/test-pc.rb +24 -0
  105. data/test/integration/test-trace.rb +1 -1
  106. data/test/unit/cmd-helper.rb +0 -1
  107. data/test/unit/test-app-brkpt.rb +21 -21
  108. data/test/unit/test-app-brkptmgr.rb +7 -8
  109. data/test/unit/test-app-display.rb +3 -4
  110. data/test/unit/test-app-frame.rb +4 -5
  111. data/test/unit/test-base-subsubcmd.rb +2 -2
  112. data/test/unit/test-cmd-break.rb +6 -6
  113. data/test/unit/test-cmd-endisable.rb +7 -6
  114. data/test/unit/test-cmd-parse_list_cmd.rb +24 -24
  115. data/test/unit/test-io-tcpserver.rb +39 -35
  116. data/test/unit/test-proc-default.rb +23 -22
  117. data/test/unit/test-proc-eval.rb +1 -2
  118. data/test/unit/test-proc-frame.rb +8 -9
  119. data/test/unit/test-proc-list.rb +1 -1
  120. data/test/unit/test-proc-location.rb +2 -2
  121. data/test/unit/test-proc-main.rb +10 -10
  122. data/test/unit/test-proc-validate.rb +11 -13
  123. data/test/unit/test-subcmd-help.rb +1 -2
  124. data/trepanning.gemspec +8 -13
  125. metadata +44 -95
  126. data/COPYING +0 -57
  127. data/data/custom_require.rb +0 -44
  128. data/data/perldb.bindings +0 -17
  129. data/data/prelude.rb +0 -38
  130. data/processor/command/info_subcmd/variables_subcmd/constant.rb +0 -41
  131. data/processor/command/raise.rb +0 -48
  132. data/processor/command/set_subcmd/pc.rb +0 -62
  133. data/processor/command/set_subcmd/sp.rb +0 -67
  134. data/processor/eventbuf.rb +0 -133
@@ -1,41 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
- require_relative 'locals'
4
-
5
- class Trepan::Subcommand::InfoVariablesConstant <
6
- Trepan::Subcommand::InfoVariablesLocals
7
- Trepan::Util.suppress_warnings {
8
- Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
- HELP = <<-EOH
10
- #{CMD}
11
- #{CMD} [names]
12
-
13
- Show class constants of the current stack frame.
14
- Normally for each which show both the name and value. If you just
15
- want a list of names add parameter 'names'.
16
- EOH
17
- SHORT_HELP = 'Show class constants via the current stack frame'
18
- MIN_ABBREV = 'co'.size
19
- MIN_ARGS = 0
20
- MAX_ARGS = 1
21
- NEED_STACK = true
22
- }
23
-
24
- def get_names
25
- @proc.debug_eval_no_errmsg('self.class.constants.sort') || []
26
- end
27
-
28
- def run(args)
29
- run_for_type(args, 'constant', @proc.debug_eval('self'))
30
- end
31
- end
32
-
33
- if __FILE__ == $0
34
- # Demo it.
35
- require_relative '../../mock'
36
- cmd =
37
- MockDebugger::subsub_setup(Trepan::Subcommand::InfoVariables,
38
- Trepan::Subcommand::InfoVariablesConstant)
39
- cmd.run(cmd.prefix)
40
- cmd.run(cmd.prefix + ['name'])
41
- end
@@ -1,48 +0,0 @@
1
- # Copyright (C) 2010, 2015 Rocky Bernstein <rockyb@rubyforge.net>
2
- require_relative '../command'
3
- class Trepan::Command::RaiseCommand < Trepan::Command
4
-
5
- unless defined?(HELP)
6
- NAME = File.basename(__FILE__, '.rb')
7
- HELP = <<-HELP
8
- **#{NAME}** [*exception-name*]
9
-
10
- Raise an *execption-name* in the debugged program. If no exception name
11
- is given, raise `RuntimeError`.
12
- HELP
13
-
14
- CATEGORY = 'running'
15
- MAX_ARGS = 1 # Need at most this many
16
- SHORT_HELP = 'Raise an exception in the debugged program'
17
- end
18
-
19
- # This method runs the command
20
- def run(args)
21
- exception =
22
- if args.size > 1
23
- except_str = args[1..-1].join(' ')
24
- # Normally would need x.respond_to? && ..
25
- # but since we catch errors with debug_eval.. not needed.
26
- eval_str = ("%s.ancestors.include?(Exception)" %
27
- [except_str])
28
- unless @proc.debug_eval_no_errmsg(eval_str)
29
- errmsg "\"#{except_str}\" does not inherit Exception."
30
- return
31
- end
32
- @proc.debug_eval_no_errmsg(except_str)
33
- else
34
- RuntimeError
35
- end
36
- @proc.step(0)
37
- @proc.leave_cmd_loop = true
38
- @proc.core.exception = exception
39
- end
40
- end
41
-
42
- if __FILE__ == $0
43
- require_relative '../mock'
44
- dbgr, cmd = MockDebugger::setup
45
- puts cmd.run([cmd.name, 'NotanException'])
46
- puts cmd.run([cmd.name, '[5]'])
47
- puts cmd.run([cmd.name, 'RuntimeError'])
48
- end
@@ -1,62 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright (C) 2012 Rocky Bernstein <rockyb@rubyforge.net>
3
- require_relative '../base/subcmd'
4
-
5
- class Trepan::Subcommand::SetPc < Trepan::Subcommand
6
- unless defined?(HELP)
7
- Trepanning::Subcommand.set_name_prefix(__FILE__, self)
8
- HELP = 'set PC INTEGER-EXPRESSION
9
-
10
- Set VM program-counter register (PC) to INTEGER-EXPRESSION.
11
-
12
- Warning: this is potentially dangerous.
13
- '
14
- SHORT_HELP = 'Set VM program counter (PC)'
15
- IN_LIST = true
16
- MIN_ABBREV = 'pc'.size
17
- end
18
-
19
- def run(args)
20
- # FIXME handle c-return
21
- # unless %w(return c-return).member?(@proc.event)
22
- if args.size < 3
23
- errmsg "Too few arguments - the 'pc' command requires a value"
24
- return
25
- end
26
- new_val_str = args[2..-1].join(' ')
27
- begin
28
- new_val = @proc.debug_eval(new_val_str)
29
- rescue StandardError, ScriptError => e
30
- return
31
- end
32
- msg("Old value was: %s" % @proc.frame.pc_offset.inspect)
33
- @proc.frame.pc_offset = new_val
34
- msg("New value is: %s" % new_val.inspect)
35
- end
36
-
37
- end
38
-
39
- if __FILE__ == $0
40
- # Demo it.
41
- require_relative %w(.. .. mock)
42
- require_relative %w(.. .. subcmd)
43
- name = File.basename(__FILE__, '.rb')
44
-
45
- # FIXME: DRY the below code
46
- dbgr, cmd = MockDebugger::setup('set')
47
- subcommand = Debugger::Subcommand::SetPc.new(cmd)
48
- testcmdMgr = Debugger::Subcmd.new(subcommand)
49
-
50
- def subcommand.msg(message)
51
- puts message
52
- end
53
- def subcommand.msg_nocr(message)
54
- print message
55
- end
56
- def subcommand.errmsg(message)
57
- puts message
58
- end
59
- subcommand.run(%w(20))
60
- name = File.basename(__FILE__, '.rb')
61
- subcommand.summary_help(name)
62
- end
@@ -1,67 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright (C) 2010-2012 Rocky Bernstein <rockyb@rubyforge.net>
3
- require_relative '../base/subcmd'
4
-
5
- class Trepan::Subcommand::SetSp < Trepan::Subcommand
6
- unless defined?(HELP)
7
- Trepanning::Subcommand.set_name_prefix(__FILE__, self)
8
- HELP = 'set sp INTEGER-EXPRESSION
9
-
10
- Set VM stack-pointer register (SP) to INTEGER-EXPRESSION.
11
-
12
- Warning: this is potentially dangerous.
13
- '
14
- SHORT_HELP = 'Set a stack pointer register'
15
- IN_LIST = true
16
- MIN_ABBREV = 'sp'.size
17
- end
18
-
19
- def run(args)
20
- # FIXME handle c-return
21
- # unless %w(return c-return).member?(@proc.event)
22
- if args.size < 4
23
- errmsg "Too few arguments - the 'sp' command requires number and a value"
24
- return
25
- end
26
- msg_on_error = "set SP requires an integer index"
27
- index = @proc.get_an_int(args[2],
28
- :msg_on_error => msg_on_error
29
- )
30
- return unless index
31
- new_val_str = args[3..-1].join(' ')
32
- begin
33
- new_val = @proc.debug_eval(new_val_str)
34
- rescue StandardError, ScriptError => e
35
- return
36
- end
37
- msg("Old value was: %s" % @proc.frame.sp(index).inspect)
38
- @proc.frame.sp_set(index, new_val).inspect
39
- msg("New value is: %s" % new_val.inspect)
40
- end
41
-
42
- end
43
-
44
- if __FILE__ == $0
45
- # Demo it.
46
- require_relative '../../mock'
47
- require_relative '../../subcmd'
48
- name = File.basename(__FILE__, '.rb')
49
-
50
- # FIXME: DRY the below code
51
- dbgr, cmd = MockTrepan::setup('set')
52
- subcommand = Trepan::Subcommand::SetSp.new(cmd)
53
- testcmdMgr = Trepan::Subcmd.new(subcommand)
54
-
55
- def subcommand.msg(message)
56
- puts message
57
- end
58
- def subcommand.msg_nocr(message)
59
- print message
60
- end
61
- def subcommand.errmsg(message)
62
- puts message
63
- end
64
- subcommand.run(%w(20))
65
- name = File.basename(__FILE__, '.rb')
66
- subcommand.summary_help(name)
67
- end
@@ -1,133 +0,0 @@
1
- # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
- # For recording hook events in a buffer for review later. Make use of
3
- # Trace::Buffer for this prupose.
4
- require 'trace'
5
- require 'linecache'
6
- require_relative 'virtual'
7
-
8
- class Trepan
9
- class CmdProcessor < VirtualCmdProcessor
10
-
11
- attr_reader :eventbuf
12
- attr_reader :event_tracefilter
13
-
14
- def eventbuf_initialize(size=100)
15
- @eventbuf = Trace::EventBuffer.new(size)
16
- # @event_tracefilter = Trace::Filter.new
17
- end
18
-
19
- # def event_processor(event, frame, arg=nil)
20
- # @eventbuf.append(event, frame, arg)
21
- # end
22
-
23
- # Print event buffer entries from FROM up to TO try to stay within
24
- # WIDTH. We show source lines only the first time they are
25
- # encountered. Also we use separators to indicate points that the
26
- # debugger has stopped at.
27
- def eventbuf_print(from=nil, to=nil, width=80)
28
- sep = '-' * ((width - 7) / 2)
29
- last_container, last_location = nil, nil
30
- if from == nil || !@eventbuf.marks[-1]
31
- mark_index = 0
32
- else
33
- mark_index = @eventbuf.marks.size-1
34
- translated_from = @eventbuf.zero_pos + from
35
- @eventbuf.marks.each_with_index do
36
- |m, i|
37
- if m > translated_from
38
- mark_index = [0, i-1].max
39
- break
40
- elsif m == translated_from
41
- mark_index = i
42
- break
43
- end
44
- end
45
- end
46
-
47
- nextmark = @eventbuf.marks[mark_index]
48
- @eventbuf.each_with_index(from, to) do |e, i|
49
- if nextmark
50
- if nextmark == i
51
- msg "#{sep} %5d #{sep}" % (mark_index - @eventbuf.marks.size)
52
- mark_index += 1 if mark_index < @eventbuf.marks.size - 1
53
- nextmark = @eventbuf.marks[mark_index]
54
- elsif nextmark < i
55
- mark_index += 1 if mark_index < @eventbuf.marks.size - 1
56
- nextmark = @eventbuf.marks[mark_index]
57
- end
58
- end
59
- last_container, last_location, mess =
60
- format_eventbuf_entry(e, last_container, last_location) if e
61
- msg mess
62
- end
63
- end
64
-
65
- # Show event buffer entry. If the location is the same as the previous
66
- # location we don't show the duplicated location information.
67
- def format_eventbuf_entry(item, last_container, last_location)
68
- container =
69
- if item.source_container[0] == 'file'
70
- item.source_container[1]
71
- else
72
- item.source_container
73
- end
74
-
75
- location =
76
- if 1 == item.source_location.size
77
- item.source_location[0]
78
- else
79
- item.source_location
80
- end
81
-
82
- same_loc = (container == last_container && location == last_location)
83
- mess = "#{item.event} "
84
- mess +=
85
- if %w(c-return return).member?(item.event)
86
- "#{item.method} => #{item.arg.inspect}" + (same_loc ? '' : "\n\t")
87
- elsif 'c-call' == item.event
88
- "#{item.method} "
89
- else
90
- "#{item.type} #{item.method} "
91
- end
92
- mess += "#{container} at line #{location}" unless same_loc
93
-
94
- if item.iseq # && long_format
95
- mess += "\n\tVM offset #{item.pc_offset}"
96
- end
97
- unless same_loc
98
- text = LineCache::getline(container, location,
99
- :reload_on_change => @reload_on_change)
100
- mess += ":\n #{text.chomp}" if text
101
- end
102
- return container, location, mess
103
- end
104
-
105
- # FIXME: multiple hook mechanism needs work.
106
- # def start_capture
107
- # @event_tracefilter.add_trace_func(method(:event_processor).to_proc,
108
- # Trace::DEFAULT_EVENT_MASK)
109
- # end
110
-
111
- # def stop_capture
112
- # @event_tracefilter.set_trace_func(nil)
113
- # end
114
-
115
- end
116
- end
117
- if __FILE__ == $0
118
- # Demo it.
119
- cmdproc = Trepan::CmdProcessor.new([])
120
- cmdproc.eventbuf_initialize(5)
121
-
122
- def cmdproc.msg(mess)
123
- puts mess
124
- end
125
- # cmdproc.start_capture
126
- # z=5
127
- # z.times do |i|
128
- # x = i
129
- # y = x+2
130
- # end
131
- # cmdproc.stop_capture
132
- cmdproc.eventbuf_print
133
- end