1# This file is part of ltrace. 2# Copyright (C) 2012 Petr Machata, Red Hat Inc. 3# 4# This program is free software; you can redistribute it and/or 5# modify it under the terms of the GNU General Public License as 6# published by the Free Software Foundation; either version 2 of the 7# License, or (at your option) any later version. 8# 9# This program is distributed in the hope that it will be useful, but 10# WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12# General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with this program; if not, write to the Free Software 16# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 17# 02110-1301 USA 18 19set libfilt1 [ltraceCompile libfilt1.so [ltraceSource c { 20 void func2(void); 21 void func1(void) { func2(); } 22}]] 23 24set libfilt2 [ltraceCompile libfilt2.so [ltraceSource c { 25 void func2(void) { puts("func2"); } 26}]] 27 28foreach ext {{} .pie} { 29 set filt [ltraceCompile filt$ext $libfilt1 $libfilt2 [ltraceSource c { 30 void func1(void); 31 int main(int argc, char *argv[]) { func1(); return 0; } 32 }]] 33 34 ltraceMatch [ltraceRun -e* $filt] { 35 {{filt(\.pie)?->func1} == 1} 36 {{libfilt1.so->func2} == 1} 37 {{libfilt2.so->puts} == 1} 38 {{func2 resumed} == 1} 39 {{func1 resumed} == 1} 40 } 41 42 ltraceMatch1 [ltraceRun $filt] \ 43 {^func1\(.*\)} == 1 44 45 ltraceMatch1 [ltraceRun -e@MAIN $filt] \ 46 {filt(\.pie)?->func1\(.*\)} == 1 47 48 ltraceMatch1 [ltraceRun -e@libfilt1.so $filt] \ 49 {libfilt1.so->func2\(.*\)} == 1 50 51 ltraceMatch1 [ltraceRun -e@libfilt2.so $filt] \ 52 {libfilt2.so->puts\(.*\)} == 1 53 54 ltraceMatch [ltraceRun -e@libfilt* $filt] { 55 {{libfilt1.so->func2\(} == 1} 56 {{libfilt2.so->puts\(.*\)} == 1} 57 {{func2 resumed} == 1} 58 } 59 60 ltraceMatch [ltraceRun -efunc* $filt] { 61 {{filt(\.pie)?->func1\(} == 1} 62 {{libfilt1.so->func2\(.*\)} == 1} 63 {{func1 resumed} == 1} 64 } 65 66 # Check that we handle breakpoint on both PLT entry and entry point 67 ltraceMatch [ltraceRun -efunc1 -xfunc1 $filt] { 68 {{filt(\.pie)?->func1\(} == 1} 69 {{func1@libfilt1.so\(.*\)} == 1} 70 {{func1 resumed} == 1} 71 } 72 73 # Check that when given -l, we don't trace symbols from other 74 # libraries. 75 ltraceMatch1 [ltraceRun -llibfilt1.so -- $filt] \ 76 {filt(\.pie)?->func1\(.*\)} == 1 77 78 ltraceMatch [ltraceRun -llibfilt1.so -llibfilt2.so $filt] { 79 {{filt(\.pie)?->func1\(} == 1} 80 {{libfilt1.so->func2\(.*\)} == 1} 81 {{func1 resumed} == 1} 82 } 83} 84 85ltraceDone 86