SystemTap.h

Go to the documentation of this file.
00001 #include "dyntypes.h"
00002 #include "dyn_regs.h"
00003 #include <vector>
00004 #include <boost/shared_ptr.hpp>
00005 
00006 #if !defined(SystemTap_h_)
00007 #define SystemTap_h_
00008 namespace Dyninst {
00009 
00010 class Elf_X;
00011 
00012 class ArgTree {
00013 private:
00014    ArgTree() {}
00015 public:
00016    typedef boost::shared_ptr<ArgTree> ptr;
00017    enum op_type_t {
00018       Register,
00019       Constant,
00020       Add,
00021       Multiply,
00022       Dereference,
00023       Segment
00024    };
00025    union op_data_t{
00026       signed int reg;
00027       signed long val;
00028    };
00029    op_type_t op_type;
00030    op_data_t op_data;
00031    ArgTree::ptr lchild;
00032    ArgTree::ptr rchild;
00033 
00034    void print(FILE *f);
00035    static ArgTree::ptr createConstant(const signed long &v);
00036    static ArgTree::ptr createRegister(Dyninst::MachRegister r);
00037    static ArgTree::ptr createDeref(ArgTree::ptr sub);
00038    static ArgTree::ptr createSegment(ArgTree::ptr l, ArgTree::ptr r);
00039    static ArgTree::ptr createAdd(ArgTree::ptr l, ArgTree::ptr r);
00040    static ArgTree::ptr createMultiply(ArgTree::ptr l, ArgTree::ptr r);
00041 };
00042 
00043 class x86OperandParser;
00044 class ppcOperandParser;
00045 
00046 class SystemTapEntries {
00047   public:
00048    struct Arg {
00049       unsigned arg_size;
00050       bool is_arg_signed;
00051       ArgTree::ptr tree;
00052    };
00053 
00054    struct Entry {
00055       Dyninst::Address addr;
00056       Dyninst::Address base_addr;
00057       Dyninst::Address semaphore_addr;
00058       std::string provider;
00059       std::vector<Arg> args;
00060    };
00061 
00062    static SystemTapEntries *createSystemTapEntries(Elf_X *file_);
00063 
00064    typedef std::map<std::string, const Entry *> entry_list_t;
00065 
00066    const entry_list_t &entryList() { return name_to_entry; }
00067   private:
00068    SystemTapEntries(Elf_X *file_);
00069    ~SystemTapEntries();
00070 
00071 
00072    static x86OperandParser *x86_parser;
00073    static x86OperandParser *x86_64_parser;
00074    static ppcOperandParser *ppc32_parser;
00075    static ppcOperandParser *ppc64_parser;
00076    static std::map<Elf_X *, SystemTapEntries *> all_entries;
00077    Elf_X *file;
00078    Dyninst::Architecture arch;
00079    unsigned int word_size;
00080 
00081    bool readAddr(const unsigned char *buffer, size_t size, unsigned &offset,
00082                  Dyninst::Address &result, unsigned int read_size = 0);
00083    bool readString(const unsigned char *buffer, size_t bsize, unsigned &offset, 
00084                    std::string &result);
00085 
00086    bool parse();
00087    bool parseAllNotes();
00088    bool parseNotes(const void *notes, size_t size);
00089    bool parseOperands(std::string ops, Entry &entry);
00090    bool parseOperand_x86(std::string op, Arg &result);
00091    bool parseOperand_ppc(std::string op, Arg &result);
00092 
00093    entry_list_t name_to_entry;
00094 };
00095 
00096 }
00097 
00098 #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