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

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: added comment 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> // TODO(dmikurube): Remove. See http://crbug.com/236855. 8 #include <unwind.h> // TODO(dmikurube): Remove. See http://crbug.com/236855.
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 // TODO(dmikurube): Remove when Bionic's get_backtrace() gets popular. 14 // TODO(dmikurube): Remove when Bionic's get_backtrace() gets popular.
14 // See http://crbug.com/236855. 15 // See http://crbug.com/236855.
15 namespace { 16 namespace {
16 17
17 /* depends how the system includes define this */ 18 /* depends how the system includes define this */
18 #ifdef HAVE_UNWIND_CONTEXT_STRUCT 19 #ifdef HAVE_UNWIND_CONTEXT_STRUCT
19 typedef struct _Unwind_Context __unwind_context; 20 typedef struct _Unwind_Context __unwind_context;
20 #else 21 #else
21 typedef _Unwind_Context __unwind_context; 22 typedef _Unwind_Context __unwind_context;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 std::string backtrace = ToString(); 92 std::string backtrace = ToString();
92 __android_log_write(ANDROID_LOG_ERROR, "chromium", backtrace.c_str()); 93 __android_log_write(ANDROID_LOG_ERROR, "chromium", backtrace.c_str());
93 } 94 }
94 95
95 // NOTE: Native libraries in APKs are stripped before installing. Print out the 96 // NOTE: Native libraries in APKs are stripped before installing. Print out the
96 // relocatable address and library names so host computers can use tools to 97 // relocatable address and library names so host computers can use tools to
97 // symbolize and demangle (e.g., addr2line, c++filt). 98 // symbolize and demangle (e.g., addr2line, c++filt).
98 void StackTrace::OutputToStream(std::ostream* os) const { 99 void StackTrace::OutputToStream(std::ostream* os) const {
99 std::string proc_maps; 100 std::string proc_maps;
100 std::vector<MappedMemoryRegion> regions; 101 std::vector<MappedMemoryRegion> regions;
102 // Allow IO to read /proc/self/maps. Reading this file doesn't hit the disk
103 // since it lives in procfs, and this is currently used to print a stack trace
104 // on fatal log messages in debug builds only. If the restriction is enabled
105 // then it will recursively trigger fatal failures when this enters on the
106 // UI thread.
107 base::ThreadRestrictions::ScopedAllowIO allow_io;
101 if (!ReadProcMaps(&proc_maps)) { 108 if (!ReadProcMaps(&proc_maps)) {
scherkus (not reviewing) 2013/07/10 15:35:30 Q: thoughts on putting the ScopedAllowIO inside Re
Joao da Silva 2013/07/10 15:36:44 Seems like a better place for this to me. Mark, wh
102 __android_log_write( 109 __android_log_write(
103 ANDROID_LOG_ERROR, "chromium", "Failed to read /proc/self/maps"); 110 ANDROID_LOG_ERROR, "chromium", "Failed to read /proc/self/maps");
104 } else if (!ParseProcMaps(proc_maps, &regions)) { 111 } else if (!ParseProcMaps(proc_maps, &regions)) {
105 __android_log_write( 112 __android_log_write(
106 ANDROID_LOG_ERROR, "chromium", "Failed to parse /proc/self/maps"); 113 ANDROID_LOG_ERROR, "chromium", "Failed to parse /proc/self/maps");
107 } 114 }
108 115
109 for (size_t i = 0; i < count_; ++i) { 116 for (size_t i = 0; i < count_; ++i) {
110 // Subtract one as return address of function may be in the next 117 // Subtract one as return address of function may be in the next
111 // function when a function is annotated as noreturn. 118 // function when a function is annotated as noreturn.
(...skipping 17 matching lines...) Expand all
129 } else { 136 } else {
130 *os << "<unknown>"; 137 *os << "<unknown>";
131 } 138 }
132 139
133 *os << "\n"; 140 *os << "\n";
134 } 141 }
135 } 142 }
136 143
137 } // namespace debug 144 } // namespace debug
138 } // namespace base 145 } // 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