diff --git a/.gitignore b/.gitignore index 9ae8f9cd14..1c66f619fb 100644 --- a/.gitignore +++ b/.gitignore @@ -114,8 +114,9 @@ DyninstAPI*.tgz common/h/version.h Doxyfile doxyfiles/* -*/*.dir/ +*.dir/ */Debug/ */Release/ cotire/ -.idea/* \ No newline at end of file +.idea/* + diff --git a/INSTALL b/INSTALL index f78b379fe3..db54646607 100644 --- a/INSTALL +++ b/INSTALL @@ -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 diff --git a/cmake/Modules/FindLibDwarf.cmake b/cmake/Modules/FindLibDwarf.cmake index 6054898956..7b289eeb7c 100644 --- a/cmake/Modules/FindLibDwarf.cmake +++ b/cmake/Modules/FindLibDwarf.cmake @@ -18,20 +18,23 @@ endif (LIBDWARF_LIBRARIES AND LIBDWARF_INCLUDE_DIRS) find_path (LIBDWARF_INCLUDE_DIR NAMES - libdwarf.h + libdw.h HINTS ${LIBDWARF_INCLUDE_DIRS} PATHS /usr/include - /usr/include/libdwarf + /usr/include/elfutils /usr/local/include /opt/local/include /sw/include + /usr/local/include/elfutils + /opt/local/include/elfutils + /sw/include/elfutils ENV CPATH) # PATH and INCLUDE will also work find_library (LIBDWARF_LIBRARIES NAMES - dwarf + dw HINTS ${LIBDWARF_LIBRARIES} PATHS diff --git a/cmake/packages.cmake b/cmake/packages.cmake index cb066c61c8..9b04458fe2 100644 --- a/cmake/packages.cmake +++ b/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 /configure --enable-shared --prefix=${CMAKE_BINARY_DIR}/libelf + CONFIGURE_COMMAND /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/elfutils) + set(LIBDWARF_LIBRARIES ${CMAKE_BINARY_DIR}/elfutils/lib/libdw.so) set(SHOULD_INSTALL_LIBELF 1) else() set(SHOULD_INSTALL_LIBELF 0) @@ -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 CFLAGS=-I${LIBELF_INCLUDE_DIR} LDFLAGS=-L${CMAKE_BINARY_DIR}/libelf/lib /libdwarf/configure --enable-shared - BUILD_COMMAND make - INSTALL_DIR ${CMAKE_BINARY_DIR}/libdwarf - INSTALL_COMMAND mkdir -p /include && mkdir -p /lib && install /libdwarf/libdwarf.h /include && install /libdwarf/dwarf.h /include && install /libdwarf.so /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}) diff --git a/dataflowAPI/rose/semantics/MemoryMap.C b/dataflowAPI/rose/semantics/MemoryMap.C index 17d1a39cb3..31c3880624 100644 --- a/dataflowAPI/rose/semantics/MemoryMap.C +++ b/dataflowAPI/rose/semantics/MemoryMap.C @@ -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) { diff --git a/dataflowAPI/rose/util/Message.C b/dataflowAPI/rose/util/Message.C index 536e553eb8..a8a66ad4ca 100644 --- a/dataflowAPI/rose/util/Message.C +++ b/dataflowAPI/rose/util/Message.C @@ -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) { @@ -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) { @@ -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) { @@ -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) { diff --git a/dwarf/h/dwarfExprParser.h b/dwarf/h/dwarfExprParser.h index e0dea7afdf..769904fae8 100644 --- a/dwarf/h/dwarfExprParser.h +++ b/dwarf/h/dwarfExprParser.h @@ -33,7 +33,7 @@ #include #include "dyn_regs.h" -#include "libdwarf.h" +#include "libdw.h" #include "dwarf.h" #include "util.h" @@ -49,21 +49,24 @@ 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 ** dwlocs, + 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 ** dwlocs, + 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 ** dwlocs, + Dwarf_Sword listlen, + long int *initialStackValue, + DwarfResult &res, + Dyninst::Architecture arch); } diff --git a/dwarf/h/dwarfFrameParser.h b/dwarf/h/dwarfFrameParser.h index 08098d5baa..b4e989ea3d 100644 --- a/dwarf/h/dwarfFrameParser.h +++ b/dwarf/h/dwarfFrameParser.h @@ -36,7 +36,7 @@ #include "dyntypes.h" #include "dyn_regs.h" #include "ProcReader.h" -#include "libdwarf.h" +#include "libdw.h" #include "util.h" namespace Dyninst { @@ -44,118 +44,117 @@ namespace Dyninst { class VariableLocation; namespace Dwarf { - class DwarfResult; + +class DwarfResult; typedef enum { - FE_Bad_Frame_Data = 15, /* to coincide with equivalent SymtabError */ - FE_No_Frame_Entry, - FE_Frame_Read_Error, - FE_Frame_Eval_Error, - FE_No_Error + FE_Bad_Frame_Data = 15, /* to coincide with equivalent SymtabError */ + FE_No_Frame_Entry, + FE_Frame_Read_Error, + FE_Frame_Eval_Error, + FE_No_Error } FrameErrors_t; typedef struct { - Dwarf_Fde *fde_data; - Dwarf_Signed fde_count; - Dwarf_Cie *cie_data; - Dwarf_Signed cie_count; + Dwarf_FDE *fde_data; + Dwarf_Sword fde_count; + Dwarf_CIE *cie_data; + Dwarf_Sword cie_count; } fde_cie_data; class DYNDWARF_EXPORT DwarfFrameParser { - public: - - typedef boost::shared_ptr Ptr; - - static Ptr create(Dwarf_Debug dbg, Architecture arch); - - DwarfFrameParser(Dwarf_Debug dbg_, Architecture arch); - ~DwarfFrameParser(); - - bool hasFrameDebugInfo(); - - bool getRegRepAtFrame(Address pc, - MachRegister reg, - VariableLocation &loc, - FrameErrors_t &err_result); - - bool getRegValueAtFrame(Address pc, - MachRegister reg, - MachRegisterVal ®_result, - ProcessReader *reader, - FrameErrors_t &err_result); - - bool getRegAtFrame(Address pc, - MachRegister reg, - DwarfResult &cons, - FrameErrors_t &err_result); - - // Returns whatever Dwarf claims the function covers. - // We use an entryPC (actually, can be any PC in the function) - // because common has no idea what a Function is and I don't want - // to move this to Symtab. - bool getRegsForFunction(Address entryPC, - MachRegister reg, - std::vector &locs, - FrameErrors_t &err_result); - - - private: - - bool getRegAtFrame_aux(Address pc, - Dwarf_Fde fde, - Dwarf_Half dwarf_reg, - MachRegister orig_reg, - DwarfResult &cons, - Address &lowpc, - FrameErrors_t &err_result); - - bool getFDE(Address pc, - Dwarf_Fde &fde, - Address &low, - Address &high, - FrameErrors_t &err_result); - - bool getDwarfReg(MachRegister reg, - Dwarf_Fde &fde, - Dwarf_Half &dwarf_reg, - FrameErrors_t &err_result); - - bool handleExpression(Address pc, - Dwarf_Signed registerNum, - MachRegister origReg, - Architecture arch, - DwarfResult &cons, - bool &done, - FrameErrors_t &err_result); - struct frameParser_key - { - Dwarf_Debug dbg; - Architecture arch; - frameParser_key(Dwarf_Debug d, Architecture a) : dbg(d), arch(a) - { - } - - bool operator< (const frameParser_key& rhs) const - { - return (dbg < rhs.dbg) || (dbg == rhs.dbg && arch < rhs.arch); - } - - }; - static std::map frameParsers; - - typedef enum { - dwarf_status_uninitialized, - dwarf_status_error, - dwarf_status_ok - } dwarf_status_t; - Dwarf_Debug dbg; - Architecture arch; - dwarf_status_t fde_dwarf_status; - - std::vector fde_data; - void setupFdeData(); - - +public: + + typedef boost::shared_ptr Ptr; + + static Ptr create(::Dwarf * dbg, Architecture arch); + + DwarfFrameParser(::Dwarf * dbg_, Architecture arch); + ~DwarfFrameParser(); + + bool hasFrameDebugInfo(); + + bool getRegRepAtFrame(Address pc, + MachRegister reg, + VariableLocation &loc, + FrameErrors_t &err_result); + + bool getRegValueAtFrame(Address pc, + MachRegister reg, + MachRegisterVal ®_result, + ProcessReader *reader, + FrameErrors_t &err_result); + + bool getRegAtFrame(Address pc, + MachRegister reg, + DwarfResult &cons, + FrameErrors_t &err_result); + + // Returns whatever Dwarf claims the function covers. + // We use an entryPC (actually, can be any PC in the function) + // because common has no idea what a Function is and I don't want + // to move this to Symtab. + bool getRegsForFunction(Address entryPC, + MachRegister reg, + std::vector &locs, + FrameErrors_t &err_result); + + +private: + + bool getRegAtFrame_aux(Address pc, + Dwarf_FDE fde, + Dwarf_Half dwarf_reg, + MachRegister orig_reg, + DwarfResult &cons, + Address &lowpc, + FrameErrors_t &err_result); + + bool getFDE(Address pc, + Dwarf_FDE &fde, + Address &low, + Address &high, + FrameErrors_t &err_result); + + bool getDwarfReg(MachRegister reg, + Dwarf_FDE &fde, + Dwarf_Half &dwarf_reg, + FrameErrors_t &err_result); + + bool handleExpression(Address pc, + Dwarf_Sword registerNum, + MachRegister origReg, + Architecture arch, + DwarfResult &cons, + bool &done, + FrameErrors_t &err_result); + struct frameParser_key + { + ::Dwarf * dbg; + Architecture arch; + frameParser_key(::Dwarf * d, Architecture a) : dbg(d), arch(a) + { + } + + bool operator< (const frameParser_key& rhs) const + { + return (dbg < rhs.dbg) || (dbg == rhs.dbg && arch < rhs.arch); + } + + }; + static std::map frameParsers; + + typedef enum { + dwarf_status_uninitialized, + dwarf_status_error, + dwarf_status_ok + } dwarf_status_t; + ::Dwarf * dbg; + Architecture arch; + dwarf_status_t fde_dwarf_status; + + std::vector fde_data; + void setupFdeData(); }; diff --git a/dwarf/h/dwarfHandle.h b/dwarf/h/dwarfHandle.h index 828c055d86..ea124d739f 100644 --- a/dwarf/h/dwarfHandle.h +++ b/dwarf/h/dwarfHandle.h @@ -31,7 +31,7 @@ #if !defined(DWARF_HANDLE_H_) #define DWARF_HANDLE_H_ -#include "libdwarf.h" +#include "libdw.h" #include "dyntypes.h" #include #include @@ -56,11 +56,11 @@ class DYNDWARF_EXPORT DwarfHandle { } dwarf_status_t; dwarf_status_t init_dwarf_status; - Dwarf_Debug dbg_file_data; - Dwarf_Debug file_data; - Dwarf_Debug *line_data; - Dwarf_Debug *type_data; - Dwarf_Debug *frame_data; + Dwarf dbg_file_data; + Dwarf file_data; + Dwarf *line_data; + Dwarf *type_data; + Dwarf *frame_data; Elf_X *file; Elf_X *dbg_file; @@ -83,9 +83,9 @@ class DYNDWARF_EXPORT DwarfHandle { Elf_X *origFile(); Elf_X *debugLinkFile(); - Dwarf_Debug *line_dbg(); - Dwarf_Debug *type_dbg(); - Dwarf_Debug *frame_dbg(); + Dwarf *line_dbg(); + Dwarf *type_dbg(); + Dwarf *frame_dbg(); DwarfFrameParserPtr frameParser(); }; diff --git a/dwarf/h/dwarfResult.h b/dwarf/h/dwarfResult.h index 890e46fe70..fb256ebc96 100644 --- a/dwarf/h/dwarfResult.h +++ b/dwarf/h/dwarfResult.h @@ -1,8 +1,39 @@ +/* + * See the dyninst/COPYRIGHT file for copyright information. + * + * We provide the Paradyn Tools (below described as "Paradyn") + * on an AS IS basis, and do not warrant its validity or performance. + * We reserve the right to update, modify, or discontinue this + * software at any time. We shall have no obligation to supply such + * updates or modifications or any other form of support to you. + * + * By your use of Paradyn, you understand and agree that we (or any + * other person or entity with proprietary rights in Paradyn) are + * under no obligation to provide either maintenance services, + * update services, notices of latent defects, or correction of + * defects for Paradyn. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + #include "dyn_regs.h" #include "dyntypes.h" -#include -#include -#include "libdwarf.h" +#include "libdw.h" #include "util.h" namespace Dyninst { @@ -13,140 +44,140 @@ class ProcessReader; namespace Dwarf { class DYNDWARF_EXPORT DwarfResult { - // An interface for building representations of Dwarf expressions. - // In concrete mode, we have access to process state and - // can calculate a value. In symbolic mode we lack this information - // and instead produce a representation. - - public: - - typedef enum { - Add, - Sub, - Mul, - Div, - Mod, - Deref, - Pick, - Drop, - And, - Or, - Not, - Xor, - Abs, - GE, - LE, - GT, - LT, - Eq, - Neq, - Shl, - Shr, - ShrArith - } Operator; - - DwarfResult(Architecture a) : arch(a), error(false) {} - virtual ~DwarfResult() {}; - - virtual void pushReg(Dyninst::MachRegister reg) = 0; - virtual void readReg(Dyninst::MachRegister reg) = 0; - virtual void pushUnsignedVal(Dyninst::MachRegisterVal constant) = 0; - virtual void pushSignedVal(Dyninst::MachRegisterVal constant) = 0; - virtual void pushOp(Operator op) = 0; - virtual void pushOp(Operator op, unsigned ref) = 0; - - // The frame base is the logical top of the stack as reported - // in the function's debug info - virtual void pushFrameBase() = 0; - - // And the CFA is the top of the stack as reported in call frame - // information. - virtual void pushCFA() = 0; - - bool err() const { return error; } - - // The conditional branch needs an immediate eval mechanism - virtual bool eval(MachRegisterVal &val) = 0; - - protected: - - // Illegal - Architecture arch; - bool error; + // An interface for building representations of Dwarf expressions. + // In concrete mode, we have access to process state and + // can calculate a value. In symbolic mode we lack this information + // and instead produce a representation. + +public: + + typedef enum { + Add, + Sub, + Mul, + Div, + Mod, + Deref, + Pick, + Drop, + And, + Or, + Not, + Xor, + Abs, + GE, + LE, + GT, + LT, + Eq, + Neq, + Shl, + Shr, + ShrArith + } Operator; + + DwarfResult(Architecture a) : arch(a), error(false) {} + virtual ~DwarfResult() {}; + + virtual void pushReg(Dyninst::MachRegister reg) = 0; + virtual void readReg(Dyninst::MachRegister reg) = 0; + virtual void pushUnsignedVal(Dyninst::MachRegisterVal constant) = 0; + virtual void pushSignedVal(Dyninst::MachRegisterVal constant) = 0; + virtual void pushOp(Operator op) = 0; + virtual void pushOp(Operator op, unsigned ref) = 0; + + // The frame base is the logical top of the stack as reported + // in the function's debug info + virtual void pushFrameBase() = 0; + + // And the CFA is the top of the stack as reported in call frame + // information. + virtual void pushCFA() = 0; + + bool err() const { return error; } + + // The conditional branch needs an immediate eval mechanism + virtual bool eval(MachRegisterVal &val) = 0; + +protected: + + // Illegal + Architecture arch; + bool error; }; class DYNDWARF_EXPORT SymbolicDwarfResult : public DwarfResult { - public: - SymbolicDwarfResult(VariableLocation &v, Architecture a) : - DwarfResult(a), var(v) {}; - virtual ~SymbolicDwarfResult() {}; - - virtual void pushReg(Dyninst::MachRegister reg); - virtual void readReg(Dyninst::MachRegister reg); - virtual void pushUnsignedVal(Dyninst::MachRegisterVal constant); - virtual void pushSignedVal(Dyninst::MachRegisterVal constant); - virtual void pushOp(Operator op); - virtual void pushOp(Operator op, unsigned ref); +public: + SymbolicDwarfResult(VariableLocation &v, Architecture a) : + DwarfResult(a), var(v) {}; + virtual ~SymbolicDwarfResult() {}; + + virtual void pushReg(Dyninst::MachRegister reg); + virtual void readReg(Dyninst::MachRegister reg); + virtual void pushUnsignedVal(Dyninst::MachRegisterVal constant); + virtual void pushSignedVal(Dyninst::MachRegisterVal constant); + virtual void pushOp(Operator op); + virtual void pushOp(Operator op, unsigned ref); - // DWARF logical "frame base", which may be the result of an expression - // in itself. TODO: figure out what info we need to carry around so we - // can compute it... - virtual void pushFrameBase(); - virtual void pushCFA(); + // DWARF logical "frame base", which may be the result of an expression + // in itself. TODO: figure out what info we need to carry around so we + // can compute it... + virtual void pushFrameBase(); + virtual void pushCFA(); - VariableLocation &val(); + VariableLocation &val(); - virtual bool eval(MachRegisterVal &) { return false; } + virtual bool eval(MachRegisterVal &) { return false; } - private: - std::stack operands; +private: + std::stack operands; - VariableLocation &var; + VariableLocation &var; }; class DYNDWARF_EXPORT ConcreteDwarfResult : public DwarfResult { - public: - ConcreteDwarfResult(ProcessReader *r, Architecture a, - Address p, Dwarf_Debug d) : - DwarfResult(a), reader(r), - pc(p), dbg(d) {}; - virtual ~ConcreteDwarfResult() {}; - - virtual void pushReg(Dyninst::MachRegister reg); - virtual void readReg(Dyninst::MachRegister reg); - virtual void pushUnsignedVal(Dyninst::MachRegisterVal constant); - virtual void pushSignedVal(Dyninst::MachRegisterVal constant); - virtual void pushOp(Operator op); - virtual void pushOp(Operator op, unsigned ref); - - // DWARF logical "frame base", which may be the result of an expression - // in itself. TODO: figure out what info we need to carry around so we - // can compute it... - virtual void pushFrameBase(); - virtual void pushCFA(); - - MachRegisterVal val(); - - bool eval(MachRegisterVal &v); - - private: - ProcessReader *reader; - - // For getting access to other expressions - Address pc; - Dwarf_Debug dbg; - - // Dwarf lets you access within the "stack", so we model - // it as a vector. - std::vector operands; - - MachRegisterVal peek(int index); - void pop(int num); - void popRange(int start, int end); - void push(MachRegisterVal v); +public: + ConcreteDwarfResult(ProcessReader *r, Architecture a, + Address p, ::Dwarf * d) : + DwarfResult(a), reader(r), + pc(p), dbg(d) {}; + virtual ~ConcreteDwarfResult() {}; + + virtual void pushReg(Dyninst::MachRegister reg); + virtual void readReg(Dyninst::MachRegister reg); + virtual void pushUnsignedVal(Dyninst::MachRegisterVal constant); + virtual void pushSignedVal(Dyninst::MachRegisterVal constant); + virtual void pushOp(Operator op); + virtual void pushOp(Operator op, unsigned ref); + + // DWARF logical "frame base", which may be the result of an expression + // in itself. TODO: figure out what info we need to carry around so we + // can compute it... + virtual void pushFrameBase(); + virtual void pushCFA(); + + MachRegisterVal val(); + + bool eval(MachRegisterVal &v); + +private: + ProcessReader *reader; + + // For getting access to other expressions + Address pc; + ::Dwarf * dbg; + + // Dwarf lets you access within the "stack", so we model + // it as a vector. + std::vector operands; + + MachRegisterVal peek(int index); + void pop(int num); + void popRange(int start, int end); + void push(MachRegisterVal v); }; diff --git a/dwarf/src/dwarfExprParser.C b/dwarf/src/dwarfExprParser.C index 2dc74926d2..4efe9ed61f 100644 --- a/dwarf/src/dwarfExprParser.C +++ b/dwarf/src/dwarfExprParser.C @@ -43,917 +43,330 @@ using namespace std; namespace Dyninst { namespace Dwarf { -bool decodeDwarfExpression(Dwarf_Locdesc *dwlocs, - long int *initialStackValue, - VariableLocation &loc, - Dyninst::Architecture arch) { - SymbolicDwarfResult res(loc, arch); - if (!decodeDwarfExpression(dwlocs, initialStackValue, - res, arch)) return false; - res.val(); - return true; +bool decodeDwarfExpression(Dwarf_Op ** dwlocs, + Dwarf_Sword listlen, + long int *initialStackValue, + VariableLocation &loc, + Dyninst::Architecture arch) { + SymbolicDwarfResult res(loc, arch); + if (!decodeDwarfExpression(dwlocs, listlen, initialStackValue, + res, arch)) return false; + res.val(); + return true; } -bool decodeDwarfExpression(Dwarf_Locdesc *dwlocs, - long int *initialStackValue, - ProcessReader *reader, - Address pc, - Dwarf_Debug dbg, - Dyninst::Architecture arch, - MachRegisterVal &end_result) { - ConcreteDwarfResult res(reader, arch, pc, dbg); - if (!decodeDwarfExpression(dwlocs, initialStackValue, - res, arch)) return false; - if (res.err()) return false; - end_result = res.val(); - return true; +bool decodeDwarfExpression(Dwarf_Op ** dwlocs, + Dwarf_Sword listlen, + long int *initialStackValue, + ProcessReader *reader, + Address pc, + ::Dwarf * dbg, + Dyninst::Architecture arch, + MachRegisterVal &end_result) { + ConcreteDwarfResult res(reader, arch, pc, dbg); + if (!decodeDwarfExpression(dwlocs, listlen, initialStackValue, + res, arch)) return false; + if (res.err()) return false; + end_result = res.val(); + return true; } - - -bool decodeDwarfExpression(Dwarf_Locdesc *dwlocs, - long int *initialStackValue, - DwarfResult &cons, - Dyninst::Architecture arch) { - // This is basically a decode passthrough, with the work - // being done by the DwarfResult. - - dwarf_printf("Entry to decodeDwarfExpression\n"); - - int addr_width = getArchAddressWidth(arch); - if (initialStackValue != NULL) { - dwarf_printf("\tInitializing expr stack with 0x%lx\n", initialStackValue); - cons.pushUnsignedVal((Dyninst::MachRegisterVal) *initialStackValue); - } - - Dwarf_Loc *locations = dwlocs->ld_s; - unsigned count = dwlocs->ld_cents; - for ( unsigned int i = 0; i < count; i++ ) - { - dwarf_printf("\tAtom %d of %d: val 0x%x\n", i, count, locations[i].lr_atom); - /* lit0 - lit31 : the constants 0..31 */ - if ( DW_OP_lit0 <= locations[i].lr_atom && locations[i].lr_atom <= DW_OP_lit31 ) - { - dwarf_printf("\t\t Pushing unsigned val 0x%lx\n", locations[i].lr_atom - DW_OP_lit0); - cons.pushUnsignedVal((Dyninst::MachRegisterVal) (locations[i].lr_atom - DW_OP_lit0)); - continue; - } - - /* reg0 - reg31: named registers (not their constants) */ - if ( DW_OP_reg0 <= locations[i].lr_atom && locations[i].lr_atom <= DW_OP_reg31 ) - { - dwarf_printf("\t\t Pushing reg %s\n",MachRegister::DwarfEncToReg(locations[i].lr_atom - DW_OP_reg0, - arch).name().c_str()); - - cons.pushReg(MachRegister::DwarfEncToReg(locations[i].lr_atom - DW_OP_reg0, - arch)); - continue; - } - - /* breg0 - breg31: register contents plus an optional offset */ - if ( DW_OP_breg0 <= locations[i].lr_atom && locations[i].lr_atom <= DW_OP_breg31 ) - { - dwarf_printf("\t\t Pushing reg %s + %d\n",MachRegister::DwarfEncToReg(locations[i].lr_atom - DW_OP_reg0, - arch).name().c_str(), - locations[i].lr_number); - cons.readReg(MachRegister::DwarfEncToReg(locations[i].lr_atom - DW_OP_breg0, - arch)); - cons.pushSignedVal((Dyninst::MachRegisterVal) locations[i].lr_number); - cons.pushOp(DwarfResult::Add); - continue; - } - - switch( locations[i].lr_atom ) { - // This is the same thing as breg, just with an encoded instead of literal - // register. - // The register is in lr_number - // The offset is in lr_number2 - case DW_OP_bregx: - dwarf_printf("\t\t Pushing reg %s + %d\n",MachRegister::DwarfEncToReg(locations[i].lr_number, - arch).name().c_str(), - locations[i].lr_number2); - - cons.readReg(MachRegister::DwarfEncToReg(locations[i].lr_number, arch)); - cons.pushSignedVal(locations[i].lr_number2); - cons.pushOp(DwarfResult::Add); - break; - - case DW_OP_regx: - dwarf_printf("\t\t Pushing reg %s\n",MachRegister::DwarfEncToReg(locations[i].lr_number, - arch).name().c_str()); - cons.pushReg(MachRegister::DwarfEncToReg(locations[i].lr_number, arch)); - break; - - case DW_OP_nop: - dwarf_printf("\t\t NOP\n"); - break; - - case DW_OP_addr: - case DW_OP_const1u: - case DW_OP_const2u: - case DW_OP_const4u: - case DW_OP_const8u: - case DW_OP_constu: - dwarf_printf("\t\t Pushing unsigned 0x%lx\n", locations[i].lr_number); - cons.pushUnsignedVal(locations[i].lr_number); - break; - - case DW_OP_const1s: - case DW_OP_const2s: - case DW_OP_const4s: - case DW_OP_const8s: - case DW_OP_consts: - dwarf_printf("\t\t Pushing signed 0x%lx\n", locations[i].lr_number); - cons.pushSignedVal(locations[i].lr_number); - break; - - case DW_OP_fbreg: - dwarf_printf("\t\t Pushing FB + 0x%lx\n", locations[i].lr_number); - cons.pushFrameBase(); - cons.pushSignedVal(locations[i].lr_number); +bool decodeDwarfExpression(Dwarf_Op ** dwlocs, + Dwarf_Sword listlen, + long int *initialStackValue, + DwarfResult &cons, + Dyninst::Architecture arch) { + // This is basically a decode passthrough, with the work + // being done by the DwarfResult. + + dwarf_printf("Entry to decodeDwarfExpression\n"); + + int addr_width = getArchAddressWidth(arch); + if (initialStackValue != NULL) { + dwarf_printf("\tInitializing expr stack with 0x%lx\n", initialStackValue); + cons.pushUnsignedVal((Dyninst::MachRegisterVal) *initialStackValue); + } + + Dwarf_Op *locations = *dwlocs; + unsigned count = listlen; + for ( unsigned int i = 0; i < count; i++ ) + { + dwarf_printf("\tAtom %d of %d: val 0x%x\n", i, count, locations[i].atom); + /* lit0 - lit31 : the constants 0..31 */ + if ( DW_OP_lit0 <= locations[i].atom && locations[i].atom <= DW_OP_lit31 ) + { + dwarf_printf("\t\t Pushing unsigned val 0x%lx\n", locations[i].atom - DW_OP_lit0); + cons.pushUnsignedVal((Dyninst::MachRegisterVal) (locations[i].atom - DW_OP_lit0)); + continue; + } + + /* reg0 - reg31: named registers (not their constants) */ + if ( DW_OP_reg0 <= locations[i].atom && locations[i].atom <= DW_OP_reg31 ) + { + dwarf_printf("\t\t Pushing reg %s\n",MachRegister::DwarfEncToReg(locations[i].atom - DW_OP_reg0, + arch).name().c_str()); + + cons.pushReg(MachRegister::DwarfEncToReg(locations[i].atom - DW_OP_reg0, + arch)); + continue; + } + + /* breg0 - breg31: register contents plus an optional offset */ + if ( DW_OP_breg0 <= locations[i].atom && locations[i].atom <= DW_OP_breg31 ) + { + dwarf_printf("\t\t Pushing reg %s + %d\n",MachRegister::DwarfEncToReg(locations[i].atom - DW_OP_reg0, + arch).name().c_str(), + locations[i].number); + cons.readReg(MachRegister::DwarfEncToReg(locations[i].atom - DW_OP_breg0, + arch)); + cons.pushSignedVal((Dyninst::MachRegisterVal) locations[i].number); cons.pushOp(DwarfResult::Add); - break; - - case DW_OP_dup: - dwarf_printf("\t\t Pushing dup\n"); - cons.pushOp(DwarfResult::Pick, 0); - break; - - case DW_OP_drop: - dwarf_printf("\t\t Pushing drop\n"); - cons.pushOp(DwarfResult::Drop, 0); - break; - - case DW_OP_pick: - dwarf_printf("\t\t Pushing pick %d\n", locations[i].lr_number); - cons.pushOp(DwarfResult::Pick, locations[i].lr_number); - break; - - case DW_OP_over: - dwarf_printf("\t\t Pushing pick 1\n"); - cons.pushOp(DwarfResult::Pick, 1); - break; - - case DW_OP_swap: - dwarf_printf("\t\t Pushing swap\n"); - cons.pushOp(DwarfResult::Pick, 1); - cons.pushOp(DwarfResult::Drop, 2); - break; - - case DW_OP_rot: - dwarf_printf("\t\t Pushing rotate\n"); - cons.pushOp(DwarfResult::Pick, 2); - cons.pushOp(DwarfResult::Pick, 2); - cons.pushOp(DwarfResult::Drop, 3); - cons.pushOp(DwarfResult::Drop, 3); - break; - - case DW_OP_deref: - dwarf_printf("\t\t Pushing deref %d\n", addr_width); - cons.pushOp(DwarfResult::Deref, addr_width); - break; - - case DW_OP_deref_size: - dwarf_printf("\t\t Pushing deref %d\n", locations[i].lr_number); - cons.pushOp(DwarfResult::Deref, locations[i].lr_number); - break; - - case DW_OP_call_frame_cfa: - // This is a reference to the CFA as computed by stack walking information. - // The current order is: - // Variable: reference frame base (fbreg, above) - // Frame base: reference CFA - // CFA: offset from stack pointer - dwarf_printf("\t\t Pushing CFA\n"); - cons.pushCFA(); - break; - - case DW_OP_abs: - dwarf_printf("\t\t Pushing abs\n"); - cons.pushOp(DwarfResult::Abs); - break; - - case DW_OP_and: - dwarf_printf("\t\t Pushing and\n"); - cons.pushOp(DwarfResult::And); - break; - - case DW_OP_div: - dwarf_printf("\t\t Pushing div\n"); - cons.pushOp(DwarfResult::Div); - break; - - case DW_OP_minus: - dwarf_printf("\t\t Pushing sub\n"); - cons.pushOp(DwarfResult::Sub); - break; - - case DW_OP_mod: - cons.pushOp(DwarfResult::Mod); - break; - - case DW_OP_mul: - cons.pushOp(DwarfResult::Mul); - break; - - case DW_OP_neg: - cons.pushSignedVal(-1); - cons.pushOp(DwarfResult::Mul); - break; - - case DW_OP_not: - cons.pushOp(DwarfResult::Not); - break; - - case DW_OP_or: - cons.pushOp(DwarfResult::Or); - break; - - case DW_OP_plus: - dwarf_printf("\t\t Pushing add\n"); - cons.pushOp(DwarfResult::Add); - break; - - case DW_OP_plus_uconst: - dwarf_printf("\t\t Pushing add 0x%x\n", locations[i].lr_number); - - cons.pushOp(DwarfResult::Add, locations[i].lr_number); - break; - - case DW_OP_shl: - cons.pushOp(DwarfResult::Shl); - break; - - case DW_OP_shr: - cons.pushOp(DwarfResult::Shr); - break; - - case DW_OP_shra: - cons.pushOp(DwarfResult::ShrArith); - break; - - case DW_OP_xor: - cons.pushOp(DwarfResult::Xor); - break; - - case DW_OP_le: - cons.pushOp(DwarfResult::LE); - break; - - case DW_OP_ge: - cons.pushOp(DwarfResult::GE); - break; - - case DW_OP_eq: - cons.pushOp(DwarfResult::Eq); - break; - - case DW_OP_ne: - cons.pushOp(DwarfResult::Neq); - break; - - case DW_OP_lt: - cons.pushOp(DwarfResult::LT); - break; - - case DW_OP_gt: - cons.pushOp(DwarfResult::GT); - break; - - case DW_OP_bra: { - // Conditional branch... - // It needs immediate evaluation so we can continue processing - // the DWARF. - Dyninst::MachRegisterVal value; - - if (!cons.eval(value)) { - // Error in dwarf, or we're doing static. I'm not worrying about - // encoding a conditional branch in static eval right now. - return false; - } - - if (value == 0) break; - // Do not break; fall through to skip - } - case DW_OP_skip: { - int bytes = (int)(Dwarf_Signed)locations[i].lr_number; - unsigned int target = (unsigned int) locations[i].lr_offset + bytes; - - int j = i; - if ( bytes < 0 ) { - for ( j = i - 1; j >= 0; j-- ) { - if ( locations[j].lr_offset == target ) { break; } - } /* end search backward */ - } else { - for ( j = i + 1; j < dwlocs->ld_cents; j ++ ) { - if ( locations[j].lr_offset == target ) { break; } - } /* end search forward */ - } /* end if positive offset */ - - /* Because i will be incremented the next time around the loop. */ - i = j - 1; - break; - } - case DW_OP_piece: - // Should detect multiple of these... - continue; - default: - return false; - } /* end operand switch */ - } /* end iteration over Dwarf_Loc entries. */ - - return true; -} - + continue; + } + + switch( locations[i].atom ) { + // This is the same thing as breg, just with an encoded instead of literal + // register. + // The register is in number + // The offset is in number2 + case DW_OP_bregx: + dwarf_printf("\t\t Pushing reg %s + %d\n",MachRegister::DwarfEncToReg(locations[i].number, + arch).name().c_str(), + locations[i].number2); + + cons.readReg(MachRegister::DwarfEncToReg(locations[i].number, arch)); + cons.pushSignedVal(locations[i].number2); + cons.pushOp(DwarfResult::Add); + break; + + case DW_OP_regx: + dwarf_printf("\t\t Pushing reg %s\n",MachRegister::DwarfEncToReg(locations[i].number, + arch).name().c_str()); + cons.pushReg(MachRegister::DwarfEncToReg(locations[i].number, arch)); + break; + + case DW_OP_nop: + dwarf_printf("\t\t NOP\n"); + break; + + case DW_OP_addr: + case DW_OP_const1u: + case DW_OP_const2u: + case DW_OP_const4u: + case DW_OP_const8u: + case DW_OP_constu: + dwarf_printf("\t\t Pushing unsigned 0x%lx\n", locations[i].number); + cons.pushUnsignedVal(locations[i].number); + break; + + case DW_OP_const1s: + case DW_OP_const2s: + case DW_OP_const4s: + case DW_OP_const8s: + case DW_OP_consts: + dwarf_printf("\t\t Pushing signed 0x%lx\n", locations[i].number); + cons.pushSignedVal(locations[i].number); + break; + + case DW_OP_fbreg: + dwarf_printf("\t\t Pushing FB + 0x%lx\n", locations[i].number); + cons.pushFrameBase(); + cons.pushSignedVal(locations[i].number); + cons.pushOp(DwarfResult::Add); + break; + + case DW_OP_dup: + dwarf_printf("\t\t Pushing dup\n"); + cons.pushOp(DwarfResult::Pick, 0); + break; + + case DW_OP_drop: + dwarf_printf("\t\t Pushing drop\n"); + cons.pushOp(DwarfResult::Drop, 0); + break; + + case DW_OP_pick: + dwarf_printf("\t\t Pushing pick %d\n", locations[i].number); + cons.pushOp(DwarfResult::Pick, locations[i].number); + break; + + case DW_OP_over: + dwarf_printf("\t\t Pushing pick 1\n"); + cons.pushOp(DwarfResult::Pick, 1); + break; + + case DW_OP_swap: + dwarf_printf("\t\t Pushing swap\n"); + cons.pushOp(DwarfResult::Pick, 1); + cons.pushOp(DwarfResult::Drop, 2); + break; + + case DW_OP_rot: + dwarf_printf("\t\t Pushing rotate\n"); + cons.pushOp(DwarfResult::Pick, 2); + cons.pushOp(DwarfResult::Pick, 2); + cons.pushOp(DwarfResult::Drop, 3); + cons.pushOp(DwarfResult::Drop, 3); + break; + + case DW_OP_deref: + dwarf_printf("\t\t Pushing deref %d\n", addr_width); + cons.pushOp(DwarfResult::Deref, addr_width); + break; + + case DW_OP_deref_size: + dwarf_printf("\t\t Pushing deref %d\n", locations[i].number); + cons.pushOp(DwarfResult::Deref, locations[i].number); + break; + + case DW_OP_call_frame_cfa: + // This is a reference to the CFA as computed by stack walking information. + // The current order is: + // Variable: reference frame base (fbreg, above) + // Frame base: reference CFA + // CFA: offset from stack pointer + dwarf_printf("\t\t Pushing CFA\n"); + cons.pushCFA(); + break; + + case DW_OP_abs: + dwarf_printf("\t\t Pushing abs\n"); + cons.pushOp(DwarfResult::Abs); + break; + + case DW_OP_and: + dwarf_printf("\t\t Pushing and\n"); + cons.pushOp(DwarfResult::And); + break; + + case DW_OP_div: + dwarf_printf("\t\t Pushing div\n"); + cons.pushOp(DwarfResult::Div); + break; + + case DW_OP_minus: + dwarf_printf("\t\t Pushing sub\n"); + cons.pushOp(DwarfResult::Sub); + break; + + case DW_OP_mod: + cons.pushOp(DwarfResult::Mod); + break; + + case DW_OP_mul: + cons.pushOp(DwarfResult::Mul); + break; + + case DW_OP_neg: + cons.pushSignedVal(-1); + cons.pushOp(DwarfResult::Mul); + break; + + case DW_OP_not: + cons.pushOp(DwarfResult::Not); + break; + + case DW_OP_or: + cons.pushOp(DwarfResult::Or); + break; + + case DW_OP_plus: + dwarf_printf("\t\t Pushing add\n"); + cons.pushOp(DwarfResult::Add); + break; + + case DW_OP_plus_uconst: + dwarf_printf("\t\t Pushing add 0x%x\n", locations[i].number); + + cons.pushOp(DwarfResult::Add, locations[i].number); + break; + + case DW_OP_shl: + cons.pushOp(DwarfResult::Shl); + break; + + case DW_OP_shr: + cons.pushOp(DwarfResult::Shr); + break; + + case DW_OP_shra: + cons.pushOp(DwarfResult::ShrArith); + break; + + case DW_OP_xor: + cons.pushOp(DwarfResult::Xor); + break; + + case DW_OP_le: + cons.pushOp(DwarfResult::LE); + break; + + case DW_OP_ge: + cons.pushOp(DwarfResult::GE); + break; + + case DW_OP_eq: + cons.pushOp(DwarfResult::Eq); + break; + + case DW_OP_ne: + cons.pushOp(DwarfResult::Neq); + break; + + case DW_OP_lt: + cons.pushOp(DwarfResult::LT); + break; + + case DW_OP_gt: + cons.pushOp(DwarfResult::GT); + break; + + case DW_OP_bra: { + // Conditional branch... + // It needs immediate evaluation so we can continue processing + // the DWARF. + Dyninst::MachRegisterVal value; + + if (!cons.eval(value)) { + // Error in dwarf, or we're doing static. I'm not worrying about + // encoding a conditional branch in static eval right now. + return false; + } + + if (value == 0) break; + // Do not break; fall through to skip + } + case DW_OP_skip: { + int bytes = (int)(Dwarf_Sword)locations[i].number; + unsigned int target = (unsigned int) locations[i].offset + bytes; + + unsigned int j = i; + if ( bytes < 0 ) { + for ( j = i - 1; j >= 0; j-- ) { + if ( locations[j].offset == target ) { break; } + } /* end search backward */ + } else { + for ( j = i + 1; j < count; j ++ ) { + if ( locations[j].offset == target ) { break; } + } /* end search forward */ + } /* end if positive offset */ + + /* Because i will be incremented the next time around the loop. */ + i = j - 1; + break; + } + case DW_OP_piece: + // Should detect multiple of these... + continue; + default: + return false; + } /* end operand switch */ + } /* end iteration over Dwarf_Op entries. */ + + return true; } } -#if 0 - -#if defined(arch_x86_64) - -#define IA32_MAX_MAP 7 -#define AMD64_MAX_MAP 15 -static int const amd64_register_map[] = - { - 0, // RAX - 2, // RDX - 1, // RCX - 3, // RBX - 6, // RSI - 7, // RDI - 5, // RBP - 4, // RSP - 8, 9, 10, 11, 12, 13, 14, 15 // gp 8 - 15 - /* This is incomplete. The x86_64 ABI specifies a mapping from - dwarf numbers (0-66) to ("architecture number"). Without a - corresponding mapping for the SVR4 dwarf-machine encoding for - IA-32, however, it is not meaningful to provide this mapping. */ - }; - - -int Dyninst::Register_DWARFtoMachineEnc32(int n) -{ - return n; } - -int Dyninst::Register_DWARFtoMachineEnc64(int n) -{ - if (n <= AMD64_MAX_MAP) - return amd64_register_map[n]; - return n; -} - -#endif - -#endif - - - -#if 0 -bool Dyninst::decodeDwarfExpression(Dwarf_Locdesc *dwlocs, - long int *initialStackValue, - VariableLocation *loc, bool &isLocSet, - ProcessReader *reader, - Dyninst::Architecture arch, - long int &end_result) -{ - /* Initialize the stack. */ - int addr_width = getArchAddressWidth(arch); - std::stack< long int > opStack = std::stack(); - if ( initialStackValue != NULL ) { opStack.push( * initialStackValue ); } - - Dwarf_Loc *locations = dwlocs->ld_s; - unsigned count = dwlocs->ld_cents; - for ( unsigned int i = 0; i < count; i++ ) - { - /* Handle the literals w/o 32 case statements. */ - if ( DW_OP_lit0 <= locations[i].lr_atom && locations[i].lr_atom <= DW_OP_lit31 ) - { - dwarf_printf( "pushing named constant: %d\n", locations[i].lr_atom - DW_OP_lit0 ); - opStack.push( locations[i].lr_atom - DW_OP_lit0 ); - continue; - } - - /* Haandle registers w/o 32 case statements. */ - if ( DW_OP_reg0 <= locations[i].lr_atom && locations[i].lr_atom <= DW_OP_reg31 ) - { - /* storageReg is unimplemented, so do an offset of 0 from the named register instead. */ - dwarf_printf( "location is named register %d\n", - DWARF_TO_MACHINE_ENC_W(locations[i].lr_atom - DW_OP_reg0, addr_width) ); - //loc->stClass = storageRegOffset; - if (loc) - { - loc->stClass = storageReg; - loc->refClass = storageNoRef; - loc->frameOffset = 0; - loc->reg = DWARF_TO_MACHINE_ENC_W(locations[i].lr_atom - DW_OP_reg0, addr_width); - loc->mr_reg = DWARF_TO_MACHINEREG_ENC_W(locations[i].lr_atom - DW_OP_reg0, addr_width); - //loc->frameOffset = 0; - isLocSet = true; - } - continue; - } - - /* Haandle registers w/o 32 case statements. */ - if ( DW_OP_breg0 <= locations[i].lr_atom && locations[i].lr_atom <= DW_OP_breg31 ) - { - dwarf_printf( "setting storage class to named register, regNum to %d, offset %d\n", DWARF_TO_MACHINE_ENC_W(locations[i].lr_atom - DW_OP_breg0, addr_width), locations[i].lr_number ); - long int to_push = 0; - if (loc) { - loc->stClass = storageRegOffset; - loc->refClass = storageNoRef; - loc->frameOffset = locations[i].lr_number ; - loc->reg = DWARF_TO_MACHINE_ENC_W(locations[i].lr_atom - DW_OP_breg0, addr_width); - loc->mr_reg = DWARF_TO_MACHINEREG_ENC_W(locations[i].lr_atom - DW_OP_breg0, addr_width); - to_push = static_cast(locations[i].lr_number); - } - else if (reader) { - Dyninst::MachRegister r = DwarfToDynReg(locations[i].lr_atom - DW_OP_breg0, - arch); - Dyninst::MachRegisterVal v; - bool result = reader->GetReg(r, v); - if (!result) { - return false; - } - to_push = (long int) v + locations[i].lr_number; - } - - opStack.push(to_push); - continue; - } - - switch( locations[i].lr_atom ) - { - case DW_OP_addr: - case DW_OP_const1u: - case DW_OP_const2u: - case DW_OP_const4u: - case DW_OP_const8u: - case DW_OP_constu: - dwarf_printf( "pushing unsigned constant %lu\n", - (unsigned long)locations[i].lr_number ); - opStack.push(static_cast(locations[i].lr_number)); - break; - - case DW_OP_const1s: - case DW_OP_const2s: - case DW_OP_const4s: - case DW_OP_const8s: - case DW_OP_consts: - dwarf_printf( "pushing signed constant %ld\n", - (signed long)(locations[i].lr_number) ); - opStack.push(static_cast(locations[i].lr_number)); - break; - - case DW_OP_regx: - /* storageReg is unimplemented, so do an offset of 0 from the named register instead. */ - dwarf_printf( "location is register %d\n", - DWARF_TO_MACHINE_ENC_W(locations[i].lr_number, addr_width) ); - if (loc) { - loc->stClass = storageReg; - loc->refClass = storageNoRef; - loc->reg = (int) DWARF_TO_MACHINE_ENC_W(locations[i].lr_number, addr_width); - loc->mr_reg = DWARF_TO_MACHINEREG_ENC_W(locations[i].lr_number, addr_width); - loc->frameOffset = 0; - isLocSet = true; - } - break; - - case DW_OP_fbreg: - { - dwarf_printf( "setting storage class to frame base\n" ); - //if ( storageClass != NULL ) { * storageClass = storageFrameOffset; } - long int to_push = 0; - if (loc) { - loc->stClass = storageRegOffset; - loc->refClass = storageNoRef; - loc->frameOffset = 0; - loc->mr_reg = Dyninst::FrameBase; - to_push = static_cast(locations[i].lr_number); - } - else if (reader) { - Dyninst::MachRegister r = Dyninst::FrameBase; - Dyninst::MachRegisterVal v; - bool result = reader->GetReg(r, v); - if (!result) { - return false; - } - to_push = (long int) v + locations[i].lr_number; - } - opStack.push(to_push); - } break; - case DW_OP_bregx: - { - dwarf_printf( "setting storage class to register, regNum to %d\n", - locations[i].lr_number ); - long int to_push = 0; - if (loc) { - loc->stClass = storageRegOffset; - loc->refClass = storageNoRef; - loc->reg = (int) DWARF_TO_MACHINE_ENC_W( locations[i].lr_number, addr_width ); - loc->mr_reg = DWARF_TO_MACHINEREG_ENC_W( locations[i].lr_number, addr_width ); - loc->frameOffset = 0; - to_push = static_cast(locations[i].lr_number2); - } - else if (reader) { - Dyninst::MachRegister r = DwarfToDynReg(locations[i].lr_number, arch); - Dyninst::MachRegisterVal v; - bool result = reader->GetReg(r, v); - if (!result) { - return false; - } - to_push = (long int) v + locations[i].lr_number2; - } - opStack.push(to_push); - } break; - case DW_OP_dup: - DWARF_FALSE_IF( opStack.size() < 1, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - opStack.push( opStack.top() ); - break; - - case DW_OP_drop: - DWARF_FALSE_IF( opStack.size() < 1, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - opStack.pop(); - break; - - case DW_OP_pick: - { - /* Duplicate the entry at index locations[i].lr_number. */ - std::stack< long int > temp = std::stack< long int >(); - - for ( unsigned int j = 0; j < locations[i].lr_number; j++ ) - { - temp.push( opStack.top() ); opStack.pop(); - } - - long int dup = opStack.top(); - - for ( unsigned int j = 0; j < locations[i].lr_number; j++ ) - { - opStack.push( temp.top() ); temp.pop(); - } - - opStack.push( dup ); - } break; - - case DW_OP_over: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - opStack.push( second ); opStack.push( first ); opStack.push( second ); - } break; - - case DW_OP_swap: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - opStack.push( first ); opStack.push( second ); - } break; - - case DW_OP_deref: - { - if (!reader) - break; - long int addr = opStack.top(); opStack.pop(); - unsigned long to_push = 0; - bool bresult = false; - if (addr_width == 4) { - uint32_t v; - bresult = reader->ReadMem(addr, &v, sizeof(v)); - to_push = (unsigned long) v; - } - else if (addr_width == 8) { - uint64_t v; - bresult = reader->ReadMem(addr, &v, sizeof(v)); - to_push = (unsigned long) v; - } - DWARF_FALSE_IF(!bresult, - "%s[%d]: Could not read from %lx\n", addr); - opStack.push(to_push); - break; - } - case DW_OP_deref_size: - { - if (!reader) - break; - long int addr = opStack.top(); opStack.pop(); - int width = locations[i].lr_number; - unsigned long to_push = 0; - bool bresult = false; - if (width == 1) { - uint8_t v; - bresult = reader->ReadMem(addr, &v, sizeof(v)); - to_push = (unsigned long) v; - } - if (width == 2) { - uint16_t v; - bresult = reader->ReadMem(addr, &v, sizeof(v)); - to_push = (unsigned long) v; - } - if (width == 4) { - uint32_t v; - bresult = reader->ReadMem(addr, &v, sizeof(v)); - to_push = (unsigned long) v; - } - else if (width == 8) { - uint64_t v; - bresult = reader->ReadMem(addr, &v, sizeof(v)); - to_push = (long int) v; - } - DWARF_FALSE_IF(!bresult, - "%s[%d]: Could not read from %lx\n", addr); - opStack.push(to_push); - break; - } - - case DW_OP_rot: - { - DWARF_FALSE_IF( opStack.size() < 3, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - long int third = opStack.top(); opStack.pop(); - opStack.push( first ); opStack.push( third ); opStack.push( second ); - } break; - - case DW_OP_abs: - { - DWARF_FALSE_IF( opStack.size() < 1, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int top = opStack.top(); opStack.pop(); - opStack.push( abs( top ) ); - } break; - - case DW_OP_and: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - opStack.push( second & first ); - } break; - - case DW_OP_div: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - DWARF_FALSE_IF(((second != 0) && (first == 0)), - "%s[%d]: invalid stack, div operation with %d / %d, returning false\n", - __FILE__, __LINE__, second, first); - - if((second == 0) && (first == 0)) - opStack.push(0); - else - opStack.push( second / first ); - } break; - - case DW_OP_minus: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - opStack.push( second - first ); - } break; - - case DW_OP_mod: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - DWARF_FALSE_IF(((second != 0) && (first == 0)), - "%s[%d]: invalid stack, mod operation with %d mod %d, returning false\n", - __FILE__, __LINE__, second, first); - - if((second == 0) && (first == 0)) - opStack.push(0); - else - opStack.push( second % first ); - } break; - - case DW_OP_mul: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - opStack.push( second * first ); - } break; - - case DW_OP_neg: - { - DWARF_FALSE_IF( opStack.size() < 1, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - opStack.push( first * (-1) ); - } break; - - case DW_OP_not: - { - DWARF_FALSE_IF( opStack.size() < 1, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - opStack.push( ~ first ); - } break; - - case DW_OP_or: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - opStack.push( second | first ); - } break; - - case DW_OP_plus: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - opStack.push( second + first ); - } break; - - case DW_OP_plus_uconst: - { - DWARF_FALSE_IF( opStack.size() < 1, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - opStack.push(static_cast(first + locations[i].lr_number)); - } break; - - case DW_OP_shl: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - opStack.push( second << first ); - } break; - - case DW_OP_shr: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - - opStack.push( (long int)((unsigned long)second >> (unsigned long)first) ); - } break; - - case DW_OP_shra: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - opStack.push( second >> first ); - } break; - - case DW_OP_xor: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - opStack.push( second ^ first ); - } break; - - case DW_OP_le: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - opStack.push( first <= second ? 1 : 0 ); - } break; - - case DW_OP_ge: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - opStack.push( first >= second ? 1 : 0 ); - } break; - - case DW_OP_eq: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - opStack.push( first == second ? 1 : 0 ); - } break; - - case DW_OP_lt: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - opStack.push( first < second ? 1 : 0 ); - } break; - - case DW_OP_gt: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - opStack.push( first > second ? 1 : 0 ); - } break; - - case DW_OP_ne: - { - DWARF_FALSE_IF( opStack.size() < 2, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - long int first = opStack.top(); opStack.pop(); - long int second = opStack.top(); opStack.pop(); - opStack.push( first != second ? 1 : 0 ); - } break; - - case DW_OP_bra: - { - DWARF_FALSE_IF( opStack.size() < 1, - "%s[%d]: invalid stack, returning false.\n", __FILE__, __LINE__ ); - if ( opStack.top() == 0 ) { break; } - opStack.pop(); - } - case DW_OP_skip: - { - int bytes = (int)(Dwarf_Signed)locations[i].lr_number; - unsigned int target = (unsigned int) locations[i].lr_offset + bytes; - - int j = i; - if ( bytes < 0 ) { - for ( j = i - 1; j >= 0; j-- ) { - if ( locations[j].lr_offset == target ) { break; } - } /* end search backward */ - } else { - for ( j = i + 1; j < dwlocs->ld_cents; j ++ ) { - if ( locations[j].lr_offset == target ) { break; } - } /* end search forward */ - } /* end if positive offset */ - - /* Because i will be incremented the next time around the loop. */ - i = j - 1; - } break; - - case DW_OP_piece: - /* For multi-part variables, which we don't handle. */ - //bperr ( "Warning: dyninst does not handle multi-part variables.\n" ); - break; - - case DW_OP_nop: - break; - - case DW_OP_call_frame_cfa: { - long int to_push = 0; - if (loc) { - loc->stClass = storageRegOffset; - loc->refClass = storageNoRef; - loc->frameOffset = 0; - loc->mr_reg = Dyninst::FrameBase; - } - else if (reader) { - Dyninst::MachRegister r = Dyninst::FrameBase; - Dyninst::MachRegisterVal v; - bool result = reader->GetReg(r, v); - if (!result) { - return false; - } - } - opStack.push(to_push); - break; - } - default: - printf( "Unrecognized or non-static location opcode 0x%x, aborting.\n", locations[i].lr_atom ); - return false; - break; - } /* end operand switch */ - } /* end iteration over Dwarf_Loc entries. */ - - if (opStack.empty()) { - dwarf_printf( "ignoring malformed location list (stack empty at end of list).\n" ); - return isLocSet; - } - dwarf_printf( "Dwarf expression returning %d\n", opStack.top() ); - end_result = opStack.top(); - return true; -} - -#endif - diff --git a/dwarf/src/dwarfFrameParser.C b/dwarf/src/dwarfFrameParser.C index 4a18b764f9..e29aaec84f 100644 --- a/dwarf/src/dwarfFrameParser.C +++ b/dwarf/src/dwarfFrameParser.C @@ -33,7 +33,7 @@ #include "dwarfResult.h" #include "VariableLocation.h" #include "Types.h" -#include "libdwarf.h" +#include "libdw.h" #include #include #include "debug_common.h" // dwarf_printf @@ -44,9 +44,9 @@ using namespace std; struct frameParser_key { - Dwarf_Debug dbg; + ::Dwarf * dbg; Architecture arch; - frameParser_key(Dwarf_Debug d, Architecture a) : dbg(d), arch(a) + frameParser_key(::Dwarf * d, Architecture a) : dbg(d), arch(a) { } @@ -61,7 +61,7 @@ struct frameParser_key std::map DwarfFrameParser::frameParsers; -DwarfFrameParser::Ptr DwarfFrameParser::create(Dwarf_Debug dbg, Architecture arch) { +DwarfFrameParser::Ptr DwarfFrameParser::create(::Dwarf * dbg, Architecture arch) { frameParser_key k(dbg, arch); auto iter = frameParsers.find(k); @@ -76,7 +76,7 @@ DwarfFrameParser::Ptr DwarfFrameParser::create(Dwarf_Debug dbg, Architecture arc } -DwarfFrameParser::DwarfFrameParser(Dwarf_Debug dbg_, Architecture arch_) : +DwarfFrameParser::DwarfFrameParser(::Dwarf * dbg_, Architecture arch_) : dbg(dbg_), arch(arch_), fde_dwarf_status(dwarf_status_uninitialized) @@ -179,7 +179,7 @@ bool DwarfFrameParser::getRegsForFunction(Address entryPC, * Get the FDE at this PC. The FDE contains the rules for getting * registers at the given PC in this frame. **/ - Dwarf_Fde fde; + Dwarf_FDE fde; Address low, high; if (!getFDE(entryPC, fde, low, high, err_result)) { dwarf_printf("\t Failed to find FDE for 0x%lx, returning error\n", entryPC); @@ -241,7 +241,7 @@ bool DwarfFrameParser::getRegAtFrame(Address pc, * Get the FDE at this PC. The FDE contains the rules for getting * registers at the given PC in this frame. **/ - Dwarf_Fde fde; + Dwarf_FDE fde; Address u1, u2; if (!getFDE(pc, fde, u1, u2, err_result)) { dwarf_printf("\t No FDE at 0x%lx, ret false\n", pc); @@ -262,7 +262,7 @@ bool DwarfFrameParser::getRegAtFrame(Address pc, } bool DwarfFrameParser::getRegAtFrame_aux(Address pc, - Dwarf_Fde fde, + Dwarf_FDE fde, Dwarf_Half dwarf_reg, MachRegister orig_reg, DwarfResult &cons, @@ -276,7 +276,7 @@ bool DwarfFrameParser::getRegAtFrame_aux(Address pc, pc, width); Dwarf_Small value_type; - Dwarf_Signed offset_relevant, register_num, offset_or_block_len; + Dwarf_Sword offset_relevant, register_num, offset_or_block_len; Dwarf_Ptr block_ptr; Dwarf_Addr row_pc; @@ -350,8 +350,8 @@ bool DwarfFrameParser::getRegAtFrame_aux(Address pc, case DW_EXPR_VAL_EXPRESSION: case DW_EXPR_EXPRESSION: { dwarf_printf("\t Handling val_expression or expression\n"); - Dwarf_Locdesc *llbuf = NULL; - Dwarf_Signed listlen = 0; + Dwarf_Op** llbuf = NULL; + Dwarf_Sword listlen = 0; result = dwarf_loclist_from_expr(dbg, block_ptr, offset_or_block_len, &llbuf, &listlen, &err); if (result != DW_DLV_OK) { dwarf_printf("\t Failed to get loclist, ret false\n"); @@ -431,7 +431,7 @@ void DwarfFrameParser::setupFdeData() fde_dwarf_status = dwarf_status_ok; } -bool DwarfFrameParser::getFDE(Address pc, Dwarf_Fde &fde, +bool DwarfFrameParser::getFDE(Address pc, Dwarf_FDE &fde, Address &low, Address &high, FrameErrors_t &err_result) { Dwarf_Addr lowpc = 0, hipc = 0; @@ -469,7 +469,7 @@ bool DwarfFrameParser::getFDE(Address pc, Dwarf_Fde &fde, } bool DwarfFrameParser::getDwarfReg(Dyninst::MachRegister reg, - Dwarf_Fde &fde, + Dwarf_FDE &fde, Dwarf_Half &dwarf_reg, FrameErrors_t &err_result) { Dwarf_Error err; @@ -479,7 +479,7 @@ bool DwarfFrameParser::getDwarfReg(Dyninst::MachRegister reg, * This is treated as a virtual register in the * FDE. We can look up the virtual register in the CIE. **/ - Dwarf_Cie cie; + Dwarf_CIE cie; int result = dwarf_get_cie_of_fde(fde, &cie, &err); if (result != DW_DLV_OK) { dwarf_printf("ARM-ERROR: bad return value.\n"); @@ -506,7 +506,7 @@ bool DwarfFrameParser::getDwarfReg(Dyninst::MachRegister reg, } bool DwarfFrameParser::handleExpression(Address pc, - Dwarf_Signed registerNum, + Dwarf_Sword registerNum, Dyninst::MachRegister origReg, Dyninst::Architecture arch, DwarfResult &cons, diff --git a/dwarf/src/dwarfHandle.C b/dwarf/src/dwarfHandle.C index 6c94f991a0..5a6d763473 100644 --- a/dwarf/src/dwarfHandle.C +++ b/dwarf/src/dwarfHandle.C @@ -28,7 +28,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libdwarf.h" +#include "libdw.h" #include "Elf_X.h" #include "dwarfHandle.h" #include "dwarfFrameParser.h" @@ -51,7 +51,7 @@ using namespace std; #endif void DwarfHandle::defaultDwarfError(Dwarf_Error err, Dwarf_Ptr p) { - dwarf_dealloc(*(Dwarf_Debug*)(p), err, DW_DLA_ERROR); + dwarf_dealloc(*(Dwarf*)(p), err, DW_DLA_ERROR); } Dwarf_Handler DwarfHandle::defaultErrFunc = DwarfHandle::defaultDwarfError; @@ -202,21 +202,21 @@ Elf_X *DwarfHandle::debugLinkFile() return dbg_file; } -Dwarf_Debug *DwarfHandle::line_dbg() +Dwarf *DwarfHandle::line_dbg() { if (!init_dbg()) return NULL; return line_data; } -Dwarf_Debug *DwarfHandle::type_dbg() +Dwarf *DwarfHandle::type_dbg() { if (!init_dbg()) return NULL; return type_data; } -Dwarf_Debug *DwarfHandle::frame_dbg() +Dwarf *DwarfHandle::frame_dbg() { if (!init_dbg()) return NULL; diff --git a/dynC_API/src/dynC.tab.C b/dynC_API/src/dynC.tab.C index f3cf58dd32..f4e13446fc 100644 --- a/dynC_API/src/dynC.tab.C +++ b/dynC_API/src/dynC.tab.C @@ -1676,7 +1676,7 @@ yyreduce: yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: - '$$ = $1'. + '$$ = $2'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison diff --git a/dyninstAPI/src/emit-x86.C b/dyninstAPI/src/emit-x86.C index 7a9b88beed..d0fac52201 100644 --- a/dyninstAPI/src/emit-x86.C +++ b/dyninstAPI/src/emit-x86.C @@ -179,7 +179,7 @@ void EmitterIA32::emitRelOp(unsigned op, Register dest, Register src1, Register RealRegister scratch_r = gen.rs()->loadVirtualForWrite(scratch, gen); emitOpRegReg(XOR_R32_RM32, dest_r, dest_r, gen); //XOR dest,dest - emitMovImmToReg(scratch_r, 0x1, gen); //MOV $1,scratch + emitMovImmToReg(scratch_r, 0x1, gen); //MOV $2,scratch emitOpRegReg(CMP_GV_EV, src1_r, src2_r, gen); //CMP src1, src2 unsigned char opcode = cmovOpcodeFromRelOp(op); @@ -1330,7 +1330,7 @@ void EmitterAMD64::emitRelOp(unsigned op, Register dest, Register src1, Register codeBufIndex_t jcc_disp = gen.used(); gen.fill(1, codeGen::cgNOP); codeBufIndex_t after_jcc = gen.used(); - // mov $1, %dest + // mov $2, %dest emitMovImmToReg64(dest, 1, false, gen); codeBufIndex_t after_mov = gen.used(); @@ -1374,7 +1374,7 @@ void EmitterAMD64::emitRelOpImm(unsigned op, Register dest, Register src1, RegVa gen.fill(1, codeGen::cgNOP); codeBufIndex_t after_jcc = gen.used(); - // mov $1, %dest + // mov $2, %dest emitMovImmToReg64(dest, 1, false, gen); codeBufIndex_t after_mov = gen.used(); diff --git a/dyninstAPI/src/image.C b/dyninstAPI/src/image.C index dd166a9a3a..6569447cad 100644 --- a/dyninstAPI/src/image.C +++ b/dyninstAPI/src/image.C @@ -67,7 +67,7 @@ #if defined( cap_dwarf ) #include "dwarf.h" -#include "libdwarf.h" +#include "libdw.h" #endif #if defined(_MSC_VER) diff --git a/stackwalk/src/dbginfo-stepper.C b/stackwalk/src/dbginfo-stepper.C index 8fc4cd1893..dd20c829b4 100644 --- a/stackwalk/src/dbginfo-stepper.C +++ b/stackwalk/src/dbginfo-stepper.C @@ -55,7 +55,7 @@ static std::map dwarf_info; #include #include "dwarf.h" -#include "libdwarf.h" +#include "libdw.h" #include "Elf_X.h" static DwarfFrameParser::Ptr getAuxDwarfInfo(std::string s) diff --git a/symtabAPI/doc/A-Appendix.tex b/symtabAPI/doc/A-Appendix.tex index 8f521fcb48..ff150205e2 100644 --- a/symtabAPI/doc/A-Appendix.tex +++ b/symtabAPI/doc/A-Appendix.tex @@ -45,7 +45,7 @@ \subsection{Building on Unix} GNU Makefile syntax and must specify directories for each dependency. Specifically, LIBDWARFDIR, LIBELFDIR and LIBXML2DIR variables must be set. LIBDWARFDIR should be set to the absolute path of libdwarf library where -\texttt{dwarf.h} and \texttt{libdwarf.h} files reside. LIBELFDIR should be set +\texttt{dwarf.h} and \texttt{libdw.h} files reside. LIBELFDIR should be set to the absolute path where \texttt{libelf.a} and \texttt{libelf.so} files are located. Finally, LIBXML2DIR to the absolute path where libxml2 is located. diff --git a/symtabAPI/h/Module.h b/symtabAPI/h/Module.h index 1cebe99938..4ce5352c75 100644 --- a/symtabAPI/h/Module.h +++ b/symtabAPI/h/Module.h @@ -39,7 +39,7 @@ #include "IBSTree.h" #include "IBSTree-fast.h" #if defined(cap_dwarf) -#include "libdwarf.h" +#include "libdw.h" #endif #include #include "RangeLookup.h" diff --git a/symtabAPI/src/Object-elf.C b/symtabAPI/src/Object-elf.C index 8ef27a2b55..9dfe3c0aa3 100644 --- a/symtabAPI/src/Object-elf.C +++ b/symtabAPI/src/Object-elf.C @@ -2427,13 +2427,13 @@ void pd_dwarf_handler(Dwarf_Error error, Dwarf_Ptr /*userData*/) //bperr( "DWARF error: %s\n", dwarf_msg); } -Dwarf_Signed declFileNo = 0; +Dwarf_Sword declFileNo = 0; char ** declFileNoToName = NULL; -bool Object::dwarf_parse_aranges(Dwarf_Debug dbg, std::set& dies_seen) +bool Object::dwarf_parse_aranges(Dwarf dbg, std::set& dies_seen) { Dwarf_Arange* ranges; - Dwarf_Signed num_ranges; + Dwarf_Sword num_ranges; int status = dwarf_get_aranges(dbg, &ranges, &num_ranges, NULL); if(status != DW_DLV_OK) return false; Dwarf_Off cu_die_off; @@ -2476,10 +2476,10 @@ bool Object::dwarf_parse_aranges(Dwarf_Debug dbg, std::set& dies_seen bool Object::fix_global_symbol_modules_static_dwarf() { /* Initialize libdwarf. */ - Dwarf_Debug *dbg_ptr = dwarf->type_dbg(); + Dwarf *dbg_ptr = dwarf->type_dbg(); if (!dbg_ptr) return false; - Dwarf_Debug dbg = *dbg_ptr; + Dwarf dbg = *dbg_ptr; std::set dies_seen; Dwarf_Off cu_die_off; Dwarf_Die cu_die; @@ -2522,7 +2522,7 @@ bool Object::fix_global_symbol_modules_static_dwarf() { // cout << "No ranges for module " << modname << ", need to extract from statements\n"; Dwarf_Line* lines; - Dwarf_Signed num_lines; + Dwarf_Sword num_lines; if(dwarf_srclines(cu_die, &lines, &num_lines, NULL) == DW_DLV_OK) { Dwarf_Addr low; @@ -3340,7 +3340,7 @@ static int read_val_of_type(int type, unsigned long *value, const unsigned char #define SHORT_FDE_HLEN 4 #define LONG_FDE_HLEN 12 static -int read_except_table_gcc3(Dwarf_Fde *fde_data, Dwarf_Signed fde_count, +int read_except_table_gcc3(Dwarf_FDE *fde_data, Dwarf_Sword fde_count, mach_relative_info &mi, Elf_X_Shdr *eh_frame, Elf_X_Shdr *except_scn, std::vector &addresses) @@ -3349,8 +3349,8 @@ int read_except_table_gcc3(Dwarf_Fde *fde_data, Dwarf_Signed fde_count, Dwarf_Addr low_pc; Dwarf_Unsigned bytes_in_cie; Dwarf_Off fde_offset, cie_offset; - Dwarf_Fde fde; - Dwarf_Cie cie; + Dwarf_FDE fde; + Dwarf_CIE cie; int status, result, ptr_size; char *augmentor; unsigned char lpstart_format, ttype_format, table_format; @@ -3676,9 +3676,9 @@ bool Object::find_catch_blocks(Elf_X_Shdr *eh_frame, Address txtaddr, Address dataaddr, std::vector &catch_addrs) { - Dwarf_Cie *cie_data; - Dwarf_Fde *fde_data; - Dwarf_Signed cie_count, fde_count; + Dwarf_CIE *cie_data; + Dwarf_FDE *fde_data; + Dwarf_Sword cie_count, fde_count; Dwarf_Error err = (Dwarf_Error) NULL; Dwarf_Unsigned bytes_in_cie; char *augmentor; @@ -3691,12 +3691,12 @@ bool Object::find_catch_blocks(Elf_X_Shdr *eh_frame, return true; } - Dwarf_Debug *dbg_ptr = dwarf->frame_dbg(); + Dwarf *dbg_ptr = dwarf->frame_dbg(); if (!dbg_ptr) { pd_dwarf_handler(err, NULL); return false; } - Dwarf_Debug &dbg = *dbg_ptr; + Dwarf &dbg = *dbg_ptr; //Read the FDE and CIE information status = dwarf_get_fde_list_eh(dbg, &cie_data, &cie_count, @@ -3945,10 +3945,10 @@ void Object::getModuleLanguageInfo(dyn_hash_map *mod if (hasDwarfInfo()) { int status; - Dwarf_Debug *dbg_ptr = dwarf->type_dbg(); + Dwarf *dbg_ptr = dwarf->type_dbg(); if (!dbg_ptr) return; - Dwarf_Debug &dbg = *dbg_ptr; + Dwarf &dbg = *dbg_ptr; Dwarf_Unsigned hdr; char * moduleName = NULL; @@ -4326,21 +4326,21 @@ struct open_statement { Dwarf_Addr start_addr; Dwarf_Addr end_addr; Dwarf_Unsigned line_number; - Dwarf_Signed column_number; + Dwarf_Sword column_number; }; void Object::parseLineInfoForCU(Dwarf_Die cuDIE, LineInformation* li_for_module) { std::vector open_statements; - Dwarf_Debug *dbg_ptr = dwarf->line_dbg(); + Dwarf *dbg_ptr = dwarf->line_dbg(); if (!dbg_ptr) return; if(!cuDIE) return; - Dwarf_Debug dbg = *dbg_ptr; + Dwarf dbg = *dbg_ptr; /* Acquire this CU's source lines. */ Dwarf_Line * lineBuffer; - Dwarf_Signed lineCount; + Dwarf_Sword lineCount; Dwarf_Error ignored; int status = dwarf_srclines( cuDIE, & lineBuffer, & lineCount, &ignored ); @@ -4359,7 +4359,7 @@ void Object::parseLineInfoForCU(Dwarf_Die cuDIE, LineInformation* li_for_module) StringTablePtr strings(li_for_module->getStrings()); char** files; size_t offset = strings->size(); - Dwarf_Signed filecount; + Dwarf_Sword filecount; status = dwarf_srcfiles(cuDIE, &files, &filecount, &ignored); if (status != DW_DLV_OK ) { @@ -4497,7 +4497,7 @@ void Object::parseLineInfoForCU(Dwarf_Die cuDIE, LineInformation* li_for_module) void Object::parseLineInfoForAddr(Offset addr_to_find) { - Dwarf_Debug *dbg_ptr = dwarf->line_dbg(); + Dwarf *dbg_ptr = dwarf->line_dbg(); if (!dbg_ptr) return; std::set mod_for_offset; @@ -4545,7 +4545,7 @@ void Object::parseTypeInfo() #endif parseStabTypes(); - Dwarf_Debug* typeInfo = dwarf->type_dbg(); + Dwarf* typeInfo = dwarf->type_dbg(); if(!typeInfo) return; DwarfWalker walker(associated_symtab, *typeInfo); walker.parse(); diff --git a/symtabAPI/src/Object-elf.h b/symtabAPI/src/Object-elf.h index 76d2e06eae..4f0537b109 100644 --- a/symtabAPI/src/Object-elf.h +++ b/symtabAPI/src/Object-elf.h @@ -39,7 +39,7 @@ #if defined(cap_dwarf) //#include "dwarf.h" -#include "libdwarf.h" +#include "libdw.h" #include "dwarfHandle.h" #endif @@ -525,7 +525,7 @@ class Object; private: void parseLineInfoForCU(Module::DebugInfoT cuDIE, LineInformation* li); - bool dwarf_parse_aranges(Dwarf_Debug dbg, std::set& dies_seen); + bool dwarf_parse_aranges(Dwarf dbg, std::set& dies_seen); void parseDwarfTypes(Symtab *obj); void parseStabTypes(); diff --git a/symtabAPI/src/dwarfWalker.C b/symtabAPI/src/dwarfWalker.C index 944a1c8b41..3a06dfadd5 100644 --- a/symtabAPI/src/dwarfWalker.C +++ b/symtabAPI/src/dwarfWalker.C @@ -74,7 +74,7 @@ using namespace std; } #define DWARF_CHECK_RET(x) DWARF_CHECK_RET_VAL(x, false) -DwarfWalker::DwarfWalker(Symtab *symtab, Dwarf_Debug dbg) +DwarfWalker::DwarfWalker(Symtab *symtab, Dwarf dbg) : DwarfParseActions(symtab, dbg), srcFileList_(NULL), @@ -248,8 +248,8 @@ void DwarfParseActions::setModuleFromName(std::string moduleName) } } -bool DwarfWalker::buildSrcFiles(Dwarf_Debug dbg, Dwarf_Die entry, StringTablePtr srcFiles) { - Dwarf_Signed cnt = 0; +bool DwarfWalker::buildSrcFiles(Dwarf dbg, Dwarf_Die entry, StringTablePtr srcFiles) { + Dwarf_Sword cnt = 0; char** srcFileList; Dwarf_Error error; int ret = dwarf_srcfiles(entry, &srcFileList, &cnt, &error); @@ -673,7 +673,7 @@ void DwarfWalker::setRanges(FunctionBase *func) { } } -pair DwarfWalker::parseHighPCLowPC(Dwarf_Debug dbg, Dwarf_Die entry) +pair DwarfWalker::parseHighPCLowPC(Dwarf dbg, Dwarf_Die entry) { Dwarf_Attribute hasLow; @@ -701,7 +701,7 @@ pair DwarfWalker::parseHighPCLowPC(Dwarf_Debug dbg, Dwarf_Di return result; } -bool DwarfWalker::parseRangeTypes(Dwarf_Debug dbg, Dwarf_Die die) { +bool DwarfWalker::parseRangeTypes(Dwarf dbg, Dwarf_Die die) { dwarf_printf("(0x%lx) Parsing ranges\n", id()); clearRanges(); @@ -715,7 +715,7 @@ bool DwarfWalker::parseRangeTypes(Dwarf_Debug dbg, Dwarf_Die die) { return !newRanges.empty(); } -vector DwarfWalker::getDieRanges(Dwarf_Debug dbg, Dwarf_Die die, Offset range_base) { +vector DwarfWalker::getDieRanges(Dwarf dbg, Dwarf_Die die, Offset range_base) { std::vector newRanges; auto highlow = parseHighPCLowPC(dbg, die); if(highlow.second) newRanges.push_back(highlow.first); @@ -724,7 +724,7 @@ vector DwarfWalker::getDieRanges(Dwarf_Debug dbg, Dwarf_Die die, O if (findConstant(DW_AT_ranges, range_offset, die, dbg)) { Dwarf_Ranges *ranges = NULL; - Dwarf_Signed ranges_length = 0; + Dwarf_Sword ranges_length = 0; dwarf_printf("calling ranges_a, offset 0x%lx, die %p\n", range_offset, die); int status = (dwarf_get_ranges_a(dbg, (Dwarf_Off) range_offset, die, &ranges, &ranges_length, NULL, NULL)); @@ -1416,7 +1416,7 @@ bool DwarfWalker::handleSpecification(bool &hasSpec) { return true; } -bool DwarfWalker::findDieName(Dwarf_Debug dbg, Dwarf_Die die, std::string &name) { +bool DwarfWalker::findDieName(Dwarf dbg, Dwarf_Die die, std::string &name) { char *cname = NULL; Dwarf_Error error; @@ -1733,8 +1733,8 @@ bool DwarfWalker::decodeLocationList(Dwarf_Half attr, } else { dwarf_printf("(0x%lx) Decoding loclist location\n", id()); - Dwarf_Locdesc **locationList; - Dwarf_Signed listLength; + Dwarf_Op* **locationList; + Dwarf_Sword listLength; int status = dwarf_loclist_n( locationAttribute, & locationList, & listLength, NULL ); dwarf_dealloc( dbg(), locationAttribute, DW_DLA_ATTR ); @@ -1843,7 +1843,7 @@ bool DwarfWalker::findString(Dwarf_Half attr, return result; } -bool DwarfWalker::findConstant(Dwarf_Half attr, Address &value, Dwarf_Die entry, Dwarf_Debug dbg) { +bool DwarfWalker::findConstant(Dwarf_Half attr, Address &value, Dwarf_Die entry, Dwarf dbg) { Dwarf_Bool has = false; DWARF_FAIL_RET(dwarf_hasattr(entry, attr, &has, NULL)); if (!has) return false; @@ -1874,7 +1874,7 @@ bool DwarfWalker::findConstantWithForm(Dwarf_Attribute &locationAttribute, value = (Address) addr; return true; case DW_FORM_sdata: - Dwarf_Signed s_tmp; + Dwarf_Sword s_tmp; DWARF_FAIL_RET(dwarf_formsdata(locationAttribute, &s_tmp, NULL)); value = (Address) s_tmp; dwarf_printf("Decoded data of form %x to 0x%lx\n", @@ -1987,7 +1987,7 @@ bool DwarfWalker::findValue(long &value, bool &valid) { return true; } - Dwarf_Signed enumValue; + Dwarf_Sword enumValue; DWARF_FAIL_RET(dwarf_formsdata(valueAttr, &enumValue, NULL)); @@ -2224,7 +2224,7 @@ bool DwarfWalker::decipherBound(Dwarf_Attribute boundAttribute, Dwarf_Bool is_in dwarf_printf("(0x%lx) Decoding form %d with formsdata\n", id(), boundForm); - Dwarf_Signed constantBound; + Dwarf_Sword constantBound; DWARF_FAIL_RET(dwarf_formsdata( boundAttribute, & constantBound, NULL )); char bString[40]; sprintf(bString, "%lld", (long long)constantBound); @@ -2276,8 +2276,8 @@ bool DwarfWalker::decipherBound(Dwarf_Attribute boundAttribute, Dwarf_Bool is_in { /* PGI extends DWARF to allow some bounds to be location lists. Since we can't do anything sane with them, ignore them. */ - // Dwarf_Locdesc * locationList; - // Dwarf_Signed listLength; + // Dwarf_Op* * locationList; + // Dwarf_Sword listLength; // status = dwarf_loclist( boundAttribute, & locationList, & listLength, NULL ); boundString = "{PGI extension}"; return false; @@ -2299,7 +2299,7 @@ bool DwarfWalker::decodeExpression(Dwarf_Attribute &attr, DWARF_FAIL_RET(dwarf_formexprloc(attr, &expr_len, &expr_ptr, NULL)); unsigned char *bitstream = (unsigned char *) expr_ptr; - // expr_ptr is a pointer to a bytestream. Try to turn it into a Dwarf_Locdesc so + // expr_ptr is a pointer to a bytestream. Try to turn it into a Dwarf_Op* so // we can use decodeDwarfExpression. dwarf_printf("(0x%lx) bitstream for expr has len %d\n", id(), expr_len); @@ -2307,8 +2307,8 @@ bool DwarfWalker::decodeExpression(Dwarf_Attribute &attr, dwarf_printf("(0x%lx) \t %#hhx\n", id(), bitstream[i]); } - Dwarf_Signed cnt; - Dwarf_Locdesc *descs; + Dwarf_Sword cnt; + Dwarf_Op* *descs; DWARF_FAIL_RET(dwarf_loclist_from_expr_a(dbg(), expr_ptr, expr_len, addr_size, &descs, &cnt, NULL)); @@ -2319,8 +2319,8 @@ bool DwarfWalker::decodeExpression(Dwarf_Attribute &attr, return ret; } -bool DwarfWalker::decodeLocationListForStaticOffsetOrAddress( Dwarf_Locdesc **locationList, - Dwarf_Signed listLength, +bool DwarfWalker::decodeLocationListForStaticOffsetOrAddress( Dwarf_Op* **locationList, + Dwarf_Sword listLength, std::vector& locs, Address * initialStackValue) { @@ -2357,7 +2357,7 @@ bool DwarfWalker::decodeLocationListForStaticOffsetOrAddress( Dwarf_Locdesc **lo for (unsigned locIndex = 0 ; locIndex < listLength; locIndex++) { /* There is only one location. */ - Dwarf_Locdesc *location = locationList[locIndex]; + Dwarf_Op* *location = locationList[locIndex]; VariableLocation loc; // Initialize location values. @@ -2430,8 +2430,8 @@ bool DwarfWalker::decodeLocationListForStaticOffsetOrAddress( Dwarf_Locdesc **lo } /* end decodeLocationListForStaticOffsetOrAddress() */ -void DwarfWalker::deallocateLocationList( Dwarf_Locdesc ** locationList, - Dwarf_Signed listLength ) +void DwarfWalker::deallocateLocationList( Dwarf_Op* ** locationList, + Dwarf_Sword listLength ) { for( int i = 0; i < listLength; i++ ) { dwarf_dealloc( dbg(), locationList[i]->ld_s, DW_DLA_LOC_BLOCK ); diff --git a/symtabAPI/src/dwarfWalker.h b/symtabAPI/src/dwarfWalker.h index 22b5bebdc2..1f1cda9ca1 100644 --- a/symtabAPI/src/dwarfWalker.h +++ b/symtabAPI/src/dwarfWalker.h @@ -7,7 +7,7 @@ #include "elf.h" #include "libelf.h" -#include "libdwarf.h" +#include "libdw.h" #include #include #include @@ -37,7 +37,7 @@ namespace Dyninst { class DwarfParseActions { protected: - Dwarf_Debug dbg() { return dbg_; } + Dwarf dbg() { return dbg_; } Module *& mod() { return mod_; } @@ -47,9 +47,9 @@ namespace Dyninst { private: Module *mod_; - Dwarf_Debug dbg_; + Dwarf dbg_; public: - DwarfParseActions(Symtab* s, Dwarf_Debug d) : + DwarfParseActions(Symtab* s, Dwarf d) : mod_(NULL), dbg_(d), symtab_(s) @@ -174,7 +174,7 @@ namespace Dyninst { } Error; - DwarfWalker(Symtab *symtab, Dwarf_Debug dbg); + DwarfWalker(Symtab *symtab, Dwarf dbg); virtual ~DwarfWalker(); @@ -188,7 +188,7 @@ namespace Dyninst { // whereas parse creates a context. bool parse_int(Dwarf_Die entry, bool parseSiblings); static std::pair::iterator, std::vector::iterator> - parseRangeList(Dwarf_Ranges *ranges, Dwarf_Signed num_ranges, Offset initial_base); + parseRangeList(Dwarf_Ranges *ranges, Dwarf_Sword num_ranges, Offset initial_base); private: enum inline_t { NormalFunc, @@ -197,7 +197,7 @@ namespace Dyninst { bool parseSubprogram(inline_t func_type); bool parseLexicalBlock(); - bool parseRangeTypes(Dwarf_Debug dbg, Dwarf_Die die); + bool parseRangeTypes(Dwarf dbg, Dwarf_Die die); bool parseCommonBlock(); bool parseConstant(); virtual bool parseVariable(); @@ -213,7 +213,7 @@ namespace Dyninst { bool parseMember(); bool parseConstPackedVolatile(); bool parseTypeReferences(); - static std::pair parseHighPCLowPC(Dwarf_Debug dbg, Dwarf_Die entry); + static std::pair parseHighPCLowPC(Dwarf dbg, Dwarf_Die entry); // These vary as we parse the tree @@ -240,7 +240,7 @@ namespace Dyninst { // A printable ID for a particular entry unsigned long id() { return (unsigned long) (offset() - compile_offset); } public: - static bool buildSrcFiles(Dwarf_Debug dbg, Dwarf_Die entry, StringTablePtr strings); + static bool buildSrcFiles(Dwarf dbg, Dwarf_Die entry, StringTablePtr strings); private: bool parseCallsite(); @@ -264,7 +264,7 @@ namespace Dyninst { bool &hasLineNumber, std::string &filename); public: - static bool findDieName(Dwarf_Debug dbg, Dwarf_Die die, std::string &); + static bool findDieName(Dwarf dbg, Dwarf_Die die, std::string &); private: bool findName(std::string &); void removeFortranUnderscore(std::string &); @@ -287,11 +287,11 @@ namespace Dyninst { Dwarf_Half &form); bool findString(Dwarf_Half attr, std::string &str); public: - static bool findConstant(Dwarf_Half attr, Address &value, Dwarf_Die entry, Dwarf_Debug dbg); + static bool findConstant(Dwarf_Half attr, Address &value, Dwarf_Die entry, Dwarf dbg); static bool findConstantWithForm(Dwarf_Attribute &attr, Dwarf_Half form, Address &value); - static std::vector getDieRanges(Dwarf_Debug dbg, Dwarf_Die die, Offset base); + static std::vector getDieRanges(Dwarf dbg, Dwarf_Die die, Offset base); private: bool decodeConstantLocation(Dwarf_Attribute &attr, Dwarf_Half form, std::vector &locs); @@ -305,12 +305,12 @@ namespace Dyninst { bool decodeExpression(Dwarf_Attribute &attr, std::vector &locs); - bool decodeLocationListForStaticOffsetOrAddress(Dwarf_Locdesc **locationList, - Dwarf_Signed listLength, + bool decodeLocationListForStaticOffsetOrAddress(Dwarf_Op* **locationList, + Dwarf_Sword listLength, std::vector& locs, Address * initialStackValue = NULL); - void deallocateLocationList(Dwarf_Locdesc **locationList, - Dwarf_Signed listLength); + void deallocateLocationList(Dwarf_Op* **locationList, + Dwarf_Sword listLength); // Header-only functions get multiple parsed. diff --git a/symtabAPI/src/parseDwarf.C b/symtabAPI/src/parseDwarf.C index 12cb8e940d..c6e82efa3b 100644 --- a/symtabAPI/src/parseDwarf.C +++ b/symtabAPI/src/parseDwarf.C @@ -32,7 +32,7 @@ #include "elf.h" #include "libelf.h" #include "dwarf.h" -#include "libdwarf.h" +#include "libdw.h" #include "dwarfExprParser.h" #include "dwarfFrameParser.h" @@ -57,12 +57,12 @@ /* Use this to get the cfa. */ extern "C" { int dwarf_get_fde_info_for_cfa_reg3( - Dwarf_Fde /*fde*/, + Dwarf_FDE /*fde*/, Dwarf_Addr /*pc_requested*/, Dwarf_Small * /*value_type*/, - Dwarf_Signed * /*offset_relevant*/, - Dwarf_Signed * /*register*/, - Dwarf_Signed * /*offset_or_block_len*/, + Dwarf_Sword * /*offset_relevant*/, + Dwarf_Sword * /*register*/, + Dwarf_Sword * /*offset_or_block_len*/, Dwarf_Ptr * /*block_ptr */, Dwarf_Addr* /*row_pc_out*/, Dwarf_Error* /*error*/)