Path: blob/main/contrib/llvm-project/lldb/utils/TableGen/LLDBTableGen.cpp
39563 views
//===- LLDBTableGen.cpp - Top-Level TableGen implementation for LLDB ------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file contains the main function for LLDB's TableGen.9//10//===----------------------------------------------------------------------===//1112#include "LLDBTableGenBackends.h" // Declares all backends.13#include "llvm/Support/CommandLine.h"14#include "llvm/Support/ManagedStatic.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"2021using namespace llvm;22using namespace lldb_private;2324enum ActionType {25PrintRecords,26DumpJSON,27GenOptionDefs,28GenPropertyDefs,29GenPropertyEnumDefs,30};3132static cl::opt<ActionType> Action(33cl::desc("Action to perform:"),34cl::values(clEnumValN(PrintRecords, "print-records",35"Print all records to stdout (default)"),36clEnumValN(DumpJSON, "dump-json",37"Dump all records as machine-readable JSON"),38clEnumValN(GenOptionDefs, "gen-lldb-option-defs",39"Generate lldb option definitions"),40clEnumValN(GenPropertyDefs, "gen-lldb-property-defs",41"Generate lldb property definitions"),42clEnumValN(GenPropertyEnumDefs, "gen-lldb-property-enum-defs",43"Generate lldb property enum definitions")));4445static bool LLDBTableGenMain(raw_ostream &OS, RecordKeeper &Records) {46switch (Action) {47case PrintRecords:48OS << Records; // No argument, dump all contents49break;50case DumpJSON:51EmitJSON(Records, OS);52break;53case GenOptionDefs:54EmitOptionDefs(Records, OS);55break;56case GenPropertyDefs:57EmitPropertyDefs(Records, OS);58break;59case GenPropertyEnumDefs:60EmitPropertyEnumDefs(Records, OS);61break;62}63return false;64}6566int main(int argc, char **argv) {67sys::PrintStackTraceOnErrorSignal(argv[0]);68PrettyStackTraceProgram X(argc, argv);69cl::ParseCommandLineOptions(argc, argv);70llvm_shutdown_obj Y;7172return TableGenMain(argv[0], &LLDBTableGenMain);73}7475#ifdef __has_feature76#if __has_feature(address_sanitizer)77#include <sanitizer/lsan_interface.h>78// Disable LeakSanitizer for this binary as it has too many leaks that are not79// very interesting to fix. See compiler-rt/include/sanitizer/lsan_interface.h .80int __lsan_is_turned_off() { return 1; }81#endif // __has_feature(address_sanitizer)82#endif // defined(__has_feature)838485