mirror of
https://github.com/nasa/trick.git
synced 2025-01-29 15:43:57 +00:00
commit
f5334e07d7
@ -638,6 +638,9 @@ namespace Trick {
|
||||
VARIABLE_MAP_ITER variable_map_end() { return variable_map.end() ; } ;
|
||||
|
||||
int debug_level; /**< -- Debug level */
|
||||
static void emitMessage( std::string s);
|
||||
static void emitError( std::string s);
|
||||
static void emitWarning( std::string s);
|
||||
|
||||
private:
|
||||
|
||||
@ -659,6 +662,7 @@ namespace Trick {
|
||||
int alloc_info_map_counter ; /**< ** counter to assign unique ids to allocations as they are added to map */
|
||||
int extern_alloc_info_map_counter ; /**< ** counter to assign unique ids to allocations as they are added to map */
|
||||
|
||||
|
||||
void write_checkpoint( std::ostream& out_s, std::vector<ALLOC_INFO*>& dependencies);
|
||||
|
||||
/**
|
||||
|
@ -94,3 +94,22 @@ Trick::MemoryManager::~MemoryManager() {
|
||||
}
|
||||
alloc_info_map.clear() ;
|
||||
}
|
||||
|
||||
#include <sstream>
|
||||
void Trick::MemoryManager::emitMessage( std::string message) {
|
||||
std::cerr << "MemoryManager:" << message << std::endl;
|
||||
std::cerr.flush();
|
||||
}
|
||||
|
||||
void Trick::MemoryManager::emitError( std::string message) {
|
||||
std::stringstream ss;
|
||||
ss << "ERROR:" << message << std::endl;
|
||||
emitMessage( ss.str() );
|
||||
}
|
||||
|
||||
void Trick::MemoryManager::emitWarning( std::string message) {
|
||||
std::stringstream ss;
|
||||
ss << "WARNING:" << message << std::endl;
|
||||
emitMessage( ss.str() );
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
#include <iostream>
|
||||
#include "sim_services/MemoryManager/include/memorymanager_c_intf.h"
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
|
||||
/* Global singleton pointer to the memory manager. */
|
||||
extern Trick::MemoryManager* trick_MM;
|
||||
@ -19,7 +17,7 @@ extern "C" void* TMM_declare_var( TRICK_TYPE type, const char*class_name, int n_
|
||||
std::string svar_name = var_name;
|
||||
return ( trick_MM->declare_var( type, sclass_name, n_stars, svar_name, n_cdims, cdims));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_declare_var() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_declare_var() called before MemoryManager instantiation. Returning NULL.") ;
|
||||
return ( (void*)NULL);
|
||||
}
|
||||
}
|
||||
@ -33,7 +31,7 @@ extern "C" void* TMM_declare_var_1d( const char* enh_type_spec, int e_elems) {
|
||||
if (trick_MM != NULL) {
|
||||
return ( trick_MM->declare_var( enh_type_spec, e_elems));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_declare_var_1d() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_declare_var_1d() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
return ( (void*)NULL);
|
||||
}
|
||||
}
|
||||
@ -47,7 +45,7 @@ extern "C" void* TMM_declare_var_s( const char* declaration) {
|
||||
if (trick_MM != NULL) {
|
||||
return ( trick_MM->declare_var( declaration));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_declare_var_s() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_declare_var_s() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
return ( (void*)NULL);
|
||||
}
|
||||
}
|
||||
@ -63,7 +61,7 @@ extern "C" void* alloc_type( int e_elems, const char* enh_type_spec) {
|
||||
if (trick_MM != NULL) {
|
||||
return ( trick_MM->declare_var( enh_type_spec, e_elems));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: alloc_type() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
Trick::MemoryManager::emitError("alloc_type() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
return ( (void*)NULL);
|
||||
}
|
||||
}
|
||||
@ -77,7 +75,7 @@ extern "C" void* TMM_declare_operatornew_var( const char * class_name, unsigned
|
||||
if (trick_MM != NULL) {
|
||||
return trick_MM->declare_operatornew_var( std::string(class_name), alloc_size, element_size ) ;
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_declare_var() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_declare_var() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
return (void*)NULL ;
|
||||
}
|
||||
}
|
||||
@ -93,7 +91,7 @@ extern "C" void* TMM_declare_ext_var( void* addr, TRICK_TYPE type, const char*cl
|
||||
std::string svar_name = var_name;
|
||||
return ( trick_MM->declare_extern_var( addr, type, sclass_name, n_stars, svar_name, n_cdims, cdims));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_declare_ext_var() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_declare_ext_var() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
return ( (void*)NULL);
|
||||
}
|
||||
}
|
||||
@ -107,7 +105,7 @@ extern "C" void* TMM_declare_ext_var_1d( void* addr, const char* elem_decl, int
|
||||
if (trick_MM != NULL) {
|
||||
return ( trick_MM->declare_extern_var( addr, elem_decl, n_elems));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_declare_ext_var_1d() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_declare_ext_var_1d() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
return ( (void*)NULL);
|
||||
}
|
||||
}
|
||||
@ -121,7 +119,7 @@ extern "C" void* TMM_declare_ext_var_s( void* addr, const char* declaration) {
|
||||
if (trick_MM != NULL) {
|
||||
return ( trick_MM->declare_extern_var(addr, declaration));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_declare_ext_var_s() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_declare_ext_var_s() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
return ( (void*)NULL);
|
||||
}
|
||||
}
|
||||
@ -137,7 +135,7 @@ void* TMM_resize_array_a(void *address, int n_cdims, int *cdims){
|
||||
if (trick_MM != NULL) {
|
||||
return ( trick_MM->resize_array(address, n_cdims, cdims));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_resize_array_a() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_resize_array_a() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
return ( (void*)NULL);
|
||||
}
|
||||
}
|
||||
@ -153,7 +151,7 @@ void* TMM_resize_array_n(const char *name, int n_cdims, int *cdims){
|
||||
if (trick_MM != NULL) {
|
||||
return ( trick_MM->resize_array(name, n_cdims, cdims));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_resize_array_n() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_resize_array_n() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
return ( (void*)NULL);
|
||||
}
|
||||
}
|
||||
@ -167,7 +165,7 @@ void* TMM_resize_array_1d_a(void* address, int num){
|
||||
if (trick_MM != NULL) {
|
||||
return ( trick_MM->resize_array(address, num));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_resize_array_1d_a() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_resize_array_1d_a() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
return ( (void*)NULL);
|
||||
}
|
||||
}
|
||||
@ -181,7 +179,7 @@ void* TMM_resize_array_1d_n(const char *name, int num){
|
||||
if (trick_MM != NULL) {
|
||||
return ( trick_MM->resize_array(name, num));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_resize_array_1d_n() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_resize_array_1d_n() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
return ( (void*)NULL);
|
||||
}
|
||||
}
|
||||
@ -195,7 +193,7 @@ extern "C" char* TMM_strdup(char *str) {
|
||||
if (trick_MM != NULL) {
|
||||
return ( trick_MM->mm_strdup( str));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_strdup called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_strdup called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
return( (char*)NULL);
|
||||
}
|
||||
}
|
||||
@ -210,7 +208,7 @@ extern "C" int TMM_var_exists( const char* var_name) {
|
||||
std::string svar_name = var_name;
|
||||
return ( trick_MM->var_exists( svar_name));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_var_exists() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_var_exists() called before MemoryManager instantiation.\n") ;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
@ -224,7 +222,7 @@ extern "C" int TMM_is_alloced(char *addr) {
|
||||
if (trick_MM != NULL) {
|
||||
return ( trick_MM->is_alloced( addr));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_is_alloced() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_is_alloced() called before MemoryManager instantiation.\n") ;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
@ -238,7 +236,7 @@ extern "C" void TMM_set_debug_level(int level) {
|
||||
if (trick_MM != NULL) {
|
||||
trick_MM->set_debug_level( level);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_set_debug_level() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_set_debug_level() called before MemoryManager instantiation.\n") ;
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +248,7 @@ extern "C" void TMM_reduced_checkpoint(int yesno) {
|
||||
if (trick_MM != NULL) {
|
||||
trick_MM->set_reduced_checkpoint( yesno!=0 );
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_reduced_checkpoint() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_reduced_checkpoint() called before MemoryManager instantiation.\n") ;
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,7 +260,7 @@ extern "C" void TMM_hexfloat_checkpoint(int yesno) {
|
||||
if (trick_MM != NULL) {
|
||||
trick_MM->set_hexfloat_checkpoint( yesno!=0 );
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_hexfloat_checkpoint() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_hexfloat_checkpoint() called before MemoryManager instantiation.\n") ;
|
||||
}
|
||||
}
|
||||
|
||||
@ -277,7 +275,7 @@ extern "C" void TMM_clear_var_a(void *addr) {
|
||||
if (trick_MM != NULL) {
|
||||
trick_MM->clear_var( addr);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_clear_var_a() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_clear_var_a() called before MemoryManager instantiation.\n") ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -290,7 +288,7 @@ extern "C" void TMM_clear_var_n( const char* name) {
|
||||
if (trick_MM != NULL) {
|
||||
trick_MM->clear_var( name);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_clear_var_n() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_clear_var_n() called before MemoryManager instantiation.\n") ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -303,7 +301,7 @@ extern "C" void TMM_delete_var_a(void *addr) {
|
||||
if (trick_MM != NULL) {
|
||||
trick_MM->delete_var( addr);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_delete_var_a() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_delete_var_a() called before MemoryManager instantiation.\n") ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -316,7 +314,7 @@ extern "C" void TMM_delete_var_n( const char* name) {
|
||||
if (trick_MM != NULL) {
|
||||
trick_MM->delete_var( name);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_delete_var_n() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_delete_var_n() called before MemoryManager instantiation.\n") ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -329,7 +327,7 @@ extern "C" void TMM_delete_extern_var_a(void *addr) {
|
||||
if (trick_MM != NULL) {
|
||||
trick_MM->delete_extern_var( addr);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_delete_extern_var_a() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_delete_extern_var_a() called before MemoryManager instantiation.\n") ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -342,7 +340,7 @@ extern "C" void TMM_delete_extern_var_n( const char* name) {
|
||||
if (trick_MM != NULL) {
|
||||
trick_MM->delete_extern_var( name);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_delete_extern_var_n() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_delete_extern_var_n() called before MemoryManager instantiation.\n") ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -355,7 +353,7 @@ extern "C" void TMM_write_checkpoint(const char* filename) {
|
||||
if (trick_MM != NULL) {
|
||||
return ( trick_MM->write_checkpoint( filename));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_write_checkpoint_fn() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_write_checkpoint_fn() called before MemoryManager instantiation.\n") ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -368,7 +366,7 @@ extern "C" int TMM_read_checkpoint(const char* filename) {
|
||||
if (trick_MM != NULL) {
|
||||
return ( trick_MM->read_checkpoint( filename));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_read_checkpoint() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_read_checkpoint() called before MemoryManager instantiation.\n") ;
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
@ -381,7 +379,7 @@ extern "C" int TMM_read_checkpoint_from_string(const char* str) {
|
||||
if (trick_MM != NULL) {
|
||||
return ( trick_MM->read_checkpoint_from_string( str));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_read_checkpoint_from_string() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_read_checkpoint_from_string() called before MemoryManager instantiation.\n") ;
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
@ -394,7 +392,7 @@ extern "C" int TMM_init_from_checkpoint(const char* filename) {
|
||||
if (trick_MM != NULL) {
|
||||
return ( trick_MM->init_from_checkpoint( filename));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_init_from_checkpoint() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_init_from_checkpoint() called before MemoryManager instantiation.\n") ;
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
@ -407,7 +405,7 @@ extern "C" int TMM_add_shared_library_symbols(const char* filename) {
|
||||
if (trick_MM != NULL) {
|
||||
return ( trick_MM->add_shared_library_symbols( filename));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: TMM_add_shared_library_symbols() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("TMM_add_shared_library_symbols() called before MemoryManager instantiation.\n") ;
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
@ -420,7 +418,7 @@ extern "C" void* add_var( TRICK_TYPE type, const char* stype, VAR_DECLARE* var_d
|
||||
if (trick_MM != NULL) {
|
||||
return( trick_MM->add_var(type, stype, var_declare, units ));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: add_var() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
Trick::MemoryManager::emitError("add_var() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
return ((void*)NULL);
|
||||
}
|
||||
}
|
||||
@ -433,7 +431,7 @@ extern "C" int add_vars( TRICK_TYPE type, const char* stype, VAR_LIST* var_list,
|
||||
if (trick_MM != NULL) {
|
||||
return( trick_MM->add_vars(type, stype, var_list, units ));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: add_vars() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("add_vars() called before MemoryManager instantiation.\n") ;
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
@ -446,7 +444,7 @@ extern "C" int ref_allocate(REF2 *R, int num) {
|
||||
if (trick_MM != NULL) {
|
||||
return( trick_MM->ref_allocate( R, num));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: ref_allocate() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("ref_allocate() called before MemoryManager instantiation.\n") ;
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
@ -459,7 +457,7 @@ extern "C" REF2* ref_attributes( char* name) {
|
||||
if (trick_MM != NULL) {
|
||||
return( trick_MM->ref_attributes( name));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: ref_attributes() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
Trick::MemoryManager::emitError("ref_attributes() called before MemoryManager instantiation. Returning NULL.\n") ;
|
||||
return ( (REF2*)NULL);
|
||||
}
|
||||
}
|
||||
@ -472,7 +470,7 @@ extern "C" int ref_assignment(REF2* R, V_TREE* V) {
|
||||
if (trick_MM != NULL) {
|
||||
return( trick_MM->ref_assignment( R, V));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: ref_assignment() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("ref_assignment() called before MemoryManager instantiation.\n") ;
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
@ -485,7 +483,7 @@ extern "C" int ref_var(REF2 *R, char* name) {
|
||||
if (trick_MM != NULL) {
|
||||
return( trick_MM->ref_var( R, name));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: ref_var() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("ref_var() called before MemoryManager instantiation.\n") ;
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
@ -498,7 +496,7 @@ extern "C" int get_size(void *addr) {
|
||||
if (trick_MM != NULL) {
|
||||
return( trick_MM->get_size( addr));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: get_size() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("get_size() called before MemoryManager instantiation.\n") ;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
@ -511,7 +509,7 @@ extern "C" int get_truncated_size(void *addr) {
|
||||
if (trick_MM != NULL) {
|
||||
return( trick_MM->get_truncated_size( addr));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: get_truncated_size() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("get_truncated_size() called before MemoryManager instantiation.\n") ;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
@ -525,8 +523,7 @@ extern "C" int io_get_fixed_truncated_size(char *ptr __attribute__ ((unused)),
|
||||
char *str __attribute__ ((unused)),
|
||||
int dims __attribute__ ((unused)),
|
||||
ATTRIBUTES * left_type __attribute__ ((unused))) {
|
||||
// FIXME
|
||||
message_publish(MSG_ERROR, "Memory Manager INTERNAL-ERROR: io_get_fixed_truncated_size() is not implemented yet.\n") ;
|
||||
Trick::MemoryManager::emitError("io_get_fixed_truncated_size() is not implemented yet.\n") ;
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -538,7 +535,7 @@ extern "C" ALLOC_INFO* get_alloc_info_of(void * addr) {
|
||||
if (trick_MM != NULL) {
|
||||
return( trick_MM->get_alloc_info_of( addr));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: get_alloc_info_of() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("get_alloc_info_of() called before MemoryManager instantiation.\n") ;
|
||||
return ( (ALLOC_INFO*)NULL);
|
||||
}
|
||||
}
|
||||
@ -551,7 +548,7 @@ extern "C" ALLOC_INFO* get_alloc_info_at(void * addr) {
|
||||
if (trick_MM != NULL) {
|
||||
return( trick_MM->get_alloc_info_at( addr));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: get_alloc_info_at() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("get_alloc_info_at() called before MemoryManager instantiation.\n") ;
|
||||
return ( (ALLOC_INFO*)NULL);
|
||||
}
|
||||
}
|
||||
@ -560,7 +557,7 @@ extern "C" int set_alloc_name_at(void * addr, const char * name ) {
|
||||
if (trick_MM != NULL) {
|
||||
return( trick_MM->set_name_at(addr, name));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: get_alloc_info_at() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("get_alloc_info_at() called before MemoryManager instantiation.\n") ;
|
||||
return ( -1 );
|
||||
}
|
||||
}
|
||||
@ -573,7 +570,7 @@ extern "C" int get_enumerated(const char* name, V_DATA* v_data) {
|
||||
if (trick_MM != NULL) {
|
||||
return( trick_MM->get_enumerated(name, v_data ));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "ERROR: get_enumerated() called before MemoryManager instantiation.\n") ;
|
||||
Trick::MemoryManager::emitError("get_enumerated() called before MemoryManager instantiation.\n") ;
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <dlfcn.h>
|
||||
|
||||
@ -8,8 +9,6 @@
|
||||
|
||||
#include "sim_services/SimObject/include/SimObject.hh"
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
|
||||
/**
|
||||
*
|
||||
@ -83,9 +82,11 @@ int Trick::MemoryManager::add_attr_info( std::string & user_type_string , ATTRIB
|
||||
}
|
||||
|
||||
if ( size_func == NULL) {
|
||||
message_publish(MSG_WARNING, "Memory Manager WARNING (%s:%d): Couldn't find an io_src_sizeof_ function for type %s [%s()].\n",
|
||||
file_name , line_num ,
|
||||
user_type_string.c_str(), size_func_name.c_str()) ;
|
||||
std::stringstream message;
|
||||
message << "(" << file_name << ":" << line_num
|
||||
<< "): Couldn't find an io_src_sizeof_ function for type"
|
||||
<< user_type_string.c_str() << "[" << size_func_name.c_str() << "()].";
|
||||
emitWarning(message.str());
|
||||
}
|
||||
|
||||
// Attempt to find an attributes list for the named user type.
|
||||
@ -110,8 +111,10 @@ int Trick::MemoryManager::add_attr_info( std::string & user_type_string , ATTRIB
|
||||
if ( init_sub_attr != NULL ) { // If the initialization function was found,
|
||||
(*init_sub_attr)() ; // then call it.
|
||||
} else {
|
||||
message_publish(MSG_WARNING, "Memory Manager WARNING: ATTRIBUTES init routine for type \"%s\" not found.\n",
|
||||
user_type_name.c_str()) ;
|
||||
std::stringstream message;
|
||||
message << " ATTRIBUTES init routine for type \""
|
||||
<< user_type_name.c_str() << "\" not found.";
|
||||
emitWarning(message.str());
|
||||
return(1) ;
|
||||
}
|
||||
|
||||
@ -139,9 +142,9 @@ int Trick::MemoryManager::add_attr_info( std::string & user_type_string , ATTRIB
|
||||
|
||||
// otherwise ...
|
||||
} else {
|
||||
|
||||
// Declare an ERROR condition.
|
||||
message_publish(MSG_WARNING, "Memory Manager WARNING: ATTRIBUTES for type %s not found.\n", user_type_name.c_str()) ;
|
||||
std::stringstream message;
|
||||
message << "ATTRIBUTES for type \"" << user_type_name.c_str() << "\" not found.";
|
||||
emitWarning(message.str());
|
||||
return(1) ;
|
||||
}
|
||||
} else {
|
||||
|
@ -6,11 +6,10 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
|
||||
/* This routine only returns the size if ptr points to the beginning of the allocation area */
|
||||
int Trick::MemoryManager::add_shared_library_symbols(const char * file_name) {
|
||||
@ -21,7 +20,9 @@ int Trick::MemoryManager::add_shared_library_symbols(const char * file_name) {
|
||||
if ( new_handle != NULL ) {
|
||||
dlhandles.push_back(new_handle) ;
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: add_shared_library_symbols could not find library file: %s.\n", file_name) ;
|
||||
std::stringstream message;
|
||||
message << "add_shared_library_symbols could not find library file: \"" << file_name << "\".";
|
||||
emitError(message.str());
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
|
@ -8,8 +8,6 @@
|
||||
#include "sim_services/MemoryManager/include/value.h"
|
||||
#include "sim_services/MemoryManager/include/vval.h"
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
|
||||
void* Trick::MemoryManager::add_var( TRICK_TYPE type,
|
||||
const char* class_name,
|
||||
@ -36,8 +34,8 @@ void* Trick::MemoryManager::add_var( TRICK_TYPE type,
|
||||
variable_pos = variable_map.find( var_declare->name);
|
||||
if (variable_pos != variable_map.end()) {
|
||||
std::stringstream ss;
|
||||
ss << "Memory Manager: Variable \""<< var_declare->name << "\" is already declared.\n";
|
||||
message_publish(MSG_ERROR, ss.str().c_str() ) ;
|
||||
ss << "Variable \""<< var_declare->name << "\" is already declared.\n";
|
||||
emitError(ss.str());
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
return ((void*)NULL);
|
||||
}
|
||||
@ -54,11 +52,10 @@ void* Trick::MemoryManager::add_var( TRICK_TYPE type,
|
||||
/** @li Call declare_var to create a named-allocation. */
|
||||
if ((address = declare_var( type, class_name_string, n_stars, var_declare->name, n_cdims, cdims)) == NULL) {
|
||||
std::stringstream ss;
|
||||
ss << "Memory Manager ERROR: Declaration \"" ;
|
||||
ss << "Declaration \"" ;
|
||||
ss << make_decl_string( type, class_name_string, n_stars, var_declare->name, n_cdims, cdims);
|
||||
ss << "\" failed.";
|
||||
ss << std::endl;
|
||||
message_publish(MSG_ERROR, ss.str().c_str() ) ;
|
||||
emitError( ss.str()) ;
|
||||
return ((void*)NULL);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
#include <sstream>
|
||||
|
||||
ALLOC_INFO* Trick::MemoryManager::get_alloc_info_of( void* addr) {
|
||||
@ -37,10 +35,9 @@ int Trick::MemoryManager::set_name_at( void* addr , const char * name ) {
|
||||
variable_pos = variable_map.find(name);
|
||||
if (variable_pos != variable_map.end()) {
|
||||
std::stringstream ss;
|
||||
ss << "Memory Manager ERROR: Call to set_name_at() failed because a variable named \""
|
||||
<< name <<"\" already exists."
|
||||
<< std::endl ;
|
||||
message_publish(MSG_ERROR, ss.str().c_str() );
|
||||
ss << "Call to set_name_at() failed because a variable named \""
|
||||
<< name << "\" already exists.";
|
||||
emitError(ss.str());
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
ret = -1 ;
|
||||
} else {
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/MemoryManager/include/bitfield_proto.h"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
#include <sstream>
|
||||
|
||||
void Trick::MemoryManager::clear_rvalue( void* base_address, ATTRIBUTES* attr, int curr_dim, int offset) {
|
||||
|
||||
@ -49,8 +48,8 @@ void Trick::MemoryManager::clear_rvalue( void* base_address, ATTRIBUTES* attr, i
|
||||
final_address = (char*)base_address + offset * sizeof(short);
|
||||
*(short*)final_address = 0;
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager INTERNAL-ERROR: Unexpected size of ENUMERATION type.\n") ;
|
||||
}
|
||||
emitError("INTERNAL-ERROR - Unexpected size of ENUMERATION type.") ;
|
||||
}
|
||||
break;
|
||||
case TRICK_LONG :
|
||||
case TRICK_UNSIGNED_LONG :
|
||||
@ -83,8 +82,9 @@ void Trick::MemoryManager::clear_rvalue( void* base_address, ATTRIBUTES* attr, i
|
||||
*(unsigned char*)final_address = insert_bitfield_any(
|
||||
*(unsigned char*)final_address, 0, attr->size, attr->index[0].start, attr->index[0].size);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager INTERNAL ERROR - Unhandled bitfield struct size (%d) "
|
||||
"in bitfield assignment.\n", attr->size) ;
|
||||
std::stringstream message;
|
||||
message << "INTERNAL - Unhandled bitfield struct size (" << attr->size << ") in bitfield assignment.";
|
||||
emitError(message.str());
|
||||
}
|
||||
break;
|
||||
case TRICK_FILE_PTR :
|
||||
@ -96,7 +96,9 @@ void Trick::MemoryManager::clear_rvalue( void* base_address, ATTRIBUTES* attr, i
|
||||
*(std::string*)final_address = "";
|
||||
break;
|
||||
default :
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Unhandled Type (%d).\n", (int)attr->type) ;
|
||||
std::stringstream message;
|
||||
message << "Unhandled Type (" << (int)attr->type << ").";
|
||||
emitError(message.str());
|
||||
break;
|
||||
}
|
||||
|
||||
@ -132,7 +134,9 @@ void Trick::MemoryManager::clear_rvalue( void* base_address, ATTRIBUTES* attr, i
|
||||
}
|
||||
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager INTERNAL-ERROR: Remaining dimensions are negative!?.\n") ;
|
||||
std::stringstream message;
|
||||
message << "This is bad. Remaining dimensions are negative!?.";
|
||||
emitError(message.str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -230,8 +234,10 @@ void Trick::MemoryManager::clear_var( void* address) {
|
||||
}
|
||||
free_reference_attr( reference_attr);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Cannot clear the variable at address %p\n"
|
||||
"because memory manager knows nothing about it.\n", address) ;
|
||||
std::stringstream message;
|
||||
message << "Cannot clear the variable at address " << address
|
||||
<< "because memory manager knows nothing about it." ;
|
||||
emitError(message.str());
|
||||
}
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
}
|
||||
@ -251,8 +257,10 @@ void Trick::MemoryManager::clear_var( const char* name) {
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
clear_var( alloc_info->start);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Cannot clear variable \"%s\"\n"
|
||||
"because it doesn't exist.\n", name) ;
|
||||
std::stringstream message;
|
||||
message << "Can't clear variable \"" << name
|
||||
<< "\" because it doesn't exist.";
|
||||
emitError(message.str());
|
||||
}
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
}
|
||||
|
@ -5,8 +5,6 @@
|
||||
#include <dlfcn.h>
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/MemoryManager/include/ADefParseContext.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
|
||||
/**
|
||||
@page examples_declare_var Examples of declare_var
|
||||
@ -71,9 +69,9 @@ void* Trick::MemoryManager::declare_var( TRICK_TYPE type,
|
||||
pthread_mutex_lock(&mm_mutex);
|
||||
variable_pos = variable_map.find( var_name);
|
||||
if (variable_pos != variable_map.end()) {
|
||||
std::stringstream ss;
|
||||
ss << "Memory Manager ERROR: Variable \""<< var_name <<"\" already declared.\n";
|
||||
message_publish(MSG_ERROR, ss.str().c_str() );
|
||||
std::stringstream message;
|
||||
message << "Variable \""<< var_name <<"\" already declared.\n";
|
||||
emitError(message.str());
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
return ((void*)NULL);
|
||||
}
|
||||
@ -90,26 +88,25 @@ void* Trick::MemoryManager::declare_var( TRICK_TYPE type,
|
||||
n_elems = n_elems * cdims[ii];
|
||||
}
|
||||
if (n_elems == 0) {
|
||||
std::stringstream ss;
|
||||
ss << "Memory Manager ERROR: In the following declaration, ";
|
||||
ss << "one or more of the constrained dimensions is zero." ;
|
||||
ss << std::endl;
|
||||
std::stringstream message;
|
||||
message << "In the following declaration, ";
|
||||
message << "one or more of the constrained dimensions is zero." ;
|
||||
message << std::endl;
|
||||
|
||||
// Print declaration.
|
||||
ss << make_decl_string( type, user_type_name, n_stars, var_name, n_cdims, cdims);
|
||||
ss << std::endl;
|
||||
message_publish(MSG_ERROR, ss.str().c_str() ) ;
|
||||
message << make_decl_string( type, user_type_name, n_stars, var_name, n_cdims, cdims);
|
||||
emitError(message.str()) ;
|
||||
return ((void*)NULL);
|
||||
}
|
||||
|
||||
/** @li From the TRICK_TYPE, user_type_name and the number of pointers (asterisks),
|
||||
determine the size and the attributes of an element. */
|
||||
if ( get_type_attributes(type, user_type_name, n_stars, sub_attr, size) != 0) {
|
||||
std::stringstream ss;
|
||||
ss << "Memory Manager ERROR: get_type_attributes failed for type: ";
|
||||
ss << trickTypeCharString(type, user_type_name.c_str());
|
||||
ss << std::endl;
|
||||
message_publish(MSG_ERROR, ss.str().c_str() ) ;
|
||||
std::stringstream message;
|
||||
message << "get_type_attributes failed for type: ";
|
||||
message << trickTypeCharString(type, user_type_name.c_str());
|
||||
message << std::endl;
|
||||
emitError(message.str()) ;
|
||||
|
||||
return ((void*)NULL);
|
||||
}
|
||||
@ -120,12 +117,11 @@ void* Trick::MemoryManager::declare_var( TRICK_TYPE type,
|
||||
(n_stars == 0 ) ) {
|
||||
|
||||
if ((address = io_src_allocate_class( user_type_name.c_str(), n_elems)) == NULL) {
|
||||
std::stringstream ss;
|
||||
ss << "Memory Manager ERROR: io_src_allocate_class (";
|
||||
ss << user_type_name << "," << n_elems ;
|
||||
ss << ") failed to allocate any memory.";
|
||||
ss << std::endl;
|
||||
message_publish(MSG_ERROR, ss.str().c_str() ) ;
|
||||
std::stringstream message;
|
||||
message << "io_src_allocate_class (";
|
||||
message << user_type_name << "," << n_elems ;
|
||||
message << ") failed to allocate any memory.";
|
||||
emitError(message.str()) ;
|
||||
|
||||
return ((void*)NULL);
|
||||
}
|
||||
@ -145,7 +141,7 @@ void* Trick::MemoryManager::declare_var( TRICK_TYPE type,
|
||||
language = Language_CPP;
|
||||
} else {
|
||||
if ( (address = calloc( (size_t)n_elems, (size_t)size ) ) == NULL) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Out of memory.\n") ;
|
||||
emitError("Out of memory.") ;
|
||||
return ((void*)NULL);
|
||||
}
|
||||
language = Language_C;
|
||||
@ -194,7 +190,7 @@ void* Trick::MemoryManager::declare_var( TRICK_TYPE type,
|
||||
}
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Out of memory.\n") ;
|
||||
emitError("Out of memory.\n") ;
|
||||
return ((void*)NULL);
|
||||
}
|
||||
|
||||
@ -246,7 +242,9 @@ void* Trick::MemoryManager::declare_var( const char *alloc_definition) {
|
||||
/** @li Delete the parse context. */
|
||||
delete( context);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager: Invalid declaration (failed to parse): \"%s\".\n", alloc_definition) ;
|
||||
std::stringstream message;
|
||||
message << "Invalid declaration (failed to parse): \"" << alloc_definition << "\".";
|
||||
emitError(message.str());
|
||||
}
|
||||
}
|
||||
/** @li Return the address of the allocation. */
|
||||
@ -296,7 +294,9 @@ void* Trick::MemoryManager::declare_var( const char *element_definition, int n_e
|
||||
/** @li Delete the parse context. */
|
||||
delete( context);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: declare_var( \"%s\",%d).\n", element_definition, n_elems) ;
|
||||
std::stringstream message;
|
||||
message << "declare_var( \"" << element_definition << "\"," << n_elems <<").";
|
||||
emitError(message.str());
|
||||
}
|
||||
}
|
||||
/** @li Return the address of the allocation. */
|
||||
@ -323,13 +323,15 @@ void* Trick::MemoryManager::declare_operatornew_var( std::string user_type_name,
|
||||
/** @li From the TRICK_TYPE, user_type_name and the number of pointers (asterisks),
|
||||
determine the size and the attributes of an element. */
|
||||
if ( get_type_attributes(type, user_type_name, 0, sub_attr, size_ref ) != 0) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: get_type_attributes failed for type: %d %s.\n",
|
||||
TRICK_STRUCTURED, user_type_name.c_str()) ;
|
||||
std::stringstream message;
|
||||
message << "get_type_attributes failed for type: " << TRICK_STRUCTURED
|
||||
<< " " << user_type_name.c_str() << ".";
|
||||
emitError(message.str());
|
||||
return ((void*)NULL);
|
||||
}
|
||||
|
||||
if ( (address = calloc( 1, alloc_size ) ) == NULL) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Out of memory.\n") ;
|
||||
emitError("Out of memory.") ;
|
||||
return ((void*)NULL);
|
||||
}
|
||||
|
||||
@ -362,7 +364,7 @@ void* Trick::MemoryManager::declare_operatornew_var( std::string user_type_name,
|
||||
alloc_info_map[address] = new_alloc;
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Out of memory.\n") ;
|
||||
emitError("Out of memory.") ;
|
||||
return ((void*)NULL);
|
||||
}
|
||||
|
||||
@ -404,7 +406,9 @@ size_t Trick::MemoryManager::sizeof_type( const char* var_definition) {
|
||||
n_elems *= context->cdims[ii];
|
||||
}
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager: Invalid variable definition \"%s\" in sizeof_type.\n", var_definition) ;
|
||||
std::stringstream message;
|
||||
message << "Invalid variable definition \"" << var_definition << "\" in sizeof_type.";
|
||||
emitError(message.str());
|
||||
}
|
||||
delete( context);
|
||||
}
|
||||
|
@ -4,14 +4,14 @@
|
||||
#include <sstream>
|
||||
#include <dlfcn.h>
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
|
||||
// MEMBER FUNCTION
|
||||
int Trick::MemoryManager::delete_var(void* address, bool destroy ) {
|
||||
|
||||
if (address == 0) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Cannot delete memory at NULL.\n") ;
|
||||
std::stringstream message;
|
||||
message << "Cannot delete memory at NULL.";
|
||||
emitError(message.str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -64,10 +64,10 @@ int Trick::MemoryManager::delete_var(void* address, bool destroy ) {
|
||||
free(alloc_info);
|
||||
|
||||
} else {
|
||||
message_publish(MSG_WARNING,
|
||||
"WARNING: The Trick MemoryManager cannot delete memory at address %p \n"
|
||||
"because the MemoryManager did not allocate it, nor does the\n"
|
||||
"MemoryManager know anything about it.\n", address) ;
|
||||
std::stringstream message;
|
||||
message << "The MemoryManager cannot delete memory at address ["
|
||||
<< address << "] because it has no record of it.";
|
||||
emitWarning(message.str());
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
@ -89,7 +89,10 @@ int Trick::MemoryManager::delete_var( const char* name) {
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
return( delete_var( alloc_info->start));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Cannot delete variable \"%s\" because it doesn't exist.\n", name) ;
|
||||
std::stringstream message;
|
||||
message << "Cannot delete variable \"" << name
|
||||
<< "\" because it doesn't exist." ;
|
||||
emitError(message.str());
|
||||
}
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
return 1;
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
#include <sstream>
|
||||
|
||||
int Trick::MemoryManager::get_type_attributes( TRICK_TYPE& type,
|
||||
std::string user_type_name,
|
||||
@ -68,7 +67,9 @@ int Trick::MemoryManager::get_type_attributes( TRICK_TYPE& type,
|
||||
size = sizeof(void*);
|
||||
} else {
|
||||
if ((size = io_src_sizeof_user_type( user_type_name.c_str())) == 0) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: size of type \"%s\" not found.\n", user_type_name.c_str()) ;
|
||||
std::stringstream message;
|
||||
message << "size of type \"" << user_type_name.c_str() <<"\" not found.\n";
|
||||
emitError(message.str());
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
@ -86,7 +87,9 @@ int Trick::MemoryManager::get_type_attributes( TRICK_TYPE& type,
|
||||
} break;
|
||||
|
||||
default: {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Unknown Trick data-type: %d.\n", type) ;
|
||||
std::stringstream message;
|
||||
message << "Unknown data-type \"" << type << "\"." ;
|
||||
emitError(message.str());
|
||||
return (1);
|
||||
} break;
|
||||
}
|
||||
|
@ -4,8 +4,6 @@
|
||||
#include <dlfcn.h>
|
||||
// Provides dlsym().
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
|
||||
// MEMBER FUNCTION: void* Trick::MemoryManager::io_src_allocate_class(const char* class_name, int num);
|
||||
|
||||
@ -48,7 +46,10 @@ void* Trick::MemoryManager::io_src_allocate_class(const char* class_name, int nu
|
||||
} else {
|
||||
const char* msg = dlerror();
|
||||
addr = NULL;
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Couldn't find function %s().\n%s\n", alloc_fn_name,msg);
|
||||
std::stringstream message;
|
||||
message << "Couldn't find function \"" << alloc_fn_name << "()\". "
|
||||
<< "dlerror= " << msg;
|
||||
emitError(message.str());
|
||||
}
|
||||
return (addr);
|
||||
}
|
||||
@ -80,7 +81,10 @@ void Trick::MemoryManager::io_src_destruct_class(ALLOC_INFO * alloc_info) {
|
||||
(*destruct)(alloc_info->start, alloc_info->num) ;
|
||||
} else {
|
||||
const char* msg = dlerror();
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Couldn't find function %s().\n%s\n", destruct_fn_name,msg);
|
||||
std::stringstream message;
|
||||
message << "Couldn't find function \"" << destruct_fn_name << "()\". "
|
||||
<< "dlerror= " << msg;
|
||||
emitError(message.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -111,7 +115,10 @@ void Trick::MemoryManager::io_src_delete_class(ALLOC_INFO * alloc_info) {
|
||||
(*delete_fn)(alloc_info->start) ;
|
||||
} else {
|
||||
const char* msg = dlerror();
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Couldn't find function %s().\n%s\n", delete_fn_name,msg);
|
||||
std::stringstream message;
|
||||
message << "Couldn't find function \"" << delete_fn_name << "()\". "
|
||||
<< "dlerror= " << msg;
|
||||
emitError(message.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -148,7 +155,10 @@ size_t Trick::MemoryManager::io_src_sizeof_user_type( const char* user_type_name
|
||||
} else {
|
||||
const char* msg = dlerror();
|
||||
class_size = 0;
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Couldn't find function %s().\n%s\n", size_fn_name,msg);
|
||||
std::stringstream message;
|
||||
message << "Couldn't find function \"" << size_fn_name << "()\". "
|
||||
<< "dlerror= " << msg;
|
||||
emitError(message.str());
|
||||
}
|
||||
return (class_size);
|
||||
}
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/MemoryManager/include/ADefParseContext.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
|
||||
/**
|
||||
@par Description:
|
||||
@ -35,7 +33,7 @@ void* Trick::MemoryManager::
|
||||
|
||||
/** @li Validate Parameters. The address can't be NULL.*/
|
||||
if (address == NULL) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: declare_extern_var called with NULL address.\n") ;
|
||||
emitError("declare_extern_var() called with NULL address.");
|
||||
return ((void*)NULL);
|
||||
}
|
||||
|
||||
@ -44,7 +42,9 @@ void* Trick::MemoryManager::
|
||||
pthread_mutex_lock(&mm_mutex);
|
||||
variable_pos = variable_map.find( var_name);
|
||||
if (variable_pos != variable_map.end()) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Variable \"%s\" already declared.\n", var_name.c_str()) ;
|
||||
std::stringstream message;
|
||||
message << "Variable \""<< var_name <<"\" already declared.";
|
||||
emitError(message.str());
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
return ((void*)NULL);
|
||||
}
|
||||
@ -62,15 +62,21 @@ void* Trick::MemoryManager::
|
||||
n_elems = n_elems * cdims[ii];
|
||||
}
|
||||
if (n_elems == 0) {
|
||||
// FIXME: This Error message needs to improved.
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: One or more of the constrained dimensions is zero.\n") ;
|
||||
std::stringstream message;
|
||||
message << "declare_extern_var() can't register \"" << var_name
|
||||
<< "\" because one or more of its constrained dimensions "
|
||||
<< "is zero, thus making its total size zero.";
|
||||
emitError(message.str());
|
||||
return ((void*)NULL);
|
||||
}
|
||||
|
||||
/** @li From the TRICK_TYPE, user_type_name and the number of pointers (asterisks),
|
||||
determine the size and the attributes of an element. */
|
||||
if ( get_type_attributes(type, user_type_name, n_stars, sub_attr, size) != 0) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: get_type_attributes failed for type %d %s.\n", type, user_type_name.c_str()) ;
|
||||
std::stringstream message;
|
||||
message << "get_type_attributes failed for type "
|
||||
<< type << " \"" << user_type_name << "\".";
|
||||
emitError(message.str());
|
||||
return ((void*)NULL);
|
||||
}
|
||||
|
||||
@ -123,7 +129,7 @@ void* Trick::MemoryManager::
|
||||
}
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Out of memory.\n") ;
|
||||
emitError("Out of memory.") ;
|
||||
return ((void*)NULL);
|
||||
}
|
||||
|
||||
@ -179,7 +185,9 @@ void* Trick::MemoryManager::
|
||||
/** @li Delete the parse context. */
|
||||
delete( context);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager: Invalid declaration \"%s\".\n", alloc_definition) ;
|
||||
std::stringstream message;
|
||||
message << "Invalid declaration \"" << alloc_definition << "\".";
|
||||
emitError(message.str());
|
||||
}
|
||||
}
|
||||
/** @li Return the address. */
|
||||
@ -232,7 +240,10 @@ void* Trick::MemoryManager::
|
||||
/** @li Delete the parse context. */
|
||||
delete( context);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: declare_extern_var( \"%s\",%d).\n", element_definition, n_elems) ;
|
||||
std::stringstream message;
|
||||
message << "declare_extern_var( \"" << element_definition
|
||||
<< "\"," << n_elems << ") failed.";
|
||||
emitError(message.str());
|
||||
}
|
||||
}
|
||||
/** @li Return the address of the allocation. */
|
||||
|
@ -1,8 +1,7 @@
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
#include <dlfcn.h>
|
||||
#include <stdlib.h>
|
||||
#include <sstream>
|
||||
|
||||
// PRIVATE MEMBER FUNCTION
|
||||
void Trick::MemoryManager::recursive_array_copy( void *s_base,
|
||||
@ -65,22 +64,23 @@ void* Trick::MemoryManager::resize_array( void *address, int n_cdims, int *cdims
|
||||
alloc_info = get_alloc_info_at( address);
|
||||
|
||||
if (alloc_info == NULL) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Address passed to resize_array is NULL.\n") ;
|
||||
emitError("Address passed to resize_array is NULL.") ;
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
return ( (void*)NULL);
|
||||
}
|
||||
|
||||
if (alloc_info->stcl != TRICK_LOCAL) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Cannot resize the array variable at address %p "
|
||||
"because it did not allocate it.\n", address) ;
|
||||
std::stringstream message;
|
||||
message << "Cannot resize the array at [" << address << "] because it's EXTERN.";
|
||||
emitError(message.str());
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
return ( (void*)NULL);
|
||||
}
|
||||
|
||||
if (alloc_info->type == TRICK_STRING) {
|
||||
message_publish(MSG_ERROR, "Memory Manager resize_array ERROR: at address %p."
|
||||
" Arrays of STL strings are not supported."
|
||||
" Consider using a vector of strings.\n", address) ;
|
||||
std::stringstream message;
|
||||
message << "resize_array doesn't support STL strings.";
|
||||
emitError(message.str());
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
return ( (void*)NULL);
|
||||
}
|
||||
@ -99,13 +99,17 @@ void* Trick::MemoryManager::resize_array( void *address, int n_cdims, int *cdims
|
||||
are the same as those in the proposed re-allocation.*/
|
||||
if (n_cdims != pre_n_cdims) {
|
||||
if (pre_n_cdims == 0) {
|
||||
message_publish(MSG_ERROR, "Memory Manager resize_array ERROR: The object at address %p is not an array.\n"
|
||||
"If you want to be able to resize it then\n"
|
||||
"declare it as an array (of one) in the first place.\n", address) ;
|
||||
std::stringstream message;
|
||||
message << "resize_array: The object at address [" << address
|
||||
<< "] is not an array. If you want to be able to resize "
|
||||
<< "it then declare it as an array (of at least one).";
|
||||
emitError(message.str());
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager resize_array ERROR: The number of dimensions specified, \"%d\",\n"
|
||||
"doesn't match the number of (non-pointer) dimensions of the object, \"%d\",\n"
|
||||
"at address %p\n.", n_cdims, pre_n_cdims, address) ;
|
||||
std::stringstream message;
|
||||
message << "resize_array: The number of dimensions specified, [" << n_cdims
|
||||
<< "], doesn't match the number of dimensions of the object at "
|
||||
<< address <<", [" << pre_n_cdims << "].";
|
||||
emitError(message.str());
|
||||
}
|
||||
return ( (void*)NULL);
|
||||
}
|
||||
@ -116,7 +120,7 @@ void* Trick::MemoryManager::resize_array( void *address, int n_cdims, int *cdims
|
||||
new_n_elems = new_n_elems * cdims[ii];
|
||||
}
|
||||
if (new_n_elems == 0) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: One or more of the constrained dimensions is zero.\n") ;
|
||||
emitError("One or more of the constrained dimensions is zero.");
|
||||
return ((void*)NULL);
|
||||
}
|
||||
|
||||
@ -127,8 +131,9 @@ void* Trick::MemoryManager::resize_array( void *address, int n_cdims, int *cdims
|
||||
(alloc_info->num_index == n_cdims) ) {
|
||||
|
||||
if ((new_address = io_src_allocate_class( alloc_info->user_type_name, new_n_elems)) == NULL) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: io_src_allocate_class(%s,%d) failed to allocate any memory.\n",
|
||||
alloc_info->user_type_name, new_n_elems) ;
|
||||
std::stringstream message;
|
||||
message << "io_src_allocate_class(" << alloc_info->user_type_name << "," << new_n_elems << ") failed to allocate any memory.";
|
||||
emitError(message.str());
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
return ((void*)NULL);
|
||||
}
|
||||
@ -140,7 +145,7 @@ void* Trick::MemoryManager::resize_array( void *address, int n_cdims, int *cdims
|
||||
}
|
||||
} else {
|
||||
if ( (new_address = calloc( (size_t)new_n_elems, (size_t)alloc_info->size ) ) == NULL) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Out of memory.\n") ;
|
||||
emitError("Out of memory.") ;
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
return ((void*)NULL);
|
||||
}
|
||||
@ -210,7 +215,9 @@ void* Trick::MemoryManager::resize_array( const char* name, int n_cdims, int *cd
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
return( resize_array( alloc_info->start, n_cdims, cdims));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Cannot resize variable \"%s\" because it doesn't exist.\n", name) ;
|
||||
std::stringstream message;
|
||||
message << "Cannot resize variable \"" << name << "\" because it doesn't exist.";
|
||||
emitError(message.str());
|
||||
}
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
return NULL ;
|
||||
|
@ -1,12 +1,11 @@
|
||||
#include <iostream>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
|
||||
#include "sim_services/MemoryManager/include/attributes.h"
|
||||
#include "sim_services/MemoryManager/include/reference.h"
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
|
||||
int Trick::MemoryManager::ref_allocate(REF2 * R , int num ) {
|
||||
|
||||
@ -16,15 +15,15 @@ int Trick::MemoryManager::ref_allocate(REF2 * R , int num ) {
|
||||
|
||||
/** @li Validate Parameters.*/
|
||||
if (R == NULL) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: R is NULL in call to ref_allocate(R,num).\n") ;
|
||||
emitError("R is NULL in call to ref_allocate(R,num).") ;
|
||||
return (1);
|
||||
}
|
||||
if (R->attr == NULL) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: R->attr is NULL in call to ref_allocate(R,num).\n") ;
|
||||
emitError("R->attr is NULL in call to ref_allocate(R,num).") ;
|
||||
return (1);
|
||||
}
|
||||
if (num <= 0) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: num is <= 0 in call to ref_allocate(R,num).\n") ;
|
||||
emitError("num is <= 0 in call to ref_allocate(R,num).") ;
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,10 @@
|
||||
#include "sim_services/MemoryManager/include/bitfield_proto.h"
|
||||
#include "sim_services/MemoryManager/include/vval.h"
|
||||
#include "sim_services/MemoryManager/include/wcs_ext.h"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
#include "trick_utils/units/include/Unit.hh"
|
||||
#include "trick_utils/units/include/UCFn.hh"
|
||||
#include <limits.h>
|
||||
#include <sstream>
|
||||
|
||||
int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, int curr_dim, int offset, V_TREE* v_tree, UCFn* cf) {
|
||||
|
||||
@ -18,13 +17,13 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
|
||||
switch (attr->type) {
|
||||
|
||||
case TRICK_CHARACTER :
|
||||
case TRICK_UNSIGNED_CHARACTER :
|
||||
case TRICK_UNSIGNED_CHARACTER :
|
||||
assign_addr = (char*)base_addr + offset * sizeof(char);
|
||||
if (v_tree && v_tree->v_data) {
|
||||
*(char*)assign_addr = vval_char(v_tree->v_data);
|
||||
} else {
|
||||
*(char*)assign_addr = '\0';
|
||||
}
|
||||
}
|
||||
if (debug_level) {
|
||||
std::cout << std::endl << "Assignment: *(char*)" << (void*)assign_addr
|
||||
<< " = ";
|
||||
@ -68,19 +67,12 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
|
||||
case TRICK_UNSIGNED_INTEGER :
|
||||
assign_addr = (char*)base_addr + offset * sizeof(int);
|
||||
if (v_tree && v_tree->v_data) {
|
||||
int input_value;
|
||||
int input_value;
|
||||
input_value = vval_int(v_tree->v_data);
|
||||
if (cf == NULL) {
|
||||
*(int *)assign_addr = input_value;
|
||||
} else {
|
||||
int assign_value;
|
||||
assign_value = (int)(input_value * cf->C[1] + cf->C[0]);
|
||||
if ((assign_value <= INT_MAX) && (assign_value >= INT_MIN)) {
|
||||
*(int *)assign_addr = (int)assign_value;
|
||||
} else {
|
||||
*(int *)assign_addr = input_value;
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Unit conversion makes value too large to be assigned. Ignoring\n") ;
|
||||
}
|
||||
*(int *)assign_addr = input_value * cf->C[1] + cf->C[0];
|
||||
}
|
||||
} else {
|
||||
*(int *)assign_addr = 0;
|
||||
@ -123,10 +115,12 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
|
||||
std::cout.flush();
|
||||
}
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Enumeration of size %d is not supported.\n", attr->size) ;
|
||||
std::stringstream message;
|
||||
message << "Enumeration of size " << attr->size << " is not supported.";
|
||||
emitError(message.str());
|
||||
}
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: v_tree data is corrupt.\n") ;
|
||||
emitError("v_tree data appears to be corrupted.");
|
||||
}
|
||||
break;
|
||||
case TRICK_LONG :
|
||||
@ -138,15 +132,8 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
|
||||
if (cf == NULL) {
|
||||
*(long *)assign_addr = input_value;
|
||||
} else {
|
||||
double assign_value;
|
||||
assign_value = input_value * cf->C[1] + cf->C[0];
|
||||
if ((assign_value <= LONG_MAX) && (assign_value >= LONG_MIN)) {
|
||||
*(long *)assign_addr = (long)assign_value;
|
||||
} else {
|
||||
*(long *)assign_addr = input_value;
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Unit conversion makes value too large to be assigned. Ignoring\n") ;
|
||||
}
|
||||
}
|
||||
*(long *)assign_addr = input_value * cf->C[1] + cf->C[0];
|
||||
}
|
||||
} else {
|
||||
*(long *)assign_addr = 0;
|
||||
}
|
||||
@ -227,9 +214,10 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
|
||||
*(unsigned char*)assign_addr = insert_bitfield_any(
|
||||
*(unsigned char*)assign_addr, input_value, attr->size, attr->index[0].start, attr->index[0].size);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager INTERNAL ERROR:\n"
|
||||
"Unhandled bitfield struct size (%d) in bitfield assignment.\n", attr->size) ;
|
||||
}
|
||||
std::stringstream message;
|
||||
message << "Unhandled bitfield struct size (" << attr->size << ") in bitfield assignment.";
|
||||
emitError(message.str());
|
||||
}
|
||||
if (debug_level) {
|
||||
std::cout << std::endl << "Assignment: "
|
||||
<< "Within the " << attr->size << " byte struct at " << (void*)assign_addr
|
||||
@ -268,7 +256,9 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
|
||||
}
|
||||
break;
|
||||
default:
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Unhandled Type (%d) in assignment.\n", attr->type) ;
|
||||
std::stringstream message;
|
||||
message << "Unhandled Type (" << attr->type << ") in assignment.";
|
||||
emitError(message.str());
|
||||
return (1);
|
||||
break;
|
||||
}
|
||||
@ -314,7 +304,7 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
|
||||
if (rhs_len <= size_of_curr_dim ) {
|
||||
strcpy((char*)assign_addr, v_tree->v_data->value.cp);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager: char array is too small for the attempted string assignment.\n") ;
|
||||
emitError("Memory Manager: char array is too small for the attempted string assignment.");
|
||||
return (1);
|
||||
}
|
||||
} else {
|
||||
@ -332,7 +322,10 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
|
||||
if (rhs_len <= size_of_curr_dim ) {
|
||||
wcscpy((wchar_t*)assign_addr, v_tree->v_data->value.wcp);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager: wchar_t array is too small for the attempted string assignment.\n") ;
|
||||
std::stringstream message;
|
||||
message << "wchar_t array at [" << (void*)assign_addr
|
||||
<< "] is to small for the attempted string assignment." ;
|
||||
emitError(message.str());
|
||||
return (1);
|
||||
}
|
||||
} else if ((v_tree) &&
|
||||
@ -343,7 +336,10 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
|
||||
if (rhs_len <= size_of_curr_dim ) {
|
||||
ncs_to_wcs( v_tree->v_data->value.cp, (wchar_t*)assign_addr, rhs_len);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager: wchar_t array is too small for the attempted string assignment.\n") ;
|
||||
std::stringstream message;
|
||||
message << "wchar_t array at [" << (void*)assign_addr
|
||||
<< "] is too small for the attempted string assignment." ;
|
||||
emitError(message.str());
|
||||
return (1);
|
||||
}
|
||||
} else {
|
||||
@ -379,7 +375,7 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
|
||||
}
|
||||
}
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR - bad reference.\n") ;
|
||||
emitError("This is bad. In assign_recursive(), remaining_dimensions is negative.");
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
@ -401,7 +397,9 @@ int Trick::MemoryManager::ref_assignment( REF2* R, V_TREE* V) {
|
||||
delete from_units;
|
||||
delete to_units;
|
||||
} catch (Unit::CONVERSION_ERROR) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Can't convert \"%s\" to \"%s\".\n", R->units, R->attr->units) ;
|
||||
std::stringstream message;
|
||||
message << "Can't convert \"" << R->units << "\" to \"" << R->attr->units << "\".";
|
||||
emitError(message.str());
|
||||
cf = NULL;
|
||||
return TRICK_UNITS_CONVERSION_ERROR ;
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/MemoryManager/include/vval.h"
|
||||
#include "sim_services/MemoryManager/include/attributes.h"
|
||||
#include "sim_services/MemoryManager/include/reference.h"
|
||||
#include "sim_services/MemoryManager/include/parameter_types.h"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
|
||||
/*
|
||||
Updates R, a reference to an arrayed object, to a reference to the indexed sub-element of that arrayed object.
|
||||
@ -19,14 +18,14 @@ int Trick::MemoryManager::ref_dim( REF2* R, V_DATA* V) {
|
||||
int item_size;
|
||||
|
||||
if (R->ref_type != REF_ADDRESS) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Attempt to index into a non-address reference is bogus in ref_dim.\n") ;
|
||||
emitError("Attempt to index into a non-address reference is bogus in ref_dim.") ;
|
||||
return (1);
|
||||
}
|
||||
|
||||
R->num_index_left--;
|
||||
if (R->num_index_left < 0) {
|
||||
/* if we have too many dimensions, flag an error */
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Too many dimensions in ref_dim.\n") ;
|
||||
emitError("Too many dimensions in ref_dim.\n") ;
|
||||
return (TRICK_PARAMETER_ARRAY_SIZE);
|
||||
}
|
||||
|
||||
@ -44,7 +43,7 @@ int Trick::MemoryManager::ref_dim( REF2* R, V_DATA* V) {
|
||||
}
|
||||
/* for fixed dimensions, we can check the validity of the index value */
|
||||
if (vval_int(V) >= R->attr->index[R->num_index].size || vval_int(V) < 0) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Array index out of bounds.\n") ;
|
||||
emitError("Memory Manager ERROR: Array index out of bounds.") ;
|
||||
return (TRICK_PARAMETER_ARRAY_SIZE);
|
||||
}
|
||||
|
||||
@ -79,7 +78,9 @@ int Trick::MemoryManager::ref_dim( REF2* R, V_DATA* V) {
|
||||
// Dereference the pointer.
|
||||
R->address = *(void**)R->address;
|
||||
if ( R->address == NULL) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Reference (%s) address is NULL in ref_dim.\n", R->reference) ;
|
||||
std::stringstream message;
|
||||
message << "Reference (" << R->reference << ") address is NULL in ref_dim.";
|
||||
emitError(message.str());
|
||||
return(TRICK_PARAMETER_ADDRESS_NULL) ;
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,13 @@
|
||||
(Initial Release.))) */
|
||||
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/MemoryManager/include/attributes.h"
|
||||
#include "sim_services/MemoryManager/include/reference.h"
|
||||
#include "sim_services/MemoryManager/include/parameter_types.h"
|
||||
#include "sim_services/MemoryManager/include/mm_error.h"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
|
||||
//FIXME TODO make a error file
|
||||
/////// MM_NO_ERROR 0
|
||||
@ -33,9 +32,11 @@ int Trick::MemoryManager::ref_name(REF2 * R, char *name) {
|
||||
}
|
||||
|
||||
if (R->address == NULL) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Since the value of the pointer \"%s\" is NULL,\n"
|
||||
" a legitimate address can't be calculated for \"%s.%s\" in ref_name.\n",
|
||||
R->reference, R->reference, name);
|
||||
std::stringstream message;
|
||||
message << "ref_name: Because the address of \"" << R->reference
|
||||
<< "\" is NULL, a legitimate address can't be calculated for \""
|
||||
<< R->reference << "." << name << "\".";
|
||||
emitError(message.str());
|
||||
return (MM_PARAMETER_NAME);
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,6 @@
|
||||
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/CheckPointAgent/include/ClassicCheckPointAgent.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
|
||||
int Trick::MemoryManager::read_checkpoint( std::istream *is) {
|
||||
|
||||
@ -19,7 +17,8 @@ int Trick::MemoryManager::read_checkpoint( std::istream *is) {
|
||||
}
|
||||
|
||||
if (currentCheckPointAgent->restore( is) !=0 ) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Checkpoint restore failed.\n") ;
|
||||
std::stringstream;
|
||||
emitError("Checkpoint restore failed.") ;
|
||||
}
|
||||
|
||||
// Go through all of the allocations that have been created looking
|
||||
@ -60,7 +59,9 @@ int Trick::MemoryManager::read_checkpoint(const char* filename ) {
|
||||
if (infile.is_open()) {
|
||||
return ( read_checkpoint( &infile ));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Couldn't open \"%s\".\n", filename) ;
|
||||
std::stringstream message;
|
||||
message << "Couldn't open \"" << filename << "\".";
|
||||
emitError(message.str());
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -80,7 +81,7 @@ int Trick::MemoryManager::read_checkpoint_from_string(const char* s ) {
|
||||
}
|
||||
return ( read_checkpoint( &ss ));
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Checkpoint string is NULL.\n") ;
|
||||
emitError("Checkpoint string is NULL.") ;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
|
||||
Trick::CheckPointAgent * Trick::MemoryManager::get_CheckPointAgent() {
|
||||
return currentCheckPointAgent ;
|
||||
@ -11,7 +9,7 @@ void Trick::MemoryManager::set_CheckPointAgent(CheckPointAgent* agent) {
|
||||
if (agent != NULL) {
|
||||
currentCheckPointAgent = agent;
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Attempt to set CheckPointAgent to NULL.\n") ;
|
||||
emitError("Attempt to set CheckPointAgent to NULL.\n") ;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string.h>
|
||||
#include <stdlib.h> // free()
|
||||
#include <algorithm> // std::sort()
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
|
||||
// GreenHills stuff
|
||||
#if ( __ghs )
|
||||
@ -43,7 +42,7 @@ void Trick::MemoryManager::write_checkpoint( std::ostream& out_s, std::vector<AL
|
||||
/** @b NOTE: We should not write declarations for external
|
||||
anonymous variables, because we should not reload them.*/
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager INTERNAL ERROR: Allocation storage class is messed up.\n") ;
|
||||
emitError("write_checkpoint: This is bad. ALLOC_INFO object is messed up.\n") ;
|
||||
}
|
||||
} else {
|
||||
currentCheckPointAgent->write_decl( out_s, alloc_info);
|
||||
@ -111,7 +110,9 @@ void Trick::MemoryManager::write_checkpoint(const char* filename) {
|
||||
if (outfile.is_open()) {
|
||||
write_checkpoint( outfile);
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: Couldn't open \"%s\".\n", filename) ;
|
||||
std::stringstream message;
|
||||
message << "Couldn't open \"" << filename << "\".";
|
||||
emitError(message.str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,8 +137,9 @@ void Trick::MemoryManager::write_checkpoint(const char* filename, const char* va
|
||||
if (out_s.is_open()) {
|
||||
write_checkpoint( out_s, var_name);
|
||||
} else {
|
||||
std::cerr << "ERROR: Couldn't open \""<< filename <<"\"." << std::endl;
|
||||
std::cerr.flush();
|
||||
std::stringstream message;
|
||||
message << "Couldn't open \"" << filename << "\".";
|
||||
emitError(message.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string.h>
|
||||
#include "sim_services/MemoryManager/include/MemoryManager.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
|
||||
// GreenHills stuff
|
||||
#if ( __ghs )
|
||||
@ -16,7 +15,7 @@ void Trick::MemoryManager::write_composite_var( std::ostream& out_s,
|
||||
ATTRIBUTES* attr_list) {
|
||||
|
||||
if (attr_list == NULL) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: attr_list = NULL in write_composite_var.\n") ;
|
||||
emitError("write_composite_var: attr_list = NULL.") ;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -52,7 +51,7 @@ void Trick::MemoryManager::write_array_var( std::ostream& out_s,
|
||||
int offset) {
|
||||
|
||||
if (attr == NULL) {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: attr = NULL in write_array_var().\n") ;
|
||||
emitError("write_array_var: attr_list = NULL.") ;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -141,8 +140,9 @@ void Trick::MemoryManager::write_var( std::ostream& out_s, const char* var_name
|
||||
alloc_info = pos->second;
|
||||
write_var( out_s, alloc_info );
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: write_var(\"%s\") failed "
|
||||
"because the given name isn't known by the MemoryManager.", var_name) ;
|
||||
std::stringstream message;
|
||||
message << "write_var(\"" << var_name << "\") failed. No such variable is being managed.";
|
||||
emitError(message.str());
|
||||
}
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
}
|
||||
@ -157,8 +157,9 @@ void Trick::MemoryManager::write_var( std::ostream& out_s, void* address) {
|
||||
if (alloc_info != NULL) {
|
||||
write_var( out_s, alloc_info );
|
||||
} else {
|
||||
message_publish(MSG_ERROR, "Memory Manager ERROR: write_var(%p) failed "
|
||||
"because no variable is being managed at that address.\n", address) ;
|
||||
std::stringstream message;
|
||||
message << "write_var(" << address << ") failed. No such variable is being managed.";
|
||||
emitError(message.str());
|
||||
}
|
||||
pthread_mutex_unlock(&mm_mutex);
|
||||
}
|
||||
|
@ -18,8 +18,6 @@
|
||||
#include "sim_services/MemoryManager/include/value.h"
|
||||
#include "sim_services/MemoryManager/include/var.h"
|
||||
#include "sim_services/MemoryManager/include/ADefParseContext.hh"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
#include "adef_parser.tab.h"
|
||||
|
||||
using namespace std;
|
||||
@ -27,7 +25,9 @@
|
||||
int ADEF_lex( YYSTYPE* lvalp, YYLTYPE* llocp, void* scanner );
|
||||
|
||||
void ADEF_error( YYLTYPE* locp, Trick::ADefParseContext* context, const char* err) {
|
||||
message_publish(MSG_ERROR, "Memory Manager adef_parser PARSE-ERROR %d : %s\n", locp->first_line, err) ;
|
||||
std::stringstream message;
|
||||
message << "adef_parser PARSE-ERROR " << locp->first_line << ": " << err << ".";
|
||||
Trick::MemoryManager::emitError(message.str());
|
||||
}
|
||||
|
||||
#define scanner context->scanner
|
||||
|
@ -18,8 +18,6 @@
|
||||
#include "sim_services/MemoryManager/include/vval.h"
|
||||
#include "sim_services/MemoryManager/include/value.h"
|
||||
#include "sim_services/MemoryManager/include/var.h"
|
||||
#include "sim_services/Message/include/message_proto.h"
|
||||
#include "sim_services/Message/include/message_type.h"
|
||||
#include "ref_parser.tab.h"
|
||||
|
||||
using namespace std;
|
||||
@ -27,10 +25,9 @@
|
||||
int REF_lex( YYSTYPE* lvalp, YYLTYPE* llocp, void* scanner );
|
||||
|
||||
void REF_error( YYLTYPE* locp, RefParseContext* context __attribute__ ((unused)) , const char* err) {
|
||||
std::stringstream ss;
|
||||
ss << "MemoryManager ERROR: Syntax error " << locp->first_line << " : " << err
|
||||
<< std::endl;
|
||||
message_publish(MSG_ERROR, ss.str().c_str() );
|
||||
std::stringstream message;
|
||||
message << "Syntax error: " << locp->first_line << " : " << err ;
|
||||
Trick::MemoryManager::emitError(message.str());
|
||||
}
|
||||
|
||||
#define scanner context->scanner
|
||||
@ -94,11 +91,9 @@ param: NAME {
|
||||
$$.ref_type = REF_ADDRESS;
|
||||
$$.create_add_path = 1 ;
|
||||
$$.address_path = DLL_Create() ;
|
||||
|
||||
// Get the address and attrs of the variable.
|
||||
|
||||
// Get the address and attrs of the variable.
|
||||
if ((ret = context->mem_mgr->ref_var( &$$, $1)) != MM_OK) {
|
||||
//don't print error, because var_exists command relies on this call
|
||||
//message_publish(MSG_ERROR, "Memory Manager ERROR: Call to ref_var( R, %s) failed.\n", $1);
|
||||
return ( ret);
|
||||
}
|
||||
// save the reference attributes allocated by ref_var so we can delete it after ref_name is called.
|
||||
@ -109,7 +104,7 @@ param: NAME {
|
||||
|
||||
}
|
||||
| '&' NAME {
|
||||
/*
|
||||
/*
|
||||
* This rule handles the first name with a preceding address character.
|
||||
* Only parameters and vars are allowed to have a preceding "&" char.
|
||||
*/
|
||||
@ -123,13 +118,12 @@ param: NAME {
|
||||
$$.ref_type = REF_ADDRESS;
|
||||
$$.create_add_path = 1 ;
|
||||
$$.address_path = DLL_Create() ;
|
||||
|
||||
// Get the address and attrs of the variable.
|
||||
|
||||
// Get the address and attrs of the variable.
|
||||
if ((ret = context->mem_mgr->ref_var( &$$, $2)) != MM_OK) {
|
||||
std::stringstream ss;
|
||||
ss << "MemoryManager ERROR: Invalid reference: \"" << $2 << "\"."
|
||||
<< std::endl;
|
||||
message_publish(MSG_ERROR, ss.str().c_str() );
|
||||
std::stringstream message;
|
||||
message << "MemoryManager ERROR: Invalid reference: \"" << $2 << "\".";
|
||||
Trick::MemoryManager::emitError(message.str());
|
||||
return ( ret);
|
||||
}
|
||||
// save the reference attributes allocated by ref_var so we can delete it after ref_name is called.
|
||||
@ -162,10 +156,9 @@ param: NAME {
|
||||
|
||||
/* Check to see if previous parameter specified enough dimensions. */
|
||||
if ($$.num_index != $$.attr->num_index) {
|
||||
std::stringstream ss;
|
||||
ss << "Memory Manager ERROR: Dimension mismatch."
|
||||
<< std::endl;
|
||||
message_publish(MSG_ERROR, ss.str().c_str() );
|
||||
std::stringstream message;
|
||||
message << "Dimension mismatch.";
|
||||
Trick::MemoryManager::emitError(message.str());
|
||||
return (MM_PARAMETER_ARRAY_DIM);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user