From 8ee64b5666cf9d1dc308ff629bd4c7ef14b0c96a Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Sat, 10 Aug 2024 16:43:43 -0400 Subject: [PATCH] debug changes --- CMakeLists.txt | 2 +- include/blt/gp/operations.h | 28 ++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bdf3ee..c8a68df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(blt-gp VERSION 0.0.128) +project(blt-gp VERSION 0.0.129) include(CTest) diff --git a/include/blt/gp/operations.h b/include/blt/gp/operations.h index 799d833..c2ed5a9 100644 --- a/include/blt/gp/operations.h +++ b/include/blt/gp/operations.h @@ -83,12 +83,17 @@ namespace blt::gp return offset; } + template + void print_args(std::integer_sequence) + { + BLT_INFO("Arguments:"); + (BLT_INFO("%ld: %s", indices, blt::type_string().c_str()), ...); + } + template inline static constexpr Return exec_sequence_to_indices(Func&& func, stack_allocator& allocator, std::integer_sequence, ExtraArgs&& ... args) { - //BLT_INFO("Arguments:"); - //(BLT_INFO("%ld: %s", indices, blt::type_string().c_str()) , ...); //blt::size_t arg_size = (stack_allocator::aligned_size>() + ...); //BLT_TRACE(arg_size); // expands Args and indices, providing each argument with its index calculating the current argument byte offset @@ -100,10 +105,21 @@ namespace blt::gp Return operator()(Func&& func, stack_allocator& read_allocator, ExtraArgs&& ... args) { constexpr auto seq = std::make_integer_sequence(); - Return ret = exec_sequence_to_indices(std::forward(func), read_allocator, seq, std::forward(args)...); - read_allocator.call_destructors...>(); - read_allocator.pop_bytes((stack_allocator::aligned_size>() + ...)); - return ret; +#if BLT_DEBUG_LEVEL > 0 + try + { +#endif + Return ret = exec_sequence_to_indices(std::forward(func), read_allocator, seq, std::forward(args)...); + read_allocator.call_destructors...>(); + read_allocator.pop_bytes((stack_allocator::aligned_size>() + ...)); + return ret; +#if BLT_DEBUG_LEVEL > 0 + } catch (const std::runtime_error& e) + { + print_args(seq); + throw std::runtime_error(e.what()); + } +#endif } };