[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

apitrace: Changes to 'debian'



 debian/apitrace-gl-tracers.install   |    1 
 debian/patches/01_multiarchify.patch |  197 +++++++++++++++++++++++++++++++++++
 debian/patches/series                |    2 
 3 files changed, 199 insertions(+), 1 deletion(-)

New commits:
commit f4170cc00e0f8980e8c3539bacb3add5845a9436
Author: Christopher James Halse Rogers <raof@ubuntu.com>
Date:   Mon Aug 20 17:59:46 2012 +1000

    Improve multiarch support
    
    Add patch to make apitrace automatically select the correct wrapper DSO
    for the binary to trace.
    
    Uses LD_LIBRARY_PATH rather than a fully-qualified LD_PRELOAD, so
    the dynamic loader does the right thing

diff --git a/debian/apitrace-gl-tracers.install b/debian/apitrace-gl-tracers.install
index b7c0380..563e86f 100644
--- a/debian/apitrace-gl-tracers.install
+++ b/debian/apitrace-gl-tracers.install
@@ -1,2 +1,3 @@
 usr/lib/*/apitrace/wrappers
 usr/share/doc/* 	usr/share/doc/apitrace-gl-tracers/
+etc/apitrace.d
diff --git a/debian/patches/01_multiarchify.patch b/debian/patches/01_multiarchify.patch
new file mode 100644
index 0000000..2a3b3f3
--- /dev/null
+++ b/debian/patches/01_multiarchify.patch
@@ -0,0 +1,197 @@
+commit 0b5a6d413c801a6620e23c6643973e2a99f90787
+Author: Christopher James Halse Rogers <raof@ubuntu.com>
+Date:   Mon Aug 20 14:25:22 2012 +1000
+
+    linux: Use relative wrapper name and LD_LIBRARY_PATH.
+    
+    This allows the dynamic linker to load whatever wrapper DSO is appropriate,
+    making tracing on multiarch system much easier
+    
+    Signed-off-by: Christopher James Halse Rogers <raof@ubuntu.com>
+Forwarded: yes
+
+Index: apitrace/CMakeLists.txt
+===================================================================
+--- apitrace.orig/CMakeLists.txt	2012-08-20 16:40:25.256045212 +1000
++++ apitrace/CMakeLists.txt	2012-08-20 17:11:59.831944053 +1000
+@@ -243,6 +243,7 @@
+ 
+ set (SCRIPTS_INSTALL_DIR ${LIB_INSTALL_DIR}/scripts)
+ set (WRAPPER_INSTALL_DIR ${LIB_ARCH_INSTALL_DIR}/wrappers)
++set (CONFIG_INSTALL_DIR /etc/apitrace.d)
+ 
+ # Expose the binary/install directories to source
+ #
+@@ -254,7 +255,8 @@
+     -DAPITRACE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
+     -DAPITRACE_SCRIPTS_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${SCRIPTS_INSTALL_DIR}"
+     -DAPITRACE_WRAPPERS_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${WRAPPER_INSTALL_DIR}"
+-)
++    -DAPITRACE_CONFIG_INSTALL_DIR="${CONFIG_INSTALL_DIR}")
++
+ 
+ 
+ ##############################################################################
+@@ -360,6 +362,24 @@
+     DESTINATION ${DOC_INSTALL_DIR}
+ )
+ 
++if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
++    # Generate wrapper config file
++    add_custom_command(OUTPUT ${ARCH_SUBDIR}.conf
++        COMMAND sh -c "echo ${CMAKE_INSTALL_PREFIX}/${WRAPPER_INSTALL_DIR} >${ARCH_SUBDIR}.conf")
++
++    add_custom_target(wrapper_config 
++        ALL 
++        DEPENDS 
++            ${CMAKE_BINARY_DIR}/${ARCH_SUBDIR}.conf
++    )
++
++    install (FILES
++            ${CMAKE_BINARY_DIR}/${ARCH_SUBDIR}.conf
++        DESTINATION
++            ${CONFIG_INSTALL_DIR}
++    )
++endif()
++
+ set (CPACK_PACKAGE_VERSION_MAJOR "3")
+ set (CPACK_PACKAGE_VERSION_MINOR "0")
+ 
+Index: apitrace/common/trace_tools_trace.cpp
+===================================================================
+--- apitrace.orig/common/trace_tools_trace.cpp	2012-08-20 16:40:25.256045212 +1000
++++ apitrace/common/trace_tools_trace.cpp	2012-08-20 17:10:37.935948428 +1000
+@@ -29,6 +29,7 @@
+ #include <stdlib.h>
+ 
+ #include <iostream>
++#include <fstream>
+ 
+ #include "os_string.hpp"
+ #include "os_process.hpp"
+@@ -45,11 +46,106 @@
+ #elif defined(_WIN32)
+ #define GL_TRACE_WRAPPER  "opengl32.dll"
+ #else
++#define LIBRARY_SEARCH_VARIABLE "LD_LIBRARY_PATH"
+ #define TRACE_VARIABLE "LD_PRELOAD"
+ #define GL_TRACE_WRAPPER  "glxtrace.so"
+ #define EGL_TRACE_WRAPPER  "egltrace.so"
+ #endif
+ 
++#ifdef LIBRARY_SEARCH_VARIABLE
++#include <string>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <dirent.h>
++#include <unistd.h>
++#include <errno.h>
++#include <malloc.h>
++
++/* TODO: This should either be a C++11 TR 2-style directory iterator
++ * implementation or should just use libboost-filesystem.
++ */
++
++class DirectoryListing {
++public:
++    DirectoryListing(os::String path);
++    ~DirectoryListing();
++
++    os::String next();
++
++private:
++    const os::String basepath;
++    struct dirent *entry;
++    DIR *dir;
++    int error;
++};
++
++DirectoryListing::DirectoryListing(os::String path) : basepath(path)
++{
++    error = 0;
++
++    int len = offsetof(struct dirent, d_name) + pathconf(path, _PC_NAME_MAX) + 1;
++    entry = static_cast<struct dirent *>(malloc(len));
++    dir = opendir(path);
++
++    if (dir == NULL)
++        error = errno;
++}
++
++DirectoryListing::~DirectoryListing()
++{
++    closedir(dir);
++    free(entry);
++}
++
++os::String DirectoryListing::next(void)
++{
++    struct dirent *result;
++
++    if (error)
++        return os::String();
++
++    error = readdir_r(dir, entry, &result);
++    if (result == NULL)
++        return os::String();
++
++    os::String filename(basepath);
++    filename.join(entry->d_name);
++
++    return filename;
++}
++
++static os::String
++findAllWrappers(const char *wrapperFilename)
++{
++    os::String conffilePath;
++    os::String wrapperPaths;
++    DirectoryListing conffileListing(APITRACE_CONFIG_INSTALL_DIR);
++
++    conffilePath = conffileListing.next();
++    while (conffilePath.length() > 0) {
++        std::ifstream conffile(conffilePath);
++        os::String wrapperPath;
++        while(conffile.good()) {
++            char path[PATH_MAX];
++            conffile.getline(path, PATH_MAX);
++            wrapperPath = path;
++            wrapperPath.join(wrapperFilename);
++            if (wrapperPath.exists()) {
++                wrapperPaths.append(path);
++                wrapperPaths.append(":");
++            }
++        }
++        conffilePath = conffileListing.next();
++    }
++
++    /* Trim off trailing ':' */
++    if (wrapperPaths.length() > 0)
++        wrapperPaths.truncate(wrapperPaths.length() - 1);
++    
++    return wrapperPaths;
++}
++
++#endif /* LIBRARY_SEARCH_VARIABLE */
+ 
+ static os::String
+ findWrapper(const char *wrapperFilename)
+@@ -176,6 +272,18 @@
+     wrapperPath.trimFilename();
+ #endif
+ 
++#if defined(LIBRARY_SEARCH_VARIABLE)
++    os::String wrapperPaths = findAllWrappers(wrapperFilename);
++    if (verbose) {
++        std::cerr << LIBRARY_SEARCH_VARIABLE << "=" << wrapperPaths.str() << "\n";
++    }
++    os::setEnvironment(LIBRARY_SEARCH_VARIABLE, wrapperPaths.str());
++    /* If we set the library search path, the linker will find the wrapper
++     * for the appropriate architecture itself; we need only supply the name
++     */
++    wrapperPath = wrapperFilename;
++#endif
++
+ #if defined(TRACE_VARIABLE)
+     if (verbose) {
+         std::cerr << TRACE_VARIABLE << "=" << wrapperPath.str() << "\n";
diff --git a/debian/patches/series b/debian/patches/series
index 8b13789..e7a73e5 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1 @@
-
+01_multiarchify.patch


Reply to: