android dumpsys dumpstate
Cross Reference: /frameworks/native/cmds/dumpstate/dumpstate.cpp
638 static void dumpstate(const std::string& screenshot_path, const std::string& version) { 639 DurationReporter duration_reporter("DUMPSTATE"); 640 unsigned long timeout; 641 642 dump_dev_files("TRUSTY VERSION", "/sys/bus/platform/drivers/trusty", "trusty_version"); 643 run_command("UPTIME", 10, "uptime", NULL); 644 dump_files( "UPTIME MMC PERF", mmcblk0, skip_not_stat, dump_stat_from_fd); 645 dump_emmc_ecsd("/d/mmc0/mmc0:0001/ext_csd"); 646 dump_file( "MEMORY INFO", "/proc/meminfo"); 647 run_command("CPU INFO", 10, "top", "-n", "1", "-d", "1", "-m", "30", "-H", NULL); 648 run_command("PROCRANK", 20, SU_PATH, "root", "procrank", NULL); 649 dump_file( "VIRTUAL MEMORY STATS", "/proc/vmstat"); 650 dump_file( "VMALLOC INFO", "/proc/vmallocinfo"); 651 dump_file( "SLAB INFO", "/proc/slabinfo"); 652 dump_file( "ZONEINFO", "/proc/zoneinfo"); 653 dump_file( "PAGETYPEINFO", "/proc/pagetypeinfo"); 654 dump_file( "BUDDYINFO", "/proc/buddyinfo"); 655 dump_file( "FRAGMENTATION INFO", "/d/extfrag/unusable_index"); 656 657 dump_file("KERNEL WAKE SOURCES", "/d/wakeup_sources"); 658 dump_file("KERNEL CPUFREQ", "/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state"); 659 dump_file("KERNEL SYNC", "/d/sync"); 660 661 run_command("PROCESSES AND THREADS", 10, "ps", "-Z", "-t", "-p", "-P", NULL); 662 run_command("LIBRANK", 10, SU_PATH, "root", "librank", NULL); 663 664 run_command("PRINTENV", 10, "printenv", NULL); 665 run_command("NETSTAT", 10, "netstat", "-n", NULL); 666 run_command("LSMOD", 10, "lsmod", NULL); 667 668 do_dmesg(); 669 670 run_command("LIST OF OPEN FILES", 10, SU_PATH, "root", "lsof", NULL); 671 for_each_pid(do_showmap, "SMAPS OF ALL PROCESSES"); 672 for_each_tid(show_wchan, "BLOCKED PROCESS WAIT-CHANNELS"); 673 for_each_pid(show_showtime, "PROCESS TIMES (pid cmd user system iowait+percentage)"); 674 675 if (!screenshot_path.empty()) { 676 MYLOGI("taking late screenshot\n"); 677 take_screenshot(screenshot_path); 678 MYLOGI("wrote screenshot: %s\n", screenshot_path.c_str()); 679 } 680
Logcat
681 // dump_file("EVENT LOG TAGS", "/etc/event-log-tags"); 682 // calculate timeout 683 timeout = logcat_timeout("main") + logcat_timeout("system") + logcat_timeout("crash"); 684 if (timeout < 20000) { 685 timeout = 20000; 686 } 687 run_command("SYSTEM LOG", timeout / 1000, "logcat", "-v", "threadtime", 688 "-v", "printable", 689 "-d", 690 "*:v", NULL); 691 timeout = logcat_timeout("events"); 692 if (timeout < 20000) { 693 timeout = 20000; 694 } 695 run_command("EVENT LOG", timeout / 1000, "logcat", "-b", "events", 696 "-v", "threadtime", 697 "-v", "printable", 698 "-d", 699 "*:v", NULL); 700 timeout = logcat_timeout("radio"); 701 if (timeout < 20000) { 702 timeout = 20000; 703 } 704 run_command("RADIO LOG", timeout / 1000, "logcat", "-b", "radio", 705 "-v", "threadtime", 706 "-v", "printable", 707 "-d", 708 "*:v", NULL); 709 710 run_command("LOG STATISTICS", 10, "logcat", "-b", "all", "-S", NULL); 711
712 run_command("RAFT LOGS", 600, SU_PATH, "root", "logcompressor", "-r", RAFT_DIR, NULL); 713 714 /* show the traces we collected in main(), if that was done */ 715 if (dump_traces_path != NULL) { 716 dump_file("VM TRACES JUST NOW", dump_traces_path); 717 } 718
ANR
719 /* only show ANR traces if they're less than 15 minutes old */ 720 struct stat st; 721 char anr_traces_path[PATH_MAX]; 722 property_get("dalvik.vm.stack-trace-file", anr_traces_path, ""); 723 if (!anr_traces_path[0]) { 724 printf("*** NO VM TRACES FILE DEFINED (dalvik.vm.stack-trace-file)\n\n"); 725 } else { 726 int fd = TEMP_FAILURE_RETRY(open(anr_traces_path, 727 O_RDONLY | O_CLOEXEC | O_NOFOLLOW | O_NONBLOCK)); 728 if (fd < 0) { 729 printf("*** NO ANR VM TRACES FILE (%s): %s\n\n", anr_traces_path, strerror(errno)); 730 } else { 731 dump_file_from_fd("VM TRACES AT LAST ANR", anr_traces_path, fd); 732 } 733 } 734 735 /* slow traces for slow operations */ 736 if (anr_traces_path[0] != 0) { 737 int tail = strlen(anr_traces_path)-1; 738 while (tail > 0 && anr_traces_path[tail] != '/') { 739 tail--; 740 } 741 int i = 0; 742 while (1) { 743 sprintf(anr_traces_path+tail+1, "slow%02d.txt", i); 744 if (stat(anr_traces_path, &st)) { 745 // No traces file at this index, done with the files. 746 break; 747 } 748 dump_file("VM TRACES WHEN SLOW", anr_traces_path); 749 i++; 750 } 751 } 752
TombStones
753 int dumped = 0; 754 for (size_t i = 0; i < NUM_TOMBSTONES; i++) { 755 if (tombstone_data[i].fd != -1) { 756 const char *name = tombstone_data[i].name; 757 int fd = tombstone_data[i].fd; 758 dumped = 1; 759 if (zip_writer) { 760 if (!add_zip_entry_from_fd(ZIP_ROOT_DIR + name, fd)) { 761 MYLOGE("Unable to add tombstone %s to zip file\n", name); 762 } 763 } else { 764 dump_file_from_fd("TOMBSTONE", name, fd); 765 } 766 close(fd); 767 tombstone_data[i].fd = -1; 768 } 769 } 770 if (!dumped) { 771 printf("*** NO TOMBSTONES to dump in %s\n\n", TOMBSTONE_DIR); 772 } 773
774 dump_file("NETWORK DEV INFO", "/proc/net/dev"); 775 dump_file("QTAGUID NETWORK INTERFACES INFO", "/proc/net/xt_qtaguid/iface_stat_all"); 776 dump_file("QTAGUID NETWORK INTERFACES INFO (xt)", "/proc/net/xt_qtaguid/iface_stat_fmt"); 777 dump_file("QTAGUID CTRL INFO", "/proc/net/xt_qtaguid/ctrl"); 778 dump_file("QTAGUID STATS INFO", "/proc/net/xt_qtaguid/stats"); 779 780 if (!stat(PSTORE_LAST_KMSG, &st)) { 781 /* Also TODO: Make console-ramoops CAP_SYSLOG protected. */ 782 dump_file("LAST KMSG", PSTORE_LAST_KMSG); 783 } else if (!stat(ALT_PSTORE_LAST_KMSG, &st)) { 784 dump_file("LAST KMSG", ALT_PSTORE_LAST_KMSG); 785 } else { 786 /* TODO: Make last_kmsg CAP_SYSLOG protected. b/5555691 */ 787 dump_file("LAST KMSG", "/proc/last_kmsg"); 788 } 789 790 /* kernels must set CONFIG_PSTORE_PMSG, slice up pstore with device tree */ 791 run_command("LAST LOGCAT", 10, "logcat", "-L", 792 "-b", "all", 793 "-v", "threadtime", 794 "-v", "printable", 795 "-d", 796 "*:v", NULL); 797 798 /* The following have a tendency to get wedged when wifi drivers/fw goes belly-up. */ 799 800 run_command("NETWORK INTERFACES", 10, "ip", "link", NULL); 801 802 run_command("IPv4 ADDRESSES", 10, "ip", "-4", "addr", "show", NULL); 803 run_command("IPv6 ADDRESSES", 10, "ip", "-6", "addr", "show", NULL); 804 805 run_command("IP RULES", 10, "ip", "rule", "show", NULL); 806 run_command("IP RULES v6", 10, "ip", "-6", "rule", "show", NULL); 807 808 dump_route_tables(); 809 810 run_command("ARP CACHE", 10, "ip", "-4", "neigh", "show", NULL); 811 run_command("IPv6 ND CACHE", 10, "ip", "-6", "neigh", "show", NULL); 812 run_command("MULTICAST ADDRESSES", 10, "ip", "maddr", NULL); 813 run_command("WIFI NETWORKS", 20, "wpa_cli", "IFNAME=wlan0", "list_networks", NULL); 814 815 #ifdef FWDUMP_bcmdhd 816 run_command("ND OFFLOAD TABLE", 5, 817 SU_PATH, "root", WLUTIL, "nd_hostip", NULL); 818 819 run_command("DUMP WIFI INTERNAL COUNTERS (1)", 20, 820 SU_PATH, "root", WLUTIL, "counters", NULL); 821 822 run_command("ND OFFLOAD STATUS (1)", 5, 823 SU_PATH, "root", WLUTIL, "nd_status", NULL); 824 825 #endif 826 dump_file("INTERRUPTS (1)", "/proc/interrupts"); 827 828 run_command("NETWORK DIAGNOSTICS", 10, "dumpsys", "-t", "10", "connectivity", "--diag", NULL); 829 830 #ifdef FWDUMP_bcmdhd 831 run_command("DUMP WIFI STATUS", 20, 832 SU_PATH, "root", "dhdutil", "-i", "wlan0", "dump", NULL); 833 834 run_command("DUMP WIFI INTERNAL COUNTERS (2)", 20, 835 SU_PATH, "root", WLUTIL, "counters", NULL); 836 837 run_command("ND OFFLOAD STATUS (2)", 5, 838 SU_PATH, "root", WLUTIL, "nd_status", NULL); 839 #endif 840 dump_file("INTERRUPTS (2)", "/proc/interrupts"); 841 842 print_properties(); 843 844 run_command("VOLD DUMP", 10, "vdc", "dump", NULL); 845 run_command("SECURE CONTAINERS", 10, "vdc", "asec", "list", NULL); 846 847 run_command("FILESYSTEMS & FREE SPACE", 10, "df", NULL); 848 849 run_command("LAST RADIO LOG", 10, "parse_radio_log", "/proc/last_radio_log", NULL); 850 851 printf("------ BACKLIGHTS ------\n"); 852 printf("LCD brightness="); 853 dump_file(NULL, "/sys/class/leds/lcd-backlight/brightness"); 854 printf("Button brightness="); 855 dump_file(NULL, "/sys/class/leds/button-backlight/brightness"); 856 printf("Keyboard brightness="); 857 dump_file(NULL, "/sys/class/leds/keyboard-backlight/brightness"); 858 printf("ALS mode="); 859 dump_file(NULL, "/sys/class/leds/lcd-backlight/als"); 860 printf("LCD driver registers:\n"); 861 dump_file(NULL, "/sys/class/leds/lcd-backlight/registers"); 862 printf("\n"); 863 864 /* Binder state is expensive to look at as it uses a lot of memory. */ 865 dump_file("BINDER FAILED TRANSACTION LOG", "/sys/kernel/debug/binder/failed_transaction_log"); 866 dump_file("BINDER TRANSACTION LOG", "/sys/kernel/debug/binder/transaction_log"); 867 dump_file("BINDER TRANSACTIONS", "/sys/kernel/debug/binder/transactions"); 868 dump_file("BINDER STATS", "/sys/kernel/debug/binder/stats"); 869 dump_file("BINDER STATE", "/sys/kernel/debug/binder/state"); 870
Board
871 printf("========================================================\n"); 872 printf("== Board\n"); 873 printf("========================================================\n"); 874 875 dumpstate_board(); 876 printf("\n"); 877 878 /* Migrate the ril_dumpstate to a dumpstate_board()? */ 879 char ril_dumpstate_timeout[PROPERTY_VALUE_MAX] = {0}; 880 property_get("ril.dumpstate.timeout", ril_dumpstate_timeout, "30"); 881 if (strnlen(ril_dumpstate_timeout, PROPERTY_VALUE_MAX - 1) > 0) { 882 if (is_user_build()) { 883 // su does not exist on user builds, so try running without it. 884 // This way any implementations of vril-dump that do not require 885 // root can run on user builds. 886 run_command("DUMP VENDOR RIL LOGS", atoi(ril_dumpstate_timeout), 887 "vril-dump", NULL); 888 } else { 889 run_command("DUMP VENDOR RIL LOGS", atoi(ril_dumpstate_timeout), 890 SU_PATH, "root", "vril-dump", NULL); 891 } 892 } 893
Android Framework Services
894 printf("========================================================\n"); 895 printf("== Android Framework Services\n"); 896 printf("========================================================\n"); 897 898 run_command("DUMPSYS", 60, "dumpsys", "-t", "60", "--skip", "meminfo", "cpuinfo", NULL); 899 900 printf("========================================================\n"); 901 printf("== Checkins\n"); 902 printf("========================================================\n"); 903 904 run_command("CHECKIN BATTERYSTATS", 30, "dumpsys", "-t", "30", "batterystats", "-c", NULL); 905 run_command("CHECKIN MEMINFO", 30, "dumpsys", "-t", "30", "meminfo", "--checkin", NULL); 906 run_command("CHECKIN NETSTATS", 30, "dumpsys", "-t", "30", "netstats", "--checkin", NULL); 907 run_command("CHECKIN PROCSTATS", 30, "dumpsys", "-t", "30", "procstats", "-c", NULL); 908 run_command("CHECKIN USAGESTATS", 30, "dumpsys", "-t", "30", "usagestats", "-c", NULL); 909 run_command("CHECKIN PACKAGE", 30, "dumpsys", "-t", "30", "package", "--checkin", NULL); 910 911 printf("========================================================\n"); 912 printf("== Running Application Activities\n"); 913 printf("========================================================\n"); 914 915 run_command("APP ACTIVITIES", 30, "dumpsys", "-t", "30", "activity", "all", NULL); 916 917 printf("========================================================\n"); 918 printf("== Running Application Services\n"); 919 printf("========================================================\n"); 920 921 run_command("APP SERVICES", 30, "dumpsys", "-t", "30", "activity", "service", "all", NULL); 922 923 printf("========================================================\n"); 924 printf("== Running Application Providers\n"); 925 printf("========================================================\n"); 926 927 run_command("APP SERVICES", 30, "dumpsys", "-t", "30", "activity", "provider", "all", NULL); 928 929 930 printf("========================================================\n"); 931 printf("== Final progress (pid %d): %d/%d (originally %d)\n", 932 getpid(), progress, weight_total, WEIGHT_TOTAL); 933 printf("========================================================\n"); 934 printf("== dumpstate: done\n"); 935 printf("========================================================\n"); 936 }
938 static void usage() { 939 fprintf(stderr, 940 "usage: dumpstate [-h] [-b soundfile] [-e soundfile] [-o file [-d] [-p] " 941 "[-z]] [-s] [-S] [-q] [-B] [-P] [-R] [-V version]\n" 942 " -h: display this help message\n" 943 " -b: play sound file instead of vibrate, at beginning of job\n" 944 " -e: play sound file instead of vibrate, at end of job\n" 945 " -o: write to file (instead of stdout)\n" 946 " -d: append date to filename (requires -o)\n" 947 " -p: capture screenshot to filename.png (requires -o)\n" 948 " -z: generate zipped file (requires -o)\n" 949 " -s: write output to control socket (for init)\n" 950 " -S: write file location to control socket (for init; requires -o and -z)" 951 " -q: disable vibrate\n" 952 " -B: send broadcast when finished (requires -o)\n" 953 " -P: send broadcast when started and update system properties on " 954 "progress (requires -o and -B)\n" 955 " -R: take bugreport in remote mode (requires -o, -z, -d and -B, " 956 "shouldn't be used with -P)\n" 957 " -V: sets the bugreport format version (valid values: %s)\n", 958 VERSION_DEFAULT.c_str()); 959 }