OLD | NEW |
1 // Copyright (c) 2006-2008 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 // Define the necessary code and global data to look for kDebugOnStart command | 5 // Define the necessary code and global data to look for kDebugOnStart command |
6 // line argument. When the command line argument is detected, it invokes the | 6 // line argument. When the command line argument is detected, it invokes the |
7 // debugger, if no system-wide debugger is registered, a debug break is done. | 7 // debugger, if no system-wide debugger is registered, a debug break is done. |
8 | 8 |
9 #ifndef BASE_DEBUG_ON_START_H_ | 9 #ifndef BASE_DEBUG_DEBUG_ON_START_WIN_H_ |
10 #define BASE_DEBUG_ON_START_H_ | 10 #define BASE_DEBUG_DEBUG_ON_START_WIN_H_ |
11 #pragma once | 11 #pragma once |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "build/build_config.h" |
14 | 15 |
15 // This only works on Windows. | 16 // This only works on Windows. It's legal to include on other platforms, but |
| 17 // will be a NOP. |
16 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
17 | 19 |
18 #ifndef DECLSPEC_SELECTANY | 20 #ifndef DECLSPEC_SELECTANY |
19 #define DECLSPEC_SELECTANY __declspec(selectany) | 21 #define DECLSPEC_SELECTANY __declspec(selectany) |
20 #endif | 22 #endif |
21 | 23 |
| 24 namespace base { |
| 25 namespace debug { |
| 26 |
22 // Debug on start functions and data. | 27 // Debug on start functions and data. |
23 class DebugOnStart { | 28 class DebugOnStart { |
24 public: | 29 public: |
25 // Expected function type in the .CRT$XI* section. | 30 // Expected function type in the .CRT$XI* section. |
26 // Note: See VC\crt\src\internal.h for reference. | 31 // Note: See VC\crt\src\internal.h for reference. |
27 typedef int (__cdecl *PIFV)(void); | 32 typedef int (__cdecl *PIFV)(void); |
28 | 33 |
29 // Looks at the command line for kDebugOnStart argument. If found, it invokes | 34 // Looks at the command line for kDebugOnStart argument. If found, it invokes |
30 // the debugger, if this fails, it crashes. | 35 // the debugger, if this fails, it crashes. |
31 static int __cdecl Init(); | 36 static int __cdecl Init(); |
(...skipping 23 matching lines...) Expand all Loading... |
55 #else // _WIN64 | 60 #else // _WIN64 |
56 | 61 |
57 // "Fix" the segment. On x86, the .CRT segment is merged into the .data segment | 62 // "Fix" the segment. On x86, the .CRT segment is merged into the .data segment |
58 // so it contains non-const data only. | 63 // so it contains non-const data only. |
59 #pragma data_seg(push, ".CRT$XIB") | 64 #pragma data_seg(push, ".CRT$XIB") |
60 // Declare the pointer so the CRT will find it. | 65 // Declare the pointer so the CRT will find it. |
61 DECLSPEC_SELECTANY DebugOnStart::PIFV debug_on_start = &DebugOnStart::Init; | 66 DECLSPEC_SELECTANY DebugOnStart::PIFV debug_on_start = &DebugOnStart::Init; |
62 // Fix back the segment. | 67 // Fix back the segment. |
63 #pragma data_seg(pop) | 68 #pragma data_seg(pop) |
64 | 69 |
| 70 } // namespace debug |
| 71 } // namespace base |
| 72 |
65 #endif // _WIN64 | 73 #endif // _WIN64 |
66 #endif // defined(OS_WIN) | 74 #endif // defined(OS_WIN) |
67 | 75 |
68 #endif // BASE_DEBUG_ON_START_H_ | 76 #endif // BASE_DEBUG_DEBUG_ON_START_WIN_H_ |
OLD | NEW |