OLD | NEW |
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 |
| 11 #include "base/debug/debugging_flags.h" |
11 #include "base/debug/stack_trace.h" | 12 #include "base/debug/stack_trace.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/process/kill.h" | 14 #include "base/process/kill.h" |
14 #include "base/process/process_handle.h" | 15 #include "base/process/process_handle.h" |
15 #include "base/test/test_timeouts.h" | 16 #include "base/test/test_timeouts.h" |
16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "testing/multiprocess_func_list.h" | 19 #include "testing/multiprocess_func_list.h" |
19 | 20 |
20 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_IOS) | 21 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_IOS) |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 EXPECT_EQ("00001", itoa_r_wrapper(1, 128, 10, 5)); | 248 EXPECT_EQ("00001", itoa_r_wrapper(1, 128, 10, 5)); |
248 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 0)); | 249 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 0)); |
249 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 1)); | 250 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 1)); |
250 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 2)); | 251 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 2)); |
251 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 3)); | 252 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 3)); |
252 EXPECT_EQ("0688", itoa_r_wrapper(0x688, 128, 16, 4)); | 253 EXPECT_EQ("0688", itoa_r_wrapper(0x688, 128, 16, 4)); |
253 EXPECT_EQ("00688", itoa_r_wrapper(0x688, 128, 16, 5)); | 254 EXPECT_EQ("00688", itoa_r_wrapper(0x688, 128, 16, 5)); |
254 } | 255 } |
255 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) | 256 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) |
256 | 257 |
257 #if HAVE_TRACE_STACK_FRAME_POINTERS && !defined(OS_WIN) | |
258 // Windows x64 binaries cannot be built with frame pointer, and MSVC doesn't | 258 // 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 | 259 // 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. | 260 // does it allow us to take the address of labels, so skip these under Windows. |
| 261 #if BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS) && !defined(OS_WIN) |
| 262 |
261 template <size_t Depth> | 263 template <size_t Depth> |
262 void NOINLINE ExpectStackFramePointers(const void** frames, | 264 void NOINLINE ExpectStackFramePointers(const void** frames, |
263 size_t max_depth) { | 265 size_t max_depth) { |
264 code_start: | 266 code_start: |
265 // Calling __builtin_frame_address() forces compiler to emit | 267 // Calling __builtin_frame_address() forces compiler to emit |
266 // frame pointers, even if they are not enabled. | 268 // frame pointers, even if they are not enabled. |
267 EXPECT_NE(nullptr, __builtin_frame_address(0)); | 269 EXPECT_NE(nullptr, __builtin_frame_address(0)); |
268 ExpectStackFramePointers<Depth - 1>(frames, max_depth); | 270 ExpectStackFramePointers<Depth - 1>(frames, max_depth); |
269 | 271 |
270 constexpr size_t frame_index = Depth - 1; | 272 constexpr size_t frame_index = Depth - 1; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 #if defined(OS_ANDROID) || defined(OS_MACOSX) | 310 #if defined(OS_ANDROID) || defined(OS_MACOSX) |
309 #define MAYBE_StackEnd StackEnd | 311 #define MAYBE_StackEnd StackEnd |
310 #else | 312 #else |
311 #define MAYBE_StackEnd DISABLED_StackEnd | 313 #define MAYBE_StackEnd DISABLED_StackEnd |
312 #endif | 314 #endif |
313 | 315 |
314 TEST_F(StackTraceTest, MAYBE_StackEnd) { | 316 TEST_F(StackTraceTest, MAYBE_StackEnd) { |
315 EXPECT_NE(0u, GetStackEnd()); | 317 EXPECT_NE(0u, GetStackEnd()); |
316 } | 318 } |
317 | 319 |
318 #endif // HAVE_TRACE_STACK_FRAME_POINTERS && !defined(OS_WIN) | 320 #endif // BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS) && !defined(OS_WIN) |
319 | 321 |
320 } // namespace debug | 322 } // namespace debug |
321 } // namespace base | 323 } // namespace base |
OLD | NEW |