1# This file was written by Yao Qi <qiyao@cn.ibm.com>. 2 3set testfile "print-instruction-pointer" 4set srcfile ${testfile}.c 5set binfile ${testfile} 6 7 8verbose "compiling source file now....." 9# Build the shared libraries this test case needs. 10if { [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" 12} 13 14# set options for ltrace. 15ltrace_options "-i" 16# Run PUT for ltrace. 17set exec_output [ltrace_runtest $objdir/$subdir $objdir/$subdir/$binfile] 18 19# Check the output of this program. 20verbose "ltrace runtest output: $exec_output\n" 21if [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!" 23 return 24} elseif [ regexp {Couldn't get .hash data} $exec_output ] { 25 fail "Couldn't get .hash data!" 26 return 27} 28 29# Get the addrss by objdump and sed. 30catch "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" 32catch "exec sh -c {echo \"$output\" | sed -n '2p'| awk -F' ' '{print \$1}'|awk -F: '{print \$1}'}" addr1 33catch "exec sh -c {echo \"$output\" | sed -n '5p'| awk -F' ' '{print \$1}'|awk -F: '{print \$1}'}" addr2 34 35verbose "addr1 = $addr1" 36verbose "addr2 = $addr2" 37# Verify the output by checking numbers of print in main.ltrace. 38set pattern "$addr1.*printf" 39ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 40 41set pattern "$addr2.*printf" 42ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 43