libobs: Always write crashing thread first

This commit is contained in:
jp9000 2015-11-18 10:59:10 -08:00
parent f05f0592e0
commit c629bbe50f

View file

@ -377,13 +377,16 @@ static inline bool walk_stack(struct exception_handler_data *data,
#endif
static inline void write_thread_trace(struct exception_handler_data *data,
THREADENTRY32 *entry)
THREADENTRY32 *entry, bool first_thread)
{
bool crash_thread = entry->th32ThreadID == GetCurrentThreadId();
struct stack_trace trace = {0};
struct stack_trace *ptrace;
HANDLE thread;
if (first_thread != crash_thread)
return;
if (entry->th32OwnerProcessID != GetCurrentProcessId())
return;
@ -417,10 +420,16 @@ static inline void write_thread_traces(struct exception_handler_data *data)
return;
entry.dwSize = sizeof(entry);
success = !!Thread32First(snapshot, &entry);
success = !!Thread32First(snapshot, &entry);
while (success) {
write_thread_trace(data, &entry);
write_thread_trace(data, &entry, true);
success = !!Thread32Next(snapshot, &entry);
}
success = !!Thread32First(snapshot, &entry);
while (success) {
write_thread_trace(data, &entry, false);
success = !!Thread32Next(snapshot, &entry);
}