trepanning 0.1.2 → 0.1.3

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 (123) hide show
  1. data/ChangeLog +354 -0
  2. data/NEWS +21 -0
  3. data/Rakefile +27 -20
  4. data/app/cmd_parse.kpeg +20 -4
  5. data/app/cmd_parse.rb +11 -10
  6. data/app/cmd_parser.rb +119 -55
  7. data/app/complete.rb +1 -0
  8. data/app/core.rb +3 -3
  9. data/app/disassemble.rb +13 -3
  10. data/app/file.rb +2 -1
  11. data/app/frame.rb +3 -1
  12. data/app/mock.rb +3 -0
  13. data/app/options.rb +48 -31
  14. data/app/util.rb +50 -0
  15. data/interface/base_intf.rb +4 -0
  16. data/interface/client.rb +4 -0
  17. data/interface/script.rb +1 -1
  18. data/interface/server.rb +4 -0
  19. data/interface/user.rb +5 -0
  20. data/io/input.rb +3 -2
  21. data/io/null_output.rb +7 -1
  22. data/processor/breakpoint.rb +3 -2
  23. data/processor/command/base/subcmd.rb +1 -1
  24. data/processor/command/base/submgr.rb +4 -1
  25. data/processor/command/base/subsubcmd.rb +2 -2
  26. data/processor/command/base/subsubmgr.rb +1 -1
  27. data/processor/command/break.rb +7 -3
  28. data/processor/command/complete.rb +1 -0
  29. data/processor/command/continue.rb +1 -1
  30. data/processor/command/disassemble.rb +1 -1
  31. data/processor/command/edit.rb +35 -14
  32. data/processor/command/enable.rb +5 -3
  33. data/processor/command/eval.rb +35 -14
  34. data/processor/command/exit.rb +2 -0
  35. data/processor/command/help.rb +0 -9
  36. data/processor/command/help/command.txt +37 -27
  37. data/processor/command/help/examples.txt +16 -0
  38. data/processor/command/help/suffixes.txt +17 -0
  39. data/processor/command/info.rb +1 -1
  40. data/processor/command/info_subcmd/args.rb +7 -13
  41. data/processor/command/info_subcmd/breakpoints.rb +8 -2
  42. data/processor/command/info_subcmd/frame.rb +2 -0
  43. data/processor/command/info_subcmd/globals.rb +63 -0
  44. data/processor/command/info_subcmd/iseq.rb +3 -1
  45. data/processor/command/info_subcmd/locals.rb +16 -15
  46. data/processor/command/{show_subcmd → info_subcmd}/macro.rb +7 -7
  47. data/processor/command/info_subcmd/program.rb +2 -0
  48. data/processor/command/info_subcmd/registers.rb +5 -1
  49. data/processor/command/info_subcmd/registers_subcmd/dfp.rb +2 -3
  50. data/processor/command/info_subcmd/registers_subcmd/helper.rb +8 -9
  51. data/processor/command/info_subcmd/registers_subcmd/lfp.rb +10 -5
  52. data/processor/command/info_subcmd/registers_subcmd/pc.rb +9 -4
  53. data/processor/command/info_subcmd/registers_subcmd/sp.rb +4 -5
  54. data/processor/command/info_subcmd/ruby.rb +3 -1
  55. data/processor/command/info_subcmd/source.rb +78 -0
  56. data/processor/command/info_subcmd/stack.rb +23 -0
  57. data/processor/command/kill.rb +4 -6
  58. data/processor/command/list.rb +118 -120
  59. data/processor/command/macro.rb +1 -1
  60. data/processor/command/parsetree.rb +56 -0
  61. data/processor/command/pp.rb +40 -0
  62. data/processor/command/pr.rb +1 -2
  63. data/processor/command/quit.rb +2 -1
  64. data/processor/command/set_subcmd/abbrev.rb +24 -0
  65. data/processor/command/set_subcmd/auto_subcmd/eval.rb +1 -2
  66. data/processor/command/set_subcmd/auto_subcmd/irb.rb +2 -3
  67. data/processor/command/set_subcmd/auto_subcmd/list.rb +2 -3
  68. data/processor/command/set_subcmd/highlight.rb +8 -2
  69. data/processor/command/set_subcmd/reload.rb +41 -0
  70. data/processor/command/set_subcmd/timer.rb +8 -18
  71. data/processor/command/set_subcmd/trace.rb +2 -2
  72. data/processor/command/set_subcmd/trace_subcmd/buffer.rb +2 -2
  73. data/processor/command/set_subcmd/trace_subcmd/print.rb +3 -3
  74. data/processor/command/{irb.rb → shell.rb} +9 -6
  75. data/processor/command/show_subcmd/abbrev.rb +19 -0
  76. data/processor/command/show_subcmd/directories.rb +21 -0
  77. data/processor/command/show_subcmd/hidelevel.rb +1 -1
  78. data/processor/command/show_subcmd/highlight.rb +2 -1
  79. data/processor/command/show_subcmd/reload.rb +17 -0
  80. data/processor/command/show_subcmd/timer.rb +17 -0
  81. data/processor/command/show_subcmd/trace_subcmd/buffer.rb +1 -1
  82. data/processor/command/source.rb +15 -14
  83. data/processor/command/tbreak.rb +20 -0
  84. data/processor/command/watchg.rb +114 -0
  85. data/processor/default.rb +43 -41
  86. data/processor/display.rb +3 -2
  87. data/processor/eval.rb +5 -3
  88. data/processor/eventbuf.rb +3 -2
  89. data/processor/frame.rb +12 -3
  90. data/processor/hook.rb +3 -2
  91. data/processor/load_cmds.rb +186 -179
  92. data/processor/location.rb +154 -159
  93. data/processor/main.rb +44 -16
  94. data/processor/mock.rb +0 -11
  95. data/processor/msg.rb +3 -1
  96. data/processor/running.rb +3 -2
  97. data/processor/validate.rb +25 -4
  98. data/processor/virtual.rb +32 -0
  99. data/test/data/debugger-stop.right +1 -0
  100. data/test/data/fname-with-blank.right +1 -0
  101. data/test/example/gcd.rb +1 -0
  102. data/test/functional/{test-trace-var.rb → test-watchg.rb} +15 -4
  103. data/test/unit/cmd-helper.rb +0 -3
  104. data/test/unit/test-app-cmd_parser.rb +2 -2
  105. data/test/unit/test-app-file.rb +1 -0
  106. data/test/unit/test-app-frame.rb +1 -1
  107. data/test/unit/test-app-util.rb +21 -0
  108. data/test/unit/test-base-cmd.rb +4 -6
  109. data/test/unit/test-base-subcmd.rb +1 -4
  110. data/test/unit/test-base-submgr.rb +1 -2
  111. data/test/unit/test-base-subsubcmd.rb +0 -4
  112. data/test/unit/test-cmd-edit.rb +33 -0
  113. data/test/unit/test-cmd-parse_list_cmd.rb +33 -0
  114. data/test/unit/test-completion.rb +1 -1
  115. data/test/unit/test-proc-frame.rb +4 -1
  116. data/test/unit/test-proc-load_cmds.rb +2 -1
  117. data/test/unit/test-proc-location.rb +9 -26
  118. data/test/unit/test-proc-main.rb +1 -4
  119. data/test/unit/test-proc-validate.rb +28 -18
  120. data/test/unit/test-subcmd-help.rb +0 -4
  121. data/trepanning.gemspec +1 -1
  122. metadata +27 -10
  123. data/processor/command/set_subcmd/trace_subcmd/var.rb +0 -57
