From: Arnaud Giersch Date: Fri, 23 Jul 2021 08:44:27 +0000 (+0200) Subject: Define a macro for debug messages. X-Git-Tag: v3.29~183 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f83d3fa0d3a4d560373b375c5350fa82def12788 Define a macro for debug messages. --- diff --git a/src/xbt/memory_map.cpp b/src/xbt/memory_map.cpp index b3ea8b17f2..fccfac8a5a 100644 --- a/src/xbt/memory_map.cpp +++ b/src/xbt/memory_map.cpp @@ -59,6 +59,12 @@ } else \ ((void)0) +#define DEBUG_PRINT(...) \ + if (false) { \ + fprintf(stderr, __VA_ARGS__); \ + } else \ + ((void)0) + namespace simgrid { namespace xbt { @@ -155,10 +161,9 @@ std::vector get_memory_map(pid_t pid) if (dladdr(reinterpret_cast(address), &dlinfo)) memreg.pathname = dlinfo.dli_fname; - if (false) // debug - std::fprintf(stderr, "Region: %016" PRIx64 "-%016" PRIx64 " | %c%c%c | %s\n", memreg.start_addr, memreg.end_addr, - (memreg.prot & PROT_READ) ? 'r' : '-', (memreg.prot & PROT_WRITE) ? 'w' : '-', - (memreg.prot & PROT_EXEC) ? 'x' : '-', memreg.pathname.c_str()); + DEBUG_PRINT("Region: %016" PRIx64 "-%016" PRIx64 " | %c%c%c | %s\n", memreg.start_addr, memreg.end_addr, + (memreg.prot & PROT_READ) ? 'r' : '-', (memreg.prot & PROT_WRITE) ? 'w' : '-', + (memreg.prot & PROT_EXEC) ? 'x' : '-', memreg.pathname.c_str()); ret.push_back(std::move(memreg)); address += size; @@ -289,8 +294,7 @@ std::vector get_memory_map(pid_t pid) /* Create space for a new map region in the region's array and copy the */ /* parsed stuff from the temporal memreg variable */ - if (false) // debug - std::fprintf(stderr, "Found region for %s\n", not memreg.pathname.empty() ? memreg.pathname.c_str() : "(null)"); + DEBUG_PRINT("Found region for \"%s\"\n", memreg.pathname.c_str()); ret.push_back(std::move(memreg)); }