diff options
author | 2015-11-10 22:11:10 +0000 | |
---|---|---|
committer | 2015-11-10 22:11:10 +0000 | |
commit | 43ec13d13a695166a55c85fc3baeb30b2d5beac0 (patch) | |
tree | 925c02d19d03ace390f6f785f069e20e7eec07b6 | |
parent | 445d453dba5fa11fd222d07e798dfe64b21ebbc8 (diff) | |
parent | 8620bb4118a68721d10c29529dc6978847d08d00 (diff) |
Merge "Migrated dumpstate to C++."
-rw-r--r-- | cmds/dumpstate/Android.mk | 4 | ||||
-rw-r--r-- | cmds/dumpstate/dumpstate.cpp (renamed from cmds/dumpstate/dumpstate.c) | 2 | ||||
-rw-r--r-- | cmds/dumpstate/dumpstate.h | 8 | ||||
-rw-r--r-- | cmds/dumpstate/libdumpstate_default.cpp (renamed from cmds/dumpstate/libdumpstate_default.c) | 0 | ||||
-rw-r--r-- | cmds/dumpstate/utils.cpp (renamed from cmds/dumpstate/utils.c) | 19 |
5 files changed, 22 insertions, 11 deletions
diff --git a/cmds/dumpstate/Android.mk b/cmds/dumpstate/Android.mk index 8c7c4a840e..6442701c29 100644 --- a/cmds/dumpstate/Android.mk +++ b/cmds/dumpstate/Android.mk @@ -1,6 +1,6 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -LOCAL_SRC_FILES := libdumpstate_default.c +LOCAL_SRC_FILES := libdumpstate_default.cpp LOCAL_MODULE := libdumpstate.default include $(BUILD_STATIC_LIBRARY) @@ -10,7 +10,7 @@ ifdef BOARD_WLAN_DEVICE LOCAL_CFLAGS := -DFWDUMP_$(BOARD_WLAN_DEVICE) endif -LOCAL_SRC_FILES := dumpstate.c utils.c +LOCAL_SRC_FILES := dumpstate.cpp utils.cpp LOCAL_MODULE := dumpstate diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.cpp index de514194fb..75604164af 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.cpp @@ -229,7 +229,7 @@ static unsigned long property_get_size(const char *key) { } /* timeout in ms */ -static unsigned long logcat_timeout(char *name) { +static unsigned long logcat_timeout(const char *name) { static const char global_tuneable[] = "persist.logd.size"; // Settings App static const char global_default[] = "ro.logd.size"; // BoardConfig.mk char key[PROP_NAME_MAX]; diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h index c5d3044ae3..f10ec46fb6 100644 --- a/cmds/dumpstate/dumpstate.h +++ b/cmds/dumpstate/dumpstate.h @@ -24,6 +24,10 @@ #define SU_PATH "/system/xbin/su" +#ifdef __cplusplus +extern "C" { +#endif + typedef void (for_each_pid_func)(int, const char *); typedef void (for_each_tid_func)(int, int, const char *); @@ -84,4 +88,8 @@ void play_sound(const char *path); /* Implemented by libdumpstate_board to dump board-specific info */ void dumpstate_board(); +#ifdef __cplusplus +} +#endif + #endif /* _DUMPSTATE_H_ */ diff --git a/cmds/dumpstate/libdumpstate_default.c b/cmds/dumpstate/libdumpstate_default.cpp index fd840dfd4b..fd840dfd4b 100644 --- a/cmds/dumpstate/libdumpstate_default.c +++ b/cmds/dumpstate/libdumpstate_default.cpp diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.cpp index 0dd0c21a9f..12f44aeba0 100644 --- a/cmds/dumpstate/utils.c +++ b/cmds/dumpstate/utils.cpp @@ -117,19 +117,19 @@ static void __for_each_pid(void (*helper)(int, const char *, void *), const char } static void for_each_pid_helper(int pid, const char *cmdline, void *arg) { - for_each_pid_func *func = arg; + for_each_pid_func *func = (for_each_pid_func*) arg; func(pid, cmdline); } void for_each_pid(for_each_pid_func func, const char *header) { - __for_each_pid(for_each_pid_helper, header, func); + __for_each_pid(for_each_pid_helper, header, (void *)func); } static void for_each_tid_helper(int pid, const char *cmdline, void *arg) { DIR *d; struct dirent *de; char taskpath[255]; - for_each_tid_func *func = arg; + for_each_tid_func *func = (for_each_tid_func *) arg; sprintf(taskpath, "/proc/%d/task", pid); @@ -174,7 +174,7 @@ static void for_each_tid_helper(int pid, const char *cmdline, void *arg) { } void for_each_tid(for_each_tid_func func, const char *header) { - __for_each_pid(for_each_tid_helper, header, func); + __for_each_pid(for_each_tid_helper, header, (void *) func); } void show_wchan(int pid, int tid, const char *name) { @@ -322,7 +322,7 @@ int dump_files(const char *title, const char *dir, DIR *dirp; struct dirent *d; char *newpath = NULL; - char *slash = "/"; + const char *slash = "/"; int fd, retval = 0; if (title) { @@ -640,6 +640,10 @@ const char *dump_traces() { return NULL; } + /* Variables below must be initialized before 'goto' statements */ + int dalvik_found = 0; + int ifd, wfd = -1; + /* walk /proc and kill -QUIT all Dalvik processes */ DIR *proc = opendir("/proc"); if (proc == NULL) { @@ -648,20 +652,19 @@ const char *dump_traces() { } /* use inotify to find when processes are done dumping */ - int ifd = inotify_init(); + ifd = inotify_init(); if (ifd < 0) { fprintf(stderr, "inotify_init: %s\n", strerror(errno)); goto error_close_fd; } - int wfd = inotify_add_watch(ifd, traces_path, IN_CLOSE_WRITE); + wfd = inotify_add_watch(ifd, traces_path, IN_CLOSE_WRITE); if (wfd < 0) { fprintf(stderr, "inotify_add_watch(%s): %s\n", traces_path, strerror(errno)); goto error_close_ifd; } struct dirent *d; - int dalvik_found = 0; while ((d = readdir(proc))) { int pid = atoi(d->d_name); if (pid <= 0) continue; |