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

Side by Side Diff: base/debug_on_start.h

Issue 5984007: Move base/debug_on_start to base/debugger and rename it to be _win since it... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « base/debug/debug_on_start_win.cc ('k') | base/debug_on_start.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
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
7 // debugger, if no system-wide debugger is registered, a debug break is done.
8
9 #ifndef BASE_DEBUG_ON_START_H_
10 #define BASE_DEBUG_ON_START_H_
11 #pragma once
12
13 #include "base/basictypes.h"
14
15 // This only works on Windows.
16 #if defined(OS_WIN)
17
18 #ifndef DECLSPEC_SELECTANY
19 #define DECLSPEC_SELECTANY __declspec(selectany)
20 #endif
21
22 // Debug on start functions and data.
23 class DebugOnStart {
24 public:
25 // Expected function type in the .CRT$XI* section.
26 // Note: See VC\crt\src\internal.h for reference.
27 typedef int (__cdecl *PIFV)(void);
28
29 // Looks at the command line for kDebugOnStart argument. If found, it invokes
30 // the debugger, if this fails, it crashes.
31 static int __cdecl Init();
32
33 // Returns true if the 'argument' is present in the 'command_line'. It does
34 // not use the CRT, only Kernel32 functions.
35 static bool FindArgument(wchar_t* command_line, const char* argument);
36 };
37
38 // Set the function pointer to our function to look for a crash on start. The
39 // XIB section is started pretty early in the program initialization so in
40 // theory it should be called before any user created global variable
41 // initialization code and CRT initialization code.
42 // Note: See VC\crt\src\defsects.inc and VC\crt\src\crt0.c for reference.
43 #ifdef _WIN64
44
45 // "Fix" the segment. On x64, the .CRT segment is merged into the .rdata segment
46 // so it contains const data only.
47 #pragma const_seg(push, ".CRT$XIB")
48 // Declare the pointer so the CRT will find it.
49 extern const DebugOnStart::PIFV debug_on_start;
50 DECLSPEC_SELECTANY const DebugOnStart::PIFV debug_on_start =
51 &DebugOnStart::Init;
52 // Fix back the segment.
53 #pragma const_seg(pop)
54
55 #else // _WIN64
56
57 // "Fix" the segment. On x86, the .CRT segment is merged into the .data segment
58 // so it contains non-const data only.
59 #pragma data_seg(push, ".CRT$XIB")
60 // Declare the pointer so the CRT will find it.
61 DECLSPEC_SELECTANY DebugOnStart::PIFV debug_on_start = &DebugOnStart::Init;
62 // Fix back the segment.
63 #pragma data_seg(pop)
64
65 #endif // _WIN64
66 #endif // defined(OS_WIN)
67
68 #endif // BASE_DEBUG_ON_START_H_
OLDNEW
« no previous file with comments | « base/debug/debug_on_start_win.cc ('k') | base/debug_on_start.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698