summaryrefslogtreecommitdiffstats
path: root/libcxx/src
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2011-09-27 23:55:03 +0000
committerHoward Hinnant <hhinnant@apple.com>2011-09-27 23:55:03 +0000
commit920b56ca88f06dd9e01caf6f99fcb01e53d1d058 (patch)
tree5e4888c62e46c2ef52fc0373283296904c36ec47 /libcxx/src
parent30c811246fe1313c9f72e504a342607a741a6602 (diff)
downloadbcm5719-llvm-920b56ca88f06dd9e01caf6f99fcb01e53d1d058.tar.gz
bcm5719-llvm-920b56ca88f06dd9e01caf6f99fcb01e53d1d058.zip
Another installment on debug mode. This addresses list. However this should be considered a temporary state. The API of the debug database and how vector and list use it, is unsatisfactory at the moment. It is both inefficient and overly verbose. I wanted to get this functionality checked in though. In the next day or so I'll refactor what is there in an attempt to streamline things.
llvm-svn: 140660
Diffstat (limited to 'libcxx/src')
-rw-r--r--libcxx/src/debug.cpp73
1 files changed, 42 insertions, 31 deletions
diff --git a/libcxx/src/debug.cpp b/libcxx/src/debug.cpp
index 2d2d6432df1..8b660f5f39a 100644
--- a/libcxx/src/debug.cpp
+++ b/libcxx/src/debug.cpp
@@ -120,20 +120,18 @@ __libcpp_db::__insert_ic(void* __i, const void* __c)
{
WLock _(mut());
__i_node* i = __insert_iterator(__i);
- _LIBCPP_ASSERT(__cbeg_ != __cend_, "Container constructed in a translation unit with debug mode disabled."
- " But it is being used in a translation unit with debug mode enabled."
- " Enable it in the other translation unit with #define _LIBCPP_DEBUG2 1");
+ const char* errmsg =
+ "Container constructed in a translation unit with debug mode disabled."
+ " But it is being used in a translation unit with debug mode enabled."
+ " Enable it in the other translation unit with #define _LIBCPP_DEBUG2 1";
+ _LIBCPP_ASSERT(__cbeg_ != __cend_, errmsg);
size_t hc = hash<const void*>()(__c) % (__cend_ - __cbeg_);
__c_node* c = __cbeg_[hc];
- _LIBCPP_ASSERT(c != nullptr, "Container constructed in a translation unit with debug mode disabled."
- " But it is being used in a translation unit with debug mode enabled."
- " Enable it in the other translation unit with #define _LIBCPP_DEBUG2 1");
+ _LIBCPP_ASSERT(c != nullptr, errmsg);
while (c->__c_ != __c)
{
c = c->__next_;
- _LIBCPP_ASSERT(c != nullptr, "Container constructed in a translation unit with debug mode disabled."
- " But it is being used in a translation unit with debug mode enabled."
- " Enable it in the other translation unit with #define _LIBCPP_DEBUG2 1");
+ _LIBCPP_ASSERT(c != nullptr, errmsg);
}
c->__add(i);
i->__c_ = c;
@@ -241,6 +239,20 @@ __libcpp_db::__find_c_and_lock(void* __c) const
return p;
}
+__c_node*
+__libcpp_db::__find_c(void* __c) const
+{
+ size_t hc = hash<void*>()(__c) % (__cend_ - __cbeg_);
+ __c_node* p = __cbeg_[hc];
+ _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c A");
+ while (p->__c_ != __c)
+ {
+ p = p->__next_;
+ _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c B");
+ }
+ return p;
+}
+
void
__libcpp_db::unlock() const
{
@@ -380,6 +392,27 @@ __libcpp_db::__insert_i(void* __i)
__insert_iterator(__i);
}
+void
+__c_node::__add(__i_node* i)
+{
+ if (end_ == cap_)
+ {
+ size_t nc = 2*(cap_ - beg_);
+ if (nc == 0)
+ nc = 1;
+ __i_node** beg = (__i_node**)malloc(nc * sizeof(__i_node*));
+ if (beg == nullptr)
+ throw bad_alloc();
+ if (nc > 1)
+ memcpy(beg, beg_, nc/2*sizeof(__i_node*));
+ free(beg_);
+ beg_ = beg;
+ end_ = beg_ + nc/2;
+ cap_ = beg_ + nc;
+ }
+ *end_++ = i;
+}
+
// private api
_LIBCPP_HIDDEN
@@ -440,28 +473,6 @@ __libcpp_db::__find_iterator(const void* __i) const
_LIBCPP_HIDDEN
void
-__c_node::__add(__i_node* i)
-{
- if (end_ == cap_)
- {
- size_t nc = 2*(cap_ - beg_);
- if (nc == 0)
- nc = 1;
- __i_node** beg = (__i_node**)malloc(nc * sizeof(__i_node*));
- if (beg == nullptr)
- throw bad_alloc();
- if (nc > 1)
- memcpy(beg, beg_, nc/2*sizeof(__i_node*));
- free(beg_);
- beg_ = beg;
- end_ = beg_ + nc/2;
- cap_ = beg_ + nc;
- }
- *end_++ = i;
-}
-
-_LIBCPP_HIDDEN
-void
__c_node::__remove(__i_node* p)
{
__i_node** r = find(beg_, end_, p);
OpenPOWER on IntegriCloud