11package io .sentry .android .core .internal .tombstone ;
22
33import androidx .annotation .NonNull ;
4-
5- import java .io .IOException ;
6- import java .io .InputStream ;
7- import java .util .ArrayList ;
8- import java .util .HashMap ;
9- import java .util .List ;
10- import java .util .Locale ;
11- import java .util .Map ;
12-
134import io .sentry .SentryEvent ;
145import io .sentry .SentryLevel ;
156import io .sentry .protocol .DebugImage ;
2011import io .sentry .protocol .SentryStackFrame ;
2112import io .sentry .protocol .SentryStackTrace ;
2213import io .sentry .protocol .SentryThread ;
14+ import java .io .IOException ;
15+ import java .io .InputStream ;
16+ import java .util .ArrayList ;
17+ import java .util .HashMap ;
18+ import java .util .List ;
19+ import java .util .Locale ;
20+ import java .util .Map ;
2321
2422public class TombstoneParser {
2523
@@ -44,7 +42,7 @@ public SentryEvent parse() throws IOException {
4442 SentryEvent event = new SentryEvent ();
4543 event .setLevel (SentryLevel .FATAL );
4644
47- // we must use the "native" platform because otherwise the stack-trace would not be correctly parsed
45+ // must use the "native" platform because otherwise the stack-trace wouldn't be correctly parsed
4846 event .setPlatform ("native" );
4947
5048 event .setMessage (constructMessage (tombstone ));
@@ -57,10 +55,11 @@ public SentryEvent parse() throws IOException {
5755 }
5856
5957 @ NonNull
60- private List <SentryThread > createThreads (TombstoneProtos .Tombstone tombstone , SentryException exc ) {
58+ private List <SentryThread > createThreads (
59+ TombstoneProtos .Tombstone tombstone , SentryException exc ) {
6160 List <SentryThread > threads = new ArrayList <>();
6261 for (Map .Entry <Integer , TombstoneProtos .Thread > threadEntry :
63- tombstone .getThreadsMap ().entrySet ()) {
62+ tombstone .getThreadsMap ().entrySet ()) {
6463
6564 SentryThread thread = new SentryThread ();
6665 thread .setId (Long .valueOf (threadEntry .getKey ()));
@@ -70,7 +69,8 @@ private List<SentryThread> createThreads(TombstoneProtos.Tombstone tombstone, Se
7069 thread .setStacktrace (stacktrace );
7170 if (tombstone .getTid () == threadEntry .getValue ().getId ()) {
7271 thread .setCrashed (true );
73- // even though we refer to the thread_id from the exception, the backend currently requires a stack-trace in exception
72+ // even though we refer to the thread_id from the exception,
73+ // the backend currently requires a stack-trace in exception
7474 exc .setStacktrace (stacktrace );
7575 }
7676 threads .add (thread );
@@ -80,11 +80,11 @@ private List<SentryThread> createThreads(TombstoneProtos.Tombstone tombstone, Se
8080 }
8181
8282 @ NonNull
83- private static SentryStackTrace createStackTrace (Map .Entry <Integer , TombstoneProtos .Thread > threadEntry ) {
83+ private static SentryStackTrace createStackTrace (
84+ Map .Entry <Integer , TombstoneProtos .Thread > threadEntry ) {
8485 List <SentryStackFrame > frames = new ArrayList <>();
8586
86- for (TombstoneProtos .BacktraceFrame frame :
87- threadEntry .getValue ().getCurrentBacktraceList ()) {
87+ for (TombstoneProtos .BacktraceFrame frame : threadEntry .getValue ().getCurrentBacktraceList ()) {
8888 SentryStackFrame stackFrame = new SentryStackFrame ();
8989 stackFrame .setPackage (frame .getFileName ());
9090 stackFrame .setFunction (frame .getFunctionName ());
@@ -96,7 +96,7 @@ private static SentryStackTrace createStackTrace(Map.Entry<Integer, TombstonePro
9696 stacktrace .setFrames (frames );
9797
9898 Map <String , Object > unknown = new HashMap <>();
99- // `libunwindstack` used for tombstone generation already applies instruction address adjustment:
99+ // `libunwindstack` used for tombstones already applies instruction address adjustment:
100100 // https://android.googlesource.com/platform/system/unwinding/+/refs/heads/main/libunwindstack/Regs.cpp#175
101101 // prevent "processing" from doing it again.
102102 unknown .put ("instruction_addr_adjustment" , "none" );
@@ -136,8 +136,8 @@ private static Mechanism createMechanismFromSignalInfo(TombstoneProtos.Signal si
136136 meta .put ("code_name" , signalInfo .getCodeName ());
137137
138138 Mechanism mechanism = new Mechanism ();
139- // this follows the current processing triggers strictly, changing any of these alters grouping and name (long-term we might want to
140- // have a tombstone mechanism)
139+ // this follows the current processing triggers strictly, changing any of these
140+ // alters grouping and name (long-term we might want to have a tombstone mechanism)
141141 mechanism .setType ("signalhandler" );
142142 mechanism .setHandled (false );
143143 mechanism .setSynthetic (true );
@@ -153,14 +153,15 @@ private Message constructMessage(TombstoneProtos.Tombstone tombstone) {
153153
154154 // reproduce the message `debuggerd` would use to dump the stack trace in logcat
155155 message .setFormatted (
156- String .format (Locale .getDefault (),
157- "Fatal signal %s (%d), %s (%d), pid = %d (%s)" ,
158- signalInfo .getName (),
159- signalInfo .getNumber (),
160- signalInfo .getCodeName (),
161- signalInfo .getCode (),
162- tombstone .getPid (),
163- String .join (" " , tombstone .getCommandLineList ())));
156+ String .format (
157+ Locale .getDefault (),
158+ "Fatal signal %s (%d), %s (%d), pid = %d (%s)" ,
159+ signalInfo .getName (),
160+ signalInfo .getNumber (),
161+ signalInfo .getCodeName (),
162+ signalInfo .getCode (),
163+ tombstone .getPid (),
164+ String .join (" " , tombstone .getCommandLineList ())));
164165
165166 return message ;
166167 }
@@ -171,8 +172,8 @@ private DebugMeta createDebugMeta(TombstoneProtos.Tombstone tombstone) {
171172 for (TombstoneProtos .MemoryMapping module : tombstone .getMemoryMappingsList ()) {
172173 // exclude anonymous and non-executable maps
173174 if (module .getBuildId ().isEmpty ()
174- || module .getMappingName ().isEmpty ()
175- || !module .getExecute ()) {
175+ || module .getMappingName ().isEmpty ()
176+ || !module .getExecute ()) {
176177 continue ;
177178 }
178179 DebugImage image = new DebugImage ();
0 commit comments