1*0b57cec5SDimitry Andric //===- llvm-xray.cpp: XRay Tool Main Program ------------------------------===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric // 9*0b57cec5SDimitry Andric // This file implements the main entry point for the suite of XRay tools. All 10*0b57cec5SDimitry Andric // additional functionality are implemented as subcommands. 11*0b57cec5SDimitry Andric // 12*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 13*0b57cec5SDimitry Andric // 14*0b57cec5SDimitry Andric // Basic usage: 15*0b57cec5SDimitry Andric // 16*0b57cec5SDimitry Andric // llvm-xray [options] <subcommand> [subcommand-specific options] 17*0b57cec5SDimitry Andric // 18*0b57cec5SDimitry Andric #include "xray-registry.h" 19*0b57cec5SDimitry Andric #include "llvm/Support/CommandLine.h" 20*0b57cec5SDimitry Andric #include "llvm/Support/raw_ostream.h" 21*0b57cec5SDimitry Andric 22*0b57cec5SDimitry Andric using namespace llvm; 23*0b57cec5SDimitry Andric using namespace llvm::xray; 24*0b57cec5SDimitry Andric 25*0b57cec5SDimitry Andric int main(int argc, char *argv[]) { 26*0b57cec5SDimitry Andric cl::ParseCommandLineOptions(argc, argv, 27*0b57cec5SDimitry Andric "XRay Tools\n\n" 28*0b57cec5SDimitry Andric " This program consolidates multiple XRay trace " 29*0b57cec5SDimitry Andric "processing tools for convenient access.\n"); 30*0b57cec5SDimitry Andric for (auto *SC : cl::getRegisteredSubcommands()) { 31*0b57cec5SDimitry Andric if (*SC) { 32*0b57cec5SDimitry Andric // If no subcommand was provided, we need to explicitly check if this is 33*0b57cec5SDimitry Andric // the top-level subcommand. 34*0b57cec5SDimitry Andric if (SC == &*cl::TopLevelSubCommand) { 35*0b57cec5SDimitry Andric cl::PrintHelpMessage(false, true); 36*0b57cec5SDimitry Andric return 0; 37*0b57cec5SDimitry Andric } 38*0b57cec5SDimitry Andric if (auto C = dispatch(SC)) { 39*0b57cec5SDimitry Andric ExitOnError("llvm-xray: ")(C()); 40*0b57cec5SDimitry Andric return 0; 41*0b57cec5SDimitry Andric } 42*0b57cec5SDimitry Andric } 43*0b57cec5SDimitry Andric } 44*0b57cec5SDimitry Andric 45*0b57cec5SDimitry Andric // If all else fails, we still print the usage message. 46*0b57cec5SDimitry Andric cl::PrintHelpMessage(false, true); 47*0b57cec5SDimitry Andric return 0; 48*0b57cec5SDimitry Andric } 49