Kind-of worked on the R-Tree; not really enough time to do much.
[aesalon.git] / include / monitor / ElfParser.h
blob47ca70cc0072a47c81c84013ea5c4b6f785ac07c
1 /** Aesalon, a tool to visualize program behaviour in real time.
2 Copyright (C) 2009-2011, Aesalon development team.
4 Aesalon is distributed under the terms of the GNU GPLv3. See
5 the included file LICENSE for more information.
7 @file include/monitor/ElfParser.h
8 */
10 #ifndef AesalonMonitor_ElfParser_H
11 #define AesalonMonitor_ElfParser_H
13 #include <stdint.h>
14 #include <string>
16 #include "config/Vault.h"
18 #define ELF32_TYPES Elf32_Ehdr, Elf32_Shdr, Elf32_Sym
19 #define ELF64_TYPES Elf64_Ehdr, Elf64_Shdr, Elf64_Sym
21 namespace Monitor {
23 class ElfParser {
24 public:
25 class Processor {
26 public:
27 virtual ~Processor() {}
29 virtual void process(const char *symbolName, uint64_t symbolAddress, uint64_t symbolSize) = 0;
31 int m_fd;
32 uint8_t *m_file;
33 uint32_t m_fileSize;
34 Processor *m_processor;
36 enum ElfType {
37 ELF32,
38 ELF64
39 } m_elfType;
41 enum Encoding {
42 MSB_ENCODING,
43 LSB_ENCODING
44 } m_encoding;
45 public:
46 ElfParser();
47 virtual ~ElfParser();
49 void parse(const std::string &filename, Processor *processor);
50 private:
51 bool identValid();
53 template<typename ELFHeader, typename SectionHeader, typename SymbolHeader>
54 void parseElf();
56 template<typename SymbolHeader>
57 void parseSymbols(SymbolHeader *symbols, int symbolCount, const char *stringTable);
60 } // namespace Monitor
62 #endif