From ec5216f9e016ee1bd8146e06d0352bcbb00d89b3 Mon Sep 17 00:00:00 2001 From: Jason Hiser <jdhiser@gmail.com> Date: Thu, 1 Nov 2018 18:41:53 +0000 Subject: [PATCH] converted thanos to return shared_ptr, so xform can keep a copy if it needs to Former-commit-id: 4bb9fc0d36a7a3e9dc023be45ab6a1620a08b683 --- libIRDB/include/core/transform_step.h | 2 +- libIRDB/test/fill_in_cfg.cpp | 4 ++-- libIRDB/test/fill_in_indtargs.cpp | 18 ++++++++++-------- tools/thanos/thanos.cpp | 12 ++++++------ 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/libIRDB/include/core/transform_step.h b/libIRDB/include/core/transform_step.h index 5b864c69e..2dc0c50b4 100644 --- a/libIRDB/include/core/transform_step.h +++ b/libIRDB/include/core/transform_step.h @@ -30,6 +30,6 @@ namespace Transform_SDK } extern "C" -std::unique_ptr<Transform_SDK::TransformStep_t> GetTransformStep(void); +std::shared_ptr<Transform_SDK::TransformStep_t> GetTransformStep(void); #endif diff --git a/libIRDB/test/fill_in_cfg.cpp b/libIRDB/test/fill_in_cfg.cpp index 9ffd312fa..554ce87d8 100644 --- a/libIRDB/test/fill_in_cfg.cpp +++ b/libIRDB/test/fill_in_cfg.cpp @@ -664,8 +664,8 @@ int PopulateCFG::executeStep(IRDBObjects_t *const irdb_objects) extern "C" -unique_ptr<Transform_SDK::TransformStep_t> GetTransformStep(void) +shared_ptr<Transform_SDK::TransformStep_t> GetTransformStep(void) { - unique_ptr<Transform_SDK::TransformStep_t> the_step(new PopulateCFG()); + shared_ptr<Transform_SDK::TransformStep_t> the_step(new PopulateCFG()); return the_step; } diff --git a/libIRDB/test/fill_in_indtargs.cpp b/libIRDB/test/fill_in_indtargs.cpp index 3faa5599d..31917f173 100644 --- a/libIRDB/test/fill_in_indtargs.cpp +++ b/libIRDB/test/fill_in_indtargs.cpp @@ -2869,7 +2869,7 @@ int64_t do_unpin_opt=numeric_limits<int64_t>::max() ; db_id_t variant_id=BaseObj_t::NOT_IN_DATABASE; set<virtual_offset_t> forced_pins; -int ParseArgs(int argc, char* argv[]) +int parseArgs(int argc, const char* const argv[]) { auto argc_iter = (int)2; @@ -2941,7 +2941,7 @@ int ParseArgs(int argc, char* argv[]) } -int ExecuteStep(IRDBObjects_t *irdb_objects) +int executeStep(IRDBObjects_t *const irdb_objects) { //VariantID_t *pidp=nullptr; //FileIR_t * firp=nullptr; @@ -3003,7 +3003,7 @@ int ExecuteStep(IRDBObjects_t *irdb_objects) return 0; } -std::string GetStepName(void) override +std::string getStepName(void) const override { return std::string("fill_in_indtargs"); } @@ -3012,25 +3012,27 @@ std::string GetStepName(void) override }; -PopulateIndTargs_t* curInvocation; +shared_ptr<Transform_SDK::TransformStep_t> curInvocation; bool possible_target(virtual_offset_t p, virtual_offset_t from_addr, ibt_provenance_t prov) { assert(curInvocation); - return curInvocation->possible_target(p,from_addr,prov); + return (dynamic_cast<PopulateIndTargs_t*>(curInvocation.get()))->possible_target(p,from_addr,prov); } void range(virtual_offset_t start, virtual_offset_t end) { assert(curInvocation); - return curInvocation->range(start,end); + return (dynamic_cast<PopulateIndTargs_t*>(curInvocation.get()))->range(start,end); } extern "C" -Transform_SDK::TransformStep_t* GetTransformStep(void) +shared_ptr<Transform_SDK::TransformStep_t> GetTransformStep(void) { - curInvocation=new PopulateIndTargs_t(); + curInvocation.reset(new PopulateIndTargs_t()); return curInvocation; + + //return shared_ptr<Transform_SDK::TransformStep_t>(new PopulateIndTargs_t()); } diff --git a/tools/thanos/thanos.cpp b/tools/thanos/thanos.cpp index 8905aa940..7ca7befa0 100644 --- a/tools/thanos/thanos.cpp +++ b/tools/thanos/thanos.cpp @@ -22,7 +22,7 @@ using namespace Transform_SDK; enum class Mode { DEBUG, VERBOSE, DEFAULT }; int execute_step(int argc, char* argv[], bool step_optional, Mode exec_mode, - IRDBObjects_t* shared_objects, unique_ptr<TransformStep_t>& the_step); + IRDBObjects_t* shared_objects, TransformStep_t* the_step); // The toolchain driver script ps_analyze.sh communicates @@ -163,9 +163,9 @@ int main(int argc, char *argv[]) } else { - unique_ptr<TransformStep_t> (*func)(void); - func = (unique_ptr<TransformStep_t> (*)(void)) sym; - unique_ptr<TransformStep_t> the_step = (*func)(); + shared_ptr<TransformStep_t> (*func)(void); + func = (shared_ptr<TransformStep_t> (*)(void)) sym; + shared_ptr<TransformStep_t> the_step = (*func)(); assert(the_step != NULL); bool step_optional = true; @@ -186,7 +186,7 @@ int main(int argc, char *argv[]) dup2(log_output_fd, STDERR_FILENO); } - int step_retval = execute_step(argc, argv, step_optional, exec_mode, shared_objects, the_step); + int step_retval = execute_step(argc, argv, step_optional, exec_mode, shared_objects, the_step.get()); // cleanup from logging if(exec_mode == Mode::DEFAULT || exec_mode == Mode::VERBOSE) @@ -287,7 +287,7 @@ int main(int argc, char *argv[]) int execute_step(int argc, char* argv[], bool step_optional, Mode exec_mode, - IRDBObjects_t* shared_objects, unique_ptr<TransformStep_t>& the_step) + IRDBObjects_t* shared_objects, TransformStep_t* the_step) { int parse_retval = the_step->parseArgs(argc, argv); if(parse_retval != 0) -- GitLab