From b527ea310bb0e0118e2b1b64fe2c856ea542b7e5 Mon Sep 17 00:00:00 2001 From: Bruno Schmitt Date: Tue, 8 Aug 2023 16:23:42 +0000 Subject: [PATCH] [Support] Closes #532: change backtrace error message --- include/cudaq/Support/Version.h | 20 ++++++++++++++++++++ tools/cudaq-opt/cudaq-opt.cpp | 5 +++++ tools/cudaq-quake/cudaq-quake.cpp | 8 ++++++-- tools/cudaq-translate/cudaq-translate.cpp | 6 ++++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 include/cudaq/Support/Version.h diff --git a/include/cudaq/Support/Version.h b/include/cudaq/Support/Version.h new file mode 100644 index 00000000000..f8eb3d19277 --- /dev/null +++ b/include/cudaq/Support/Version.h @@ -0,0 +1,20 @@ +/****************************************************************-*- C++ -*-**** + * Copyright (c) 2022 - 2023 NVIDIA Corporation & Affiliates. * + * All rights reserved. * + * * + * This source code and the accompanying materials are made available under * + * the terms of the Apache License 2.0 which accompanies this distribution. * + ******************************************************************************/ + +#pragma once + +namespace cudaq { + +// TODO: const char *getVersion(); + +/// A generic bug report message. +constexpr const char *bugReportMsg = + "PLEASE submit a bug report to https://github.com/NVIDIA/cuda-quantum and " + "include the crash backtrace.\n"; + +} // namespace cudaq diff --git a/tools/cudaq-opt/cudaq-opt.cpp b/tools/cudaq-opt/cudaq-opt.cpp index 7286bb46dca..91f3589750b 100644 --- a/tools/cudaq-opt/cudaq-opt.cpp +++ b/tools/cudaq-opt/cudaq-opt.cpp @@ -12,6 +12,7 @@ #include "cudaq/Optimizer/Dialect/Quake/QuakeDialect.h" #include "cudaq/Optimizer/Transforms/Passes.h" #include "cudaq/Support/Plugin.h" +#include "cudaq/Support/Version.h" #include "llvm/Option/Option.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/InitLLVM.h" @@ -50,6 +51,10 @@ static cl::list cl::desc("Load passes from plugin library")); int main(int argc, char **argv) { + // Set the bug report message to indicate users should file issues on + // nvidia/cuda-quantum + llvm::setBugReportMsg(cudaq::bugReportMsg); + mlir::registerAllPasses(); cudaq::opt::registerOptCodeGenPasses(); cudaq::opt::registerOptTransformsPasses(); diff --git a/tools/cudaq-quake/cudaq-quake.cpp b/tools/cudaq-quake/cudaq-quake.cpp index c7187428e0c..e88d4d8c5ad 100644 --- a/tools/cudaq-quake/cudaq-quake.cpp +++ b/tools/cudaq-quake/cudaq-quake.cpp @@ -18,6 +18,7 @@ #include "cudaq/Optimizer/Dialect/CC/CCDialect.h" #include "cudaq/Optimizer/Dialect/Quake/QuakeDialect.h" #include "cudaq/Optimizer/Support/Verifier.h" +#include "cudaq/Support/Version.h" #include "nvqpp_config.h" #include "clang/CodeGen/BackendUtil.h" #include "clang/CodeGen/CodeGenAction.h" @@ -261,9 +262,12 @@ std::string getExecutablePath(const char *argv0, bool canonicalPrefixes) { //===----------------------------------------------------------------------===// int main(int argc, char **argv) { + // Set the bug report message to indicate users should file issues on + // nvidia/cuda-quantum + llvm::setBugReportMsg(cudaq::bugReportMsg); - // First we need the location of this cudaq-quake executable - // so that we can get the install path + // We need the location of this cudaq-quake executable so that we can get the + // install path std::string executablePath = getExecutablePath(argv[0], true); std::filesystem::path cudaqQuakePath{executablePath}; auto installBinPath = cudaqQuakePath.parent_path(); diff --git a/tools/cudaq-translate/cudaq-translate.cpp b/tools/cudaq-translate/cudaq-translate.cpp index a34bb2d5cf1..2279cdaa168 100644 --- a/tools/cudaq-translate/cudaq-translate.cpp +++ b/tools/cudaq-translate/cudaq-translate.cpp @@ -10,6 +10,7 @@ #include "cudaq/Optimizer/Dialect/CC/CCDialect.h" #include "cudaq/Optimizer/Dialect/Quake/QuakeDialect.h" #include "cudaq/Optimizer/Transforms/Passes.h" +#include "cudaq/Support/Version.h" #include "cudaq/Target/IQM/IQMJsonEmitter.h" #include "cudaq/Target/OpenQASM/OpenQASMEmitter.h" #include "cudaq/Todo.h" @@ -17,6 +18,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/ToolOutputFile.h" @@ -115,6 +117,10 @@ static void checkErrorCode(const std::error_code &ec) { } int main(int argc, char **argv) { + // Set the bug report message to indicate users should file issues on + // nvidia/cuda-quantum + llvm::setBugReportMsg(cudaq::bugReportMsg); + registerAsmPrinterCLOptions(); registerMLIRContextCLOptions(); registerPassManagerCLOptions();