<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class="">Adding         packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates</div><div class="">Adding         packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/Makefile</div><div class="">Adding         packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py</div><div class="">Adding         packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/main.cpp</div><div class="">Transmitting file data ...</div><div class="">Committed revision 256034.</div></div><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 15, 2015, at 11:17 AM, Zachary Turner <<a href="mailto:zturner@google.com" class="">zturner@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I'm more hardline than most, but personally I would say "making it testable" is in and of itself a driver :)  Of course even the most robust test suite will never catch everything, but it makes me sleep easier at night when I know that I will never encounter the same bug more than once.</div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Mon, Dec 14, 2015 at 7:58 PM Enrico Granata <<a href="mailto:egranata@apple.com" class="">egranata@apple.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" class=""><div class="">All of these things are theoretically possible (i.e. They can be done by writing enough code :-), but I would love if there were a real feature driver for them before I sit down and write said code.</div><div class=""><br class=""></div><div class="">The most interesting avenue is making the FormatManager be a per-debugger entity instead of a shared singleton, but given my last try it is quite a bit of work. Possible to do, unlikely to happen anytime soon though.</div><div class=""><br class=""></div><div class="">The easier thing to do might be allowing the addition of formatters to language categories via the command line/API. Then one could have an ad-hoc formatter added just for testing.<br class=""><br class="">Sent from my iPhone</div></div><div dir="auto" class=""><div class=""><br class="">On Dec 14, 2015, at 7:07 PM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank" class="">zturner@google.com</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class="">Ahh.  Is there any way to change that behavior so that you can add back deleted formatters?   Or make it so that FormatManager itself can be created and then destroyed.  i.e. we could still use it as a singleton / global state in LLDB, but we could create and destroy them with each test in the test suite.</div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Mon, Dec 14, 2015 at 6:48 PM Enrico Granata <<a href="mailto:egranata@apple.com" target="_blank" class="">egranata@apple.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">It’s a hard unit test to write though</div><div class=""><br class=""></div><div class="">I caught this because I deleted a formatter in a language category and saw it still applied</div><div class=""><br class=""></div><div class="">Problem is that you can’t add new formatters or add back previously deleted formatters to a language category, and the FormatManager is global state, so a deletion is forever, which worries me as potentially affecting downstream tests</div><div class=""><br class=""></div><div class="">I’ll keep this in mind though, if I can come up with a good way to cons a test up, I’ll definitely make it happen</div></div><div style="word-wrap:break-word" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 14, 2015, at 6:45 PM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank" class="">zturner@google.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">A unit test would be good at catching bugs like this.</div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Mon, Dec 14, 2015 at 6:23 PM Enrico Granata via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org" target="_blank" class="">lldb-commits@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: enrico<br class="">
Date: Mon Dec 14 20:20:48 2015<br class="">
New Revision: 255603<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=255603&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=255603&view=rev</a><br class="">
Log:<br class="">
Fix a bug where language categories would hold on to their caches even after changes<br class="">
<br class="">
<br class="">
Modified:<br class="">
    lldb/trunk/include/lldb/DataFormatters/FormatManager.h<br class="">
    lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h<br class="">
    lldb/trunk/source/DataFormatters/FormatManager.cpp<br class="">
    lldb/trunk/source/DataFormatters/LanguageCategory.cpp<br class="">
<br class="">
Modified: lldb/trunk/include/lldb/DataFormatters/FormatManager.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatManager.h?rev=255603&r1=255602&r2=255603&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatManager.h?rev=255603&r1=255602&r2=255603&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/include/lldb/DataFormatters/FormatManager.h (original)<br class="">
+++ lldb/trunk/include/lldb/DataFormatters/FormatManager.h Mon Dec 14 20:20:48 2015<br class="">
@@ -238,11 +238,7 @@ public:<br class="">
     ShouldPrintAsOneLiner (ValueObject& valobj);<br class="">
<br class="">
     void<br class="">
-    Changed () override<br class="">
-    {<br class="">
-        ++m_last_revision;<br class="">
-        m_format_cache.Clear ();<br class="">
-    }<br class="">
+    Changed () override;<br class="">
<br class="">
     uint32_t<br class="">
     GetCurrentRevision () override<br class="">
@@ -290,13 +286,13 @@ private:<br class="">
                         bool did_strip_ref,<br class="">
                         bool did_strip_typedef,<br class="">
                         bool root_level = false);<br class="">
-<br class="">
+<br class="">
+    std::atomic<uint32_t> m_last_revision;<br class="">
     FormatCache m_format_cache;<br class="">
+    Mutex m_language_categories_mutex;<br class="">
+    LanguageCategories m_language_categories_map;<br class="">
     NamedSummariesMap m_named_summaries_map;<br class="">
-    std::atomic<uint32_t> m_last_revision;<br class="">
     TypeCategoryMap m_categories_map;<br class="">
