Skip to content

Fixes to enable DISPATCH_DEBUG on Linux #33

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

Merged
merged 1 commit into from
Feb 4, 2016
Merged
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
6 changes: 3 additions & 3 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ _dispatch_logv_init(void *context DISPATCH_UNUSED)
struct timeval tv;
gettimeofday(&tv, NULL);
#if DISPATCH_DEBUG
dispatch_log_basetime = mach_absolute_time();
dispatch_log_basetime = _dispatch_absolute_time();
#endif
dprintf(dispatch_logfile, "=== log file opened for %s[%u] at "
"%ld.%06u ===\n", getprogname() ?: "", getpid(),
Expand Down Expand Up @@ -559,7 +559,7 @@ _dispatch_logv_file(const char *msg, va_list ap)

#if DISPATCH_DEBUG
offset += dsnprintf(&buf[offset], bufsiz - offset, "%llu\t",
mach_absolute_time() - dispatch_log_basetime);
_dispatch_absolute_time() - dispatch_log_basetime);
#endif
r = vsnprintf(&buf[offset], bufsiz - offset, msg, ap);
if (r < 0) return;
Expand Down Expand Up @@ -656,7 +656,7 @@ _dispatch_debugv(dispatch_object_t dou, const char *msg, va_list ap)
int r;
#if DISPATCH_DEBUG && !DISPATCH_USE_OS_DEBUG_LOG
offset += dsnprintf(&buf[offset], bufsiz - offset, "%llu\t\t%p\t",
mach_absolute_time() - dispatch_log_basetime,
_dispatch_absolute_time() - dispatch_log_basetime,
(void *)_dispatch_thread_self());
#endif
if (dou._do) {
Expand Down
4 changes: 4 additions & 0 deletions src/shims/linux_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,9 @@ unsigned short dispatch_timer__program_semaphore;
unsigned short dispatch_timer__wake_semaphore;
unsigned short dispatch_timer__fire_semaphore;
unsigned short dispatch_timer__configure_semaphore;
unsigned short dispatch_queue__pop_semaphore;
unsigned short dispatch_callout__entry_semaphore;
unsigned short dispatch_callout__return_semaphore;
unsigned short dispatch_queue__push_semaphore;
void (*_dispatch_block_special_invoke)(void*);
struct dispatch_queue_attr_s _dispatch_queue_attr_concurrent;
13 changes: 12 additions & 1 deletion src/source.c
Original file line number Diff line number Diff line change
Expand Up @@ -4707,8 +4707,12 @@ _evflagstr2(uint16_t *flagsp)
_evflag2(EV_RECEIPT);
_evflag2(EV_DISPATCH);
_evflag2(EV_UDATA_SPECIFIC);
#ifdef EV_POLL
_evflag2(EV_POLL);
#endif
#ifdef EV_OOBAND
_evflag2(EV_OOBAND);
#endif
_evflag2(EV_ERROR);
_evflag2(EV_EOF);
*flagsp = 0;
Expand Down Expand Up @@ -4816,7 +4820,12 @@ _dispatch_kevent_debug(const _dispatch_kevent_qos_s* kev, const char* str)
"ext[0] = 0x%llx, ext[1] = 0x%llx }: %s", kev, kev->ident,
_evfiltstr(kev->filter), _evflagstr(kev->flags, flagstr,
sizeof(flagstr)), kev->flags, kev->fflags, kev->data, kev->udata,
kev->ext[0], kev->ext[1], str);
#if DISPATCH_USE_KEVENT_QOS
kev->ext[0], kev->ext[1],
#else
0ull, 0ull,
#endif
str);
}

static void
Expand Down Expand Up @@ -4921,9 +4930,11 @@ _dispatch_kevent_debugger(void *context DISPATCH_UNUSED)
int val, r, fd, sock_opt = 1;
socklen_t slen = sizeof(sa_u);

#ifndef __linux__
if (issetugid()) {
return;
}
#endif
valstr = getenv("LIBDISPATCH_DEBUGGER");
if (!valstr) {
return;
Expand Down