Line |
Branch |
Exec |
Source |
1 |
|
|
#pragma once |
2 |
|
|
|
3 |
|
|
////////////////////////////////////////////////////////////////////////// |
4 |
|
|
// Class to store address-to-line mappings for richer symbolic information |
5 |
|
|
// |
6 |
|
|
// During assembly, included files and information about generated asm |
7 |
|
|
// should be added to this, and then read back during symbol file |
8 |
|
|
// generation |
9 |
|
|
|
10 |
|
|
#include "autoarray.h" |
11 |
|
|
#include "libstr.h" |
12 |
|
|
#include <unordered_map> |
13 |
|
|
|
14 |
|
|
class AddressToLineMapping |
15 |
|
|
{ |
16 |
|
|
public: |
17 |
|
|
|
18 |
|
|
struct AddrToLineInfo |
19 |
|
|
{ |
20 |
|
|
int fileIdx; |
21 |
|
|
int line; |
22 |
|
|
int addr; |
23 |
|
|
}; |
24 |
|
|
|
25 |
|
|
// resets the mapping to initial state |
26 |
|
|
void reset(); |
27 |
|
|
|
28 |
|
|
// Adds information of what source file and line number an output rom address is at |
29 |
|
|
void includeMapping(const char* filename, int line, int addr); |
30 |
|
|
|
31 |
|
|
struct FileInfo |
32 |
|
|
{ |
33 |
|
|
string filename; |
34 |
|
|
uint32_t fileCrc; |
35 |
|
|
}; |
36 |
|
2 |
const autoarray<FileInfo>& getFileList() const { return m_fileList; } |
37 |
|
2 |
const autoarray<AddrToLineInfo>& getAddrToLineInfo() const { return m_addrToLineInfo; } |
38 |
|
|
|
39 |
|
|
private: |
40 |
|
|
|
41 |
|
|
// Helper to add file to list, and get the index of that file |
42 |
|
|
int getFileIndex(const char* filename); |
43 |
|
|
|
44 |
|
|
autoarray<FileInfo> m_fileList; |
45 |
|
|
std::unordered_map<string, int> m_file_indices_map; |
46 |
|
|
|
47 |
|
|
|
48 |
|
|
autoarray<AddrToLineInfo> m_addrToLineInfo; |
49 |
|
|
}; |
50 |
|
|
|
51 |
|
|
extern AddressToLineMapping addressToLineMapping; |
52 |
|
|
|