trepanning 1.93.35 → 2.15.33

Sign up to get free protection for your applications and to get access to all the features.
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,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'test/unit'
3
- require 'trace'
4
3
  require_relative 'fn_helper'
5
4
 
6
5
  class TestRemap < Test::Unit::TestCase
@@ -8,19 +7,19 @@ class TestRemap < Test::Unit::TestCase
8
7
  include FnTestHelper
9
8
 
10
9
  def test_remap
11
- skip "Not sure what this one was supposed to test - Investigate."
10
+ skip 'needs to be reworked'
12
11
  cmds = [
13
12
  'step',
14
13
  'list',
15
14
  ]
16
15
  d = strarray_setup(cmds)
17
- d.start
16
+ d.start(true)
18
17
  ##############################
19
18
  require 'date'
20
19
  ##############################
21
20
  d.stop
22
21
  out = [
23
- '-- ',
22
+ 'line ',
24
23
  "require 'date'",
25
24
  'METHOD TestRemap#require(path)',
26
25
  '-> ',
@@ -35,16 +34,16 @@ class TestRemap < Test::Unit::TestCase
35
34
  ' 27 ',
36
35
  ' 28 -> def require(path) # :doc:',
37
36
  ' 29 gem_original_require path',
38
- '-- ',
37
+ 'line ',
39
38
  'gem_original_require path',
40
39
  '<- ',
41
40
  'R=> false',
42
41
  'end',
43
- '-- ',
42
+ 'line ',
44
43
  'd.stop'
45
44
  ]
46
45
  compare_output(out, d, cmds)
47
46
 
48
47
  end
49
-
48
+
50
49
  end
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'test/unit'
3
- require 'trace'
4
3
  require_relative 'fn_helper'
5
4
 
6
5
  class TestRaise < Test::Unit::TestCase
@@ -10,10 +9,12 @@ class TestRaise < Test::Unit::TestCase
10
9
  def test_return
11
10
 
12
11
  cmds = [
12
+ 'set max width 80',
13
+ 'set different off',
13
14
  'set events call, return',
14
- 'step',
15
+ 'step-',
15
16
  'info args',
16
- 'step',
17
+ 'step-',
17
18
  'info return',
18
19
  'set return 10',
19
20
  'set events line',
@@ -21,80 +22,85 @@ class TestRaise < Test::Unit::TestCase
21
22
  'pr foo_retval',
22
23
  ]
23
24
  d = strarray_setup(cmds)
24
- d.start
25
25
  ##############################
26
- x = 1
27
26
  def foo(arg)
28
27
  5
29
28
  end
29
+ d.start(true)
30
+ x = 1
30
31
  foo_retval = foo('ho')
31
32
  z = 3
32
33
  ##############################
33
34
  d.stop
34
- out = ['-- ',
35
+ out = ['line ',
35
36
  'x = 1',
36
- 'Trace events we may stop on:',
37
- "\tbrkpt, call, return",
38
- 'METHOD TestRaise#foo(arg)',
39
- '-> ',
40
- 'def foo(arg)',
37
+ 'max width is 80.',
38
+ 'different is off.',
39
+ "Trace events we may stop on:\n----------------------------",
40
+ ' call return',
41
+ 'call ',
42
+ '5',
41
43
  "arg = \"ho\"",
42
- '<- ',
44
+ "Values may have change from the initial call values.",
45
+ 'return ',
43
46
  'R=> 5',
44
47
  'end',
48
+ 'Return class: Fixnum',
45
49
  'Return value: 5',
46
- 'Return value was: 5',
50
+ 'Old value was: 5',
47
51
  'New value is: 10',
48
- 'Trace events we may stop on:',
49
- "\tbrkpt, line",
50
- '-- ',
52
+ "Trace events we may stop on:\n----------------------------",
53
+ ' line',
54
+ 'line ',
51
55
  'z = 3',
52
56
  '10',
53
- '-- ',
54
- 'd.stop']
57
+ 'line ',
58
+ 'd.stop',
59
+ "line ",
60
+ 'RubyVM::Frame::get.trace_off = true'
61
+ ]
55
62
  compare_output(out, d, cmds)
56
63
 
