This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: v4l2-tracer: look in more places for libv4l2tracer
Author:  Deborah Brouwer <deborah.brou...@collabora.com>
Date:    Thu Nov 30 16:46:29 2023 -0800

The v4l2-tracer already looks in the build and install directories for its
library, but now it will also look in a truncated version of the
LIBTRACER_PATH which is helpful if it was installed by a cross-build. If
all else fails, it also allows the user to set a custom path using the
LD_PRELOAD environment variable.

Exit if the libv4l2tracer.so can’t be found.

Signed-off-by: Deborah Brouwer <deborah.brou...@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-ci...@xs4all.nl>

 utils/v4l2-tracer/v4l2-tracer.cpp | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=5a78cd626686925b7dad5af859a44847a2e03aaf
diff --git a/utils/v4l2-tracer/v4l2-tracer.cpp 
b/utils/v4l2-tracer/v4l2-tracer.cpp
index a039f5287b65..37e17eb6c50c 100644
--- a/utils/v4l2-tracer/v4l2-tracer.cpp
+++ b/utils/v4l2-tracer/v4l2-tracer.cpp
@@ -306,13 +306,31 @@ int tracer(int argc, char *argv[], bool retrace)
        else
                idx++;
 
-       /* look for libv4l2tracer next to the executable */
        libv4l2tracer_path = program.replace(program.begin() + idx, 
program.end(), "libv4l2tracer.so");
 
-       /* otherwise, use the installation path */
-       if (stat(libv4l2tracer_path.c_str(), &sb) == -1)
+       if (stat(libv4l2tracer_path.c_str(), &sb) == -1) {
+               /* If not found, get the libv4l2tracer library from the meson 
install path 'prefix' */
                libv4l2tracer_path = std::string(LIBTRACER_PATH) + 
"/libv4l2tracer.so";
 
+               /* Otherwise, guess where the library might be for a 
cross-build. */
+               if (stat(libv4l2tracer_path.c_str(), &sb) == -1) {
+                       std::size_t idx =  libv4l2tracer_path.find("/home");
+                       libv4l2tracer_path = libv4l2tracer_path.substr(idx);
+
+                       /* Finally, check if the user set a custom path using 
LD_PRELOAD. */
+                       if (stat(libv4l2tracer_path.c_str(), &sb) == -1) {
+                               if (getenv("LD_PRELOAD"))
+                                       libv4l2tracer_path = 
std::string(getenv("LD_PRELOAD"));
+
+                               if (stat(libv4l2tracer_path.c_str(), &sb) == 
-1) {
+                                       fprintf(stderr, "Exiting: can't find 
libv4l2tracer library\n");
+                                       fprintf(stderr, "Set a custom 
libv4l2tracer library path using: LD_PRELOAD\n");
+                                       exit(EXIT_FAILURE);
+                               }
+                       }
+               }
+       }
+
        if (is_verbose())
                fprintf(stderr, "Loading libv4l2tracer: %s\n", 
libv4l2tracer_path.c_str());
        setenv("LD_PRELOAD", libv4l2tracer_path.c_str(), 0);
@@ -355,6 +373,7 @@ int tracer(int argc, char *argv[], bool retrace)
        fprintf(stderr, "%s", trace_filename.c_str());
        fprintf(stderr, "\n");
 
+       unsetenv("LD_PRELOAD");
        return exec_result;
 }
 

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to