From: sage Date: Sun, 26 Jun 2005 23:45:41 +0000 (+0000) Subject: buffer debug X-Git-Tag: v0.1~2039 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=25468b3810a46f9fb9703b880d0ab81d4e28c528;p=ceph.git buffer debug git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@342 29311d96-e01e-0410-9327-a35deaab8ce9 --- diff --git a/ceph/config.cc b/ceph/config.cc index c9f6dbcea08ab..745185656ee0b 100644 --- a/ceph/config.cc +++ b/ceph/config.cc @@ -29,6 +29,7 @@ md_config_t g_conf = { debug: 1, debug_mds_balancer: 1, debug_mds_log: 1, + debug_buffer: 0, // --- client --- client_cache_size: 400, diff --git a/ceph/config.h b/ceph/config.h index d5c3d06cb41d1..bad85bc96d17f 100644 --- a/ceph/config.h +++ b/ceph/config.h @@ -20,6 +20,7 @@ struct md_config_t { int debug; int debug_mds_balancer; int debug_mds_log; + int debug_buffer; // client int client_cache_size; diff --git a/ceph/include/buffer.h b/ceph/include/buffer.h index a9b4f38a81aa3..6c927a2ee9c43 100644 --- a/ceph/include/buffer.h +++ b/ceph/include/buffer.h @@ -16,6 +16,11 @@ using namespace std; #define BUFFER_MODE_DEFAULT 3//(BUFFER_MODE_COPY|BUFFER_MODE_FREE) +// debug crap +#include "include/config.h" +#define bdbout(x) if (x <= g_conf.debug_buffer) cout + + /* * buffer - the underlying buffer container. with a reference count. * @@ -35,11 +40,11 @@ class buffer { int _ref; int _get() { - //cout << "buffer.get " << *this << " get " << _ref+1 << endl; + bdbout(1) << "buffer.get " << *this << " get " << _ref+1 << endl; return ++_ref; } int _put() { - //cout << "buffer.put " << *this << " put " << _ref-1 << endl; + bdbout(1) << "buffer.put " << *this << " put " << _ref-1 << endl; return --_ref; } @@ -48,17 +53,17 @@ class buffer { public: // constructors buffer() : _dataptr(0), _len(0), _alloc_len(0), _ref(0), _myptr(true) { - //cout << "buffer.cons " << *this << endl; + bdbout(1) << "buffer.cons " << *this << endl; } buffer(int a) : _dataptr(0), _len(0), _alloc_len(a), _ref(0), _myptr(true) { - //cout << "buffer.cons " << *this << endl; + bdbout(1) << "buffer.cons " << *this << endl; _dataptr = new char[a]; - //cout << "buffer.malloc " << (void*)_dataptr << endl; + bdbout(1) << "buffer.malloc " << (void*)_dataptr << endl; } ~buffer() { - //cout << "buffer.des " << *this << endl; + bdbout(1) << "buffer.des " << *this << endl; if (_dataptr && _myptr) { - //cout << "buffer.free " << (void*)_dataptr << endl; + bdbout(1) << "buffer.free " << (void*)_dataptr << endl; delete[] _dataptr; } } @@ -70,15 +75,15 @@ class buffer { _ref(0), _myptr(0) { _myptr = mode & BUFFER_MODE_FREE ? true:false; - //cout << "buffer.cons " << *this << " mode = " << mode << ", myptr=" << _myptr << endl; + bdbout(1) << "buffer.cons " << *this << " mode = " << mode << ", myptr=" << _myptr << endl; if (mode & BUFFER_MODE_COPY) { _dataptr = new char[l]; - //cout << "buffer.malloc " << (void*)_dataptr << endl; + bdbout(1) << "buffer.malloc " << (void*)_dataptr << endl; memcpy(_dataptr, p, l); - //cout << "buffer(copy) " << *this << endl; + bdbout(1) << "buffer.copy " << *this << endl; } else { _dataptr = (char*)p; // ugly - //cout << "buffer(claim), myptr=" << _myptr << " " << *this << endl; + bdbout(1) << "buffer.claim " << *this << " myptr=" << _myptr << endl; } }