1 //===- LLDBTableGen.cpp - Top-Level TableGen implementation for LLDB ------===//
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 // This file contains the main function for LLDB's TableGen.
11 //===----------------------------------------------------------------------===//
13 #include "LLDBTableGenBackends.h" // Declares all backends.
14 #include "llvm/Support/CommandLine.h"
15 #include "llvm/Support/ManagedStatic.h"
16 #include "llvm/Support/PrettyStackTrace.h"
17 #include "llvm/Support/Signals.h"
18 #include "llvm/TableGen/Error.h"
19 #include "llvm/TableGen/Main.h"
20 #include "llvm/TableGen/Record.h"
23 using namespace lldb_private
;
33 static cl::opt
<ActionType
> Action(
34 cl::desc("Action to perform:"),
35 cl::values(clEnumValN(PrintRecords
, "print-records",
36 "Print all records to stdout (default)"),
37 clEnumValN(DumpJSON
, "dump-json",
38 "Dump all records as machine-readable JSON"),
39 clEnumValN(GenOptionDefs
, "gen-lldb-option-defs",
40 "Generate lldb option definitions"),
41 clEnumValN(GenPropertyDefs
, "gen-lldb-property-defs",
42 "Generate lldb property definitions"),
43 clEnumValN(GenPropertyEnumDefs
, "gen-lldb-property-enum-defs",
44 "Generate lldb property enum definitions")));
46 static bool LLDBTableGenMain(raw_ostream
&OS
, const RecordKeeper
&Records
) {
49 OS
<< Records
; // No argument, dump all contents
52 EmitJSON(Records
, OS
);
55 EmitOptionDefs(Records
, OS
);
58 EmitPropertyDefs(Records
, OS
);
60 case GenPropertyEnumDefs
:
61 EmitPropertyEnumDefs(Records
, OS
);
67 int main(int argc
, char **argv
) {
68 sys::PrintStackTraceOnErrorSignal(argv
[0]);
69 PrettyStackTraceProgram
X(argc
, argv
);
70 cl::ParseCommandLineOptions(argc
, argv
);
73 return TableGenMain(argv
[0], &LLDBTableGenMain
);
77 #if __has_feature(address_sanitizer)
78 #include <sanitizer/lsan_interface.h>
79 // Disable LeakSanitizer for this binary as it has too many leaks that are not
80 // very interesting to fix. See compiler-rt/include/sanitizer/lsan_interface.h .
81 int __lsan_is_turned_off() { return 1; }
82 #endif // __has_feature(address_sanitizer)
83 #endif // defined(__has_feature)