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