data/app/cmd_parse.kpeg CHANGED
@@ -16,6 +16,19 @@
16
16
  # Structure to hold list information
17
17
  List = Struct.new(:position, :num)
18
18
 
19
+ DEFAULT_OPTS = {
20
+ :debug=>false,
21
+ :file_exists_proc => Proc.new{|filename|
22
+ File.readable?(filename) && !File.directory?(filename)
23
+ }
24
+ }
25
+ def initialize(str, opts={})
26
+ @opts = DEFAULT_OPTS.merge(opts)
27
+ setup_parser(str, opts[:debug])
28
+ @file_exists_proc = @opts[:file_exists_proc]
29
+ end
30
+
31
+
19
32
  }
20
33
  #####################################################
21
34
 
@@ -185,10 +198,10 @@ position =
185
198
 
186
199
  location =
187
200
  position
188
- | <filename>:file &{ File.exist?(file) } file_pos_sep position:pos {
201
+ | <filename>:file &{ @file_exists_proc.call(file) } file_pos_sep position:pos {
189
202
  Position.new(:file, file, pos.position_type, pos.position)
190
203
  }
191
- | <filename>:file &{ File.exist?(file) } {
204
+ | <filename>:file &{ @file_exists_proc.call(file) } {
192
205
  Position.new(:file, file, nil, nil)
193
206
  }
194
207
  | class_module_chain?:fn file_pos_sep position:pos {
@@ -215,7 +228,10 @@ breakpoint_stmt = location:loc - if_unless:iu - condition:cond {
215
228
  # Note that the first word "list", "list>" or handled in
216
229
  # the command. Also, "list" with nothing else is
217
230
  # handled there as well
218
- list_special_targets = <'.' '-'> { text }
219
- list_stmt = (list_special_target | location):loc - (integer:int)? {
231
+ list_special_targets = <'.' | '-'> { text }
232
+ list_stmt = (list_special_targets | location):loc - (integer:int)? {
220
233
  List.new(loc, int)
234
+ }
235
+ | (list_special_targets | location):loc {
236
+ List.new(loc, nil)
221
237
  }
data/app/cmd_parse.rb CHANGED
@@ -5,6 +5,7 @@ require_relative 'cmd_parser'
5
5
  class Trepan
6
6
  module CmdParser
7
7
 
8
+ module_function
8
9
  # Given a KPeg parse object, return the method of that parse or raise a
9
10
  # Name error if we can't find a method. parent_class is the parent class of
10
11
  # the object we've found so far and "binding" is used if we need
@@ -111,28 +112,28 @@ class Trepan
111
112
  end
112
113
  end
113
114
 
114
- def parse_terminal(terminal_name, loc_str)
115
- @cp ? @cp.setup_parser(loc_str) : @cp = CmdParse.new(loc_str)
115
+ def parse_terminal(terminal_name, loc_str, opts={})
116
+ @cp ? @cp.setup_parser(loc_str) : @cp = CmdParse.new(loc_str, opts)
116
117
  @cp.send(terminal_name) ? @cp : nil
117
118
  end
118
119
 
119
- def parse_location(loc_str)
120
- parse = parse_terminal(:_location, loc_str)
120
+ def parse_location(loc_str, opts={})
121
+ parse = parse_terminal(:_location, loc_str, opts)
121
122
  parse ? parse.result : nil
122
123
  end
123
124
 
124
- def parse_breakpoint(str)
125
- parse = parse_terminal(:_breakpoint_stmt, str)
125
+ def parse_breakpoint(str, opts={})
126
+ parse = parse_terminal(:_breakpoint_stmt, str, opts)
126
127
  parse ? parse.result : nil
127
128
  end
128
129
 
129
- def parse_breakpoint_no_condition(str)
130
- parse = parse_terminal(:_breakpoint_stmt_no_condition, str)
130
+ def parse_breakpoint_no_condition(str, opts={})
131
+ parse = parse_terminal(:_breakpoint_stmt_no_condition, str, opts)
131
132
  parse ? parse.result : nil
132
133
  end
133
134
 
134
- def parse_list_cmd(str)
135
- parse = parse_terminal(:_list_stmt, str)
135
+ def parse_list(str, opts={})
136
+ parse = parse_terminal(:_list_stmt, str, opts)
136
137
  parse ? parse.result : nil
137
138
  end
138
139
  end
data/app/cmd_parser.rb CHANGED
@@ -274,6 +274,7 @@ class CmdParse
274
274
 
275
275
  #####################################################
276
276
  # Structure to hold composite method names
277
+ unless defined? SymbolEntry
277
278
  SymbolEntry = Struct.new(:type, :name, :chain)
278
279
 
279
280
 
@@ -287,6 +288,21 @@ class CmdParse
287
288
  # Structure to hold list information
288
289
  List = Struct.new(:position, :num)
289
290
 
291
+ DEFAULT_OPTS = {
292
+ :debug=>false,
293
+ :file_exists_proc => Proc.new{|filename|
294
+ File.readable?(filename) && !File.directory?(filename)
295
+ }
296
+ }
297
+ end
298
+
299
+ def initialize(str, opts={})
300
+ @opts = DEFAULT_OPTS.merge(opts)
301
+ setup_parser(str, opts[:debug])
302
+ @file_exists_proc = @opts[:file_exists_proc]
303
+ end
304
+
305
+
290
306
 
291
307
 
292
308
 
@@ -1436,7 +1452,7 @@ class CmdParse
1436
1452
  return _tmp
1437
1453
  end
1438
1454
 
1439
- # location = (position | < filename >:file &{ File.exist?(file) } file_pos_sep position:pos { Position.new(:file, file, pos.position_type, pos.position) } | < filename >:file &{ File.exist?(file) } { Position.new(:file, file, nil, nil) } | class_module_chain?:fn file_pos_sep position:pos { Position.new(:fn, fn, pos.position_type, pos.position) } | class_module_chain?:fn { Position.new(:fn, fn, nil, nil) })
1455
+ # location = (position | < filename >:file &{ @file_exists_proc.call(file) } file_pos_sep position:pos { Position.new(:file, file, pos.position_type, pos.position) } | < filename >:file &{ @file_exists_proc.call(file) } { Position.new(:file, file, nil, nil) } | class_module_chain?:fn file_pos_sep position:pos { Position.new(:fn, fn, pos.position_type, pos.position) } | class_module_chain?:fn { Position.new(:fn, fn, nil, nil) })
1440
1456
  def _location
1441
1457
 
1442
1458
  _save = self.pos
@@ -1458,7 +1474,7 @@ class CmdParse
1458
1474
  break
1459
1475
  end
1460
1476
  _save2 = self.pos
1461
- _tmp = begin; File.exist?(file) ; end
1477
+ _tmp = begin; @file_exists_proc.call(file) ; end
1462
1478
  self.pos = _save2
1463
1479
  unless _tmp
1464
1480
  self.pos = _save1
@@ -1501,7 +1517,7 @@ class CmdParse
1501
1517
  break
1502
1518
  end
1503
1519
  _save4 = self.pos
1504
- _tmp = begin; File.exist?(file) ; end
1520
+ _tmp = begin; @file_exists_proc.call(file) ; end
1505
1521
  self.pos = _save4
1506
1522
  unless _tmp
1507
1523
  self.pos = _save3
@@ -1737,7 +1753,7 @@ class CmdParse
1737
1753
  return _tmp
1738
1754
  end
1739
1755
 
1740
- # list_special_targets = < "." "-" > { text }
1756
+ # list_special_targets = < ("." | "-") > { text }
1741
1757
  def _list_special_targets
1742
1758
 
1743
1759
  _save = self.pos
@@ -1745,18 +1761,15 @@ class CmdParse
1745
1761
  _text_start = self.pos
1746
1762
 
1747
1763
  _save1 = self.pos
1748
- while true # sequence
1764
+ while true # choice
1749
1765
  _tmp = match_string(".")
1750
- unless _tmp
1751
- self.pos = _save1
1752
- break
1753
- end
1766
+ break if _tmp
1767
+ self.pos = _save1
1754
1768
  _tmp = match_string("-")
1755
- unless _tmp
1756
- self.pos = _save1
1757
- end
1769
+ break if _tmp
1770
+ self.pos = _save1
1758
1771
  break
1759
- end # end sequence
1772
+ end # end choice
1760
1773
 
1761
1774
  if _tmp
1762
1775
  text = get_text(_text_start)
@@ -1777,53 +1790,93 @@ class CmdParse
1777
1790
  return _tmp
1778
1791
  end
1779
1792
 
1780
- # list_stmt = (list_special_target | location):loc - integer:int? { List.new(loc, int) }
1793
+ # list_stmt = ((list_special_targets | location):loc - integer:int? { List.new(loc, int) } | (list_special_targets | location):loc { List.new(loc, nil) })
1781
1794
  def _list_stmt
1782
1795
 
1783
1796
  _save = self.pos
1784
- while true # sequence
1797
+ while true # choice
1785
1798
 
1786
1799
  _save1 = self.pos
1787
- while true # choice
1788
- _tmp = apply(:_list_special_target)
1789
- break if _tmp
1790
- self.pos = _save1
1791
- _tmp = apply(:_location)
1792
- break if _tmp
1793
- self.pos = _save1
1794
- break
1795
- end # end choice
1800
+ while true # sequence
1801
+
1802
+ _save2 = self.pos
1803
+ while true # choice
1804
+ _tmp = apply(:_list_special_targets)
1805
+ break if _tmp
1806
+ self.pos = _save2
1807
+ _tmp = apply(:_location)
1808
+ break if _tmp
1809
+ self.pos = _save2
1810
+ break
1811
+ end # end choice
1796
1812
 
1797
- loc = @result
1798
- unless _tmp
1799
- self.pos = _save
1800
- break
1801
- end
1802
- _tmp = apply(:__hyphen_)
1803
- unless _tmp
1804
- self.pos = _save
1805
- break
1806
- end
1807
- _save2 = self.pos
1808
- _tmp = apply(:_integer)
1809
- int = @result
1810
- unless _tmp
1813
+ loc = @result
1814
+ unless _tmp
1815
+ self.pos = _save1
1816
+ break
1817
+ end
1818
+ _tmp = apply(:__hyphen_)
1819
+ unless _tmp
1820
+ self.pos = _save1
1821
+ break
1822
+ end
1823
+ _save3 = self.pos
1824
+ _tmp = apply(:_integer)
1825
+ int = @result
1826
+ unless _tmp
1827
+ _tmp = true
1828
+ self.pos = _save3
1829
+ end
1830
+ unless _tmp
1831
+ self.pos = _save1
1832
+ break
1833
+ end
1834
+ @result = begin;
1835
+ List.new(loc, int)
1836
+ ; end
1811
1837
  _tmp = true
1812
- self.pos = _save2
1813
- end
1814
- unless _tmp
1815
- self.pos = _save
1838
+ unless _tmp
1839
+ self.pos = _save1
1840
+ end
1816
1841
  break
1817
- end
1818
- @result = begin;
1819
- List.new(loc, int)
1842
+ end # end sequence
1843
+
1844
+ break if _tmp
1845
+ self.pos = _save
1846
+
1847
+ _save4 = self.pos
1848
+ while true # sequence
1849
+
1850
+ _save5 = self.pos
1851
+ while true # choice
1852
+ _tmp = apply(:_list_special_targets)
1853
+ break if _tmp
1854
+ self.pos = _save5
1855
+ _tmp = apply(:_location)
1856
+ break if _tmp
1857
+ self.pos = _save5
1858
+ break
1859
+ end # end choice
1860
+
1861
+ loc = @result
1862
+ unless _tmp
1863
+ self.pos = _save4
1864
+ break
1865
+ end
1866
+ @result = begin;
1867
+ List.new(loc, nil)
1820
1868
  ; end
1821
- _tmp = true
1822
- unless _tmp
1823
- self.pos = _save
1824
- end
1869
+ _tmp = true
1870
+ unless _tmp
1871
+ self.pos = _save4
1872
+ end
1873
+ break
1874
+ end # end sequence
1875
+
1876
+ break if _tmp
1877
+ self.pos = _save
1825
1878
  break
1826
- end # end sequence
1879
+ end # end choice
1827
1880
 
1828
1881
  set_failed_rule :_list_stmt unless _tmp
1829
1882
  return _tmp
@@ -1862,18 +1915,18 @@ class CmdParse
1862
1915
  Rules[:_line_number] = rule_info("line_number", "integer")
1863
1916
  Rules[:_vm_offset] = rule_info("vm_offset", "\"@\" integer:int { Position.new(nil, nil, :offset, int) }")
1864
1917
  Rules[:_position] = rule_info("position", "(vm_offset | line_number:l { Position.new(nil, nil, :line, l) })")
1865
- Rules[:_location] = rule_info("location", "(position | < filename >:file &{ File.exist?(file) } file_pos_sep position:pos { Position.new(:file, file, pos.position_type, pos.position) } | < filename >:file &{ File.exist?(file) } { Position.new(:file, file, nil, nil) } | class_module_chain?:fn file_pos_sep position:pos { Position.new(:fn, fn, pos.position_type, pos.position) } | class_module_chain?:fn { Position.new(:fn, fn, nil, nil) })")
1918
+ Rules[:_location] = rule_info("location", "(position | < filename >:file &{ @file_exists_proc.call(file) } file_pos_sep position:pos { Position.new(:file, file, pos.position_type, pos.position) } | < filename >:file &{ @file_exists_proc.call(file) } { Position.new(:file, file, nil, nil) } | class_module_chain?:fn file_pos_sep position:pos { Position.new(:fn, fn, pos.position_type, pos.position) } | class_module_chain?:fn { Position.new(:fn, fn, nil, nil) })")
1866
1919
  Rules[:_if_unless] = rule_info("if_unless", "< (\"if\" | \"unless\") > { text }")
1867
1920
  Rules[:_condition] = rule_info("condition", "< /.+/ > { text}")
1868
1921
  Rules[:_breakpoint_stmt_no_condition] = rule_info("breakpoint_stmt_no_condition", "location:loc { Breakpoint.new(loc, false, 'true') }")
1869
1922
  Rules[:_breakpoint_stmt] = rule_info("breakpoint_stmt", "(location:loc - if_unless:iu - condition:cond { Breakpoint.new(loc, iu == 'unless', cond) } | breakpoint_stmt_no_condition)")
1870
- Rules[:_list_special_targets] = rule_info("list_special_targets", "< \".\" \"-\" > { text }")
1871
- Rules[:_list_stmt] = rule_info("list_stmt", "(list_special_target | location):loc - integer:int? { List.new(loc, int) }")
1923
+ Rules[:_list_special_targets] = rule_info("list_special_targets", "< (\".\" | \"-\") > { text }")
1924
+ Rules[:_list_stmt] = rule_info("list_stmt", "((list_special_targets | location):loc - integer:int? { List.new(loc, int) } | (list_special_targets | location):loc { List.new(loc, nil) })")
1872
1925
  end
1873
1926
  if __FILE__ == $0
1874
1927
  # require 'rubygems'; require_relative '../lib/trepanning';
1875
1928
 
1876
- cp = CmdParse.new('', true)
1929
+ cp = CmdParse.new('', :debug=>true)
1877
1930
  %w(A::B @@classvar abc01! @ivar @ivar.meth
1878
1931
  Object A::B::C A::B::C::D A::B.c A.b.c.d).each do |name|
1879
1932
  cp.setup_parser(name, true)
@@ -1909,6 +1962,17 @@ if __FILE__ == $0
1909
1962
  res = cp._filename
1910
1963
  p res
1911
1964
  puts cp.string
1912
- puts cp.result
1965
+ p cp.result
1966
+ end
1967
+ ['.', '-', 'filename', '"this is a filename"',
1968
+ 'this\ is\ another\ filename',
1969
+ 'C\:filename', '5', '. 5', '5 10'
1970
+ ].each do |name|
1971
+ puts '-' * 10
1972
+ cp.setup_parser(name, {:debug=>true})
1973
+ res = cp._list_stmt
1974
+ p res
1975
+ puts cp.string
1976
+ p cp.result
1913
1977
  end
1914
1978
  end
data/app/complete.rb CHANGED
@@ -76,4 +76,5 @@ if __FILE__ == $0
76
76
  [0, 2, 5, 8, 9, 13, 19].each do |pos|
77
77
  p next_token(x, pos)
78
78
  end
79
+ p complete_token(global_variables.map{|g| g.to_s}, '$s')
79
80
  end
data/app/core.rb CHANGED
@@ -169,8 +169,8 @@ class Trepan
169
169
  end
170
170
 
171
171
  # A trace-hook processor for 'trace var'
172
- def trace_var_processor(val)
173
- frame = RubyVM::ThreadFrame.current.prev
172
+ def trace_var_processor(var_name, value)
173
+ frame = RubyVM::ThreadFrame.current.prev(2)
174
174
  if 'CFUNC' == frame.type
175
175
  # Don't need the C call that got us here.
176
176
  prev = frame.prev
@@ -181,7 +181,7 @@ class Trepan
181
181
  Thread.current.tracing = true
182
182
 
183
183
  @step_count = 0 # Make event processor stop
184
- event_processor('trace-var', frame)
184
+ event_processor('trace-var', frame, [var_name, value])
185
185
  end
186
186
 
187
187
  end
data/app/disassemble.rb CHANGED
@@ -10,12 +10,18 @@ class Trepan
10
10
  def mark_disassembly(disassembly_str, iseq_equal, pc_offset,
11
11
  brkpt_offsets=[], max_width=80, highlight=nil)
12
12
 
13
+ dis_array = disassembly_str.split(/\n/)
13
14
  if highlight
14
- require_relative '../app/yarv'
15
- @highlighter ||= CodeRay::Duo[:yarv, :term]
15
+ begin
16
+ require_relative '../app/yarv'
17
+ @highlighter ||= CodeRay::Duo[:yarv, :term]
18
+ rescue LoadError
19
+ dis_array.
20
+ unshift('** Highlighting requested but CodeRay is not installed.')
21
+ highlight = false
22
+ end
16
23
  end
17
24
 
18
- dis_array = disassembly_str.split(/\n/)
19
25
  dis_array.map do |line|
20
26
  if line =~ /^(.*?)(\s+)(\(\s+\d+\))?$/
21
27
  line_begin = $1
@@ -91,4 +97,8 @@ local table (size: 6, argc: 1 [opts: 0, rest: -1, post: 0, block: -1] s1)
91
97
  puts '=' * 40
92
98
  require 'pp'
93
99
  PP.pp(disassemble_split(dis_string), $stdout)
100
+ str = mark_disassembly(dis_string, false, 2, [], 70, true).join("\n")
101
+ puts str
102
+ puts '=' * 40
103
+ PP.pp(disassemble_split(dis_string), $stdout)
94
104
  end
data/app/file.rb CHANGED
@@ -72,7 +72,7 @@ module Trepanning
72
72
 
73
73
  def find_scripts(filename)
74
74
  filename_pat = file_match_pat(filename)
75
- return SCRIPT_ISEQS__.keys.grep(/#{filename_pat}/)
75
+ return SCRIPT_LINES__.keys.grep(/#{filename_pat}/)
76
76
  end
77
77
 
78
78
  end
@@ -82,6 +82,7 @@ if __FILE__ == $0
82
82
  if !(ARGV.size == 1 && ARGV[0] == 'noload')
83
83
  ISEQS__ = {}
84
84
  SCRIPT_ISEQS__ = {}
85
+ SCRIPT_LINES__ = {}
85
86
  ARGV[0..-1] = ['noload']
86
87
  load(__FILE__)
87
88
  else
data/app/frame.rb CHANGED
@@ -158,7 +158,9 @@ class Trepan
158
158
 
159
159
  def offset_for_return(event)
160
160
  raise RuntimeError unless %w(return c-return).member?(event)
161
- 'return' == event ? 1 : 2
161
+ # FIXME: C calls have a RubyVM::Env added to the stack.
162
+ # Where? Why?
163
+ 'return' == event ? 1 : 4
162
164
  end
163
165
  module_function :offset_for_return
164
166
 
data/app/mock.rb CHANGED
@@ -1,11 +1,14 @@
1
1
  # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
2
2
  class Trepan
3
3
  attr_accessor :trace_filter # Procs/Methods we ignore.
4
+ attr_accessor :intf
4
5
  def initialize(opts={})
5
6
  @trace_filter = []
7
+ @intf = []
6
8
  end
7
9
  class MockDebugger
8
10
  attr_reader :initial_dir
11
+ attr_accessor :intf
9
12
  def initialize(settings={})
10
13
  @initial_dir = '.'
11
14
  end