From f8061e88eaee4973ceb82319cdb987741534dd8f Mon Sep 17 00:00:00 2001
From: ncteisen <ncteisen@gmail.com>
Date: Fri, 9 Jun 2017 10:44:42 -0700
Subject: [PATCH] Fix compile. WIP probably

---
 src/core/lib/iomgr/combiner.c          |  4 ++--
 src/core/lib/iomgr/ev_epollsig_linux.c |  7 ++-----
 src/core/lib/iomgr/ev_poll_posix.c     |  4 ----
 src/core/lib/iomgr/ev_posix.c          |  4 ++++
 src/core/lib/iomgr/ev_posix.h          |  4 ----
 src/core/lib/iomgr/exec_ctx.c          |  4 ++--
 src/core/lib/iomgr/executor.c          |  2 +-
 src/core/lib/iomgr/pollset.h           |  4 ++++
 src/core/lib/iomgr/pollset_uv.c        |  4 ++++
 src/core/lib/iomgr/pollset_windows.c   |  4 ++++
 src/core/lib/iomgr/tcp_windows.c       |  2 +-
 src/core/lib/surface/init.c            | 11 -----------
 12 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/src/core/lib/iomgr/combiner.c b/src/core/lib/iomgr/combiner.c
index 5e88aeed10..7f9c5d837f 100644
--- a/src/core/lib/iomgr/combiner.c
+++ b/src/core/lib/iomgr/combiner.c
@@ -249,7 +249,7 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx *exec_ctx) {
     GPR_TIMER_BEGIN("combiner.exec1", 0);
     grpc_closure *cl = (grpc_closure *)n;
     grpc_error *cl_err = cl->error_data.error;
-#ifdef GRPC_CLOSURE_RICH_DEBUG
+#ifndef NDEBUG
     cl->scheduled = false;
 #endif
     cl->cb(exec_ctx, cl->cb_arg, cl_err);
@@ -266,7 +266,7 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx *exec_ctx) {
           gpr_log(GPR_DEBUG, "C:%p execute_final[%d] c=%p", lock, loops, c));
       grpc_closure *next = c->next_data.next;
       grpc_error *error = c->error_data.error;
-#ifdef GRPC_CLOSURE_RICH_DEBUG
+#ifndef NDEBUG
       c->scheduled = false;
 #endif
       c->cb(exec_ctx, c->cb_arg, error);
