diff --git a/apitrace-4.0_resources.patch b/apitrace-4.0_resources.patch index 9e715dd..f3f233b 100644 --- a/apitrace-4.0_resources.patch +++ b/apitrace-4.0_resources.patch @@ -1,50 +1,6 @@ diff -rupN apitrace-4.0/cli/cli_resources.cpp apitrace-4.0-new/cli/cli_resources.cpp --- apitrace-4.0/cli/cli_resources.cpp 2013-05-02 09:05:06.000000000 +0200 +++ apitrace-4.0-new/cli/cli_resources.cpp 2013-11-13 23:01:42.288012440 +0100 -@@ -63,42 +63,13 @@ os::String - findWrapper(const char *wrapperFilename) - { - os::String wrapperPath; -- -- os::String processDir = os::getProcessName(); -- processDir.trimFilename(); -- -- // Try relative build directory -- // XXX: Just make build and install directory layout match -- wrapperPath = processDir; -+ wrapperPath = APITRACE_LIB_DIR; - wrapperPath.join("wrappers"); - wrapperPath.join(wrapperFilename); - if (wrapperPath.exists()) { - return wrapperPath; - } - -- // Try relative install directory -- wrapperPath = processDir; --#if defined(_WIN32) -- wrapperPath.join("..\\lib\\wrappers"); --#elif defined(__APPLE__) -- wrapperPath.join("../lib/wrappers"); --#else -- wrapperPath.join("../lib/apitrace/wrappers"); --#endif -- wrapperPath.join(wrapperFilename); -- if (wrapperPath.exists()) { -- return wrapperPath; -- } -- --#ifndef _WIN32 -- // Try absolute install directory -- wrapperPath = APITRACE_WRAPPERS_INSTALL_DIR; -- wrapperPath.join(wrapperFilename); -- if (wrapperPath.exists()) { -- return wrapperPath; -- } --#endif -- - return ""; - } - @@ -106,44 +77,13 @@ os::String findScript(const char *scriptFilename) { diff --git a/apitrace-4.0_support-32bit-preload.patch b/apitrace-4.0_support-32bit-preload.patch new file mode 100644 index 0000000..93c54eb --- /dev/null +++ b/apitrace-4.0_support-32bit-preload.patch @@ -0,0 +1,107 @@ +diff -rupN apitrace-4.0/cli/cli_resources.cpp apitrace-4.0-new/cli/cli_resources.cpp +--- apitrace-4.0/cli/cli_resources.cpp 2013-05-02 09:05:06.000000000 +0200 ++++ apitrace-4.0-new/cli/cli_resources.cpp 2014-03-07 22:09:42.186333361 +0100 +@@ -32,6 +32,45 @@ + + #include "cli_resources.hpp" + ++#include ++ ++// Stolen from elfio ++#define EI_NIDENT 16 ++#define EI_MAG0 0 ++#define EI_MAG1 1 ++#define EI_MAG2 2 ++#define EI_MAG3 3 ++#define EI_CLASS 4 ++#define ELFMAG0 0x7F ++#define ELFMAG1 'E' ++#define ELFMAG2 'L' ++#define ELFMAG3 'F' ++#define ELFCLASSNONE 0 ++#define ELFCLASS32 1 ++#define ELFCLASS64 2 ++ ++int get_elf_class(const char* filename) { ++ std::ifstream stream; ++ stream.open( filename, std::ios::in | std::ios::binary ); ++ if ( !stream ) { ++ return ELFCLASSNONE; ++ } ++ unsigned char e_ident[EI_NIDENT]; ++ ++ // Read ELF file signature ++ stream.seekg( 0 ); ++ stream.read( reinterpret_cast( &e_ident ), sizeof( e_ident ) ); ++ ++ // Is it ELF file? ++ if ( stream.gcount() != sizeof( e_ident ) || ++ e_ident[EI_MAG0] != ELFMAG0 || ++ e_ident[EI_MAG1] != ELFMAG1 || ++ e_ident[EI_MAG2] != ELFMAG2 || ++ e_ident[EI_MAG3] != ELFMAG3 ) { ++ return ELFCLASSNONE; ++ } ++ return e_ident[EI_CLASS]; ++} + + os::String + findProgram(const char*programFilename) +@@ -60,7 +99,7 @@ findProgram(const char*programFilename) + } + + os::String +-findWrapper(const char *wrapperFilename) ++findWrapper(const char *wrapperFilename, const char *argv0) + { + os::String wrapperPath; + +@@ -83,8 +122,24 @@ findWrapper(const char *wrapperFilename) + #elif defined(__APPLE__) + wrapperPath.join("../lib/wrappers"); + #else ++ // If we are on a 64-bit architecture, support tracing 32-bit executables by preloading the appropriate shared library ++#ifdef __LP64__ ++ int elfclass = get_elf_class(argv0); ++ if(elfclass == ELFCLASS32) { ++ wrapperPath.join("../lib/apitrace/wrappers"); ++ if (!wrapperPath.exists()) { ++ std::cerr << "32-bit wrapper libraries not found, please install apitrace-libs.i686" << std::endl; ++ } ++ } else if(elfclass == ELFCLASS64) { ++ wrapperPath.join("../lib64/apitrace/wrappers"); ++ } else if(elfclass == ELFCLASSNONE) { ++ std::cerr << "error: failed to determine elf class for " << argv0 << ", assuming ELFCLASS64" << std::endl; ++ wrapperPath.join("../lib64/apitrace/wrappers"); ++ } ++#else + wrapperPath.join("../lib/apitrace/wrappers"); + #endif ++#endif + wrapperPath.join(wrapperFilename); + if (wrapperPath.exists()) { + return wrapperPath; +diff -rupN apitrace-4.0/cli/cli_resources.hpp apitrace-4.0-new/cli/cli_resources.hpp +--- apitrace-4.0/cli/cli_resources.hpp 2013-05-02 09:05:06.000000000 +0200 ++++ apitrace-4.0-new/cli/cli_resources.hpp 2014-02-22 23:47:43.917645323 +0100 +@@ -40,7 +40,7 @@ os::String + findScript(const char *name); + + os::String +-findWrapper(const char *wrapperFilename); ++findWrapper(const char *wrapperFilename, const char *argv0); + + + #endif /* _CLI_RESOURCES_HPP_ */ +diff -rupN apitrace-4.0/cli/cli_trace.cpp apitrace-4.0-new/cli/cli_trace.cpp +--- apitrace-4.0/cli/cli_trace.cpp 2013-05-02 09:05:06.000000000 +0200 ++++ apitrace-4.0-new/cli/cli_trace.cpp 2014-03-07 22:06:51.312093308 +0100 +@@ -126,7 +126,7 @@ traceProgram(trace::API api, + return 1; + } + +- os::String wrapperPath = findWrapper(wrapperFilename); ++ os::String wrapperPath = findWrapper(wrapperFilename, argv[0]); + if (!wrapperPath.length()) { + std::cerr << "error: failed to find " << wrapperFilename << "\n"; + goto exit; diff --git a/apitrace.spec b/apitrace.spec index 7de4965..1e802e4 100644 --- a/apitrace.spec +++ b/apitrace.spec @@ -1,6 +1,6 @@ Name: apitrace Version: 4.0 -Release: 4%{?dist} +Release: 5%{?dist} Summary: Tools for tracing OpenGL License: MIT @@ -15,6 +15,8 @@ Patch1: apitrace-4.0_libdir.patch Patch2: apitrace-4.0_resources.patch # Remove gzguts.h requirement (not upstreamable, needed for Patch0) Patch3: apitrace-4.0_gzguts.patch +# Support tracing 32bit binaries on 64bit +Patch4: apitrace-4.0_support-32bit-preload.patch BuildRequires: cmake BuildRequires: qtwebkit-devel @@ -24,6 +26,7 @@ BuildRequires: snappy-devel BuildRequires: qjson-devel BuildRequires: desktop-file-utils +Requires: %{name}-libs%{_isa} = %{version}-%{release} # scripts/snapdiff.py Requires: python-pillow @@ -36,6 +39,14 @@ apitrace consists of a set of tools to: * visualize and edit trace files +%package libs +Summary: Libraries used by apitrace +Requires: %{name} = %{version}-%{release} + +%description libs +Libraries used by apitrace + + %package gui Summary: Graphical frontend for apitrace Requires: %{name}%{_isa} = %{version}-%{release} @@ -50,6 +61,7 @@ This package contains qapitrace, the Graphical frontend for apitrace. %patch1 -p1 %patch2 -p1 %patch3 -p1 +%patch4 -p1 # Remove bundled libraries, except khronos headers rm -rf `ls -1 thirdparty | grep -v khronos` @@ -89,6 +101,8 @@ chmod 0644 %{buildroot}%{_libdir}/%{name}/scripts/highlight.py %{_bindir}/apitrace %{_bindir}/eglretrace %{_bindir}/glretrace + +%files libs %{_libdir}/%{name}/ %files gui @@ -98,6 +112,10 @@ chmod 0644 %{buildroot}%{_libdir}/%{name}/scripts/highlight.py %changelog +* Sat Mar 07 2014 Sandro Mani - 4.0-5 +- Split off libs package +- Allow tracing 32bit binaries on 64bit + * Mon Nov 18 2013 Sandro Mani - 4.0-4 - chmod 0644 scripts/highlight.py - Fix all python shebangs according to fedora guidelines