57
- # Try C function
64
+ # Try a C function
58
65
  cmds = [
66
+ 'set max width 80',
59
67
  'set different off',
60
68
  'set events c_call, c_return',
61
69
  'step',
62
70
  'info args',
63
71
  'step',
64
- 'info return',
65
- 'set return "abc"',
66
72
  'set events line',
67
73
  'step',
68
74
  'pr result',
69
75
  ]
70
76
  d = strarray_setup(cmds)
71
- d.start
77
+ d.start(true)
72
78
  ##############################
73
79
  a = 1
74
80
  result = File.basename('/a/b.c')
75
81
  ##############################
76
- d.stop # ({:remove => true})
77
- out = ["-- ",
82
+ d.stop
83
+ out = ["line ",
78
84
  "a = 1",
85
+ 'max width is 80.',
79
86
  'different is off.',
80
- "Trace events we may stop on:",
81
- "\tbrkpt, c_call, c_return",
82
- "CFUNC File#basename(\"/a/b.c\")",
83
- "C> ",
87
+ "Trace events we may stop on:\n----------------------------",
88
+ " c_call c_return",
89
+ "c_call ",
84
90
  "result = File.basename('/a/b.c')",
85
91
  "1: \"/a/b.c\"",
86
- "<C ",
92
+ "c_return ",
87
93
  "R=> \"b.c\"",
88
94
  "result = File.basename('/a/b.c')",
89
- "Return value: \"b.c\"",
90
- "Return value was: \"b.c\"",
91
- "New value is: \"abc\"",
92
- "Trace events we may stop on:",
93
- "\tbrkpt, line",
94
- "-- ",
95
- "d.stop # ({:remove => true})",
96
- '"abc"']
95
+ "Trace events we may stop on:\n----------------------------",
96
+ " line",
97
+ "line ",
98
+ 'd.stop',
99
+ "\"b.c\"",
100
+ "line ",
101
+ "RubyVM::Frame::get.trace_off = true",
102
+ ]
97
103
  compare_output(out, d, cmds)
98
104
  end
99
-
105
+
100
106
  end
@@ -1,46 +1,44 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'test/unit'
3
- require 'trace'
4
3
  require_relative 'fn_helper'
5
4
 
6
5
  class TestStep < Test::Unit::TestCase
7
6
 
8
7
  include FnTestHelper
9
- include Trace
10
8
 
11
- def test_step_same_level
9
+ def no_test_step_same_level
10
+ skip "FIXME"
12
11
 
13
12
  # See that we can step with parameter which is the same as 'step 1'
14
13
  cmds = ['step', 'continue']
15
14
  d = strarray_setup(cmds)
16
- d.core.step_events = TEST_STEP_EVENT_MASK
17
15
 
18
- d.start
16
+ d.start(true)
19
17
  ########### t1 ###############
20
18
  x = 5
21
19
  y = 6
22
20
  ##############################
23
21
  d.stop
24
- out = ['-- ', 'x = 5', '-- ', 'y = 6']
22
+ out = ['line ', 'x = 5', 'line ', 'y = 6']
25
23
  compare_output(out, d, cmds)
26
24
 
27
25
  # See that we can step with a computed count value
28
26
  cmds = ['step 5-3', 'continue']
29
27
  d = strarray_setup(cmds)
30
- d.start
28
+ d.start(true)
31
29
  ########### t2 ###############
32
30
  x = 5
33
31
  y = 6
34
32
  z = 7
35
33
  ##############################
36
34
  d.stop # ({:remove => true})
37
- out = ['-- ', 'x = 5', '-- ', 'z = 7']
35
+ out = ['line ', 'x = 5', 'line ', 'z = 7']
38
36
  compare_output(out, d, cmds)
39
-
37
+
40
38
  # Test step>
41
39
  cmds = ['step>', 'continue']
42
40
  d = strarray_setup(cmds)
43
- d.start
41
+ d.start(true)
44
42
  ########### t3 ###############
45
43
  x = 5
46
44
  def foo()
@@ -49,13 +47,13 @@ class TestStep < Test::Unit::TestCase
49
47
  foo
50
48
  ##############################
51
49
  d.stop # {:remove => true})
52
- out = ['-- ', 'x = 5', 'METHOD TestStep#foo()', '-> ', 'def foo()']
50
+ out = ['line ', 'x = 5', 'METHOD TestStep#foo()', 'call ', 'def foo()']
53
51
  compare_output(out, d, cmds)
