diff --git a/champ.rb b/champ.rb index 2189aed..ee64881 100755 --- a/champ.rb +++ b/champ.rb @@ -63,6 +63,7 @@ class Champ @execution_log_size = 20 @code_for_pc = {} @source_for_file = {} + @pc_for_file_and_line = {} args = ARGV.dup while args.size > 1 item = args.shift @@ -788,25 +789,33 @@ class Champ # write error dump if @error io = StringIO.new - io.puts "
"
source_code = @code_for_pc[@error[:pc]]
- STDERR.puts source_code.to_yaml
offset = source_code[:line] - 1
this_filename = source_code[:file]
- io.puts "#{sprintf('%-83s', this_filename)}"
+ io.puts " Line | PC | #{sprintf('%-75s', this_filename)}"
((offset - 16)..(offset + 16)).each do |i|
next if i < 0 || i >= @source_for_file[this_filename].size
io.print ""
- io.print sprintf('%5d | %-75s', i + 1, @source_for_file[this_filename][i])
+ line_pc = nil
+ if @pc_for_file_and_line[this_filename]
+ if @pc_for_file_and_line[this_filename][i]
+ line_pc = sprintf('0x%04x', @pc_for_file_and_line[this_filename][i + 1])
+ end
+ end
+ line_pc ||= ''
+ io.print sprintf('%5d | %6s | %-75s', i + 1, line_pc, @source_for_file[this_filename][i])
io.print "" if i == offset
io.puts
end
io.puts "
"
+ io.puts ""
io.puts sprintf(" PC | A X Y PC SP Flags ")
@execution_log.each do |item|
@@ -817,6 +826,8 @@ class Champ
io.puts "