Minor changes here and there.
[aesalon.git] / src / monitor / SymbolResolver.cpp
blobbbb05e2533e3639a7be245ba49bd44dd68c96be9
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 src/monitor/SymbolResolver.cpp
8 */
10 #include <cstring>
12 #include "monitor/SymbolResolver.h"
13 #include "storage/RTree.h"
14 #include "monitor/ElfParser.h"
15 #include "monitor/Coordinator.h"
17 namespace Monitor {
19 SymbolResolver::SymbolResolver() {
20 m_rtree = new RTree();
23 SymbolResolver::~SymbolResolver() {
24 delete m_rtree;
27 void SymbolResolver::parse(const std::string &filename, uint64_t offset) {
28 class Processor : public ElfParser::Processor {
29 private:
30 RTree *m_rtree;
31 uint64_t m_offset;
32 Storage::Mempool *m_mempool;
33 public:
34 Processor(RTree *rtree, uint64_t offset) : m_rtree(rtree), m_offset(offset),
35 m_mempool(Coordinator::instance()->mempool()) {}
36 virtual ~Processor() {}
38 virtual void process(const char *symbolName, uint64_t symbolAddress, uint64_t symbolSize) {
39 symbolAddress += m_offset;
40 RTree::Bound b;
41 b.setRange(RTree::Range(symbolAddress, symbolAddress + symbolSize), 0);
43 char *name = static_cast<char *>(m_mempool->request(std::strlen(symbolName)));
44 strcpy(name, symbolName);
45 m_rtree->insert(b, name);
49 Processor p(m_rtree, offset);
51 ElfParser ep;
52 ep.parse(filename, &p);
55 } // namespace Monitor