Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set previous ignored after callback #82

Open
wants to merge 2 commits into
base: rolling
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ struct MemoryToolsService
void
unignore();

// Return ignored or not.
OSRF_TESTING_TOOLS_CPP_MEMORY_TOOLS_PUBLIC
bool
get_ignored();

/// Adds a backtrace to the log message.
/** Repeated calls do nothing, and only prints if a log is also printed. */
OSRF_TESTING_TOOLS_CPP_MEMORY_TOOLS_PUBLIC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ MemoryToolsService::unignore()
impl_->ignored = false;
}

bool
MemoryToolsService::get_ignored()
{
return impl_->ignored;
}

void
MemoryToolsService::print_backtrace()
{
Expand Down
32 changes: 28 additions & 4 deletions osrf_testing_tools_cpp/src/memory_tools/testing_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ on_unexpected_malloc(AnyMemoryToolsCallback callback)
on_malloc(
[callback](MemoryToolsService & service) {
if (g_malloc_unexpected.load()) {
service.unignore();
bool ignored = service.get_ignored();
if (ignored) {
service.unignore();
}
dispatch_callback(&callback, service);
if (ignored) {
service.ignore();
}
}
});
}
Expand Down Expand Up @@ -62,8 +68,14 @@ on_unexpected_realloc(AnyMemoryToolsCallback callback)
on_realloc(
[callback](MemoryToolsService & service) {
if (g_realloc_unexpected.load()) {
service.unignore();
bool ignored = service.get_ignored();
if (ignored) {
service.unignore();
}
dispatch_callback(&callback, service);
if (ignored) {
service.ignore();
}
}
});
}
Expand Down Expand Up @@ -92,8 +104,14 @@ on_unexpected_calloc(AnyMemoryToolsCallback callback)
on_calloc(
[callback](MemoryToolsService & service) {
if (g_calloc_unexpected.load()) {
service.unignore();
bool ignored = service.get_ignored();
if (ignored) {
service.unignore();
}
dispatch_callback(&callback, service);
if (ignored) {
service.ignore();
}
}
});
}
Expand Down Expand Up @@ -122,8 +140,14 @@ on_unexpected_free(AnyMemoryToolsCallback callback)