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 // 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_DEBUG_ON_START_WIN_H_ | 9 #ifndef BASE_DEBUG_DEBUG_ON_START_WIN_H_ |
10 #define BASE_DEBUG_DEBUG_ON_START_WIN_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 #include "build/build_config.h" |
15 | 15 |
16 // This only works on Windows. It's legal to include on other platforms, but | 16 // This only works on Windows. It's legal to include on other platforms, but |
17 // will be a NOP. | 17 // will be a NOP. |
18 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
19 | 19 |
20 #ifndef DECLSPEC_SELECTANY | 20 #ifndef DECLSPEC_SELECTANY |
21 #define DECLSPEC_SELECTANY __declspec(selectany) | 21 #define DECLSPEC_SELECTANY __declspec(selectany) |
22 #endif | 22 #endif |
23 | 23 |
24 namespace base { | 24 namespace base { |
25 namespace debug { | 25 namespace debug { |
26 | 26 |
27 // There is no way for this code, as currently implemented, to work across DLLs. | 27 // There is no way for this code, as currently implemented, to work across DLLs. |
28 // TODO(rvargas): It looks like we really don't use this code, at least not for | 28 // TODO(rvargas): It looks like we really don't use this code, at least not for |
29 // Chrome. Figure out if it's really worth implementing something simpler. | 29 // Chrome. Figure out if it's really worth implementing something simpler. |
30 #if !defined(COMPONENT_BUILD) | 30 #if !defined(BASE_DLL) |
31 | 31 |
32 // Debug on start functions and data. | 32 // Debug on start functions and data. |
33 class DebugOnStart { | 33 class DebugOnStart { |
34 public: | 34 public: |
35 // Expected function type in the .CRT$XI* section. | 35 // Expected function type in the .CRT$XI* section. |
36 // Note: See VC\crt\src\internal.h for reference. | 36 // Note: See VC\crt\src\internal.h for reference. |
37 typedef int (__cdecl *PIFV)(void); | 37 typedef int (__cdecl *PIFV)(void); |
38 | 38 |
39 // Looks at the command line for kDebugOnStart argument. If found, it invokes | 39 // Looks at the command line for kDebugOnStart argument. If found, it invokes |
40 // the debugger, if this fails, it crashes. | 40 // the debugger, if this fails, it crashes. |
(...skipping 26 matching lines...) Expand all Loading... |
67 // "Fix" the segment. On x86, the .CRT segment is merged into the .data segment | 67 // "Fix" the segment. On x86, the .CRT segment is merged into the .data segment |
68 // so it contains non-const data only. | 68 // so it contains non-const data only. |
69 #pragma data_seg(push, ".CRT$XIB") | 69 #pragma data_seg(push, ".CRT$XIB") |
70 // Declare the pointer so the CRT will find it. | 70 // Declare the pointer so the CRT will find it. |
71 DECLSPEC_SELECTANY DebugOnStart::PIFV debug_on_start = &DebugOnStart::Init; | 71 DECLSPEC_SELECTANY DebugOnStart::PIFV debug_on_start = &DebugOnStart::Init; |
72 // Fix back the segment. | 72 // Fix back the segment. |
73 #pragma data_seg(pop) | 73 #pragma data_seg(pop) |
74 | 74 |
75 #endif // _WIN64 | 75 #endif // _WIN64 |
76 | 76 |
77 #endif // defined(COMPONENT_BUILD) | 77 #endif // defined(BASE_DLL) |
78 | 78 |
79 } // namespace debug | 79 } // namespace debug |
80 } // namespace base | 80 } // namespace base |
81 | 81 |
82 #endif // defined(OS_WIN) | 82 #endif // defined(OS_WIN) |
83 | 83 |
84 #endif // BASE_DEBUG_DEBUG_ON_START_WIN_H_ | 84 #endif // BASE_DEBUG_DEBUG_ON_START_WIN_H_ |
OLD | NEW |