summaryrefslogtreecommitdiff
path: root/other/Kermit/include/SymbolTable.hpp
blob: b0f8aa3348d063a97547e65a911ca1aee62b2e53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
 * SymbolTable.hpp:
 * a container for "on-demand" symbol address fetching
 * written by palmers / teso
 */
#ifndef __SYMBOL_TABLE_C
#define __SYMBOL_TABLE_C

#include <SymbolFingp.hpp>
#include <SystemMap.hpp>
#include <DevMemPatt.hpp>
#include <rwKernel.hpp>
#include <list>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iterator>

#define DEFAULTDUMP		"SymbolTableDump"
#define DEFAULTSYSTEMMAP	"System.map"

typedef struct
  {
    string Name;
    unsigned int Address;
  } zzSym;
typedef list<zzSym *> zzSymList;


/**
 * A container class for "on-demand" symbol address fetching.
 */
class SymbolTable
{
private:
  SymbolFingp *fing;
  DevMemPatt *patt;
  SystemMap exported;
  SystemMap mapp;
  SystemMap rest;
  string dump_file;

  bool createObjects (rwKernel *);
  bool loadFiles (string, string);

public:
/**
 * List of name, address pairs.
 */
  zzSymList symList;

/**
 * Construct a SymbolTable object and load configuration from default files.
 */
  SymbolTable ();

/**
 * Construct a SymbolTable object and load configuration from defined files.
 * @param res file name of restore file.
 * @param sys System.map file to load.
 */
  SymbolTable (string res, string sys);

/**
 * Construct a SymbolTable object and use the referenced rwKernel object in all
 * member attributes and methods.
 */
  SymbolTable (rwKernel *);

/**
 * Foo.
 */
  ~SymbolTable ();

/**
 * Define the file written to on saveCache ().
 * @see saveCache()
 */
  void setSaveFile (string);

/**
 * get the address of a known symbol.
 * @return If the symbol is unknow zero is returned.
 * (hey, would you call 0x00000000?). Else, the address
 * of the symbol.
 */
  unsigned int getSymbol (string);

/**
 * Find a symbol. This will try all available methods to
 * find a symbol and cache the address, name pair (zero
 * if search was not successfull).
 * @return true on success.
 */
  bool findSymbol (string);

/**
 * add a symbol, address pair to the cache.
 */
  void addSymbolToCache (string, unsigned int);

/**
 * flush the address cache.
 */
  void clearCache ();

/**
 * save the cache to a file (human readable, System.map style).
 */
  bool saveCache ();
};
#endif /* __SYMBOL_TABLE_C */