summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andreas Gampe <agampe@google.com> 2017-08-22 13:08:37 -0700
committer Andreas Gampe <agampe@google.com> 2017-08-24 22:51:30 +0000
commit8262d481bd56f8ce2ddbd2944ca80b6de1fe7bc0 (patch)
tree089a92ca5757127578825f7dbec1c90db0a221a6
parent086a02a25f4e24be436411d7cbe86307ae0a6ad7 (diff)
Dumpstate: Add tombstone filtering
Only package the ten latest tombstones. This recovers the old behavior when tombstones were limited to ten by tombstoned, and ensures that bugreports stay small in size. It is future work to optimize this, e.g., by packaging as many as possible. (cherry picked from commit d0d7695ecbfd12aaecc8aec66aacb487b116ac0b) Bug: 64290162 Test: m Test: adb root && for ((i=0;i<50;i++)) ; do adb shell touch /data/tombstones/tombstone_$i ; done ; adb bugreport test.zip ; unzip -l test.zip | grep tomb Merged-In: I4072b5fbcf1e0314aa3eebeefbadc61d5ec10787 Change-Id: I4072b5fbcf1e0314aa3eebeefbadc61d5ec10787
-rw-r--r--cmds/dumpstate/dumpstate.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 657323d90d..5f93e9906a 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -144,10 +144,12 @@ static const CommandOptions AS_ROOT_20 = CommandOptions::WithTimeout(20).AsRoot(
* Returns a vector of dump fds under |dir_path| with a given |file_prefix|.
* The returned vector is sorted by the mtimes of the dumps. If |limit_by_mtime|
* is set, the vector only contains files that were written in the last 30 minutes.
+ * If |limit_by_count| is set, the vector only contains the ten latest files.
*/
static std::vector<DumpData>* GetDumpFds(const std::string& dir_path,
const std::string& file_prefix,
- bool limit_by_mtime) {
+ bool limit_by_mtime,
+ bool limit_by_count = true) {
const time_t thirty_minutes_ago = ds.now_ - 60 * 30;
std::unique_ptr<std::vector<DumpData>> dump_data(new std::vector<DumpData>());
@@ -190,6 +192,10 @@ static std::vector<DumpData>* GetDumpFds(const std::string& dir_path,
std::sort(dump_data->begin(), dump_data->end());
+ if (limit_by_count && dump_data->size() > 10) {
+ dump_data->erase(dump_data->begin() + 10, dump_data->end());
+ }
+
return dump_data.release();
}