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/base_api.h" | |
wtc
2011/03/25 17:20:34
Does this file need to include base_api.h? It doe
rvargas (doing something else)
2011/03/25 17:43:00
This is a good point. Happy to remove it.
| |
13 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
15 | 16 |
16 // This only works on Windows. It's legal to include on other platforms, but | 17 // This only works on Windows. It's legal to include on other platforms, but |
17 // will be a NOP. | 18 // will be a NOP. |
18 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
19 | 20 |
20 #ifndef DECLSPEC_SELECTANY | 21 #ifndef DECLSPEC_SELECTANY |
21 #define DECLSPEC_SELECTANY __declspec(selectany) | 22 #define DECLSPEC_SELECTANY __declspec(selectany) |
22 #endif | 23 #endif |
23 | 24 |
24 namespace base { | 25 namespace base { |
25 namespace debug { | 26 namespace debug { |
26 | 27 |
28 #if !defined(BASE_DLL) | |
wtc
2011/03/25 17:20:34
It would be nice to add a comment to explain why t
rvargas (doing something else)
2011/03/25 17:43:00
I'm tempted to rip this code altogether :)
Added:
| |
29 | |
27 // Debug on start functions and data. | 30 // Debug on start functions and data. |
28 class DebugOnStart { | 31 class DebugOnStart { |
29 public: | 32 public: |
30 // Expected function type in the .CRT$XI* section. | 33 // Expected function type in the .CRT$XI* section. |
31 // Note: See VC\crt\src\internal.h for reference. | 34 // Note: See VC\crt\src\internal.h for reference. |
32 typedef int (__cdecl *PIFV)(void); | 35 typedef int (__cdecl *PIFV)(void); |
33 | 36 |
34 // Looks at the command line for kDebugOnStart argument. If found, it invokes | 37 // Looks at the command line for kDebugOnStart argument. If found, it invokes |
35 // the debugger, if this fails, it crashes. | 38 // the debugger, if this fails, it crashes. |
36 static int __cdecl Init(); | 39 static int __cdecl Init(); |
(...skipping 25 matching lines...) Expand all Loading... | |
62 // "Fix" the segment. On x86, the .CRT segment is merged into the .data segment | 65 // "Fix" the segment. On x86, the .CRT segment is merged into the .data segment |
63 // so it contains non-const data only. | 66 // so it contains non-const data only. |
64 #pragma data_seg(push, ".CRT$XIB") | 67 #pragma data_seg(push, ".CRT$XIB") |
65 // Declare the pointer so the CRT will find it. | 68 // Declare the pointer so the CRT will find it. |
66 DECLSPEC_SELECTANY DebugOnStart::PIFV debug_on_start = &DebugOnStart::Init; | 69 DECLSPEC_SELECTANY DebugOnStart::PIFV debug_on_start = &DebugOnStart::Init; |
67 // Fix back the segment. | 70 // Fix back the segment. |
68 #pragma data_seg(pop) | 71 #pragma data_seg(pop) |
69 | 72 |
70 #endif // _WIN64 | 73 #endif // _WIN64 |
71 | 74 |
75 #endif // defined(BASE_DLL) | |
76 | |
72 } // namespace debug | 77 } // namespace debug |
73 } // namespace base | 78 } // namespace base |
74 | 79 |
75 #endif // defined(OS_WIN) | 80 #endif // defined(OS_WIN) |
76 | 81 |
77 #endif // BASE_DEBUG_DEBUG_ON_START_WIN_H_ | 82 #endif // BASE_DEBUG_DEBUG_ON_START_WIN_H_ |
OLD | NEW |