54
-
52
+
55
53
  # Test step!
56
54
  cmds = ['step!', 'continue']
57
55
  d = strarray_setup(cmds)
58
- d.start()
56
+ d.start(true)
59
57
  ########### t4 ###############
60
58
  x = 5
61
59
  begin
@@ -65,16 +63,16 @@ class TestStep < Test::Unit::TestCase
65
63
  end
66
64
  ##############################
67
65
  d.stop # ({:remove => true})
68
- out = ['-- ', 'x = 5',
69
- '#<ZeroDivisionError: divided by 0>',
66
+ out = ['line ', 'x = 5',
67
+ '#<ZeroDivisionError: divided by 0>',
70
68
  '!! ', 'z = 1/0']
71
69
  compare_output(out, d, cmds)
72
-
70
+
73
71
  # Test "step" with sets of events. Part 1
74
72
  cmds = ['set events call raise',
75
73
  'step', 's!']
76
74
  d = strarray_setup(cmds)
77
- d.start()
75
+ d.start(true)
78
76
  ########### t5 ###############
79
77
  x = 5
80
78
  def foo1
@@ -86,12 +84,12 @@ class TestStep < Test::Unit::TestCase
86
84
  z = 1
87
85
  ##############################
88
86
  d.stop # ({:remove => true})
89
- out = ['-- ',
87
+ out = ['line ',
90
88
  'x = 5',
91
89
  'Trace events we may stop on:',
92
90
  "\tbrkpt, call, raise",
93
91
  'METHOD TestStep#foo1()',
94
- '-> ',
92
+ 'call ',
95
93
  'def foo1',
96
94
  '#<Exception: Exception>',
97
95
  '!! ',
@@ -100,12 +98,12 @@ class TestStep < Test::Unit::TestCase
100
98
  got = filter_line_cmd(d.intf[-1].output.output)
101
99
  out.pop if got.size+1 == out.size
102
100
  compare_output(out, d, cmds)
103
-
101
+
104
102
  # Test "step" will sets of events. Part 2
105
103
  cmds = ['step> 1+0',
106
104
  'step! 1', 'continue']
107
105
  d = strarray_setup(cmds)
108
- d.start()
106
+ d.start(true)
109
107
  ########### t6 ###############
110
108
  x = 5
111
109
  begin
@@ -119,38 +117,39 @@ class TestStep < Test::Unit::TestCase
119
117
  z = 1
120
118
  ##############################
121
119
  d.stop({:remove => true})
122
- out = ['-- ',
120
+ out = ['line ',
123
121
  'x = 5',
124
122
  'METHOD TestStep#foo2()',
125
- '-> ',
123
+ 'call ',
126
124
  'def foo2()',
127
125
  'TestStep',
128
126
  '!! ',
129
127
  'raise Exception']
130
-
128
+
131
129
  end
132
130
 
133
131
  def test_step_between_fn
132
+ skip("FIXME")
134
133
 
135
134
  # Step into and out of a function
136
135
  def sqr(x)
137
136
  y = x * x
138
137
  end
139
138
  cmds = %w(step) * 4 + %w(continue)
140
- out = ['-- ',
139
+ out = ['line ',
141
140
  'x = sqr(4)',
142
141
  'METHOD TestStep#sqr(x)',
143
- '-> ',
142
+ 'call ',
144
143
  'def sqr(x)',
145
- '-- ',
144
+ 'line ',
146
145
  'y = x * x',
147
- '<- ',
146
+ 'return ',
148
147
  'R=> 16',
149
148
  'end',
150
- '-- ',
149
+ 'line ',
151
150
  'y = 5']
152
151
  d = strarray_setup(cmds)
153
- d.start
152
+ d.start(true)
154
153
  ########### t7 ###############
155
154
  x = sqr(4)
156
155
  y = 5
@@ -160,18 +159,18 @@ class TestStep < Test::Unit::TestCase
160
159
 
161
160
  cmds = ['set events call return',
162
161
  'step', 'step', 'continue']
163
- out = ['-- ',
162
+ out = ['line ',
164
163
  'x = sqr(4)',
165
164
  'Trace events we may stop on:',
166
165
  "\tbrkpt, call, return",
167
166
  'METHOD TestStep#sqr(x)',
168
- '-> ',
167
+ 'call ',
169
168
  'def sqr(x)',
170
- '<- ',
169
+ 'return ',
171
170
  'R=> 16',
172
171
  'end']
173
172
  d = strarray_setup(cmds)
174
- d.start
173
+ d.start(true)
175
174
  ########### t8 ###############
176
175
  x = sqr(4)
177
176
  y = 5
@@ -181,6 +180,7 @@ class TestStep < Test::Unit::TestCase
181
180
  end
182
181
 
183
182
  def test_step_in_exception
183
+ skip "FIXME"
184
184
  def boom(x)
185
185
  y = 0/x
186
186
  end
@@ -190,17 +190,17 @@ class TestStep < Test::Unit::TestCase
190
190
  end
191
191
  cmds = %w(step! continue)
192
192
  d = strarray_setup(cmds)
193
- begin
194
- d.start()
193
+ begin
194
+ d.start(true)
195
195
  x = bad(0)
196
196
  assert_equal(false, true, 'should have raised an exception')
197
197
  rescue ZeroDivisionError
198
198
  assert true, 'Got the exception'
199
199
  ensure
200
- d.stop({:remove => true})
200
+ d.stop
201
201
  end
202
-
203
- out = ['-- ',
202
+
203
+ out = ['line ',
204
204
  'x = bad(0)', # line event
205
205
  '#<ZeroDivisionError: divided by 0>',
206
206
  '!! ', # exception event
@@ -210,39 +210,41 @@ class TestStep < Test::Unit::TestCase
210
210
  end
211
211
 
212
212
  def test_step_event
213
+ skip "FIXME"
213
214
 
214
215
  def fact(x)
215
216
  return 1 if x <= 1
216
217
  x = x * fact(x-1)
217
218
  return x
218
219
  end
219
- cmds = ['step<', '1 == x', 'continue']
220
+ cmds = ['step<', '1 == x', 'continue']
220
221
  d = strarray_setup(cmds)
221
- d.start
222
+ d.start(true)
222
223
  ########### t9 ###############
223
224
  x = fact(4)
224
225
  y = 5
225
226
  ##############################
226
227
  d.stop # ({:remove => true})
227
- out = ['-- ',
228
- 'x = fact(4)',
229
- '<- ',
230
- 'R=> 1',
231
- 'return 1 if x <= 1',
228
+ out = ['line ',
229
+ 'x = fact(4)',
230
+ 'return ',
231
+ 'R=> 1',
232
+ 'return 1 if x <= 1',
232
233
  'D=> true']
233
234
  compare_output(out, d, cmds)
234
235
  end
235
236
 
236
237
  def test_step_into_fun
238
+ skip "FIXME"
237
239
 
238
240
  # Bug was that we were stopping at a VM instruction before the fn
239
241
  # call proper ('bar' below), and not getting a line number for it.
240
242
  # So a subsequent 'step' when 'set different' in effect was to stay
241
243
  # at the same place at the function call.
242
244
  cmds = ['set different', 'set events call, class, line, return',
243
- 'step', 'step', 'step', 'step', 'continue']
245
+ 'step', 'step', 'step', 'step', 'continue']
244
246
  d = strarray_setup(cmds)
245
- d.start
247
+ d.start(true)
246
248
  ########### t10 ###############
247
249
  def bar
248
250
  return 1
@@ -255,19 +257,19 @@ class TestStep < Test::Unit::TestCase
255
257
  foo
256
258
  ##############################
257
259
  d.stop # ({:remove => true})
258
- out = ['-- ',
260
+ out = ['line ',
259
261
  'def bar',
260
262
  'different is on.',
261
263
  'Trace events we may stop on:',
262
264
  "\tbrkpt, call, class, line, return",
263
- '-- ',
265
+ 'line ',
264
266
  'def foo',
265
- '-- ',
267
+ 'line ',
266
268
  'foo',
267
269
  'METHOD TestStep#foo()',
268
- '-> ',
270
+ 'call ',
269
271
  'def foo',
270
- '-- ',
272
+ 'line ',
271
273
  'bar']
272
274
  compare_output(out, d, cmds)
273
275
  end