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 HostInfo::SharedLibraryDirectoryHelper *helper)
40 : m_shlib_dir_helper(helper) {}
41
43
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 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
59 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
60 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
61 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
62 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
63 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
64 }
65#endif
66
68
71 HostInfo::Initialize(m_shlib_dir_helper);
72
73 llvm::Error error = Socket::Initialize();
74 if (error)
75 return error;
76
78
80
81#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
82 defined(__OpenBSD__)
84#endif
85#if defined(_WIN32)
87#endif
88
89 return llvm::Error::success();
90}
91
94
95#if defined(_WIN32)
97#endif
98
100 HostInfo::Terminate();
104}
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:282
static llvm::Error Initialize()
Definition: Socket.cpp:114
static void Terminate()
Definition: Socket.cpp:132
SystemInitializerCommon(HostInfo::SharedLibraryDirectoryHelper *helper)
HostInfo::SharedLibraryDirectoryHelper * m_shlib_dir_helper
A class that represents a running process on the host machine.
void InitializeLldbChannel()
Definition: LLDBLog.cpp:81