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