LLDBTableGen.cpp revision 360784
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/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" 20 21using namespace llvm; 22using namespace lldb_private; 23 24enum ActionType { 25 PrintRecords, 26 DumpJSON, 27 GenOptionDefs, 28 GenPropertyDefs, 29 GenPropertyEnumDefs, 30}; 31 32static 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"))); 44 45static bool LLDBTableGenMain(raw_ostream &OS, RecordKeeper &Records) { 46 switch (Action) { 47 case PrintRecords: 48 OS << Records; // No argument, dump all contents 49 break; 50 case DumpJSON: 51 EmitJSON(Records, OS); 52 break; 53 case GenOptionDefs: 54 EmitOptionDefs(Records, OS); 55 break; 56 case GenPropertyDefs: 57 EmitPropertyDefs(Records, OS); 58 break; 59 case GenPropertyEnumDefs: 60 EmitPropertyEnumDefs(Records, OS); 61 break; 62 } 63 return false; 64} 65 66int main(int argc, char **argv) { 67 sys::PrintStackTraceOnErrorSignal(argv[0]); 68 PrettyStackTraceProgram X(argc, argv); 69 cl::ParseCommandLineOptions(argc, argv); 70 71 llvm_shutdown_obj Y; 72 73 return TableGenMain(argv[0], &LLDBTableGenMain); 74} 75 76#ifdef __has_feature 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 . 81int __lsan_is_turned_off() { return 1; } 82#endif // __has_feature(address_sanitizer) 83#endif // defined(__has_feature) 84