Add a thread dump section to the log.

This commit is contained in:
Greyson Parrelli
2025-02-07 16:49:18 -05:00
parent 02bf7edb18
commit 1fe58e2bc5
2 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
package org.thoughtcrime.securesms.logsubmit;
import android.content.Context;
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
public class LogSectionCurrentThreadDump implements LogSection {
@Override
public @NonNull String getTitle() {
return "LAST THREAD DUMP";
}
@Override
public @NonNull CharSequence getContent(@NonNull Context context) {
Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces();
StringBuilder out = new StringBuilder();
for (Map.Entry<Thread, StackTraceElement[]> entry : traces.entrySet()) {
Thread thread = entry.getKey();
out.append("-- [").append(thread.getId()).append("] ")
.append(thread.getName()).append(" (").append(thread.getState()).append(")\n");
for (StackTraceElement element : entry.getValue()) {
out.append(element.toString()).append("\n");
}
out.append("\n");
}
return out;
}
}

View File

@@ -93,6 +93,7 @@ public class SubmitDebugLogRepository {
add(new LogSectionTrace()); add(new LogSectionTrace());
add(new LogSectionThreads()); add(new LogSectionThreads());
add(new LogSectionThreadDump()); add(new LogSectionThreadDump());
add(new LogSectionCurrentThreadDump());
if (RemoteConfig.internalUser()) { if (RemoteConfig.internalUser()) {
add(new LogSectionSenderKey()); add(new LogSectionSenderKey());
} }