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

Commit db6d211e authored by Elliott Hughes's avatar Elliott Hughes
Browse files

dumpstate: remove the arbitrary limit on tombstones.

Don't just arbitrarily limit to 10. Assume the user knows what they're
doing (or is at least happy with the trade-off).

The initial idea was to just honor debuggerd's system property for how
many tombstones to collect (because why tell a device to collect N
tombstones if you don't also want it to give you N tombstones?), but
then why duplicate that check here? Instead we assume that anyone who's
manually decreasing the system property is also going to wipe their
tombstones directory.

Bug: http://b/140580637
Test: run crasher, dumpstate
Change-Id: Iad5f5a3a4c9d7d089514f4a02b247d83ececfa90
parent 0c1abd12
Loading
Loading
Loading
Loading
+1 −12
Original line number Diff line number Diff line
@@ -300,12 +300,10 @@ 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_count = true) {
                                        bool limit_by_mtime) {
    const time_t thirty_minutes_ago = ds.now_ - 60 * 30;

    std::unique_ptr<DIR, decltype(&closedir)> dump_dir(opendir(dir_path.c_str()), closedir);
@@ -349,15 +347,6 @@ static std::vector<DumpData> GetDumpFds(const std::string& dir_path,
        dump_data.emplace_back(DumpData{abs_path, std::move(fd), st.st_mtime});
    }

    // Sort in descending modification time so that we only keep the newest
    // reports if |limit_by_count| is true.
    std::sort(dump_data.begin(), dump_data.end(),
              [](const DumpData& d1, const DumpData& d2) { return d1.mtime > d2.mtime; });

    if (limit_by_count && dump_data.size() > 10) {
        dump_data.erase(dump_data.begin() + 10, dump_data.end());
    }

    return dump_data;
}