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