2020-04-01 23:02:42 +00:00
|
|
|
#ifndef __TRACYSOURCEVIEW_HPP__
|
|
|
|
#define __TRACYSOURCEVIEW_HPP__
|
|
|
|
|
2020-03-25 21:37:34 +00:00
|
|
|
#include <string>
|
2020-03-22 19:53:59 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2020-04-04 00:25:12 +00:00
|
|
|
#include "tracy_robin_hood.h"
|
2020-03-28 00:22:27 +00:00
|
|
|
#include "TracyDecayValue.hpp"
|
|
|
|
|
2020-03-22 19:53:59 +00:00
|
|
|
struct ImFont;
|
|
|
|
|
|
|
|
namespace tracy
|
|
|
|
{
|
|
|
|
|
2020-03-25 00:09:02 +00:00
|
|
|
class Worker;
|
|
|
|
|
2020-03-22 19:53:59 +00:00
|
|
|
class SourceView
|
|
|
|
{
|
|
|
|
struct Line
|
|
|
|
{
|
|
|
|
const char* begin;
|
|
|
|
const char* end;
|
|
|
|
};
|
|
|
|
|
2020-03-25 21:37:34 +00:00
|
|
|
struct AsmLine
|
|
|
|
{
|
|
|
|
uint64_t addr;
|
2020-03-27 23:53:48 +00:00
|
|
|
uint64_t jumpAddr;
|
2020-03-25 21:37:34 +00:00
|
|
|
std::string mnemonic;
|
|
|
|
std::string operands;
|
|
|
|
};
|
|
|
|
|
2020-04-04 00:25:12 +00:00
|
|
|
struct JumpData
|
|
|
|
{
|
|
|
|
uint64_t min;
|
|
|
|
uint64_t max;
|
|
|
|
int level;
|
|
|
|
std::vector<uint64_t> source;
|
|
|
|
};
|
|
|
|
|
2020-04-08 20:04:00 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
DisplaySource,
|
|
|
|
DisplayAsm,
|
|
|
|
DisplayMixed
|
|
|
|
};
|
|
|
|
|
2020-03-22 19:53:59 +00:00
|
|
|
public:
|
|
|
|
SourceView( ImFont* font );
|
|
|
|
~SourceView();
|
|
|
|
|
2020-04-08 00:11:58 +00:00
|
|
|
void OpenSource( const char* fileName, int line );
|
|
|
|
void OpenSymbol( const char* fileName, int line, uint64_t baseAddr, uint64_t symAddr, const Worker& worker );
|
2020-03-25 00:09:02 +00:00
|
|
|
void Render( const Worker& worker );
|
2020-03-22 19:53:59 +00:00
|
|
|
|
|
|
|
private:
|
2020-04-08 00:11:58 +00:00
|
|
|
void ParseSource( const char* fileName, const Worker* worker );
|
|
|
|
bool Disassemble( uint64_t symAddr, const Worker& worker );
|
|
|
|
|
2020-04-07 23:58:23 +00:00
|
|
|
void RenderSimpleSourceView();
|
|
|
|
void RenderSymbolView( const Worker& worker );
|
|
|
|
|
2020-04-08 20:04:00 +00:00
|
|
|
void RenderSymbolSourceView( uint32_t iptotal, unordered_flat_map<uint64_t, uint32_t> ipcount, const Worker& worker );
|
|
|
|
uint64_t RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<uint64_t, uint32_t> ipcount, const Worker& worker );
|
|
|
|
|
2020-04-07 23:58:23 +00:00
|
|
|
void RenderLine( const Line& line, int lineNum, uint32_t ipcnt, uint32_t iptotal, const Worker* worker );
|
2020-04-08 23:31:27 +00:00
|
|
|
void RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t iptotal, const Worker& worker, uint64_t& jumpOut, int maxAddrLen );
|
2020-03-25 21:53:05 +00:00
|
|
|
|
2020-04-08 21:30:42 +00:00
|
|
|
void SelectLine( uint32_t line, const Worker* worker, bool changeAsmLine = true, uint64_t targetAddr = 0 );
|
2020-04-08 21:59:10 +00:00
|
|
|
void SelectAsmLines( uint32_t file, uint32_t line, const Worker& worker, bool changeAsmLine = true, uint64_t targetAddr = 0 );
|
2020-04-08 20:57:42 +00:00
|
|
|
|
2020-03-22 19:53:59 +00:00
|
|
|
ImFont* m_font;
|
|
|
|
const char* m_file;
|
2020-04-02 00:15:10 +00:00
|
|
|
uint32_t m_fileStringIdx;
|
2020-03-24 23:07:31 +00:00
|
|
|
uint64_t m_symAddr;
|
2020-03-27 23:57:41 +00:00
|
|
|
uint64_t m_baseAddr;
|
2020-03-25 21:53:05 +00:00
|
|
|
uint64_t m_targetAddr;
|
2020-03-22 19:53:59 +00:00
|
|
|
char* m_data;
|
|
|
|
size_t m_dataSize;
|
|
|
|
int m_targetLine;
|
|
|
|
int m_selectedLine;
|
2020-04-08 20:04:00 +00:00
|
|
|
int m_displayMode;
|
2020-03-26 01:23:09 +00:00
|
|
|
uint32_t m_codeLen;
|
2020-03-28 00:22:27 +00:00
|
|
|
DecayValue<uint64_t> m_highlightAddr;
|
2020-03-28 13:33:35 +00:00
|
|
|
bool m_asmRelative;
|
2020-04-01 23:37:56 +00:00
|
|
|
bool m_asmShowSourceLocation;
|
2020-03-22 19:53:59 +00:00
|
|
|
|
|
|
|
std::vector<Line> m_lines;
|
2020-03-25 21:37:34 +00:00
|
|
|
std::vector<AsmLine> m_asm;
|
2020-04-04 00:25:12 +00:00
|
|
|
|
|
|
|
unordered_flat_map<uint64_t, JumpData> m_jumpTable;
|
2020-04-04 11:51:55 +00:00
|
|
|
unordered_flat_set<uint64_t> m_jumpOut;
|
2020-04-04 00:25:12 +00:00
|
|
|
int m_maxJumpLevel;
|
2020-04-04 01:34:54 +00:00
|
|
|
bool m_showJumps;
|
2020-04-08 20:18:00 +00:00
|
|
|
|
2020-04-08 20:25:36 +00:00
|
|
|
unordered_flat_map<uint32_t, uint32_t> m_sourceFiles;
|
2020-04-08 20:57:42 +00:00
|
|
|
unordered_flat_set<uint64_t> m_selectedAddresses;
|
2020-04-08 23:45:38 +00:00
|
|
|
|
2020-04-08 23:52:22 +00:00
|
|
|
uint32_t m_maxLine;
|
2020-04-08 23:45:38 +00:00
|
|
|
int m_maxMnemonicLen;
|
2020-03-22 19:53:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2020-04-01 23:02:42 +00:00
|
|
|
|
|
|
|
#endif
|