dwarfFrameParser.h

Go to the documentation of this file.
00001 /*
00002  * See the dyninst/COPYRIGHT file for copyright information.
00003  * 
00004  * We provide the Paradyn Tools (below described as "Paradyn")
00005  * on an AS IS basis, and do not warrant its validity or performance.
00006  * We reserve the right to update, modify, or discontinue this
00007  * software at any time.  We shall have no obligation to supply such
00008  * updates or modifications or any other form of support to you.
00009  * 
00010  * By your use of Paradyn, you understand and agree that we (or any
00011  * other person or entity with proprietary rights in Paradyn) are
00012  * under no obligation to provide either maintenance services,
00013  * update services, notices of latent defects, or correction of
00014  * defects for Paradyn.
00015  * 
00016  * This library is free software; you can redistribute it and/or
00017  * modify it under the terms of the GNU Lesser General Public
00018  * License as published by the Free Software Foundation; either
00019  * version 2.1 of the License, or (at your option) any later version.
00020  * 
00021  * This library is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00024  * Lesser General Public License for more details.
00025  * 
00026  * You should have received a copy of the GNU Lesser General Public
00027  * License along with this library; if not, write to the Free Software
00028  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00029  */
00030 
00031 #if !defined(DWARF_SW_H_)
00032 #define DWARF_SW_H_
00033 
00034 #include <stack>
00035 #include <vector>
00036 #include "dyntypes.h"
00037 #include "dyn_regs.h"
00038 #include "ProcReader.h"
00039 #include "libdwarf.h"
00040 
00041 namespace Dyninst {
00042 
00043 struct VariableLocation;
00044 
00045 namespace Dwarf {
00046    class DwarfResult;
00047 typedef enum {
00048    FE_Bad_Frame_Data = 15,   /* to coincide with equivalent SymtabError */
00049    FE_No_Frame_Entry,
00050    FE_Frame_Read_Error,
00051    FE_Frame_Eval_Error,
00052    FE_No_Error
00053 } FrameErrors_t;
00054 
00055 typedef struct {
00056   Dwarf_Fde *fde_data;
00057   Dwarf_Signed fde_count;
00058   Dwarf_Cie *cie_data;
00059   Dwarf_Signed cie_count;   
00060 } fde_cie_data;
00061 
00062 
00063 class DwarfFrameParser {
00064   public:
00065 
00066    typedef boost::shared_ptr<DwarfFrameParser> Ptr;
00067 
00068    static Ptr create(Dwarf_Debug dbg, Architecture arch);
00069 
00070    DwarfFrameParser(Dwarf_Debug dbg_, Architecture arch);
00071    ~DwarfFrameParser();
00072 
00073    bool hasFrameDebugInfo();
00074    
00075    bool getRegRepAtFrame(Address pc,
00076                          MachRegister reg,
00077                          VariableLocation &loc,
00078                          FrameErrors_t &err_result);
00079 
00080    bool getRegValueAtFrame(Address pc, 
00081                            MachRegister reg, 
00082                            MachRegisterVal &reg_result,
00083                            ProcessReader *reader,
00084                            FrameErrors_t &err_result);
00085 
00086    bool getRegAtFrame(Address pc,
00087                       MachRegister reg,
00088                       DwarfResult &cons,
00089                       FrameErrors_t &err_result);
00090 
00091    // Returns whatever Dwarf claims the function covers. 
00092    // We use an entryPC (actually, can be any PC in the function)
00093    // because common has no idea what a Function is and I don't want
00094    // to move this to Symtab. 
00095    bool getRegsForFunction(Address entryPC,
00096                            MachRegister reg,
00097                            std::vector<VariableLocation> &locs,
00098                            FrameErrors_t &err_result);
00099 
00100 
00101   private:
00102 
00103    bool getRegAtFrame_aux(Address pc,
00104                           Dwarf_Fde fde,
00105                           Dwarf_Half dwarf_reg,
00106                           MachRegister orig_reg,
00107                           DwarfResult &cons,
00108                           Address &lowpc,
00109                           FrameErrors_t &err_result);
00110 
00111    bool getFDE(Address pc, 
00112                Dwarf_Fde &fde, 
00113                Address &low,
00114                Address &high,
00115                FrameErrors_t &err_result);
00116 
00117    bool getDwarfReg(MachRegister reg,
00118                     Dwarf_Fde &fde,
00119                     Dwarf_Half &dwarf_reg,
00120                     FrameErrors_t &err_result);
00121    
00122    bool handleExpression(Address pc,
00123                          Dwarf_Signed registerNum,
00124                          MachRegister origReg,
00125                          Architecture arch,
00126                          DwarfResult &cons,
00127                          bool &done,
00128                          FrameErrors_t &err_result);
00129 
00130    static std::map<Dwarf_Debug, Ptr> frameParsers;
00131 
00132    typedef enum {
00133       dwarf_status_uninitialized,
00134       dwarf_status_error,
00135       dwarf_status_ok
00136    } dwarf_status_t;
00137    Dwarf_Debug dbg;
00138    Architecture arch;
00139    dwarf_status_t fde_dwarf_status;
00140 
00141    std::vector<fde_cie_data> fde_data;
00142    void setupFdeData();
00143 
00144 
00145 
00146 };
00147 
00148 }
00149 
00150 }
00151 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 12 Jul 2013 for SymtabAPI by  doxygen 1.6.1