use of com.facebook.stetho.dumpapp.DumpException in project stetho by facebook.
the class HprofDumperPlugin method writeHprof.
private void writeHprof(File outputPath) throws DumpException {
try {
// Test that we can write here. dumpHprofData appears to hang if it cannot write
// to the target location on ART.
truncateAndDeleteFile(outputPath);
Debug.dumpHprofData(outputPath.getAbsolutePath());
} catch (IOException e) {
throw new DumpException("Failure writing to " + outputPath + ": " + e.getMessage());
}
}
use of com.facebook.stetho.dumpapp.DumpException in project stetho by facebook.
the class CrashDumperPlugin method doUncaughtException.
private void doUncaughtException(Iterator<String> argsIter) throws DumpException {
String throwableClassString = ArgsHelper.nextOptionalArg(argsIter, OPTION_THROW_DEFAULT);
try {
Class<? extends Throwable> throwableClass = (Class<? extends Throwable>) Class.forName(throwableClassString);
Throwable t;
Constructor<? extends Throwable> ctorWithMessage = tryGetDeclaredConstructor(throwableClass, String.class);
if (ctorWithMessage != null) {
t = ctorWithMessage.newInstance("Uncaught exception triggered by Stetho");
} else {
Constructor<? extends Throwable> ctorParameterless = throwableClass.getDeclaredConstructor();
t = ctorParameterless.newInstance();
}
Thread crashThread = new Thread(new ThrowRunnable(t));
crashThread.start();
Util.joinUninterruptibly(crashThread);
} catch (ClassNotFoundException | ClassCastException | NoSuchMethodException | IllegalAccessException | InstantiationException e) {
throw new DumpException("Invalid supplied Throwable class: " + e);
} catch (InvocationTargetException e) {
// reflect that as a normal unchecked exception in dumpapp output.
throw ExceptionUtil.propagate(e.getCause());
}
}
use of com.facebook.stetho.dumpapp.DumpException in project stetho by facebook.
the class CrashDumperPlugin method doKill.
private void doKill(DumperContext dumpContext, Iterator<String> argsIter) throws DumpException {
String signal = ArgsHelper.nextOptionalArg(argsIter, OPTION_KILL_DEFAULT);
try {
Process kill = new ProcessBuilder().command("/system/bin/kill", "-" + signal, String.valueOf(android.os.Process.myPid())).redirectErrorStream(true).start();
// actually take out our process...
try {
InputStream in = kill.getInputStream();
Util.copy(in, dumpContext.getStdout(), new byte[1024]);
} finally {
kill.destroy();
}
} catch (IOException e) {
throw new DumpException("Failed to invoke kill: " + e);
}
}
use of com.facebook.stetho.dumpapp.DumpException in project fresco by facebook.
the class BaseFrescoStethoPlugin method diskcache.
private void diskcache(FileCache cache, String title, PrintStream writer, List<String> args) throws DumpException {
DiskStorage.DiskDumpInfo intDiskDumpInfo;
try {
intDiskDumpInfo = cache.getDumpInfo();
} catch (IOException e) {
throw new DumpException(e.getMessage());
}
if (!args.isEmpty() && args.get(0).equals("-s")) {
writeDiskDumpInfoScriptReadable(writer, intDiskDumpInfo);
} else {
writer.println();
writer.println(title + " disk cache contents:");
writeDiskDumpInfo(writer, intDiskDumpInfo);
}
}
use of com.facebook.stetho.dumpapp.DumpException in project fresco by facebook.
the class BaseFrescoStethoPlugin method getFiles.
private void getFiles(PrintStream writer, CountingMemoryCacheInspector.DumpInfo<CacheKey, CloseableImage> dumpInfo) throws DumpException, IOException {
writer.println("\nStoring all images in the memory cache into /sdcard/imagedumperfiles/ ...");
File dir = new File(Environment.getExternalStorageDirectory().getPath() + "/imagedumperfiles/");
if (dir.exists() && dir.isDirectory()) {
File[] files = dir.listFiles();
if (files != null) {
for (File file : files) {
file.delete();
}
}
if (!dir.delete()) {
throw new DumpException("Failed to clear existing /sdcard/imagedumperfiles directory");
}
}
if (!dir.mkdirs()) {
throw new DumpException("Failed to create /sdcard/imagedumperfiles directory");
}
if (!dumpInfo.lruEntries.isEmpty()) {
writer.println("LRU Entries:");
storeEntries(dumpInfo.lruEntries, 1, writer, dir);
}
if (!dumpInfo.sharedEntries.isEmpty()) {
writer.println("Shared Entries:");
storeEntries(dumpInfo.sharedEntries, dumpInfo.lruEntries.size() + 1, writer, dir);
}
writer.println("Done!");
}
Aggregations