diff options
author | Tucker Sylvestro <tuckeris@google.com> | 2015-07-06 19:29:06 -0400 |
---|---|---|
committer | Andre Eisenbach <eisenbach@google.com> | 2015-07-07 00:25:34 +0000 |
commit | 1192df9f7e709b9d9508ac86cbf5099a3a7ffa0e (patch) | |
tree | 0ecb424c3084c545cdebf35cf8b9288fec1a0fa4 /hci/src | |
parent | 7927f68bb2d9b963288261e1e858463b43c52a2d (diff) | |
download | android_system_bt-1192df9f7e709b9d9508ac86cbf5099a3a7ffa0e.tar.gz android_system_bt-1192df9f7e709b9d9508ac86cbf5099a3a7ffa0e.tar.bz2 android_system_bt-1192df9f7e709b9d9508ac86cbf5099a3a7ffa0e.zip |
Save all snoop logs when BtSnoopSaveLog=true
Previously, only the last snoop log was saved, which was often not
enough if the bluetooth stack was in a crash loop or an app was
resetting it frequently.
Bug: 22202788
Change-Id: I74622ceabe9ce12d5ba03c640c37f697d5a5bb01
Diffstat (limited to 'hci/src')
-rw-r--r-- | hci/src/btsnoop.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/hci/src/btsnoop.c b/hci/src/btsnoop.c index 990623e38..d859e6842 100644 --- a/hci/src/btsnoop.c +++ b/hci/src/btsnoop.c @@ -137,6 +137,17 @@ const btsnoop_t *btsnoop_get_interface() { // Internal functions +static uint64_t btsnoop_timestamp(void) { + struct timeval tv; + gettimeofday(&tv, NULL); + + // Timestamp is in microseconds. + uint64_t timestamp = tv.tv_sec * 1000 * 1000LL; + timestamp += tv.tv_usec; + timestamp += BTSNOOP_EPOCH_DELTA; + return timestamp; +} + static void update_logging() { bool should_log = module_started && (logging_enabled_via_api || stack_config->get_btsnoop_turned_on()); @@ -153,7 +164,7 @@ static void update_logging() { // Save the old log if configured to do so if (stack_config->get_btsnoop_should_save_last()) { char last_log_path[PATH_MAX]; - snprintf(last_log_path, PATH_MAX, "%s.last", log_path); + snprintf(last_log_path, PATH_MAX, "%s.%llu", log_path, btsnoop_timestamp()); if (!rename(log_path, last_log_path) && errno != ENOENT) LOG_ERROR("%s unable to rename '%s' to '%s': %s", __func__, log_path, last_log_path, strerror(errno)); } @@ -175,17 +186,6 @@ static void update_logging() { } } -static uint64_t btsnoop_timestamp(void) { - struct timeval tv; - gettimeofday(&tv, NULL); - - // Timestamp is in microseconds. - uint64_t timestamp = tv.tv_sec * 1000 * 1000LL; - timestamp += tv.tv_usec; - timestamp += BTSNOOP_EPOCH_DELTA; - return timestamp; -} - static void btsnoop_write(const void *data, size_t length) { if (logfile_fd != INVALID_FD) write(logfile_fd, data, length); |