dwarfFrameParser.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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,
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 ®_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
00092
00093
00094
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