From 627d6c926a9df0d200d3164b177f73e446a85fb1 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Wed, 30 Oct 2024 10:24:33 -0400 Subject: [PATCH] More printf --- libcxx/src/locale.cpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp index 3c173a8d1541be..63177cd64c3716 100644 --- a/libcxx/src/locale.cpp +++ b/libcxx/src/locale.cpp @@ -150,7 +150,13 @@ class _LIBCPP_HIDDEN locale::__imp : public facet { void install(facet* f, long id); template void install(F* f) { - install(f, f->id.__get()); + std::fprintf(stderr, "Entering install(Facet*)\n"); + + std::fprintf(stderr, "Getting id for locale\n"); + long id = f->id.__get(); + + std::fprintf(stderr, "Calling install(Facet*, long id)\n"); + install(f, id); } template void install_from(const __imp& other); @@ -231,8 +237,13 @@ locale::__imp::__imp(const string& name, size_t refs) : facet(refs), facets_(N), if (facets_[i]) facets_[i]->__add_shared(); - std::fprintf(stderr, "Installing locales\n"); - install(new collate_byname(name_)); + { + std::fprintf(stderr, "Creating collate_byname\n"); + auto* byname = new collate_byname(name_); + + std::fprintf(stderr, "Installing collate_byname\n"); + install(byname); + } #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS install(new collate_byname(name_)); #endif @@ -480,12 +491,25 @@ locale::__imp::~__imp() { } void locale::__imp::install(facet* f, long id) { + std::fprintf(stderr, "Entering install(facet*, long id)\n"); + + std::fprintf(stderr, "Calling facet->__add_shared()\n"); f->__add_shared(); + + std::fprintf(stderr, "Creating unique_ptr to hold facet\n"); unique_ptr hold(f); - if (static_cast(id) >= facets_.size()) + + if (static_cast(id) >= facets_.size()) { + std::fprintf(stderr, "Resizing facets vector\n"); facets_.resize(static_cast(id + 1)); - if (facets_[static_cast(id)]) + } + + if (facets_[static_cast(id)]) { + std::fprintf(stderr, "Releasing facets[id]\n"); facets_[static_cast(id)]->__release_shared(); + } + + std::fprintf(stderr, "Releasing unique_ptr\n"); facets_[static_cast(id)] = hold.release(); }