~registry/dolphin-emu/triforce

« back to all changes in this revision

Viewing changes to Source/Core/Common/Src/SymbolDB.h

  • Committer: Sérgio Benjamim
  • Date: 2015-02-13 05:54:40 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20150213055440-ey2rt3sjpy27km78
Dolphin Triforce branch from code.google, commit b957980 (4.0-315).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2013 Dolphin Emulator Project
 
2
// Licensed under GPLv2
 
3
// Refer to the license.txt file included.
 
4
 
 
5
// This file contains a generic symbol map implementation. For CPU-specific
 
6
// magic, derive and extend.
 
7
 
 
8
#ifndef _SYMBOL_DB_H
 
9
#define _SYMBOL_DB_H
 
10
 
 
11
#include <string>
 
12
#include <map>
 
13
#include <vector>
 
14
 
 
15
#include "Common.h"
 
16
 
 
17
struct SCall
 
18
{
 
19
        SCall(u32 a, u32 b) :
 
20
                function(a),
 
21
                callAddress(b)
 
22
        {}
 
23
        u32 function;
 
24
        u32 callAddress;
 
25
};
 
26
 
 
27
struct Symbol
 
28
{
 
29
        enum {
 
30
                SYMBOL_FUNCTION = 0,
 
31
                SYMBOL_DATA = 1,
 
32
        };
 
33
 
 
34
        Symbol() :
 
35
                hash(0),
 
36
                address(0),
 
37
                flags(0),
 
38
                size(0),
 
39
                numCalls(0),
 
40
                type(SYMBOL_FUNCTION),
 
41
                analyzed(0)
 
42
        {}
 
43
 
 
44
        std::string name;
 
45
        std::vector<SCall> callers; //addresses of functions that call this function
 
46
        std::vector<SCall> calls;   //addresses of functions that are called by this function
 
47
        u32 hash;            //use for HLE function finding
 
48
        u32 address;
 
49
        u32 flags;
 
50
        int size;
 
51
        int numCalls;
 
52
        int type;
 
53
        int index; // only used for coloring the disasm view
 
54
        int analyzed;
 
55
};
 
56
 
 
57
enum
 
58
{
 
59
        FFLAG_TIMERINSTRUCTIONS=(1<<0),
 
60
        FFLAG_LEAF=(1<<1),
 
61
        FFLAG_ONLYCALLSNICELEAFS=(1<<2),
 
62
        FFLAG_EVIL=(1<<3),
 
63
        FFLAG_RFI=(1<<4),
 
64
        FFLAG_STRAIGHT=(1<<5)
 
65
};
 
66
 
 
67
 
 
68
 
 
69
class SymbolDB
 
70
{
 
71
public:
 
72
        typedef std::map<u32, Symbol>  XFuncMap;
 
73
        typedef std::map<u32, Symbol*> XFuncPtrMap;
 
74
 
 
75
protected:
 
76
        XFuncMap    functions;
 
77
        XFuncPtrMap checksumToFunction;
 
78
 
 
79
public:
 
80
        SymbolDB() {}
 
81
        virtual ~SymbolDB() {}
 
82
        virtual Symbol *GetSymbolFromAddr(u32 addr) { return 0; }
 
83
        virtual Symbol *AddFunction(u32 startAddr) { return 0;}
 
84
 
 
85
        void AddCompleteSymbol(const Symbol &symbol);
 
86
 
 
87
        Symbol *GetSymbolFromName(const char *name);
 
88
        Symbol *GetSymbolFromHash(u32 hash) {
 
89
                XFuncPtrMap::iterator iter = checksumToFunction.find(hash);
 
90
                if (iter != checksumToFunction.end())
 
91
                        return iter->second;
 
92
                else
 
93
                        return 0;
 
94
        }
 
95
 
 
96
        const XFuncMap &Symbols() const {return functions;}
 
97
        XFuncMap &AccessSymbols() {return functions;}
 
98
 
 
99
        // deprecated
 
100
        XFuncMap::iterator GetIterator() { return functions.begin(); }
 
101
        XFuncMap::const_iterator GetConstIterator() { return functions.begin(); }
 
102
        XFuncMap::iterator End() { return functions.end(); }
 
103
 
 
104
        void Clear(const char *prefix = "");
 
105
        void List();
 
106
        void Index();
 
107
};
 
108
 
 
109
#endif