On 02/14/2014 11:41 AM, Carl E. Love wrote:
I am looking into an error reported for running the OProfile testsuite
on Ubuntu.  Opcontrol tries to open the vmlinux file stored
at /boot/vmlinux-`uname -r` to read the symbol information.  On Ubuntu,
this file apparently doesn't contain the symbol information that we
expect an causes opcontrol to fail.

I am wondering if anyone knows if Ubuntu is stripping the symbols from
the vmlinux files? If so, is this a recent change?   Thanks

                 Carl Love



Carl, here's a patch that addresses the issue.  Could you give it a quick review?

I haven't yet tested it on Ubuntu, but I've tested it by putting various files into
/boot and naming them "vmlinux-`uname -r`. In one case, the file was not an
ELF file; in a second case, the file was stripped of symbols; and finally, I used
a valid vmlinux file.

-Maynard
------------------------------------------------------------------------
Detect vmlinux file with no symbols

Some platforms include a /boot/vmlinux-`uname -r` file that has
no symbols.  The oprofile testsuite currently assumes that such
a file does have symbols and will fail horribly if it finds such
a stripped file.  This patch makes the testsuite more robust by
doing some basic checking of the file for validity.

Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
---
 testsuite/config/unix.exp |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/testsuite/config/unix.exp b/testsuite/config/unix.exp
index 85ae28c..9befabf 100644
--- a/testsuite/config/unix.exp
+++ b/testsuite/config/unix.exp
@@ -47,26 +47,39 @@ load_lib "operf_util.exp"
 
 # we need to find a linux image, before anything else
 
+proc _is_vmlinux_valid {vmlinux_file} {
+        set result [ local_exec "objdump -t $vmlinux_file" "" "" 100 ]
+        if { [regexp "File format not recognized" "$result" ]} {
+                verbose "File format not recognized for $vmlinux_file\n"
+                return 0
+        } elseif { [regexp "no symbols" "$result" ]} {
+                verbose "No symbols in $vmlinux_file\n"
+                return 0
+        } elseif { [regexp ".text" "$result" ]}  {
+                verbose "Found symbols in  $vmlinux_file\n"
+                return 1
+        } else {
+                verbose "Unknown result from objdump for $vmlinux_file\n"
+                return 0
+        }
+}
+
 proc oprofile_start {} {
     global op_vmlinux
     global op_module_active
 
     set op_linux_version [exec /bin/uname -r]
     set op_vmlinux "/boot/vmlinux-$op_linux_version"
-    set test "check for linux image"
-    if {[file exists $op_vmlinux] == 1} {
+    if {[file exists $op_vmlinux] == 1 && [_is_vmlinux_valid $op_vmlinux] == 1} {
 	verbose "using linux image $op_vmlinux"
-#	pass $test
     } else {
 	# try the debuginfo location
 	set op_vmlinux "/usr/lib/debug/lib/modules/${op_linux_version}/vmlinux"
 	if {[file exists $op_vmlinux] == 1} {
 	    verbose "using linux image $op_vmlinux"
-#	    pass $test
 	} else {
 	    verbose "linux image for $op_linux_version not found"
 	    set op_vmlinux 0
-#	    fail $test
 	}
     }
 
-- 
1.7.1