1 # This file was written by Yao Qi <qiyao (at) cn.ibm.com>. 2 3 set testfile "print-instruction-pointer" 4 set srcfile ${testfile}.c 5 set binfile ${testfile} 6 7 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" 12 } 13 14 # set options for ltrace. 15 ltrace_options "-i" 16 # Run PUT for ltrace. 17 set exec_output [ltrace_runtest $objdir/$subdir $objdir/$subdir/$binfile] 18 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!" 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. 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 34 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 40 41 set pattern "$addr2.*printf" 42 ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1 43