11namespace tracktion {
inline namespace engine
18 entries.ensureStorageAllocated (64);
28 entries.removeFirstMatchingValue (c);
33 #if TRACKTION_LOG_ENABLED
36 for (
int i = entries.size(); --i >= 0;)
39 for (
int j = 0; j < threads.
size(); ++j)
46 for (
int i = entries.size(); --i >= 0;)
48 auto& s = *entries.getUnchecked (i);
50 if (s.threadID == thread)
52 if (s.pluginName !=
nullptr)
53 TRACKTION_LOG (
" ** Plugin crashed: " +
juce::String (s.pluginName));
69 for (
int i = entries.size(); --i >= 0;)
71 auto entryThreadID = entries.getUnchecked (i)->threadID;
73 if (entryThreadID == threadIDToDump || entryThreadID == juce::Thread::ThreadID())
77 for (
int j = 0; j < threads.
size(); ++j)
84 for (
int i = entries.size(); --i >= 0;)
86 auto& s = *entries.getUnchecked (i);
88 if (s.threadID == thread)
90 if (s.pluginName !=
nullptr)
106 for (
auto s : entries)
107 if (s->pluginName !=
nullptr)
108 plugins.
add (s->pluginName);
113 juce::String getCrashedPlugin (juce::Thread::ThreadID thread)
115 for (
int i = entries.size(); --i >= 0;)
117 auto& s = *entries.getUnchecked (i);
119 if (s.threadID == thread)
120 if (s.pluginName !=
nullptr)
127 juce::String getCrashLocation (juce::Thread::ThreadID thread)
129 for (
int i = entries.size(); --i >= 0;)
131 auto& s = *entries.getUnchecked (i);
133 if (s.threadID == thread)
138 return "UnknownLocation";
146CrashStackTracer::CrashStackTracer (
const char* f,
const char* fn,
int l,
const char* plugin)
147 : file (f), function (fn), pluginName (plugin), line (l), threadID (
juce::Thread::getCurrentThreadId())
149 crashStack.push (
this);
151 #if ! TRACKTION_LOG_ENABLED
156CrashStackTracer::~CrashStackTracer()
158 crashStack.pop (
this);
163 return crashStack.getCrashedPlugins();
166void CrashStackTracer::dump()
168 TRACKTION_LOG (
"Crashed");
175 dump (os, juce::Thread::ThreadID());
180 os.
writeText (
"Crashed",
false,
false,
nullptr);
182 crashStack.dump (os, threadID);
185juce::String CrashStackTracer::getCrashedPlugin (juce::Thread::ThreadID threadID)
187 return crashStack.getCrashedPlugin (threadID);
190juce::String CrashStackTracer::getCrashLocation (juce::Thread::ThreadID threadID)
192 return crashStack.getCrashLocation (threadID);
196DeadMansPedalMessage::DeadMansPedalMessage (PropertyStorage& ps,
const juce::String& message)
197 : file (getDeadMansPedalFile (ps))
199 file.replaceWithText (message);
202DeadMansPedalMessage::~DeadMansPedalMessage()
204 auto success = file.deleteFile();
209juce::String DeadMansPedalMessage::getAndClearLastMessage (PropertyStorage& propertyStorage)
211 auto file = getDeadMansPedalFile (propertyStorage);
212 auto s = file.loadFileAsString();
223juce::File DeadMansPedalMessage::getDeadMansPedalFile (PropertyStorage& propertyStorage)
225 auto folder = propertyStorage.getAppPrefsFolder();
226 jassert (folder.exists() && folder.hasWriteAccess());
227 return folder.getChildFile (
"deadMansPedal");
ElementType getUnchecked(int index) const
int size() const noexcept
bool addIfNotAlreadyThere(ParameterType newElement)
String getFileName() const
static File createFileWithoutCheckingPath(const String &absolutePath) noexcept
virtual bool writeText(const String &text, bool asUTF16, bool writeUTF16ByteOrderMark, const char *lineEndings)
void add(String stringToAdd)
void ignoreUnused(Types &&...) noexcept
Used by the CRASH_TRACER macros to help provide a useful crash log of the stack.