[cfe-commits] r92959 - /cfe/trunk/tools/CIndex/CIndex.cpp
Ted Kremenek
kremenek at apple.com
Thu Jan 7 15:13:54 PST 2010
Author: kremenek
Date: Thu Jan 7 17:13:53 2010
New Revision: 92959
URL: http://llvm.org/viewvc/llvm-project?rev=92959&view=rev
Log:
More crashtracer enhancements to CIndex. When "popping" a crashtracer string
restore to the one most recently created.
Modified:
cfe/trunk/tools/CIndex/CIndex.cpp
Modified: cfe/trunk/tools/CIndex/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=92959&r1=92958&r2=92959&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CIndex.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndex.cpp Thu Jan 7 17:13:53 2010
@@ -38,19 +38,20 @@
extern "C" const char *__crashreporter_info__;
#define NUM_CRASH_STRINGS 16
static unsigned crashtracer_counter = 0;
+static unsigned crashtracer_counter_id[NUM_CRASH_STRINGS] = { 0 };
static const char *crashtracer_strings[NUM_CRASH_STRINGS] = { 0 };
static const char *agg_crashtracer_strings[NUM_CRASH_STRINGS] = { 0 };
static unsigned SetCrashTracerInfo(const char *str,
llvm::SmallString<1024> &AggStr) {
- unsigned slot = crashtracer_counter;
+ unsigned slot = 0;
while (crashtracer_strings[slot]) {
if (++slot == NUM_CRASH_STRINGS)
slot = 0;
}
crashtracer_strings[slot] = str;
- crashtracer_counter = slot;
+ crashtracer_counter_id[slot] = ++crashtracer_counter;
// We need to create an aggregate string because multiple threads
// may be in this method at one time. The crash reporter string
@@ -67,14 +68,19 @@
}
static void ResetCrashTracerInfo(unsigned slot) {
- agg_crashtracer_strings[slot] = crashtracer_strings[slot] = 0;
- for (unsigned i = 0 ; i < NUM_CRASH_STRINGS; ++i) {
- if (agg_crashtracer_strings[i]) {
- __crashreporter_info__ = agg_crashtracer_strings[i];
- return;
+ unsigned max_slot = 0;
+ unsigned max_value = 0;
+
+ crashtracer_strings[slot] = agg_crashtracer_strings[slot] = 0;
+
+ for (unsigned i = 0 ; i < NUM_CRASH_STRINGS; ++i)
+ if (agg_crashtracer_strings[i] &&
+ crashtracer_counter_id[i] > max_value) {
+ max_slot = i;
+ max_value = crashtracer_counter_id[i];
}
- }
- __crashreporter_info__ = 0;
+
+ __crashreporter_info__ = agg_crashtracer_strings[max_slot];
}
namespace {
More information about the cfe-commits
mailing list