Skip to content

[LLDB][Test] Fix the test case of listing verbose break info on Windows #85200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2024

Conversation

bvlgah
Copy link
Contributor

@bvlgah bvlgah commented Mar 14, 2024

I noticed a failure of running LLDB test suites on Windows AArch64. The failed test case is about
checking output of command breakpoint list -v -L c++, and an mismatch on the demangled
name of a function occurred. The test case expects ns::func(void), but on Windows it is int ns::func(void).
It results from the different mangling scheme used by MSVC, and the comparison is as follows:

Scheme Mangled Demangled (fully) Note
MSVC ?func@ns@@YAHXZ int __cdecl ns::func(void) Godbolt (I have no available Windows device)
Itanium _ZN2ns4funcEv ns::func()

According to the current use of MSVC demangling,

static char *GetMSVCDemangledStr(llvm::StringRef M) {
char *demangled_cstr = llvm::microsoftDemangle(
M, nullptr, nullptr,
llvm::MSDemangleFlags(
llvm::MSDF_NoAccessSpecifier | llvm::MSDF_NoCallingConvention |
llvm::MSDF_NoMemberType | llvm::MSDF_NoVariableType));
if (Log *log = GetLog(LLDBLog::Demangle)) {
if (demangled_cstr && demangled_cstr[0])
LLDB_LOGF(log, "demangled msvc: %s -> \"%s\"", M.data(), demangled_cstr);
else
LLDB_LOGF(log, "demangled msvc: %s -> error", M.data());
}
return demangled_cstr;
}

the __cdecl specifier is not part of the name. However, the function's parameter types should be present
as llvm::MSDF_NoVariableType does not affect a symbol for functions.

Therefore, it is inappropriate to assume the demangled name are the same on all platforms. Instead of tweaking the
existing code of demangling to get the same (demangled) name, I think it is more reasonable to modify the test case.

@bvlgah bvlgah requested a review from JDevlieghere as a code owner March 14, 2024 08:43
@llvmbot llvmbot added the lldb label Mar 14, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 14, 2024

@llvm/pr-subscribers-lldb

Author: None (bvlgah)

Changes

I noticed a failure of running LLDB test suites on Windows AArch64. The failed test case is about
checking output of command breakpoint list -v -L c++, and an mismatch on the demangled
name of a function occurred. The test case expects ns::func(void), but on Windows it is int ns::func(void).
It results from the different mangling scheme used by MSVC, and the comparison is as follows:

Scheme Mangled Demangled (fully) Note
MSVC ?func@<!-- -->ns@@<!-- -->YAHXZ int __cdecl ns::func(void) Godbolt (I have no available Windows device)
Itanium _ZN2ns4funcEv ns::func()

According to the current use of MSVC demangling,

static char *GetMSVCDemangledStr(llvm::StringRef M) {
char *demangled_cstr = llvm::microsoftDemangle(
M, nullptr, nullptr,
llvm::MSDemangleFlags(
llvm::MSDF_NoAccessSpecifier | llvm::MSDF_NoCallingConvention |
llvm::MSDF_NoMemberType | llvm::MSDF_NoVariableType));
if (Log *log = GetLog(LLDBLog::Demangle)) {
if (demangled_cstr && demangled_cstr[0])
LLDB_LOGF(log, "demangled msvc: %s -> \"%s\"", M.data(), demangled_cstr);
else
LLDB_LOGF(log, "demangled msvc: %s -> error", M.data());
}
return demangled_cstr;
}

the __cdecl specifier is not part of the name. However, the function's parameter types should be present
as llvm::MSDF_NoVariableType does not affect a symbol for functions.

Therefore, it is inappropriate to assume the demangled name are the same on all platforms. Instead of tweaking the
existing code of demangling to get the same (demangled) name, I think it is more reasonable to modify the test case.


Full diff: https://github.com/llvm/llvm-project/pull/85200.diff

1 Files Affected:

  • (modified) lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py (+3-1)
diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py b/lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py
index 5179ffe730b9a0..d262b627195bc8 100644
--- a/lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py
+++ b/lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py
@@ -95,8 +95,10 @@ def breakpoint_options_language_test(self):
         self.expect(
             "breakpoint list -v",
             "Verbose breakpoint list contains mangled names",
+            # The demangled function name is system-dependent, e.g.
+            # 'int ns::func(void)' on Windows and 'ns::func()' on Linux.
             substrs=[
-                "function = ns::func",
+                f"function = {function.GetName()}",
                 f"mangled function = {function.GetMangledName()}",
             ],
         )

@DavidSpickett
Copy link
Collaborator

Thanks for the fix! We (Linaro) were about to look into this ourselves.

I'm going to merge this now so we can see if it works ASAP.

@DavidSpickett DavidSpickett merged commit ece2c25 into llvm:main Mar 14, 2024
@bvlgah bvlgah deleted the lldb-fix-break-list branch March 14, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants