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

View File

@@ -62,7 +62,8 @@ public class SectionsFlipperPlugin implements FlipperPlugin, ChangesetListener {
String surfaceId, String surfaceId,
String id, String id,
FlipperArray tree, FlipperArray tree,
FlipperObject changesetData) { FlipperObject changesetData,
StackTraceElement[] trace) {
if (mConnection == null) { if (mConnection == null) {
return; return;
} }
@@ -84,7 +85,9 @@ public class SectionsFlipperPlugin implements FlipperPlugin, ChangesetListener {
.put("reason", reason) .put("reason", reason)
.put("surface_key", surfaceId) .put("surface_key", surfaceId)
.put("tree_generation_timestamp", 10000) // TODO .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()) .put("payload", eventPayloadBuilder.build())
.build()); .build());
@@ -122,4 +125,14 @@ public class SectionsFlipperPlugin implements FlipperPlugin, ChangesetListener {
.put("changeset", changesetData) .put("changeset", changesetData)
.build()); .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, id: string,
reason: string, reason: string,
stack_trace: Array<string>, stack_trace: Array<string>,
skip_stack_trace_format?: boolean,
surface_key: string, surface_key: string,
event_timestamp: number, event_timestamp: number,
update_mode: number, update_mode: number,

View File

@@ -22,10 +22,23 @@ function isSystemLibrary(libraryName: ?string): boolean {
type Props = { type Props = {
data: Array<string>, data: Array<string>,
skip_stack_trace_format?: boolean,
}; };
export default class extends React.Component<Props> { export default class extends React.Component<Props> {
render() { 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 ( return (
<StackTrace backgroundColor={colors.white}> <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 */} {/* 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)} {this.renderTreeHierarchy(focusedTreeGeneration)}
{focusedTreeGeneration && ( {focusedTreeGeneration && (
<Sidebar position="bottom" minHeight={100} height={250}> <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> </Sidebar>
)} )}
<DetailSidebar> <DetailSidebar>