asar coverage - build #


src/asar/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
26 of 26, 0 excluded
100.0%
Functions:
3 of 3, 0 excluded
100.0%
Branches:
23 of 49, 0 excluded
46.9%

addr2line.cpp
Line Branch Exec Source
1 #include "addr2line.h"
2 #include "crc32.h"
3
4 //////////////////////////////////////////////////////////////////////////
5 // Class to store address-to-line mappings for richer symbolic information
6 //
7 // During assembly, included files and information about generated asm
8 // should be added to this, and then read back during symbol file
9 // generation
10
11 859 void AddressToLineMapping::reset()
12 {
13 859 m_fileList.reset();
14 859 m_file_indices_map.clear();
15 859 m_addrToLineInfo.reset();
16 859 }
17
18 // Adds information of what source file and line number an output rom address is at
19 5534 void AddressToLineMapping::includeMapping(const char* filename, int line, int addr)
20 {
21 2782 AddrToLineInfo newInfo;
22
2/4
✓ Branch 2 → 3 taken 2752 times.
✗ Branch 2 → 5 not taken.
✓ Branch 4 → 5 taken 2782 times.
✗ Branch 4 → 11 not taken.
5534 newInfo.fileIdx = getFileIndex(filename);
23 5534 newInfo.line = line;
24 5534 newInfo.addr = addr;
25
26
2/4
✓ Branch 3 → 4 taken 2752 times.
✗ Branch 3 → 5 not taken.
✓ Branch 8 → 9 taken 2782 times.
✗ Branch 8 → 11 not taken.
5534 m_addrToLineInfo.append(newInfo);
27 5534 }
28
29 // Helper to add file to list, and get the index of that file
30 5534 int AddressToLineMapping::getFileIndex(const char* filename)
31 {
32 // check if the file exists first
33
7/11
✓ Branch 2 → 3 taken 2752 times.
✗ Branch 2 → 24 not taken.
✓ Branch 3 → 4 taken 2752 times.
✗ Branch 3 → 22 not taken.
✓ Branch 7 → 8 taken 5433 times.
✓ Branch 7 → 10 taken 101 times.
✗ Branch 7 → 55 not taken.
✓ Branch 9 → 10 taken 2782 times.
✗ Branch 9 → 53 not taken.
✓ Branch 20 → 21 taken 2660 times.
✓ Branch 20 → 25 taken 122 times.
5534 if(auto it = m_file_indices_map.find(filename); it != m_file_indices_map.end()) {
34 5311 return it->second;
35 }
36
37 // file doesn't exist, so start tracking it
38 223 char* data = nullptr;
39 223 int len = 0;
40 223 uint32_t fileCrc = 0;
41
4/9
✓ Branch 10 → 12 taken 101 times.
✗ Branch 10 → 32 not taken.
✗ Branch 10 → 33 not taken.
✓ Branch 12 → 13 taken 101 times.
✗ Branch 12 → 15 not taken.
✓ Branch 30 → 31 taken 122 times.
✗ Branch 30 → 66 not taken.
✓ Branch 31 → 32 taken 122 times.
✗ Branch 31 → 34 not taken.
223 if (readfile(filename, "", &data, &len))
42 {
43
2/5
✓ Branch 13 → 14 taken 101 times.
✗ Branch 13 → 32 not taken.
✗ Branch 13 → 33 not taken.
✓ Branch 32 → 33 taken 122 times.
✗ Branch 32 → 66 not taken.
223 fileCrc = crc32((const uint8_t*)data, (unsigned int)len);
44 }
45 223 free(data);
46
47 223 int result = m_fileList.count;
48
1/2
✓ Branch 41 → 42 taken 122 times.
✗ Branch 41 → 59 not taken.
345 m_fileList.append({ string(filename), fileCrc });
49
2/4
✓ Branch 18 → 19 taken 101 times.
✗ Branch 18 → 32 not taken.
✓ Branch 47 → 48 taken 122 times.
✗ Branch 47 → 66 not taken.
223 m_file_indices_map.emplace(filename, result);
50
51 223 return result;
52
3/10
✓ Branch 15 → 16 taken 101 times.
✗ Branch 15 → 31 not taken.
✓ Branch 16 → 17 taken 101 times.
✗ Branch 16 → 26 not taken.
✗ Branch 28 → 29 not taken.
✗ Branch 28 → 30 not taken.
✓ Branch 39 → 40 taken 122 times.
✗ Branch 39 → 64 not taken.
✗ Branch 61 → 62 not taken.
✗ Branch 61 → 63 not taken.
223 }
53