Skip to content

Commit

Permalink
chore: put throws in separate function for debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
gebner committed Jan 23, 2023
1 parent 34777c9 commit 345aa6f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/runtime/interrupt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ void set_max_heartbeat_thousands(unsigned max) { g_max_heartbeat = static_cast<s
scope_heartbeat::scope_heartbeat(size_t max):flet<size_t>(g_heartbeat, max) {}
scope_max_heartbeat::scope_max_heartbeat(size_t max):flet<size_t>(g_max_heartbeat, max) {}

// separate definition to allow breakpoint in debugger
void throw_heartbeat_exception() {
throw heartbeat_exception();
}

void check_heartbeat() {
inc_heartbeat();
if (g_max_heartbeat > 0 && g_heartbeat > g_max_heartbeat)
throw heartbeat_exception();
throw_heartbeat_exception();
}

LEAN_THREAD_VALUE(atomic_bool *, g_interrupt_flag, nullptr);
Expand Down
7 changes: 6 additions & 1 deletion src/runtime/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ void set_max_memory_megabyte(unsigned max) {
set_max_memory(m);
}

// separate definition to allow breakpoint in debugger
void throw_memory_exception(char const * component_name) {
throw memory_exception(component_name);
}

void check_memory(char const * component_name) {
if (g_max_memory == 0) return;
g_counter++;
Expand All @@ -135,7 +140,7 @@ void check_memory(char const * component_name) {
if (r > 0 && r < g_max_memory) return;
r = get_current_rss();
if (r == 0 || r < g_max_memory) return;
throw memory_exception(component_name);
throw_memory_exception(component_name);
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/runtime/stackinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,18 @@ size_t get_available_stack_size() {
return g_stack_size - sz;
}

// separate definition to allow breakpoint in debugger
void throw_stack_space_exception(char const * component_name) {
throw stack_space_exception(component_name);
}

void check_stack(char const * component_name) {
if (!g_stack_info_init)
save_stack_info(false);
char y;
size_t curr_stack = reinterpret_cast<size_t>(&y);
if (curr_stack < g_stack_threshold)
throw stack_space_exception(component_name);
throw_stack_space_exception(component_name);
}
}
#endif

0 comments on commit 345aa6f

Please sign in to comment.