Skip to content

Commit

Permalink
tests: filter-out spurious references to bpf module symbols from kall…
Browse files Browse the repository at this point in the history
…modsyms

We see references to symbols assigned to a "bpf" module in
/proc/kallmodsyms.  We filter these references out in a few tests and in
libdtrace/dt_module.c.

The tests which were failing before the changes here include:
test/unittest/aggs/tst.aggmod_full.sh
test/unittest/aggs/tst.aggmod_full2.sh
test/unittest/consumer/tst.merge_ranges_bug25767469.c
test/unittest/consumer/tst.symbols.c

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Signed-off-by: David Mc Lean <david.mclean@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
dpmclean authored and nickalcock committed Nov 25, 2020
1 parent 07972b6 commit 7ce719c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion libdtrace/dt_module.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand Down Expand Up @@ -1122,6 +1122,9 @@ dt_modsym_update(dtrace_hdl_t *dtp, const char *line)
|| (sym_type == 'w') || (sym_type == 'W');
mod_name[strlen(mod_name)-1] = '\0'; /* chop trailing ] */

if (strcmp(mod_name, "bpf") == 0)
return 0;

/*
* Symbols of "absolute" type are typically defined per CPU. Their
* "addresses" in /proc/kallmodsyms are very low and are actually offsets.
Expand Down
3 changes: 2 additions & 1 deletion test/unittest/aggs/tst.aggmod_full.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Oracle Linux DTrace.
# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
#
Expand Down Expand Up @@ -84,6 +84,7 @@ NF == 4 && $4 == "__init_scratch_begin" {
NF == 4 {$5 = "[vmlinux]"};
$3 == "a" {$2 = 0};
$3 == "A" {$2 = 0};
$5 == "[bpf]" {$2 = 0};
$2 != 0 { print $1 >> $5 }
' /proc/kallmodsyms

Expand Down
6 changes: 5 additions & 1 deletion test/unittest/aggs/tst.aggmod_full2.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Oracle Linux DTrace.
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
#
Expand Down Expand Up @@ -41,6 +41,7 @@ cat > test.c << EOF
#include <string.h>
#include <unistd.h>
#include <linux/limits.h>
#include <time.h>
#include "prov.h"
/*
Expand Down Expand Up @@ -90,6 +91,9 @@ int main(int argc, char **argv) {
if (size == 0)
continue;
if (strcmp(modname, "bpf]") == 0)
continue;
/* trim the trailing ']' and print modname to stdout */
modname[strlen(modname)-1] = '\0';
printf("%s\n", modname);
Expand Down
4 changes: 3 additions & 1 deletion test/unittest/consumer/tst.symbols.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand Down Expand Up @@ -107,6 +107,8 @@ int read_symbols() {
continue;
}
#undef KERNEL_FLAG_INIT_SCRATCH
if (strcmp(modname, "bpf]") == 0)
continue;

/*
* In libdtrace/dt_module.c function dt_modsym_update(),
Expand Down

0 comments on commit 7ce719c

Please sign in to comment.