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__)
23#endif
24
25#if defined(_WIN32)
28#include <crtdbg.h>
29#endif
30
31#include "llvm/Support/TargetSelect.h"
32
33#include <string>
34
35using namespace lldb_private;
36
38 HostInfo::SharedLibraryDirectoryHelper *helper)
39 : m_shlib_dir_helper(helper) {}
40
42
44#if defined(_WIN32)
45 const char *disable_crash_dialog_var = getenv("LLDB_DISABLE_CRASH_DIALOG");
46 if (disable_crash_dialog_var &&
47 llvm::StringRef(disable_crash_dialog_var).equals_insensitive("true")) {
48 // This will prevent Windows from displaying a dialog box requiring user
49 // interaction when
50 // LLDB crashes. This is mostly useful when automating LLDB, for example
51 // via the test
52 // suite, so that a crash in LLDB does not prevent completion of the test
53 // suite.
54 ::SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS |
55 SEM_NOGPFAULTERRORBOX);
56
57 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
58 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
59 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
60 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
61 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
62 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
63 }
64#endif
65
67
70 HostInfo::Initialize(m_shlib_dir_helper);
71
72 llvm::Error error = Socket::Initialize();
73 if (error)
74 return error;
75
77
79
80#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
82#endif
83#if defined(_WIN32)
85#endif
86
87 return llvm::Error::success();
88}
89
92
93#if defined(_WIN32)
95#endif
96
98 HostInfo::Terminate();
102}
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:281
static llvm::Error Initialize()
Definition: Socket.cpp:82
static void Terminate()
Definition: Socket.cpp:101
SystemInitializerCommon(HostInfo::SharedLibraryDirectoryHelper *helper)
HostInfo::SharedLibraryDirectoryHelper * m_shlib_dir_helper
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
void InitializeLldbChannel()
Definition: LLDBLog.cpp:81