1 //===-- lldb-server.cpp -----------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "SystemInitializerLLGS.h"
10 #include "lldb/Host/Config.h"
11 #include "lldb/Initialization/SystemLifetimeManager.h"
12 #include "lldb/Version/Version.h"
14 #include "llvm/ADT/STLExtras.h"
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/Support/InitLLVM.h"
17 #include "llvm/Support/ManagedStatic.h"
18 #include "llvm/Support/PrettyStackTrace.h"
19 #include "llvm/Support/Signals.h"
24 static llvm::ManagedStatic
<lldb_private::SystemLifetimeManager
>
27 static void display_usage(const char *progname
) {
28 fprintf(stderr
, "Usage:\n"
30 " %s g[dbserver] [options]\n"
31 " %s p[latform] [options]\n"
32 "Invoke subcommand for additional help\n",
33 progname
, progname
, progname
);
37 // Forward declarations of subcommand main methods.
38 int main_gdbserver(int argc
, char *argv
[]);
39 int main_platform(int argc
, char *argv
[]);
42 static void initialize() {
43 if (auto e
= g_debugger_lifetime
->Initialize(
44 std::make_unique
<SystemInitializerLLGS
>(), nullptr))
45 llvm::consumeError(std::move(e
));
48 static void terminate_debugger() { g_debugger_lifetime
->Terminate(); }
52 int main(int argc
, char *argv
[]) {
53 llvm::InitLLVM
IL(argc
, argv
, /*InstallPipeSignalExitHandler=*/false);
54 llvm::setBugReportMsg("PLEASE submit a bug report to " LLDB_BUG_REPORT_URL
55 " and include the crash backtrace.\n");
58 const char *progname
= argv
[0];
60 display_usage(progname
);
67 main_gdbserver(argc
, argv
);
68 llgs::terminate_debugger();
72 main_platform(argc
, argv
);
73 llgs::terminate_debugger();
76 fprintf(stderr
, "%s\n", lldb_private::GetVersion());
79 display_usage(progname
);