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/Initialization/SystemLifetimeManager.h"
11 #include "lldb/Version/Version.h"
13 #include "llvm/ADT/STLExtras.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/Support/InitLLVM.h"
16 #include "llvm/Support/ManagedStatic.h"
17 #include "llvm/Support/PrettyStackTrace.h"
18 #include "llvm/Support/Signals.h"
23 static llvm::ManagedStatic
<lldb_private::SystemLifetimeManager
>
26 static void display_usage(const char *progname
) {
27 fprintf(stderr
, "Usage:\n"
29 " %s g[dbserver] [options]\n"
30 " %s p[latform] [options]\n"
31 "Invoke subcommand for additional help\n",
32 progname
, progname
, progname
);
36 // Forward declarations of subcommand main methods.
37 int main_gdbserver(int argc
, char *argv
[]);
38 int main_platform(int argc
, char *argv
[]);
41 static void initialize() {
42 if (auto e
= g_debugger_lifetime
->Initialize(
43 std::make_unique
<SystemInitializerLLGS
>(), nullptr))
44 llvm::consumeError(std::move(e
));
47 static void terminate_debugger() { g_debugger_lifetime
->Terminate(); }
51 int main(int argc
, char *argv
[]) {
52 llvm::InitLLVM
IL(argc
, argv
, /*InstallPipeSignalExitHandler=*/false);
53 llvm::PrettyStackTraceProgram
X(argc
, argv
);
56 const char *progname
= argv
[0];
58 display_usage(progname
);
65 main_gdbserver(argc
, argv
);
66 llgs::terminate_debugger();
70 main_platform(argc
, argv
);
71 llgs::terminate_debugger();
74 fprintf(stderr
, "%s\n", lldb_private::GetVersion());
77 display_usage(progname
);