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

nasa / trick / 8457600858

27 Mar 2024 07:32PM UTC coverage: 55.855% (-0.06%) from 55.91%
8457600858

push

github

web-flow
Bump express from 4.18.2 to 4.19.2 in /trick_source/web/dashboard (#1678)

Bumps [express](https://github.com/expressjs/express) from 4.18.2 to 4.19.2.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.18.2...4.19.2)

---
updated-dependencies:
- dependency-name: express
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

12253 of 21937 relevant lines covered (55.86%)

84774.22 hits per line

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

59.02
/trick_source/sim_services/MemoryManager/MemoryManager_delete_var.cpp
1
#include <stdlib.h>
2
#include <iostream>
3

4
#include <sstream>
5
#include <algorithm>
6
#include <dlfcn.h>
7
#include "trick/MemoryManager.hh"
8

9
// MEMBER FUNCTION
10
int Trick::MemoryManager::delete_var(void* address ) {
5,053✔
11

12
    if (address == 0) {
5,053✔
13
        if (debug_level) {
×
14
            std::stringstream message;
×
15
            message << "Cannot delete memory at NULL.";
×
16
            emitWarning(message.str());
×
17
        }
18
        return 1;
×
19
    }
20

21
    // Find the allocation record for this address.
22
    ALLOC_INFO * alloc_info = get_alloc_info_at( address);
5,053✔
23

24
    if ((alloc_info != NULL)) {
5,053✔
25
        /*
26
           Remove the allocation from the map first so we don't have trouble
27
           if io_src_destruct_class or io_src_delete_class calls delete_var recursively.
28
         */
29
        // BEGIN PROTECTION of the alloc_info_map.
30
        pthread_mutex_lock(&mm_mutex);
5,053✔
31
        alloc_info_map.erase( address);
5,053✔
32
        // END PROTECTION of the alloc_info_map.
33
        pthread_mutex_unlock(&mm_mutex);
5,053✔
34

35
        /* Verify that it's OK to free the memory at the given address.
36
           It's OK if an allocation record exists for this address and the
37
           MemoryManager allocated it.
38
         */
39
        if ( alloc_info->stcl == TRICK_LOCAL ) {
5,053✔
40
            if ( alloc_info->alloc_type == TRICK_ALLOC_MALLOC ) {
5,047✔
41

42
                // This will call a destructor ONLY if alloc_info->type is TRICK_STRUCTURED.
43
                // Otherwise it does nothing.
44
                io_src_destruct_class( alloc_info );
3,528✔
45

46
                // The destructor that we just called MAY have deleted addresses
47
                // that are already planned for deletion, say during reset_memory.
48
                // So, keep a record of what we've recently deleted so we don't
49
                // to warn that we can't find it, when reset_memory also tries to
50
                // delete that same address.
51
                deleted_addr_list.push_back(address);
3,528✔
52

53
                free( address);
3,528✔
54
            } else if ( alloc_info->alloc_type == TRICK_ALLOC_NEW ) {
1,519✔
55
                io_src_delete_class( alloc_info );
7✔
56
            }
57
        }
58

59
        if (debug_level) {
5,053✔
60
            std::cout << "Deleted allocation at address " << alloc_info->start << "." << std::endl;
×
61
            std::cout.flush();
×
62
        }
63

64
        if (alloc_info->name ) {
5,053✔
65
            pthread_mutex_lock(&mm_mutex);
3,745✔
66
            variable_map.erase( alloc_info->name);
3,745✔
67
            pthread_mutex_unlock(&mm_mutex);
3,745✔
68
            free(alloc_info->name);
3,745✔
69
        }
70

71
        if ( alloc_info->user_type_name ) {
5,053✔
72
            free(alloc_info->user_type_name);
219✔
73
        }
74

75
        // Delete the alloc_info record.
76
        free(alloc_info);
5,053✔
77

78
    } else {
79

80
        // The allocation (address) we're tring to delete may have just been
81
        // deleted by a user's destructor (using delete_var). Check the deleted_addr_list
82
        // to see if the allocation was just deleted. If it was, then there's no
83
        // problem. If it wasn't, then the MemoryManager never knew about it, and
84
        // this call to delete_var() is a problem.
85

86
        if ( resetting_memory == true) {
×
87
            // Check the deleted_addr_list to see whether we recently deleted this address.
88
            std::list<void*>::iterator iter =
89
                std::find( deleted_addr_list.begin(), deleted_addr_list.end(), address );
×
90
            // If we didn't recently delete it, then there's a problem.
91
            if ( iter == deleted_addr_list.end() ) {
×
92
                std::stringstream message;
×
93
                message << "The MemoryManager cannot delete memory at address ["
×
94
                        << address << "] because it has no record of it. Furthermore,"
×
95
                        << " the MemoryManager has not recently deleted it while"
96
                        << " resetting memory for a checkpoint reload.";
×
97
                emitWarning(message.str());
×
98
            }
99
        } else {
100
            std::stringstream message;
×
101
            message << "The MemoryManager cannot delete memory at address ["
×
102
                    << address << "] because it has no record of it.";
×
103
            emitWarning(message.str());
×
104
        }
105

106
        return 1 ;
×
107
    }
108

109
    return 0;
5,053✔
110
}
111

112
// MEMBER FUNCTION
113
int Trick::MemoryManager::delete_var( const char* name) {
1,819✔
114

115
    VARIABLE_MAP::iterator pos;
1,819✔
116
    ALLOC_INFO *alloc_info;
117

118
    pthread_mutex_lock(&mm_mutex);
1,819✔
119
    pos = variable_map.find( name);
1,819✔
120

121
    if (pos != variable_map.end()) {
1,819✔
122
        alloc_info = pos->second;
1,819✔
123

124
        pthread_mutex_unlock(&mm_mutex);
1,819✔
125
        return( delete_var( alloc_info->start));
1,819✔
126
    } else {
127
        std::stringstream message;
×
128
        message << "Cannot delete variable \"" << name
129
                << "\" because it doesn't exist." ;
×
130
        emitError(message.str());
×
131
    }
132
    pthread_mutex_unlock(&mm_mutex);
×
133
    return 1;
×
134
}
135

136
// MEMBER FUNCTION
137
int Trick::MemoryManager::delete_extern_var( void* address) {
1✔
138
    // delete_var will remove the external variable from the allocation map
139
    return delete_var(address) ;
1✔
140
}
141

142
// MEMBER FUNCTION
143
int Trick::MemoryManager::delete_extern_var( const char* name) {
1✔
144
    // delete_var will remove the external variable from the allocation map
145
    return delete_var(name) ;
1✔
146
}
147

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

© 2025 Coveralls, Inc