[fdio] Remove unused FDIO_LLDEBUG logging

Change-Id: I3e4965f48656e8101310425c1c9e3713f6e6c0dd
diff --git a/zircon/system/ulib/fdio/debug.c b/zircon/system/ulib/fdio/debug.c
deleted file mode 100644
index bea5520..0000000
--- a/zircon/system/ulib/fdio/debug.c
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "private.h"
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <zircon/syscalls.h>
-#include <zircon/syscalls/log.h>
-
-#ifdef FDIO_LLDEBUG
-#define LOGBUF_MAX (ZX_LOG_RECORD_MAX - sizeof(zx_log_record_t))
-
-static ssize_t fdio_lldebug_log_write(const void* _data, size_t len) {
-    static thread_local struct {
-        zx_handle_t log;
-        uint32_t next;
-        char data[LOGBUF_MAX];
-    }* logbuf = NULL;
-
-    if (logbuf == NULL) {
-        if ((logbuf = calloc(1, sizeof(*logbuf))) == NULL) {
-            return len;
-        }
-        if (zx_debuglog_create(0, 0, &logbuf->log) != ZX_OK) {
-            free(logbuf);
-            logbuf = NULL;
-            return len;
-        }
-    }
-
-    const char* data = _data;
-    size_t r = len;
-    while (len-- > 0) {
-        char c = *data++;
-        if (c == '\n') {
-            zx_debuglog_write(logbuf->log, 0, logbuf->data, logbuf->next);
-            logbuf->next = 0;
-            continue;
-        }
-        if (c < ' ') {
-            continue;
-        }
-        logbuf->data[logbuf->next++] = c;
-        if (logbuf->next == LOGBUF_MAX) {
-            zx_debuglog_write(logbuf->log, 0, logbuf->data, logbuf->next);
-            logbuf->next = 0;
-            continue;
-        }
-    }
-    return r;
-}
-
-static unsigned debug_level = FDIO_LLDEBUG;
-
-void fdio_lldebug_printf(unsigned level, const char* fmt, ...) {
-    if (debug_level >= level) {
-        va_list ap;
-        char buf[128];
-        va_start(ap, fmt);
-        size_t sz = vsnprintf(buf, sizeof(buf), fmt, ap);
-        va_end(ap);
-        fdio_lldebug_log_write(buf, sz > sizeof(buf) ? sizeof(buf) : sz);
-    }
-}
-#endif
-
-void fdio_set_debug_level(unsigned level) {
-#ifdef FDIO_LLDEBUG
-    debug_level = level;
-#endif
-}
diff --git a/zircon/system/ulib/fdio/fdio.c b/zircon/system/ulib/fdio/fdio.c
index 1e88be3..f06069d 100644
--- a/zircon/system/ulib/fdio/fdio.c
+++ b/zircon/system/ulib/fdio/fdio.c
@@ -72,21 +72,17 @@
 
 fdio_t* fdio_alloc(const fdio_ops_t* ops) {
     fdio_t* io = (fdio_t*) calloc(1, sizeof(fdio_t));
-    LOG(5, "fdio: io: alloc: %p\n", io);
     io->ops = ops;
     atomic_init(&io->refcount, 1);
     return io;
 }
 
 void fdio_acquire(fdio_t* io) {
-    LOG(6, "fdio: acquire: %p\n", io);
     atomic_fetch_add(&io->refcount, 1);
 }
 
 void fdio_release(fdio_t* io) {
-    LOG(6, "fdio: release: %p\n", io);
     if (atomic_fetch_sub(&io->refcount, 1) == 1) {
-        LOG(5, "fdio: io: free: %p\n", io);
         io->ops = NULL;
         free(io);
     }
diff --git a/zircon/system/ulib/fdio/namespace/local-connection.cpp b/zircon/system/ulib/fdio/namespace/local-connection.cpp
index 19841ec..803e905 100644
--- a/zircon/system/ulib/fdio/namespace/local-connection.cpp
+++ b/zircon/system/ulib/fdio/namespace/local-connection.cpp
@@ -63,7 +63,6 @@
 zx_status_t zxio_dir_open(fdio_t* io, const char* path, uint32_t flags,
                           uint32_t mode, fdio_t** out) {
     LocalConnection* dir = fdio_get_zxio_dir(io);
-    LOG(6, "OPEN '%s'\n", path);
 
     return dir->fs->Open(fbl::WrapRefPtr(dir->vn), path, flags, mode, out);
 }
diff --git a/zircon/system/ulib/fdio/namespace/local-filesystem.cpp b/zircon/system/ulib/fdio/namespace/local-filesystem.cpp
index d5e2a70..2d869ba 100644
--- a/zircon/system/ulib/fdio/namespace/local-filesystem.cpp
+++ b/zircon/system/ulib/fdio/namespace/local-filesystem.cpp
@@ -193,7 +193,6 @@
 
 zx_status_t fdio_namespace::Connect(const char* path, uint32_t flags,
                                     zx::channel channel) const {
-    LOG(6, "CONNECT '%s'\n", path);
     // Require that we start at /
     if (path[0] != '/') {
         return ZX_ERR_NOT_FOUND;
diff --git a/zircon/system/ulib/fdio/namespace/namespace.cpp b/zircon/system/ulib/fdio/namespace/namespace.cpp
index 601c2c0..632ffb4 100644
--- a/zircon/system/ulib/fdio/namespace/namespace.cpp
+++ b/zircon/system/ulib/fdio/namespace/namespace.cpp
@@ -61,7 +61,6 @@
 
 __EXPORT
 zx_status_t fdio_ns_bind(fdio_ns_t* ns, const char* path, zx_handle_t remote_raw) {
-    LOG(1, "BIND '%s' %x\n", path, remote_raw);
     zx::channel remote(remote_raw);
     return ns->Bind(path, std::move(remote));
 }
diff --git a/zircon/system/ulib/fdio/private.h b/zircon/system/ulib/fdio/private.h
index 2bcc93e..71f160a 100644
--- a/zircon/system/ulib/fdio/private.h
+++ b/zircon/system/ulib/fdio/private.h
@@ -275,25 +275,6 @@
 #define fdio_root_init (__fdio_global_state.init)
 #define fdio_root_ns (__fdio_global_state.ns)
 
-// Enable low level debug chatter, which requires a kernel that
-// doesn't check the resource argument to zx_debuglog_create()
-//
-// The value is the default debug level (0 = none)
-// The environment variable FDIODEBUG will override this on fdio init
-//
-// #define FDIO_LLDEBUG 1
-
-#ifdef FDIO_LLDEBUG
-void fdio_lldebug_printf(unsigned level, const char* fmt, ...);
-#define LOG(level, fmt...) fdio_lldebug_printf(level, fmt)
-#else
-#define LOG(level, fmt...) \
-    do {                   \
-    } while (0)
-#endif
-
-void fdio_set_debug_level(unsigned level);
-
 // Returns an fd number greater than or equal to |starting_fd|, following the
 // same rules as fdio_bind_fd. If there are no free file descriptors, -1 is
 // returned and |errno| is set to EMFILE. The returned |fd| is bound to
diff --git a/zircon/system/ulib/fdio/rules.mk b/zircon/system/ulib/fdio/rules.mk
index 287081b..4f7319f 100644
--- a/zircon/system/ulib/fdio/rules.mk
+++ b/zircon/system/ulib/fdio/rules.mk
@@ -14,7 +14,6 @@
 
 MODULE_SRCS += \
     $(LOCAL_DIR)/bsdsocket.c \
-    $(LOCAL_DIR)/debug.c \
     $(LOCAL_DIR)/fd.cpp \
     $(LOCAL_DIR)/get-vmo.c \
     $(LOCAL_DIR)/fdio.c \
diff --git a/zircon/system/ulib/fdio/unistd.c b/zircon/system/ulib/fdio/unistd.c
index 67ce7c7..290af37 100644
--- a/zircon/system/ulib/fdio/unistd.c
+++ b/zircon/system/ulib/fdio/unistd.c
@@ -120,7 +120,6 @@
     fdio_t* io_to_close = NULL;
 
     mtx_lock(&fdio_lock);
-    LOG(1, "fdio: bind_to_fd(%p, %d, %d)\n", io, fd, starting_fd);
     if (fd < 0) {
         // If we are not given an |fd|, the |starting_fd| must be non-negative.
         if (starting_fd < 0) {
@@ -147,8 +146,6 @@
         io_to_close = fdio_fdtab[fd];
         if (io_to_close) {
             fdio_dupcount_release(io_to_close);
-            LOG(1, "fdio: bind_to_fd: closed fd=%d, io=%p, dupcount=%d\n",
-                fd, io_to_close, fdio_get_dupcount(io_to_close));
             if (fdio_get_dupcount(io_to_close) > 0) {
                 // still alive in another fdtab slot
                 fdio_release(io_to_close);
@@ -158,7 +155,6 @@
     }
 
 free_fd_found:
-    LOG(1, "fdio: bind_to_fd() OK fd=%d\n", fd);
     fdio_dupcount_acquire(io);
     fdio_fdtab[fd] = io;
     mtx_unlock(&fdio_lock);
@@ -178,7 +174,6 @@
 zx_status_t fdio_unbind_from_fd(int fd, fdio_t** out) {
     zx_status_t status;
     mtx_lock(&fdio_lock);
-    LOG(1, "fdio: unbind_from_fd(%d)\n", fd);
     if (fd >= FDIO_MAX_FD) {
         status = ZX_ERR_INVALID_ARGS;
         goto done;
@@ -224,10 +219,6 @@
 }
 
 zx_status_t fdio_close(fdio_t* io) {
-    if (fdio_get_dupcount(io) > 0) {
-        LOG(1, "fdio: close(%p): nonzero dupcount!\n", io);
-    }
-    LOG(1, "fdio: io: close(%p)\n", io);
     return fdio_get_ops(io)->close(io);
 }
 
@@ -593,16 +584,6 @@
                             uint32_t name_count,
                             char** names) {
 
-#ifdef FDIO_LLDEBUG
-    const char* fdiodebug = getenv("FDIODEBUG");
-    if (fdiodebug) {
-        fdio_set_debug_level(strtoul(fdiodebug, NULL, 10));
-        LOG(1, "fdio: init: debuglevel = %s\n", fdiodebug);
-    } else {
-        LOG(1, "fdio: init()\n");
-    }
-#endif
-
     int stdio_fd = -1;
 
     // extract handles we care about
@@ -621,14 +602,11 @@
             fdio_t* io = NULL;
             zx_status_t status = fdio_create(h, &io);
             if (status != ZX_OK) {
-                LOG(1, "fdio: Failed to acquire for fd=%d status=%d (%s)\n",
-                    arg_fd, status, zx_status_get_string(status));
                 zx_handle_close(h);
                 continue;
             }
             fdio_fdtab[arg_fd] = io;
             fdio_dupcount_acquire(fdio_fdtab[arg_fd]);
-            LOG(1, "fdio: inherit fd=%d\n", arg_fd);
             break;
         }
         case PA_NS_DIR:
@@ -677,7 +655,6 @@
                 fdio_fdtab[n] = fdio_null_create();
             }
             fdio_dupcount_acquire(fdio_fdtab[n]);
-            LOG(1, "fdio: inherit fd=%u (dup of fd=%d)\n", n, stdio_fd);
         }
     }
 
@@ -1171,7 +1148,6 @@
     fdio_t* io = fdio_fdtab[fd];
     fdio_dupcount_release(io);
     fdio_fdtab[fd] = NULL;
-    LOG(1, "fdio: close(%d) dupcount=%u\n", fdio_get_dupcount(io));
     if (fdio_get_dupcount(io) > 0) {
         // still alive in other fdtab slots
         mtx_unlock(&fdio_lock);
@@ -1601,11 +1577,9 @@
     fdio_t* io;
     zx_status_t r;
 
-    LOG(1,"fdio: fstatat(%d, '%s',...)\n", dirfd, fn);
     if ((r = __fdio_open_at(&io, dirfd, fn, O_PATH, 0)) < 0) {
         return ERROR(r);
     }
-    LOG(1,"fdio: fstatat io=%p\n", io);
     r = fdio_stat(io, s);
     fdio_close(io);
     fdio_release(io);