Update to 11.0.1

This commit is contained in:
Stan Cox 2021-07-08 16:50:43 -04:00
parent 77d455a6b5
commit 90c81439ea
10 changed files with 41 additions and 373 deletions

2
.gitignore vendored
View File

@ -25,3 +25,5 @@
/dyninst-10.2.1.tar.gz
/dyninst-11.0.0.tar.gz
/testsuite-11.0.0.tar.gz
/dyninst-11.0.1.tar.gz
/testsuite-11.0.1.tar.gz

View File

@ -1,317 +0,0 @@
Debuginfod is a lightweight web service that indexes ELF/DWARF debugging
resources by build-id and serves them over HTTP.
This patch enables dyninst to query debuginfod servers for a file's
separate debuginfo when it otherwise cannot be found.
This patch also adds a cmake option -DENABLE_DEBUGINFOD to control
whether dyninst is built with debuginfod support.
This requires having the debuginfod client library (libdebuginfod)
and header installed.
Debuginfod is distributed with elfutils, for more information see
https://sourceware.org/elfutils/Debuginfod.html
---
cmake/ElfUtils.cmake | 37 ++++++++---
cmake/Modules/FindLibDebuginfod.cmake | 76 +++++++++++++++++++++
cmake/options.cmake | 2 +
elf/CMakeLists.txt | 3 +
elf/src/Elf_X.C | 95 ++++++++++++++++++++-------
5 files changed, 178 insertions(+), 35 deletions(-)
create mode 100644 cmake/Modules/FindLibDebuginfod.cmake
--- dyninst-10.2.1/dyninst-10.2.1/cmake/ElfUtils.cmake
+++ dyninst-10.2.1/dyninst-10.2.1/cmake/ElfUtils.cmake
@@ -28,7 +28,7 @@
#
#======================================================================================
-if(LibElf_FOUND AND LibDwarf_FOUND)
+if(LibElf_FOUND AND LibDwarf_FOUND AND (LibDebuginfod_FOUND OR NOT ENABLE_DEBUGINFOD))
return()
endif()
@@ -37,7 +37,12 @@ if(NOT UNIX)
endif()
# Minimum acceptable version of elfutils
-set(_min_version 0.178)
+if(ENABLE_DEBUGINFOD)
+ set(_min_version 0.179)
+else()
+ set(_min_version 0.178)
+endif()
+
set(ElfUtils_MIN_VERSION ${_min_version}
CACHE STRING "Minimum acceptable elfutils version")
if(${ElfUtils_MIN_VERSION} VERSION_LESS ${_min_version})
@@ -62,7 +67,7 @@ set(ElfUtils_LIBRARYDIR "${ElfUtils_ROOT_DIR}/lib"
CACHE PATH "Hint directory that contains the elfutils library files")
# libelf/dwarf-specific directory hints
-foreach(l LibElf LibDwarf)
+foreach(l LibElf LibDwarf LibDebuginfod)
foreach(d ROOT_DIR INCLUDEDIR LIBRARYDIR)
set(${l}_${d} ${ElfUtils_${d}})
endforeach()
@@ -72,18 +77,30 @@ endforeach()
find_package(LibElf ${ElfUtils_MIN_VERSION})
-# Don't search for libdw if we didn't find a suitable libelf
+# Don't search for libdw or libdebuginfod if we didn't find a suitable libelf
if(LibElf_FOUND)
find_package(LibDwarf ${ElfUtils_MIN_VERSION})
+ if (ENABLE_DEBUGINFOD)
+ find_package(LibDebuginfod ${ElfUtils_MIN_VERSION})
+ endif()
endif()
# -------------- SOURCE BUILD -------------------------------------------------
-if(LibElf_FOUND AND LibDwarf_FOUND)
- set(_eu_root ${ElfUtils_ROOT_DIR})
- set(_eu_inc_dirs ${LibElf_INCLUDE_DIRS} ${LibDwarf_INCLUDE_DIRS})
- set(_eu_lib_dirs ${LibElf_LIBRARY_DIRS} ${LibDwarf_LIBRARY_DIRS})
- set(_eu_libs ${LibElf_LIBRARIES} ${LibDwarf_LIBRARIES})
+if(LibElf_FOUND AND LibDwarf_FOUND AND (NOT ENABLE_DEBUGINFOD OR LibDebuginfod_FOUND))
+ if(ENABLE_DEBUGINFOD AND LibDebuginfod_FOUND)
+ set(_eu_root ${ElfUtils_ROOT_DIR})
+ set(_eu_inc_dirs ${LibElf_INCLUDE_DIRS} ${LibDwarf_INCLUDE_DIRS} ${LibDebuginfod_INCLUDE_DIRS})
+ set(_eu_lib_dirs ${LibElf_LIBRARY_DIRS} ${LibDwarf_LIBRARY_DIRS} ${LibDebuginfod_LIBRARY_DIRS})
+ set(_eu_libs ${LibElf_LIBRARIES} ${LibDwarf_LIBRARIES} ${LibDebuginfod_LIBRARIES})
+ else()
+ set(_eu_root ${ElfUtils_ROOT_DIR})
+ set(_eu_inc_dirs ${LibElf_INCLUDE_DIRS} ${LibDwarf_INCLUDE_DIRS})
+ set(_eu_lib_dirs ${LibElf_LIBRARY_DIRS} ${LibDwarf_LIBRARY_DIRS})
+ set(_eu_libs ${LibElf_LIBRARIES} ${LibDwarf_LIBRARIES})
+ endif()
add_library(ElfUtils SHARED IMPORTED)
+elseif(ENABLE_DEBUGINFOD AND NOT LibDebuginfod_FOUND)
+ message(FATAL_ERROR "Debuginfod enabled but not found")
elseif(NOT (LibElf_FOUND AND LibDwarf_FOUND) AND STERILE_BUILD)
message(FATAL_ERROR "Elfutils not found and cannot be downloaded because build is sterile.")
else()
--- /dev/null
+++ dyninst-10.2.1/dyninst-10.2.1/cmake/Modules/FindLibDebuginfod.cmake
@@ -0,0 +1,76 @@
+#========================================================================================
+# FindDebuginfod
+# -----------
+#
+# Find debuginfod library and headers
+#
+# The module defines the following variables:
+#
+# This module reads hints about search locations from variables::
+#
+# LibDebuginfod_ROOT_DIR - Base directory the of libdebuginfod installation
+# LibDebuginfod_INCLUDEDIR - Hint directory that contains the libdebuginfod headers files
+# LibDebuginfod_LIBRARYDIR - Hint directory that contains the libdebuginfod library files
+#
+# and saves search results persistently in CMake cache entries::
+#
+# LibDebuginfod_FOUND - True if headers and requested libraries were found
+# LibDebuginfod_INCLUDE_DIRS - libdebuginfod include directories
+# LibDebuginfod_LIBRARY_DIRS - Link directories for libdebuginfod libraries
+# LibDebuginfod_LIBRARIES - libdebuginfod library files
+#
+# Utilize package config (e.g. /usr/lib64/pkgconfig/libdebuginfod.pc) to fetch
+# version information.
+#
+#========================================================================================
+
+find_package(PkgConfig QUIET)
+pkg_check_modules(PC_Debuginfod QUIET REQUIRED libdebuginfod>=${ElfUtils_MIN_VERSION})
+set(LibDebuginfod_VERSION "${PC_Debuginfod_VERSION}")
+
+find_path(LibDebuginfod_INCLUDE_DIRS
+ NAMES
+ debuginfod.h
+ HINTS
+ ${PC_Debuginfod_INCLUDEDIR}
+ ${PC_Debuginfod_INCLUDE_DIRS}
+ ${LibDebuginfod_ROOT_DIR}/include
+ ${LibDebuginfod_ROOT_DIR}
+ ${LibDebuginfod_INCLUDEDIR}
+ PATHS
+ ${DYNINST_SYSTEM_INCLUDE_PATHS}
+ PATH_SUFFIXES
+ ${_path_suffixes}
+ DOC
+ "libdebuginfod include directories")
+
+find_library(LibDebuginfod_LIBRARIES
+ NAMES
+ libdebuginfod.so.1 libdebuginfod.so
+ HINTS
+ ${PC_Debuginfod_LIBDIR}
+ ${PC_Debuginfod_LIBRARY_DIRS}
+ ${LibDebuginfod_ROOT_DIR}/lib
+ ${LibDebuginfod_ROOT_DIR}
+ ${LibDebuginfod_LIBRARYDIR}
+ PATHS
+ ${DYNINST_SYSTEM_LIBRARY_PATHS}
+ PATH_SUFFIXES
+ ${_path_suffixes})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LibDebuginfod
+ FOUND_VAR
+ LibDebuginfod_FOUND
+ REQUIRED_VARS
+ LibDebuginfod_INCLUDE_DIRS
+ LibDebuginfod_LIBRARIES
+ VERSION_VAR
+ LibDebuginfod_VERSION)
+
+if(LibDebuginfod_FOUND)
+ set(LibDebuginfod_INCLUDE_DIRS ${LibDebuginfod_INCLUDE_DIRS})
+ set(LibDebuginfod_LIBRARIES ${LibDebuginfod_LIBRARIES})
+ get_filename_component(_debuginfod_dir ${LibDebuginfod_LIBRARIES} DIRECTORY)
+ set(LibDebuginfod_LIBRARY_DIRS ${_debuginfod_dir} "${_debuginfod_dir}/elfutils")
+endif()
--- dyninst-10.2.1/dyninst-10.2.1/cmake/options.cmake
+++ dyninst-10.2.1/dyninst-10.2.1/cmake/options.cmake
@@ -16,6 +16,8 @@ option(USE_COTIRE "Enable Cotire precompiled headers")
option (ENABLE_LTO "Enable Link-Time Optimization" OFF)
+option(ENABLE_DEBUGINFOD "Enable debuginfod support" OFF)
+
# Some global on/off switches
if (LIGHTWEIGHT_SYMTAB)
add_definitions (-DWITHOUT_SYMTAB_API -DWITH_SYMLITE)
--- dyninst-10.2.1/dyninst-10.2.1/elf/CMakeLists.txt
+++ dyninst-10.2.1/dyninst-10.2.1/elf/CMakeLists.txt
@@ -27,5 +27,8 @@ endif()
add_dependencies(dynElf ElfUtils)
target_link_private_libraries(dynElf ${ElfUtils_LIBRARIES})
+if (ENABLE_DEBUGINFOD AND LibDebuginfod_FOUND)
+ add_definitions(-DDEBUGINFOD_LIB)
+endif()
add_definitions(-DDYNELF_LIB)
--- dyninst-10.2.1/dyninst-10.2.1/elf/src/Elf_X.C
+++ dyninst-10.2.1/dyninst-10.2.1/elf/src/Elf_X.C
@@ -47,6 +47,9 @@
#include <sstream>
#include <libelf.h>
+#if DEBUGINFOD_LIB
+#include <elfutils/debuginfod.h>
+#endif
using namespace std;
using boost::crc_32_type;
@@ -1722,37 +1725,79 @@ bool Elf_X::findDebugFile(std::string origfilename, string &output_name, char* &
}
}
- if (debugFileFromDebugLink.empty())
- return false;
+ if (!debugFileFromDebugLink.empty()) {
+ char *mfPathNameCopy = strdup(origfilename.c_str());
+ string objectFileDirName = dirname(mfPathNameCopy);
- char *mfPathNameCopy = strdup(origfilename.c_str());
- string objectFileDirName = dirname(mfPathNameCopy);
+ vector<string> fnames = list_of
+ (objectFileDirName + "/" + debugFileFromDebugLink)
+ (objectFileDirName + "/.debug/" + debugFileFromDebugLink)
+ ("/usr/lib/debug/" + objectFileDirName + "/" + debugFileFromDebugLink);
- vector<string> fnames = list_of
- (objectFileDirName + "/" + debugFileFromDebugLink)
- (objectFileDirName + "/.debug/" + debugFileFromDebugLink)
- ("/usr/lib/debug/" + objectFileDirName + "/" + debugFileFromDebugLink);
+ free(mfPathNameCopy);
- free(mfPathNameCopy);
+ for(unsigned i = 0; i < fnames.size(); i++) {
+ bool result = loadDebugFileFromDisk(fnames[i], output_buffer, output_buffer_size);
+ if (!result)
+ continue;
- for(unsigned i = 0; i < fnames.size(); i++) {
- bool result = loadDebugFileFromDisk(fnames[i], output_buffer, output_buffer_size);
- if (!result)
- continue;
-
- boost::crc_32_type crcComputer;
- crcComputer.process_bytes(output_buffer, output_buffer_size);
- if(crcComputer.checksum() != debugFileCrc) {
- munmap(output_buffer, output_buffer_size);
- continue;
- }
+ boost::crc_32_type crcComputer;
+ crcComputer.process_bytes(output_buffer, output_buffer_size);
+ if(crcComputer.checksum() != debugFileCrc) {
+ munmap(output_buffer, output_buffer_size);
+ continue;
+ }
+
+ output_name = fnames[i];
+ cached_debug_buffer = output_buffer;
+ cached_debug_size = output_buffer_size;
+ cached_debug_name = output_name;
+ return true;
+ }
+ }
- output_name = fnames[i];
- cached_debug_buffer = output_buffer;
- cached_debug_size = output_buffer_size;
- cached_debug_name = output_name;
- return true;
+#ifdef DEBUGINFOD_LIB
+ if (!debugFileFromBuildID.empty()) {
+ // Given /usr/lib/debug/.buildid/XX/YYYYYY.debug, isolate XXYYYYYY.
+ size_t idx1 = debugFileFromBuildID.find_last_of("/");
+ size_t idx2 = debugFileFromBuildID.find_last_of(".");
+
+ if (idx1 == string::npos || idx2 == string::npos
+ || idx1 < 2 || idx1 > idx2)
+ return false;
+
+ idx1 -= 2;
+ string buildid(debugFileFromBuildID.substr(idx1, idx2 - idx1));
+ buildid.erase(2, 1);
+
+ debuginfod_client *client = debuginfod_begin();
+ if (client == NULL)
+ return false;
+
+ char *filename;
+ int fd = debuginfod_find_debuginfo(client,
+ (const unsigned char *)buildid.c_str(),
+ 0, &filename);
+ debuginfod_end(client);
+
+ if (fd >= 0) {
+ string fname = string(filename);
+ free(filename);
+ close(fd);
+
+ bool result = loadDebugFileFromDisk(fname,
+ output_buffer,
+ output_buffer_size);
+ if (result) {
+ output_name = fname;
+ cached_debug_buffer = output_buffer;
+ cached_debug_size = output_buffer_size;
+ cached_debug_name = output_name;
+ return true;
+ }
+ }
}
+#endif
return false;
}

