summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-27 02:46:10 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-27 02:46:10 +0000
commit77a25464cf7ab80f96a486753b99a1276e70d401 (patch)
tree08c50269b1d78bfd13af1df9e413c697ea08b846
parent54d768dbbdc71d359966e2f755f04b23e2c0b495 (diff)
downloadchromium_src-77a25464cf7ab80f96a486753b99a1276e70d401.zip
chromium_src-77a25464cf7ab80f96a486753b99a1276e70d401.tar.gz
chromium_src-77a25464cf7ab80f96a486753b99a1276e70d401.tar.bz2
Disable frame pointer optimization on base::debug::StackTrace() so it works properly in release builds.
Similarly disable optimizations in npobject_stub.cc so base::debug::StackTrace() can recognize more frames (This last de-optimization is only temporary, whereas the change to base::debug::StackTrace is intended to be permanent). BUG=94179 Review URL: http://codereview.chromium.org/7763008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98542 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/debug/stack_trace_win.cc13
-rw-r--r--content/plugin/npobject_stub.cc26
2 files changed, 39 insertions, 0 deletions
diff --git a/base/debug/stack_trace_win.cc b/base/debug/stack_trace_win.cc
index 97376a2..3332979 100644
--- a/base/debug/stack_trace_win.cc
+++ b/base/debug/stack_trace_win.cc
@@ -135,11 +135,24 @@ class SymbolContext {
} // namespace
+// Disable optimizations for the StackTrace::StackTrace function. It is
+// important to disable at least frame pointer optimization ("y"), since
+// that breaks CaptureStackBackTrace() and prevents StackTrace from working
+// in Release builds (it may still be janky if other frames are using FPO,
+// but at least it will make it further).
+#if defined(COMPILER_MSVC)
+#pragma optimize("", off)
+#endif
+
StackTrace::StackTrace() {
// When walking our own stack, use CaptureStackBackTrace().
count_ = CaptureStackBackTrace(0, arraysize(trace_), trace_, NULL);
}
+#if defined(COMPILER_MSVC)
+#pragma optimize("", on)
+#endif
+
StackTrace::StackTrace(EXCEPTION_POINTERS* exception_pointers) {
// When walking an exception stack, we need to use StackWalk64().
count_ = 0;
diff --git a/content/plugin/npobject_stub.cc b/content/plugin/npobject_stub.cc
index 1d51cb2..34d631d 100644
--- a/content/plugin/npobject_stub.cc
+++ b/content/plugin/npobject_stub.cc
@@ -16,6 +16,26 @@
using WebKit::WebBindings;
+// TODO(eroman): Remove this when done investigating 94179.
+//
+// The following disables optimizations for all the functions in this file.
+//
+// At a minimum we want to disable frame pointer optimization ("y"), so that
+// base::debug::StackTrace() works better. We also prevent inlining of these
+// functions so that StackTrace() is more complete. (The StackTrace() will
+// probably not be able to go deeper than these functions since the callers
+// will probably have FPO).
+//
+// Note that disabling optimizations causes warning 4748 which I have had to
+// disable throughout this file. That warning was:
+//
+// /GS can not protect parameters and local variables from local buffer
+// overrun because optimizations are disabled in function
+#if defined(COMPILER_MSVC)
+#pragma optimize("", off)
+MSVC_PUSH_DISABLE_WARNING(4748)
+#endif
+
NPObjectStub::NPObjectStub(
NPObject* npobject,
PluginChannelBase* channel,
@@ -445,3 +465,9 @@ void NPObjectStub::OnEvaluate(const std::string& script,
NPObjectMsg_Evaluate::WriteReplyParams(reply_msg, result_param, return_value);
channel_->Send(reply_msg);
}
+
+// Restore compiler optimizations and warnings.
+#if defined(COMPILER_MSVC)
+MSVC_POP_WARNING()
+#pragma optimize("", on)
+#endif