diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2010-01-10 21:47:42 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2010-01-10 21:47:42 +0000 |
commit | 37e6be3704bca205ce132f6b272639465cd841f4 (patch) | |
tree | 2a923a2c6b2319e21c555333db83e091842af53a /usr.bin/aucat/miofile.c | |
parent | b039c5e2f74be6a127e392ec2effc1aebc324126 (diff) |
Add traces to help tracking subtle timing bugs often causing
underuns and overruns; such bugs are hard to debug with ktrace
or a debugger. They are also handy to debug or monitor code
using aucat.
To enable traces, compile aucat with ``make DEBUG=-DDEBUG'' and
use the -d option multiple times.
ok jakemsr
Diffstat (limited to 'usr.bin/aucat/miofile.c')
-rw-r--r-- | usr.bin/aucat/miofile.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/usr.bin/aucat/miofile.c b/usr.bin/aucat/miofile.c index d8c45125113..f3038c88b47 100644 --- a/usr.bin/aucat/miofile.c +++ b/usr.bin/aucat/miofile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: miofile.c,v 1.3 2009/11/05 08:36:48 ratchov Exp $ */ +/* $OpenBSD: miofile.c,v 1.4 2010/01/10 21:47:41 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -27,6 +27,9 @@ #include "conf.h" #include "file.h" #include "miofile.h" +#ifdef DEBUG +#include "dbg.h" +#endif struct miofile { struct file file; @@ -94,8 +97,18 @@ miofile_read(struct file *file, unsigned char *data, unsigned count) if (n == 0) { f->file.state &= ~FILE_ROK; if (mio_eof(f->hdl)) { +#ifdef DEBUG + dbg_puts(f->file.name); + dbg_puts(": failed to read from device\n"); +#endif file_eof(&f->file); } else { +#ifdef DEBUG + if (debug_level >= 4) { + file_dbg(&f->file); + dbg_puts(": reading blocked\n"); + } +#endif } return 0; } @@ -113,8 +126,18 @@ miofile_write(struct file *file, unsigned char *data, unsigned count) if (n == 0) { f->file.state &= ~FILE_WOK; if (mio_eof(f->hdl)) { +#ifdef DEBUG + dbg_puts(f->file.name); + dbg_puts(": failed to write on device\n"); +#endif file_hup(&f->file); } else { +#ifdef DEBUG + if (debug_level >= 4) { + file_dbg(&f->file); + dbg_puts(": writing blocked\n"); + } +#endif } return 0; } |