Add new filter mechanism: Exclude list of function symbols
This commit is contained in:
@@ -94,6 +94,39 @@ my %CONFIGS = (
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# All entries are functions part of the native call chain
|
||||||
|
my @NATIVE_CALL_FUNCS = (
|
||||||
|
'aot_invoke_native', # imported-function dispatch (AOT)
|
||||||
|
'aot_call_indirect', # call_indirect dispatch (AOT)
|
||||||
|
'wasm_interp_call_func_native', # native dispatch (Interp)
|
||||||
|
'wasm_runtime_invoke_native', # common
|
||||||
|
'invokeNative', # common
|
||||||
|
|
||||||
|
# Imported functions:
|
||||||
|
'host_fail_start_trace',
|
||||||
|
'host_fail_stop_trace',
|
||||||
|
'host_fail_marker_positive',
|
||||||
|
'host_fail_marker_negative',
|
||||||
|
'host_fail_marker_detected',
|
||||||
|
'host_print',
|
||||||
|
);
|
||||||
|
|
||||||
|
$CONFIGS{no_native_call_instr} = {
|
||||||
|
label => "Exclude WAMR native call chain (instr)",
|
||||||
|
regions => [
|
||||||
|
map { { func => $_, col => 'p.injection_instr_absolute' } }
|
||||||
|
@NATIVE_CALL_FUNCS
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
$CONFIGS{no_native_call_data} = {
|
||||||
|
label => "Exclude WAMR native call chain (data)",
|
||||||
|
regions => [
|
||||||
|
map { { func => $_, col => 'g.data_physical_address' } }
|
||||||
|
@NATIVE_CALL_FUNCS
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
# Those will be executed automatically by runner.pl (+ no filter at all)
|
# Those will be executed automatically by runner.pl (+ no filter at all)
|
||||||
# my @DEFAULT_CONFIGS = ('no_aot_data');
|
# my @DEFAULT_CONFIGS = ('no_aot_data');
|
||||||
my @DEFAULT_CONFIGS = ();
|
my @DEFAULT_CONFIGS = ();
|
||||||
@@ -117,12 +150,26 @@ sub build_filter_clause {
|
|||||||
return ""
|
return ""
|
||||||
unless defined $experiment_dir && -f "$experiment_dir/system.elf";
|
unless defined $experiment_dir && -f "$experiment_dir/system.elf";
|
||||||
|
|
||||||
|
my $elf = "$experiment_dir/system.elf";
|
||||||
|
|
||||||
my @filters;
|
my @filters;
|
||||||
for my $pair (@$regions) {
|
for my $region (@$regions) {
|
||||||
my ( $start_sym, $end_sym, $col ) = @$pair;
|
my ( $start, $end, $col );
|
||||||
my $start =
|
|
||||||
Util::elf_sym_addr( "$experiment_dir/system.elf", $start_sym );
|
if ( ref($region) eq 'HASH' ) {
|
||||||
my $end = Util::elf_sym_addr( "$experiment_dir/system.elf", $end_sym );
|
|
||||||
|
# Single-function form: resolve [start, end) via symbol + size.
|
||||||
|
$col = $region->{col};
|
||||||
|
( $start, $end ) = Util::elf_sym_range( $elf, $region->{func} );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# Linker-range form: [start_sym, end_sym, col].
|
||||||
|
my ( $start_sym, $end_sym );
|
||||||
|
( $start_sym, $end_sym, $col ) = @$region;
|
||||||
|
$start = Util::elf_sym_addr( $elf, $start_sym );
|
||||||
|
$end = Util::elf_sym_addr( $elf, $end_sym );
|
||||||
|
}
|
||||||
|
|
||||||
next unless defined $start && defined $end && $end > $start;
|
next unless defined $start && defined $end && $end > $start;
|
||||||
push @filters, "$col NOT BETWEEN $start AND @{[$end - 1]}";
|
push @filters, "$col NOT BETWEEN $start AND @{[$end - 1]}";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,6 +188,54 @@ sub elf_sym_addr {
|
|||||||
return hex($1);
|
return hex($1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Determine the address range of a function symbol
|
||||||
|
sub elf_sym_range {
|
||||||
|
my ( $elffile, $sym ) = @_;
|
||||||
|
|
||||||
|
my @lines = qx{nm -nS "$elffile" 2>/dev/null};
|
||||||
|
return () unless @lines;
|
||||||
|
|
||||||
|
for my $i ( 0 .. $#lines ) {
|
||||||
|
my $line = $lines[$i];
|
||||||
|
|
||||||
|
# With size: "0010eefe 000001fe T aot_invoke_native"
|
||||||
|
# Without size: "001298fe T invokeNative"
|
||||||
|
next
|
||||||
|
unless $line =~ /^([0-9a-f]+)(?:\s+([0-9a-f]+))?\s+\S\s+(\S+)\s*$/i;
|
||||||
|
my ( $addr, $size, $name ) = ( $1, $2, $3 );
|
||||||
|
next unless $name eq $sym;
|
||||||
|
|
||||||
|
my $start = hex($addr);
|
||||||
|
|
||||||
|
if ( defined $size ) {
|
||||||
|
return ( $start, $start + hex($size) );
|
||||||
|
}
|
||||||
|
|
||||||
|
# Those don't have sizes, skip them.
|
||||||
|
# They appear inside invokeNative_ia32.s
|
||||||
|
my %ELF_INTERNAL_LABELS = (
|
||||||
|
stack_aligned => 1,
|
||||||
|
skip_push_args => 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
# No size -> take next symbol whose address is > $start.
|
||||||
|
for my $j ( $i + 1 .. $#lines ) {
|
||||||
|
next
|
||||||
|
unless $lines[$j] =~
|
||||||
|
/^([0-9a-f]+)(?:\s+[0-9a-f]+)?\s+\S\s+(\S+)\s*$/i;
|
||||||
|
my ( $next_addr, $next_name ) = ( hex($1), $2 );
|
||||||
|
next if $next_addr <= $start;
|
||||||
|
next if $ELF_INTERNAL_LABELS{$next_name};
|
||||||
|
return ( $start, $next_addr );
|
||||||
|
}
|
||||||
|
|
||||||
|
# No next symbol, don't know size
|
||||||
|
return ();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ();
|
||||||
|
}
|
||||||
|
|
||||||
sub elf_read_sections {
|
sub elf_read_sections {
|
||||||
my ($elffile) = @_;
|
my ($elffile) = @_;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user