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"
19#include "lldb/Utility/Timer.h"
21
22#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
23 defined(__OpenBSD__)
25#endif
26
27#if defined(_WIN32)
30#include <crtdbg.h>
31#endif
32
33#include "llvm/Support/TargetSelect.h"
34
35#include <string>
36
37using namespace lldb_private;
38
40
42
45#if defined(_WIN32)
46 const char *disable_crash_dialog_var = getenv("LLDB_DISABLE_CRASH_DIALOG");
47 if (disable_crash_dialog_var &&
48 llvm::StringRef(disable_crash_dialog_var).equals_insensitive("true")) {
49 // This will prevent Windows from displaying a dialog box requiring user
50 // interaction when
51 // LLDB crashes. This is mostly useful when automating LLDB, for example
52 // via the test
53 // suite, so that a crash in LLDB does not prevent completion of the test
54 // suite.
55 ::SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS |
56 SEM_NOGPFAULTERRORBOX);
57
58#ifdef _MSC_VER
59 // crtdbg.h expands these to no-ops unless _DEBUG is set, in which case
60 // they become real calls into the debug CRT. That macro means both "this
61 // code is built in debug mode" and "a debug CRT is linked", which go
62 // together for MSVC but not for MinGW: a debug MinGW build normally still
63 // links the release CRT, which does not export them.
64 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
65 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
66 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
67 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
68 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
69 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
70#endif // _MSC_VER
71 }
72#endif
73
77 HostInfo::Initialize();
78
79 llvm::Error error = Socket::Initialize();
80 if (error)
81 return error;
82
84
86
87#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
88 defined(__OpenBSD__)
90#endif
91#if defined(_WIN32)
93#endif
94
95 return llvm::Error::success();
96}
97
100
101#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
102 defined(__OpenBSD__)
104#endif
105#if defined(_WIN32)
107#endif
108
110
112 HostInfo::Terminate();
117
119}
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
static void Initialize()
Set up and tear down the system pool, for strings that are not owned by a Debugger.
A class that represents a running process on the host machine.