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/PrettyStackTrace.h"
16 #include "llvm/Support/Signals.h"
17 #include "llvm/TableGen/Error.h"
18 #include "llvm/TableGen/Main.h"
19 #include "llvm/TableGen/Record.h"
22 using namespace lldb_private
;
32 static cl::opt
<ActionType
> Action(
33 cl::desc("Action to perform:"),
34 cl::values(clEnumValN(PrintRecords
, "print-records",
35 "Print all records to stdout (default)"),
36 clEnumValN(DumpJSON
, "dump-json",
37 "Dump all records as machine-readable JSON"),
38 clEnumValN(GenOptionDefs
, "gen-lldb-option-defs",
39 "Generate lldb option definitions"),
40 clEnumValN(GenPropertyDefs
, "gen-lldb-property-defs",
41 "Generate lldb property definitions"),
42 clEnumValN(GenPropertyEnumDefs
, "gen-lldb-property-enum-defs",
43 "Generate lldb property enum definitions")));
45 static bool LLDBTableGenMain(raw_ostream
&OS
, RecordKeeper
&Records
) {
48 OS
<< Records
; // No argument, dump all contents
51 EmitJSON(Records
, OS
);
54 EmitOptionDefs(Records
, OS
);
57 EmitPropertyDefs(Records
, OS
);
59 case GenPropertyEnumDefs
:
60 EmitPropertyEnumDefs(Records
, OS
);
66 int main(int argc
, char **argv
) {
67 sys::PrintStackTraceOnErrorSignal(argv
[0]);
68 PrettyStackTraceProgram
X(argc
, argv
);
69 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)