mirror of
https://github.com/specht/champ.git
synced 2024-12-21 12:29:24 +00:00
show which subroutine a watch came from
This commit is contained in:
parent
c1a62aad8a
commit
b3706fbf53
19
champ.rb
19
champ.rb
@ -156,9 +156,11 @@ class Champ
|
||||
watch_index += 1
|
||||
end
|
||||
end
|
||||
|
||||
watch_input = io.string
|
||||
|
||||
@watch_values = {}
|
||||
@watch_called_from_subroutine = {}
|
||||
start_pc = @pc_for_label[@config['entry']] || @config['entry']
|
||||
Signal.trap('INT') do
|
||||
puts 'Killing 65C02 profiler...'
|
||||
@ -172,7 +174,7 @@ class Champ
|
||||
@calls_per_function = {}
|
||||
call_stack = []
|
||||
last_call_stack_cycles = 0
|
||||
Open3.popen2("./p65c02 --hide-log --start-pc #{start_pc} #{File.join(temp_dir, 'disk_image')}") do |stdin, stdout, thread|
|
||||
Open3.popen2("./p65c02 #{@record_frames ? '' : '--no-screen'} --hide-log --start-pc #{start_pc} #{File.join(temp_dir, 'disk_image')}") do |stdin, stdout, thread|
|
||||
stdin.puts watch_input.split("\n").size
|
||||
stdin.puts watch_input
|
||||
stdin.close
|
||||
@ -208,9 +210,11 @@ class Champ
|
||||
last_call_stack_cycles = cycles
|
||||
call_stack.pop
|
||||
elsif parts.first == 'watch'
|
||||
watch_index = parts[1].to_i
|
||||
watch_index = parts[2].to_i
|
||||
@watch_called_from_subroutine[watch_index] ||= Set.new()
|
||||
@watch_called_from_subroutine[watch_index] << parts[1].to_i(16)
|
||||
@watch_values[watch_index] ||= []
|
||||
@watch_values[watch_index] << parts[2, parts.size - 2].map { |x| x.to_i }
|
||||
@watch_values[watch_index] << parts[3, parts.size - 3].map { |x| x.to_i }
|
||||
elsif parts.first == 'screen'
|
||||
@frame_count += 1
|
||||
print "\rFrames: #{@frame_count}, Cycles: #{cycle_count}"
|
||||
@ -348,11 +352,11 @@ class Champ
|
||||
|
||||
histogram_max = histogram.values.max
|
||||
width = 276
|
||||
height = (watch[:components].size == 1) ? 148 : 276
|
||||
height = (watch[:components].size == 1) ? 158 : 286
|
||||
canvas_top = 20
|
||||
canvas_left = 40
|
||||
canvas_width = width - 60
|
||||
canvas_height = height - 60
|
||||
canvas_height = height - 70
|
||||
pixels = [0] * width * height
|
||||
|
||||
histogram.each_pair do |key, value|
|
||||
@ -447,6 +451,11 @@ class Champ
|
||||
end
|
||||
end
|
||||
label = "#{sprintf('0x%04x', watch[:pc])} / #{watch[:path]}:#{watch[:line_number]} (#{watch[:post] ? 'post' : 'pre'})"
|
||||
print_s(pixels, width, height, width / 2 - 3 * label.size, height - 20, label, 63)
|
||||
label = @watch_called_from_subroutine[index].map do |x|
|
||||
"#{@label_for_pc[x] || sprintf('0x%04x', x)}+#{watch[:pc] - x}"
|
||||
end.join(', ')
|
||||
label = "at #{label}"
|
||||
print_s(pixels, width, height, width / 2 - 3 * label.size, height - 10, label, 63)
|
||||
|
||||
tr = @highlight_color[1, 2].to_i(16)
|
||||
|
28
p65c02.c
28
p65c02.c
@ -17,6 +17,7 @@
|
||||
#define NEGATIVE 0x80
|
||||
|
||||
uint8_t show_log = 1;
|
||||
uint8_t show_screen = 1;
|
||||
uint8_t show_call_stack = 0;
|
||||
|
||||
uint8_t trace_stack[0x100];
|
||||
@ -992,13 +993,20 @@ void handle_watch(uint16_t pc, uint8_t post)
|
||||
while (watches[offset].pc == pc && watches[offset].post == post)
|
||||
{
|
||||
r_watch* watch = &watches[offset];
|
||||
if (old_index == -1)
|
||||
uint16_t watch_in_subroutine = 0;
|
||||
for (int i = trace_stack_pointer + 1; i <= 0xff; i++)
|
||||
{
|
||||
printf("watch %d", watch->index);
|
||||
if (trace_stack[i] == cpu.sp + 2)
|
||||
{
|
||||
watch_in_subroutine = trace_stack_function[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (old_index == -1)
|
||||
printf("watch 0x%04x %d", watch_in_subroutine, watch->index);
|
||||
else
|
||||
if (old_index != watch->index)
|
||||
printf("\nwatch %d", watch->index);
|
||||
printf("\nwatch 0x%04x %d", watch_in_subroutine, watch->index);
|
||||
|
||||
old_index = watch->index;
|
||||
int32_t value = 0;
|
||||
@ -1060,6 +1068,7 @@ int main(int argc, char** argv)
|
||||
printf(" --start-pc <address or label>\n");
|
||||
printf(" --frame-start <address or label>\n");
|
||||
printf(" --max-frames <n>\n");
|
||||
printf(" --no-screen\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -1134,6 +1143,8 @@ int main(int argc, char** argv)
|
||||
{
|
||||
if (strcmp(argv[i], "--hide-log") == 0)
|
||||
show_log = 0;
|
||||
else if (strcmp(argv[i], "--no-screen") == 0)
|
||||
show_screen = 0;
|
||||
else if (strcmp(argv[i], "--start-pc") == 0)
|
||||
{
|
||||
char *temp = argv[++i];
|
||||
@ -1193,11 +1204,14 @@ int main(int argc, char** argv)
|
||||
uint8_t current_screen = old_screen_number;
|
||||
int x, y;
|
||||
printf("screen %d", cpu.total_cycles);
|
||||
for (y = 0; y < 192; y++)
|
||||
if (show_screen)
|
||||
{
|
||||
uint16_t line_offset = yoffset[y] | (current_screen == 1 ? 0x2000 : 0x4000);
|
||||
for (x = 0; x < 40; x++)
|
||||
printf(" %d", ram[line_offset + x]);
|
||||
for (y = 0; y < 192; y++)
|
||||
{
|
||||
uint16_t line_offset = yoffset[y] | (current_screen == 1 ? 0x2000 : 0x4000);
|
||||
for (x = 0; x < 40; x++)
|
||||
printf(" %d", ram[line_offset + x]);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
|
Loading…
Reference in New Issue
Block a user