2023-01-30 20:03:32 +00:00
|
|
|
#ifndef _DEBUGSYMBOLTABLE_H_
|
|
|
|
#define _DEBUGSYMBOLTABLE_H_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
|
2023-02-01 03:14:49 +00:00
|
|
|
#include "utils/mutex.h"
|
|
|
|
|
2023-02-04 20:15:31 +00:00
|
|
|
class debugSymbolPage_t;
|
|
|
|
class debugSymbolTable_t;
|
2023-01-30 20:03:32 +00:00
|
|
|
|
2023-02-04 20:15:31 +00:00
|
|
|
class debugSymbol_t
|
|
|
|
{
|
|
|
|
public:
|
2023-01-30 20:03:32 +00:00
|
|
|
debugSymbol_t(void)
|
|
|
|
{
|
|
|
|
ofs = 0;
|
|
|
|
};
|
|
|
|
|
2023-02-04 20:15:31 +00:00
|
|
|
debugSymbol_t( int ofs, const char *name = nullptr, const char *comment = nullptr )
|
2023-01-30 20:03:32 +00:00
|
|
|
{
|
|
|
|
this->ofs = ofs;
|
|
|
|
|
2023-02-04 12:25:39 +00:00
|
|
|
if (name)
|
|
|
|
{
|
2023-02-04 20:15:31 +00:00
|
|
|
this->_name.assign(name);
|
2023-02-04 12:25:39 +00:00
|
|
|
}
|
2023-01-30 20:03:32 +00:00
|
|
|
if ( comment )
|
|
|
|
{
|
2023-02-04 20:15:31 +00:00
|
|
|
this->_comment.assign( comment );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string &name(void)
|
|
|
|
{
|
|
|
|
return _name;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string &comment(void)
|
|
|
|
{
|
|
|
|
return _comment;
|
|
|
|
}
|
|
|
|
|
|
|
|
void commentAssign( std::string str )
|
|
|
|
{
|
|
|
|
_comment.assign(str);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void commentAssign( const char *str )
|
|
|
|
{
|
|
|
|
_comment.assign(str);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int offset(void)
|
|
|
|
{
|
|
|
|
return ofs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setOffset( int o )
|
|
|
|
{
|
|
|
|
if (o != ofs)
|
|
|
|
{
|
|
|
|
ofs = o;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void updateName( const char *name, int arrayIndex = -1 )
|
|
|
|
{
|
|
|
|
_name.assign( name );
|
|
|
|
|
|
|
|
trimTrailingSpaces();
|
|
|
|
|
|
|
|
if (arrayIndex >= 0)
|
|
|
|
{
|
|
|
|
char stmp[32];
|
|
|
|
|
|
|
|
sprintf( stmp, "[%i]", arrayIndex );
|
|
|
|
|
|
|
|
_name.append(stmp);
|
2023-01-30 20:03:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void trimTrailingSpaces(void)
|
|
|
|
{
|
2023-02-04 20:15:31 +00:00
|
|
|
while ( _name.size() > 0 )
|
2023-01-30 20:03:32 +00:00
|
|
|
{
|
2023-02-04 20:15:31 +00:00
|
|
|
if ( isspace( _name.back() ) )
|
2023-01-30 20:03:32 +00:00
|
|
|
{
|
2023-02-04 20:15:31 +00:00
|
|
|
_name.pop_back();
|
2023-01-30 20:03:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-02-04 20:15:31 +00:00
|
|
|
while ( _comment.size() > 0 )
|
2023-01-30 20:03:32 +00:00
|
|
|
{
|
2023-02-04 20:15:31 +00:00
|
|
|
if ( isspace( _comment.back() ) )
|
2023-01-30 20:03:32 +00:00
|
|
|
{
|
2023-02-04 20:15:31 +00:00
|
|
|
_comment.pop_back();
|
2023-01-30 20:03:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-02-04 20:15:31 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
int ofs;
|
|
|
|
std::string _name;
|
|
|
|
std::string _comment;
|
|
|
|
|
|
|
|
friend class debugSymbolPage_t;
|
|
|
|
friend class debugSymbolTable_t;
|
2023-01-30 20:03:32 +00:00
|
|
|
};
|
|
|
|
|
2023-02-04 20:15:31 +00:00
|
|
|
class debugSymbolPage_t
|
2023-01-30 20:03:32 +00:00
|
|
|
{
|
2023-02-04 20:15:31 +00:00
|
|
|
public:
|
2023-01-30 20:03:32 +00:00
|
|
|
debugSymbolPage_t(void);
|
|
|
|
~debugSymbolPage_t(void);
|
|
|
|
|
|
|
|
int save(void);
|
|
|
|
void print(void);
|
|
|
|
int size(void){ return symMap.size(); }
|
|
|
|
|
|
|
|
int addSymbol( debugSymbol_t *sym );
|
|
|
|
|
|
|
|
int deleteSymbolAtOffset( int ofs );
|
|
|
|
|
|
|
|
debugSymbol_t *getSymbolAtOffset( int ofs );
|
|
|
|
|
|
|
|
debugSymbol_t *getSymbol( const std::string &name );
|
|
|
|
|
2023-02-04 20:15:31 +00:00
|
|
|
private:
|
|
|
|
int pageNum;
|
2023-01-30 20:03:32 +00:00
|
|
|
std::map <int, debugSymbol_t*> symMap;
|
|
|
|
std::map <std::string, debugSymbol_t*> symNameMap;
|
2023-02-04 20:15:31 +00:00
|
|
|
|
|
|
|
friend class debugSymbolTable_t;
|
2023-01-30 20:03:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class debugSymbolTable_t
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
debugSymbolTable_t(void);
|
|
|
|
~debugSymbolTable_t(void);
|
|
|
|
|
|
|
|
int loadFileNL( int addr );
|
|
|
|
int loadGameSymbols(void);
|
|
|
|
int numPages(void){ return pageMap.size(); }
|
|
|
|
|
|
|
|
void save(void);
|
|
|
|
void clear(void);
|
|
|
|
void print(void);
|
|
|
|
|
|
|
|
debugSymbol_t *getSymbolAtBankOffset( int bank, int ofs );
|
|
|
|
|
|
|
|
debugSymbol_t *getSymbol( int bank, const std::string& name);
|
|
|
|
|
|
|
|
debugSymbol_t *getSymbolAtAnyBank( const std::string& name);
|
|
|
|
|
|
|
|
int addSymbolAtBankOffset( int bank, int ofs, debugSymbol_t *sym );
|
|
|
|
|
2023-02-04 12:25:39 +00:00
|
|
|
int addSymbolAtBankOffset(int bank, int ofs, const char* name, const char* comment = nullptr);
|
|
|
|
|
2023-01-30 20:03:32 +00:00
|
|
|
int deleteSymbolAtBankOffset( int bank, int ofs );
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::map <int, debugSymbolPage_t*> pageMap;
|
2023-02-01 03:14:49 +00:00
|
|
|
FCEU::mutex *cs;
|
2023-01-30 20:03:32 +00:00
|
|
|
|
|
|
|
int loadRegisterMap(void);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
extern debugSymbolTable_t debugSymbolTable;
|
|
|
|
|
|
|
|
#endif
|