1//===- llvm-xray.cpp: XRay Tool Main Program ------------------------------===//
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 implements the main entry point for the suite of XRay tools. All
10// additional functionality are implemented as subcommands.
11//
12//===----------------------------------------------------------------------===//
13//
14// Basic usage:
15//
16// llvm-xray [options] <subcommand> [subcommand-specific options]
17//
18#include "xray-registry.h"
19#include "llvm/Support/CommandLine.h"
20
21using namespace llvm;
22using namespace llvm::xray;
23
24int main(int argc, char *argv[]) {
25 cl::ParseCommandLineOptions(argc, argv,
26 Overview: "XRay Tools\n\n"
27 " This program consolidates multiple XRay trace "
28 "processing tools for convenient access.\n");
29 for (auto *SC : cl::getRegisteredSubcommands()) {
30 if (*SC) {
31 // If no subcommand was provided, we need to explicitly check if this is
32 // the top-level subcommand.
33 if (SC == &cl::SubCommand::getTopLevel()) {
34 cl::PrintHelpMessage(Hidden: false, Categorized: true);
35 return 0;
36 }
37 if (auto C = dispatch(SC)) {
38 ExitOnError("llvm-xray: ")(C());
39 return 0;
40 }
41 }
42 }
43
44 // If all else fails, we still print the usage message.
45 cl::PrintHelpMessage(Hidden: false, Categorized: true);
46 return 0;
47}
48