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

Side by Side Diff: base/debug/stack_trace_android.cc

Issue 18293007: Enable IO before reading /proc/self/maps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 5 months 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/debug/stack_trace.h" 5 #include "base/debug/stack_trace.h"
6 6
7 #include <android/log.h> 7 #include <android/log.h>
8 #include <unwind.h> 8 #include <unwind.h>
9 9
10 #include "base/debug/proc_maps_linux.h" 10 #include "base/debug/proc_maps_linux.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/threading/thread_restrictions.h"
12 13
13 namespace { 14 namespace {
14 15
15 struct StackCrawlState { 16 struct StackCrawlState {
16 StackCrawlState(uintptr_t* frames, size_t max_depth) 17 StackCrawlState(uintptr_t* frames, size_t max_depth)
17 : frames(frames), 18 : frames(frames),
18 frame_count(0), 19 frame_count(0),
19 max_depth(max_depth), 20 max_depth(max_depth),
20 have_skipped_self(false) {} 21 have_skipped_self(false) {}
21 22
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 std::string backtrace = ToString(); 79 std::string backtrace = ToString();
79 __android_log_write(ANDROID_LOG_ERROR, "chromium", backtrace.c_str()); 80 __android_log_write(ANDROID_LOG_ERROR, "chromium", backtrace.c_str());
80 } 81 }
81 82
82 // NOTE: Native libraries in APKs are stripped before installing. Print out the 83 // NOTE: Native libraries in APKs are stripped before installing. Print out the
83 // relocatable address and library names so host computers can use tools to 84 // relocatable address and library names so host computers can use tools to
84 // symbolize and demangle (e.g., addr2line, c++filt). 85 // symbolize and demangle (e.g., addr2line, c++filt).
85 void StackTrace::OutputToStream(std::ostream* os) const { 86 void StackTrace::OutputToStream(std::ostream* os) const {
86 std::string proc_maps; 87 std::string proc_maps;
87 std::vector<MappedMemoryRegion> regions; 88 std::vector<MappedMemoryRegion> regions;
89 // Allow IO to read /proc/self/maps. Reading this file doesn't hit the disk
90 // since it lives in procfs, and this is currently used to print a stack trace
91 // on fatal log messages in debug builds only. If the restriction is enabled
92 // then it will recursively trigger fatal failures when this enters on the
93 // UI thread.
94 base::ThreadRestrictions::ScopedAllowIO allow_io;
88 if (!ReadProcMaps(&proc_maps)) { 95 if (!ReadProcMaps(&proc_maps)) {
89 __android_log_write( 96 __android_log_write(
90 ANDROID_LOG_ERROR, "chromium", "Failed to read /proc/self/maps"); 97 ANDROID_LOG_ERROR, "chromium", "Failed to read /proc/self/maps");
91 } else if (!ParseProcMaps(proc_maps, &regions)) { 98 } else if (!ParseProcMaps(proc_maps, &regions)) {
92 __android_log_write( 99 __android_log_write(
93 ANDROID_LOG_ERROR, "chromium", "Failed to parse /proc/self/maps"); 100 ANDROID_LOG_ERROR, "chromium", "Failed to parse /proc/self/maps");
94 } 101 }
95 102
96 for (size_t i = 0; i < count_; ++i) { 103 for (size_t i = 0; i < count_; ++i) {
97 // Subtract one as return address of function may be in the next 104 // Subtract one as return address of function may be in the next
(...skipping 18 matching lines...) Expand all
116 } else { 123 } else {
117 *os << "<unknown>"; 124 *os << "<unknown>";
118 } 125 }
119 126
120 *os << "\n"; 127 *os << "\n";
121 } 128 }
122 } 129 }
123 130
124 } // namespace debug 131 } // namespace debug
125 } // namespace base 132 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698