-    LanguageCategories m_language_categories_map;<br class="">
-    Mutex m_language_categories_mutex;<br class="">
<br class="">
     ConstString m_default_category_name;<br class="">
     ConstString m_system_category_name;<br class="">
<br class="">
Modified: lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h?rev=255603&r1=255602&r2=255603&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h?rev=255603&r1=255602&r2=255603&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h (original)<br class="">
+++ lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h Mon Dec 14 20:20:48 2015<br class="">
@@ -69,6 +69,9 @@ public:<br class="">
     lldb::TypeCategoryImplSP<br class="">
     GetCategory () const;<br class="">
<br class="">
+    FormatCache&<br class="">
+    GetFormatCache ();<br class="">
+<br class="">
     void<br class="">
     Enable ();<br class="">
<br class="">
<br class="">
Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=255603&r1=255602&r2=255603&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=255603&r1=255602&r2=255603&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)<br class="">
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Mon Dec 14 20:20:48 2015<br class="">
@@ -123,6 +123,19 @@ GetFormatFromFormatName (const char *for<br class="">
     return false;<br class="">
 }<br class="">
<br class="">
+void<br class="">
+FormatManager::Changed ()<br class="">
+{<br class="">
+    ++m_last_revision;<br class="">
+    m_format_cache.Clear ();<br class="">
+    Mutex::Locker lang_locker(m_language_categories_mutex);<br class="">
+    for (auto& iter : m_language_categories_map)<br class="">
+    {<br class="">
+        if (iter.second)<br class="">
+            iter.second->GetFormatCache().Clear();<br class="">
+    }<br class="">
+}<br class="">
+<br class="">
 bool<br class="">
 FormatManager::GetFormatFromCString (const char *format_cstr,<br class="">
                                      bool partial_match_ok,<br class="">
@@ -1043,12 +1056,12 @@ FormatManager::GetHardcodedValidator (Fo<br class="">
 }<br class="">
<br class="">
 FormatManager::FormatManager() :<br class="">
+    m_last_revision(0),<br class="">
     m_format_cache(),<br class="">
+    m_language_categories_mutex(Mutex::eMutexTypeRecursive),<br class="">
+    m_language_categories_map(),<br class="">
     m_named_summaries_map(this),<br class="">
-    m_last_revision(0),<br class="">
     m_categories_map(this),<br class="">
-    m_language_categories_map(),<br class="">
-    m_language_categories_mutex(Mutex::eMutexTypeRecursive),<br class="">
     m_default_category_name(ConstString("default")),<br class="">
     m_system_category_name(ConstString("system")),<br class="">
     m_vectortypes_category_name(ConstString("VectorTypes"))<br class="">
@@ -1063,7 +1076,6 @@ FormatManager::FormatManager() :<br class="">
 void<br class="">
 FormatManager::LoadSystemFormatters()<br class="">
 {<br class="">
-<br class="">
     TypeSummaryImpl::Flags string_flags;<br class="">
     string_flags.SetCascades(true)<br class="">
     .SetSkipPointers(true)<br class="">
<br class="">
Modified: lldb/trunk/source/DataFormatters/LanguageCategory.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LanguageCategory.cpp?rev=255603&r1=255602&r2=255603&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LanguageCategory.cpp?rev=255603&r1=255602&r2=255603&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/DataFormatters/LanguageCategory.cpp (original)<br class="">
+++ lldb/trunk/source/DataFormatters/LanguageCategory.cpp Mon Dec 14 20:20:48 2015<br class="">
@@ -242,6 +242,12 @@ LanguageCategory::GetCategory () const<br class="">
     return m_category_sp;<br class="">
 }<br class="">
<br class="">
+FormatCache&<br class="">
+LanguageCategory::GetFormatCache ()<br class="">
+{<br class="">
+    return m_format_cache;<br class="">
+}<br class="">
+<br class="">
 void<br class="">
 LanguageCategory::Enable ()<br class="">
 {<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
lldb-commits mailing list<br class="">
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank" class="">lldb-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br class="">
</blockquote></div>
</div></blockquote></div><br class=""></div><div style="word-wrap:break-word" class=""><div class="">
<div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-position: normal; font-variant-caps: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><br class="">Thanks,</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-position: normal; font-variant-caps: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><i class="">- Enrico</i><br class="">📩 egranata@<font color="#ff2600" class=""></font>.com ☎️ 27683</div>
</div>
<br class=""></div></blockquote></div>
</div></blockquote></div></blockquote></div>
</div></blockquote></div><br class=""><div class="">
<div class="" style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class="Apple-interchange-newline">Thanks,</div><div class="" style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><i class="">- Enrico</i><br class="">📩 egranata@<font color="#ff2600" class=""></font>.com ☎️ 27683</div>
</div>
<br class=""></body></html>