From 7af5c12597b4a99a501e1e7ddbecb72b69400488 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 5 Jan 2004 05:27:31 +0000 Subject: Initial checkin of the LLVM Source-Level Debugger. This is incomplete, but a good start. The status is documented in docs/SourceLevelDebugging.html git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10687 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-db/llvm-db.cpp | 88 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 tools/llvm-db/llvm-db.cpp (limited to 'tools/llvm-db/llvm-db.cpp') diff --git a/tools/llvm-db/llvm-db.cpp b/tools/llvm-db/llvm-db.cpp new file mode 100644 index 0000000000..124db2ba06 --- /dev/null +++ b/tools/llvm-db/llvm-db.cpp @@ -0,0 +1,88 @@ +//===- llvm-db.cpp - LLVM Debugger ----------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This utility implements a simple text-mode front-end to the LLVM debugger +// library. +// +//===----------------------------------------------------------------------===// + +#include "CLIDebugger.h" +#include "Support/CommandLine.h" +#include + +using namespace llvm; + +namespace { + // Command line options for specifying the program to debug and options to use + cl::opt + InputFile(cl::desc(""), cl::Positional, cl::init("")); + + cl::list + InputArgs("args", cl::Positional, cl::desc(""), + cl::ZeroOrMore); + + // Command line options to control various directory related stuff + cl::list + SourceDirectories("directory", cl::value_desc("directory"), + cl::desc("Add directory to the search for source files")); + cl::alias SDA("d", cl::desc("Alias for --directory"), + cl::aliasopt(SourceDirectories)); + + cl::opt + WorkingDirectory("cd", cl::desc("Use directory as current working directory"), + cl::value_desc("directory")); + + // Command line options specific to the llvm-db debugger driver + cl::opt Version("version", cl::desc("Print version number and quit")); + cl::opt Quiet("quiet", cl::desc("Do not print introductory messages")); + cl::alias QA1("silent", cl::desc("Alias for -quiet"), cl::aliasopt(Quiet)); + cl::alias QA2("q", cl::desc("Alias for -quiet"), cl::aliasopt(Quiet)); +} + +//===----------------------------------------------------------------------===// +// main Driver function +// +int main(int argc, char **argv, char * const *envp) { + cl::ParseCommandLineOptions(argc, argv, + " llvm source-level debugger\n"); + + if (Version || !Quiet) { + std::cout << "llvm-db: The LLVM source-level debugger\n"; + if (Version) return 1; + } + + // Merge Inputfile and InputArgs into the InputArgs list... + if (!InputFile.empty() && InputArgs.empty()) + InputArgs.push_back(InputFile); + + // Create the CLI debugger... + CLIDebugger D; + + // Initialize the debugger with the command line options we read... + Debugger &Dbg = D.getDebugger(); + + // Initialize the debugger environment. + Dbg.initializeEnvironment(envp); + Dbg.setWorkingDirectory(WorkingDirectory); + for (unsigned i = 0, e = SourceDirectories.size(); i != e; ++i) + D.addSourceDirectory(SourceDirectories[i]); + + if (!InputArgs.empty()) { + try { + D.fileCommand(InputArgs[0]); + } catch (const std::string &Error) { + std::cout << "Error: " << Error << "\n"; + } + + Dbg.setProgramArguments(InputArgs.begin()+1, InputArgs.end()); + } + + // Now that we have initialized the debugger, run it. + return D.run(); +} -- cgit v1.2.3-18-g5258