]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
buffer debug
authorsage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Sun, 26 Jun 2005 23:45:41 +0000 (23:45 +0000)
committersage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Sun, 26 Jun 2005 23:45:41 +0000 (23:45 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@342 29311d96-e01e-0410-9327-a35deaab8ce9

ceph/config.cc
ceph/config.h
ceph/include/buffer.h

index c9f6dbcea08ab7c1a5aee35bca39297f680b0860..745185656ee0b5004d4cf54f4fecf04ead50e7d9 100644 (file)
@@ -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,
index d5c3d06cb41d13747b20ea403625df73bebff0b3..bad85bc96d17fb0ba1f0f7f347be6dafbef9ffac 100644 (file)
@@ -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;
index a9b4f38a81aa39ab2fdaeeb15672fefb9d438074..6c927a2ee9c439d5937fa3f4c25708c99fb79c1c 100644 (file)
@@ -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;
        }
   }