CrashDumperPlugin.smali
.class public Lcom/facebook/stetho/dumpapp/plugins/CrashDumperPlugin;
.super Ljava/lang/Object;
.source "SourceFile"
# interfaces
.implements Lcom/facebook/stetho/dumpapp/DumperPlugin;
# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcom/facebook/stetho/dumpapp/plugins/CrashDumperPlugin$ThrowRunnable;
}
.end annotation
# static fields
.field private static final NAME:Ljava/lang/String; = "crash"
.field private static final OPTION_EXIT_DEFAULT:Ljava/lang/String; = "0"
.field private static final OPTION_KILL_DEFAULT:Ljava/lang/String; = "9"
.field private static final OPTION_THROW_DEFAULT:Ljava/lang/String; = "java.lang.Error"
# direct methods
.method public constructor <init>()V
.registers 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public static INVOKEVIRTUAL_com_facebook_stetho_dumpapp_plugins_CrashDumperPlugin_com_shopee_app_asm_fix_androidx_ThreadFixer_start(Ljava/lang/Thread;)V
.registers 3
.line 1
:try_start_0
invoke-static {}, Lcom/shopee/app/asm/fix/androidx/b;->b()Z
move-result v0
if-eqz v0, :cond_12
.line 2
invoke-static {p0}, Lcom/shopee/app/asm/fix/androidx/b;->a(Ljava/lang/Thread;)V
:try_end_9
.catchall {:try_start_0 .. :try_end_9} :catchall_a
goto :goto_12
:catchall_a
move-exception v0
.line 3
invoke-static {}, Lcom/shopee/app/apm/c;->d()Lcom/shopee/app/apm/nonfatal/a;
move-result-object v1
invoke-virtual {v1, v0}, Lcom/shopee/app/apm/nonfatal/a;->c(Ljava/lang/Throwable;)V
.line 4
:cond_12
:goto_12
invoke-virtual {p0}, Ljava/lang/Thread;->start()V
return-void
.end method
.method private doKill(Lcom/facebook/stetho/dumpapp/DumperContext;Ljava/util/Iterator;)V
.registers 7
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/facebook/stetho/dumpapp/DumperContext;",
"Ljava/util/Iterator<",
"Ljava/lang/String;",
">;)V"
}
.end annotation
.annotation system Ldalvik/annotation/Throws;
value = {
Lcom/facebook/stetho/dumpapp/DumpException;
}
.end annotation
const-string v0, "9"
.line 1
invoke-static {p2, v0}, Lcom/facebook/stetho/dumpapp/ArgsHelper;->nextOptionalArg(Ljava/util/Iterator;Ljava/lang/String;)Ljava/lang/String;
move-result-object p2
.line 2
:try_start_6
new-instance v0, Ljava/lang/ProcessBuilder;
const/4 v1, 0x0
new-array v2, v1, [Ljava/lang/String;
invoke-direct {v0, v2}, Ljava/lang/ProcessBuilder;-><init>([Ljava/lang/String;)V
const/4 v2, 0x3
new-array v2, v2, [Ljava/lang/String;
const-string v3, "/system/bin/kill"
aput-object v3, v2, v1
new-instance v1, Ljava/lang/StringBuilder;
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
const-string v3, "-"
invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v1, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p2
const/4 v1, 0x1
aput-object p2, v2, v1
const/4 p2, 0x2
.line 3
invoke-static {}, Landroid/os/Process;->myPid()I
move-result v3
invoke-static {v3}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;
move-result-object v3
aput-object v3, v2, p2
invoke-virtual {v0, v2}, Ljava/lang/ProcessBuilder;->command([Ljava/lang/String;)Ljava/lang/ProcessBuilder;
move-result-object p2
.line 4
invoke-virtual {p2, v1}, Ljava/lang/ProcessBuilder;->redirectErrorStream(Z)Ljava/lang/ProcessBuilder;
move-result-object p2
.line 5
invoke-virtual {p2}, Ljava/lang/ProcessBuilder;->start()Ljava/lang/Process;
move-result-object p2
:try_end_40
.catch Ljava/io/IOException; {:try_start_6 .. :try_end_40} :catch_58
.line 6
:try_start_40
invoke-virtual {p2}, Ljava/lang/Process;->getInputStream()Ljava/io/InputStream;
move-result-object v0
.line 7
invoke-virtual {p1}, Lcom/facebook/stetho/dumpapp/DumperContext;->getStdout()Ljava/io/PrintStream;
move-result-object p1
const/16 v1, 0x400
new-array v1, v1, [B
invoke-static {v0, p1, v1}, Lcom/facebook/stetho/common/Util;->copy(Ljava/io/InputStream;Ljava/io/OutputStream;[B)V
:try_end_4f
.catchall {:try_start_40 .. :try_end_4f} :catchall_53
.line 8
:try_start_4f
invoke-virtual {p2}, Ljava/lang/Process;->destroy()V
return-void
:catchall_53
move-exception p1
invoke-virtual {p2}, Ljava/lang/Process;->destroy()V
throw p1
:try_end_58
.catch Ljava/io/IOException; {:try_start_4f .. :try_end_58} :catch_58
:catch_58
move-exception p1
.line 9
new-instance p2, Lcom/facebook/stetho/dumpapp/DumpException;
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
const-string v1, "Failed to invoke kill: "
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p1
invoke-direct {p2, p1}, Lcom/facebook/stetho/dumpapp/DumpException;-><init>(Ljava/lang/String;)V
throw p2
.end method
.method private doSystemExit(Ljava/util/Iterator;)V
.registers 3
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Ljava/util/Iterator<",
"Ljava/lang/String;",
">;)V"
}
.end annotation
const-string v0, "0"
.line 1
invoke-static {p1, v0}, Lcom/facebook/stetho/dumpapp/ArgsHelper;->nextOptionalArg(Ljava/util/Iterator;Ljava/lang/String;)Ljava/lang/String;
move-result-object p1
.line 2
invoke-static {p1}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;)I
move-result p1
invoke-static {p1}, Ljava/lang/System;->exit(I)V
return-void
.end method
.method private doUncaughtException(Ljava/util/Iterator;)V
.registers 6
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Ljava/util/Iterator<",
"Ljava/lang/String;",
">;)V"
}
.end annotation
.annotation system Ldalvik/annotation/Throws;
value = {
Lcom/facebook/stetho/dumpapp/DumpException;
}
.end annotation
const-string v0, "java.lang.Error"
.line 1
invoke-static {p1, v0}, Lcom/facebook/stetho/dumpapp/ArgsHelper;->nextOptionalArg(Ljava/util/Iterator;Ljava/lang/String;)Ljava/lang/String;
move-result-object p1
.line 2
:try_start_6
invoke-static {p1}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;
move-result-object p1
const/4 v0, 0x1
new-array v1, v0, [Ljava/lang/Class;
.line 3
const-class v2, Ljava/lang/String;
const/4 v3, 0x0
aput-object v2, v1, v3
.line 4
invoke-static {p1, v1}, Lcom/facebook/stetho/dumpapp/plugins/CrashDumperPlugin;->tryGetDeclaredConstructor(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
move-result-object v1
if-eqz v1, :cond_25
new-array p1, v0, [Ljava/lang/Object;
const-string v0, "Uncaught exception triggered by Stetho"
aput-object v0, p1, v3
.line 5
invoke-virtual {v1, p1}, Ljava/lang/reflect/Constructor;->newInstance([Ljava/lang/Object;)Ljava/lang/Object;
move-result-object p1
check-cast p1, Ljava/lang/Throwable;
goto :goto_33
:cond_25
new-array v0, v3, [Ljava/lang/Class;
.line 6
invoke-virtual {p1, v0}, Ljava/lang/Class;->getDeclaredConstructor([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
move-result-object p1
new-array v0, v3, [Ljava/lang/Object;
.line 7
invoke-virtual {p1, v0}, Ljava/lang/reflect/Constructor;->newInstance([Ljava/lang/Object;)Ljava/lang/Object;
move-result-object p1
check-cast p1, Ljava/lang/Throwable;
.line 8
:goto_33
new-instance v0, Ljava/lang/Thread;
new-instance v1, Lcom/facebook/stetho/dumpapp/plugins/CrashDumperPlugin$ThrowRunnable;
invoke-direct {v1, p1}, Lcom/facebook/stetho/dumpapp/plugins/CrashDumperPlugin$ThrowRunnable;-><init>(Ljava/lang/Throwable;)V
invoke-direct {v0, v1}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V
.line 9
invoke-static {v0}, Lcom/facebook/stetho/dumpapp/plugins/CrashDumperPlugin;->INVOKEVIRTUAL_com_facebook_stetho_dumpapp_plugins_CrashDumperPlugin_com_shopee_app_asm_fix_androidx_ThreadFixer_start(Ljava/lang/Thread;)V
.line 10
invoke-static {v0}, Lcom/facebook/stetho/common/Util;->joinUninterruptibly(Ljava/lang/Thread;)V
:try_end_43
.catch Ljava/lang/ClassNotFoundException; {:try_start_6 .. :try_end_43} :catch_56
.catch Ljava/lang/ClassCastException; {:try_start_6 .. :try_end_43} :catch_54
.catch Ljava/lang/NoSuchMethodException; {:try_start_6 .. :try_end_43} :catch_52
.catch Ljava/lang/IllegalAccessException; {:try_start_6 .. :try_end_43} :catch_50
.catch Ljava/lang/InstantiationException; {:try_start_6 .. :try_end_43} :catch_4e
.catch Ljava/lang/reflect/InvocationTargetException; {:try_start_6 .. :try_end_43} :catch_44
return-void
:catch_44
move-exception p1
.line 11
invoke-virtual {p1}, Ljava/lang/reflect/InvocationTargetException;->getCause()Ljava/lang/Throwable;
move-result-object p1
invoke-static {p1}, Lcom/facebook/stetho/common/ExceptionUtil;->propagate(Ljava/lang/Throwable;)Ljava/lang/RuntimeException;
move-result-object p1
throw p1
:catch_4e
move-exception p1
goto :goto_57
:catch_50
move-exception p1
goto :goto_57
:catch_52
move-exception p1
goto :goto_57
:catch_54
move-exception p1
goto :goto_57
:catch_56
move-exception p1
.line 12
:goto_57
new-instance v0, Lcom/facebook/stetho/dumpapp/DumpException;
const-string v1, "Invalid supplied Throwable class: "
.line 13
invoke-static {v1, p1}, Landroidx/appcompat/b;->b(Ljava/lang/String;Ljava/lang/Exception;)Ljava/lang/String;
move-result-object p1
.line 14
invoke-direct {v0, p1}, Lcom/facebook/stetho/dumpapp/DumpException;-><init>(Ljava/lang/String;)V
throw v0
.end method
.method private doUsage(Ljava/io/PrintStream;)V
.registers 3
const-string v0, "Usage: dumpapp crash <command> [command-options]"
.line 1
invoke-virtual {p1, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
const-string v0, "Usage: dumpapp crash throw"
.line 2
invoke-virtual {p1, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
const-string v0, " dumpapp crash kill"
.line 3
invoke-virtual {p1, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
const-string v0, " dumpapp crash exit"
.line 4
invoke-virtual {p1, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
.line 5
invoke-virtual {p1}, Ljava/io/PrintStream;->println()V
const-string v0, "dumpapp crash throw: Throw an uncaught exception (simulates a program crash)"
.line 6
invoke-virtual {p1, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
const-string v0, " <Throwable>: Throwable class to use (default: java.lang.Error)"
.line 7
invoke-virtual {p1, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
.line 8
invoke-virtual {p1}, Ljava/io/PrintStream;->println()V
const-string v0, "dumpapp crash kill: Send a signal to this process (simulates the low memory killer)"
.line 9
invoke-virtual {p1, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
const-string v0, " <SIGNAL>: Either signal name or number to send (default: 9)"
.line 10
invoke-virtual {p1, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
const-string v0, " See `adb shell kill -l` for more information"
.line 11
invoke-virtual {p1, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
.line 12
invoke-virtual {p1}, Ljava/io/PrintStream;->println()V
const-string v0, "dumpapp crash exit: Invoke System.exit (simulates an abnormal Android exit strategy)"
.line 13
invoke-virtual {p1, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
const-string v0, " <code>: Exit code (default: 0)"
.line 14
invoke-virtual {p1, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
return-void
.end method
.method private static varargs tryGetDeclaredConstructor(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
.registers 2
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">(",
"Ljava/lang/Class<",
"TT;>;[",
"Ljava/lang/Class<",
"*>;)",
"Ljava/lang/reflect/Constructor<",
"+TT;>;"
}
.end annotation
:try_start_0
invoke-virtual {p0, p1}, Ljava/lang/Class;->getDeclaredConstructor([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
move-result-object p0
:try_end_4
.catch Ljava/lang/NoSuchMethodException; {:try_start_0 .. :try_end_4} :catch_5
return-object p0
:catch_5
const/4 p0, 0x0
return-object p0
.end method
# virtual methods
.method public dump(Lcom/facebook/stetho/dumpapp/DumperContext;)V
.registers 5
.annotation system Ldalvik/annotation/Throws;
value = {
Lcom/facebook/stetho/dumpapp/DumpException;
}
.end annotation
.line 1
invoke-virtual {p1}, Lcom/facebook/stetho/dumpapp/DumperContext;->getArgsAsList()Ljava/util/List;
move-result-object v0
invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;
move-result-object v0
const/4 v1, 0x0
.line 2
invoke-static {v0, v1}, Lcom/facebook/stetho/dumpapp/ArgsHelper;->nextOptionalArg(Ljava/util/Iterator;Ljava/lang/String;)Ljava/lang/String;
move-result-object v1
const-string v2, "throw"
.line 3
invoke-virtual {v2, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v2
if-eqz v2, :cond_19
.line 4
invoke-direct {p0, v0}, Lcom/facebook/stetho/dumpapp/plugins/CrashDumperPlugin;->doUncaughtException(Ljava/util/Iterator;)V
goto :goto_3a
:cond_19
const-string v2, "kill"
.line 5
invoke-virtual {v2, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v2
if-eqz v2, :cond_25
.line 6
invoke-direct {p0, p1, v0}, Lcom/facebook/stetho/dumpapp/plugins/CrashDumperPlugin;->doKill(Lcom/facebook/stetho/dumpapp/DumperContext;Ljava/util/Iterator;)V
goto :goto_3a
:cond_25
const-string v2, "exit"
.line 7
invoke-virtual {v2, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v2
if-eqz v2, :cond_31
.line 8
invoke-direct {p0, v0}, Lcom/facebook/stetho/dumpapp/plugins/CrashDumperPlugin;->doSystemExit(Ljava/util/Iterator;)V
goto :goto_3a
.line 9
:cond_31
invoke-virtual {p1}, Lcom/facebook/stetho/dumpapp/DumperContext;->getStdout()Ljava/io/PrintStream;
move-result-object p1
invoke-direct {p0, p1}, Lcom/facebook/stetho/dumpapp/plugins/CrashDumperPlugin;->doUsage(Ljava/io/PrintStream;)V
if-nez v1, :cond_3b
:goto_3a
return-void
.line 10
:cond_3b
new-instance p1, Lcom/facebook/stetho/dumpapp/DumpUsageException;
const-string v0, "Unsupported command: "
.line 11
invoke-static {v0, v1}, Landroidx/appcompat/e;->g(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
move-result-object v0
.line 12
invoke-direct {p1, v0}, Lcom/facebook/stetho/dumpapp/DumpUsageException;-><init>(Ljava/lang/String;)V
throw p1
.end method
.method public getName()Ljava/lang/String;
.registers 2
const-string v0, "crash"
return-object v0
.end method