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

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

Issue 2782063005: Explicitly specify whether to emit frame pointers by default. (Closed)
Patch Set: Clean up. Created 3 years, 8 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
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <limits> 7 #include <limits>
8 #include <sstream> 8 #include <sstream>
9 #include <string> 9 #include <string>
10 10
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 EXPECT_EQ("00001", itoa_r_wrapper(1, 128, 10, 5)); 247 EXPECT_EQ("00001", itoa_r_wrapper(1, 128, 10, 5));
248 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 0)); 248 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 0));
249 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 1)); 249 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 1));
250 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 2)); 250 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 2));
251 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 3)); 251 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 3));
252 EXPECT_EQ("0688", itoa_r_wrapper(0x688, 128, 16, 4)); 252 EXPECT_EQ("0688", itoa_r_wrapper(0x688, 128, 16, 4));
253 EXPECT_EQ("00688", itoa_r_wrapper(0x688, 128, 16, 5)); 253 EXPECT_EQ("00688", itoa_r_wrapper(0x688, 128, 16, 5));
254 } 254 }
255 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) 255 #endif // defined(OS_POSIX) && !defined(OS_ANDROID)
256 256
257 #if HAVE_TRACE_STACK_FRAME_POINTERS && !defined(OS_WIN)
258 // Windows x64 binaries cannot be built with frame pointer, and MSVC doesn't 257 // Windows x64 binaries cannot be built with frame pointer, and MSVC doesn't
259 // provide intrinsics to query the frame pointer even for the x86 build, nor 258 // provide intrinsics to query the frame pointer even for the x86 build, nor
260 // does it allow us to take the address of labels, so skip these under Windows. 259 // does it allow us to take the address of labels, so skip these under Windows.
260 #if CAN_UNWIND_WITH_FRAME_POINTERS && !defined(OS_WIN)
261
261 template <size_t Depth> 262 template <size_t Depth>
262 void NOINLINE ExpectStackFramePointers(const void** frames, 263 void NOINLINE ExpectStackFramePointers(const void** frames,
263 size_t max_depth) { 264 size_t max_depth) {
264 code_start: 265 code_start:
265 // Calling __builtin_frame_address() forces compiler to emit 266 // Calling __builtin_frame_address() forces compiler to emit
266 // frame pointers, even if they are not enabled. 267 // frame pointers, even if they are not enabled.
267 EXPECT_NE(nullptr, __builtin_frame_address(0)); 268 EXPECT_NE(nullptr, __builtin_frame_address(0));
268 ExpectStackFramePointers<Depth - 1>(frames, max_depth); 269 ExpectStackFramePointers<Depth - 1>(frames, max_depth);
269 270
270 constexpr size_t frame_index = Depth - 1; 271 constexpr size_t frame_index = Depth - 1;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 #if defined(OS_ANDROID) || defined(OS_MACOSX) 309 #if defined(OS_ANDROID) || defined(OS_MACOSX)
309 #define MAYBE_StackEnd StackEnd 310 #define MAYBE_StackEnd StackEnd
310 #else 311 #else
311 #define MAYBE_StackEnd DISABLED_StackEnd 312 #define MAYBE_StackEnd DISABLED_StackEnd
312 #endif 313 #endif
313 314
314 TEST_F(StackTraceTest, MAYBE_StackEnd) { 315 TEST_F(StackTraceTest, MAYBE_StackEnd) {
315 EXPECT_NE(0u, GetStackEnd()); 316 EXPECT_NE(0u, GetStackEnd());
316 } 317 }
317 318
318 #endif // HAVE_TRACE_STACK_FRAME_POINTERS && !defined(OS_WIN) 319 #endif // CAN_UNWIND_WITH_FRAME_POINTERS && !defined(OS_WIN)
319 320
320 } // namespace debug 321 } // namespace debug
321 } // namespace base 322 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698