ppsspp/Core/Debugger/SymbolMap.h

110 lines
3 KiB
C
Raw Normal View History

2012-11-01 16:19:01 +01:00
// Copyright (c) 2012- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
2012-11-01 16:19:01 +01:00
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#pragma once
#include "Globals.h"
#include "native/base/mutex.h"
2012-11-01 16:19:01 +01:00
#include <vector>
#include <set>
#include <map>
2012-11-01 16:19:01 +01:00
enum SymbolType {
2012-11-01 16:19:01 +01:00
ST_FUNCTION=1,
ST_DATA=2
};
struct SymbolInfo {
u32 address;
u32 size;
};
2012-11-01 16:19:01 +01:00
#ifdef _WIN32
struct HWND__;
typedef struct HWND__ *HWND;
#endif
class SymbolMap {
2012-11-01 16:19:01 +01:00
public:
SymbolMap() {}
2012-11-01 16:19:01 +01:00
bool LoadSymbolMap(const char *filename);
void SaveSymbolMap(const char *filename) const;
2013-07-29 13:06:01 +02:00
bool LoadNocashSym(const char *ilename);
2012-11-01 16:19:01 +01:00
void AddSymbol(const char *symbolname, unsigned int vaddress, size_t size, SymbolType symbol);
void RemoveSymbolNum(int symbolnum);
void Clear();
2012-11-01 16:19:01 +01:00
void AnalyzeBackwards();
int GetSymbolNum(unsigned int address, SymbolType symmask=ST_FUNCTION) const;
bool GetSymbolInfo(SymbolInfo *info, u32 address, SymbolType symmask = ST_FUNCTION) const;
u32 GetNextSymbolAddress(u32 address);
const char *GetDescription(unsigned int address) const;
2012-11-01 16:19:01 +01:00
#ifdef _WIN32
void FillSymbolListBox(HWND listbox, SymbolType symmask=ST_FUNCTION) const;
void FillSymbolComboBox(HWND listbox,SymbolType symmask=ST_FUNCTION) const;
void FillListBoxBLinks(HWND listbox, int num) const;
2012-11-01 16:19:01 +01:00
#endif
int GetNumSymbols() const;
const char *GetSymbolName(int i) const;
2012-11-01 16:19:01 +01:00
void SetSymbolName(int i, const char *newname);
void SetSymbolSize(int i, int newSize);
u32 GetSymbolSize(int i) const;
u32 GetSymbolAddr(int i) const;
SymbolType GetSymbolType(int i) const;
int FindSymbol(const char *name) const;
u32 GetAddress(int num) const;
2012-11-01 16:19:01 +01:00
void IncreaseRunCount(int num);
unsigned int GetRunCount(int num) const;
2012-11-01 16:19:01 +01:00
void SortSymbols();
const char* getDirectSymbol(u32 address);
2013-06-29 15:17:00 +02:00
bool getSymbolValue(char* symbol, u32& dest);
2012-11-01 16:19:01 +01:00
void UseFuncSignaturesFile(const char *filename, u32 maxAddress);
void CompileFuncSignaturesFile(const char *filename) const;
2012-11-01 16:19:01 +01:00
private:
struct MapEntryUniqueInfo {
2012-11-01 16:19:01 +01:00
u32 address;
u32 vaddress;
u32 size;
SymbolType type;
2012-11-01 16:19:01 +01:00
bool operator < (const MapEntryUniqueInfo &other) const {
return vaddress < other.vaddress;
}
};
2012-11-01 16:19:01 +01:00
struct MapEntry : public MapEntryUniqueInfo {
char name[128];
u32 unknown;
u32 runCount;
2012-11-01 16:19:01 +01:00
#ifdef BWLINKS
std::vector <u32> backwardLinks;
#endif
void UndecorateName() {
2012-11-01 16:19:01 +01:00
// TODO
}
};
std::set<MapEntryUniqueInfo> uniqueEntries;
std::vector<MapEntry> entries;
std::map<u32, u32> entryRanges;
mutable recursive_mutex lock_;
2012-11-01 16:19:01 +01:00
};
extern SymbolMap symbolMap;