rlovelett
(Ryan Lovelett)
May 11, 2018, 2:35am
1
I am trying to debug Dispatch to see what is causing a bug I've stumbled into .
I've actually got a debug build of libdispatch made and am able to step through it with lldb
.
I was wondering how I go about enabling some of the logging in libdispatch.
I'm not sure what or how I would send to the Swift build-script
to get that part of the compilation turned on.
rlovelett
(Ryan Lovelett)
May 11, 2018, 1:26pm
2
I've added libdispatch-cmake-options=-DDISPATCH_ENABLE_ASSERTS=1 -DDISPATCH_DEBUG=1 -DDISPATCH_IO_DEBUG=1
to my .swift-build-presets
and I see it showing up the arguments sent to the libdispatch compiler. Though I'm still not seeing any logs actually being written.
I think you need to set LIBDISPATCH_LOG in your environment when you are running the program as well.
static dispatch_once_t _dispatch_logv_pred;
static void
_dispatch_logv_init(void *context DISPATCH_UNUSED)
{
#if DISPATCH_DEBUG
bool log_to_file = true;
#else
bool log_to_file = false;
#endif
char *e = getenv("LIBDISPATCH_LOG");
if (e) {
if (strcmp(e, "YES") == 0) {
// default
} else if (strcmp(e, "NO") == 0) {
dispatch_log_disabled = true;
} else if (strcmp(e, "syslog") == 0) {
log_to_file = false;
} else if (strcmp(e, "file") == 0) {
log_to_file = true;
} else if (strcmp(e, "stderr") == 0) {
1 Like
rlovelett
(Ryan Lovelett)
May 11, 2018, 2:53pm
4
LIBDISPATCH_LOG=stderr ./test
Thank you @dgrove-oss