>From 38bab065e8228508ad3e62c03c92f14f64ca529e Mon Sep 17 00:00:00 2001
Message-Id: <38bab065e8228508ad3e62c03c92f14f64ca529e.1456861797.git.Torsten.Polle@gmx.de>
From: Torsten Polle <Torsten.Polle@gmx.de>
Date: Wed, 3 Dec 2014 22:17:14 +0100
Subject: [PATCH] Fix: process.library.function failed with sysroot.


Signed-off-by: Torsten Polle <Torsten.Polle@gmx.de>
---
 tapsets.cxx |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/tapsets.cxx b/tapsets.cxx
index 347a32d..5883ecc 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -737,11 +737,15 @@ base_query::base_query(dwflpp & dw, literal_map_t const & params):
       // Library probe? Let's target that instead if it is fully resolved (such
       // as what query_one_library() would have done for us). Otherwise, we
       // resort to iterate_over_libraries().
-      if (has_library && is_fully_resolved(library_name, sess.sysroot, sess.sysenv,
-                                           "LD_LIBRARY_PATH"))
-        {
-          path = path_remove_sysroot(sess, module_val);
-          module_val = library_name;
+      if (has_library)
+	{
+	  string library = find_executable (library_name, sess.sysroot,
+					    sess.sysenv, "LD_LIBRARY_PATH");
+	  if (is_fully_resolved(library, "", sess.sysenv, "LD_LIBRARY_PATH"))
+	    {
+	      path = path_remove_sysroot(sess, module_val);
+	      module_val = library;
+	    }
         }
     }
 
@@ -8162,9 +8166,15 @@ dwarf_builder::build(systemtap_session & sess,
       // do this only if the library path is already fully resolved (such as
       // what query_one_library() would have done for us). Otherwise, we resort
       // to iterate_over_libraries.
-      if (get_param (parameters, TOK_LIBRARY, user_lib) && !user_lib.empty()
-          && is_fully_resolved(user_lib, sess.sysroot, sess.sysenv, "LD_LIBRARY_PATH"))
-        module_name = user_lib;
+      if (get_param (parameters, TOK_LIBRARY, user_lib) && !user_lib.empty())
+	{
+	  string library = find_executable (user_lib, sess.sysroot,
+					    sess.sysenv, "LD_LIBRARY_PATH");
+	  if (is_fully_resolved(library, "", sess.sysenv, "LD_LIBRARY_PATH"))
+	    {
+	      module_name = library;
+	    }
+	}
       else
         module_name = user_path; // canonicalize it
 
-- 
1.7.4.1

