Skip to content

Commit

Permalink
Merge branch 'master' into new-parallel-parsing
Browse files Browse the repository at this point in the history
# Conflicts:
#	dyninstAPI/src/Relocation/Transformers/Movement-analysis.C
#	symtabAPI/src/LineInformation.C
#	symtabAPI/src/dwarfWalker.C
  • Loading branch information
wrwilliams committed Sep 27, 2017
2 parents 9f77aa4 + 84ffda2 commit 3cd48c5
Show file tree
Hide file tree
Showing 49 changed files with 3,317 additions and 3,866 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Expand Up @@ -114,9 +114,8 @@ DyninstAPI*.tgz
common/h/version.h
Doxyfile
doxyfiles/*
*/*.dir/
*.dir/
*/Debug/
*/Release/
cotire/
.idea/*
boost/
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -16,7 +16,7 @@ set(RT_BINARY_DIR ${PROJECT_BINARY_DIR}/dyninstAPI_RT)

include (${DYNINST_ROOT}/cmake/shared.cmake)

configure_file(cmake/version.h.in common/h/version.h)
configure_file(cmake/version.h.in common/h/dyninstversion.h)
include_directories(${PROJECT_BINARY_DIR})
include_directories(${PROJECT_BINARY_DIR}/common/h)
set (HEADER_DIRS common
Expand Down
2 changes: 1 addition & 1 deletion INSTALL
Expand Up @@ -25,7 +25,7 @@ CMAKE_CXX_COMPILER: C++ compiler to use
CMAKE_C_COMPILER: C compiler to use
LIBELF_INCLUDE_DIR: location of elf.h and libelf.h
LIBELF_LIBRARIES: full path of libelf.so
LIBDWARF_INCLUDE_DIR: location of libdwarf.h
LIBDWARF_INCLUDE_DIR: location of libdw.h
LIBDWARF_LIBRARIES: full path of libdwarf.so
IBERTY_LIBRARIES: full path of libiberty.[a|so]; libiberty.a must be built with -fPIC
CMAKE_[C|CXX]_COMPILER_FLAGS: additional C/C++ compiler flags to use
Expand Down
5 changes: 2 additions & 3 deletions cmake/Modules/FindLibDwarf.cmake
Expand Up @@ -14,20 +14,19 @@ endif (LIBDWARF_LIBRARIES AND LIBDWARF_INCLUDE_DIRS)

find_path (LIBDWARF_INCLUDE_DIR
NAMES
libdwarf.h
elfutils/libdw.h
HINTS
${LIBDWARF_INCLUDE_DIRS}
PATHS
/usr/include
/usr/include/libdwarf
/usr/local/include
/opt/local/include
/sw/include
ENV CPATH) # PATH and INCLUDE will also work

find_library (LIBDWARF_LIBRARIES
NAMES
dwarf
dw
HINTS
${LIBDWARF_LIBRARIES}
PATHS
Expand Down
48 changes: 12 additions & 36 deletions cmake/packages.cmake
@@ -1,18 +1,22 @@
if (UNIX)
find_package (LibDwarf)
find_package (LibElf)
if(NOT LIBELF_FOUND)
message(STATUS "No libelf found, attempting to build as external project")

if(NOT LIBELF_FOUND OR NOT LIBDWARF_FOUND)
message(STATUS "Attempting to build elfutils as external project")
cmake_minimum_required (VERSION 2.8.11)
include(ExternalProject)
ExternalProject_Add(LibElf
PREFIX ${CMAKE_BINARY_DIR}/libelf
PREFIX ${CMAKE_BINARY_DIR}/elfutils
URL https://sourceware.org/elfutils/ftp/0.168/elfutils-0.168.tar.bz2
CONFIGURE_COMMAND <SOURCE_DIR>/configure --enable-shared --prefix=${CMAKE_BINARY_DIR}/libelf
BUILD_COMMAND make -C libelf
INSTALL_COMMAND make -C libelf install
CONFIGURE_COMMAND CFLAGS=-g <SOURCE_DIR>/configure --enable-shared --prefix=${CMAKE_BINARY_DIR}/elfutils
BUILD_COMMAND make
INSTALL_COMMAND make install
)
set(LIBELF_INCLUDE_DIR ${CMAKE_BINARY_DIR}/libelf/include)
set(LIBELF_LIBRARIES ${CMAKE_BINARY_DIR}/libelf/lib/libelf.so)
set(LIBELF_INCLUDE_DIR ${CMAKE_BINARY_DIR}/elfutils/include)
set(LIBELF_LIBRARIES ${CMAKE_BINARY_DIR}/elfutils/lib/libelf.so)
set(LIBDWARF_INCLUDE_DIR ${CMAKE_BINARY_DIR}/elfutils/include)
set(LIBDWARF_LIBRARIES ${CMAKE_BINARY_DIR}/elfutils/lib/libdw.so)
set(SHOULD_INSTALL_LIBELF 1)
else()
set(SHOULD_INSTALL_LIBELF 0)
Expand All @@ -25,34 +29,6 @@ if (UNIX)
add_dependencies(libelf_imp LibElf)
endif()

find_package (LibDwarf)

if(NOT LIBDWARF_FOUND)
message(STATUS "No libdwarf found, attempting to build as external project")
cmake_minimum_required (VERSION 2.8.11)
include(ExternalProject)
ExternalProject_Add(LibDwarf
PREFIX ${CMAKE_BINARY_DIR}/libdwarf
DEPENDS libelf_imp
# URL http://reality.sgiweb.org/davea/libdwarf-20130126.tar.gz
# URL http://sourceforge.net/p/libdwarf/code/ci/20130126/tarball
URL http://www.paradyn.org/libdwarf/libdwarf-20130126.tar.gz
# GIT_REPOSITORY git://git.code.sf.net/p/libdwarf/code libdwarf-code
# GIT_TAG 20130126
CONFIGURE_COMMAND env CFLAGS=${CMAKE_C_FLAGS}\ -I${LIBELF_INCLUDE_DIR} LDFLAGS=-L${CMAKE_BINARY_DIR}/libelf/lib <SOURCE_DIR>/libdwarf/configure --enable-shared
BUILD_COMMAND make
INSTALL_DIR ${CMAKE_BINARY_DIR}/libdwarf
INSTALL_COMMAND mkdir -p <INSTALL_DIR>/include && mkdir -p <INSTALL_DIR>/lib && install <SOURCE_DIR>/libdwarf/libdwarf.h <INSTALL_DIR>/include && install <SOURCE_DIR>/libdwarf/dwarf.h <INSTALL_DIR>/include && install <BINARY_DIR>/libdwarf.so <INSTALL_DIR>/lib
)
add_dependencies(LibDwarf libelf_imp)
set(LIBDWARF_INCLUDE_DIR ${CMAKE_BINARY_DIR}/libdwarf/include)
set(LIBDWARF_LIBRARIES ${CMAKE_BINARY_DIR}/libdwarf/lib/libdwarf.so)
else()
# Unfortunately, libdwarf doesn't always link to libelf itself.
# (e.g. https://bugzilla.redhat.com/show_bug.cgi?id=1061432)
set(LIBDWARF_LIBRARIES ${LIBDWARF_LIBRARIES} ${LIBELF_LIBRARIES})
endif()

add_library(libdwarf_imp SHARED IMPORTED)
set_property(TARGET libdwarf_imp
PROPERTY IMPORTED_LOCATION ${LIBDWARF_LIBRARIES})
Expand Down
12 changes: 6 additions & 6 deletions common/src/arch-x86.C
Expand Up @@ -9510,9 +9510,9 @@ static unsigned int ia32_decode_modrm(const unsigned int addrSzAttr, const unsig
addr++;

/* Get displacements we're going to use */
const unsigned char* disp8 = (const unsigned char*)addr;
const unsigned short* disp16 = (const unsigned short*)addr;
const unsigned int* disp32 = (const unsigned int*)addr;
const char* disp8 = (const char*)addr;
const short* disp16 = (const short*)addr;
const int* disp32 = (const int*)addr;

