Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 43ec13d1 authored by Felipe Leme's avatar Felipe Leme Committed by Android (Google) Code Review
Browse files

Merge "Migrated dumpstate to C++."

parents 445d453d 8620bb41
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
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

+1 −1
Original line number Diff line number Diff line
@@ -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];
+8 −0
Original line number Diff line number Diff line
@@ -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_ */
+11 −8
Original line number Diff line number Diff line
@@ -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;