Loading debuggerd/Android.bp +0 −1 Original line number Original line Diff line number Diff line cc_defaults { cc_defaults { name: "debuggerd_defaults", name: "debuggerd_defaults", defaults: ["linux_bionic_supported"], cflags: [ cflags: [ "-Wall", "-Wall", "-Wextra", "-Wextra", Loading liblog/fake_log_device.c +15 −66 Original line number Original line Diff line number Diff line Loading @@ -15,9 +15,7 @@ */ */ /* /* * Intercepts log messages intended for the Android log device. * Intercepts log messages intended for the Android log device. * When running in the context of the simulator, the messages are * Messages are printed to stderr. * passed on to the underlying (fake) log device. When not in the * simulator, messages are printed to stderr. */ */ #include <ctype.h> #include <ctype.h> #include <errno.h> #include <errno.h> Loading Loading @@ -561,7 +559,8 @@ static void showLog(LogState* state, int logPrio, const char* tag, * tag (N bytes -- null-terminated ASCII string) * tag (N bytes -- null-terminated ASCII string) * message (N bytes -- null-terminated ASCII string) * message (N bytes -- null-terminated ASCII string) */ */ static ssize_t logWritev(int fd, const struct iovec* vector, int count) { LIBLOG_HIDDEN ssize_t fakeLogWritev(int fd, const struct iovec* vector, int count) { LogState* state; LogState* state; /* Make sure that no-one frees the LogState while we're using it. /* Make sure that no-one frees the LogState while we're using it. Loading Loading @@ -626,8 +625,18 @@ error: /* /* * Free up our state and close the fake descriptor. * Free up our state and close the fake descriptor. * * The logger API has no means or need to 'stop' or 'close' using the logs, * and as such, there is no way for that 'stop' or 'close' to translate into * a close operation to the fake log handler. fakeLogClose is provided for * completeness only. * * We have no intention of adding a log close operation as it would complicate * every user of the logging API with no gain since the only valid place to * call is in the exit handler. Logging can continue in the exit handler to * help debug HOST tools ... */ */ static int logClose(int fd) { LIBLOG_HIDDEN int fakeLogClose(int fd) { deleteFakeFd(fd); deleteFakeFd(fd); return 0; return 0; } } Loading @@ -635,7 +644,7 @@ static int logClose(int fd) { /* /* * Open a log output device and return a fake fd. * Open a log output device and return a fake fd. */ */ static int logOpen(const char* pathName, int flags __unused) { LIBLOG_HIDDEN int fakeLogOpen(const char* pathName) { LogState* logState; LogState* logState; int fd = -1; int fd = -1; Loading @@ -654,66 +663,6 @@ static int logOpen(const char* pathName, int flags __unused) { return fd; return fd; } } /* * Runtime redirection. If this binary is running in the simulator, * just pass log messages to the emulated device. If it's running * outside of the simulator, write the log messages to stderr. */ static int (*redirectOpen)(const char* pathName, int flags) = NULL; static int (*redirectClose)(int fd) = NULL; static ssize_t (*redirectWritev)(int fd, const struct iovec* vector, int count) = NULL; static void setRedirects() { const char* ws; /* Wrapsim sets this environment variable on children that it's * created using its LD_PRELOAD wrapper. */ ws = getenv("ANDROID_WRAPSIM"); if (ws != NULL && strcmp(ws, "1") == 0) { /* We're running inside wrapsim, so we can just write to the device. */ redirectOpen = (int (*)(const char* pathName, int flags))open; redirectClose = close; redirectWritev = writev; } else { /* There's no device to delegate to; handle the logging ourselves. */ redirectOpen = logOpen; redirectClose = logClose; redirectWritev = logWritev; } } LIBLOG_HIDDEN int fakeLogOpen(const char* pathName, int flags) { if (redirectOpen == NULL) { setRedirects(); } return redirectOpen(pathName, flags); } /* * The logger API has no means or need to 'stop' or 'close' using the logs, * and as such, there is no way for that 'stop' or 'close' to translate into * a close operation to the fake log handler. fakeLogClose is provided for * completeness only. * * We have no intention of adding a log close operation as it would complicate * every user of the logging API with no gain since the only valid place to * call is in the exit handler. Logging can continue in the exit handler to * help debug HOST tools ... */ LIBLOG_HIDDEN int fakeLogClose(int fd) { /* Assume that open() was called first. */ return redirectClose(fd); } LIBLOG_HIDDEN ssize_t fakeLogWritev(int fd, const struct iovec* vector, int count) { /* Assume that open() was called first. */ return redirectWritev(fd, vector, count); } LIBLOG_HIDDEN ssize_t __send_log_msg(char* buf __unused, LIBLOG_HIDDEN ssize_t __send_log_msg(char* buf __unused, size_t buf_size __unused) { size_t buf_size __unused) { return -ENODEV; return -ENODEV; Loading liblog/fake_log_device.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,7 @@ struct iovec; struct iovec; LIBLOG_HIDDEN int fakeLogOpen(const char* pathName, int flags); LIBLOG_HIDDEN int fakeLogOpen(const char* pathName); LIBLOG_HIDDEN int fakeLogClose(int fd); LIBLOG_HIDDEN int fakeLogClose(int fd); LIBLOG_HIDDEN ssize_t fakeLogWritev(int fd, const struct iovec* vector, LIBLOG_HIDDEN ssize_t fakeLogWritev(int fd, const struct iovec* vector, int count); int count); Loading liblog/fake_writer.c +2 −2 Original line number Original line Diff line number Diff line Loading @@ -55,9 +55,9 @@ static int fakeOpen() { continue; continue; } } snprintf(buf, sizeof(buf), "/dev/log_%s", android_log_id_to_name(i)); snprintf(buf, sizeof(buf), "/dev/log_%s", android_log_id_to_name(i)); logFds[i] = fakeLogOpen(buf, O_WRONLY); logFds[i] = fakeLogOpen(buf); if (logFds[i] < 0) { if (logFds[i] < 0) { fprintf(stderr, "fakeLogOpen(%s, O_WRONLY) failed\n", buf); fprintf(stderr, "fakeLogOpen(%s) failed\n", buf); } } } } return 0; return 0; Loading Loading
debuggerd/Android.bp +0 −1 Original line number Original line Diff line number Diff line cc_defaults { cc_defaults { name: "debuggerd_defaults", name: "debuggerd_defaults", defaults: ["linux_bionic_supported"], cflags: [ cflags: [ "-Wall", "-Wall", "-Wextra", "-Wextra", Loading
liblog/fake_log_device.c +15 −66 Original line number Original line Diff line number Diff line Loading @@ -15,9 +15,7 @@ */ */ /* /* * Intercepts log messages intended for the Android log device. * Intercepts log messages intended for the Android log device. * When running in the context of the simulator, the messages are * Messages are printed to stderr. * passed on to the underlying (fake) log device. When not in the * simulator, messages are printed to stderr. */ */ #include <ctype.h> #include <ctype.h> #include <errno.h> #include <errno.h> Loading Loading @@ -561,7 +559,8 @@ static void showLog(LogState* state, int logPrio, const char* tag, * tag (N bytes -- null-terminated ASCII string) * tag (N bytes -- null-terminated ASCII string) * message (N bytes -- null-terminated ASCII string) * message (N bytes -- null-terminated ASCII string) */ */ static ssize_t logWritev(int fd, const struct iovec* vector, int count) { LIBLOG_HIDDEN ssize_t fakeLogWritev(int fd, const struct iovec* vector, int count) { LogState* state; LogState* state; /* Make sure that no-one frees the LogState while we're using it. /* Make sure that no-one frees the LogState while we're using it. Loading Loading @@ -626,8 +625,18 @@ error: /* /* * Free up our state and close the fake descriptor. * Free up our state and close the fake descriptor. * * The logger API has no means or need to 'stop' or 'close' using the logs, * and as such, there is no way for that 'stop' or 'close' to translate into * a close operation to the fake log handler. fakeLogClose is provided for * completeness only. * * We have no intention of adding a log close operation as it would complicate * every user of the logging API with no gain since the only valid place to * call is in the exit handler. Logging can continue in the exit handler to * help debug HOST tools ... */ */ static int logClose(int fd) { LIBLOG_HIDDEN int fakeLogClose(int fd) { deleteFakeFd(fd); deleteFakeFd(fd); return 0; return 0; } } Loading @@ -635,7 +644,7 @@ static int logClose(int fd) { /* /* * Open a log output device and return a fake fd. * Open a log output device and return a fake fd. */ */ static int logOpen(const char* pathName, int flags __unused) { LIBLOG_HIDDEN int fakeLogOpen(const char* pathName) { LogState* logState; LogState* logState; int fd = -1; int fd = -1; Loading @@ -654,66 +663,6 @@ static int logOpen(const char* pathName, int flags __unused) { return fd; return fd; } } /* * Runtime redirection. If this binary is running in the simulator, * just pass log messages to the emulated device. If it's running * outside of the simulator, write the log messages to stderr. */ static int (*redirectOpen)(const char* pathName, int flags) = NULL; static int (*redirectClose)(int fd) = NULL; static ssize_t (*redirectWritev)(int fd, const struct iovec* vector, int count) = NULL; static void setRedirects() { const char* ws; /* Wrapsim sets this environment variable on children that it's * created using its LD_PRELOAD wrapper. */ ws = getenv("ANDROID_WRAPSIM"); if (ws != NULL && strcmp(ws, "1") == 0) { /* We're running inside wrapsim, so we can just write to the device. */ redirectOpen = (int (*)(const char* pathName, int flags))open; redirectClose = close; redirectWritev = writev; } else { /* There's no device to delegate to; handle the logging ourselves. */ redirectOpen = logOpen; redirectClose = logClose; redirectWritev = logWritev; } } LIBLOG_HIDDEN int fakeLogOpen(const char* pathName, int flags) { if (redirectOpen == NULL) { setRedirects(); } return redirectOpen(pathName, flags); } /* * The logger API has no means or need to 'stop' or 'close' using the logs, * and as such, there is no way for that 'stop' or 'close' to translate into * a close operation to the fake log handler. fakeLogClose is provided for * completeness only. * * We have no intention of adding a log close operation as it would complicate * every user of the logging API with no gain since the only valid place to * call is in the exit handler. Logging can continue in the exit handler to * help debug HOST tools ... */ LIBLOG_HIDDEN int fakeLogClose(int fd) { /* Assume that open() was called first. */ return redirectClose(fd); } LIBLOG_HIDDEN ssize_t fakeLogWritev(int fd, const struct iovec* vector, int count) { /* Assume that open() was called first. */ return redirectWritev(fd, vector, count); } LIBLOG_HIDDEN ssize_t __send_log_msg(char* buf __unused, LIBLOG_HIDDEN ssize_t __send_log_msg(char* buf __unused, size_t buf_size __unused) { size_t buf_size __unused) { return -ENODEV; return -ENODEV; Loading
liblog/fake_log_device.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,7 @@ struct iovec; struct iovec; LIBLOG_HIDDEN int fakeLogOpen(const char* pathName, int flags); LIBLOG_HIDDEN int fakeLogOpen(const char* pathName); LIBLOG_HIDDEN int fakeLogClose(int fd); LIBLOG_HIDDEN int fakeLogClose(int fd); LIBLOG_HIDDEN ssize_t fakeLogWritev(int fd, const struct iovec* vector, LIBLOG_HIDDEN ssize_t fakeLogWritev(int fd, const struct iovec* vector, int count); int count); Loading
liblog/fake_writer.c +2 −2 Original line number Original line Diff line number Diff line Loading @@ -55,9 +55,9 @@ static int fakeOpen() { continue; continue; } } snprintf(buf, sizeof(buf), "/dev/log_%s", android_log_id_to_name(i)); snprintf(buf, sizeof(buf), "/dev/log_%s", android_log_id_to_name(i)); logFds[i] = fakeLogOpen(buf, O_WRONLY); logFds[i] = fakeLogOpen(buf); if (logFds[i] < 0) { if (logFds[i] < 0) { fprintf(stderr, "fakeLogOpen(%s, O_WRONLY) failed\n", buf); fprintf(stderr, "fakeLogOpen(%s) failed\n", buf); } } } } return 0; return 0; Loading