llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Ebuka Ezike (da-viper) <details> <summary>Changes</summary> the ubsan decorator previously assumes the platform is macOS. macOS has an extra underscore in symbols names match two or more. uses the llvm-nm that is built instead of the system's nm. --- Full diff: https://github.com/llvm/llvm-project/pull/177964.diff 4 Files Affected: - (modified) lldb/packages/Python/lldbsuite/test/configuration.py (+12) - (modified) lldb/packages/Python/lldbsuite/test/decorators.py (+10-28) - (modified) lldb/packages/Python/lldbsuite/test/dotest.py (+3) - (modified) lldb/source/Target/InstrumentationRuntimeStopInfo.cpp (+1-2) ``````````diff diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py b/lldb/packages/Python/lldbsuite/test/configuration.py index c2c46b94454a5..f96fd31b17a37 100644 --- a/lldb/packages/Python/lldbsuite/test/configuration.py +++ b/lldb/packages/Python/lldbsuite/test/configuration.py @@ -12,6 +12,7 @@ # Third-party modules +from typing import Optional import unittest # LLDB Modules @@ -61,6 +62,9 @@ # Path to the FileCheck testing tool. Not optional. filecheck = None +# Path to the nm tool. +nm: Optional[str] = None + # Path to the yaml2obj tool. Not optional. yaml2obj = None @@ -171,6 +175,14 @@ def get_filecheck_path(): return filecheck +def get_nm_path(): + """ + Get the path to the nm tool. + """ + if nm and os.path.lexists(nm): + return nm + + def get_yaml2obj_path(): """ Get the path to the yaml2obj tool. diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index ac4a899fbbb8e..6acd2f3979810 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -1046,36 +1046,18 @@ def is_compiler_clang_with_ubsan(): outputf, ): return "Compiler cannot compile with -fsanitize=undefined" + if not outputf.path: + return "Cannot create Temp file path." + + nm_bin = configuration.get_nm_path() + if not nm_bin: + return "No llvm-nm or nm binary." # Check that we actually see ubsan instrumentation in the binary. - cmd = "nm %s" % outputf.path - with os.popen(cmd) as nm_output: - if "___ubsan_handle_divrem_overflow" not in nm_output.read(): - return "Division by zero instrumentation is missing" - - # Find the ubsan dylib. - # FIXME: This check should go away once compiler-rt gains support for __ubsan_on_report. - cmd = ( - "%s -fsanitize=undefined -x c - -o - -### 2>&1" - % lldbplatformutil.getCompiler() - ) - with os.popen(cmd) as cc_output: - driver_jobs = cc_output.read() - m = re.search(r'"([^"]+libclang_rt.ubsan_osx_dynamic.dylib)"', driver_jobs) - if not m: - return "Could not find the ubsan dylib used by the driver" - ubsan_dylib = m.group(1) - - # Check that the ubsan dylib has special monitor hooks. - cmd = "nm -gU %s" % ubsan_dylib - with os.popen(cmd) as nm_output: - syms = nm_output.read() - if "___ubsan_on_report" not in syms: - return "Missing ___ubsan_on_report" - if "___ubsan_get_current_report_data" not in syms: - return "Missing ___ubsan_get_current_report_data" - - # OK, this dylib + compiler works for us. + nm_output = subprocess.check_output([nm_bin, outputf.path], text=True) + if "__ubsan_handle_divrem_overflow" not in nm_output: + return "Division by zero instrumentation is missing" + return None return skipTestIfFn(is_compiler_clang_with_ubsan)(func) diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index 84490d86c7e7f..533be0a065e3a 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -280,6 +280,9 @@ def parseOptionsAndInitTestdirs(): configuration.llvm_tools_dir = args.llvm_tools_dir configuration.filecheck = shutil.which("FileCheck", path=args.llvm_tools_dir) configuration.yaml2obj = shutil.which("yaml2obj", path=args.llvm_tools_dir) + configuration.nm = shutil.which( + "llvm-nm", path=args.llvm_tools_dir + ) or shutil.which("nm", path=args.llvm_tools_dir) if not configuration.get_filecheck_path(): logging.warning("No valid FileCheck executable; some tests may fail...") diff --git a/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp b/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp index aef895def7939..4be6c5119e07b 100644 --- a/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp +++ b/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp @@ -53,8 +53,7 @@ InstrumentationRuntimeStopInfo::GetSuggestedStackFrameIndex( // case we somehow ended up looking at an infinite recursion. constexpr size_t max_stack_depth = 128; - // Start at parent frame. - size_t stack_idx = 1; + size_t stack_idx = 0; StackFrameSP most_relevant_frame_sp = thread_sp->GetStackFrameAtIndex(stack_idx); `````````` </details> https://github.com/llvm/llvm-project/pull/177964 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
