allow annotating markers in explorer

This commit is contained in:
2026-04-23 21:53:07 +02:00
parent 5f42323ccb
commit c76b0b8a8e
3 changed files with 190 additions and 42 deletions

View File

@ -21,12 +21,7 @@ my $local_root = '/home/christoph/Notes/TU/MastersThesis/FailNix';
my $local_archive_dir = "$local_root/injections";
# Select experiment to open
my @experiments = Util::find_subdirs($local_archive_dir);
my @selected_experiments =
TUI::select_from_list( "Select Archived Experiment to Open", 0,
@experiments );
die "No experiment selected" unless @selected_experiments;
my $selected_experiment = $selected_experiments[0];
my $selected_experiment = Util::select_experiment(0);
my $cui = TUI::init_cui();
@ -75,6 +70,25 @@ my %index_of_markers;
my $selected_threshold = 0;
my @sections;
sub marker_label {
my ($marker) = @_;
return sprintf(
"%4s %8s %5s %17s %12sx %-40s",
$marker->{benchmark},
$marker->{fault_address},
Util::get_section_name( $marker->{fault_address}, @sections ),
$marker->{resulttype},
Util::format_number_sep( $marker->{faults} ),
Util::read_marker_info(
$selected_experiment, $marker->{benchmark},
$marker->{fault_address}
),
);
}
sub load_faults_csv {
@marker_values = ();
%marker_labels = ();
@ -85,7 +99,7 @@ sub load_faults_csv {
headers => 'auto'
);
my @sections = Util::elf_read_sections(
@sections = Util::elf_read_sections(
"$local_archive_dir/$selected_experiment/system.elf");
# Result:
@ -95,16 +109,7 @@ sub load_faults_csv {
@marker_values = @$data;
@filtered_marker_values = @marker_values;
%marker_labels =
map {
$_ => sprintf(
"%5s %10s %10s %20s %15sx",
$_->{benchmark},
$_->{fault_address},
Util::get_section_name( $_->{fault_address}, @sections ),
$_->{resulttype},
Util::format_number_sep( $_->{faults} ),
);
} @marker_values;
map { $_ => marker_label($_); } @marker_values;
}
sub filter_marker_values {
@ -360,7 +365,7 @@ $win->add(
'info', 'Label',
-y => -1,
-text =>
"Space = toggle, F = filter markers, S = open source, A = open assembly, R = resize, Q = quit",
"Space = toggle, F = filter markers, S = open source, A = open assembly, N = edit notes, R = resize, Q = quit",
);
sub set_geometry {
@ -465,6 +470,7 @@ sub markers_filter_popup {
-title => "By Count Threshold",
-border => 1,
-text => $selected_threshold,
-pos => length($selected_threshold),
-regexp => '/^\d*$/',
);
@ -533,6 +539,79 @@ sub markers_filter_popup {
$focus->();
}
# =============================================================================
# Notes Popup
# =============================================================================
sub edit_notes_popup {
my $w = 60;
my $h = 24;
my $marker = $markers_panel->get_active_value();
my $marker_text =
Util::read_marker_info( $selected_experiment, $marker->{benchmark},
$marker->{fault_address} );
my $popup = $cui->add(
'popup', 'Window',
-x => int( $cui->width() / 2 - $w / 2 ),
-y => int( $cui->height() / 2 - $h / 2 ),
-width => $w,
-height => $h,
-border => 1,
-title => "Edit Notes",
);
my $notes = $popup->add(
'marker_notes',
'TextEditor',
-height => $h - 3,
-border => 1,
-text => $marker_text,
-pos => length($marker_text),
);
$popup->add(
'popup_info', 'Label',
-y => -1,
-text => "^S/^C = save, ^Q = quit",
);
$popup->set_binding(
sub {
my $text = $notes->get();
if ( length($text) > 0 ) {
Util::overwrite_marker_info( $selected_experiment,
$marker->{benchmark}, $marker->{fault_address}, $text, );
}
else {
Util::delete_marker_info( $selected_experiment,
$marker->{benchmark}, $marker->{fault_address} );
}
$marker_labels{$marker} = marker_label($marker);
$cui->delete('popup');
$cui->layout();
$markers_panel->draw();
},
"\cS",
"\cC",
);
$popup->set_binding(
sub {
$cui->delete('popup');
$cui->layout();
},
"\cQ"
);
$cui->layout();
$notes->focus();
}
# =============================================================================
# Bindings
# =============================================================================
@ -544,6 +623,13 @@ $win->set_binding(
'f',
);
$win->set_binding(
sub {
edit_notes_popup();
},
'n',
);
$win->set_binding(
sub {
layout_resize();