X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fgc-anchored.cpp;h=3f4cfc12dcf8cbe1a3022882495dbfe451f480f5;hb=03a65c733a473cd92d50132961d02c3910417f72;hp=285efd69d909767ff742c376de960c31cdc375b9;hpb=9913b9cb8fe557ed68c814af16a1f3455dcc8bb4;p=inkscape.git diff --git a/src/gc-anchored.cpp b/src/gc-anchored.cpp index 285efd69d..3f4cfc12d 100644 --- a/src/gc-anchored.cpp +++ b/src/gc-anchored.cpp @@ -12,7 +12,8 @@ #include #include "gc-anchored.h" #include "debug/event-tracker.h" -#include "debug/event.h" +#include "debug/simple-event.h" +#include "debug/demangle.h" #include "util/share.h" #include "util/format.h" @@ -20,51 +21,39 @@ namespace Inkscape { namespace GC { -class AnchorEvent : public Debug::Event { -public: - enum Type { ANCHOR, RELEASE }; - - AnchorEvent(GC::Anchored const *object, Type type) - : _base(Util::format("%p", Core::base(const_cast(object)))), - _object(Util::format("%p", object)), - _class_name(Util::share_static_string(typeid(*object).name())), - _refcount(Util::format("%d", ( type == ANCHOR ? object->_anchored_refcount() + 1 : object->_anchored_refcount() - 1 ))), - _type(type) - {} +namespace { - static Category category() { return REFCOUNT; } +typedef Debug::SimpleEvent RefCountEvent; - Util::ptr_shared name() const { - if ( _type == ANCHOR ) { - return Util::share_static_string("gc-anchor"); - } else { - return Util::share_static_string("gc-release"); - } - } - unsigned propertyCount() const { return 4; } - PropertyPair property(unsigned index) const { - switch (index) { - case 0: - return PropertyPair("base", _base); - case 1: - return PropertyPair("pointer", _object); - case 2: - return PropertyPair("class", _class_name); - case 3: - return PropertyPair("new-refcount", _refcount); - default: - return PropertyPair(); - } +class BaseAnchorEvent : public RefCountEvent { +public: + BaseAnchorEvent(Anchored const *object, int bias, + Util::ptr_shared name) + : RefCountEvent(name) + { + _addProperty("base", Util::format("%p", Core::base(const_cast(object)))); + _addProperty("pointer", Util::format("%p", object)); + _addProperty("class", Debug::demangle(typeid(*object).name())); + _addProperty("new-refcount", Util::format("%d", object->_anchored_refcount() + bias)); } +}; -private: - Util::ptr_shared _base; - Util::ptr_shared _object; - Util::ptr_shared _class_name; - Util::ptr_shared _refcount; - Type _type; +class AnchorEvent : public BaseAnchorEvent { +public: + AnchorEvent(Anchored const *object) + : BaseAnchorEvent(object, 1, Util::share_static_string("gc-anchor")) + {} }; +class ReleaseEvent : public BaseAnchorEvent { +public: + ReleaseEvent(Anchored const *object) + : BaseAnchorEvent(object, -1, Util::share_static_string("gc-release")) + {} +}; + +} + Anchored::Anchor *Anchored::_new_anchor() const { return new Anchor(this); } @@ -74,7 +63,7 @@ void Anchored::_free_anchor(Anchored::Anchor *anchor) const { } void Anchored::anchor() const { - Debug::EventTracker tracker(this, AnchorEvent::ANCHOR); + Debug::EventTracker tracker(this); if (!_anchor) { _anchor = _new_anchor(); } @@ -82,7 +71,7 @@ void Anchored::anchor() const { } void Anchored::release() const { - Debug::EventTracker tracker(this, AnchorEvent::RELEASE); + Debug::EventTracker tracker(this); if (!--_anchor->refcount) { _free_anchor(_anchor); _anchor = NULL;