Add direct STL checkpointing

The typenames on the Mac need to be converted for strings.  The
templates are genererating the long form of the string type name.  I
wrote a function to catch test the template parameter types and
return std::string.

refs #206
This commit is contained in:
Alex Lin 2016-03-31 15:48:19 -05:00
parent c8a39f4a44
commit c1eb4e6fc5
7 changed files with 47 additions and 13 deletions

View File

@ -19,6 +19,7 @@
#endif
#include "checkpoint_is_stl_container.hh"
#include "checkpoint_stl_protos.hh"
#include "checkpoint_fwd_declare.hh"
#include "trick/memorymanager_c_intf.h"
#include "trick/message_proto.h"
@ -50,7 +51,8 @@ int checkpoint_map_ik_id(STL & in_map , std::string object_name , std::string va
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
var_declare << abi::__cxa_demangle(typeid(*keys).name(), 0, 0, &status ) << " "
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*keys).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "_keys[" << cont_size << "]" ;
keys = (typename STL::key_type *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ;
@ -58,7 +60,8 @@ int checkpoint_map_ik_id(STL & in_map , std::string object_name , std::string va
var_declare.str("") ;
var_declare.clear() ;
var_declare << abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ) << " "
type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "_data[" << cont_size << "]" ;
items = (typename STL::mapped_type *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ;
@ -104,7 +107,8 @@ int checkpoint_map_ik_sd(STL & in_map , std::string object_name , std::string va
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
var_declare << abi::__cxa_demangle(typeid(*keys).name(), 0, 0, &status ) << " "
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*keys).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "_keys[" << cont_size << "]" ;
keys = (typename STL::key_type *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ;
@ -174,7 +178,8 @@ int checkpoint_map_sk_id(STL & in_map , std::string object_name , std::string va
var_declare.str("") ;
var_declare.clear() ;
var_declare << abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ) << " "
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "_data[" << cont_size << "]" ;
items = (typename STL::mapped_type *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ;

View File

@ -18,6 +18,7 @@
#endif
#include "checkpoint_is_stl_container.hh"
#include "checkpoint_stl_protos.hh"
#include "checkpoint_fwd_declare.hh"
#include "trick/memorymanager_c_intf.h"
#include "trick/message_proto.h"
@ -33,7 +34,8 @@ int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name
SECOND * second = nullptr ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
var_declare << abi::__cxa_demangle(typeid(*first).name(), 0, 0, &status ) << " "
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*first).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "_first[1]" ;
first = (FIRST *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_first").c_str()) ;
@ -41,7 +43,8 @@ int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name
var_declare.str("") ;
var_declare.clear() ;
var_declare << abi::__cxa_demangle(typeid(*second).name(), 0, 0, &status ) << " "
type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*second).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "_second[1]" ;
second = (SECOND *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_second").c_str()) ;
@ -62,7 +65,8 @@ int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name
std::string * second = nullptr ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
var_declare << abi::__cxa_demangle(typeid(*first).name(), 0, 0, &status ) << " "
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*first).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "_first[1]" ;
first = (FIRST *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_first").c_str()) ;
@ -99,7 +103,8 @@ int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name
var_declare.str("") ;
var_declare.clear() ;
var_declare << abi::__cxa_demangle(typeid(*second).name(), 0, 0, &status ) << " "
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*second).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "_second[1]" ;
second = (SECOND *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_second").c_str()) ;

View File

@ -17,6 +17,7 @@
#endif
#include "checkpoint_is_stl_container.hh"
#include "checkpoint_stl_protos.hh"
#include "checkpoint_fwd_declare.hh"
#include "checkpoint_sequence_stl.hh"
#include "trick/memorymanager_c_intf.h"
@ -42,7 +43,8 @@ int checkpoint_stl(std::queue<ITEM_TYPE,_Sequence> & in_stl , std::string object
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
var_declare << abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ) << " "
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
items = (ITEM_TYPE *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;
@ -110,7 +112,8 @@ int checkpoint_stl(std::priority_queue<ITEM_TYPE, _Container, _Compare> & in_stl
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
var_declare << abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ) << " "
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
items = (ITEM_TYPE *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;

View File

@ -20,6 +20,7 @@
#endif
#include "checkpoint_is_stl_container.hh"
#include "checkpoint_stl_protos.hh"
#include "checkpoint_fwd_declare.hh"
#include "trick/memorymanager_c_intf.h"
#include "trick/message_proto.h"
@ -44,8 +45,8 @@ int checkpoint_sequence_i(STL & in_stl , std::string object_name , std::string v
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
var_declare << abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ) << " "
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
items = (typename STL::value_type *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;

View File

@ -17,6 +17,7 @@
#endif
#include "trick/checkpoint_sequence_stl.hh"
#include "checkpoint_stl_protos.hh"
#include "trick/memorymanager_c_intf.h"
#include "trick/message_proto.h"
@ -39,7 +40,8 @@ int checkpoint_stl(std::stack<ITEM_TYPE,_Sequence> & in_stl , std::string object
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
var_declare << abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ) << " "
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
items = (ITEM_TYPE *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;

View File

@ -0,0 +1,7 @@
#include <string>
// prototype of functions used in checkpoint_stl templates
std::string stl_type_name_convert(std::string in_type) ;

View File

@ -0,0 +1,11 @@
#include <string>
std::string stl_type_name_convert(std::string in_type) {
std::string type_string(in_type) ;
std::string basic_string("std::__1::basic_string") ;
if ( !type_string.compare(0, basic_string.length(), basic_string)) {
type_string = "std::string" ;
}
return type_string ;
}