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

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

Issue 7763008: Disable frame pointer optimization on base::debug::StackTrace() so it works properly in release b... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 3 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 | content/plugin/npobject_stub.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 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <windows.h> 7 #include <windows.h>
8 #include <dbghelp.h> 8 #include <dbghelp.h>
9 9
10 #include <iostream> 10 #include <iostream>
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 } 129 }
130 130
131 DWORD init_error_; 131 DWORD init_error_;
132 base::Lock lock_; 132 base::Lock lock_;
133 DISALLOW_COPY_AND_ASSIGN(SymbolContext); 133 DISALLOW_COPY_AND_ASSIGN(SymbolContext);
134 }; 134 };
135 135
136 } // namespace 136 } // namespace
137 137
138 // Disable optimizations for the StackTrace::StackTrace function. It is
139 // important to disable at least frame pointer optimization ("y"), since
140 // that breaks CaptureStackBackTrace() and prevents StackTrace from working
141 // in Release builds (it may still be janky if other frames are using FPO,
142 // but at least it will make it further).
143 #if defined(COMPILER_MSVC)
144 #pragma optimize("", off)
145 #endif
146
138 StackTrace::StackTrace() { 147 StackTrace::StackTrace() {
139 // When walking our own stack, use CaptureStackBackTrace(). 148 // When walking our own stack, use CaptureStackBackTrace().
140 count_ = CaptureStackBackTrace(0, arraysize(trace_), trace_, NULL); 149 count_ = CaptureStackBackTrace(0, arraysize(trace_), trace_, NULL);
141 } 150 }
142 151
152 #if defined(COMPILER_MSVC)
153 #pragma optimize("", on)
154 #endif
155
143 StackTrace::StackTrace(EXCEPTION_POINTERS* exception_pointers) { 156 StackTrace::StackTrace(EXCEPTION_POINTERS* exception_pointers) {
144 // When walking an exception stack, we need to use StackWalk64(). 157 // When walking an exception stack, we need to use StackWalk64().
145 count_ = 0; 158 count_ = 0;
146 // Initialize stack walking. 159 // Initialize stack walking.
147 STACKFRAME64 stack_frame; 160 STACKFRAME64 stack_frame;
148 memset(&stack_frame, 0, sizeof(stack_frame)); 161 memset(&stack_frame, 0, sizeof(stack_frame));
149 #if defined(_WIN64) 162 #if defined(_WIN64)
150 int machine_type = IMAGE_FILE_MACHINE_AMD64; 163 int machine_type = IMAGE_FILE_MACHINE_AMD64;
151 stack_frame.AddrPC.Offset = exception_pointers->ContextRecord->Rip; 164 stack_frame.AddrPC.Offset = exception_pointers->ContextRecord->Rip;
152 stack_frame.AddrFrame.Offset = exception_pointers->ContextRecord->Rbp; 165 stack_frame.AddrFrame.Offset = exception_pointers->ContextRecord->Rbp;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 (*os) << "\t" << trace_[i] << "\n"; 201 (*os) << "\t" << trace_[i] << "\n";
189 } 202 }
190 } else { 203 } else {
191 (*os) << "Backtrace:\n"; 204 (*os) << "Backtrace:\n";
192 context->OutputTraceToStream(trace_, count_, os); 205 context->OutputTraceToStream(trace_, count_, os);
193 } 206 }
194 } 207 }
195 208
196 } // namespace debug 209 } // namespace debug
197 } // namespace base 210 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | content/plugin/npobject_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698