From 82ecf9a0b1b3b90e99e90cb16f4bff78c4e8be3c Mon Sep 17 00:00:00 2001 From: Eric Astor Date: Thu, 21 Apr 2022 10:01:02 -0400 Subject: [PATCH] [LLVM-ML] Add standard LLVM debug flags Adds support for -debug and -debug-only= flags. Reviewed By: ayzhao Differential Revision: https://reviews.llvm.org/D123545 --- llvm/tools/llvm-ml/Opts.td | 6 ++++++ llvm/tools/llvm-ml/llvm-ml.cpp | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/llvm/tools/llvm-ml/Opts.td b/llvm/tools/llvm-ml/Opts.td index a6759ad..9cd1e91 100644 --- a/llvm/tools/llvm-ml/Opts.td +++ b/llvm/tools/llvm-ml/Opts.td @@ -7,6 +7,7 @@ class LLVMFlag : Flag<["--", "-"], name>; class LLVMJoined : Joined<["--", "-"], name>; class LLVMJoinedOrSeparate : JoinedOrSeparate<["--", "-"], name>; class LLVMSeparate : Separate<["--", "-"], name>; +class LLVMCommaJoined : CommaJoined<["--", "-"], name>; def ml_Group : OptionGroup<"">, HelpText<"ML.EXE COMPATIBILITY OPTIONS">; @@ -31,6 +32,11 @@ def bitness : LLVMJoined<"m">, Values<"32,64">, HelpText<"Target platform (x86 or x86-64)">; def as_lex : LLVMFlag<"as-lex">, HelpText<"Lex tokens from a .asm file without assembling">; +def debug : LLVMFlag<"debug">, Flags<[HelpHidden]>, + HelpText<"Enable debug output">; +def debug_only : LLVMCommaJoined<"debug-only=">, Flags<[HelpHidden]>, + HelpText<"Enable a specific type of debug output (comma " + "separated list of types)">; def fatal_warnings : LLVMFlag<"fatal-warnings">, HelpText<"Treat warnings as errors">; def filetype : LLVMJoined<"filetype=">, Values<"obj,s,null">, diff --git a/llvm/tools/llvm-ml/llvm-ml.cpp b/llvm/tools/llvm-ml/llvm-ml.cpp index 1be820b..2fd218a 100644 --- a/llvm/tools/llvm-ml/llvm-ml.cpp +++ b/llvm/tools/llvm-ml/llvm-ml.cpp @@ -243,6 +243,13 @@ int main(int Argc, char **Argv) { << "' option\n"; } + if (InputArgs.hasArg(OPT_debug)) { + DebugFlag = true; + } + for (auto *Arg : InputArgs.filtered(OPT_debug_only)) { + setCurrentDebugTypes(Arg->getValues().data(), Arg->getNumValues()); + } + if (InputArgs.hasArg(OPT_help)) { std::string Usage = llvm::formatv("{0} [ /options ] file", ProgName).str(); T.printHelp(outs(), Usage.c_str(), "LLVM MASM Assembler", -- 2.7.4