LLDB mainline
SystemInitializerCommon.cpp
Go to the documentation of this file.
1//===-- SystemInitializerCommon.cpp ---------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
14#include "lldb/Host/Host.h"
15#include "lldb/Host/Socket.h"
18#include "lldb/Utility/Timer.h"
20
21#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
22 defined(__OpenBSD__)
24#endif
25
26#if defined(_WIN32)
29#include <crtdbg.h>
30#endif
31
32#include "llvm/Support/TargetSelect.h"
33
34#include <string>
35
36using namespace lldb_private;
37
39
41
43#if defined(_WIN32)
44 const char *disable_crash_dialog_var = getenv("LLDB_DISABLE_CRASH_DIALOG");
45 if (disable_crash_dialog_var &&
46 llvm::StringRef(disable_crash_dialog_var).equals_insensitive("true")) {
47 // This will prevent Windows from displaying a dialog box requiring user
48 // interaction when
49 // LLDB crashes. This is mostly useful when automating LLDB, for example
50 // via the test
51 // suite, so that a crash in LLDB does not prevent completion of the test
52 // suite.
53 ::SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS |
54 SEM_NOGPFAULTERRORBOX);
55
56#ifdef _MSC_VER
57 // crtdbg.h expands these to no-ops unless _DEBUG is set, in which case
58 // they become real calls into the debug CRT. That macro means both "this
59 // code is built in debug mode" and "a debug CRT is linked", which go
60 // together for MSVC but not for MinGW: a debug MinGW build normally still
61 // links the release CRT, which does not export them.
62 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
63 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
64 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
65 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
66 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
67 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
68#endif // _MSC_VER
69 }
70#endif
71
75 HostInfo::Initialize();
76
77 llvm::Error error = Socket::Initialize();
78 if (error)
79 return error;
80
82
84
85#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
86 defined(__OpenBSD__)
88#endif
89#if defined(_WIN32)
91#endif
92
93 return llvm::Error::success();
94}
95
98
99#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
100 defined(__OpenBSD__)
102#endif
103#if defined(_WIN32)
105#endif
106
108
110 HostInfo::Terminate();
115}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_SCOPED_TIMER()
Definition Timer.h:83
static void Initialize(T &&...t)
Definition FileSystem.h:50
static void DisableAllLogChannels()
Definition Log.cpp:297
static llvm::Error Initialize()
Definition Socket.cpp:176
static void Terminate()
Definition Socket.cpp:194
A class that represents a running process on the host machine.