From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPDGg-0006uf-4A for qemu-devel@nongnu.org; Mon, 08 Apr 2013 10:42:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPDGZ-0007VR-Sa for qemu-devel@nongnu.org; Mon, 08 Apr 2013 10:41:58 -0400 Received: from mail-we0-x229.google.com ([2a00:1450:400c:c03::229]:61275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPDGZ-0007VG-LX for qemu-devel@nongnu.org; Mon, 08 Apr 2013 10:41:51 -0400 Received: by mail-we0-f169.google.com with SMTP id x43so4641367wey.14 for ; Mon, 08 Apr 2013 07:41:50 -0700 (PDT) Date: Mon, 8 Apr 2013 16:41:48 +0200 From: Stefan Hajnoczi Message-ID: <20130408144148.GI4429@stefanha-thinkpad.redhat.com> References: <1365167273-28050-1-git-send-email-rjones@redhat.com> <1365167273-28050-2-git-send-email-rjones@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1365167273-28050-2-git-send-email-rjones@redhat.com> Subject: Re: [Qemu-devel] [PATCH v7 1/2] block: Add support for Secure Shell (ssh) block device. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Richard W.M. Jones" Cc: qemu-devel@nongnu.org On Fri, Apr 05, 2013 at 02:07:52PM +0100, Richard W.M. Jones wrote: > +/* DEBUG_SSH=1 enables the DPRINTF (debugging printf) statements in > + * this block driver code. > + * > + * TRACE_LIBSSH2= enables tracing in libssh2 itself. Note > + * that this requires that libssh2 was specially compiled with the > + * `./configure --enable-debug' option, so most likely you will have > + * to compile it yourself. The meaning of is described > + * here: http://www.libssh2.org/libssh2_trace.html > + */ > +#define DEBUG_SSH 0 > +#define TRACE_LIBSSH2 0 /* or try: LIBSSH2_TRACE_SFTP */ > + > +#if DEBUG_SSH > +#define DPRINTF(fmt,...) \ > + do { \ > + fprintf(stderr, "ssh: %-15s " fmt "\n", __func__, ##__VA_ARGS__); \ > + } while (0) > +#else > +#define DPRINTF(fmt,...) /* nothing */ > +#endif The following approach keeps syntax and format string error checking even when DEBUG_SSH if 0: #define DPRINTF(fmt, ...) \ do { \ if (DEBUG_SSH) { \ fprintf(stderr, "ssh: %-15s " fmt "\n", \ __func__, ##__VA_ARGS__); \ } \ } while (0) It avoids DPRINTF() bitrot. > +#define LOCK(s) do { \ > + DPRINTF("acquiring the lock"); \ > + qemu_co_mutex_lock(&s->lock); \ > + DPRINTF("acquired the lock"); \ > + } while (0) > + > +#define UNLOCK(s) do { \ > + qemu_co_mutex_unlock(&s->lock); \ > + DPRINTF("released the lock"); \ > + } while (0) See ./trace-events: qemu_co_mutex_lock_entry(void *mutex, void *self) "mutex %p self %p" qemu_co_mutex_lock_return(void *mutex, void *self) "mutex %p self %p" qemu_co_mutex_unlock_entry(void *mutex, void *self) "mutex %p self %p" qemu_co_mutex_unlock_return(void *mutex, void *self) "mutex %p self %p" This means you can get these printfs like this: $ ./configure --enable-trace-backend=stderr $ echo qemu_co_mutex_lock_entry >my-events $ echo qemu_co_mutex_lock_return >>my-events $ echo qemu_co_mutex_unlock_entry >>my-events $ echo qemu_co_mutex_unlock_return >>my-events $ x86_64-softmmu/qemu-system-x86_64 -trace events=my-events ... If you want you can keep the macros but really we already have these printfs.