From fb7432d096b4b22c02a78f2e61deb7aef6eab288 Mon Sep 17 00:00:00 2001 From: Alex Lin Date: Mon, 4 Apr 2016 15:07:57 -0500 Subject: [PATCH] Add direct STL checkpointing Modified ICG to save the non-canonical name for STLs. This is typically more readable because it is shorter. Added code to the variable server to filter out requests accessing STLs, because those accesses will not currently work. refs #206 --- include/trick/VariableServerThread.hh | 3 +++ include/trick/checkpoint_stl_protos.hh | 4 ++++ include/trick/stl_s_define_macro.hh | 9 --------- .../codegen/Interface_Code_Gen/FieldDescription.cpp | 8 ++++++++ .../codegen/Interface_Code_Gen/FieldDescription.hh | 7 ++++++- .../codegen/Interface_Code_Gen/FieldVisitor.cpp | 6 +++++- .../VariableServer/VariableServerThread_commands.cpp | 10 ++++++++++ 7 files changed, 36 insertions(+), 11 deletions(-) delete mode 100644 include/trick/stl_s_define_macro.hh diff --git a/include/trick/VariableServerThread.hh b/include/trick/VariableServerThread.hh index da10e285..ab8579a5 100644 --- a/include/trick/VariableServerThread.hh +++ b/include/trick/VariableServerThread.hh @@ -479,6 +479,9 @@ namespace Trick { /** Dummy integer for bad references.\n */ static int bad_ref_int ; /**< trick_io(**) */ + /** Dummy integer for bad references. If a variable points here, do not try to re-resolve address\n */ + static int do_not_resolve_bad_ref_int ; /**< trick_io(**) */ + /** The simulation time converted to seconds\n */ double time ; /**< trick_units(s) */ diff --git a/include/trick/checkpoint_stl_protos.hh b/include/trick/checkpoint_stl_protos.hh index b72c29fa..8cb6455c 100644 --- a/include/trick/checkpoint_stl_protos.hh +++ b/include/trick/checkpoint_stl_protos.hh @@ -1,7 +1,11 @@ +#ifndef CHECKPOINT_STL_PROTOS_HH +#define CHECKPOINT_STL_PROTOS_HH + #include // prototype of functions used in checkpoint_stl templates std::string stl_type_name_convert(std::string in_type) ; +#endif diff --git a/include/trick/stl_s_define_macro.hh b/include/trick/stl_s_define_macro.hh deleted file mode 100644 index 0601946c..00000000 --- a/include/trick/stl_s_define_macro.hh +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef STL_S_DEFINE_MACRO_HH -#define STL_S_DEFINE_MACRO_HH - -#define CHECKPOINT_STL(varname) \ - ("checkpoint") checkpoint_stl(varname, name + std::string("_") + std::string(#varname), std::string("")) ; \ - ("post_checkpoint") delete_stl (varname, name + std::string("_") + std::string(#varname), std::string("")) ; \ - ("restart") restore_stl (varname, name + std::string("_") + std::string(#varname), std::string("")) - -#endif diff --git a/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp b/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp index 7704b8cd..19fb361f 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp @@ -251,6 +251,14 @@ unsigned int FieldDescription::getBaseClassOffset() { return base_class_offset ; } +void FieldDescription::setNonCanonicalTypeName( std::string in_val ) { + non_canonical_type_name = in_val ; +} + +std::string FieldDescription::getNonCanonicalTypeName() { + return non_canonical_type_name ; +} + void FieldDescription::setTypeName( std::string in_val ) { type_name = in_val ; } diff --git a/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh b/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh index 5335d68f..2c3e5db5 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh +++ b/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh @@ -43,6 +43,8 @@ class FieldDescription : public ConstructValues { std::string getContainerClass() ; void setContainerClass( std::string in_name ) ; unsigned int getBaseClassOffset() ; + void setNonCanonicalTypeName( std::string in_val ) ; + std::string getNonCanonicalTypeName() ; void setTypeName( std::string in_val ) ; std::string getTypeName() ; void setLineNo( unsigned int ) ; @@ -99,7 +101,10 @@ class FieldDescription : public ConstructValues { be added to field offset */ unsigned int base_class_offset ; - /** Name of the type */ + /** Name of the type. Non-canonical. It's what was actually read in input file */ + std::string non_canonical_type_name ; + + /** Name of the type, will be canonical, resolving all typedefs and adding default template args */ std::string type_name ; /** Name of the type */ diff --git a/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp b/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp index 08c61e8e..96e7e418 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp @@ -217,6 +217,7 @@ bool FieldVisitor::VisitFieldDecl( clang::FieldDecl *field ) { //field->dump() ; } if ( !qt.isCanonical() ) { + fdes->setNonCanonicalTypeName(qt.getAsString()) ; clang::QualType ct = qt.getCanonicalType() ; std::string tst_string = ct.getAsString() ; if ( debug_level >= 3 ) { @@ -377,7 +378,10 @@ bool FieldVisitor::VisitRecordType(clang::RecordType *rt) { fdes->setSTL(true) ; fdes->setTypeName(tst_string) ; fdes->setSTLClear((*it).second) ; - fdes->setMangledTypeName(mangle_string(tst_string)) ; + // set the type name to the non canonical name, the name the user put in the header file + // The typename is not used by STL variables, and it is nice to see the type that was + // actually inputted by the user + fdes->setMangledTypeName(fdes->getNonCanonicalTypeName()) ; return false ; } } diff --git a/trick_source/sim_services/VariableServer/VariableServerThread_commands.cpp b/trick_source/sim_services/VariableServer/VariableServerThread_commands.cpp index 56955d1c..c740858a 100644 --- a/trick_source/sim_services/VariableServer/VariableServerThread_commands.cpp +++ b/trick_source/sim_services/VariableServer/VariableServerThread_commands.cpp @@ -15,6 +15,7 @@ #include "trick/sie_c_intf.h" int Trick::VariableServerThread::bad_ref_int = 0 ; +int Trick::VariableServerThread::do_not_resolve_bad_ref_int = 0 ; REF2* Trick::VariableServerThread::make_time_ref() { REF2* new_ref; @@ -62,6 +63,15 @@ int Trick::VariableServerThread::var_add(std::string in_name) { // Replace the REF2 object we got from ref_attributes with an error-ref. free(new_ref); new_ref = make_error_ref(in_name); + // set the address of the data to the do_not_resolve address. We won't retry resolving the name + new_ref->address = (char *)&do_not_resolve_bad_ref_int ; + } else if ( new_ref->attr->type == TRICK_STL ) { + message_publish(MSG_ERROR, "Variable Server: var_add cant add \"%s\" because its an STL variable.\n", in_name.c_str()); + // Replace the REF2 object we got from ref_attributes with an error-ref. + free(new_ref); + new_ref = make_error_ref(in_name); + // set the address of the data to the do_not_resolve address. We won't retry resolving the name + new_ref->address = (char *)&do_not_resolve_bad_ref_int ; } } else { message_publish(MSG_ERROR, "Variable Server: BAD MOJO - Missing ATTRIBUTES.");