[Lldb-commits] [PATCH] D138892: [DataFormatter] Fix variant npos with `_LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION` enabled.
labath accepted this revision. labath added inline comments. This revision is now accepted and ready to land. Comment at: lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp:74 + case 1: +return static_cast(-1); + case 2: I'd probably use fixed with types (uint8_t et al.) here. Comment at: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp:32 std::variant v_no_value; +std::variant< +int, int, int, int, int, int, int, int, int, int, int, int, int, int, Maybe just add a quick note that the number 300 was chosen because it does not fit into a single byte. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138892/new/ https://reviews.llvm.org/D138892 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D138430: [lldb/test] Use SBPlatform info for lldbplatformutil.getPlatform()
This revision was automatically updated to reflect the committed changes. Closed by commit rG6335deb68b1d: [lldb/test] Use SBPlatform info for lldbplatformutil.getPlatform() (authored by labath). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138430/new/ https://reviews.llvm.org/D138430 Files: lldb/packages/Python/lldbsuite/test/dotest.py lldb/packages/Python/lldbsuite/test/lldbplatformutil.py Index: lldb/packages/Python/lldbsuite/test/lldbplatformutil.py === --- lldb/packages/Python/lldbsuite/test/lldbplatformutil.py +++ lldb/packages/Python/lldbsuite/test/lldbplatformutil.py @@ -98,21 +98,23 @@ return dictionary +def _get_platform_os(p): +# Use the triple to determine the platform if set. +triple = p.GetTriple() +if triple: +platform = triple.split('-')[2] +if platform.startswith('freebsd'): +platform = 'freebsd' +elif platform.startswith('netbsd'): +platform = 'netbsd' +return platform + +return '' + + def getHostPlatform(): """Returns the host platform running the test suite.""" -# Attempts to return a platform name matching a target Triple platform. -if sys.platform.startswith('linux'): -return 'linux' -elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'): -return 'windows' -elif sys.platform.startswith('darwin'): -return 'macosx' -elif sys.platform.startswith('freebsd'): -return 'freebsd' -elif sys.platform.startswith('netbsd'): -return 'netbsd' -else: -return sys.platform +return _get_platform_os(lldb.SBPlatform("host")) def getDarwinOSTriples(): @@ -130,16 +132,7 @@ platform = 'ios' return platform -platform = configuration.lldb_platform_name -if platform is None: -platform = "host" -if platform == "qemu-user": -platform = "host" -if platform == "host": -return getHostPlatform() -if platform.startswith("remote-"): -return platform[7:] -return platform +return _get_platform_os(lldb.selected_platform) def platformIsDarwin(): Index: lldb/packages/Python/lldbsuite/test/dotest.py === --- lldb/packages/Python/lldbsuite/test/dotest.py +++ lldb/packages/Python/lldbsuite/test/dotest.py @@ -849,14 +849,14 @@ skip_msg = "Skipping %s tests, as they are not compatible with remote testing on this platform" if lldbplatformutil.platformIsDarwin(): configuration.skip_categories.append("llgs") -if configuration.lldb_platform_name: +if lldb.remote_platform: # configuration.skip_categories.append("debugserver") if configuration.verbose: print(skip_msg%"debugserver"); else: configuration.skip_categories.append("debugserver") -if configuration.lldb_platform_name and lldbplatformutil.getPlatform() == "windows": +if lldb.remote_platform and lldbplatformutil.getPlatform() == "windows": configuration.skip_categories.append("llgs") if configuration.verbose: print(skip_msg%"lldb-server"); @@ -891,14 +891,6 @@ lldb.SBDebugger.Initialize() lldb.SBDebugger.PrintStackTraceOnError() -checkLibcxxSupport() -checkLibstdcxxSupport() -checkWatchpointSupport() -checkDebugInfoSupport() -checkDebugServerSupport() -checkObjcSupport() -checkForkVForkSupport() - # Use host platform by default. lldb.remote_platform = None lldb.selected_platform = lldb.SBPlatform.GetHostPlatform() @@ -957,8 +949,16 @@ # Note that it's not dotest's job to clean this directory. lldbutil.mkdir_p(configuration.test_build_dir) +checkLibcxxSupport() +checkLibstdcxxSupport() +checkWatchpointSupport() +checkDebugInfoSupport() +checkDebugServerSupport() +checkObjcSupport() +checkForkVForkSupport() + skipped_categories_list = ", ".join(configuration.skip_categories) -print("Skipping the following test categories: {}".format(skipped_categories_list)) +print("Skipping the following test categories: {}".format(configuration.skip_categories)) for testdir in configuration.testdirs: for (dirpath, dirnames, filenames) in os.walk(testdir): ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 6335deb - [lldb/test] Use SBPlatform info for lldbplatformutil.getPlatform()
Author: Pavel Labath Date: 2022-11-29T11:29:58+01:00 New Revision: 6335deb68b1dd417da4dff4f36fc344d8656e81a URL: https://github.com/llvm/llvm-project/commit/6335deb68b1dd417da4dff4f36fc344d8656e81a DIFF: https://github.com/llvm/llvm-project/commit/6335deb68b1dd417da4dff4f36fc344d8656e81a.diff LOG: [lldb/test] Use SBPlatform info for lldbplatformutil.getPlatform() Previously, we just used the platform name. This worked mostly OK, but it required adding special handling for any unusual (and potentially downstream) platform plugins, as evidenced by the hardcoding of the qemu-user platform. The current implementation was added in D121605/21c5bb0a636c23ec75b13681c0a6fdb03ecd9c0d, which this essentially reverts and goes back to the previous method of retrieving the platform name from the platform triple (the "OS" field). The motivation for D121605 was the ability to retrieve the process without constructing an SBDebugger object (which would be necessary in a world where SBPlatforms are managed by SBDebuggers). However, this world did not arrive (mainly due to other commitments on my part), and I now think that if we do want to go in that direction, that we should just create a dummy/empty SBDebugger object for holding the initial SBPlatform. One benefit of D121605 was the unification of getPlatform and getHostPlatform code paths, and I preserve that benefit by unifying them in the other direction -- using the host SBPlatform for getHostPlatform. Differential Revision: https://reviews.llvm.org/D138430 Added: Modified: lldb/packages/Python/lldbsuite/test/dotest.py lldb/packages/Python/lldbsuite/test/lldbplatformutil.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index 818e8f618afa7..db7a3450ffc4d 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -849,14 +849,14 @@ def checkDebugServerSupport(): skip_msg = "Skipping %s tests, as they are not compatible with remote testing on this platform" if lldbplatformutil.platformIsDarwin(): configuration.skip_categories.append("llgs") -if configuration.lldb_platform_name: +if lldb.remote_platform: # configuration.skip_categories.append("debugserver") if configuration.verbose: print(skip_msg%"debugserver"); else: configuration.skip_categories.append("debugserver") -if configuration.lldb_platform_name and lldbplatformutil.getPlatform() == "windows": +if lldb.remote_platform and lldbplatformutil.getPlatform() == "windows": configuration.skip_categories.append("llgs") if configuration.verbose: print(skip_msg%"lldb-server"); @@ -891,14 +891,6 @@ def run_suite(): lldb.SBDebugger.Initialize() lldb.SBDebugger.PrintStackTraceOnError() -checkLibcxxSupport() -checkLibstdcxxSupport() -checkWatchpointSupport() -checkDebugInfoSupport() -checkDebugServerSupport() -checkObjcSupport() -checkForkVForkSupport() - # Use host platform by default. lldb.remote_platform = None lldb.selected_platform = lldb.SBPlatform.GetHostPlatform() @@ -957,8 +949,16 @@ def run_suite(): # Note that it's not dotest's job to clean this directory. lldbutil.mkdir_p(configuration.test_build_dir) +checkLibcxxSupport() +checkLibstdcxxSupport() +checkWatchpointSupport() +checkDebugInfoSupport() +checkDebugServerSupport() +checkObjcSupport() +checkForkVForkSupport() + skipped_categories_list = ", ".join(configuration.skip_categories) -print("Skipping the following test categories: {}".format(skipped_categories_list)) +print("Skipping the following test categories: {}".format(configuration.skip_categories)) for testdir in configuration.testdirs: for (dirpath, dirnames, filenames) in os.walk(testdir): diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py index 3f95e8054f789..56d402418d457 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py @@ -98,21 +98,23 @@ def finalize_build_dictionary(dictionary): return dictionary +def _get_platform_os(p): +# Use the triple to determine the platform if set. +triple = p.GetTriple() +if triple: +platform = triple.split('-')[2] +if platform.startswith('freebsd'): +platform = 'freebsd' +elif platform.startswith('netbsd'): +platform = 'netbsd' +return platform + +return '' + + def getHostPlatform(): """Returns the host platform running the test suite.""" -# Attempts to return a platform name matching a target Tri
[Lldb-commits] [PATCH] D138892: [DataFormatter] Fix variant npos with `_LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION` enabled.
rupprecht updated this revision to Diff 478507. rupprecht added a comment. - Add comment about choice of 300 types - Use fixed-width types Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138892/new/ https://reviews.llvm.org/D138892 Files: lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp @@ -29,6 +29,34 @@ std::variant v3; std::variant> v_v1 ; std::variant v_no_value; +// The next variant has 300 types, meaning the type index does not fit in +// a byte and must be `unsigned short` instead of `unsigned char` when +// using the unstable libc++ ABI. With stable libc++ ABI, the type index +// is always just `unsigned int`. +std::variant< +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int, int, int, int, int, int, int, int, int, +int, int, int, int, int, int> +v_300_types_no_value; v1 = 12; // v contains int v_v1 = v1 ; @@ -54,6 +82,13 @@ } catch( ... ) {} printf( "%zu\n", v_no_value.index() ) ; + + try { + v_300_types_no_value.emplace<0>(S()); + } catch (...) { + } + + printf("%zu\n", v_300_types_no_value.index()); #endif return 0; // break here Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py @@ -76,3 +76,6 @@ self.expect("frame variable v_no_value", substrs=['v_no_value = No Value']) + +self.expect("frame variable v_300_types_no_value", +substrs=['v_300_types_no_value = No Value']) Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp === --- lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp +++ lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp @@ -9,6 +9,8 @@ #include "LibCxxVariant.h" #include "LibCxx.h" #include "lldb/DataFormatters/FormattersHelpers.h" +#include "lldb/Symbol/CompilerType.h" +#include "lldb/Utility/LLDBAssert.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/ScopeExit.h" @@ -66,6 +68,19 @@ // 3) NPos, its value is variant_npos which means the variant has no value enum class LibcxxVariantIndexValidity { Valid, Invalid, NPos }; +uint64_t VariantNposValue(uint64_t index_byte_size) { + switch (index_byte_size) { + case 1: +return static_cast(-1); + case 2: +return static_cast(-1); + case 4: +return static_cast(-1); + } + lldbassert(false && "Unknown index type size"); + return static_cast(-1); // Fallbac
[Lldb-commits] [PATCH] D138310: [NFC] Make headers self-contained.
rupprecht marked an inline comment as done. rupprecht added inline comments. Comment at: lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h:15 -#include "EmulateInstructionRISCV.h" #include "llvm/ADT/Optional.h" MaskRay wrote: > I assume that this is correct, even after considering IWYU. Perhaps worth a > double check. Thanks, I double checked: the only top-level type exported by `EmulateInstructionRISCV.h` is `class EmulateInstructionRISCV`. That's forward-declared in this file (line 20 on the base side), and only ever referred to by reference, so a forward declare is fully sufficient for that. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138310/new/ https://reviews.llvm.org/D138310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] cd02e78 - [NFC] Make headers self-contained.
Author: Jordan Rupprecht Date: 2022-11-29T04:14:55-08:00 New Revision: cd02e78cd5cdfa079f2a82f34fea25bee1ae02da URL: https://github.com/llvm/llvm-project/commit/cd02e78cd5cdfa079f2a82f34fea25bee1ae02da DIFF: https://github.com/llvm/llvm-project/commit/cd02e78cd5cdfa079f2a82f34fea25bee1ae02da.diff LOG: [NFC] Make headers self-contained. Some headers in LLDB work only when considered as textual inclusion, but not if one attempts to use them on their own or with a different context. - python-typemaps.h: uses Python definitions without using "Python.h". - RISCVCInstructions.h uses RISC-V register enums without including the enums header. - RISCVInstructions.h includes EmulateInstructionRISCV.h, but is unnecessary since we forward-declare EmulateInstructionRISCV anyway. Including the header is problematic because EmulateInstructionRISCV.h uses DecodeResult which isn't defined until later in RISCVInstructions.h. This makes LLDB build cleanly with the "parse_headers" feature [1]. I'm not sure what the analagous CMake option is. [1] I didn't find public documentation but @MaskRay wrote this up: https://maskray.me/blog/2022-09-25-layering-check-with-clang#parse_headers Reviewed By: labath, MaskRay Differential Revision: https://reviews.llvm.org/D138310 Added: Modified: lldb/bindings/python/python-typemaps.h lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h Removed: diff --git a/lldb/bindings/python/python-typemaps.h b/lldb/bindings/python/python-typemaps.h index b45352ad62952..8a533e822988e 100644 --- a/lldb/bindings/python/python-typemaps.h +++ b/lldb/bindings/python/python-typemaps.h @@ -1,6 +1,8 @@ #ifndef LLDB_BINDINGS_PYTHON_PYTHON_TYPEMAPS_H #define LLDB_BINDINGS_PYTHON_PYTHON_TYPEMAPS_H +#include + // Defined here instead of a .swig file because SWIG 2 doesn't support // explicit deleted functions. struct Py_buffer_RAII { diff --git a/lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h b/lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h index 1f113167311ad..c48eae457a9df 100644 --- a/lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h +++ b/lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h @@ -12,6 +12,7 @@ #include #include +#include "Plugins/Process/Utility/lldb-riscv-register-enums.h" #include "RISCVInstructions.h" #include "llvm/ADT/Optional.h" diff --git a/lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h b/lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h index 0b406a1fa10ee..3aca675ee6370 100644 --- a/lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h +++ b/lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h @@ -12,7 +12,6 @@ #include #include -#include "EmulateInstructionRISCV.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/Optional.h" ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D138310: [NFC] Make headers self-contained.
This revision was automatically updated to reflect the committed changes. rupprecht marked an inline comment as done. Closed by commit rGcd02e78cd5cd: [NFC] Make headers self-contained. (authored by rupprecht). Changed prior to commit: https://reviews.llvm.org/D138310?vs=476502&id=478515#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138310/new/ https://reviews.llvm.org/D138310 Files: lldb/bindings/python/python-typemaps.h lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h Index: lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h === --- lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h +++ lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h @@ -12,7 +12,6 @@ #include #include -#include "EmulateInstructionRISCV.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/Optional.h" Index: lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h === --- lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h +++ lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h @@ -12,6 +12,7 @@ #include #include +#include "Plugins/Process/Utility/lldb-riscv-register-enums.h" #include "RISCVInstructions.h" #include "llvm/ADT/Optional.h" Index: lldb/bindings/python/python-typemaps.h === --- lldb/bindings/python/python-typemaps.h +++ lldb/bindings/python/python-typemaps.h @@ -1,6 +1,8 @@ #ifndef LLDB_BINDINGS_PYTHON_PYTHON_TYPEMAPS_H #define LLDB_BINDINGS_PYTHON_PYTHON_TYPEMAPS_H +#include + // Defined here instead of a .swig file because SWIG 2 doesn't support // explicit deleted functions. struct Py_buffer_RAII { Index: lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h === --- lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h +++ lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h @@ -12,7 +12,6 @@ #include #include -#include "EmulateInstructionRISCV.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/Optional.h" Index: lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h === --- lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h +++ lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h @@ -12,6 +12,7 @@ #include #include +#include "Plugins/Process/Utility/lldb-riscv-register-enums.h" #include "RISCVInstructions.h" #include "llvm/ADT/Optional.h" Index: lldb/bindings/python/python-typemaps.h === --- lldb/bindings/python/python-typemaps.h +++ lldb/bindings/python/python-typemaps.h @@ -1,6 +1,8 @@ #ifndef LLDB_BINDINGS_PYTHON_PYTHON_TYPEMAPS_H #define LLDB_BINDINGS_PYTHON_PYTHON_TYPEMAPS_H +#include + // Defined here instead of a .swig file because SWIG 2 doesn't support // explicit deleted functions. struct Py_buffer_RAII { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3c10e9c - [test] Implement layout for unstable std::string garbage formatter tests.
Author: Jordan Rupprecht Date: 2022-11-29T04:22:30-08:00 New Revision: 3c10e9c77332ad0472d8641a62b8faf76deef0bf URL: https://github.com/llvm/llvm-project/commit/3c10e9c77332ad0472d8641a62b8faf76deef0bf DIFF: https://github.com/llvm/llvm-project/commit/3c10e9c77332ad0472d8641a62b8faf76deef0bf.diff LOG: [test] Implement layout for unstable std::string garbage formatter tests. The layout is essentially just reversed from the stable std::string layout. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D138850 Added: Modified: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp Removed: diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp index f88afc1f3a8e8..02c55487c41d2 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp @@ -7,12 +7,19 @@ // A corrupt string which hits the SSO code path, but has an invalid size. static struct { +#if _LIBCPP_ABI_VERSION == 1 // Set the size of this short-mode string to 116. Note that in short mode, // the size is encoded as `size << 1`. unsigned char size = 232; // 23 garbage bytes for the inline string payload. char inline_buf[23] = {0}; +#else // _LIBCPP_ABI_VERSION == 1 + // Like above, but data comes first, and use bitfields to indicate size. + char inline_buf[23] = {0}; + unsigned char size : 7 = 116; + unsigned char is_long : 1 = 0; +#endif // #if _LIBCPP_ABI_VERSION == 1 } garbage_string_short_mode; // A corrupt libcxx string in long mode with a payload that contains a utf8 @@ -23,9 +30,16 @@ static unsigned char garbage_utf8_payload1[] = { 250, 250, 250 }; static struct { +#if _LIBCPP_ABI_VERSION == 1 uint64_t cap = 5; uint64_t size = 4; unsigned char *data = &garbage_utf8_payload1[0]; +#else // _LIBCPP_ABI_VERSION == 1 + unsigned char *data = &garbage_utf8_payload1[0]; + uint64_t size = 4; + uint64_t cap : 63 = 4; + uint64_t is_long : 1 = 1; +#endif // #if _LIBCPP_ABI_VERSION == 1 } garbage_string_long_mode1; // A corrupt libcxx string in long mode with a payload that contains a utf8 @@ -36,25 +50,46 @@ static unsigned char garbage_utf8_payload2[] = { 240 }; static struct { +#if _LIBCPP_ABI_VERSION == 1 uint64_t cap = 3; uint64_t size = 2; unsigned char *data = &garbage_utf8_payload2[0]; +#else // _LIBCPP_ABI_VERSION == 1 + unsigned char *data = &garbage_utf8_payload2[0]; + uint64_t size = 2; + uint64_t cap : 63 = 3; + uint64_t is_long : 1 = 1; +#endif // #if _LIBCPP_ABI_VERSION == 1 } garbage_string_long_mode2; // A corrupt libcxx string which has an invalid size (i.e. a size greater than // the capacity of the string). static struct { +#if _LIBCPP_ABI_VERSION == 1 uint64_t cap = 5; uint64_t size = 7; const char *data = "foo"; +#else // _LIBCPP_ABI_VERSION == 1 + const char *data = "foo"; + uint64_t size = 7; + uint64_t cap : 63 = 5; + uint64_t is_long : 1 = 1; +#endif // #if _LIBCPP_ABI_VERSION == 1 } garbage_string_long_mode3; // A corrupt libcxx string in long mode with a payload that would trigger a // buffer overflow. static struct { +#if _LIBCPP_ABI_VERSION == 1 uint64_t cap = 5; uint64_t size = 2; uint64_t data = 0xfffeULL; +#else // _LIBCPP_ABI_VERSION == 1 + uint64_t data = 0xfffeULL; + uint64_t size = 2; + uint64_t cap : 63 = 5; + uint64_t is_long : 1 = 1; +#endif // #if _LIBCPP_ABI_VERSION == 1 } garbage_string_long_mode4; size_t touch_string(std::string &in_str) @@ -81,7 +116,6 @@ int main() std::basic_string uchar(5, 'a'); std::string *null_str = nullptr; -#if _LIBCPP_ABI_VERSION == 1 std::string garbage1, garbage2, garbage3, garbage4, garbage5; if (sizeof(std::string) == sizeof(garbage_string_short_mode)) memcpy((void *)&garbage1, &garbage_string_short_mode, sizeof(std::string)); @@ -93,9 +127,6 @@ int main() memcpy((void *)&garbage4, &garbage_string_long_mode3, sizeof(std::string)); if (sizeof(std::string) == sizeof(garbage_string_long_mode4)) memcpy((void *)&garbage5, &garbage_string_long_mode4, sizeof(std::string)); -#else -#error "Test potentially needs to be updated for a new std::string ABI." -#endif S.assign(L"!"); // Set break point at this line. std::string *not_a_string = (std::string *) 0x0; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D138850: [test] Implement layout for unstable std::string garbage formatter tests.
This revision was automatically updated to reflect the committed changes. Closed by commit rG3c10e9c77332: [test] Implement layout for unstable std::string garbage formatter tests. (authored by rupprecht). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138850/new/ https://reviews.llvm.org/D138850 Files: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp @@ -7,12 +7,19 @@ // A corrupt string which hits the SSO code path, but has an invalid size. static struct { +#if _LIBCPP_ABI_VERSION == 1 // Set the size of this short-mode string to 116. Note that in short mode, // the size is encoded as `size << 1`. unsigned char size = 232; // 23 garbage bytes for the inline string payload. char inline_buf[23] = {0}; +#else // _LIBCPP_ABI_VERSION == 1 + // Like above, but data comes first, and use bitfields to indicate size. + char inline_buf[23] = {0}; + unsigned char size : 7 = 116; + unsigned char is_long : 1 = 0; +#endif // #if _LIBCPP_ABI_VERSION == 1 } garbage_string_short_mode; // A corrupt libcxx string in long mode with a payload that contains a utf8 @@ -23,9 +30,16 @@ 250, 250, 250 }; static struct { +#if _LIBCPP_ABI_VERSION == 1 uint64_t cap = 5; uint64_t size = 4; unsigned char *data = &garbage_utf8_payload1[0]; +#else // _LIBCPP_ABI_VERSION == 1 + unsigned char *data = &garbage_utf8_payload1[0]; + uint64_t size = 4; + uint64_t cap : 63 = 4; + uint64_t is_long : 1 = 1; +#endif // #if _LIBCPP_ABI_VERSION == 1 } garbage_string_long_mode1; // A corrupt libcxx string in long mode with a payload that contains a utf8 @@ -36,25 +50,46 @@ 240 }; static struct { +#if _LIBCPP_ABI_VERSION == 1 uint64_t cap = 3; uint64_t size = 2; unsigned char *data = &garbage_utf8_payload2[0]; +#else // _LIBCPP_ABI_VERSION == 1 + unsigned char *data = &garbage_utf8_payload2[0]; + uint64_t size = 2; + uint64_t cap : 63 = 3; + uint64_t is_long : 1 = 1; +#endif // #if _LIBCPP_ABI_VERSION == 1 } garbage_string_long_mode2; // A corrupt libcxx string which has an invalid size (i.e. a size greater than // the capacity of the string). static struct { +#if _LIBCPP_ABI_VERSION == 1 uint64_t cap = 5; uint64_t size = 7; const char *data = "foo"; +#else // _LIBCPP_ABI_VERSION == 1 + const char *data = "foo"; + uint64_t size = 7; + uint64_t cap : 63 = 5; + uint64_t is_long : 1 = 1; +#endif // #if _LIBCPP_ABI_VERSION == 1 } garbage_string_long_mode3; // A corrupt libcxx string in long mode with a payload that would trigger a // buffer overflow. static struct { +#if _LIBCPP_ABI_VERSION == 1 uint64_t cap = 5; uint64_t size = 2; uint64_t data = 0xfffeULL; +#else // _LIBCPP_ABI_VERSION == 1 + uint64_t data = 0xfffeULL; + uint64_t size = 2; + uint64_t cap : 63 = 5; + uint64_t is_long : 1 = 1; +#endif // #if _LIBCPP_ABI_VERSION == 1 } garbage_string_long_mode4; size_t touch_string(std::string &in_str) @@ -81,7 +116,6 @@ std::basic_string uchar(5, 'a'); std::string *null_str = nullptr; -#if _LIBCPP_ABI_VERSION == 1 std::string garbage1, garbage2, garbage3, garbage4, garbage5; if (sizeof(std::string) == sizeof(garbage_string_short_mode)) memcpy((void *)&garbage1, &garbage_string_short_mode, sizeof(std::string)); @@ -93,9 +127,6 @@ memcpy((void *)&garbage4, &garbage_string_long_mode3, sizeof(std::string)); if (sizeof(std::string) == sizeof(garbage_string_long_mode4)) memcpy((void *)&garbage5, &garbage_string_long_mode4, sizeof(std::string)); -#else -#error "Test potentially needs to be updated for a new std::string ABI." -#endif S.assign(L"!"); // Set break point at this line. std::string *not_a_string = (std::string *) 0x0; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7d26f9e - [test] Allow libc++ namespaces besides `__1`
Author: Jordan Rupprecht Date: 2022-11-29T04:34:40-08:00 New Revision: 7d26f9e1329f981ed43eb31f66891702de2f6470 URL: https://github.com/llvm/llvm-project/commit/7d26f9e1329f981ed43eb31f66891702de2f6470 DIFF: https://github.com/llvm/llvm-project/commit/7d26f9e1329f981ed43eb31f66891702de2f6470.diff LOG: [test] Allow libc++ namespaces besides `__1` The libc++ data formatter for `std::shared_ptr` allows any namespace, but the test asserts that it must be the default `__1` namespace. Relax the regex to allow anything that looks like `__.*` (although we use `__[^:]*` so we don't match arbitrarily long text). Reviewed By: labath Differential Revision: https://reviews.llvm.org/D129898 Added: Modified: lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py Removed: diff --git a/lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py index 943aa5b777252..6adf016727cc8 100644 --- a/lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py @@ -37,4 +37,4 @@ def test(self): # Both `std::vector` and the type of the member have forward # declarations before their definitions. self.expect("expr --raw -- v", -substrs=['(std::__1::vector) $0 = {', 'f = nullptr', '}']) +patterns=[r'\(std::__[^:]*::vector\) \$0 = {', 'f = nullptr', '}']) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py index 663058e07653c..c646fccc2f5eb 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py @@ -68,7 +68,7 @@ def test_shared_ptr_variables(self): valobj = self.expect_var_path("sp_user", type="std::shared_ptr") self.assertRegex( valobj.summary, -"^std(::__1)?::shared_ptr::element_type @ 0x0*[1-9a-f][0-9a-f]+( strong=1)? weak=1", +"^std(::__[^:]*)?::shared_ptr::element_type @ 0x0*[1-9a-f][0-9a-f]+( strong=1)? weak=1", ) self.assertNotEqual(valobj.child[0].unsigned, 0) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D129898: [test] Allow libc++ namespaces besides `__1`
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG7d26f9e1329f: [test] Allow libc++ namespaces besides `__1` (authored by rupprecht). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D129898/new/ https://reviews.llvm.org/D129898 Files: lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py @@ -68,7 +68,7 @@ valobj = self.expect_var_path("sp_user", type="std::shared_ptr") self.assertRegex( valobj.summary, -"^std(::__1)?::shared_ptr::element_type @ 0x0*[1-9a-f][0-9a-f]+( strong=1)? weak=1", +"^std(::__[^:]*)?::shared_ptr::element_type @ 0x0*[1-9a-f][0-9a-f]+( strong=1)? weak=1", ) self.assertNotEqual(valobj.child[0].unsigned, 0) Index: lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py === --- lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py @@ -37,4 +37,4 @@ # Both `std::vector` and the type of the member have forward # declarations before their definitions. self.expect("expr --raw -- v", -substrs=['(std::__1::vector) $0 = {', 'f = nullptr', '}']) +patterns=[r'\(std::__[^:]*::vector\) \$0 = {', 'f = nullptr', '}']) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py @@ -68,7 +68,7 @@ valobj = self.expect_var_path("sp_user", type="std::shared_ptr") self.assertRegex( valobj.summary, -"^std(::__1)?::shared_ptr::element_type @ 0x0*[1-9a-f][0-9a-f]+( strong=1)? weak=1", +"^std(::__[^:]*)?::shared_ptr::element_type @ 0x0*[1-9a-f][0-9a-f]+( strong=1)? weak=1", ) self.assertNotEqual(valobj.child[0].unsigned, 0) Index: lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py === --- lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py @@ -37,4 +37,4 @@ # Both `std::vector` and the type of the member have forward # declarations before their definitions. self.expect("expr --raw -- v", -substrs=['(std::__1::vector) $0 = {', 'f = nullptr', '}']) +patterns=[r'\(std::__[^:]*::vector\) \$0 = {', 'f = nullptr', '}']) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b3c978e - [lldb] Make SWIG an auto-detected dependency
Author: Jonas Devlieghere Date: 2022-11-29T09:07:11-08:00 New Revision: b3c978e850d374438697f8b79b5e28ab51310068 URL: https://github.com/llvm/llvm-project/commit/b3c978e850d374438697f8b79b5e28ab51310068 DIFF: https://github.com/llvm/llvm-project/commit/b3c978e850d374438697f8b79b5e28ab51310068.diff LOG: [lldb] Make SWIG an auto-detected dependency This patch makes SWIG itself an auto-detected dependency. This allows us to look for SWIG once in a centralized place and makes it easier downstream to detect whether to use the static bindings. Differential revision: https://reviews.llvm.org/D138879 Added: Modified: lldb/cmake/modules/FindLuaAndSwig.cmake lldb/cmake/modules/FindPythonAndSwig.cmake lldb/cmake/modules/LLDBConfig.cmake Removed: diff --git a/lldb/cmake/modules/FindLuaAndSwig.cmake b/lldb/cmake/modules/FindLuaAndSwig.cmake index 982616169a05e..dd51ea1ef4c18 100644 --- a/lldb/cmake/modules/FindLuaAndSwig.cmake +++ b/lldb/cmake/modules/FindLuaAndSwig.cmake @@ -7,8 +7,7 @@ if(LUA_LIBRARIES AND LUA_INCLUDE_DIR AND SWIG_EXECUTABLE) set(LUAANDSWIG_FOUND TRUE) else() - find_package(SWIG 3.0) - if (SWIG_FOUND) + if (LLDB_ENABLE_SWIG) find_package(Lua 5.3 EXACT) if(LUA_FOUND AND SWIG_FOUND) mark_as_advanced( @@ -20,6 +19,7 @@ else() message(STATUS "SWIG 3 or later is required for Lua support in LLDB but could not be found") endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(LuaAndSwig FOUND_VAR @@ -27,5 +27,5 @@ else() REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR - SWIG_EXECUTABLE) + LLDB_ENABLE_SWIG) endif() diff --git a/lldb/cmake/modules/FindPythonAndSwig.cmake b/lldb/cmake/modules/FindPythonAndSwig.cmake index 3535b548c45f2..1b7e1657e364b 100644 --- a/lldb/cmake/modules/FindPythonAndSwig.cmake +++ b/lldb/cmake/modules/FindPythonAndSwig.cmake @@ -38,9 +38,8 @@ endmacro() if(Python3_LIBRARIES AND Python3_INCLUDE_DIRS AND Python3_EXECUTABLE AND SWIG_EXECUTABLE) set(PYTHONANDSWIG_FOUND TRUE) else() - find_package(SWIG 3.0) - if (SWIG_FOUND) - FindPython3() + if (LLDB_ENABLE_SWIG) +FindPython3() else() message(STATUS "SWIG 3 or later is required for Python support in LLDB but could not be found") endif() @@ -64,5 +63,5 @@ else() Python3_LIBRARIES Python3_INCLUDE_DIRS Python3_EXECUTABLE - SWIG_EXECUTABLE) + LLDB_ENABLE_SWIG) endif() diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index 1079e4b2def17..f3f1103d244f6 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -56,6 +56,7 @@ macro(add_optional_dependency variable description package found) message(STATUS "${description}: ${${variable}}") endmacro() +add_optional_dependency(LLDB_ENABLE_SWIG "Enable SWIG to generate LLDB bindings" SWIG SWIG_FOUND VERSION 3) add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support in LLDB" LibEdit LibEdit_FOUND) add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" CursesAndPanel CURSESANDPANEL_FOUND) add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in LLDB" LibLZMA LIBLZMA_FOUND) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D138879: [lldb] Make SWIG an autodetected depenency
This revision was automatically updated to reflect the committed changes. Closed by commit rGb3c978e850d3: [lldb] Make SWIG an auto-detected dependency (authored by JDevlieghere). Herald added a project: LLDB. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138879/new/ https://reviews.llvm.org/D138879 Files: lldb/cmake/modules/FindLuaAndSwig.cmake lldb/cmake/modules/FindPythonAndSwig.cmake lldb/cmake/modules/LLDBConfig.cmake Index: lldb/cmake/modules/LLDBConfig.cmake === --- lldb/cmake/modules/LLDBConfig.cmake +++ lldb/cmake/modules/LLDBConfig.cmake @@ -56,6 +56,7 @@ message(STATUS "${description}: ${${variable}}") endmacro() +add_optional_dependency(LLDB_ENABLE_SWIG "Enable SWIG to generate LLDB bindings" SWIG SWIG_FOUND VERSION 3) add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support in LLDB" LibEdit LibEdit_FOUND) add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" CursesAndPanel CURSESANDPANEL_FOUND) add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in LLDB" LibLZMA LIBLZMA_FOUND) Index: lldb/cmake/modules/FindPythonAndSwig.cmake === --- lldb/cmake/modules/FindPythonAndSwig.cmake +++ lldb/cmake/modules/FindPythonAndSwig.cmake @@ -38,9 +38,8 @@ if(Python3_LIBRARIES AND Python3_INCLUDE_DIRS AND Python3_EXECUTABLE AND SWIG_EXECUTABLE) set(PYTHONANDSWIG_FOUND TRUE) else() - find_package(SWIG 3.0) - if (SWIG_FOUND) - FindPython3() + if (LLDB_ENABLE_SWIG) +FindPython3() else() message(STATUS "SWIG 3 or later is required for Python support in LLDB but could not be found") endif() @@ -64,5 +63,5 @@ Python3_LIBRARIES Python3_INCLUDE_DIRS Python3_EXECUTABLE - SWIG_EXECUTABLE) + LLDB_ENABLE_SWIG) endif() Index: lldb/cmake/modules/FindLuaAndSwig.cmake === --- lldb/cmake/modules/FindLuaAndSwig.cmake +++ lldb/cmake/modules/FindLuaAndSwig.cmake @@ -7,8 +7,7 @@ if(LUA_LIBRARIES AND LUA_INCLUDE_DIR AND SWIG_EXECUTABLE) set(LUAANDSWIG_FOUND TRUE) else() - find_package(SWIG 3.0) - if (SWIG_FOUND) + if (LLDB_ENABLE_SWIG) find_package(Lua 5.3 EXACT) if(LUA_FOUND AND SWIG_FOUND) mark_as_advanced( @@ -20,6 +19,7 @@ message(STATUS "SWIG 3 or later is required for Lua support in LLDB but could not be found") endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(LuaAndSwig FOUND_VAR @@ -27,5 +27,5 @@ REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR - SWIG_EXECUTABLE) + LLDB_ENABLE_SWIG) endif() Index: lldb/cmake/modules/LLDBConfig.cmake === --- lldb/cmake/modules/LLDBConfig.cmake +++ lldb/cmake/modules/LLDBConfig.cmake @@ -56,6 +56,7 @@ message(STATUS "${description}: ${${variable}}") endmacro() +add_optional_dependency(LLDB_ENABLE_SWIG "Enable SWIG to generate LLDB bindings" SWIG SWIG_FOUND VERSION 3) add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support in LLDB" LibEdit LibEdit_FOUND) add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" CursesAndPanel CURSESANDPANEL_FOUND) add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in LLDB" LibLZMA LIBLZMA_FOUND) Index: lldb/cmake/modules/FindPythonAndSwig.cmake === --- lldb/cmake/modules/FindPythonAndSwig.cmake +++ lldb/cmake/modules/FindPythonAndSwig.cmake @@ -38,9 +38,8 @@ if(Python3_LIBRARIES AND Python3_INCLUDE_DIRS AND Python3_EXECUTABLE AND SWIG_EXECUTABLE) set(PYTHONANDSWIG_FOUND TRUE) else() - find_package(SWIG 3.0) - if (SWIG_FOUND) - FindPython3() + if (LLDB_ENABLE_SWIG) +FindPython3() else() message(STATUS "SWIG 3 or later is required for Python support in LLDB but could not be found") endif() @@ -64,5 +63,5 @@ Python3_LIBRARIES Python3_INCLUDE_DIRS Python3_EXECUTABLE - SWIG_EXECUTABLE) + LLDB_ENABLE_SWIG) endif() Index: lldb/cmake/modules/FindLuaAndSwig.cmake === --- lldb/cmake/modules/FindLuaAndSwig.cmake +++ lldb/cmake/modules/FindLuaAndSwig.cmake @@ -7,8 +7,7 @@ if(LUA_LI
[Lldb-commits] [PATCH] D138724: [lldb][Target] Flush the scratch TypeSystem when process gets deleted
kastiglione added inline comments. Comment at: lldb/source/Target/Target.cpp:208 +// of the debugee. +m_scratch_type_system_map.Clear(); m_process_sp.reset(); Do we have some place in the life-cycle where we can perform this only if the target has changed? Ideally this would happen when the binary has a different timestamp, or for mach-o a different UUID. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138724/new/ https://reviews.llvm.org/D138724 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D131858: [clang] Track the templated entity in type substitution.
arphaman added a comment. Herald added a reviewer: njames93. Hi @mizvekov. This change has caused a failure in Clang's stage 2 CI on the green dragon Darwin CI: https://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/6390/console. Assertion failed: (lvaluePath->getType() == elemTy && "Unexpected type reference!"), function readAPValue, file /Users/buildslave/jenkins/workspace/clang-stage1-RA/clang-build/tools/clang/include/clang/AST/AbstractBasicReader.inc, line 736. Assertion failed: (BlockScope.empty() && CurAbbrevs.empty() && "Block imbalance"), function ~BitstreamWriter, file /Users/buildslave/jenkins/workspace/clang-stage1-RA/llvm-project/llvm/include/llvm/Bitstream/BitstreamWriter.h, line 119. Full log is here - https://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/6390/console. This happens when a Release+Asserts stage 1 clang is building stage 2 clang when Clang modules are enabled. You should be able to reproduce this by building Release+Asserts clang, and then using it to build clang again with the LLVM_ENABLE_MODULES cmake option. Could you please look into this as soon as you can? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D131858/new/ https://reviews.llvm.org/D131858 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D138939: [WIP][clang] adds a way to provide user-oriented reasons
cjdb created this revision. cjdb added reviewers: aaron.ballman, erichkeane, shafik. Herald added subscribers: carlosgalvezp, kadircet, arphaman. Herald added a reviewer: njames93. Herald added projects: Flang, All. cjdb requested review of this revision. Herald added subscribers: cfe-commits, libcxx-commits, lldb-commits, jdoerfert. Herald added projects: clang, LLDB, libc++abi, clang-tools-extra. Herald added a reviewer: libc++abi. Part of the [revised diagnostic model][1] is to provide users with diagnostics that explain what's going wrong from their perspective, as opposed to from the compiler's perspective. This may be achieved through a rewording of the reason, or by provididng more info, or both. This commit also changes the diagnostic for an explicit template parameter gone wrong to demonstrate how it works. NOTE: this is a work-in-progress. Most of the work has been fleshed out, but the note needs to be provided with the kind of template argument it is given. I'm looking into doing this, but it seems to require a lot of tedious manual changes, and I'd prefer to get input on the changes that are currently in the diff before making those extra changes (which will distract from the current stuff, and may ultimately be unnecessary if the current direction is undesirable). [1]: https://discourse.llvm.org/t/rfc-improving-clang-s-diagnostics/62584 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D138939 Files: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tools-extra/clangd/Compiler.cpp clang-tools-extra/clangd/Diagnostics.cpp clang/include/clang/Basic/Diagnostic.h clang/include/clang/Basic/Diagnostic.td clang/include/clang/Basic/DiagnosticAST.h clang/include/clang/Basic/DiagnosticAnalysis.h clang/include/clang/Basic/DiagnosticComment.h clang/include/clang/Basic/DiagnosticCrossTU.h clang/include/clang/Basic/DiagnosticDriver.h clang/include/clang/Basic/DiagnosticFrontend.h clang/include/clang/Basic/DiagnosticIDs.h clang/include/clang/Basic/DiagnosticLex.h clang/include/clang/Basic/DiagnosticParse.h clang/include/clang/Basic/DiagnosticRefactoring.h clang/include/clang/Basic/DiagnosticSema.h clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Basic/DiagnosticSerialization.h clang/include/clang/Basic/PartialDiagnostic.h clang/include/clang/Frontend/ASTUnit.h clang/include/clang/Frontend/DiagnosticRenderer.h clang/lib/Basic/Diagnostic.cpp clang/lib/Basic/DiagnosticIDs.cpp clang/lib/Format/TokenAnalyzer.cpp clang/lib/Frontend/ASTUnit.cpp clang/lib/Frontend/LogDiagnosticPrinter.cpp clang/lib/Frontend/SARIFDiagnosticPrinter.cpp clang/lib/Frontend/SerializedDiagnosticPrinter.cpp clang/lib/Frontend/TextDiagnosticBuffer.cpp clang/lib/Frontend/TextDiagnosticPrinter.cpp clang/lib/Sema/SemaOverload.cpp clang/test/Frontend/sarif-reason.cpp clang/test/TableGen/DiagnosticBase.inc clang/test/TableGen/deferred-diag.td clang/tools/clang-format/ClangFormat.cpp clang/tools/clang-import-test/clang-import-test.cpp clang/tools/diagtool/DiagnosticNames.cpp clang/unittests/Driver/SimpleDiagnosticConsumer.h clang/unittests/Driver/ToolChainTest.cpp clang/unittests/Frontend/FrontendActionTest.cpp clang/unittests/Tooling/RewriterTestContext.h clang/utils/TableGen/ClangDiagnosticsEmitter.cpp flang/lib/Frontend/TextDiagnosticBuffer.cpp flang/lib/Frontend/TextDiagnosticPrinter.cpp libcxxabi/test/test_demangle.pass.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp === --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -697,7 +697,8 @@ const clang::Diagnostic &info) override { if (m_log) { llvm::SmallVector diag_str(10); - info.FormatDiagnostic(diag_str); + info.FormatSummary(diag_str); + info.FormatLegacyReason(diag_str); diag_str.push_back('\0'); LLDB_LOGF(m_log, "Compiler diagnostic: %s\n", diag_str.data()); } Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp === --- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -192,7 +192,8 @@ Log *log = GetLog(LLDBLog::Expressions); if (log) { llvm::SmallVector diag_str; -Info.FormatDiagnostic(diag_str); +Info.FormatSummary(diag_str); +Info.FormatLegacyReason(diag_str); diag_str.push_back('\0'); const char *plain_diag = diag_str.data(); LLDB_LOG(log, "Received diagnostic outside parsing: {0}", plain_diag); Index: flang/lib/Frontend/TextDiagnost
[Lldb-commits] [lldb] 185d496 - [lldb] Introduce dwim-print command
Author: Dave Lee Date: 2022-11-29T12:46:20-08:00 New Revision: 185d4964a1584cedc3385adb4d6ed863c71f6515 URL: https://github.com/llvm/llvm-project/commit/185d4964a1584cedc3385adb4d6ed863c71f6515 DIFF: https://github.com/llvm/llvm-project/commit/185d4964a1584cedc3385adb4d6ed863c71f6515.diff LOG: [lldb] Introduce dwim-print command Implements `dwim-print`, a printing command that chooses the most direct, efficient, and resilient means of printing a given expression. DWIM is an acronym for Do What I Mean. From Wikipedia, DWIM is described as: > attempt to anticipate what users intend to do, correcting trivial errors > automatically rather than blindly executing users' explicit but > potentially incorrect input The `dwim-print` command serves as a single print command for users who don't yet know, or prefer not to know, the various lldb commands that can be used to print, and when to use them. This initial implementation is the base foundation for `dwim-print`. It accepts no flags, only an expression. If the expression is the name of a variable in the frame, then effectively `frame variable` is used to get, and print, its value. Otherwise, printing falls back to using `expression` evaluation. In this initial version, frame variable paths will be handled with `expression`. Following this, there are a number of improvements that can be made. Some improvements include supporting `frame variable` expressions or registers. To provide transparency, especially as the `dwim-print` command evolves, a new setting is also introduced: `dwim-print-verbosity`. This setting instructs `dwim-print` to optionally print a message showing the effective command being run. For example `dwim-print var.meth()` can print a message such as: "note: ran `expression var.meth()`". See https://discourse.llvm.org/t/dwim-print-command/66078 for the proposal and discussion. Differential Revision: https://reviews.llvm.org/D138315 Added: lldb/source/Commands/CommandObjectDWIMPrint.cpp lldb/source/Commands/CommandObjectDWIMPrint.h lldb/test/API/commands/dwim-print/Makefile lldb/test/API/commands/dwim-print/TestDWIMPrint.py lldb/test/API/commands/dwim-print/main.c Modified: lldb/include/lldb/Core/Debugger.h lldb/include/lldb/lldb-enumerations.h lldb/source/Commands/CMakeLists.txt lldb/source/Core/CoreProperties.td lldb/source/Core/Debugger.cpp lldb/source/Interpreter/CommandInterpreter.cpp Removed: diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 041d1fd86473..c1394c1d0ebd 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -348,6 +348,8 @@ class Debugger : public std::enable_shared_from_this, bool SetTabSize(uint32_t tab_size); + lldb::DWIMPrintVerbosity GetDWIMPrintVerbosity() const; + bool GetEscapeNonPrintables() const; bool GetNotifyVoid() const; diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index a5bd557112b3..c46ef4bf3616 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -1203,6 +1203,16 @@ enum TraceCursorSeekType { eTraceCursorSeekTypeEnd }; +/// Enum to control the verbosity level of `dwim-print` execution. +enum DWIMPrintVerbosity { + /// Run `dwim-print` with no verbosity. + eDWIMPrintVerbosityNone, + /// Print a message when `dwim-print` uses `expression` evaluation. + eDWIMPrintVerbosityExpression, + /// Always print a message indicating how `dwim-print` is evaluating its + /// expression. + eDWIMPrintVerbosityFull, +}; } // namespace lldb diff --git a/lldb/source/Commands/CMakeLists.txt b/lldb/source/Commands/CMakeLists.txt index 0b705ade5ea8..bec6a9c1bc44 100644 --- a/lldb/source/Commands/CMakeLists.txt +++ b/lldb/source/Commands/CMakeLists.txt @@ -10,6 +10,7 @@ add_lldb_library(lldbCommands CommandObjectCommands.cpp CommandObjectDiagnostics.cpp CommandObjectDisassemble.cpp + CommandObjectDWIMPrint.cpp CommandObjectExpression.cpp CommandObjectFrame.cpp CommandObjectGUI.cpp diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp new file mode 100644 index ..232e877f53d7 --- /dev/null +++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp @@ -0,0 +1,84 @@ +//===-- CommandObjectDWIMPrint.cpp --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "CommandObjectDWIMPrint.h" + +#include "lldb/Core/ValueObject.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/Comma
[Lldb-commits] [PATCH] D138315: [lldb] Introduce dwim-print command
This revision was automatically updated to reflect the committed changes. Closed by commit rG185d4964a158: [lldb] Introduce dwim-print command (authored by kastiglione). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138315/new/ https://reviews.llvm.org/D138315 Files: lldb/include/lldb/Core/Debugger.h lldb/include/lldb/lldb-enumerations.h lldb/source/Commands/CMakeLists.txt lldb/source/Commands/CommandObjectDWIMPrint.cpp lldb/source/Commands/CommandObjectDWIMPrint.h lldb/source/Core/CoreProperties.td lldb/source/Core/Debugger.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/test/API/commands/dwim-print/Makefile lldb/test/API/commands/dwim-print/TestDWIMPrint.py lldb/test/API/commands/dwim-print/main.c Index: lldb/test/API/commands/dwim-print/main.c === --- /dev/null +++ lldb/test/API/commands/dwim-print/main.c @@ -0,0 +1,3 @@ +int main(int argc, char **argv) { + return 0; +} Index: lldb/test/API/commands/dwim-print/TestDWIMPrint.py === --- /dev/null +++ lldb/test/API/commands/dwim-print/TestDWIMPrint.py @@ -0,0 +1,68 @@ +""" +Test dwim-print with variables, variable paths, and expressions. +""" + +import re +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil + + +class TestCase(TestBase): +def setUp(self): +TestBase.setUp(self) +self.build() +lldbutil.run_to_name_breakpoint(self, "main") + +def _run_cmd(self, cmd: str) -> str: +"""Run the given lldb command and return its output.""" +result = lldb.SBCommandReturnObject() +self.ci.HandleCommand(cmd, result) +return result.GetOutput().rstrip() + +PERSISTENT_VAR = re.compile(r"\$\d+") + +def _mask_persistent_var(self, string: str) -> str: +""" +Replace persistent result variables (ex '$0', '$1', etc) with a regex +that matches any persistent result (r'\$\d+'). The returned string can +be matched against other `expression` results. +""" +before, after = self.PERSISTENT_VAR.split(string, maxsplit=1) +return re.escape(before) + r"\$\d+" + re.escape(after) + +def _expect_cmd(self, expr: str, base_cmd: str) -> None: +"""Run dwim-print and verify the output against the expected command.""" +cmd = f"{base_cmd} {expr}" +cmd_output = self._run_cmd(cmd) + +# Verify dwim-print chose the expected command. +self.runCmd("settings set dwim-print-verbosity full") +substrs = [f"note: ran `{cmd}`"] +patterns = [] + +if base_cmd == "expression --" and self.PERSISTENT_VAR.search(cmd_output): +patterns.append(self._mask_persistent_var(cmd_output)) +else: +substrs.append(cmd_output) + +self.expect(f"dwim-print {expr}", substrs=substrs, patterns=patterns) + +def test_variables(self): +"""Test dwim-print with variables.""" +vars = ("argc", "argv") +for var in vars: +self._expect_cmd(var, "frame variable") + +def test_variable_paths(self): +"""Test dwim-print with variable path expressions.""" +exprs = ("&argc", "*argv", "argv[0]") +for expr in exprs: +self._expect_cmd(expr, "expression --") + +def test_expressions(self): +"""Test dwim-print with expressions.""" +exprs = ("argc + 1", "(void)argc", "(int)abs(argc)") +for expr in exprs: +self._expect_cmd(expr, "expression --") Index: lldb/test/API/commands/dwim-print/Makefile === --- /dev/null +++ lldb/test/API/commands/dwim-print/Makefile @@ -0,0 +1,3 @@ +C_SOURCES := main.c + +include Makefile.rules Index: lldb/source/Interpreter/CommandInterpreter.cpp === --- lldb/source/Interpreter/CommandInterpreter.cpp +++ lldb/source/Interpreter/CommandInterpreter.cpp @@ -15,6 +15,7 @@ #include "Commands/CommandObjectApropos.h" #include "Commands/CommandObjectBreakpoint.h" #include "Commands/CommandObjectCommands.h" +#include "Commands/CommandObjectDWIMPrint.h" #include "Commands/CommandObjectDiagnostics.h" #include "Commands/CommandObjectDisassemble.h" #include "Commands/CommandObjectExpression.h" @@ -532,6 +533,7 @@ REGISTER_COMMAND_OBJECT("command", CommandObjectMultiwordCommands); REGISTER_COMMAND_OBJECT("diagnostics", CommandObjectDiagnostics); REGISTER_COMMAND_OBJECT("disassemble", CommandObjectDisassemble); + REGISTER_COMMAND_OBJECT("dwim-print", CommandObjectDWIMPrint); REGISTER_COMMAND_OBJECT("expression", CommandObjectExpression); REGISTER_COMMAND_OBJECT("frame", CommandObjectMultiwordFrame); REGISTER_COMMAND_OBJECT("gui", CommandObjectGUI); Index:
[Lldb-commits] [PATCH] D138939: [WIP][clang] adds a way to provide user-oriented reasons
erichkeane added a comment. Herald added subscribers: Michael137, JDevlieghere. A few comments. I don't mind the approach, though I find myself wondering if the "FormatDiagnostic" call should stay the same, and choose the legacy-reason only when a sarif reason doesn't exist? Or for some level of command line control? The clang-side interface to this seems a touch clunky, and I fear it'll make continuing its use/generalizing its use less likely. Comment at: clang/include/clang/Basic/DiagnosticIDs.h:165 +struct DiagnosticReason { + std::string Legacy; + std::string SARIF; "Reason" is a part of the diagnostic itself, pre-rendered, right? Since these strings are literals, can this be an llvm::StringLiteral instead? (the constexpr-stringref type)? Else, generating these is going to cost us at startup time. Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:4520 + DiagReason< +/*Legacy:*/"invalid explicitly-specified argument for template parameter %0", +/*SARIF:*/"we passed a %select{type|value|class template}1 as our %ordinal2 " Already kidna hate this format here. Is there any way we could make this be something more like: `DiagReason, SARIF<"whatever">>` ? Comment at: clang/lib/Format/TokenAnalyzer.cpp:47 llvm::SmallVector Message; - Info.FormatDiagnostic(Message); + Info.FormatSummary(Message); + Info.FormatLegacyReason(Message); This pair of calls has happened ~20 times by the time I've scrolled here. Can we do a single call here of some sort instead? Comment at: clang/test/Frontend/sarif-reason.cpp:15 +void g() { + f1<0>(); // expected-error{{no matching function for call to 'f1'}} + f1(); // expected-error{{no matching function for call to 'f1'}} This is definitely a case where I'd love the diagnostics formatted/arranged differently here. If you can use the #BOOKMARK style to make sure errors and notes are together, it would better illustrate what you're trying to do here. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138939/new/ https://reviews.llvm.org/D138939 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D138939: [WIP][clang] adds a way to provide user-oriented reasons
cjdb added a comment. I don't understand why `test_demangle.pass.cpp` was considered too big to upload. Here's the diff: diff --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp index dce8e6c3..9da6fb7d2ad9 100644 --- a/libcxxabi/test/test_demangle.pass.cpp +++ b/libcxxabi/test/test_demangle.pass.cpp @@ -11451,7 +11451,9 @@ const char* cases[][2] = {"_ZN5clang16DiagnosticClientD1Ev", "clang::DiagnosticClient::~DiagnosticClient()"}, {"_ZN5clang16DiagnosticClientD2Ev", "clang::DiagnosticClient::~DiagnosticClient()"}, {"_ZN5clang16DiagnosticClient16HandleDiagnosticENS_10Diagnostic5LevelERKNS_14DiagnosticInfoE", "clang::DiagnosticClient::HandleDiagnostic(clang::Diagnostic::Level, clang::DiagnosticInfo const&)"}, - {"_ZNK5clang14DiagnosticInfo16FormatDiagnosticERN4llvm15SmallVectorImplIcEE", "clang::DiagnosticInfo::FormatDiagnostic(llvm::SmallVectorImpl&) const"}, + {"_ZNK5clang14DiagnosticInfo13FormatSummaryERN4llvm15SmallVectorImplIcEE", "clang::DiagnosticInfo::FormatSummary(llvm::SmallVectorImpl&) const"}, + {"_ZNK5clang14DiagnosticInfo18FormatLegacyReasonERN4llvm15SmallVectorImplIcEE", "clang::DiagnosticInfo::FormatLegacyReason(llvm::SmallVectorImpl&) const"}, + {"_ZNK5clang14DiagnosticInfo17FormatSARIFReasonERN4llvm15SmallVectorImplIcEE", "clang::DiagnosticInfo::FormatSARIFReason(llvm::SmallVectorImpl&) const"}, {"_ZNK5clang14DiagnosticInfo16FormatDiagnosticEPKcS2_RN4llvm15SmallVectorImplIcEE", "clang::DiagnosticInfo::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl&) const"}, {"_Z10ScanFormatPKcS0_c", "ScanFormat(char const*, char const*, char)"}, {"_Z20HandlePluralModifierRKN5clang14DiagnosticInfoEjPKcjRN4llvm15SmallVectorImplIcEE", "HandlePluralModifier(clang::DiagnosticInfo const&, unsigned int, char const*, unsigned int, llvm::SmallVectorImpl&)"}, Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138939/new/ https://reviews.llvm.org/D138939 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D138939: [WIP][clang] adds a way to provide user-oriented reasons
cjdb added a comment. > The clang-side interface to this seems a touch clunky, and I fear it'll make > continuing its use/generalizing its use less likely. Is this w.r.t. the `FormatDiagnostic` being split up, or is it something else? If it's the former: I'll be changing that to `FormatLegacyDiagnostic`, which //almost// gets us back to where we started. Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:4520 + DiagReason< +/*Legacy:*/"invalid explicitly-specified argument for template parameter %0", +/*SARIF:*/"we passed a %select{type|value|class template}1 as our %ordinal2 " erichkeane wrote: > Already kidna hate this format here. Is there any way we could make this be > something more like: > > `DiagReason, SARIF<"whatever">>` ? I like this suggestion. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138939/new/ https://reviews.llvm.org/D138939 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D137900: Make only one function that needs to be implemented when searching for types.
aprantl added a comment. I think the ` void FindTypes(const TypeQuery &query, TypeResults &results);` API looks like a reasonable compromise. I have a bunch of smaller questions inside, but otherwise I think this can work. Comment at: lldb/include/lldb/Core/Module.h:435 + /// match: "b::a", "c::b::a", "d::b::a", "e::f::b::a". + lldb::TypeSP FindFirstType(ConstString type_name, bool exact_match); Why is this not taking a TypeQuery that wraps a name? Comment at: lldb/include/lldb/Core/Module.h:442 /// - /// \param searched_symbol_files - /// Prevents one file from being visited multiple times. - void - FindTypes(llvm::ArrayRef pattern, LanguageSet languages, -llvm::DenseSet &searched_symbol_files, -TypeMap &types); - - lldb::TypeSP FindFirstType(const SymbolContext &sc, ConstString type_name, - bool exact_match); - - /// Find types by name that are in a namespace. This function is used by the - /// expression parser when searches need to happen in an exact namespace - /// scope. + /// \param[in] search_first + /// If non-null, this module will be searched before any other copy&paste error? Comment at: lldb/include/lldb/Core/ModuleList.h:350 /// - /// \param[in] name - /// The name of the type we are looking for. - /// - /// \param[in] max_matches - /// Allow the number of matches to be limited to \a - /// max_matches. Specify UINT32_MAX to get all possible matches. - /// - /// \param[out] types - /// A type list gets populated with any matches. + /// \param[inout] match + /// A type matching object that contains all of the details of the type needs update now Comment at: lldb/include/lldb/Core/ModuleList.h:373 + /// match: "b::a", "c::b::a", "d::b::a", "e::f::b::a". + lldb::TypeSP FindFirstType(Module *search_first, ConstString type_name, + bool exact_match) const; same question — why is this not a TypeQuery? Comment at: lldb/include/lldb/Symbol/CompilerDecl.h:90 + /// \param context A valid vector of CompilerContext entries that describes + /// this delcaratiion context. The first entry in the vector is the parent of + /// the subsequent entry, so the top most entry is the global namespace. declaration Comment at: lldb/include/lldb/Symbol/CompilerDecl.h:93 + void GetCompilerContext( + llvm::SmallVectorImpl &context) const; + aprantl wrote: > Why can't this be a return value? The context objects are tiny. ping? Comment at: lldb/include/lldb/Symbol/Type.h:85 + /// doing name lookups. + TypeQuery() = default; + Can we get rid of this now? Comment at: lldb/include/lldb/Symbol/Type.h:231 + /// Add a language family to the list of languages that should produce a match. + void AddLanguage(lldb::LanguageType language); + Would you mind sorting this closer to the constructors, so it doesn't appear in the middle of the list of functions that FindTypes implementation would use? we could even wrap the setup / match functions in a doxygen group /// \{ /// \} Comment at: lldb/include/lldb/Symbol/Type.h:275 + /// Clients can use this to populate the context manually. + llvm::SmallVector &GetContextRef() { return m_context; } + Could this return an `ArrayRef`? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D137900/new/ https://reviews.llvm.org/D137900 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D138939: [WIP][clang] adds a way to provide user-oriented reasons
cjdb added a comment. > though I find myself wondering if the "FormatDiagnostic" call should stay the > same, and choose the legacy-reason only when a sarif reason doesn't exist? Or > for some level of command line control? Hmm... isn't this the point of the diagnostic consumers? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138939/new/ https://reviews.llvm.org/D138939 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D138558: [lldb][DataFormatter] Add std::ranges::ref_view formatter
aprantl accepted this revision. aprantl added a comment. This revision is now accepted and ready to land. Small nitpicks, otherwise good! Comment at: lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp:41 +private: + lldb::ValueObjectSP m_range_sp = nullptr; ///< Pointer to the dereferenced +///< __range_ member Personally I prefer ``` ///Pointer to the dereferenced __range_ member. lldb::ValueObjectSP m_range_sp = nullptr; ``` for longer comments. Comment at: lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp:55 + return 1; +} + I wonder if it would be more readable to move those one-line function definitions into the declaration? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138558/new/ https://reviews.llvm.org/D138558 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D138724: [lldb][Target] Flush the scratch TypeSystem when process gets deleted
aprantl added inline comments. Comment at: lldb/source/Target/Target.cpp:207 +// E.g., this could happen on rebuild & relaunch +// of the debugee. +m_scratch_type_system_map.Clear(); Not opposed to this, but this is leaking an implementation detail of TypeSystemClang into Target. Just out of curiosity — would if be feasible to use weak_ptr in DeclOrigin or is that defined inside of Clang and can't be changed? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138724/new/ https://reviews.llvm.org/D138724 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D138960: [lldb] Enable use of dummy target from dwim-print
kastiglione created this revision. kastiglione added reviewers: jingham, labath. Herald added a project: All. kastiglione requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Allow `dwim-print` to evaluate expressions using the dummy target if no real target exists. This adds some parity to `expression`. With this, both of the following work: lldb -o 'expr 1+2' lldb -o 'dwim-print 1+2' Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D138960 Files: lldb/source/Commands/CommandObjectDWIMPrint.cpp lldb/test/API/commands/dwim-print/TestDWIMPrint.py Index: lldb/test/API/commands/dwim-print/TestDWIMPrint.py === --- lldb/test/API/commands/dwim-print/TestDWIMPrint.py +++ lldb/test/API/commands/dwim-print/TestDWIMPrint.py @@ -10,11 +10,6 @@ class TestCase(TestBase): -def setUp(self): -TestBase.setUp(self) -self.build() -lldbutil.run_to_name_breakpoint(self, "main") - def _run_cmd(self, cmd: str) -> str: """Run the given lldb command and return its output.""" result = lldb.SBCommandReturnObject() @@ -51,18 +46,28 @@ def test_variables(self): """Test dwim-print with variables.""" +self.build() +lldbutil.run_to_name_breakpoint(self, "main") vars = ("argc", "argv") for var in vars: self._expect_cmd(var, "frame variable") def test_variable_paths(self): """Test dwim-print with variable path expressions.""" +self.build() +lldbutil.run_to_name_breakpoint(self, "main") exprs = ("&argc", "*argv", "argv[0]") for expr in exprs: self._expect_cmd(expr, "expression --") def test_expressions(self): """Test dwim-print with expressions.""" +self.build() +lldbutil.run_to_name_breakpoint(self, "main") exprs = ("argc + 1", "(void)argc", "(int)abs(argc)") for expr in exprs: self._expect_cmd(expr, "expression --") + +def test_dummy_target_expressions(self): +# Run with no target. +self._expect_cmd("1 + 2", "expression --") Index: lldb/source/Commands/CommandObjectDWIMPrint.cpp === --- lldb/source/Commands/CommandObjectDWIMPrint.cpp +++ lldb/source/Commands/CommandObjectDWIMPrint.cpp @@ -22,12 +22,11 @@ using namespace lldb_private; CommandObjectDWIMPrint::CommandObjectDWIMPrint(CommandInterpreter &interpreter) -: CommandObjectRaw( - interpreter, "dwim-print", "Print a variable or expression.", - "dwim-print [ | ]", - eCommandProcessMustBePaused | eCommandTryTargetAPILock | - eCommandRequiresFrame | eCommandProcessMustBeLaunched | - eCommandRequiresProcess) {} +: CommandObjectRaw(interpreter, "dwim-print", + "Print a variable or expression.", + "dwim-print [ | ]", + eCommandProcessMustBePaused | eCommandTryTargetAPILock) { +} bool CommandObjectDWIMPrint::DoExecute(StringRef expr, CommandReturnObject &result) { @@ -40,14 +39,10 @@ return false; } - // eCommandRequiresFrame guarantees a frame. - StackFrame *frame = m_exe_ctx.GetFramePtr(); - assert(frame); - auto verbosity = GetDebugger().GetDWIMPrintVerbosity(); - // First, try `expr` as the name of a variable. - { + // First, try `expr` as the name of a frame variable. + if (StackFrame *frame = m_exe_ctx.GetFramePtr()) { auto valobj_sp = frame->FindVariable(ConstString(expr)); if (valobj_sp && valobj_sp->GetError().Success()) { if (verbosity == eDWIMPrintVerbosityFull) @@ -60,12 +55,13 @@ // Second, also lastly, try `expr` as a source expression to evaluate. { -// eCommandRequiresProcess guarantees a target. -Target *target = m_exe_ctx.GetTargetPtr(); -assert(target); +Target *target_ptr = m_exe_ctx.GetTargetPtr(); +// Fallback to the dummy target, which can allow for expression evaluation. +Target &target = target_ptr ? *target_ptr : GetDummyTarget(); +auto *exe_scope = m_exe_ctx.GetBestExecutionContextScope(); ValueObjectSP valobj_sp; -if (target->EvaluateExpression(expr, frame, valobj_sp) == +if (target.EvaluateExpression(expr, exe_scope, valobj_sp) == eExpressionCompleted) { if (verbosity != eDWIMPrintVerbosityNone) result.AppendMessageWithFormatv("note: ran `expression -- {0}`", expr); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D138060: Improve error logging when xcrun fails to execute successfully
aprantl updated this revision to Diff 478762. aprantl added a comment. Herald added a subscriber: fedor.sergeev. Don't introduce a Host->Core dependency. Cache the errors and remove Progress reports (since they also depend on Core). CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138060/new/ https://reviews.llvm.org/D138060 Files: lldb/include/lldb/Host/HostInfoBase.h lldb/include/lldb/Host/macosx/HostInfoMacOSX.h lldb/source/Core/Module.cpp lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp lldb/unittests/Host/CMakeLists.txt lldb/unittests/Host/HostInfoTest.cpp Index: lldb/unittests/Host/HostInfoTest.cpp === --- lldb/unittests/Host/HostInfoTest.cpp +++ lldb/unittests/Host/HostInfoTest.cpp @@ -56,11 +56,21 @@ #if defined(__APPLE__) TEST_F(HostInfoTest, GetXcodeSDK) { - EXPECT_FALSE(HostInfo::GetXcodeSDKPath(XcodeSDK("MacOSX.sdk")).empty()); + auto get_sdk = [](std::string sdk, bool error = false) -> llvm::StringRef { +auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(XcodeSDK(std::move(sdk))); +if (!error) { + EXPECT_TRUE((bool)sdk_path_or_err); + return *sdk_path_or_err; +} +EXPECT_FALSE((bool)sdk_path_or_err); +llvm::consumeError(sdk_path_or_err.takeError()); +return {}; + }; + EXPECT_FALSE(get_sdk("MacOSX.sdk").empty()); // These are expected to fall back to an available version. - EXPECT_FALSE(HostInfo::GetXcodeSDKPath(XcodeSDK("MacOSX.sdk")).empty()); + EXPECT_FALSE(get_sdk("MacOSX.sdk").empty()); // This is expected to fail. - EXPECT_TRUE(HostInfo::GetXcodeSDKPath(XcodeSDK("CeciNestPasUnOS.sdk")).empty()); + EXPECT_TRUE(get_sdk("CeciNestPasUnOS.sdk", true).empty()); } #endif Index: lldb/unittests/Host/CMakeLists.txt === --- lldb/unittests/Host/CMakeLists.txt +++ lldb/unittests/Host/CMakeLists.txt @@ -32,6 +32,7 @@ ${FILES} LINK_LIBS lldbHost +lldbCore lldbUtilityHelpers lldbHostHelpers LLVMTestingSupport Index: lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp === --- lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -17,6 +17,7 @@ #include "PlatformRemoteAppleWatch.h" #endif #include "lldb/Breakpoint/BreakpointLocation.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" @@ -123,8 +124,14 @@ } // Use the default SDK as a fallback. - FileSpec fspec( - HostInfo::GetXcodeSDKPath(lldb_private::XcodeSDK::GetAnyMacOS())); + auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(XcodeSDK::GetAnyMacOS()); + if (!sdk_path_or_err) { +Debugger::ReportError("Error while searching for Xcode SDK: " + + toString(sdk_path_or_err.takeError())); +return {}; + } + + FileSpec fspec(*sdk_path_or_err); if (fspec) { if (FileSystem::Instance().Exists(fspec)) return ConstString(fspec.GetPath()); Index: lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp === --- lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp @@ -12,6 +12,7 @@ #include #endif +#include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Host/HostInfo.h" @@ -278,9 +279,19 @@ static llvm::StringRef GetXcodeSDKDir(std::string preferred, std::string secondary) { llvm::StringRef sdk; - sdk = HostInfo::GetXcodeSDKPath(XcodeSDK(std::move(preferred))); + auto get_sdk = [&](std::string sdk) -> llvm::StringRef { +auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(XcodeSDK(std::move(sdk))); +if (!sdk_path_or_err) { + Debugger::ReportError("Error while searching for Xcode SDK: " + +toString(sdk_path_or_err.takeError())); + return {}; +} +return *sdk_path_or_err; + }; + + sdk = get_sdk(preferred); if (sdk.empty()) -sdk = HostInfo::GetXcodeSDKPath(XcodeSDK(std::move(secondary))); +sdk = get_sdk(secondary); return sdk; } Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm === --- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -6,15 +6,15 @@ // //===--===// +#include "lldb/Host/macosx/HostInfoMacOSX.h" +#include "Utility/UuidCompatibility.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "