Index: source/Core/Mangled.cpp =================================================================== --- source/Core/Mangled.cpp +++ source/Core/Mangled.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// +#include // FreeBSD9-STABLE requires this to know about size_t in cxxabi.h #include #if defined(_MSC_VER) @@ -4995,6 +4996,32 @@ using namespace lldb_private; +#if defined(_MSC_VER) +static void +insert_spaces_after_commas (char *s, std::size_t max) +{ + assert(max > 0); + const std::size_t length = strlen(s); + const int comma_count = std::count(s, s + length, ','); + if (comma_count > 0 && length + comma_count < max - 1) + { + // Start at the end and work backwards until the target location catches + // up to the source location. (We already know that everything from the + // beginning of the string to that point is identical.) + const char *source = s + length; + char *target = s + length + comma_count; + while (target > source) + { + if (*source == ',') + { + *target-- = ' '; + } + *target-- = *source--; + } + } +} +#endif + static inline bool cstring_is_mangled (const char *s) { @@ -5231,11 +5258,14 @@ if (!demangled_name) demangled_name = __cxa_demangle (mangled_cstr, NULL, NULL, NULL); #elif defined(_MSC_VER) - char *demangled_name = (char *)::malloc(1024); - ::ZeroMemory(demangled_name, 1024); - DWORD result = ::UnDecorateSymbolName(mangled_cstr, demangled_name, 1023, + const std::size_t demangled_buffer_size = 1024; + char *demangled_name = (char *)::malloc(demangled_buffer_size); + ::ZeroMemory(demangled_name, demangled_buffer_size); + DWORD result = ::UnDecorateSymbolName(mangled_cstr, demangled_name, + demangled_buffer_size - 1, UNDNAME_NO_ACCESS_SPECIFIERS | // Strip public, private, protected keywords UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall, etc keywords + UNDNAME_NO_FUNCTION_RETURNS | // Strip function return types UNDNAME_NO_THROW_SIGNATURES | // Strip throw() specifications UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc specifiers UNDNAME_NO_MS_KEYWORDS // Strip all MS extension keywords @@ -5245,6 +5275,14 @@ free (demangled_name); demangled_name = nullptr; } + else + { + // UnDecorateSymbolName doesn't put spaces after commas, but + // the built-in demangler does, so add them for consistency. + // Besides, our tests expect them. + insert_spaces_after_commas(demangled_name, demangled_buffer_size); + } + #else char *demangled_name = abi::__cxa_demangle (mangled_cstr, NULL, NULL, NULL); #endif Index: test/functionalities/abbreviation/TestAbbreviations.py =================================================================== --- test/functionalities/abbreviation/TestAbbreviations.py +++ test/functionalities/abbreviation/TestAbbreviations.py @@ -148,19 +148,14 @@ "at main.cpp\:25", "stop reason = breakpoint 2.1" ]) - # ARCH, if not specified, defaults to x86_64. - self.runCmd("dis -f") + # Recognizing output as disassembly in an architecture-independent way + # is tricky. Since we're just trying to verify that `dis -f` does the + # same things as `disassemble -f`, we'll run both commands and compare + # the output. This doesn't validate anything about the disassembly + # itself; there are other tests for that. + self.runCmd("disassemble -f") disassembly = self.res.GetOutput() - if self.getArchitecture() in ["", 'x86_64', 'i386']: - # hey! we shouldn't have a software breakpoint in here - self.assertFalse("int3" in disassembly) - self.expect(disassembly, exe=False, - startstr = "a.out`sum(int, int)", - substrs = [' mov', - ' addl ', - 'ret']) - else: - self.fail('unimplemented for arch = "{arch}"'.format(arch=self.getArchitecture())) + self.expect("dis -f", startstr = disassembly) self.expect("i d l main.cpp", patterns = ["Line table for .*main.cpp in `a.out"]) Index: test/make/Makefile.rules =================================================================== --- test/make/Makefile.rules +++ test/make/Makefile.rules @@ -30,8 +30,22 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)../../ #---------------------------------------------------------------------- -# If ARCH is not defined, default to x86_64. # If OS is not defined, use 'uname -s' to determine the OS name. +# +# uname on Windows gives "windows32", but most environments standardize +# on "Windows_NT", so we'll make it consistent here. When running +# tests from Visual Studio, the environment variable isn't inherited +# all the way down to the process spawned for make. +#---------------------------------------------------------------------- +ifeq "$(OS)" "" + OS = $(shell uname -s) +endif +ifeq "$(OS)" "windows32" + OS = Windows_NT +endif + +#---------------------------------------------------------------------- +# If ARCH is not defined, default to x86_64. #---------------------------------------------------------------------- ifeq "$(ARCH)" "" ifeq "$(OS)" "Windows_NT" @@ -41,10 +55,6 @@ endif endif -ifeq "$(OS)" "" - OS = $(shell uname -s) -endif - #---------------------------------------------------------------------- # CC defaults to clang. #