llvm-project
83 строки · 2.7 Кб
1//===- LLDBTableGen.cpp - Top-Level TableGen implementation for LLDB ------===//
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//
9// This file contains the main function for LLDB's TableGen.
10//
11//===----------------------------------------------------------------------===//
12
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"21
22using namespace llvm;23using namespace lldb_private;24
25enum ActionType {26PrintRecords,27DumpJSON,28GenOptionDefs,29GenPropertyDefs,30GenPropertyEnumDefs,31};32
33static cl::opt<ActionType> Action(34cl::desc("Action to perform:"),35cl::values(clEnumValN(PrintRecords, "print-records",36"Print all records to stdout (default)"),37clEnumValN(DumpJSON, "dump-json",38"Dump all records as machine-readable JSON"),39clEnumValN(GenOptionDefs, "gen-lldb-option-defs",40"Generate lldb option definitions"),41clEnumValN(GenPropertyDefs, "gen-lldb-property-defs",42"Generate lldb property definitions"),43clEnumValN(GenPropertyEnumDefs, "gen-lldb-property-enum-defs",44"Generate lldb property enum definitions")));45
46static bool LLDBTableGenMain(raw_ostream &OS, RecordKeeper &Records) {47switch (Action) {48case PrintRecords:49OS << Records; // No argument, dump all contents50break;51case DumpJSON:52EmitJSON(Records, OS);53break;54case GenOptionDefs:55EmitOptionDefs(Records, OS);56break;57case GenPropertyDefs:58EmitPropertyDefs(Records, OS);59break;60case GenPropertyEnumDefs:61EmitPropertyEnumDefs(Records, OS);62break;63}64return false;65}
66
67int main(int argc, char **argv) {68sys::PrintStackTraceOnErrorSignal(argv[0]);69PrettyStackTraceProgram X(argc, argv);70cl::ParseCommandLineOptions(argc, argv);71llvm_shutdown_obj Y;72
73return TableGenMain(argv[0], &LLDBTableGenMain);74}
75
76#ifdef __has_feature77#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 .
81int __lsan_is_turned_off() { return 1; }82#endif // __has_feature(address_sanitizer)83#endif // defined(__has_feature)84