Fix lookup of prototypes from non-leader threads
authorPetr Machata <pmachata@redhat.com>
Tue, 6 May 2014 10:53:03 +0000 (12:53 +0200)
committerChanho Park <chanho61.park@samsung.com>
Fri, 22 Aug 2014 11:38:25 +0000 (20:38 +0900)
output.c
testsuite/ltrace.main/parameters3.exp

index 0cec653..671a5d7 100644 (file)
--- a/output.c
+++ b/output.c
@@ -531,7 +531,7 @@ output_left(enum tof type, struct process *proc,
 
        account_output(&current_column, fprintf(options.output, "("));
 
-       struct prototype *func = lookup_symbol_prototype(proc, libsym);
+       struct prototype *func = lookup_symbol_prototype(proc->leader, libsym);
        if (func == NULL) {
        fail:
                account_output(&current_column, fprintf(options.output, "???"));
index d49ecb2..693c219 100644 (file)
@@ -1,5 +1,5 @@
 # This file is part of ltrace.
-# Copyright (C) 2012 Petr Machata, Red Hat Inc.
+# Copyright (C) 2012, 2014 Petr Machata, Red Hat Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -37,4 +37,37 @@ set bin [ltraceCompile {} $liba [ltraceSource c {
 ltraceMatch1 [ltraceRun -F $dir -L -x fun -- $bin] {fun@liba.so\(\)} == 1
 ltraceMatch1 [ltraceRun -F $dir -e fun -- $bin] {fun\(\)} == 1
 
+# This tests lookup of prototypes from non-leader threads.
+
+set bin [ltraceCompile {} $liba -lpthread [ltraceSource c {
+    #include <pthread.h>
+    #include <assert.h>
+
+    void fun();
+
+    void *
+    start(void *arg)
+    {
+       fun();
+       return NULL;
+    }
+
+    int
+    main(int argc, char *argv[])
+    {
+       pthread_t thr;
+       int rc = pthread_create(&thr, NULL, &start, NULL);
+       assert(rc == 0);
+
+       void *retval;
+       rc = pthread_join(thr, &retval);
+       assert(rc == 0);
+
+       return 0;
+    }
+}]]
+
+ltraceMatch1 [ltraceRun -F $dir -f -L -x fun -- $bin] {fun@liba.so\(\)} == 1
+ltraceMatch1 [ltraceRun -F $dir -f -e fun -- $bin] {fun\(\)} == 1
+
 ltraceDone