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
13#include "lldb/Host/Host.h"
14#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 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
57 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
58 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
59 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
60 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
61 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
62 }
63#endif
64
68 HostInfo::Initialize();
69
70 llvm::Error error = Socket::Initialize();
71 if (error)
72 return error;
73
75
77
78#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
79 defined(__OpenBSD__)
81#endif
82#if defined(_WIN32)
84#endif
85
86 return llvm::Error::success();
87}
88
91
92#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
93 defined(__OpenBSD__)
95#endif
96#if defined(_WIN32)
98#endif
99
101
103 HostInfo::Terminate();
108}
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:294
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.