Jonas Devlieghere | 9870f6a | 2019-07-25 04:38:46 +0000 | [diff] [blame] | 1 | //===- LLDBTableGen.cpp - Top-Level TableGen implementation for LLDB ------===// |
Jonas Devlieghere | 93f5059 | 2019-07-23 17:47:08 +0000 | [diff] [blame] | 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 | // |
Jonas Devlieghere | 9870f6a | 2019-07-25 04:38:46 +0000 | [diff] [blame] | 9 | // This file contains the main function for LLDB's TableGen. |
Jonas Devlieghere | 93f5059 | 2019-07-23 17:47:08 +0000 | [diff] [blame] | 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 | |
| 21 | using namespace llvm; |
| 22 | using namespace lldb_private; |
| 23 | |
| 24 | enum ActionType { |
| 25 | PrintRecords, |
| 26 | DumpJSON, |
| 27 | GenOptionDefs, |
Jonas Devlieghere | 971f9ca | 2019-07-25 21:36:37 +0000 | [diff] [blame] | 28 | GenPropertyDefs, |
| 29 | GenPropertyEnumDefs, |
Jonas Devlieghere | 93f5059 | 2019-07-23 17:47:08 +0000 | [diff] [blame] | 30 | }; |
| 31 | |
Jonas Devlieghere | 971f9ca | 2019-07-25 21:36:37 +0000 | [diff] [blame] | 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"))); |
Jonas Devlieghere | 93f5059 | 2019-07-23 17:47:08 +0000 | [diff] [blame] | 44 | |
| 45 | static 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; |
Jonas Devlieghere | 971f9ca | 2019-07-25 21:36:37 +0000 | [diff] [blame] | 56 | case GenPropertyDefs: |
| 57 | EmitPropertyDefs(Records, OS); |
| 58 | break; |
| 59 | case GenPropertyEnumDefs: |
| 60 | EmitPropertyEnumDefs(Records, OS); |
| 61 | break; |
Jonas Devlieghere | 93f5059 | 2019-07-23 17:47:08 +0000 | [diff] [blame] | 62 | } |
| 63 | return false; |
| 64 | } |
| 65 | |
| 66 | int 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 . |
| 81 | int __lsan_is_turned_off() { return 1; } |
| 82 | #endif // __has_feature(address_sanitizer) |
| 83 | #endif // defined(__has_feature) |