1 # This file is part of ltrace. 2 # Copyright (C) 2012, 2013 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 19 set libll [ltraceCompile libll.so [ltraceSource c { 20 #include <unistd.h> 21 void sym(void) { 22 sleep(1); 23 } 24 }]] 25 26 spawn [ltraceCompile exe -ldl [ltraceSource c { 27 #include <unistd.h> 28 #include <dlfcn.h> 29 #include <assert.h> 30 #include <stdio.h> 31 #include <string.h> 32 int main(int argc, char **argv) { 33 assert(argc == 2); 34 #define FN "libll.so" 35 char buf[strlen(argv[1]) + 1 + sizeof FN]; 36 sprintf(buf, "%s/%s", argv[1], FN); 37 void *libll = dlopen(buf, RTLD_LAZY | RTLD_LOCAL); 38 assert(libll != NULL); 39 sleep(1); 40 void (*sym)(void) = dlsym(libll, "sym"); 41 assert(sym != NULL); 42 sym(); 43 return 0; 44 } 45 }]] $objdir/$subdir 46 47 ltraceMatch1 [ltraceRun -e* -p [exp_pid]] {libll.so->sleep} == 1 48 49 ltraceDone 50