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

nasa / trick / 21039148268

15 Jan 2026 04:46PM UTC coverage: 55.67% (-0.2%) from 55.875%
21039148268

Pull #1965

github

web-flow
Merge b6d3aa7f1 into 36fe2139e
Pull Request #1965: 1964 methods return size one pointers

91 of 128 new or added lines in 3 files covered. (71.09%)

1022 existing lines in 21 files now uncovered.

12573 of 22585 relevant lines covered (55.67%)

299072.13 hits per line

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

93.33
/trick_source/sim_services/MemoryManager/MemoryManager.cpp
1
#include <dlfcn.h>
2
#include <stdlib.h>
3
#include "trick/MemoryManager.hh"
4
#include "trick/ClassicCheckPointAgent.hh"
5
// Global pointer to the (singleton) MemoryManager for the C language interface.
6
Trick::MemoryManager * trick_MM = NULL;
7

8
// CLASS VARIABLE INITIALIZATION
9
int Trick::MemoryManager::instance_count = 0;
10
bool Trick::MemoryManager::restore_stls_default = true;
11

12
// CONSTRUCTOR
13
Trick::MemoryManager::MemoryManager()
639✔
14
{
15

16

17
    // The MemoryManager is a singleton. That is only one instance of it is allowed.
18
    if (instance_count != 0) {
630✔
19
        throw std::logic_error("Only one instance of the Memory Manager is allowed.");
1✔
20
    }
21
    instance_count ++;
629✔
22

23
    debug_level = 0;
629✔
24
    hexfloat_checkpoint = 0;
629✔
25
    reduced_checkpoint  = 1;
629✔
26
    resetting_memory = false;
629✔
27
    expanded_arrays  = 0;
629✔
28
    // start counter at 100mil.  This (hopefully) ensures all alloc'ed ids are after external variables.
29
    alloc_info_map_counter = 100000000 ;
629✔
30
    // start counter at 0.  This forces extern vars to appear in front of actual allocations in checkpoint.
31
    extern_alloc_info_map_counter = 0 ;
629✔
32
    pthread_mutex_init(&mm_mutex, NULL);
629✔
33

34
    defaultCheckPointAgent = new ClassicCheckPointAgent( this);
629✔
35
    defaultCheckPointAgent->set_reduced_checkpoint( reduced_checkpoint);
629✔
36
    defaultCheckPointAgent->set_hexfloat_checkpoint( hexfloat_checkpoint);
629✔
37
    defaultCheckPointAgent->set_hexfloat_decimal_comment_checkpoint( hexfloat_decimal_comment_checkpoint);
629✔
38
    defaultCheckPointAgent->set_debug_level( debug_level);
629✔
39

40
    currentCheckPointAgent = defaultCheckPointAgent;
629✔
41

42
    dlhandles.push_back(dlopen( NULL, RTLD_LAZY)) ;
629✔
43

44
    local_anon_var_prefix = "trick_anon_local_";
629✔
45
    extern_anon_var_prefix = "trick_anon_extern_";
629✔
46

47
    primitive_types.insert(std::string("char")) ;
629✔
48
    primitive_types.insert(std::string("unsigned char")) ;
629✔
49
    primitive_types.insert(std::string("short")) ;
629✔
50
    primitive_types.insert(std::string("unsigned short")) ;
629✔
51
    primitive_types.insert(std::string("int")) ;
629✔
52
    primitive_types.insert(std::string("unsigned int")) ;
629✔
53
    primitive_types.insert(std::string("long")) ;
629✔
54
    primitive_types.insert(std::string("unsigned long")) ;
629✔
55
    primitive_types.insert(std::string("long long")) ;
629✔
56
    primitive_types.insert(std::string("unsigned long long")) ;
629✔
57
    primitive_types.insert(std::string("double")) ;
629✔
58
    primitive_types.insert(std::string("float")) ;
629✔
59
    primitive_types.insert(std::string("bool")) ;
629✔
60
    // add stdint.h types
61
    primitive_types.insert(std::string("int8_t")) ;
629✔
62
    primitive_types.insert(std::string("uint8_t")) ;
629✔
63
    primitive_types.insert(std::string("int16_t")) ;
629✔
64
    primitive_types.insert(std::string("uint16_t")) ;
629✔
65
    primitive_types.insert(std::string("int32_t")) ;
629✔
66
    primitive_types.insert(std::string("uint32_t")) ;
629✔
67
    primitive_types.insert(std::string("int64_t")) ;
629✔
68
    primitive_types.insert(std::string("uint64_t")) ;
629✔
69

70
    trick_MM = this;
629✔
71
    return ;
629✔
72
}
73

74
Trick::MemoryManager::~MemoryManager() {
628✔
75

76
    ALLOC_INFO_MAP::iterator ait ;
628✔
77

78
    if (instance_count > 0) {
628✔
79
        instance_count --;
628✔
80
    }
81

82
    delete defaultCheckPointAgent ;
628✔
83

84
    for ( ait = alloc_info_map.begin() ; ait != alloc_info_map.end() ; ++ait ) {
7,286✔
85
        ALLOC_INFO * ai_ptr = (*ait).second ;
6,658✔
86
        if (ai_ptr->stcl == TRICK_LOCAL) {
6,658✔
87
            if ( ai_ptr->alloc_type == TRICK_ALLOC_MALLOC ) {
1,815✔
88
                free((char *)ai_ptr->start - ai_ptr->sentinel_bytes) ;
1,781✔
89
            } else if ( ai_ptr->alloc_type == TRICK_ALLOC_NEW ) {
34✔
90
                io_src_delete_class( ai_ptr );
34✔
91
            }
92
        }
93
        if (ai_ptr->name) { free(ai_ptr->name); }
6,658✔
94
        if (ai_ptr->user_type_name) { free(ai_ptr->user_type_name); }
6,658✔
95
        free(ai_ptr) ;
6,658✔
96
    }
97
    alloc_info_map.clear() ;
628✔
98
}
628✔
99

100
#include <sstream>
101
void Trick::MemoryManager::emitMessage( std::string message) {
5✔
102
    std::cerr << "MemoryManager:" << message << std::endl;
5✔
103
    std::cerr.flush();
5✔
104
}
5✔
105

106
void Trick::MemoryManager::emitError( std::string message) {
5✔
107
    std::stringstream ss;
5✔
108
    ss << "ERROR:" << message << std::endl;
5✔
109
    emitMessage( ss.str() );
5✔
110
}
5✔
111

112
void Trick::MemoryManager::emitWarning( std::string message) {
×
113
    std::stringstream ss;
×
114
    ss << "WARNING:" << message << std::endl;
×
115
    emitMessage( ss.str() );
×
UNCOV
116
}
×
117

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

© 2026 Coveralls, Inc