Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: crash_sender

Issue 4088003: crash-reporter: write conversion failure diagnostics into fake dmp files (Closed) Base URL: http://git.chromium.org/git/crash-reporter.git
Patch Set: Add signature for error logs Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « crash_collector_test.cc ('k') | kernel_collector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/sh 1 #!/bin/sh
2 2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 set -e 7 set -e
8 8
9 # Product ID in crash report 9 # Product ID in crash report
10 CHROMEOS_PRODUCT=ChromeOS 10 CHROMEOS_PRODUCT=ChromeOS
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 mktemp "${TIMESTAMPS_DIR}"/XXXX > /dev/null 145 mktemp "${TIMESTAMPS_DIR}"/XXXX > /dev/null
146 return 0 146 return 0
147 } 147 }
148 148
149 # Gets the base part of a crash report file, such as 149 # Gets the base part of a crash report file, such as
150 # name.01234.5678.9012 from name.01234.5678.9012.meta 150 # name.01234.5678.9012 from name.01234.5678.9012.meta
151 get_base() { 151 get_base() {
152 echo "${1%.*}" 152 echo "${1%.*}"
153 } 153 }
154 154
155 get_extension() {
156 echo "${1##*.}"
157 }
158
155 # Return which kind of report the given metadata file relates to 159 # Return which kind of report the given metadata file relates to
156 get_kind() { 160 get_kind() {
157 # There should never be a report with both a dmp and kcrash file. 161 local payload="$(get_key_value "$1" "payload")"
158 # If that were to happen we arbitrarily consider this a minidump 162 if [ ! -r "${payload}" ]; then
159 # report and effectively ignore the kcrash. 163 lecho "Missing payload: ${payload}"
160 local base="$(get_base "$1")" 164 echo "unknown"
161 if [ -r "${base}.dmp" ]; then 165 return
166 fi
167 local kind="$(get_extension "${payload}")"
168 if [ "${kind}" = "dmp" ]; then
162 echo "minidump" 169 echo "minidump"
163 return 170 return
164 fi 171 fi
165 if [ -r "${base}.kcrash" ]; then 172 echo "${kind}"
166 echo "kcrash"
167 return
168 fi
169 } 173 }
170 174
171 get_key_value() { 175 get_key_value() {
172 if ! grep -q "$2=" "$1"; then 176 if ! grep -q "$2=" "$1"; then
173 echo "undefined" 177 echo "undefined"
174 return 178 return
175 fi 179 fi
176 grep "$2=" "$1" | cut -d = -f 2- 180 grep "$2=" "$1" | cut -d = -f 2-
177 } 181 }
178 182
179 # Return the board name. 183 # Return the board name.
180 get_board() { 184 get_board() {
181 echo $(get_key_value "/etc/lsb-release" "CHROMEOS_RELEASE_BOARD") 185 echo $(get_key_value "/etc/lsb-release" "CHROMEOS_RELEASE_BOARD")
182 } 186 }
183 187
184 # Return the hardware class or "unknown". 188 # Return the hardware class or "unknown".
185 get_hardware_class() { 189 get_hardware_class() {
186 if [ -r "${HWCLASS_PATH}" ]; then 190 if [ -r "${HWCLASS_PATH}" ]; then
187 cat "${HWCLASS_PATH}" 191 cat "${HWCLASS_PATH}"
188 else 192 else
189 echo "unknown" 193 echo "unknown"
190 fi 194 fi
191 } 195 }
192 196
193 send_crash() { 197 send_crash() {
194 local meta_path="$1" 198 local meta_path="$1"
199 local report_payload="$(get_key_value "${meta_path}" "payload")"
195 local kind="$(get_kind "${meta_path}")" 200 local kind="$(get_kind "${meta_path}")"
196 local exec_name="$(get_key_value "${meta_path}" "exec_name")" 201 local exec_name="$(get_key_value "${meta_path}" "exec_name")"
197 local sleep_time=$(generate_uniform_random $SECONDS_SEND_SPREAD) 202 local sleep_time=$(generate_uniform_random $SECONDS_SEND_SPREAD)
198 local url="${REPORT_UPLOAD_PROD_URL}" 203 local url="${REPORT_UPLOAD_PROD_URL}"
199 local chromeos_version="$(get_key_value "${meta_path}" "ver")" 204 local chromeos_version="$(get_key_value "${meta_path}" "ver")"
200 local board="$(get_board)" 205 local board="$(get_board)"
201 local hwclass="$(get_hardware_class)" 206 local hwclass="$(get_hardware_class)"
202 local payload_extension="${kind}"
203 local write_payload_size="$(get_key_value "${meta_path}" "payload_size")" 207 local write_payload_size="$(get_key_value "${meta_path}" "payload_size")"
204 local sig="$(get_key_value "${meta_path}" "sig")" 208 local sig="$(get_key_value "${meta_path}" "sig")"
205 [ "${kind}" = "minidump" ] && payload_extension="dmp" 209 local send_payload_size="$(stat --printf=%s "${report_payload}" 2>/dev/null)"
206 local report_payload="$(get_base "${meta_path}").${payload_extension}"
207 local send_payload_size="$(stat --printf=%s "${report_payload}")"
208 lecho "Sending crash:" 210 lecho "Sending crash:"
209 lecho " Scheduled to send in ${sleep_time}s" 211 lecho " Scheduled to send in ${sleep_time}s"
210 lecho " Metadata: ${meta_path} (${kind})" 212 lecho " Metadata: ${meta_path} (${kind})"
211 lecho " Payload: ${report_payload}" 213 lecho " Payload: ${report_payload}"
212 lecho " Version: ${chromeos_version}" 214 lecho " Version: ${chromeos_version}"
213 if is_mock; then 215 if is_mock; then
214 lecho " Product: ${CHROMEOS_PRODUCT}" 216 lecho " Product: ${CHROMEOS_PRODUCT}"
215 lecho " URL: ${url}" 217 lecho " URL: ${url}"
216 lecho " Board: ${board}" 218 lecho " Board: ${board}"
217 lecho " HWClass: ${hwclass}" 219 lecho " HWClass: ${hwclass}"
(...skipping 16 matching lines...) Expand all
234 return 1 236 return 1
235 fi 237 fi
236 238
237 local report_id="${TMP_DIR}/report_id" 239 local report_id="${TMP_DIR}/report_id"
238 local curl_stderr="${TMP_DIR}/curl_stderr" 240 local curl_stderr="${TMP_DIR}/curl_stderr"
239 241
240 local extra_key1="write_payload_size" 242 local extra_key1="write_payload_size"
241 local extra_value1="${write_payload_size}" 243 local extra_value1="${write_payload_size}"
242 local extra_key2="send_payload_size" 244 local extra_key2="send_payload_size"
243 local extra_value2="${send_payload_size}" 245 local extra_value2="${send_payload_size}"
244 if [ "${kind}" = "kcrash" ]; then 246 if [ "${sig}" != "unknown" ]; then
245 extra_key1="sig" 247 extra_key1="sig"
246 extra_value1="${sig}" 248 extra_value1="${sig}"
247 extra_key2="sig2" 249 extra_key2="sig2"
248 extra_value2="${sig}" 250 extra_value2="${sig}"
249 fi 251 fi
250 252
251 set +e 253 set +e
252 curl "${url}" \ 254 curl "${url}" \
253 -F "prod=${CHROMEOS_PRODUCT}" \ 255 -F "prod=${CHROMEOS_PRODUCT}" \
254 -F "ver=${chromeos_version}" \ 256 -F "ver=${chromeos_version}" \
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 lecho "Removing old orphaned file: ${old_file}." 304 lecho "Removing old orphaned file: ${old_file}."
303 rm -f -- "${old_file}" 305 rm -f -- "${old_file}"
304 fi 306 fi
305 done 307 done
306 308
307 # Look through all metadata (*.meta) files, if any exist. 309 # Look through all metadata (*.meta) files, if any exist.
308 for meta_path in $(ls -1t "${dir}"/*.meta 2>/dev/null); do 310 for meta_path in $(ls -1t "${dir}"/*.meta 2>/dev/null); do
309 lecho "Considering metadata ${meta_path}." 311 lecho "Considering metadata ${meta_path}."
310 local kind=$(get_kind "${meta_path}") 312 local kind=$(get_kind "${meta_path}")
311 313
312 if [ "${kind}" != "minidump" ] && [ "${kind}" != "kcrash" ]; then 314 if [ "${kind}" != "minidump" ] && \
313 lecho "Unknown report kind. Removing report." 315 [ "${kind}" != "kcrash" ] && \
316 [ "${kind}" != "log" ]; then
317 lecho "Unknown report kind ${kind}. Removing report."
314 remove_report "${meta_path}" 318 remove_report "${meta_path}"
315 continue 319 continue
316 fi 320 fi
317 321
318 if ${METRICS_CLIENT} -g; then 322 if ${METRICS_CLIENT} -g; then
319 lecho "Guest mode has been entered. Delaying crash sending until exited." 323 lecho "Guest mode has been entered. Delaying crash sending until exited."
320 return 0 324 return 0
321 fi 325 fi
322 326
323 if ! ${METRICS_CLIENT} -c; then 327 if ! ${METRICS_CLIENT} -c; then
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 TMP_DIR="$(mktemp -d /tmp/crash_sender.XXXX)" 390 TMP_DIR="$(mktemp -d /tmp/crash_sender.XXXX)"
387 391
388 # Send system-wide crashes 392 # Send system-wide crashes
389 send_crashes "/var/spool/crash" 393 send_crashes "/var/spool/crash"
390 394
391 # Send user-specific crashes 395 # Send user-specific crashes
392 send_crashes "/home/chronos/user/crash" 396 send_crashes "/home/chronos/user/crash"
393 } 397 }
394 398
395 main 399 main
OLDNEW
« no previous file with comments | « crash_collector_test.cc ('k') | kernel_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698