• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nasa / trick / 44797905565

20 Nov 2026 06:59PM UTC coverage: 57.215% (+0.2%) from 57.009%
44797905565

push

github

web-flow
feat: Add TMM/MM calls for determining whether any errors while writing a checkpoint (#2278)

108 of 168 new or added lines in 8 files covered. (64.29%)

15 existing lines in 5 files now uncovered.

15134 of 26451 relevant lines covered (57.22%)

470620.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.7
/trick_source/sim_services/MemoryManager/MemoryManager_alloc_depends.cpp
1
#include "trick/MemoryManager.hh"
2
#include "trick/attributes.h"
3

4
// MEMBER FUNCTION
5
void Trick::MemoryManager::get_alloc_deps_in_allocation(ALLOC_INFO* alloc_info ) {
303 ✔
6

7
    ATTRIBUTES* reference_attr;
8

9
    bool found = false;
303 ✔
10
    int n_depends = dependencies.size();
303 ✔
11

12
    if (debug_level > 1) {
303 ✔
13
          std::cout << "DEBUG: Entered function:" <<  __FUNCTION__ << std::endl;
×
14
    }
15

16
    if (alloc_info == NULL) {
303 ✔
17
        std::cerr << "ERROR: Trick::MemoryManager::get_alloc_deps_in_allocation called with alloc_info == NULL." << std::endl;
×
NEW
18
        report_checkpoint_write_error();
×
19
        std::cout.flush();
×
20
        return;
×
21
    }
22

23
    if (debug_level > 1) {
303 ✔
24
        debug_write_alloc_info(alloc_info);
×
25
    }
26

27
    if (debug_level) {
303 ✔
28
        std::cout << __FUNCTION__ << ": Allocation @" << (void*)alloc_info->start ;
×
29
        if (alloc_info->name != NULL) {
×
30
            std::cout << " is named \"" << alloc_info->name << "\"." << std::endl;
×
31
        } else {
32
            std::cout << " is anonymous." << std::endl;
×
33
        }
34
    }
35

36
    std::cout.flush();
303 ✔
37

38
    for (int ii = 0 ; ii < n_depends ; ii ++) {
408 ✔
39
        if (alloc_info == dependencies[ii]) {
107 ✔
40
            found = true;
2 ✔
41
            if (debug_level) {
2 ✔
42
                std::cout << __FUNCTION__ << ": Dependencies of allocation @"<< (void*)alloc_info->start <<" are already known." << std::endl;
×
43
            }
44
            return;
2 ✔
45
        }
46
    }
47

48
    if (!found) {
301 ✔
49

50
        if (debug_level) {
301 ✔
51
            std::cout << __FUNCTION__ <<  ": Begin scan of allocation @" << (void*)alloc_info->start << " for dependencies." << std::endl;
×
52
        }
53

54
        // The allocation is dependent upon itself.
55
        dependencies.push_back(alloc_info);
301 ✔
56

57
        reference_attr = make_reference_attr( alloc_info);
301 ✔
58

59
        // Get the dependencies of the allocation
60
        if (alloc_info->type == TRICK_STRUCTURED) {
301 ✔
61
            if (reference_attr->num_index > 0) {
41 ✔
62
                get_alloc_deps_in_arrayed_class( (char*)(alloc_info->start), reference_attr, 0, 0) ;
10 ✔
63
            } else {
64
                get_alloc_deps_in_class( (char*)(alloc_info->start), alloc_info->attr) ;
31 ✔
65
            }
66
        } else {
67
            get_alloc_deps_in_intrinsic( alloc_info->start, reference_attr, 0, 0 );
260 ✔
68
        }
69

70
        if (debug_level) {
301 ✔
71
            std::cout <<  __FUNCTION__ << ": End scan of allocation @" << (void*)alloc_info->start << "." << std::endl;
×
72
        }
73

74
        free_reference_attr( reference_attr);
301 ✔
75
    }
76

77
}
78

79
// MEMBER FUNCTION
80
void Trick::MemoryManager::get_alloc_deps_in_allocation( const char* var_name ) {
258 ✔
81

82
    VARIABLE_MAP::iterator pos;
258 ✔
83
    ALLOC_INFO *alloc_info;
84

85
    if (debug_level > 1) {
258 ✔
86
          std::cout << "DEBUG: Entered function:" <<  __FUNCTION__ << std::endl;
×
87
    }
88

89
    pos = variable_map.find( var_name);
516 ✔
90

91
    if (pos != variable_map.end()) {
258 ✔
92
        alloc_info = pos->second;
257 ✔
93
        get_alloc_deps_in_allocation( alloc_info );
257 ✔
94
    } else {
95
        std::cerr << "ERROR: get_alloc_deps_in_allocation(\""<< var_name
96
                  <<"\") failed because the given name is'nt known by the MemoryManager."
1 ✔
97
                  << std::endl;
1 ✔
98
        std::cerr.flush();
1 ✔
99
        report_checkpoint_write_error();
1 ✔
100
    }
101
}
258 ✔
102

103

104
// MEMBER FUNCTION
105
void Trick::MemoryManager::get_alloc_deps_in_class( char* address, ATTRIBUTES* attr) {
54 ✔
106
    int ii;
107

108
    if (debug_level > 1) {
54 ✔
109
          std::cout << "DEBUG: Entered function:" <<  __FUNCTION__ << std::endl;
×
110
    }
111

112
    if (attr == NULL) {
54 ✔
113
        std::cerr << "ERROR: Trick::MemoryManager::get_alloc_deps_in_class called with attr = NULL." << std::endl;
×
NEW
114
        report_checkpoint_write_error();
×
UNCOV
115
        return;
×
116
    }
117

118
    for (ii = 0; attr[ii].name[0] != '\0'; ii++) {
216 ✔
119
        if (currentCheckPointAgent->output_perm_check(&attr[ii])) {
162 ✔
120
            char *elem_addr;
121
            if (attr[ii].mods & 2) {
158 ✔
122
                elem_addr = (char *) attr[ii].offset;
×
123
            } else {
124
                elem_addr = address + attr[ii].offset;
158 ✔
125
            }
126

127
            if (attr[ii].type == TRICK_STRUCTURED) {
158 ✔
128
                if (attr[ii].num_index != 0) {
35 ✔
129
                    get_alloc_deps_in_arrayed_class( elem_addr, &attr[ii], 0, 0);
35 ✔
130
                } else {
131
                    get_alloc_deps_in_class( elem_addr, (ATTRIBUTES*)(attr[ii].attr));
×
132
                }
133
            } else {
134
                get_alloc_deps_in_intrinsic( elem_addr, &(attr[ii]), 0, 0);
123 ✔
135
            }
136
        }
137
    }
138
}
139

140
// MEMBER FUNCTION
141
void Trick::MemoryManager::get_alloc_deps_in_arrayed_class(
50 ✔
142
                                                char*       address,
143
                                                ATTRIBUTES* attr,
144
                                                int         curr_dim,
145
                                                int         offset) {
146
    int ii;
147

148
    if (debug_level > 1) {
50 ✔
149
          std::cout << "DEBUG: Entered function:" <<  __FUNCTION__ << std::endl;
×
150
    }
151

152
    if (attr == NULL) {
50 ✔
153
        std::cerr << "Trick::MemoryManager::get_alloc_deps_in_arrayed_class: ERROR: attr = NULL." << std::endl;
×
NEW
154
        report_checkpoint_write_error();
×
UNCOV
155
        return;
×
156
    }
157

158
    if (attr->index[curr_dim].size == 0) {
50 ✔
159

160
        void* pointer = *(void**)((char*)address + offset * sizeof(void*));
40 ✔
161

162
        if (pointer != NULL) {
40 ✔
163
            ALLOC_INFO *alloc_info;
164
            alloc_info = get_alloc_info_of( pointer);
18 ✔
165
            if (alloc_info != NULL) {
18 ✔
166

167
                if (debug_level) {
18 ✔
168
                    std::cout << __FUNCTION__ << ": @" << (void*)address << "." << attr->name << "[" << offset << "] points to @" << (void*)pointer << std::endl;
×
169
                }
170
                get_alloc_deps_in_allocation(alloc_info);
18 ✔
171
            } else {
172
                if (debug_level) {
×
173
                    std::cout << __FUNCTION__ << ": Pointer ("<< (void*)pointer <<") refers to memory that the MemoryManager doesn't know about." << std::endl;
×
174
                    std::cout.flush();
×
175
                }
176
            }
177
        } else {
178
            if (debug_level) {
22 ✔
179
                std::cout << __FUNCTION__ << ": Allocation reference is NULL." << std::endl;
×
180
                std::cout.flush();
×
181
            }
182
        }
183

184
    } else {
185
        int curr_dim_size;
186
        curr_dim_size = attr->index[curr_dim].size;
10 ✔
187
        for (ii = 0; ii < curr_dim_size; ii++) {
38 ✔
188
            if (curr_dim < attr->num_index - 1) {
28 ✔
189
                get_alloc_deps_in_arrayed_class( address, attr, curr_dim + 1, offset * curr_dim_size + ii);
5 ✔
190
            } else {
191
                char* elem_addr;
192
                elem_addr = address + (offset * curr_dim + ii) * attr->size ;
23 ✔
193
                get_alloc_deps_in_class( elem_addr, (ATTRIBUTES*)attr->attr );
23 ✔
194
            }
195
        }
196
    }
197
}
198

199

200
// MEMBER FUNCTION
201
void Trick::MemoryManager::get_alloc_deps_in_intrinsic( void* address, ATTRIBUTES* attr, int curr_dim, int offset) {
1,752 ✔
202

203
    if (debug_level > 1) {
1,752 ✔
204
          std::cout << "DEBUG: Entered function:" <<  __FUNCTION__ << std::endl;
×
205
    }
206

207
    // If the variable that we are pointing to is an arrayed
208
    if (curr_dim < attr->num_index) {
1,752 ✔
209

210
        // If it is an unconstrained array (a pointer)
211
        if (attr->index[curr_dim].size == 0) {
356 ✔
212

213
            void* pointer = *(void**)((char*)address + offset * sizeof(void*));
74 ✔
214

215
            if (pointer != NULL) {
74 ✔
216
                ALLOC_INFO *alloc_info;
217
                alloc_info = get_alloc_info_of( pointer);
30 ✔
218
                if (alloc_info != NULL) {
30 ✔
219
                    if (debug_level) {
28 ✔
220
                        std::cout << __FUNCTION__ <<  ": @" << (void*)address << "." << attr->name << "[" << offset << "] points to @" << (void*)pointer << std::endl;
×
221
                    }
222
                    get_alloc_deps_in_allocation(alloc_info);
28 ✔
223
                } else {
224
                    if (debug_level) {
2 ✔
225
                        std::cout << __FUNCTION__ <<  ": Pointer ("<< (void*)pointer <<") refers to memory that the MemoryManager doesn't know about." << std::endl;
×
226
                        std::cout.flush();
×
227
                    }
228
                }
229
            } else {
230
                if (debug_level) {
44 ✔
231
                    std::cout << __FUNCTION__ <<  ": Allocation reference is NULL." << std::endl;
×
232
                    std::cout.flush();
×
233
                }
234
            }
235

236
        } else { // otherwise its a constrained array.
237
            int ii;
238
            for (ii=0 ; ii< attr->index[curr_dim].size ; ii++) {
1,651 ✔
239
                get_alloc_deps_in_intrinsic( address, attr, curr_dim + 1, offset * attr->index[curr_dim].size + ii);
1,369 ✔
240
            }
241
        }
242
    }
243
}
1,752 ✔
244

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc