From 52b533c9a80e6a00611bc055f58d2ce9bf256322 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vivek=20Das=C2=A0Mohapatra?= <vivek@collabora.co.uk>
Date: Wed, 24 May 2017 18:08:44 +0100
Subject: [PATCH] capsule-dlmopen.c: more debug output from the DSO search
 functions

---
 capsule/capsule-dlmopen.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/capsule/capsule-dlmopen.c b/capsule/capsule-dlmopen.c
index f9a3c0138..dab375ed8 100644
--- a/capsule/capsule-dlmopen.c
+++ b/capsule/capsule-dlmopen.c
@@ -482,6 +482,9 @@ search_ldcache_cb (ldlibs_t *ldlibs,
         size_t plen   = ldlibs->prefix.len;
         char  *lpath  = ldlibs->needed[ idx ].path;
 
+        LDLIB_DEBUG( ldlibs, DEBUG_SEARCH|DEBUG_LDCACHE,
+                     "checking %s vs %s [%s]",
+                     target->name, name, path );
         // copy in the prefix and append the DSO path to it
         safe_strncpy( lpath, prefix, PATH_MAX );
         safe_strncpy( lpath + plen, path, PATH_MAX - plen );
@@ -616,6 +619,8 @@ dso_find (const char *name, ldlibs_t *ldlibs, int i)
             if( absolute )
             {
                 safe_strncpy( prefixed + plen, name, PATH_MAX - plen );
+                LDLIB_DEBUG( ldlibs, DEBUG_SEARCH|DEBUG_PATH,
+                             "absolute path to DSO %s", prefixed );
             }
             else
             {   // name is relative... this is probably wrong?
@@ -624,6 +629,8 @@ dso_find (const char *name, ldlibs_t *ldlibs, int i)
                 // path we couldn't resolve, and then move on:
                 safe_strncpy( prefixed + plen, "/", PATH_MAX - plen );
                 safe_strncpy( prefixed + plen + 1, name, PATH_MAX - plen - 1);
+                LDLIB_DEBUG( ldlibs, DEBUG_SEARCH|DEBUG_PATH,
+                             "relative path to DSO %s", prefixed );
             }
 
             target = prefixed;
@@ -633,7 +640,8 @@ dso_find (const char *name, ldlibs_t *ldlibs, int i)
             target = name;
         }
 
-        LDLIB_DEBUG( ldlibs, DEBUG_PATH, "resolving path %s", target );
+        LDLIB_DEBUG( ldlibs, DEBUG_SEARCH|DEBUG_PATH,
+                     "resolving path %s", target );
         // this will fail for a non-absolute path, but that's OK
         // if realpath lookup succeeds needed[i].path will be set correctly:
         if( realpath( target, ldlibs->needed[i].path ) )
@@ -644,6 +652,7 @@ dso_find (const char *name, ldlibs_t *ldlibs, int i)
     if( absolute )
         return 0;
 
+    LDLIB_DEBUG( ldlibs, DEBUG_SEARCH, "target DSO is %s", name );
     // now search LD_LIBRARY_PATH, the ld.so.cache, and the default locations
     // in that order (similar algorithm to the linker, but with the RPATH and
     // ${ORIGIN} support dropped)
-- 
GitLab