• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/core


Commit MetaInfo

修订版855333f346ec98423a96efa7032174488114c2f7 (tree)
时间2017-06-13 14:35:09
作者TreeHugger Robot <treehugger-gerrit@goog...>
CommiterAndroid (Google) Code Review

Log Message

Merge "tombstoned: log where we're writing the tombstone." into oc-dev

更改概述

差异

--- a/debuggerd/tombstoned/tombstoned.cpp
+++ b/debuggerd/tombstoned/tombstoned.cpp
@@ -61,6 +61,7 @@ struct Crash {
6161 unique_fd crash_fd;
6262 pid_t crash_pid;
6363 event* crash_event = nullptr;
64+ std::string crash_path;
6465 };
6566
6667 static constexpr char kTombstoneDirectory[] = "/data/tombstones/";
@@ -104,32 +105,31 @@ static void find_oldest_tombstone() {
104105 next_tombstone = oldest_tombstone;
105106 }
106107
107-static unique_fd get_tombstone_fd() {
108+static std::pair<unique_fd, std::string> get_tombstone() {
108109 // If kMaxConcurrentDumps is greater than 1, then theoretically the same
109110 // filename could be handed out to multiple processes. Unlink and create the
110111 // file, instead of using O_TRUNC, to avoid two processes interleaving their
111112 // output.
112113 unique_fd result;
113- char buf[PATH_MAX];
114- snprintf(buf, sizeof(buf), "tombstone_%02d", next_tombstone);
115- if (unlinkat(tombstone_directory_fd, buf, 0) != 0 && errno != ENOENT) {
116- PLOG(FATAL) << "failed to unlink tombstone at " << kTombstoneDirectory << buf;
114+ std::string file_name = StringPrintf("tombstone_%02d", next_tombstone);
115+ if (unlinkat(tombstone_directory_fd, file_name.c_str(), 0) != 0 && errno != ENOENT) {
116+ PLOG(FATAL) << "failed to unlink tombstone at " << kTombstoneDirectory << "/" << file_name;
117117 }
118118
119- result.reset(
120- openat(tombstone_directory_fd, buf, O_CREAT | O_EXCL | O_WRONLY | O_APPEND | O_CLOEXEC, 0640));
119+ result.reset(openat(tombstone_directory_fd, file_name.c_str(),
120+ O_CREAT | O_EXCL | O_WRONLY | O_APPEND | O_CLOEXEC, 0640));
121121 if (result == -1) {
122- PLOG(FATAL) << "failed to create tombstone at " << kTombstoneDirectory << buf;
122+ PLOG(FATAL) << "failed to create tombstone at " << kTombstoneDirectory << "/" << file_name;
123123 }
124124
125125 next_tombstone = (next_tombstone + 1) % kTombstoneCount;
126- return result;
126+ return {std::move(result), std::string(kTombstoneDirectory) + "/" + file_name};
127127 }
128128
129129 static void perform_request(Crash* crash) {
130130 unique_fd output_fd;
131131 if (!intercept_manager->GetIntercept(crash->crash_pid, &output_fd)) {
132- output_fd = get_tombstone_fd();
132+ std::tie(output_fd, crash->crash_path) = get_tombstone();
133133 }
134134
135135 TombstonedCrashPacket response = {
@@ -251,6 +251,10 @@ static void crash_completed_cb(evutil_socket_t sockfd, short ev, void* arg) {
251251 goto fail;
252252 }
253253
254+ if (!crash->crash_path.empty()) {
255+ LOG(ERROR) << "Tombstone written to: " << crash->crash_path;
256+ }
257+
254258 fail:
255259 delete crash;
256260