Show caller stack trace

Summary: On Android, the stack trace looks different so we don't need to use the Regex we use on iOS. We can simply display all the lines in the trace.

Reviewed By: pasqualeanatriello

Differential Revision: D17181400

fbshipit-source-id: e471da17b89806a161edc7edcf05ac6faed44bf0
This commit is contained in:
Mihaela Ogrezeanu
2019-11-19 10:26:30 -08:00
committed by Facebook Github Bot
parent 73e8c03eea
commit 4d324075e9
5 changed files with 39 additions and 5 deletions

View File

@@ -40,7 +40,8 @@ public class ChangesetDebug implements ChangesetDebugListener {
String surfaceId,
String id,
FlipperArray tree,
FlipperObject changesetData);
FlipperObject changesetData,
StackTraceElement[] trace);
}
public static void setListener(ChangesetListener listener) {
@@ -103,7 +104,8 @@ public class ChangesetDebug implements ChangesetDebugListener {
surfaceId,
sChangesetIdGenerator.incrementAndGet() + "-" + surfaceId,
tree.build(),
changesetData.build());
changesetData.build(),
changesetDebugInfo.getStackTrace());
}
private static boolean isEventAsync(@ApplyNewChangeSet int source) {

View File

@@ -62,7 +62,8 @@ public class SectionsFlipperPlugin implements FlipperPlugin, ChangesetListener {
String surfaceId,
String id,
FlipperArray tree,
FlipperObject changesetData) {
FlipperObject changesetData,
StackTraceElement[] trace) {
if (mConnection == null) {
return;
}
@@ -84,7 +85,9 @@ public class SectionsFlipperPlugin implements FlipperPlugin, ChangesetListener {
.put("reason", reason)
.put("surface_key", surfaceId)
.put("tree_generation_timestamp", 10000) // TODO
.put("stack_trace", new FlipperArray.Builder().build())
.put("payload", new FlipperObject.Builder().build())
.put("stack_trace", getStackTrace(trace))
.put("skip_stack_trace_format", true)
.put("payload", eventPayloadBuilder.build())
.build());
@@ -122,4 +125,14 @@ public class SectionsFlipperPlugin implements FlipperPlugin, ChangesetListener {
.put("changeset", changesetData)
.build());
}
private FlipperArray getStackTrace(StackTraceElement[] trace) {
final FlipperArray.Builder builder = new FlipperArray.Builder();
for (StackTraceElement element : trace) {
builder.put(element.toString() + "\n");
}
return builder.build();
}
}

View File

@@ -16,6 +16,7 @@ export type AddEventPayload = {|
id: string,
reason: string,
stack_trace: Array<string>,
skip_stack_trace_format?: boolean,
surface_key: string,
event_timestamp: number,
update_mode: number,

View File

@@ -22,10 +22,23 @@ function isSystemLibrary(libraryName: ?string): boolean {
type Props = {
data: Array<string>,
skip_stack_trace_format?: boolean,
};
export default class extends React.Component<Props> {
render() {
if (this.props.skip_stack_trace_format) {
return (
<StackTrace backgroundColor={colors.white}>
{this.props.data.map(stack_trace_line => {
return {
caller: stack_trace_line,
};
})}
</StackTrace>
);
}
return (
<StackTrace backgroundColor={colors.white}>
{/* We need to filter out from the stack trace any reference to the plugin such that the information is more coincised and focused */}

View File

@@ -284,7 +284,12 @@ export default class extends FlipperPlugin<State, *, PersistedState> {
{this.renderTreeHierarchy(focusedTreeGeneration)}
{focusedTreeGeneration && (
<Sidebar position="bottom" minHeight={100} height={250}>
<StackTrace data={focusedTreeGeneration.stack_trace} />
<StackTrace
data={focusedTreeGeneration.stack_trace}
skip_stack_trace_format={
focusedTreeGeneration.skip_stack_trace_format
}
/>
</Sidebar>
)}
<DetailSidebar>