< prev index next >

src/share/vm/logging/log.cpp

Print this page
rev 10535 : imported patch 8151438
rev 10536 : [mq]: 8151438.01

*** 157,162 **** --- 157,207 ---- LogConfiguration::disable_logging(); assert(Test_logconfiguration_subscribe_triggered == 3, "subscription not triggered (3)"); } + void Test_logtagset_duplicates() { + for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + char ts_name[512]; + ts->label(ts_name, sizeof(ts_name), ","); + + // verify that NO_TAG is never followed by a real tag + for (size_t i = 0; i < LogTag::MaxTags; i++) { + if (ts->tag(i) == LogTag::__NO_TAG) { + for (i++; i < LogTag::MaxTags; i++) { + assert(ts->tag(i) == LogTag::__NO_TAG, + "NO_TAG was followed by a real tag (%s) in tagset %s", + LogTag::name(ts->tag(i)), ts_name); + } + } + } + + // verify that there are no duplicate tagsets (same tags in different order) + for (LogTagSet* other = ts->next(); other != NULL; other = other->next()) { + if (ts->ntags() != other->ntags()) { + continue; + } + bool equal = true; + for (size_t i = 0; i < ts->ntags(); i++) { + LogTagType tag = ts->tag(i); + if (!other->contains(tag)) { + equal = false; + break; + } + } + // Since tagsets are implemented using template arguments, using both of + // the (logically equivalent) tagsets (t1, t2) and (t2, t1) somewhere will + // instantiate two different LogTagSetMappings. This causes multiple + // tagset instances to be created for the same logical set. We want to + // avoid this to save time, memory and prevent any confusion around it. + if (equal) { + char other_name[512]; + other->label(other_name, sizeof(other_name), ","); + assert(false, "duplicate LogTagSets found: '%s' vs '%s' " + "(tags must always be specified in the same order for each tagset)", + ts_name, other_name); + } + } + } + } + #endif // PRODUCT
< prev index next >