1 # This file was written by Yao Qi <qiyao@cn.ibm.com>.
3 set testfile "print-instruction-pointer"
4 set srcfile ${testfile}.c
5 set binfile ${testfile}
8 verbose "compiling source file now....."
9 # Build the shared libraries this test case needs.
10 if { [ltrace_compile "${srcdir}/${subdir}/${srcfile}" "${objdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
11 send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
14 # set options for ltrace.
17 set exec_output [ltrace_runtest $objdir/$subdir $objdir/$subdir/$binfile]
19 # Check the output of this program.
20 verbose "ltrace runtest output: $exec_output\n"
21 if [regexp {ELF from incompatible architecture} $exec_output] {
22 fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
24 } elseif [ regexp {Couldn't get .hash data} $exec_output ] {
25 fail "Couldn't get .hash data!"
29 # Get the addrss by objdump and sed.
30 catch "exec sh -c {objdump -d $objdir/$subdir/$binfile | sed -n '/^\[0-9a-fA-F\]\[0-9a-fA-F\]* <main>/,/^\[0-9a-fA-F\]\[0-9a-fA-F\]* </p'| grep -A 1 'call\\|bl' }" output
31 #verbose "output=$output"
32 catch "exec sh -c {echo \"$output\" | sed -n '2p'| awk -F' ' '{print \$1}'|awk -F: '{print \$1}'}" addr1
33 catch "exec sh -c {echo \"$output\" | sed -n '5p'| awk -F' ' '{print \$1}'|awk -F: '{print \$1}'}" addr2
35 verbose "addr1 = $addr1"
36 verbose "addr2 = $addr2"
37 # Verify the output by checking numbers of print in main.ltrace.
38 set pattern "$addr1.*printf"
39 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1
41 set pattern "$addr2.*printf"
42 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1