if(addrSzAttr == 1) // 16-bit, cannot have SIB
{
Expand Down Expand Up @@ -9693,9 +9693,9 @@ static unsigned int ia32_decode_modrm(const unsigned int addrSzAttr, const unsig
}

/* Update displacement pointers */
disp8 = (const unsigned char*)addr;
disp16 = (const unsigned short*)addr;
disp32 = (const unsigned int*)addr;
disp8 = (const char*)addr;
disp16 = (const short*)addr;
disp32 = (const int*)addr;

/* this is tricky: there is a disp32 iff (1) rm == 5 or (2) hassib && base == 5 */
unsigned char check5 = hassib ? base : rm;
Expand Down
2 changes: 1 addition & 1 deletion dataflowAPI/rose/semantics/MemoryMap.C
Expand Up @@ -454,7 +454,7 @@ MemoryMap::insertProcess(const std::string &locatorString) {
throw insertProcessError(locatorString, "cannot open " + memName + ": " + strerror(errno));

// Read each line from the /proc/xxx/maps to figure out what memory is mapped in the subordinate process. The format for
// the part we're interested in is /^([0-9a-f]+)-([0-9a-f]+) ([-r][-w][-x])/ where $1 is the inclusive starting address, $2
// the part we're interested in is /^([0-9a-f]+)-([0-9a-f]+) ([-r][-w][-x])/ where $2 is the inclusive starting address, $2
// is the exclusive ending address, and $3 are the permissions.
int mapsFileLineNumber = 0;
while (rose_getline(&local.buf, &local.bufsz, local.mapsFile)>0) {
Expand Down
8 changes: 4 additions & 4 deletions dataflowAPI/rose/util/Message.C
Expand Up @@ -1752,7 +1752,7 @@ Facilities::ControlTerm::toString() const {

// class method; thread-safe
// Matches the Perl regular expression /^\s*([a-zA-Z]\w*((\.|::)[a-zA-Z]\w*)*/
// On match, returns $1 and str points to the next character after the regular expression
// On match, returns $2 and str points to the next character after the regular expression
// When not matched, returns "" and str is unchanged
SAWYER_EXPORT std::string
Facilities::parseFacilityName(const char *&str) {
Expand All @@ -1775,7 +1775,7 @@ Facilities::parseFacilityName(const char *&str) {
}

// class method; thread-safe
// Matches the Perl regular expression /^\s*([+!]?)/ and returns $1 on success with str pointing to the character after the
// Matches the Perl regular expression /^\s*([+!]?)/ and returns $2 on success with str pointing to the character after the
// match. Returns the empty string on failure with str not adjusted.
SAWYER_EXPORT std::string
Facilities::parseEnablement(const char *&str) {
Expand All @@ -1789,7 +1789,7 @@ Facilities::parseEnablement(const char *&str) {
}

// class method; thread-safe
// Matches the Perl regular expression /^\s*(<=?|>=?)/ and returns $1 on success with str pointing to the character after
// Matches the Perl regular expression /^\s*(<=?|>=?)/ and returns $2 on success with str pointing to the character after
// the match. Returns the empty string on failure with str not adjusted.
SAWYER_EXPORT std::string
Facilities::parseRelation(const char *&str) {
Expand All @@ -1807,7 +1807,7 @@ Facilities::parseRelation(const char *&str) {

// class method; thread-safe
// Matches the Perl regular expression /^\s*(all|none|debug|trace|where|info|warn|error|fatal)\b/
// On match, returns $1 and str points to the next character after the match
// On match, returns $2 and str points to the next character after the match
// On failure, returns "" and str is unchanged
SAWYER_EXPORT std::string
Facilities::parseImportanceName(const char *&str) {
Expand Down
2 changes: 1 addition & 1 deletion dwarf/CMakeLists.txt
Expand Up @@ -20,7 +20,7 @@ set (SRC_LIST
)


dyninst_library(dynDwarf dynElf common ${LIBDWARF_LIBRARIES})
dyninst_library(dynDwarf dynElf common ${LIBDWARF_LIBRARIES} ${LIBELF_LIBRARIES})
if (USE_COTIRE)
cotire(dynDwarf)
endif()
33 changes: 18 additions & 15 deletions dwarf/h/dwarfExprParser.h
Expand Up @@ -33,7 +33,7 @@

#include <stack>
#include "dyn_regs.h"
#include "libdwarf.h"
#include "elfutils/libdw.h"
#include "dwarf.h"
#include "util.h"

Expand All @@ -42,28 +42,31 @@ namespace Dyninst {
class VariableLocation;
class ProcessReader;

namespace Dwarf {
namespace DwarfDyninst{

class DwarfResult;

DYNDWARF_EXPORT int Register_DWARFtoMachineEnc32(int n);
DYNDWARF_EXPORT int Register_DWARFtoMachineEnc64(int n);

DYNDWARF_EXPORT bool decodeDwarfExpression(Dwarf_Locdesc *dwlocs,
long int *initialStackValue,
Dyninst::VariableLocation &loc,
Dyninst::Architecture arch);
DYNDWARF_EXPORT bool decodeDwarfExpression(Dwarf_Op * expr,
Dwarf_Sword listlen,
long int *initialStackValue,
Dyninst::VariableLocation &loc,
Dyninst::Architecture arch);

DYNDWARF_EXPORT bool decodeDwarfExpression(Dwarf_Locdesc *dwlocs,
long int *initialStackValue,
Dyninst::ProcessReader *reader,
Dyninst::Architecture arch,
long int &end_result);
DYNDWARF_EXPORT bool decodeDwarfExpression(Dwarf_Op * expr,
Dwarf_Sword listlen,
long int *initialStackValue,
Dyninst::ProcessReader *reader,
Dyninst::Architecture arch,
long int &end_result);

DYNDWARF_EXPORT bool decodeDwarfExpression(Dwarf_Locdesc *dwlocs,
long int *initialStackValue,
DwarfResult &res,
Dyninst::Architecture arch);
DYNDWARF_EXPORT bool decodeDwarfExpression(Dwarf_Op * expr,
Dwarf_Sword listlen,
long int *initialStackValue,
DwarfResult &res,
Dyninst::Architecture arch);

}

Expand Down

0 comments on commit 3cd48c5

Please sign in to comment.