diff --git a/src/core/lib/iomgr/ev_epollsig_linux.c b/src/core/lib/iomgr/ev_epollsig_linux.c
index b1eaf6a4f2..9508e6ffb6 100644
--- a/src/core/lib/iomgr/ev_epollsig_linux.c
+++ b/src/core/lib/iomgr/ev_epollsig_linux.c
@@ -49,9 +49,6 @@
 
 #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1)
 
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_fd_refcount = GRPC_TRACER_INITIALIZER(false);
-#endif
 
 #define GRPC_POLLING_TRACE(...)             \
   if (GRPC_TRACER_ON(grpc_polling_trace)) { \
@@ -292,7 +289,7 @@ static void pi_unref(grpc_exec_ctx *exec_ctx, polling_island *pi);
 #ifndef NDEBUG
 static void pi_add_ref_dbg(polling_island *pi, const char *reason,
                            const char *file, int line) {
-  if (GRPC_TRACER_ON(grpc_trace_workqueue_refcount)) {
+  if (GRPC_TRACER_ON(grpc_polling_trace)) {
     long old_cnt = gpr_atm_acq_load(&pi->ref_count);
     gpr_log(GPR_DEBUG, "Add ref pi: %p, old: %ld -> new:%ld (%s) - (%s, %d)",
             (void *)pi, old_cnt, old_cnt + 1, reason, file, line);
@@ -302,7 +299,7 @@ static void pi_add_ref_dbg(polling_island *pi, const char *reason,
 
 static void pi_unref_dbg(grpc_exec_ctx *exec_ctx, polling_island *pi,
                          const char *reason, const char *file, int line) {
-  if (GRPC_TRACER_ON(grpc_trace_workqueue_refcount)) {
+  if (GRPC_TRACER_ON(grpc_polling_trace)) {
     long old_cnt = gpr_atm_acq_load(&pi->ref_count);
     gpr_log(GPR_DEBUG, "Unref pi: %p, old:%ld -> new:%ld (%s) - (%s, %d)",
             (void *)pi, old_cnt, (old_cnt - 1), reason, file, line);
diff --git a/src/core/lib/iomgr/ev_poll_posix.c b/src/core/lib/iomgr/ev_poll_posix.c
index 4d2ecd6300..57d0ca254f 100644
--- a/src/core/lib/iomgr/ev_poll_posix.c
+++ b/src/core/lib/iomgr/ev_poll_posix.c
@@ -45,10 +45,6 @@
 
 #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1)
 
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_fd_refcount = GRPC_TRACER_INITIALIZER(false);
-#endif
-
 /*******************************************************************************
  * FD declarations
  */
diff --git a/src/core/lib/iomgr/ev_posix.c b/src/core/lib/iomgr/ev_posix.c
index 54960d1ecc..668407b4ce 100644
--- a/src/core/lib/iomgr/ev_posix.c
+++ b/src/core/lib/iomgr/ev_posix.c
@@ -41,6 +41,10 @@
 grpc_tracer_flag grpc_polling_trace =
     GRPC_TRACER_INITIALIZER(false); /* Disabled by default */
 
+#ifndef NDEBUG
+grpc_tracer_flag grpc_trace_fd_refcount = GRPC_TRACER_INITIALIZER(false);
+#endif
+
 /** Default poll() function - a pointer so that it can be overridden by some
  *  tests */
 grpc_poll_function_type grpc_poll_function = poll;
diff --git a/src/core/lib/iomgr/ev_posix.h b/src/core/lib/iomgr/ev_posix.h
index 7f0a21be86..54c4f2ee11 100644
--- a/src/core/lib/iomgr/ev_posix.h
+++ b/src/core/lib/iomgr/ev_posix.h
@@ -29,10 +29,6 @@
 
 extern grpc_tracer_flag grpc_polling_trace; /* Disabled by default */
 
-#ifndef NDEBUG
-extern grpc_tracer_flag grpc_trace_fd_refcount;
-#endif
-
 typedef struct grpc_fd grpc_fd;
 
 typedef struct grpc_event_engine_vtable {
diff --git a/src/core/lib/iomgr/exec_ctx.c b/src/core/lib/iomgr/exec_ctx.c
index a2bd71ea9b..833170ceed 100644
--- a/src/core/lib/iomgr/exec_ctx.c
+++ b/src/core/lib/iomgr/exec_ctx.c
@@ -62,7 +62,7 @@ bool grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) {
         grpc_closure *next = c->next_data.next;
         grpc_error *error = c->error_data.error;
         did_something = true;
-#ifdef GRPC_CLOSURE_RICH_DEBUG
+#ifndef NDEBUG
         c->scheduled = false;
 #endif
         c->cb(exec_ctx, c->cb_arg, error);
@@ -85,7 +85,7 @@ void grpc_exec_ctx_finish(grpc_exec_ctx *exec_ctx) {
 
 static void exec_ctx_run(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
                          grpc_error *error) {
-#ifdef GRPC_CLOSURE_RICH_DEBUG
+#ifndef NDEBUG
   closure->scheduled = false;
   if (GRPC_TRACER_ON(grpc_trace_closure)) {
     gpr_log(GPR_DEBUG, "running closure %p: created [%s:%d]: %s [%s:%d]",
diff --git a/src/core/lib/iomgr/executor.c b/src/core/lib/iomgr/executor.c
index fda274e797..7621a7fe75 100644
--- a/src/core/lib/iomgr/executor.c
+++ b/src/core/lib/iomgr/executor.c
@@ -58,7 +58,7 @@ static size_t run_closures(grpc_exec_ctx *exec_ctx, grpc_closure_list list) {
   while (c != NULL) {
     grpc_closure *next = c->next_data.next;
     grpc_error *error = c->error_data.error;
-#ifdef GRPC_CLOSURE_RICH_DEBUG
+#ifndef NDEBUG
     c->scheduled = false;
 #endif
     c->cb(exec_ctx, c->cb_arg, error);
diff --git a/src/core/lib/iomgr/pollset.h b/src/core/lib/iomgr/pollset.h
index 3ff878e596..a609a3877a 100644
--- a/src/core/lib/iomgr/pollset.h
+++ b/src/core/lib/iomgr/pollset.h
@@ -25,6 +25,10 @@
 
 #include "src/core/lib/iomgr/exec_ctx.h"
 
+#ifndef NDEBUG
+extern grpc_tracer_flag grpc_trace_fd_refcount;
+#endif
+
 /* A grpc_pollset is a set of file descriptors that a higher level item is
    interested in. For example:
     - a server will typically keep a pollset containing all connected channels,
diff --git a/src/core/lib/iomgr/pollset_uv.c b/src/core/lib/iomgr/pollset_uv.c
index 07c7c04559..034b7ff270 100644
--- a/src/core/lib/iomgr/pollset_uv.c
+++ b/src/core/lib/iomgr/pollset_uv.c
@@ -20,6 +20,10 @@
 
 #ifdef GRPC_UV
 
+#ifndef NDEBUG
+grpc_tracer_flag grpc_trace_fd_refcount = GRPC_TRACER_INITIALIZER(false);
+#endif
+
 #include <uv.h>
 
 #include <string.h>
diff --git a/src/core/lib/iomgr/pollset_windows.c b/src/core/lib/iomgr/pollset_windows.c
index d5a03732cb..1bfc2a22a8 100644
--- a/src/core/lib/iomgr/pollset_windows.c
+++ b/src/core/lib/iomgr/pollset_windows.c
@@ -30,6 +30,10 @@
 
 #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1)
 
+#ifndef NDEBUG
+grpc_tracer_flag grpc_trace_fd_refcount = GRPC_TRACER_INITIALIZER(false);
+#endif
+
 gpr_mu grpc_polling_mu;
 static grpc_pollset_worker *g_active_poller;
 static grpc_pollset_worker g_global_root_worker;
diff --git a/src/core/lib/iomgr/tcp_windows.c b/src/core/lib/iomgr/tcp_windows.c
index 2312b5b86a..6704a158ce 100644
--- a/src/core/lib/iomgr/tcp_windows.c
+++ b/src/core/lib/iomgr/tcp_windows.c
@@ -48,7 +48,7 @@
 #define GRPC_FIONBIO FIONBIO
 #endif
 
-int grpc_tcp_trace = 0;
+grpc_tracer_flag grpc_tcp_trace = GRPC_TRACER_INITIALIZER(false);
 
 static grpc_error *set_non_block(SOCKET sock) {
   int status;
diff --git a/src/core/lib/surface/init.c b/src/core/lib/surface/init.c
index 731aa4aba9..14a86bfa0a 100644
--- a/src/core/lib/surface/init.c
+++ b/src/core/lib/surface/init.c
@@ -47,12 +47,6 @@
 #include "src/core/lib/transport/connectivity_state.h"
 #include "src/core/lib/transport/transport_impl.h"
 
-#ifndef NDEBUG
-#include "src/core/lib/iomgr/ev_posix.h"
-#include "src/core/lib/security/context/security_context.h"
-#include "src/core/lib/security/transport/security_connector.h"
-#endif
-
 /* (generated) built in registry of plugins */
 extern void grpc_register_built_in_plugins(void);
 
@@ -147,11 +141,6 @@ void grpc_init(void) {
     grpc_register_tracer("closure", &grpc_trace_closure);
     grpc_register_tracer("error_refcount", &grpc_trace_error_refcount);
     grpc_register_tracer("stream_refcount", &grpc_trace_stream_refcount);
-    // TODO(ncteisen): fix this after rebase
-    // grpc_register_tracer("auth_context_refcount",
-    // &grpc_trace_auth_context_refcount);
-    // grpc_register_tracer("security_connector_refcount",
-    // &grpc_trace_security_connector_refcount);
     grpc_register_tracer("fd_refcount", &grpc_trace_fd_refcount);
     grpc_register_tracer("metadata", &grpc_trace_metadata);
 #endif
-- 
GitLab