View File

@ -3,8 +3,8 @@ Remove extraneous error messages of the form:
err message: invalid DWARF
which are repeated in some circumstances without adding useful context
--- dyninst-11.0.0/dyninst-11.0.0/symtabAPI/src/dwarfWalker.C.orig 2021-04-08 16:48:12.000000000 -0400
+++ dyninst-11.0.0/dyninst-11.0.0/symtabAPI/src/dwarfWalker.C 2021-04-27 12:48:55.643978425 -0400
--- dyninst-11.0.1/symtabAPI/src/dwarfWalker.C.orig 2021-04-08 16:48:12.000000000 -0400
+++ dyninst-11.0.1/symtabAPI/src/dwarfWalker.C 2021-04-27 12:48:55.643978425 -0400
@@ -1858,1 +1858,1 @@
- cerr << "err message: " << dwarf_errmsg(dwarf_errno()) << endl;
+ dwarf_printf("(0x%lx) Error while decoding location: %s\n", id(), dwarf_errmsg(dwarf_errno()));

View File

@ -0,0 +1,11 @@
rhbz1973038
--- dyninst-11.0.1/dataflowAPI/src/RoseInsnFactory.C.orig 2021-06-09 15:54:21.753883619 -0400
+++ dyninst-11.0.1/dataflowAPI/src/RoseInsnFactory.C 2021-06-23 14:17:37.854933719 -0400
@@ -317,5 +317,5 @@
// It looks like the ROSE semantics code will infer the target from
// the bo field. So, what is passed in as the third operands does not matter
- if(branch_target) {
+ if(branch_target || iapi_opcode == power_op_bc) {
rose_operands->append_operand(new SgAsmDoubleWordValueExpression(branch_target));
} else if(power_op_bcctr == iapi_opcode) {

View File

@ -1,13 +0,0 @@
diff --git a/testsuite-10.1.0/src/dyninst/test1_3.C b/testsuite-10.1.0/src/dyninst/test1_3.C
index d32f630..b9bd0ba 100644
--- a/testsuite-10.1.0/src/dyninst/test1_3.C
+++ b/testsuite-10.1.0/src/dyninst/test1_3.C
@@ -134,7 +134,7 @@ test_results_t test1_3_Mutator::executeTest()
}
// see if we can find the address
- if (expr3_1->getBaseAddr() <= 0)
+ if (expr3_1->getBaseAddr() == 0)
{
logerror("*Error*: address %p for %s is not valid\n",
expr3_1->getBaseAddr(), globalVar);

View File

@ -1,17 +1,18 @@
Summary: An API for Run-time Code Generation
License: LGPLv2+
Name: dyninst
Group: Development/Libraries
Release: 1%{?dist}
URL: http://www.dyninst.org
Version: 11.0.0
Version: 11.0.1
ExclusiveArch: %{ix86} x86_64 ppc64le aarch64
Source0: https://github.com/dyninst/dyninst/archive/v%{version}/dyninst-%{version}.tar.gz
Source1: https://github.com/dyninst/testsuite/archive/%{version}/testsuite-%{version}.tar.gz
Patch1: testsuite-11.0.0-test12.patch
Patch2: testsuite-11.0.0-386.patch
Patch3: dyninst-11.0.0-dwarf.patch
Patch1: dyninst-11.0.1-dwarf.patch
Patch2: dyninst-11.0.1-rosebc.patch
Patch3: testsuite-11.0.1-386.patch
%global dyninst_base dyninst-%{version}
%global testsuite_base testsuite-%{version}
@ -20,7 +21,7 @@ BuildRequires: gcc-c++
BuildRequires: elfutils-devel
BuildRequires: elfutils-libelf-devel
BuildRequires: elfutils-debuginfod-client-devel
BuildRequires: boost-devel >= 1.75
BuildRequires: boost-devel
BuildRequires: binutils-devel
BuildRequires: cmake
BuildRequires: libtirpc-devel
@ -50,11 +51,13 @@ the creation of tools and applications that use run-time code patching.
%package doc
Summary: Documentation for using the Dyninst API
Group: Documentation
%description doc
dyninst-doc contains API documentation for the Dyninst libraries.
%package devel
Summary: Header files for compiling programs with Dyninst
Group: Development/System
Requires: dyninst = %{version}-%{release}
Requires: boost-devel
Requires: tbb-devel
@ -66,6 +69,7 @@ that uses Dyninst.
%package testsuite
Summary: Programs for testing Dyninst
Group: Development/System
Requires: dyninst = %{version}-%{release}
Requires: dyninst-devel = %{version}-%{release}
%description testsuite
@ -76,9 +80,14 @@ making sure that dyninst works properly.
%setup -q -n %{name}-%{version} -c
%setup -q -T -D -a 1
%patch1 -p1 -b .test12
%patch2 -p1 -b .386
pushd %{dyninst_base}
%patch1 -p1 -b .386
%patch2 -p1 -b .rose
popd
pushd %{testsuite_base}
%patch3 -p1 -b .dwarf
popd
# cotire seems to cause non-deterministic gcc errors
# https://bugzilla.redhat.com/show_bug.cgi?id=1420551
@ -104,7 +113,8 @@ export CFLAGS CXXFLAGS LDFLAGS
-DINSTALL_INCLUDE_DIR:PATH=%{_includedir}/dyninst \
-DINSTALL_CMAKE_DIR:PATH=%{_libdir}/cmake/Dyninst \
-DCMAKE_BUILD_TYPE=None \
-DCMAKE_SKIP_RPATH:BOOL=YES
-DCMAKE_SKIP_RPATH:BOOL=YES \
.
%cmake_build
# Hack to install dyninst nearby, so the testsuite can use it
@ -120,6 +130,7 @@ cd ../%{testsuite_base}
-DINSTALL_DIR:PATH=%{_libdir}/dyninst/testsuite \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DCMAKE_SKIP_RPATH:BOOL=YES \
.
%cmake_build
%install
@ -182,6 +193,9 @@ find %{buildroot}%{_libdir}/dyninst/testsuite/ \
%attr(644,root,root) %{_libdir}/dyninst/testsuite/*.a
%changelog
* Thu Jul 08 2021 Stan Cox <scox@redhat.com> - 11.0.1
- Update to 11.0.1
* Fri Apr 30 2021 Stan Cox <scox@redhat.com> - 11.0.0
- Update to 11.0.0

View File

@ -1,2 +1,2 @@
SHA512 (dyninst-11.0.0.tar.gz) = 30d73af656a597e4874f8b6bf0fb388e98ef591901ece9bbcaee389b9d09c44d1f3c3d323c959e6835971295eb8977d6a92c4bbb216b038126fbbc8360e9318d
SHA512 (testsuite-11.0.0.tar.gz) = bf3568e74eeb5ff7c5e8266f7843d1dd3563ab87e6275d4d586e2bbaaf965035356d869d886e527b3f000ba4213bdc035864c19f79bf648ff136d564c88a1018
SHA512 (dyninst-11.0.1.tar.gz) = 9c439be0252edae0ed3fcfa05b38595b614a91b6627afa85db126df32d5c5de5dc9413a70caf52bee7ac2349d24947626f6370f0dbf19413916c39e01679444f
SHA512 (testsuite-11.0.1.tar.gz) = 3c671adb9fd7e1b7cc6374c45b3fe2325b725f9a2add300ae46d95f3169b75719fb912c536a609631ca3eaf1c632e3d32b93a3d8e5ae26f03f0611bc9226723a

View File

@ -1,15 +0,0 @@
--- dyninst-10.1.0/testsuite-10.1.0/src/proccontrol/pcontrol_mutatee_tools.c.orig 2019-05-31 05:20:00.492379706 +0200
+++ dyninst-10.1.0/testsuite-10.1.0/src/proccontrol/pcontrol_mutatee_tools.c 2019-05-31 05:10:11.354826668 +0200
@@ -62,9 +62,9 @@
#if !defined(os_windows_test)
#include <poll.h>
-static unsigned int gettid(){
- return (unsigned int)pthread_self();
-}
+// static unsigned int gettid(){
+// return (unsigned int)pthread_self();
+// }
#endif
thread_t threads[MAX_POSSIBLE_THREADS];

View File

@ -1,14 +0,0 @@
--- dyninst-10.2.0/testsuite-10.1.0/src/test_lib.h
+++ dyninst-10.2.0/testsuite-10.1.0/src/test_lib.h
@@ -158,3 +158,3 @@
- TESTLIB_DLL_EXPORT virtual ~LocErr() THROW;
+ TESTLIB_DLL_EXPORT virtual ~LocErr() throw();
--- dyninst-10.2.0/testsuite-10.1.0/src/test_lib.C
+++ dyninst-10.2.0/testsuite-10.1.0/src/test_lib.C
@@ -112,3 +112,3 @@
-LocErr::~LocErr() THROW
+LocErr::~LocErr() throw()
{}

View File

@ -1,5 +1,5 @@
--- dyninst-11.0.0/testsuite-11.0.0/CMakeLists.txt
+++ dyninst-11.0.0/testsuite-11.0.0/CMakeLists.txt
--- testsuite-11.0.1/CMakeLists.txt
+++ testsuite-11.0.1/CMakeLists.txt
@@ -111,7 +111,8 @@
if(UNIX)
enable_language(ASM-ATT)