llvm/llvm/tools/llvm-debuginfod-find/llvm-debuginfod-find.cpp

//===-- llvm-debuginfod-find.cpp - Simple CLI for libdebuginfod-client ----===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This file contains the llvm-debuginfod-find tool. This tool
/// queries the debuginfod servers in the DEBUGINFOD_URLS environment
/// variable (delimited by space (" ")) for the executable,
/// debuginfo, or specified source file of the binary matching the
/// given build-id.
///
//===----------------------------------------------------------------------===//

#include "llvm/ADT/StringExtras.h"
#include "llvm/Debuginfod/BuildIDFetcher.h"
#include "llvm/Debuginfod/Debuginfod.h"
#include "llvm/Debuginfod/HTTPClient.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/InitLLVM.h"

usingnamespacellvm;

cl::OptionCategory DebuginfodFindCategory("llvm-debuginfod-find Options");

cl::opt<std::string> InputBuildID(cl::Positional, cl::Required,
                                  cl::desc("<input build_id>"), cl::init("-"),
                                  cl::cat(DebuginfodFindCategory));

static cl::opt<bool>
    FetchExecutable("executable", cl::init(false),
                    cl::desc("If set, fetch a binary file associated with this "
                             "build id, containing the executable sections."),
                    cl::cat(DebuginfodFindCategory));

static cl::opt<bool>
    FetchDebuginfo("debuginfo", cl::init(false),
                   cl::desc("If set, fetch a binary file associated with this "
                            "build id, containing the debuginfo sections."),
                   cl::cat(DebuginfodFindCategory));

static cl::opt<std::string> FetchSource(
    "source", cl::init(""),
    cl::desc("Fetch a source file associated with this build id, which is at "
             "this relative path relative to the compilation directory."),
    cl::cat(DebuginfodFindCategory));

static cl::opt<bool>
    DumpToStdout("dump", cl::init(false),
                 cl::desc("If set, dumps the contents of the fetched artifact "
                          "to standard output. Otherwise, dumps the absolute "
                          "path to the cached artifact on disk."),
                 cl::cat(DebuginfodFindCategory));

static cl::list<std::string> DebugFileDirectory(
    "debug-file-directory",
    cl::desc("Path to directory where to look for debug files."),
    cl::cat(DebuginfodFindCategory));

[[noreturn]] static void helpExit() {}

ExitOnError ExitOnErr;

static std::string fetchDebugInfo(object::BuildIDRef BuildID);

int main(int argc, char **argv) {}

// Find a debug file in local build ID directories and via debuginfod.
std::string fetchDebugInfo(object::BuildIDRef BuildID) {}