[Lldb-commits] [lldb] [lldb] Fix printing of unsigned enum bitfields when they contain the max value (PR #96202)
Michael137 wrote: FYI, the new test seems to be failing on the matrix LLDB bot that's testing DWARFv2: ``` == FAIL: test_bitfield_enums_dsym (TestBitfieldEnums.TestBitfieldEnum) -- Traceback (most recent call last): File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 1756, in test_method return attrvalue(self) File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/test/API/commands/expression/bitfield_enums/TestBitfieldEnums.py", line 20, in test_bitfield_enums self.expect_expr( File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2512, in expect_expr value_check.check_value(self, eval_result, str(eval_result)) File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 326, in check_value self.check_value_children(test_base, val, error_msg) File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 349, in check_value_children expected_child.check_value(test_base, actual_child, child_error) File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 311, in check_value test_base.assertEqual(self.expect_value, val.GetValue(), this_error_msg) AssertionError: 'max' != '-1' - max + -1 : Checking child with index 5: (BitfieldStruct) $0 = { signed_min = min signed_other = -1 signed_max = max unsigned_min = min unsigned_other = 1 unsigned_max = -1 } Checking SBValue: (UnsignedEnum:2) unsigned_max = -1 ``` https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake-matrix/459/execution/node/59/log/?consoleFull (both the dSYM and non-dSYM variants of the test are failing) AFAICT, this seems to just be an existing bug in the DWARFv2 support that this test uncovered. With my system LLDB (compiling the test with `-gdwarf-2`): ``` (lldb) v bfs (BitfieldStruct) bfs = { signed_min = min signed_other = -1 signed_max = max unsigned_min = min unsigned_other = 1 unsigned_max = -1 } ``` https://github.com/llvm/llvm-project/pull/96202 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
@@ -0,0 +1,33 @@ +//===-- HLSLIntangibleTypes.def - HLSL standard intangible types *- 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 +// +//===--===// +// +// This file defines HLSL standard intangible types. These are implementation- +// defined types such as handle types that have no defined object +// representation or value representation and their size is unknown at compile +// time. +// +// The macro is: +// +//HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) +// +// where: +// +// - Name is the name of the builtin type. +// +// - BuiltinType::Id is the enumerator defining the type. +// +// - Context.SingletonId is the global singleton of this type. +// +// To include this file, define HLSL_INTANGIBLE_TYPE. +// The macro will be undefined after inclusion. +// +//===--===// + +HLSL_INTANGIBLE_TYPE(__builtin_hlsl_resource_t, HLSLResource, HLSLResourceTy) llvm-beanz wrote: I don't know if we have any cases where a type is prefixed by `__builtin`, usually types are `__clang` or `__` (e.g. `__arm`, `__amdgpu`). Maybe we should just do `__hlsl`? https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
@@ -12335,6 +12335,10 @@ def warn_hlsl_availability_unavailable : Warning, InGroup, DefaultError; +def err_hlsl_intangible_type_cannot_be_declared : Error< +"HLSL intangible type cannot be declared here">; +def err_hlsl_intangible_type_as_function_arg_or_return : Error< +"HLSL intangible type cannot be used as function %select{argument|return value}0">; llvm-beanz wrote: I don't think this is correct. We do allow resources as argument and return types. https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
@@ -3428,6 +3428,12 @@ void CXXNameMangler::mangleType(const BuiltinType *T) { Out << 'u' << type_name.size() << type_name; \ break; #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + case BuiltinType::Id: \ +type_name = #Name; \ +Out << type_name.size() << type_name; \ llvm-beanz wrote: ```suggestion Out << 'u' << type_name.size() << type_name; \ ``` The `u` is significant here because it denotes a vendor-specific builtin type (see: https://itanium-cxx-abi.github.io/cxx-abi/abi-mangling.html). https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
@@ -8001,6 +8001,12 @@ NamedDecl *Sema::ActOnVariableDeclarator( } } + if (getLangOpts().HLSL) { +if (R->isHLSLSpecificType() && !NewVD->isImplicit()) { + Diag(D.getBeginLoc(), diag::err_hlsl_intangible_type_cannot_be_declared); llvm-beanz wrote: Is the intent here to basically say that you can't create these types unless the declaration is implicit? I know we don't expose handle types in DXC, but do we really need to force these to be invalid in source? https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/llvm-beanz commented: Few comments, but mostly I really like this direction! https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/llvm-beanz edited https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang][RecordLayoutBuilder] Be stricter about inferring packed-ness in ExternalLayouts (PR #97443)
https://github.com/efriedma-quic commented: If I'm understanding correctly, the way this currently works is that you do normal field layout, then if you discover that the actual offset of a field is less than the offset normal field layout would produce, you assume the struct is packed. This misses cases where a struct is packed, but the packing doesn't affect the offset of any of the fields. But as you note, this can't be fixed without adjusting the overall architecture. There's an issue with the current implementation: it skips fields which actually are packed, I think. Consider the following: ``` struct Empty {}; struct __attribute((packed)) S { [[no_unique_address]] Empty a,b,c,d; char x; int y; }; S s; ``` In this case, the field "y" is both overlapping, and at a packed offset. Really, you don't want to check for overlap; you want to ignore empty fields. (Non-empty fields can't overlap.) https://github.com/llvm/llvm-project/pull/97443 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 048815c - Revert "[lldb] Silence function cast warning when building with Clang ToT targetting Windows"
Author: Alexandre Ganea Date: 2024-07-06T12:00:13-04:00 New Revision: 048815c22ae779b1f2a0289b7b28ed8cf54af676 URL: https://github.com/llvm/llvm-project/commit/048815c22ae779b1f2a0289b7b28ed8cf54af676 DIFF: https://github.com/llvm/llvm-project/commit/048815c22ae779b1f2a0289b7b28ed8cf54af676.diff LOG: Revert "[lldb] Silence function cast warning when building with Clang ToT targetting Windows" This reverts commit cf1ded3ac248ad4feeed7b4dd20c60b7e3c40339. Added: Modified: lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp Removed: diff --git a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp index dc7697f71d6a6f..a69c10081ff190 100644 --- a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp @@ -175,11 +175,6 @@ Status TargetThreadWindows::DoResume() { return Status(); } -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wcast-function-type-mismatch" -#endif - const char *TargetThreadWindows::GetName() { Log *log = GetLog(LLDBLog::Thread); static GetThreadDescriptionFunctionPtr GetThreadDescription = []() { @@ -205,7 +200,3 @@ const char *TargetThreadWindows::GetName() { return m_name.c_str(); } - -#if defined(__clang__) -#pragma clang diagnostic pop -#endif ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix string truncation method when substring is the prefix of string (NFC) (PR #94785)
https://github.com/xgupta updated https://github.com/llvm/llvm-project/pull/94785 >From 6ec5b1a005b7551f2857b30e2461d297e7febfa3 Mon Sep 17 00:00:00 2001 From: Shivam Gupta Date: Fri, 7 Jun 2024 23:44:49 +0530 Subject: [PATCH 1/2] [LLDB][NFC] Fix a cppcheck warning in Platform/Android/PlatformAndroid.cpp Fix #91211 --- lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp index e177c134fea20e..6367763dd8b4ac 100644 --- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp +++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec _file_spec, static constexpr llvm::StringLiteral k_zip_separator("!/"); size_t pos = source_file.find(k_zip_separator); if (pos != std::string::npos) -source_file = source_file.substr(0, pos); +source_file = source_file.resize(0, pos); Status error; AdbClientUP adb(GetAdbClient(error)); >From c05f1a9812b8ef6cfc4f1f4c2d7525371d65a95b Mon Sep 17 00:00:00 2001 From: Shivam Gupta Date: Sat, 6 Jul 2024 11:00:16 +0200 Subject: [PATCH 2/2] address review comment --- lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp index 6367763dd8b4ac..ff63af68aec9db 100644 --- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp +++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec _file_spec, static constexpr llvm::StringLiteral k_zip_separator("!/"); size_t pos = source_file.find(k_zip_separator); if (pos != std::string::npos) -source_file = source_file.resize(0, pos); +source_file = source_file.resize(pos); Status error; AdbClientUP adb(GetAdbClient(error)); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Correct format specifier for sscanf to prevent buffer overflow (NFC) (PR #94783)
https://github.com/xgupta updated https://github.com/llvm/llvm-project/pull/94783 >From 17d39d89ee723881063ecbea19caaa6806e4e095 Mon Sep 17 00:00:00 2001 From: Shivam Gupta Date: Sat, 15 Jun 2024 23:57:03 +0530 Subject: [PATCH 1/2] Resolved merge conflict --- lldb/source/Host/linux/Host.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp index 5545f9ef4d70e6..8a38947d4b665f 100644 --- a/lldb/source/Host/linux/Host.cpp +++ b/lldb/source/Host/linux/Host.cpp @@ -100,7 +100,7 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo , StatFields stat_fields; if (sscanf( Rest.data(), - "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld", + "%d %15s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld", _fields.pid, stat_fields.comm, _fields.state, _fields.ppid, _fields.pgrp, _fields.session, _fields.tty_nr, _fields.tpgid, _fields.flags, >From d84106a138040dc4e680ec82306969f8ff7ec01d Mon Sep 17 00:00:00 2001 From: Shivam Gupta Date: Sat, 6 Jul 2024 10:57:08 +0200 Subject: [PATCH 2/2] run clang-format --- lldb/source/Host/linux/Host.cpp | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp index 8a38947d4b665f..b5fa266da1d3bf 100644 --- a/lldb/source/Host/linux/Host.cpp +++ b/lldb/source/Host/linux/Host.cpp @@ -98,16 +98,16 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo , if (Rest.empty()) return false; StatFields stat_fields; - if (sscanf( - Rest.data(), - "%d %15s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld", - _fields.pid, stat_fields.comm, _fields.state, - _fields.ppid, _fields.pgrp, _fields.session, - _fields.tty_nr, _fields.tpgid, _fields.flags, - _fields.minflt, _fields.cminflt, _fields.majflt, - _fields.cmajflt, _fields.utime, _fields.stime, - _fields.cutime, _fields.cstime, - _fields.realtime_priority, _fields.priority) < 0) { + if (sscanf(Rest.data(), + "%d %15s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld " + "%ld", + _fields.pid, stat_fields.comm, _fields.state, + _fields.ppid, _fields.pgrp, _fields.session, + _fields.tty_nr, _fields.tpgid, _fields.flags, + _fields.minflt, _fields.cminflt, _fields.majflt, + _fields.cmajflt, _fields.utime, _fields.stime, + _fields.cutime, _fields.cstime, + _fields.realtime_priority, _fields.priority) < 0) { return false; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)
AlexK0 wrote: @jasonmolenda, I checked the tests with the latest fix. There is a minor compilation error: https://github.com/llvm/llvm-project/pull/96260#pullrequestreview-2161497469 If fix it (I just drop `pc` from the logging), all breakpoint tests work, and I don’t see any new failures compared to the main branch. https://github.com/llvm/llvm-project/pull/96260 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)
https://github.com/AlexK0 edited https://github.com/llvm/llvm-project/pull/96260 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)
@@ -377,24 +377,17 @@ void ProcessWindows::RefreshStateAfterStop() { if (!stop_thread) return; - switch (active_exception->GetExceptionCode()) { - case EXCEPTION_SINGLE_STEP: { -RegisterContextSP register_context = stop_thread->GetRegisterContext(); + // If we're at a BreakpointSite, mark this as an Unexecuted Breakpoint. + // We'll clear that state if we've actually executed the breakpoint. + if (RegisterContextSP register_context = stop_thread->GetRegisterContext()) { AlexK0 wrote: Moving `pc` into a scope causes a compilation error at the line with the logging Here: https://github.com/llvm/llvm-project/pull/96260/files#diff-3f6125dd89c50f3b1751b5a7d3270cdd93ad55eae76aef83deee563834c45888R399 https://github.com/llvm/llvm-project/pull/96260 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix incorrect logical operator in 'if' condition check (NFC) (PR #94779)
@@ -85,13 +85,17 @@ class ScriptedPythonInterface : virtual public ScriptedInterface { bool has_class_name = !class_name.empty(); bool has_interpreter_dict = !(llvm::StringRef(m_interpreter.GetDictionaryName()).empty()); -if (!has_class_name && !has_interpreter_dict && !script_obj) { - if (!has_class_name) -return create_error("Missing script class name."); - else if (!has_interpreter_dict) -return create_error("Invalid script interpreter dictionary."); - else -return create_error("Missing scripting object."); + +if (!has_class_name) { + return create_error("Missing script class name."); +} xgupta wrote: Sure, thanks. https://github.com/llvm/llvm-project/pull/94779 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix incorrect logical operator in 'if' condition check (NFC) (PR #94779)
https://github.com/xgupta updated https://github.com/llvm/llvm-project/pull/94779 >From b8a387d82ed90c98f6bc9c0c7f9bc9da0d8e4d18 Mon Sep 17 00:00:00 2001 From: Shivam Gupta Date: Fri, 7 Jun 2024 23:21:15 +0530 Subject: [PATCH 1/3] [LLDB][NFC] Fix a cppcheck warning in Python/Interfaces/ScriptedPythonInterface.h Fix #89195 --- .../Python/Interfaces/ScriptedPythonInterface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h index 163659234466d..30811639c9a95 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h @@ -85,7 +85,7 @@ class ScriptedPythonInterface : virtual public ScriptedInterface { bool has_class_name = !class_name.empty(); bool has_interpreter_dict = !(llvm::StringRef(m_interpreter.GetDictionaryName()).empty()); -if (!has_class_name && !has_interpreter_dict && !script_obj) { +if (!has_class_name || !has_interpreter_dict || !script_obj) { if (!has_class_name) return create_error("Missing script class name."); else if (!has_interpreter_dict) >From 7a53eeb7c42c79f7637a8900a02e782f385d494f Mon Sep 17 00:00:00 2001 From: Shivam Gupta Date: Wed, 19 Jun 2024 13:46:57 +0530 Subject: [PATCH 2/3] simplify condition --- .../Interfaces/ScriptedPythonInterface.h | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h index 30811639c9a95..3d7c640a686ae 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h @@ -85,13 +85,17 @@ class ScriptedPythonInterface : virtual public ScriptedInterface { bool has_class_name = !class_name.empty(); bool has_interpreter_dict = !(llvm::StringRef(m_interpreter.GetDictionaryName()).empty()); -if (!has_class_name || !has_interpreter_dict || !script_obj) { - if (!has_class_name) -return create_error("Missing script class name."); - else if (!has_interpreter_dict) -return create_error("Invalid script interpreter dictionary."); - else -return create_error("Missing scripting object."); + +if (!has_class_name) { + return create_error("Missing script class name."); +} + +if (!has_interpreter_dict) { + return create_error("Invalid script interpreter dictionary."); +} + +if (!script_obj) { + return create_error("Missing scripting object."); } Locker py_lock(_interpreter, Locker::AcquireLock | Locker::NoSTDIN, >From 93a6edb2e5cfeca2eccbc6b70ad8a06476c99210 Mon Sep 17 00:00:00 2001 From: Shivam Gupta Date: Sat, 6 Jul 2024 09:21:30 +0200 Subject: [PATCH 3/3] address review comment --- .../Python/Interfaces/ScriptedPythonInterface.h | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h index 3d7c640a686ae..9e859ec4b3653 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h @@ -86,17 +86,14 @@ class ScriptedPythonInterface : virtual public ScriptedInterface { bool has_interpreter_dict = !(llvm::StringRef(m_interpreter.GetDictionaryName()).empty()); -if (!has_class_name) { +if (!has_class_name) return create_error("Missing script class name."); -} -if (!has_interpreter_dict) { +if (!has_interpreter_dict) return create_error("Invalid script interpreter dictionary."); -} -if (!script_obj) { +if (!script_obj) return create_error("Missing scripting object."); -} Locker py_lock(_interpreter, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)
walter-erquinigo wrote: This is a screenshot of how it's looking for me on VSCode. ![image](https://github.com/llvm/llvm-project/assets/1613874/7a344b26-549c-4be6-b7d6-7082e701ee88) https://github.com/llvm/llvm-project/pull/97871 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Walter Erquinigo (walter-erquinigo) Changes …lly registered languages First of all, this is done to support exceptions for the Mojo language, but it's done in a way that will benefit any other plugin language. 1. I added a new lldb-dap CLI argument (not DAP field) called `pre-init-commands`. These commands are executed before DAP initialization. The other `init-commands` are executed after DAP initialization. It's worth mentioning that the debug adapter returns to VSCode the list of supported exception breakpoints during DAP initialization, which means that I need to register the Mojo plugin before that initialization step, hence the need for `pre-init-commands`. In general, language plugins should be registered in that step, as they affect the capabilities of the debugger. 2. I added a set of APIs for lldb-dap to query information of each language related to exception breakpoints. E.g. whether a language supports throw or catch breakpoints, how the throw keyword is called in each particular language, etc. 3. I'm realizing that the Swift support for exception breakpoints in lldb-dap should have been implemented in this way, instead of hardcoding it. --- Full diff: https://github.com/llvm/llvm-project/pull/97871.diff 7 Files Affected: - (modified) lldb/include/lldb/API/SBLanguageRuntime.h (+26) - (modified) lldb/include/lldb/Target/Language.h (+8) - (modified) lldb/source/API/SBLanguageRuntime.cpp (+40) - (modified) lldb/tools/lldb-dap/DAP.cpp (+54-1) - (modified) lldb/tools/lldb-dap/DAP.h (+2) - (modified) lldb/tools/lldb-dap/Options.td (+8) - (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+16-3) ``diff diff --git a/lldb/include/lldb/API/SBLanguageRuntime.h b/lldb/include/lldb/API/SBLanguageRuntime.h index 38aac05d490c19..acdc256fa2ac5a 100644 --- a/lldb/include/lldb/API/SBLanguageRuntime.h +++ b/lldb/include/lldb/API/SBLanguageRuntime.h @@ -18,6 +18,32 @@ class SBLanguageRuntime { static lldb::LanguageType GetLanguageTypeFromString(const char *string); static const char *GetNameForLanguageType(lldb::LanguageType language); + + /// Returns whether the given language is any version of C++. + static bool LanguageIsCPlusPlus(lldb::LanguageType language); + + /// Returns whether the given language is Obj-C or Obj-C++. + static bool LanguageIsObjC(lldb::LanguageType language); + + /// Returns whether the given language is any version of C, C++ or Obj-C. + static bool LanguageIsCFamily(lldb::LanguageType language); + + /// Returns whether the given language supports exception breakpoints on + /// throw statements. + static bool SupportsExceptionBreakpointsOnThrow(lldb::LanguageType language); + + /// Returns whether the given language supports exception breakpoints on + /// catch statements. + static bool SupportsExceptionBreakpointsOnCatch(lldb::LanguageType language); + + /// Returns the keyword used for throw statements in the given language, e.g. + /// Python uses \b raise. Returns \b nullptr if the language is not supported. + static const char *GetThrowKeywordForLanguage(lldb::LanguageType language); + + /// Returns the keyword used for catch statements in the given language, e.g. + /// Python uses \b except. Returns \b nullptr if the language is not + /// supported. + static const char *GetCatchKeywordForLanguage(lldb::LanguageType language); }; } // namespace lldb diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 83bf7635e369a5..41d8eeef469eab 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -371,6 +371,14 @@ class Language : public PluginInterface { /// a corresponding LanguageRuntime plugin. virtual bool SupportsExceptionBreakpointsOnCatch() const { return false; } + /// Returns the keyword used for throw statements in this language, e.g. + /// Python uses \b raise. Defaults to \b throw. + virtual llvm::StringRef GetThrowKeyword() const { return "throw"; } + + /// Returns the keyword used for catch statements in this language, e.g. + /// Python uses \b except. Defaults to \b catch. + virtual llvm::StringRef GetCatchKeyword() const { return "catch"; } + protected: // Classes that inherit from Language can see and modify these diff --git a/lldb/source/API/SBLanguageRuntime.cpp b/lldb/source/API/SBLanguageRuntime.cpp index d571f282fce03d..3926c57efedf54 100644 --- a/lldb/source/API/SBLanguageRuntime.cpp +++ b/lldb/source/API/SBLanguageRuntime.cpp @@ -26,3 +26,43 @@ SBLanguageRuntime::GetNameForLanguageType(lldb::LanguageType language) { return Language::GetNameForLanguageType(language); } + +bool SBLanguageRuntime::LanguageIsCPlusPlus(lldb::LanguageType language) { + return Language::LanguageIsCPlusPlus(language); +} + +bool SBLanguageRuntime::LanguageIsObjC(lldb::LanguageType language) { + return Language::LanguageIsObjC(language); +} + +bool
[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)
https://github.com/walter-erquinigo created https://github.com/llvm/llvm-project/pull/97871 …lly registered languages First of all, this is done to support exceptions for the Mojo language, but it's done in a way that will benefit any other plugin language. 1. I added a new lldb-dap CLI argument (not DAP field) called `pre-init-commands`. These commands are executed before DAP initialization. The other `init-commands` are executed after DAP initialization. It's worth mentioning that the debug adapter returns to VSCode the list of supported exception breakpoints during DAP initialization, which means that I need to register the Mojo plugin before that initialization step, hence the need for `pre-init-commands`. In general, language plugins should be registered in that step, as they affect the capabilities of the debugger. 2. I added a set of APIs for lldb-dap to query information of each language related to exception breakpoints. E.g. whether a language supports throw or catch breakpoints, how the throw keyword is called in each particular language, etc. 3. I'm realizing that the Swift support for exception breakpoints in lldb-dap should have been implemented in this way, instead of hardcoding it. >From 63ab70e2a02faed8322c71dc2491428938891471 Mon Sep 17 00:00:00 2001 From: walter erquinigo Date: Fri, 5 Jul 2024 20:30:44 -0400 Subject: [PATCH] [lldb-dap] Support throw and catch exception breakpoints for dynamically registered languages First of all, this is done to support exceptions for the Mojo language, but it's done in a way that will benefit any other plugin language. 1. I added a new lldb-dap CLI argument (not DAP field) called `pre-init-commands`. These commands are executed before DAP initialization. The other `init-commands` are executed after DAP initialization. It's worth mentioning that the debug adapter returns to VSCode the list of supported exception breakpoints during DAP initialization, which means that I need to register the Mojo plugin before that initialization step, hence the need for `pre-init-commands`. In general, language plugins should be registered in that step, as they affect the capabilities of the debugger. 2. I added a set of APIs for lldb-dap to query information of each language related to exception breakpoints. E.g. whether a language supports throw or catch breakpoints, how the throw keyword is called in each particular language, etc. 3. I'm realizing that the Swift support for exception breakpoints in lldb-dap should have been implemented in this way, instead of hardcoding it. --- lldb/include/lldb/API/SBLanguageRuntime.h | 26 +++ lldb/include/lldb/Target/Language.h | 8 lldb/source/API/SBLanguageRuntime.cpp | 40 + lldb/tools/lldb-dap/DAP.cpp | 55 ++- lldb/tools/lldb-dap/DAP.h | 2 + lldb/tools/lldb-dap/Options.td| 8 lldb/tools/lldb-dap/lldb-dap.cpp | 19 ++-- 7 files changed, 154 insertions(+), 4 deletions(-) diff --git a/lldb/include/lldb/API/SBLanguageRuntime.h b/lldb/include/lldb/API/SBLanguageRuntime.h index 38aac05d490c1..acdc256fa2ac5 100644 --- a/lldb/include/lldb/API/SBLanguageRuntime.h +++ b/lldb/include/lldb/API/SBLanguageRuntime.h @@ -18,6 +18,32 @@ class SBLanguageRuntime { static lldb::LanguageType GetLanguageTypeFromString(const char *string); static const char *GetNameForLanguageType(lldb::LanguageType language); + + /// Returns whether the given language is any version of C++. + static bool LanguageIsCPlusPlus(lldb::LanguageType language); + + /// Returns whether the given language is Obj-C or Obj-C++. + static bool LanguageIsObjC(lldb::LanguageType language); + + /// Returns whether the given language is any version of C, C++ or Obj-C. + static bool LanguageIsCFamily(lldb::LanguageType language); + + /// Returns whether the given language supports exception breakpoints on + /// throw statements. + static bool SupportsExceptionBreakpointsOnThrow(lldb::LanguageType language); + + /// Returns whether the given language supports exception breakpoints on + /// catch statements. + static bool SupportsExceptionBreakpointsOnCatch(lldb::LanguageType language); + + /// Returns the keyword used for throw statements in the given language, e.g. + /// Python uses \b raise. Returns \b nullptr if the language is not supported. + static const char *GetThrowKeywordForLanguage(lldb::LanguageType language); + + /// Returns the keyword used for catch statements in the given language, e.g. + /// Python uses \b except. Returns \b nullptr if the language is not + /// supported. + static const char *GetCatchKeywordForLanguage(lldb::LanguageType language); }; } // namespace lldb diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 83bf7635e369a..41d8eeef469ea 100644 --- a/lldb/include/lldb/Target/Language.h +++
[Lldb-commits] [lldb] cf1ded3 - [lldb] Silence function cast warning when building with Clang ToT targetting Windows
Author: Alexandre Ganea Date: 2024-07-05T20:49:40-04:00 New Revision: cf1ded3ac248ad4feeed7b4dd20c60b7e3c40339 URL: https://github.com/llvm/llvm-project/commit/cf1ded3ac248ad4feeed7b4dd20c60b7e3c40339 DIFF: https://github.com/llvm/llvm-project/commit/cf1ded3ac248ad4feeed7b4dd20c60b7e3c40339.diff LOG: [lldb] Silence function cast warning when building with Clang ToT targetting Windows Added: Modified: lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp Removed: diff --git a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp index a69c10081ff190..dc7697f71d6a6f 100644 --- a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp @@ -175,6 +175,11 @@ Status TargetThreadWindows::DoResume() { return Status(); } +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-function-type-mismatch" +#endif + const char *TargetThreadWindows::GetName() { Log *log = GetLog(LLDBLog::Thread); static GetThreadDescriptionFunctionPtr GetThreadDescription = []() { @@ -200,3 +205,7 @@ const char *TargetThreadWindows::GetName() { return m_name.c_str(); } + +#if defined(__clang__) +#pragma clang diagnostic pop +#endif ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/Commands] Add `scripting template list` command with auto discovery (PR #97273)
@@ -19,6 +19,12 @@ if (LLDB_ENABLE_LIBEDIT) list(APPEND LLDB_LIBEDIT_LIBS LibEdit::LibEdit) endif() +set_property(GLOBAL PROPERTY LLDB_EXTRA_SCRIPT_PLUGINS + lldbPluginOperatingSystemPythonInterface + lldbPluginScriptedProcessPythonInterface + lldbPluginScriptedThreadPlanPythonInterface bulbazord wrote: No, you're just adding some elements to the list `LLDB_EXTRA_SCRIPT_PLUGINS`. Right below this is `add_lldb_library` which creates one library. It will contain the 3 cpp files that implement these plugin interfaces. https://github.com/llvm/llvm-project/pull/97273 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/Commands] Add `scripting template list` command with auto discovery (PR #97273)
@@ -19,6 +19,12 @@ if (LLDB_ENABLE_LIBEDIT) list(APPEND LLDB_LIBEDIT_LIBS LibEdit::LibEdit) endif() +set_property(GLOBAL PROPERTY LLDB_EXTRA_SCRIPT_PLUGINS + lldbPluginOperatingSystemPythonInterface + lldbPluginScriptedProcessPythonInterface + lldbPluginScriptedThreadPlanPythonInterface medismailben wrote: @bulbazord aren't we making 3 separate libraries here ? https://github.com/llvm/llvm-project/pull/97273 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/Commands] Add `scripting template list` command with auto discovery (PR #97273)
@@ -29,6 +29,9 @@ add_subdirectory(UnwindAssembly) set(LLDB_STRIPPED_PLUGINS) get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS) +get_property(LLDB_EXTRA_PLUGINS GLOBAL PROPERTY LLDB_EXTRA_SCRIPT_PLUGINS) +list(APPEND LLDB_ALL_PLUGINS ${LLDB_EXTRA_PLUGINS}) bulbazord wrote: I see why this doesn't work now. LLDB plugins are added to the `LLDB_PLUGINS` global property via the PLUGIN argument to `add_lldb_library`. You aren't adding the PLUGIN argument to the `add_lldb_library` invocation in `lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt`. This is how the build system knows the list of plugins. But even if you were to remove this and add that `PLUGIN` argument, this still wouldn't work. I don't think we've explicitly documented this behavior, but LLDB expects each library to be one plugin, not three as you've done here. When LLDB creates a plugin, it's going to generate a `Plugins.def` file that LLDB uses to initialize and teardown all plugins. It has a list of entries that look like this: `LLDB_PLUGIN(lldbPluginFooBar)`. There are some exceptions for the script interpreter plugins (not sure why, didn't check). It also expects the `LLDB_PLUGIN_DEFINE` argument to match the library name exactly (without the initial `lldbPlugin`, specifically). The way I see it, you have three options: 1. Restructure the build so that there are 3 libraries, each one of them a plugin. 2. Change LLDB's CMake machinery to accept libraries that define multiple plugin interfaces. You'll need to modify `add_lldb_library` so that you can pass it a list of plugin interface names instead of assuming the plugin names matches the library's name. 3. Keep the workaround and document why it exists. I would suggest (1) or (2). I think (3) is just kicking the can down the road. This is a solution that explicitly works around LLDB's existing plugin system, is difficult to discover without knowing its there, and could make future refactors more difficult. https://github.com/llvm/llvm-project/pull/97273 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
Jlalond wrote: @jeffreytan81 I think the callout for multiple exception is a good question. I made a C# testbed to see what would happen if I had multiple simultaneous exceptions. [Gist here](https://gist.github.com/Jlalond/467bc990f10fbb75cc9ca7db897a7beb). When manually collecting a minidump on my Windows system and then viewing it, I do get a warning that my application has multiple exceptions. ![image](https://github.com/llvm/llvm-project/assets/25160653/d7f7f1c2-3de9-40bd-b692-f3f3ef23fd38) This leads me to believe multiple exceptions is acceptable, albeit rare. https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
@@ -464,8 +464,8 @@ Stream::create(const Directory , const object::MinidumpFile ) { StreamKind Kind = getKind(StreamDesc.Type); switch (Kind) { case StreamKind::Exception: { -Expected ExpectedExceptionStream = -File.getExceptionStream(); +Expected ExpectedExceptionStream = jeffreytan81 wrote: Why are you changing this to return by value copy? https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
@@ -53,6 +54,31 @@ Expected MinidumpFile::getString(size_t Offset) const { return Result; } +Expected> +MinidumpFile::getExceptionStreams() const { + // Scan the directories for exceptions first + std::vector exceptionStreams; + for (const auto : Streams) { +if (directory.Type == StreamType::Exception) + exceptionStreams.push_back(directory); + } jeffreytan81 wrote: Similar, I do not think you need to make a copy of `Directory`, returning by reference is enough. https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
https://github.com/jeffreytan81 requested changes to this pull request. One concern is that, whether minidump format specification supports multiple exception streams. If this is not supported by spec, we may generate minidump that only lldb can read/parse but can fail other consumers. It would be interesting to copy the generated minidump with multiple exception steams to a Windows machine and try windbg/Visual Studio and see if they break. https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
@@ -82,15 +82,24 @@ class MinidumpFile : public Binary { return getListStream(minidump::StreamType::ThreadList); } - /// Returns the contents of the Exception stream. An error is returned if the - /// file does not contain this stream, or the stream is smaller than the size - /// of the ExceptionStream structure. The internal consistency of the stream - /// is not checked in any way. - Expected getExceptionStream() const { -return getStream( -minidump::StreamType::Exception); + /// Returns the contents of the Exception stream. An error is returned if the + /// associated stream is smaller than the size of the ExceptionStream + /// structure. Or the directory supplied is not of kind exception stream. + Expected + getExceptionStream(minidump::Directory Directory) const { +if (Directory.Type != minidump::StreamType::Exception) { + return createError("Not an exception stream"); +} + +return getStreamFromDirectory(Directory); } + /// Returns the contents of the Exception streams. An error is returned if + /// any of the streams are smaller than the size of the ExceptionStream + /// structure. The internal consistency of the stream is not checked in any + /// way. + Expected> getExceptionStreams() const; jeffreytan81 wrote: Should this API return `Expected<>` instead of `std::option<>`? It seems perfect expected that a minidump does not have any exceptions. https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
@@ -53,6 +54,31 @@ Expected MinidumpFile::getString(size_t Offset) const { return Result; } +Expected> +MinidumpFile::getExceptionStreams() const { + // Scan the directories for exceptions first + std::vector exceptionStreams; + for (const auto : Streams) { +if (directory.Type == StreamType::Exception) + exceptionStreams.push_back(directory); + } + + if (exceptionStreams.empty()) +return createError("No exception streams found"); + + std::vector exceptionStreamList; + for (const auto : exceptionStreams) { +llvm::Expected ExpectedStream = +getStreamFromDirectory(exceptionStream); +if (!ExpectedStream) + return ExpectedStream.takeError(); + +exceptionStreamList.push_back(ExpectedStream.get()); jeffreytan81 wrote: `minidump::ExceptionStream` is non-trivial in size. There are a lot of copying here which I do not think you need. The ownership of `minidump::ExceptionStream` is still inside the stream, so let's return reference/pointer from these functions instead of copying by value. https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
@@ -9,6 +9,7 @@ #include "llvm/Object/Minidump.h" #include "llvm/Object/Error.h" #include "llvm/Support/ConvertUTF.h" +#include jeffreytan81 wrote: Is this needed? https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
@@ -109,7 +109,7 @@ class ProcessMinidump : public PostMortemProcess { private: lldb::DataBufferSP m_core_data; llvm::ArrayRef m_thread_list; - const minidump::ExceptionStream *m_active_exception; + std::unordered_map m_exceptions_by_tid; jeffreytan81 wrote: Store `const minidump::ExceptionStream&` instead. https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
@@ -82,15 +82,24 @@ class MinidumpFile : public Binary { return getListStream(minidump::StreamType::ThreadList); } - /// Returns the contents of the Exception stream. An error is returned if the - /// file does not contain this stream, or the stream is smaller than the size - /// of the ExceptionStream structure. The internal consistency of the stream - /// is not checked in any way. - Expected getExceptionStream() const { -return getStream( -minidump::StreamType::Exception); + /// Returns the contents of the Exception stream. An error is returned if the + /// associated stream is smaller than the size of the ExceptionStream + /// structure. Or the directory supplied is not of kind exception stream. + Expected + getExceptionStream(minidump::Directory Directory) const { +if (Directory.Type != minidump::StreamType::Exception) { + return createError("Not an exception stream"); +} + +return getStreamFromDirectory(Directory); jeffreytan81 wrote: Why are changing the API not to return by const reference? https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
@@ -209,7 +208,20 @@ Status ProcessMinidump::DoLoadCore() { GetTarget().SetArchitecture(arch, true /*set_platform*/); m_thread_list = m_minidump_parser->GetThreads(); - m_active_exception = m_minidump_parser->GetExceptionStream(); + std::vector exception_streams = jeffreytan81 wrote: Do not return by a vector of copies, instead return a value of const references/pointers. https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
https://github.com/jeffreytan81 edited https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/bulbazord commented: >From an API standpoint, there doesn't actually seem to be a huge difference >between an empty StringMap and an optional with an empty string map in it >right? Why not return a map every time? https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3bfc516 - [lldb-dap][NFC] Minor rename
Author: walter erquinigo Date: 2024-07-05T13:12:13-04:00 New Revision: 3bfc5167d9e49b9a53e364e8d8853fce543cca0f URL: https://github.com/llvm/llvm-project/commit/3bfc5167d9e49b9a53e364e8d8853fce543cca0f DIFF: https://github.com/llvm/llvm-project/commit/3bfc5167d9e49b9a53e364e8d8853fce543cca0f.diff LOG: [lldb-dap][NFC] Minor rename As a minor follow up for https://github.com/llvm/llvm-project/pull/97675, I'm renaming `SupportsExceptionBreakpoints` to `SupportsExceptionBreakpointsOnThrow` and adding a `SupportsExceptionBreakpointsOnCatch` to have a bit of more granularity. Added: Modified: lldb/include/lldb/Target/Language.h lldb/source/Commands/CommandObjectBreakpoint.cpp lldb/source/Plugins/Language/ObjC/ObjCLanguage.h Removed: diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 2d6e5a40a0c0e4..83bf7635e369a5 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -363,9 +363,13 @@ class Language : public PluginInterface { return false; } - /// Returns true if this Language supports exception breakpoints via a - /// corresponding LanguageRuntime plugin. - virtual bool SupportsExceptionBreakpoints() const { return false; } + /// Returns true if this Language supports exception breakpoints on throw via + /// a corresponding LanguageRuntime plugin. + virtual bool SupportsExceptionBreakpointsOnThrow() const { return false; } + + /// Returns true if this Language supports exception breakpoints on catch via + /// a corresponding LanguageRuntime plugin. + virtual bool SupportsExceptionBreakpointsOnCatch() const { return false; } protected: // Classes that inherit from Language can see and modify these diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index a5fe9273fac76d..773f8ed2fa8af8 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -317,7 +317,8 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { break; default: if (Language *languagePlugin = Language::FindPlugin(language)) { -if (languagePlugin->SupportsExceptionBreakpoints()) { +if (languagePlugin->SupportsExceptionBreakpointsOnThrow() || +languagePlugin->SupportsExceptionBreakpointsOnCatch()) { m_exception_language = language; break; } diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h index a61d0f128370d4..d9c0cd3c18cfa1 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h @@ -194,7 +194,7 @@ class ObjCLanguage : public Language { llvm::StringRef GetInstanceVariableName() override { return "self"; } - bool SupportsExceptionBreakpoints() const override { return true; } + bool SupportsExceptionBreakpointsOnThrow() const override { return true; } // PluginInterface protocol llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix type error when calling random.randrange with 'float' arg (PR #97328)
kendalharland wrote: I'll also need help merging this since I don't have write access to the repo. https://github.com/llvm/llvm-project/pull/97328 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix flake in TestZerothFrame.py (PR #96685)
kendalharland wrote: I'll need help merging this since I don't have write access to the repo. https://github.com/llvm/llvm-project/pull/96685 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
@@ -22,13 +22,13 @@ using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - if (std::optional> features = + if (const std::optional> features = sys::getHostCPUFeatures(features)) { -if ((*features)["sse"]) +if (features->contains("sse")) DavidSpickett wrote: Fixed. https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/DavidSpickett updated https://github.com/llvm/llvm-project/pull/97824 >From 7ebe4e487b763ff26fbab6d75aa7c8694d63e8b1 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Fri, 5 Jul 2024 08:42:22 + Subject: [PATCH 1/3] [llvm][TargetParser] Return optional from getHostCPUFeatures Previously this took a reference to a map and returned a bool to say whether it succeeded. This is an optional but with more steps. The only reason to keep it that way was if someone was appending to an existing map, but all callers made a new map before calling it. --- clang/lib/Driver/ToolChains/Arch/ARM.cpp | 6 ++-- clang/lib/Driver/ToolChains/Arch/X86.cpp | 6 ++-- lldb/utils/lit-cpuid/lit-cpuid.cpp| 21 +++--- llvm/include/llvm/TargetParser/Host.h | 14 - llvm/lib/CodeGen/CommandFlags.cpp | 16 -- .../Orc/JITTargetMachineBuilder.cpp | 8 ++--- llvm/lib/Target/TargetMachineC.cpp| 5 ++-- llvm/lib/TargetParser/Host.cpp| 29 --- 8 files changed, 54 insertions(+), 51 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp index 8ae22cc37a1368..77adbf3865ab11 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -591,9 +591,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver , // Add CPU features for generic CPUs if (CPUName == "native") { -llvm::StringMap HostFeatures; -if (llvm::sys::getHostCPUFeatures(HostFeatures)) - for (auto : HostFeatures) +if (std::optional> HostFeatures = +llvm::sys::getHostCPUFeatures()) + for (auto : *HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); } else if (!CPUName.empty()) { diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp index 92821b2a82daec..e4adfcac23ca0d 100644 --- a/clang/lib/Driver/ToolChains/Arch/X86.cpp +++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -131,9 +131,9 @@ void x86::getX86TargetFeatures(const Driver , const llvm::Triple , // If -march=native, autodetect the feature list. if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { if (StringRef(A->getValue()) == "native") { - llvm::StringMap HostFeatures; - if (llvm::sys::getHostCPUFeatures(HostFeatures)) -for (auto : HostFeatures) + if (std::optional> HostFeatures = + llvm::sys::getHostCPUFeatures()) +for (auto : *HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); } diff --git a/lldb/utils/lit-cpuid/lit-cpuid.cpp b/lldb/utils/lit-cpuid/lit-cpuid.cpp index be322cb6aa42a9..16743164e6a5d9 100644 --- a/lldb/utils/lit-cpuid/lit-cpuid.cpp +++ b/lldb/utils/lit-cpuid/lit-cpuid.cpp @@ -15,22 +15,23 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Host.h" +#include + using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - StringMap features; - - if (!sys::getHostCPUFeatures(features)) + if (std::optional> features = + sys::getHostCPUFeatures(features)) { +if ((*features)["sse"]) + outs() << "sse\n"; +if ((*features)["avx"]) + outs() << "avx\n"; +if ((*features)["avx512f"]) + outs() << "avx512f\n"; + } else return 1; - - if (features["sse"]) -outs() << "sse\n"; - if (features["avx"]) -outs() << "avx\n"; - if (features["avx512f"]) -outs() << "avx512f\n"; #endif return 0; diff --git a/llvm/include/llvm/TargetParser/Host.h b/llvm/include/llvm/TargetParser/Host.h index af72045a8fe67f..d68655835a3233 100644 --- a/llvm/include/llvm/TargetParser/Host.h +++ b/llvm/include/llvm/TargetParser/Host.h @@ -13,6 +13,7 @@ #ifndef LLVM_TARGETPARSER_HOST_H #define LLVM_TARGETPARSER_HOST_H +#include #include namespace llvm { @@ -47,13 +48,12 @@ namespace sys { /// The particular format of the names are target dependent, and suitable for /// passing as -mattr to the target which matches the host. /// - /// \param Features - A string mapping feature names to either - /// true (if enabled) or false (if disabled). This routine makes no guarantees - /// about exactly which features may appear in this map, except that they are - /// all valid LLVM feature names. - /// - /// \return - True on success. - bool getHostCPUFeatures(StringMap ); + /// \return - If feature detection succeeds, a string map mapping feature + /// names to either true (if enabled) or false (if disabled). This routine + /// makes no guarantees about exactly which features may appear in this map, + /// except that they are all valid LLVM feature names. If feature detection + /// fails, an empty optional is
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
@@ -22,13 +22,13 @@ using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - if (std::optional> features = + if (const std::optional> features = sys::getHostCPUFeatures(features)) { -if ((*features)["sse"]) +if (features->contains("sse")) DavidSpickett wrote: Doh, of course. https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
@@ -22,13 +22,13 @@ using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - if (std::optional> features = + if (const std::optional> features = sys::getHostCPUFeatures(features)) { -if ((*features)["sse"]) +if (features->contains("sse")) tmatheson-arm wrote: `contains` will only check if the key exists in the map, but you want to actually get the `bool` if it exists and default to `false` if it doesn't. I think `lookup` fits better. https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DataFormatter] Simplify std::unordered_map::iterator formatter (PR #97754)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/97754 >From b10f76bd6d02106e80315a70a7b72461cb6f2a99 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 4 Jul 2024 13:35:21 +0200 Subject: [PATCH 1/2] [lldb][DataFormatter] Move std::unordered_map::iterator formatter into LibCxxUnorderedMap.cpp --- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 149 - .../Plugins/Language/CPlusPlus/LibCxx.h | 54 + .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 196 ++ 3 files changed, 200 insertions(+), 199 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 05cfa0568c25d..feaa51a96843a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -202,155 +202,6 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( return true; } -lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp) { - if (valobj_sp) -Update(); -} - -lldb::ChildCacheState lldb_private::formatters:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd::Update() { - m_pair_sp.reset(); - m_iter_ptr = nullptr; - - ValueObjectSP valobj_sp = m_backend.GetSP(); - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - TargetSP target_sp(valobj_sp->GetTargetSP()); - - if (!target_sp) -return lldb::ChildCacheState::eRefetch; - - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - auto exprPathOptions = ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None); - - // This must be a ValueObject* because it is a child of the ValueObject we - // are producing children for it if were a ValueObjectSP, we would end up - // with a loop (iterator -> synthetic -> child -> parent == iterator) and - // that would in turn leak memory by never allowing the ValueObjects to die - // and free their memory. - m_iter_ptr = - valobj_sp - ->GetValueForExpressionPath(".__i_.__node_", nullptr, nullptr, - exprPathOptions, nullptr) - .get(); - - if (m_iter_ptr) { -auto iter_child(valobj_sp->GetChildMemberWithName("__i_")); -if (!iter_child) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -CompilerType node_type(iter_child->GetCompilerType() - .GetTypeTemplateArgument(0) - .GetPointeeType()); - -CompilerType pair_type(node_type.GetTypeTemplateArgument(0)); - -std::string name; -uint64_t bit_offset_ptr; -uint32_t bitfield_bit_size_ptr; -bool is_bitfield_ptr; - -pair_type = pair_type.GetFieldAtIndex( -0, name, _offset_ptr, _bit_size_ptr, _bitfield_ptr); -if (!pair_type) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -uint64_t addr = m_iter_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); -m_iter_ptr = nullptr; - -if (addr == 0 || addr == LLDB_INVALID_ADDRESS) - return lldb::ChildCacheState::eRefetch; - -auto ts = pair_type.GetTypeSystem(); -auto ast_ctx = ts.dyn_cast_or_null(); -if (!ast_ctx) - return lldb::ChildCacheState::eRefetch; - -// Mimick layout of std::__hash_iterator::__node_ and read it in -// from process memory. -// -// The following shows the contiguous block of memory: -// -// +-+ class __hash_node_base -// __node_ | __next_pointer __next_; | -// +-+ class __hash_node -// | size_t __hash_; | -// | __node_value_type __value_; | <<< our key/value pair -// +-+ -// -CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( -llvm::StringRef(), -{{"__next_", - ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, - {"__hash_", ast_ctx->GetBasicType(lldb::eBasicTypeUnsignedLongLong)}, - {"__value_", pair_type}}); -std::optional size = tree_node_type.GetByteSize(nullptr); -if (!size) - return lldb::ChildCacheState::eRefetch; -WritableDataBufferSP buffer_sp(new DataBufferHeap(*size, 0)); -ProcessSP process_sp(target_sp->GetProcessSP()); -Status error; -process_sp->ReadMemory(addr, buffer_sp->GetBytes(), - buffer_sp->GetByteSize(), error); -if (error.Fail()) - return lldb::ChildCacheState::eRefetch; -
[Lldb-commits] [lldb] [lldb][DataFormatter] Simplify std::unordered_map::iterator formatter (PR #97754)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/97754 >From b10f76bd6d02106e80315a70a7b72461cb6f2a99 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 4 Jul 2024 13:35:21 +0200 Subject: [PATCH 1/2] [lldb][DataFormatter] Move std::unordered_map::iterator formatter into LibCxxUnorderedMap.cpp --- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 149 - .../Plugins/Language/CPlusPlus/LibCxx.h | 54 + .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 196 ++ 3 files changed, 200 insertions(+), 199 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 05cfa0568c25d..feaa51a96843a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -202,155 +202,6 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( return true; } -lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp) { - if (valobj_sp) -Update(); -} - -lldb::ChildCacheState lldb_private::formatters:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd::Update() { - m_pair_sp.reset(); - m_iter_ptr = nullptr; - - ValueObjectSP valobj_sp = m_backend.GetSP(); - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - TargetSP target_sp(valobj_sp->GetTargetSP()); - - if (!target_sp) -return lldb::ChildCacheState::eRefetch; - - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - auto exprPathOptions = ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None); - - // This must be a ValueObject* because it is a child of the ValueObject we - // are producing children for it if were a ValueObjectSP, we would end up - // with a loop (iterator -> synthetic -> child -> parent == iterator) and - // that would in turn leak memory by never allowing the ValueObjects to die - // and free their memory. - m_iter_ptr = - valobj_sp - ->GetValueForExpressionPath(".__i_.__node_", nullptr, nullptr, - exprPathOptions, nullptr) - .get(); - - if (m_iter_ptr) { -auto iter_child(valobj_sp->GetChildMemberWithName("__i_")); -if (!iter_child) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -CompilerType node_type(iter_child->GetCompilerType() - .GetTypeTemplateArgument(0) - .GetPointeeType()); - -CompilerType pair_type(node_type.GetTypeTemplateArgument(0)); - -std::string name; -uint64_t bit_offset_ptr; -uint32_t bitfield_bit_size_ptr; -bool is_bitfield_ptr; - -pair_type = pair_type.GetFieldAtIndex( -0, name, _offset_ptr, _bit_size_ptr, _bitfield_ptr); -if (!pair_type) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -uint64_t addr = m_iter_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); -m_iter_ptr = nullptr; - -if (addr == 0 || addr == LLDB_INVALID_ADDRESS) - return lldb::ChildCacheState::eRefetch; - -auto ts = pair_type.GetTypeSystem(); -auto ast_ctx = ts.dyn_cast_or_null(); -if (!ast_ctx) - return lldb::ChildCacheState::eRefetch; - -// Mimick layout of std::__hash_iterator::__node_ and read it in -// from process memory. -// -// The following shows the contiguous block of memory: -// -// +-+ class __hash_node_base -// __node_ | __next_pointer __next_; | -// +-+ class __hash_node -// | size_t __hash_; | -// | __node_value_type __value_; | <<< our key/value pair -// +-+ -// -CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( -llvm::StringRef(), -{{"__next_", - ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, - {"__hash_", ast_ctx->GetBasicType(lldb::eBasicTypeUnsignedLongLong)}, - {"__value_", pair_type}}); -std::optional size = tree_node_type.GetByteSize(nullptr); -if (!size) - return lldb::ChildCacheState::eRefetch; -WritableDataBufferSP buffer_sp(new DataBufferHeap(*size, 0)); -ProcessSP process_sp(target_sp->GetProcessSP()); -Status error; -process_sp->ReadMemory(addr, buffer_sp->GetBytes(), - buffer_sp->GetByteSize(), error); -if (error.Fail()) - return lldb::ChildCacheState::eRefetch; -
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
@@ -15,22 +15,23 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Host.h" +#include + using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - StringMap features; - - if (!sys::getHostCPUFeatures(features)) + if (std::optional> features = + sys::getHostCPUFeatures(features)) { +if ((*features)["sse"]) DavidSpickett wrote: Done. https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/DavidSpickett updated https://github.com/llvm/llvm-project/pull/97824 >From 7ebe4e487b763ff26fbab6d75aa7c8694d63e8b1 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Fri, 5 Jul 2024 08:42:22 + Subject: [PATCH 1/2] [llvm][TargetParser] Return optional from getHostCPUFeatures Previously this took a reference to a map and returned a bool to say whether it succeeded. This is an optional but with more steps. The only reason to keep it that way was if someone was appending to an existing map, but all callers made a new map before calling it. --- clang/lib/Driver/ToolChains/Arch/ARM.cpp | 6 ++-- clang/lib/Driver/ToolChains/Arch/X86.cpp | 6 ++-- lldb/utils/lit-cpuid/lit-cpuid.cpp| 21 +++--- llvm/include/llvm/TargetParser/Host.h | 14 - llvm/lib/CodeGen/CommandFlags.cpp | 16 -- .../Orc/JITTargetMachineBuilder.cpp | 8 ++--- llvm/lib/Target/TargetMachineC.cpp| 5 ++-- llvm/lib/TargetParser/Host.cpp| 29 --- 8 files changed, 54 insertions(+), 51 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp index 8ae22cc37a136..77adbf3865ab1 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -591,9 +591,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver , // Add CPU features for generic CPUs if (CPUName == "native") { -llvm::StringMap HostFeatures; -if (llvm::sys::getHostCPUFeatures(HostFeatures)) - for (auto : HostFeatures) +if (std::optional> HostFeatures = +llvm::sys::getHostCPUFeatures()) + for (auto : *HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); } else if (!CPUName.empty()) { diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp index 92821b2a82dae..e4adfcac23ca0 100644 --- a/clang/lib/Driver/ToolChains/Arch/X86.cpp +++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -131,9 +131,9 @@ void x86::getX86TargetFeatures(const Driver , const llvm::Triple , // If -march=native, autodetect the feature list. if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { if (StringRef(A->getValue()) == "native") { - llvm::StringMap HostFeatures; - if (llvm::sys::getHostCPUFeatures(HostFeatures)) -for (auto : HostFeatures) + if (std::optional> HostFeatures = + llvm::sys::getHostCPUFeatures()) +for (auto : *HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); } diff --git a/lldb/utils/lit-cpuid/lit-cpuid.cpp b/lldb/utils/lit-cpuid/lit-cpuid.cpp index be322cb6aa42a..16743164e6a5d 100644 --- a/lldb/utils/lit-cpuid/lit-cpuid.cpp +++ b/lldb/utils/lit-cpuid/lit-cpuid.cpp @@ -15,22 +15,23 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Host.h" +#include + using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - StringMap features; - - if (!sys::getHostCPUFeatures(features)) + if (std::optional> features = + sys::getHostCPUFeatures(features)) { +if ((*features)["sse"]) + outs() << "sse\n"; +if ((*features)["avx"]) + outs() << "avx\n"; +if ((*features)["avx512f"]) + outs() << "avx512f\n"; + } else return 1; - - if (features["sse"]) -outs() << "sse\n"; - if (features["avx"]) -outs() << "avx\n"; - if (features["avx512f"]) -outs() << "avx512f\n"; #endif return 0; diff --git a/llvm/include/llvm/TargetParser/Host.h b/llvm/include/llvm/TargetParser/Host.h index af72045a8fe67..d68655835a323 100644 --- a/llvm/include/llvm/TargetParser/Host.h +++ b/llvm/include/llvm/TargetParser/Host.h @@ -13,6 +13,7 @@ #ifndef LLVM_TARGETPARSER_HOST_H #define LLVM_TARGETPARSER_HOST_H +#include #include namespace llvm { @@ -47,13 +48,12 @@ namespace sys { /// The particular format of the names are target dependent, and suitable for /// passing as -mattr to the target which matches the host. /// - /// \param Features - A string mapping feature names to either - /// true (if enabled) or false (if disabled). This routine makes no guarantees - /// about exactly which features may appear in this map, except that they are - /// all valid LLVM feature names. - /// - /// \return - True on success. - bool getHostCPUFeatures(StringMap ); + /// \return - If feature detection succeeds, a string map mapping feature + /// names to either true (if enabled) or false (if disabled). This routine + /// makes no guarantees about exactly which features may appear in this map, + /// except that they are all valid LLVM feature names. If feature detection + /// fails, an empty optional is returned.
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
@@ -1710,15 +1710,17 @@ VendorSignatures getVendorSignature(unsigned *MaxLeaf) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) -bool sys::getHostCPUFeatures(StringMap ) { +std::optional> sys::getHostCPUFeatures() { unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0; unsigned MaxLevel; if (getX86CpuIDAndInfo(0, , , , ) || MaxLevel < 1) -return false; +return {}; getX86CpuIDAndInfo(1, , , , ); + StringMap Features; DavidSpickett wrote: The caller creating a blank map to pass to this function is the symptom of what I'm looking to fix here. The implementations are still going to create a map if they're going to return features. The motivation for the change is to allow: ``` if (auto features = sys::getCPUHostFeatures()) ``` Instead of: ``` map features; if (sys::getCPUHostFeatures(map) ``` As the optional better describes the situation. You either get a feature map or you don't. Versus bool+mutable ref which could allow any combination of states. The docstring helps but might as well use the typesystem to say the same thing as well. If the callers were building a map as they went, I'd understand the mutable ref parameter. Like: ``` map features if (add_some_features(features)) if (add_some_more_features(features)) filter_features(features) ``` But all uses create an empty map specifically to pass to the function. ...which is to say yeah, I should include the motivation in the commit message, let me do that :) https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
@@ -1710,15 +1710,17 @@ VendorSignatures getVendorSignature(unsigned *MaxLeaf) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) -bool sys::getHostCPUFeatures(StringMap ) { +std::optional> sys::getHostCPUFeatures() { unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0; unsigned MaxLevel; if (getX86CpuIDAndInfo(0, , , , ) || MaxLevel < 1) -return false; +return {}; getX86CpuIDAndInfo(1, , , , ); + StringMap Features; phoebewang wrote: IIUC, the motivation is to avoid creating a blank map. But here we still create it with each call. Is there any difference except early return in line 1728, which should rarely happend. https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
@@ -15,22 +15,23 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Host.h" +#include + using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - StringMap features; - - if (!sys::getHostCPUFeatures(features)) + if (std::optional> features = + sys::getHostCPUFeatures(features)) { +if ((*features)["sse"]) tmatheson-arm wrote: Maybe ```suggestion if (features->lookup("sse")) ``` which does the same, but doesn't insert the default entry into the map. https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/tmatheson-arm approved this pull request. https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
llvmbot wrote: @llvm/pr-subscribers-backend-x86 @llvm/pr-subscribers-clang-driver Author: David Spickett (DavidSpickett) Changes Previously this took a reference to a map and returned a bool to say whether it succeeded. This is an optional but with more steps. The only reason to keep it that way was if someone was appending to an existing map, but all callers made a new map before calling it. --- Full diff: https://github.com/llvm/llvm-project/pull/97824.diff 8 Files Affected: - (modified) clang/lib/Driver/ToolChains/Arch/ARM.cpp (+3-3) - (modified) clang/lib/Driver/ToolChains/Arch/X86.cpp (+3-3) - (modified) lldb/utils/lit-cpuid/lit-cpuid.cpp (+11-10) - (modified) llvm/include/llvm/TargetParser/Host.h (+7-7) - (modified) llvm/lib/CodeGen/CommandFlags.cpp (+6-10) - (modified) llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp (+4-4) - (modified) llvm/lib/Target/TargetMachineC.cpp (+2-3) - (modified) llvm/lib/TargetParser/Host.cpp (+18-11) ``diff diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp index 8ae22cc37a136..77adbf3865ab1 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -591,9 +591,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver , // Add CPU features for generic CPUs if (CPUName == "native") { -llvm::StringMap HostFeatures; -if (llvm::sys::getHostCPUFeatures(HostFeatures)) - for (auto : HostFeatures) +if (std::optional> HostFeatures = +llvm::sys::getHostCPUFeatures()) + for (auto : *HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); } else if (!CPUName.empty()) { diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp index 92821b2a82dae..e4adfcac23ca0 100644 --- a/clang/lib/Driver/ToolChains/Arch/X86.cpp +++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -131,9 +131,9 @@ void x86::getX86TargetFeatures(const Driver , const llvm::Triple , // If -march=native, autodetect the feature list. if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { if (StringRef(A->getValue()) == "native") { - llvm::StringMap HostFeatures; - if (llvm::sys::getHostCPUFeatures(HostFeatures)) -for (auto : HostFeatures) + if (std::optional> HostFeatures = + llvm::sys::getHostCPUFeatures()) +for (auto : *HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); } diff --git a/lldb/utils/lit-cpuid/lit-cpuid.cpp b/lldb/utils/lit-cpuid/lit-cpuid.cpp index be322cb6aa42a..16743164e6a5d 100644 --- a/lldb/utils/lit-cpuid/lit-cpuid.cpp +++ b/lldb/utils/lit-cpuid/lit-cpuid.cpp @@ -15,22 +15,23 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Host.h" +#include + using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - StringMap features; - - if (!sys::getHostCPUFeatures(features)) + if (std::optional> features = + sys::getHostCPUFeatures(features)) { +if ((*features)["sse"]) + outs() << "sse\n"; +if ((*features)["avx"]) + outs() << "avx\n"; +if ((*features)["avx512f"]) + outs() << "avx512f\n"; + } else return 1; - - if (features["sse"]) -outs() << "sse\n"; - if (features["avx"]) -outs() << "avx\n"; - if (features["avx512f"]) -outs() << "avx512f\n"; #endif return 0; diff --git a/llvm/include/llvm/TargetParser/Host.h b/llvm/include/llvm/TargetParser/Host.h index af72045a8fe67..d68655835a323 100644 --- a/llvm/include/llvm/TargetParser/Host.h +++ b/llvm/include/llvm/TargetParser/Host.h @@ -13,6 +13,7 @@ #ifndef LLVM_TARGETPARSER_HOST_H #define LLVM_TARGETPARSER_HOST_H +#include #include namespace llvm { @@ -47,13 +48,12 @@ namespace sys { /// The particular format of the names are target dependent, and suitable for /// passing as -mattr to the target which matches the host. /// - /// \param Features - A string mapping feature names to either - /// true (if enabled) or false (if disabled). This routine makes no guarantees - /// about exactly which features may appear in this map, except that they are - /// all valid LLVM feature names. - /// - /// \return - True on success. - bool getHostCPUFeatures(StringMap ); + /// \return - If feature detection succeeds, a string map mapping feature + /// names to either true (if enabled) or false (if disabled). This routine + /// makes no guarantees about exactly which features may appear in this map, + /// except that they are all valid LLVM feature names. If feature detection + /// fails, an empty optional is returned. + std::optional> getHostCPUFeatures(); /// This is a function compatible with cl::AddExtraVersionPrinter, which adds
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/97824 Previously this took a reference to a map and returned a bool to say whether it succeeded. This is an optional but with more steps. The only reason to keep it that way was if someone was appending to an existing map, but all callers made a new map before calling it. >From 7ebe4e487b763ff26fbab6d75aa7c8694d63e8b1 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Fri, 5 Jul 2024 08:42:22 + Subject: [PATCH] [llvm][TargetParser] Return optional from getHostCPUFeatures Previously this took a reference to a map and returned a bool to say whether it succeeded. This is an optional but with more steps. The only reason to keep it that way was if someone was appending to an existing map, but all callers made a new map before calling it. --- clang/lib/Driver/ToolChains/Arch/ARM.cpp | 6 ++-- clang/lib/Driver/ToolChains/Arch/X86.cpp | 6 ++-- lldb/utils/lit-cpuid/lit-cpuid.cpp| 21 +++--- llvm/include/llvm/TargetParser/Host.h | 14 - llvm/lib/CodeGen/CommandFlags.cpp | 16 -- .../Orc/JITTargetMachineBuilder.cpp | 8 ++--- llvm/lib/Target/TargetMachineC.cpp| 5 ++-- llvm/lib/TargetParser/Host.cpp| 29 --- 8 files changed, 54 insertions(+), 51 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp index 8ae22cc37a1368..77adbf3865ab11 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -591,9 +591,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver , // Add CPU features for generic CPUs if (CPUName == "native") { -llvm::StringMap HostFeatures; -if (llvm::sys::getHostCPUFeatures(HostFeatures)) - for (auto : HostFeatures) +if (std::optional> HostFeatures = +llvm::sys::getHostCPUFeatures()) + for (auto : *HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); } else if (!CPUName.empty()) { diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp index 92821b2a82daec..e4adfcac23ca0d 100644 --- a/clang/lib/Driver/ToolChains/Arch/X86.cpp +++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -131,9 +131,9 @@ void x86::getX86TargetFeatures(const Driver , const llvm::Triple , // If -march=native, autodetect the feature list. if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { if (StringRef(A->getValue()) == "native") { - llvm::StringMap HostFeatures; - if (llvm::sys::getHostCPUFeatures(HostFeatures)) -for (auto : HostFeatures) + if (std::optional> HostFeatures = + llvm::sys::getHostCPUFeatures()) +for (auto : *HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); } diff --git a/lldb/utils/lit-cpuid/lit-cpuid.cpp b/lldb/utils/lit-cpuid/lit-cpuid.cpp index be322cb6aa42a9..16743164e6a5d9 100644 --- a/lldb/utils/lit-cpuid/lit-cpuid.cpp +++ b/lldb/utils/lit-cpuid/lit-cpuid.cpp @@ -15,22 +15,23 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Host.h" +#include + using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - StringMap features; - - if (!sys::getHostCPUFeatures(features)) + if (std::optional> features = + sys::getHostCPUFeatures(features)) { +if ((*features)["sse"]) + outs() << "sse\n"; +if ((*features)["avx"]) + outs() << "avx\n"; +if ((*features)["avx512f"]) + outs() << "avx512f\n"; + } else return 1; - - if (features["sse"]) -outs() << "sse\n"; - if (features["avx"]) -outs() << "avx\n"; - if (features["avx512f"]) -outs() << "avx512f\n"; #endif return 0; diff --git a/llvm/include/llvm/TargetParser/Host.h b/llvm/include/llvm/TargetParser/Host.h index af72045a8fe67f..d68655835a3233 100644 --- a/llvm/include/llvm/TargetParser/Host.h +++ b/llvm/include/llvm/TargetParser/Host.h @@ -13,6 +13,7 @@ #ifndef LLVM_TARGETPARSER_HOST_H #define LLVM_TARGETPARSER_HOST_H +#include #include namespace llvm { @@ -47,13 +48,12 @@ namespace sys { /// The particular format of the names are target dependent, and suitable for /// passing as -mattr to the target which matches the host. /// - /// \param Features - A string mapping feature names to either - /// true (if enabled) or false (if disabled). This routine makes no guarantees - /// about exactly which features may appear in this map, except that they are - /// all valid LLVM feature names. - /// - /// \return - True on success. - bool getHostCPUFeatures(StringMap ); + /// \return - If feature detection succeeds, a string map mapping feature + ///
[Lldb-commits] [lldb] [lldb][DataFormatter] Simplify std::unordered_map::iterator formatter (PR #97754)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/97754 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DataFormatter] Simplify std::unordered_map::iterator formatter (PR #97754)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/97754 >From b10f76bd6d02106e80315a70a7b72461cb6f2a99 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 4 Jul 2024 13:35:21 +0200 Subject: [PATCH 1/2] [lldb][DataFormatter] Move std::unordered_map::iterator formatter into LibCxxUnorderedMap.cpp --- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 149 - .../Plugins/Language/CPlusPlus/LibCxx.h | 54 + .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 196 ++ 3 files changed, 200 insertions(+), 199 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 05cfa0568c25d4..feaa51a96843ab 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -202,155 +202,6 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( return true; } -lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp) { - if (valobj_sp) -Update(); -} - -lldb::ChildCacheState lldb_private::formatters:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd::Update() { - m_pair_sp.reset(); - m_iter_ptr = nullptr; - - ValueObjectSP valobj_sp = m_backend.GetSP(); - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - TargetSP target_sp(valobj_sp->GetTargetSP()); - - if (!target_sp) -return lldb::ChildCacheState::eRefetch; - - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - auto exprPathOptions = ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None); - - // This must be a ValueObject* because it is a child of the ValueObject we - // are producing children for it if were a ValueObjectSP, we would end up - // with a loop (iterator -> synthetic -> child -> parent == iterator) and - // that would in turn leak memory by never allowing the ValueObjects to die - // and free their memory. - m_iter_ptr = - valobj_sp - ->GetValueForExpressionPath(".__i_.__node_", nullptr, nullptr, - exprPathOptions, nullptr) - .get(); - - if (m_iter_ptr) { -auto iter_child(valobj_sp->GetChildMemberWithName("__i_")); -if (!iter_child) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -CompilerType node_type(iter_child->GetCompilerType() - .GetTypeTemplateArgument(0) - .GetPointeeType()); - -CompilerType pair_type(node_type.GetTypeTemplateArgument(0)); - -std::string name; -uint64_t bit_offset_ptr; -uint32_t bitfield_bit_size_ptr; -bool is_bitfield_ptr; - -pair_type = pair_type.GetFieldAtIndex( -0, name, _offset_ptr, _bit_size_ptr, _bitfield_ptr); -if (!pair_type) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -uint64_t addr = m_iter_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); -m_iter_ptr = nullptr; - -if (addr == 0 || addr == LLDB_INVALID_ADDRESS) - return lldb::ChildCacheState::eRefetch; - -auto ts = pair_type.GetTypeSystem(); -auto ast_ctx = ts.dyn_cast_or_null(); -if (!ast_ctx) - return lldb::ChildCacheState::eRefetch; - -// Mimick layout of std::__hash_iterator::__node_ and read it in -// from process memory. -// -// The following shows the contiguous block of memory: -// -// +-+ class __hash_node_base -// __node_ | __next_pointer __next_; | -// +-+ class __hash_node -// | size_t __hash_; | -// | __node_value_type __value_; | <<< our key/value pair -// +-+ -// -CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( -llvm::StringRef(), -{{"__next_", - ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, - {"__hash_", ast_ctx->GetBasicType(lldb::eBasicTypeUnsignedLongLong)}, - {"__value_", pair_type}}); -std::optional size = tree_node_type.GetByteSize(nullptr); -if (!size) - return lldb::ChildCacheState::eRefetch; -WritableDataBufferSP buffer_sp(new DataBufferHeap(*size, 0)); -ProcessSP process_sp(target_sp->GetProcessSP()); -Status error; -process_sp->ReadMemory(addr, buffer_sp->GetBytes(), - buffer_sp->GetByteSize(), error); -if (error.Fail()) - return lldb::ChildCacheState::eRefetch; -
[Lldb-commits] [lldb] [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_x86_64() declaration (PR #97796)
github-actions[bot] wrote: @kiyolee Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/97796 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_x86_64() declaration (PR #97796)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/97796 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b3fa2a6 - [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_x86_64() declaration (#97796)
Author: Kelvin Lee Date: 2024-07-05T09:05:05+01:00 New Revision: b3fa2a691ff7d5a85bc31fb428cd58d68bfecd10 URL: https://github.com/llvm/llvm-project/commit/b3fa2a691ff7d5a85bc31fb428cd58d68bfecd10 DIFF: https://github.com/llvm/llvm-project/commit/b3fa2a691ff7d5a85bc31fb428cd58d68bfecd10.diff LOG: [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_x86_64() declaration (#97796) Supposingly this is a typo. Added: Modified: lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h Removed: diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h index 54ec9fc154ca2..a522d850cb37d 100644 --- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h +++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h @@ -38,7 +38,7 @@ class NativeRegisterContextFreeBSD_x86_64 public NativeRegisterContextDBReg_x86 { public: NativeRegisterContextFreeBSD_x86_64(const ArchSpec _arch, - NativeThreadProtocol _thread); + NativeThreadFreeBSD _thread); uint32_t GetRegisterSetCount() const override; const RegisterSet *GetRegisterSet(uint32_t set_index) const override; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_x86_64() declaration (PR #97796)
DavidSpickett wrote: Specifically changes from https://github.com/llvm/llvm-project/pull/85058. https://github.com/llvm/llvm-project/pull/97796 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_x86_64() declaration (PR #97796)
https://github.com/DavidSpickett approved this pull request. Yes this is due to me only testing my changes on AArch64, thanks for the patch. https://github.com/llvm/llvm-project/pull/97796 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_x86_64() declaration (PR #97796)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/97796 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb/FreeBSD: Fix NativeRegisterContextFreeBSD_x86_64() declaration (PR #97796)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Kelvin Lee (kiyolee) Changes Supposingly this is a typo. --- Full diff: https://github.com/llvm/llvm-project/pull/97796.diff 1 Files Affected: - (modified) lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h (+1-1) ``diff diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h index 54ec9fc154ca2..a522d850cb37d 100644 --- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h +++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h @@ -38,7 +38,7 @@ class NativeRegisterContextFreeBSD_x86_64 public NativeRegisterContextDBReg_x86 { public: NativeRegisterContextFreeBSD_x86_64(const ArchSpec _arch, - NativeThreadProtocol _thread); + NativeThreadFreeBSD _thread); uint32_t GetRegisterSetCount() const override; const RegisterSet *GetRegisterSet(uint32_t set_index) const override; `` https://github.com/llvm/llvm-project/pull/97796 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb/FreeBSD: Fix NativeRegisterContextFreeBSD_x86_64() declaration (PR #97796)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/97796 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb/FreeBSD: Fix NativeRegisterContextFreeBSD_x86_64() declaration (PR #97796)
https://github.com/kiyolee created https://github.com/llvm/llvm-project/pull/97796 Supposingly this is a typo. >From dc56ef5d100525d48e7ecc86dc6bb65bceeea114 Mon Sep 17 00:00:00 2001 From: Kelvin Lee Date: Fri, 5 Jul 2024 17:51:20 +1000 Subject: [PATCH] lldb/FreeBSD: Fix NativeRegisterContextFreeBSD_x86_64() declaration --- .../Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h index 54ec9fc154ca2..a522d850cb37d 100644 --- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h +++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h @@ -38,7 +38,7 @@ class NativeRegisterContextFreeBSD_x86_64 public NativeRegisterContextDBReg_x86 { public: NativeRegisterContextFreeBSD_x86_64(const ArchSpec _arch, - NativeThreadProtocol _thread); + NativeThreadFreeBSD _thread); uint32_t GetRegisterSetCount() const override; const RegisterSet *GetRegisterSet(uint32_t set_index) const override; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support new libc++ __compressed_pair layout (PR #96538)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/96538 >From 0d39f1ecfb9643f944aa1352d4a307e5638ab08f Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 29 Jan 2024 16:23:16 + Subject: [PATCH 1/2] [lldb] Support new libc++ __compressed_pair layout This patch is in preparation for the `__compressed_pair` refactor in https://github.com/llvm/llvm-project/pull/76756. This gets the formatter tests to at least pass. Currently in draft because there's still some cleanup to be done. --- lldb/examples/synthetic/libcxx.py | 26 -- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 61 ++ .../Plugins/Language/CPlusPlus/LibCxxList.cpp | 83 --- .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 68 +++ .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 62 +- .../Language/CPlusPlus/LibCxxVector.cpp | 40 + .../list/TestDataFormatterGenericList.py | 3 +- .../libcxx/string/simulator/main.cpp | 1 + .../TestDataFormatterLibcxxUniquePtr.py | 7 +- 9 files changed, 246 insertions(+), 105 deletions(-) diff --git a/lldb/examples/synthetic/libcxx.py b/lldb/examples/synthetic/libcxx.py index 474aaa428fa23a..060ff901008497 100644 --- a/lldb/examples/synthetic/libcxx.py +++ b/lldb/examples/synthetic/libcxx.py @@ -721,6 +721,12 @@ def _get_value_of_compressed_pair(self, pair): def update(self): logger = lldb.formatters.Logger.Logger() try: +has_compressed_pair_layout = True +alloc_valobj = self.valobj.GetChildMemberWithName("__alloc_") +size_valobj = self.valobj.GetChildMemberWithName("__size_") +if alloc_valobj.IsValid() and size_valobj.IsValid(): +has_compressed_pair_layout = False + # A deque is effectively a two-dim array, with fixed width. # 'map' contains pointers to the rows of this array. The # full memory area allocated by the deque is delimited @@ -734,9 +740,13 @@ def update(self): # variable tells which element in this NxM array is the 0th # one, and the 'size' element gives the number of elements # in the deque. -count = self._get_value_of_compressed_pair( -self.valobj.GetChildMemberWithName("__size_") -) +if has_compressed_pair_layout: +count = self._get_value_of_compressed_pair( +self.valobj.GetChildMemberWithName("__size_") +) +else: +count = size_valobj.GetValueAsUnsigned(0) + # give up now if we cant access memory reliably if self.block_size < 0: logger.write("block_size < 0") @@ -748,9 +758,13 @@ def update(self): self.map_begin = map_.GetChildMemberWithName("__begin_") map_begin = self.map_begin.GetValueAsUnsigned(0) map_end = map_.GetChildMemberWithName("__end_").GetValueAsUnsigned(0) -map_endcap = self._get_value_of_compressed_pair( -map_.GetChildMemberWithName("__end_cap_") -) + +if has_compressed_pair_layout: +map_endcap = self._get_value_of_compressed_pair( +map_.GetChildMemberWithName("__end_cap_") +) +else: +map_endcap = map_.GetChildMemberWithName("__end_cap_").GetValueAsUnsigned(0) # check consistency if not map_first <= map_begin <= map_end <= map_endcap: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 0f9f93b727ce86..1eee1d9cec7e82 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -27,6 +27,7 @@ #include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" #include #include @@ -176,9 +177,9 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( if (!ptr_sp) return false; - ptr_sp = GetFirstValueOfLibCXXCompressedPair(*ptr_sp); - if (!ptr_sp) -return false; + if (ValueObjectSP compressed_pair_value__sp = + GetFirstValueOfLibCXXCompressedPair(*ptr_sp)) +ptr_sp = std::move(compressed_pair_value__sp); if (ptr_sp->GetValueAsUnsigned(0) == 0) { stream.Printf("nullptr"); @@ -701,15 +702,28 @@ lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update() { if (!ptr_sp) return lldb::ChildCacheState::eRefetch; + bool has_compressed_pair_layout = true; + ValueObjectSP deleter_sp(valobj_sp->GetChildMemberWithName("__deleter_")); + if (deleter_sp) +has_compressed_pair_layout = false; + // Retrieve the actual pointer and the deleter, and clone them to give them // user-friendly
[Lldb-commits] [lldb] [lldb][DataFormatter] Simplify std::unordered_map::iterator formatter (PR #97754)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff fbd1b6567ae41d64f1dbb6b32c7cf8a1b710b8d9 9e66b1c4787ad49b7f4ffab9f87746d7c59a4fd5 -- lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxx.h lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp index 534a22f98f..19ef2f556f 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp @@ -34,7 +34,7 @@ int main() sium["hello"] = 137; int_vector iv; - iv.push_back(3); +iv.push_back(3); string_vector sv; sv.push_back("hello"); @@ -45,7 +45,7 @@ int main() si_umap_iter siumI = sium.begin(); ivter ivI = iv.begin(); - svter svI = sv.begin(); +svter svI = sv.begin(); return 0; // Set break point at this line. } `` https://github.com/llvm/llvm-project/pull/97754 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DataFormatter] Simplify std::unordered_map::iterator formatter (PR #97754)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes Depends on https://github.com/llvm/llvm-project/pull/97752 This patch changes the way we retrieve the key/value pair in the `std::unordered_map::iterator` formatter (similar to how we are changing it for `std::map::iterator` in https://github.com/llvm/llvm-project/pull/97713, the motivations being the same). The `std::unordered_map` already does it this way, so we align the iterator counterpart to do the same. --- Full diff: https://github.com/llvm/llvm-project/pull/97754.diff 5 Files Affected: - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp (-149) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.h (+4-50) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp (+150) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py (+16) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp (+19-6) ``diff diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 05cfa0568c25d..feaa51a96843a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -202,155 +202,6 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( return true; } -lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp) { - if (valobj_sp) -Update(); -} - -lldb::ChildCacheState lldb_private::formatters:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd::Update() { - m_pair_sp.reset(); - m_iter_ptr = nullptr; - - ValueObjectSP valobj_sp = m_backend.GetSP(); - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - TargetSP target_sp(valobj_sp->GetTargetSP()); - - if (!target_sp) -return lldb::ChildCacheState::eRefetch; - - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - auto exprPathOptions = ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None); - - // This must be a ValueObject* because it is a child of the ValueObject we - // are producing children for it if were a ValueObjectSP, we would end up - // with a loop (iterator -> synthetic -> child -> parent == iterator) and - // that would in turn leak memory by never allowing the ValueObjects to die - // and free their memory. - m_iter_ptr = - valobj_sp - ->GetValueForExpressionPath(".__i_.__node_", nullptr, nullptr, - exprPathOptions, nullptr) - .get(); - - if (m_iter_ptr) { -auto iter_child(valobj_sp->GetChildMemberWithName("__i_")); -if (!iter_child) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -CompilerType node_type(iter_child->GetCompilerType() - .GetTypeTemplateArgument(0) - .GetPointeeType()); - -CompilerType pair_type(node_type.GetTypeTemplateArgument(0)); - -std::string name; -uint64_t bit_offset_ptr; -uint32_t bitfield_bit_size_ptr; -bool is_bitfield_ptr; - -pair_type = pair_type.GetFieldAtIndex( -0, name, _offset_ptr, _bit_size_ptr, _bitfield_ptr); -if (!pair_type) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -uint64_t addr = m_iter_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); -m_iter_ptr = nullptr; - -if (addr == 0 || addr == LLDB_INVALID_ADDRESS) - return lldb::ChildCacheState::eRefetch; - -auto ts = pair_type.GetTypeSystem(); -auto ast_ctx = ts.dyn_cast_or_null(); -if (!ast_ctx) - return lldb::ChildCacheState::eRefetch; - -// Mimick layout of std::__hash_iterator::__node_ and read it in -// from process memory. -// -// The following shows the contiguous block of memory: -// -// +-+ class __hash_node_base -// __node_ | __next_pointer __next_; | -// +-+ class __hash_node -// | size_t __hash_; | -// | __node_value_type __value_; | <<< our key/value pair -// +-+ -// -CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( -llvm::StringRef(), -{{"__next_", - ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, - {"__hash_", ast_ctx->GetBasicType(lldb::eBasicTypeUnsignedLongLong)}, -
[Lldb-commits] [lldb] [lldb][DataFormatter] Simplify std::unordered_map::iterator formatter (PR #97754)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/97754 Depends on https://github.com/llvm/llvm-project/pull/97752 This patch changes the way we retrieve the key/value pair in the `std::unordered_map::iterator` formatter (similar to how we are changing it for `std::map::iterator` in https://github.com/llvm/llvm-project/pull/97713, the motivations being the same). The `std::unordered_map` already does it this way, so we align the iterator counterpart to do the same. >From b10f76bd6d02106e80315a70a7b72461cb6f2a99 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 4 Jul 2024 13:35:21 +0200 Subject: [PATCH 1/2] [lldb][DataFormatter] Move std::unordered_map::iterator formatter into LibCxxUnorderedMap.cpp --- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 149 - .../Plugins/Language/CPlusPlus/LibCxx.h | 54 + .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 196 ++ 3 files changed, 200 insertions(+), 199 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 05cfa0568c25d..feaa51a96843a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -202,155 +202,6 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( return true; } -lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp) { - if (valobj_sp) -Update(); -} - -lldb::ChildCacheState lldb_private::formatters:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd::Update() { - m_pair_sp.reset(); - m_iter_ptr = nullptr; - - ValueObjectSP valobj_sp = m_backend.GetSP(); - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - TargetSP target_sp(valobj_sp->GetTargetSP()); - - if (!target_sp) -return lldb::ChildCacheState::eRefetch; - - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - auto exprPathOptions = ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None); - - // This must be a ValueObject* because it is a child of the ValueObject we - // are producing children for it if were a ValueObjectSP, we would end up - // with a loop (iterator -> synthetic -> child -> parent == iterator) and - // that would in turn leak memory by never allowing the ValueObjects to die - // and free their memory. - m_iter_ptr = - valobj_sp - ->GetValueForExpressionPath(".__i_.__node_", nullptr, nullptr, - exprPathOptions, nullptr) - .get(); - - if (m_iter_ptr) { -auto iter_child(valobj_sp->GetChildMemberWithName("__i_")); -if (!iter_child) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -CompilerType node_type(iter_child->GetCompilerType() - .GetTypeTemplateArgument(0) - .GetPointeeType()); - -CompilerType pair_type(node_type.GetTypeTemplateArgument(0)); - -std::string name; -uint64_t bit_offset_ptr; -uint32_t bitfield_bit_size_ptr; -bool is_bitfield_ptr; - -pair_type = pair_type.GetFieldAtIndex( -0, name, _offset_ptr, _bit_size_ptr, _bitfield_ptr); -if (!pair_type) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -uint64_t addr = m_iter_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); -m_iter_ptr = nullptr; - -if (addr == 0 || addr == LLDB_INVALID_ADDRESS) - return lldb::ChildCacheState::eRefetch; - -auto ts = pair_type.GetTypeSystem(); -auto ast_ctx = ts.dyn_cast_or_null(); -if (!ast_ctx) - return lldb::ChildCacheState::eRefetch; - -// Mimick layout of std::__hash_iterator::__node_ and read it in -// from process memory. -// -// The following shows the contiguous block of memory: -// -// +-+ class __hash_node_base -// __node_ | __next_pointer __next_; | -// +-+ class __hash_node -// | size_t __hash_; | -// | __node_value_type __value_; | <<< our key/value pair -// +-+ -// -CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( -llvm::StringRef(), -{{"__next_", - ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, - {"__hash_", ast_ctx->GetBasicType(lldb::eBasicTypeUnsignedLongLong)}, - {"__value_", pair_type}}); -std::optional size =
[Lldb-commits] [lldb] [lldb][DataFormatter] Move std::unordered_map::iterator formatter into LibCxxUnorderedMap.cpp (PR #97752)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes Similar to how we moved the `std::map::iterator` formatter in https://github.com/llvm/llvm-project/pull/97687, do the same for `std::unordered_map::iterator`. Again the `unordered_map` and `unordered_map::iterator` formatters try to do very similar things: retrieve data out of the map. The iterator formatter does this in a fragile way (similar to how `std::map` does it, see https://github.com/llvm/llvm-project/pull/97579). Thus we will be refactoring the `std::unordered_map::iterator` in upcoming patches. Having it in `LibCxxUnorderedMap` will allow us to re-use some of the logic (and we won't have to repeat some of the clarification comments). --- Full diff: https://github.com/llvm/llvm-project/pull/97752.diff 3 Files Affected: - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp (-149) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.h (+4-50) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp (+196) ``diff diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 05cfa0568c25d..feaa51a96843a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -202,155 +202,6 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( return true; } -lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp) { - if (valobj_sp) -Update(); -} - -lldb::ChildCacheState lldb_private::formatters:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd::Update() { - m_pair_sp.reset(); - m_iter_ptr = nullptr; - - ValueObjectSP valobj_sp = m_backend.GetSP(); - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - TargetSP target_sp(valobj_sp->GetTargetSP()); - - if (!target_sp) -return lldb::ChildCacheState::eRefetch; - - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - auto exprPathOptions = ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None); - - // This must be a ValueObject* because it is a child of the ValueObject we - // are producing children for it if were a ValueObjectSP, we would end up - // with a loop (iterator -> synthetic -> child -> parent == iterator) and - // that would in turn leak memory by never allowing the ValueObjects to die - // and free their memory. - m_iter_ptr = - valobj_sp - ->GetValueForExpressionPath(".__i_.__node_", nullptr, nullptr, - exprPathOptions, nullptr) - .get(); - - if (m_iter_ptr) { -auto iter_child(valobj_sp->GetChildMemberWithName("__i_")); -if (!iter_child) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -CompilerType node_type(iter_child->GetCompilerType() - .GetTypeTemplateArgument(0) - .GetPointeeType()); - -CompilerType pair_type(node_type.GetTypeTemplateArgument(0)); - -std::string name; -uint64_t bit_offset_ptr; -uint32_t bitfield_bit_size_ptr; -bool is_bitfield_ptr; - -pair_type = pair_type.GetFieldAtIndex( -0, name, _offset_ptr, _bit_size_ptr, _bitfield_ptr); -if (!pair_type) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -uint64_t addr = m_iter_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); -m_iter_ptr = nullptr; - -if (addr == 0 || addr == LLDB_INVALID_ADDRESS) - return lldb::ChildCacheState::eRefetch; - -auto ts = pair_type.GetTypeSystem(); -auto ast_ctx = ts.dyn_cast_or_null(); -if (!ast_ctx) - return lldb::ChildCacheState::eRefetch; - -// Mimick layout of std::__hash_iterator::__node_ and read it in -// from process memory. -// -// The following shows the contiguous block of memory: -// -// +-+ class __hash_node_base -// __node_ | __next_pointer __next_; | -// +-+ class __hash_node -// | size_t __hash_; | -// | __node_value_type __value_; | <<< our key/value pair -// +-+ -// -CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( -llvm::StringRef(), -{{"__next_", - ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, - {"__hash_", ast_ctx->GetBasicType(lldb::eBasicTypeUnsignedLongLong)}, -
[Lldb-commits] [lldb] [lldb][DataFormatter] Move std::unordered_map::iterator formatter into LibCxxUnorderedMap.cpp (PR #97752)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/97752 Similar to how we moved the `std::map::iterator` formatter in https://github.com/llvm/llvm-project/pull/97687, do the same for `std::unordered_map::iterator`. Again the `unordered_map` and `unordered_map::iterator` formatters try to do very similar things: retrieve data out of the map. The iterator formatter does this in a fragile way (similar to how `std::map` does it, see https://github.com/llvm/llvm-project/pull/97579). Thus we will be refactoring the `std::unordered_map::iterator` in upcoming patches. Having it in `LibCxxUnorderedMap` will allow us to re-use some of the logic (and we won't have to repeat some of the clarification comments). >From f62e9688284af9295aeee0987398805884c37a4f Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 4 Jul 2024 13:35:21 +0200 Subject: [PATCH] [lldb][DataFormatter] Move std::unordered_map::iterator formatter into LibCxxUnorderedMap.cpp --- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 149 - .../Plugins/Language/CPlusPlus/LibCxx.h | 54 + .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 196 ++ 3 files changed, 200 insertions(+), 199 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 05cfa0568c25d4..feaa51a96843ab 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -202,155 +202,6 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( return true; } -lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp) { - if (valobj_sp) -Update(); -} - -lldb::ChildCacheState lldb_private::formatters:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd::Update() { - m_pair_sp.reset(); - m_iter_ptr = nullptr; - - ValueObjectSP valobj_sp = m_backend.GetSP(); - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - TargetSP target_sp(valobj_sp->GetTargetSP()); - - if (!target_sp) -return lldb::ChildCacheState::eRefetch; - - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - auto exprPathOptions = ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None); - - // This must be a ValueObject* because it is a child of the ValueObject we - // are producing children for it if were a ValueObjectSP, we would end up - // with a loop (iterator -> synthetic -> child -> parent == iterator) and - // that would in turn leak memory by never allowing the ValueObjects to die - // and free their memory. - m_iter_ptr = - valobj_sp - ->GetValueForExpressionPath(".__i_.__node_", nullptr, nullptr, - exprPathOptions, nullptr) - .get(); - - if (m_iter_ptr) { -auto iter_child(valobj_sp->GetChildMemberWithName("__i_")); -if (!iter_child) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -CompilerType node_type(iter_child->GetCompilerType() - .GetTypeTemplateArgument(0) - .GetPointeeType()); - -CompilerType pair_type(node_type.GetTypeTemplateArgument(0)); - -std::string name; -uint64_t bit_offset_ptr; -uint32_t bitfield_bit_size_ptr; -bool is_bitfield_ptr; - -pair_type = pair_type.GetFieldAtIndex( -0, name, _offset_ptr, _bit_size_ptr, _bitfield_ptr); -if (!pair_type) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -uint64_t addr = m_iter_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); -m_iter_ptr = nullptr; - -if (addr == 0 || addr == LLDB_INVALID_ADDRESS) - return lldb::ChildCacheState::eRefetch; - -auto ts = pair_type.GetTypeSystem(); -auto ast_ctx = ts.dyn_cast_or_null(); -if (!ast_ctx) - return lldb::ChildCacheState::eRefetch; - -// Mimick layout of std::__hash_iterator::__node_ and read it in -// from process memory. -// -// The following shows the contiguous block of memory: -// -// +-+ class __hash_node_base -// __node_ | __next_pointer __next_; | -// +-+ class __hash_node -// | size_t __hash_; | -// | __node_value_type __value_; | <<< our key/value pair -// +-+ -// -CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( -llvm::StringRef(), -{{"__next_",
[Lldb-commits] [lldb] [lldb][DataFormatter][NFC] Move std::map iterator formatter into LibCxxMap.cpp (PR #97687)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/97687 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] fbd1b65 - [lldb][DataFormatter][NFC] Move std::map iterator formatter into LibCxxMap.cpp (#97687)
Author: Michael Buch Date: 2024-07-04T17:06:10+01:00 New Revision: fbd1b6567ae41d64f1dbb6b32c7cf8a1b710b8d9 URL: https://github.com/llvm/llvm-project/commit/fbd1b6567ae41d64f1dbb6b32c7cf8a1b710b8d9 DIFF: https://github.com/llvm/llvm-project/commit/fbd1b6567ae41d64f1dbb6b32c7cf8a1b710b8d9.diff LOG: [lldb][DataFormatter][NFC] Move std::map iterator formatter into LibCxxMap.cpp (#97687) The two formatters follow very similar techniques to retrieve data out of the map. We're changing this for `std::map` in https://github.com/llvm/llvm-project/pull/97579 and plan to change it in the same way for the iterator formatter. Having them in the same place will allow us to re-use some of the logic (and we won't have to repeat some of the clarification comments). Added: Modified: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxx.h lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp Removed: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index ad467c3966e60..05cfa0568c25d 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -202,194 +202,6 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( return true; } -/* - (lldb) fr var ibeg --raw --ptr-depth 1 - (std::__1::__map_iterator, - std::__1::allocator > >, std::__1::__tree_node, - std::__1::allocator > >, void *> *, long> >) ibeg = { - __i_ = { - __ptr_ = 0x000100103870 { - std::__1::__tree_node_base = { - std::__1::__tree_end_node *> = { - __left_ = 0x - } - __right_ = 0x - __parent_ = 0x0001001038b0 - __is_black_ = true - } - __value_ = { - first = 0 - second = { std::string } - */ - -lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd:: -LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp), m_pair_ptr(), m_pair_sp() { - if (valobj_sp) -Update(); -} - -lldb::ChildCacheState -lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() { - m_pair_sp.reset(); - m_pair_ptr = nullptr; - - ValueObjectSP valobj_sp = m_backend.GetSP(); - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - TargetSP target_sp(valobj_sp->GetTargetSP()); - - if (!target_sp) -return lldb::ChildCacheState::eRefetch; - - // this must be a ValueObject* because it is a child of the ValueObject we - // are producing children for it if were a ValueObjectSP, we would end up - // with a loop (iterator -> synthetic -> child -> parent == iterator) and - // that would in turn leak memory by never allowing the ValueObjects to die - // and free their memory - m_pair_ptr = valobj_sp - ->GetValueForExpressionPath( - ".__i_.__ptr_->__value_", nullptr, nullptr, - ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None), - nullptr) - .get(); - - if (!m_pair_ptr) { -m_pair_ptr = valobj_sp - ->GetValueForExpressionPath( - ".__i_.__ptr_", nullptr, nullptr, - ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None), - nullptr) - .get(); -if (m_pair_ptr) { - auto __i_(valobj_sp->GetChildMemberWithName("__i_")); - if (!__i_) { -m_pair_ptr = nullptr; -return lldb::ChildCacheState::eRefetch; - } - CompilerType pair_type( - __i_->GetCompilerType().GetTypeTemplateArgument(0)); - std::string name; - uint64_t bit_offset_ptr; - uint32_t bitfield_bit_size_ptr; - bool is_bitfield_ptr; - pair_type = pair_type.GetFieldAtIndex( - 0, name, _offset_ptr, _bit_size_ptr, _bitfield_ptr); - if (!pair_type) { -m_pair_ptr = nullptr; -return lldb::ChildCacheState::eRefetch; - } - - auto addr(m_pair_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS)); - m_pair_ptr = nullptr; - if (addr && addr != LLDB_INVALID_ADDRESS) { -auto ts = pair_type.GetTypeSystem(); -auto ast_ctx = ts.dyn_cast_or_null(); -if (!ast_ctx) - return lldb::ChildCacheState::eRefetch; - -// Mimick layout of
[Lldb-commits] [lldb] [lldb][DataFormatter][NFC] Move std::map iterator formatter into LibCxxMap.cpp (PR #97687)
https://github.com/jasonmolenda approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/97687 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)
https://github.com/walter-erquinigo closed https://github.com/llvm/llvm-project/pull/97675 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 94a067a - [LLDB] Support exception breakpoints for plugin-provided languages (#97675)
Author: Walter Erquinigo Date: 2024-07-04T10:05:01-04:00 New Revision: 94a067a306fecceac913cc6d9bfdcd49464358ec URL: https://github.com/llvm/llvm-project/commit/94a067a306fecceac913cc6d9bfdcd49464358ec DIFF: https://github.com/llvm/llvm-project/commit/94a067a306fecceac913cc6d9bfdcd49464358ec.diff LOG: [LLDB] Support exception breakpoints for plugin-provided languages (#97675) CommandObjectBreakpoint has a harcoded list of languages for which exception breakpoints can be enabled. I'm making this a bit more generic so that my Mojo plugin can get this feature. Basically, I'm adding a new overridable method `Language::SupportsExceptionBreakpoints` that can be used by language plugins to determine whether they support this feature or not. This method is used in addition to the hardcoded list and, as an example, I'm using it for the ObjC language support. Another route is simply to avoid doing the check that it's being done right now and simply try to the create the exception breakpoint for whatever language that is not in the hardcoded list. I'm happy to do that if the reviewers think it's a good idea. As a note, the other possible place for adding this `SupportsExceptionBreakpoints` method is in `LanguageRuntime`. However, accessing it requires having a process, which is not always the case when invoking the `breakpoint set -E` command. The process might not be alive yet, so `Language` is a good second place for this. And as a final note, I don't want to make this `SupportsExceptionBreakpoints` complicated. I'm keeping it as simple as possible because it can easily evolve as it's not part of the public API. Added: Modified: lldb/include/lldb/Target/Language.h lldb/source/Commands/CommandObjectBreakpoint.cpp lldb/source/Plugins/Language/ObjC/ObjCLanguage.h Removed: diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index ff7c60bf68bfc9..2d6e5a40a0c0e4 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -363,6 +363,10 @@ class Language : public PluginInterface { return false; } + /// Returns true if this Language supports exception breakpoints via a + /// corresponding LanguageRuntime plugin. + virtual bool SupportsExceptionBreakpoints() const { return false; } + protected: // Classes that inherit from Language can see and modify these diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index cd4c7790f447e1..a5fe9273fac76d 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -308,9 +308,6 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { case eLanguageTypeC_plus_plus_14: m_exception_language = eLanguageTypeC_plus_plus; break; -case eLanguageTypeObjC: - m_exception_language = eLanguageTypeObjC; - break; case eLanguageTypeObjC_plus_plus: error_context = "Set exception breakpoints separately for c++ and objective-c"; @@ -319,6 +316,12 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { error_context = "Unknown language type for exception breakpoint"; break; default: + if (Language *languagePlugin = Language::FindPlugin(language)) { +if (languagePlugin->SupportsExceptionBreakpoints()) { + m_exception_language = language; + break; +} + } error_context = "Unsupported language type for exception breakpoint"; } if (!error_context.empty()) diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h index a50f4b036108d7..a61d0f128370d4 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h @@ -194,6 +194,8 @@ class ObjCLanguage : public Language { llvm::StringRef GetInstanceVariableName() override { return "self"; } + bool SupportsExceptionBreakpoints() const override { return true; } + // PluginInterface protocol llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); } }; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)
walter-erquinigo wrote: > And does this list include languages that are not plugin provided? The hardcoded list in the file being changes includes C++ and Objc in its various variants. > I was wondering why only Objective C changed, but if the rest are not plugins > then this makes sense. That was the only simple example I could use to show how this change does work. Thanks for the review! https://github.com/llvm/llvm-project/pull/97675 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)
@@ -319,6 +316,12 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { error_context = "Unknown language type for exception breakpoint"; break; default: + if (Language *languagePlugin = Language::FindPlugin(language)) { walter-erquinigo wrote: Within switch statements I tend to be very paranoid with braces https://github.com/llvm/llvm-project/pull/97675 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)
https://github.com/walter-erquinigo updated https://github.com/llvm/llvm-project/pull/97675 >From 5d1a7254d1e1a541a7b901be0d3a84eab42474b2 Mon Sep 17 00:00:00 2001 From: walter erquinigo Date: Thu, 4 Jul 2024 00:34:14 -0400 Subject: [PATCH 1/2] [LLDB] Support exception breakpoints for plugin-provided languages CommandObjectBreakpoint has a harcoded list of languages for which exception breakpoints can be enabled. I'm making this a bit more generic so that my Mojo plugin can get this feature. Basically, I'm adding a new overridable method `Language::SupportsExceptionBreakpoints` that can be used by language plugins to determine whether they support this feature or not. This method is used in addition to the hardcoded list and, as an example, I'm using it for the ObjC language support. Another route is simply to avoid doing the check that it's being done right now and simply try to the create the exception breakpoint for whatever language that is not in the hardcoded list. I'm happy to do that if the reviewers think it's a good idea. As a note, the other possible place for adding this `SupportsExceptionBreakpoints` method is in `LanguageRuntime`. However, accessing it requires having a process, which is not always the case when invoking the `breakpoint set -E` command. The process might not be alive yet, so `Language` is a good second place for this. And as a final note, I don't want to make this `SupportsExceptionBreakpoints` complicated. I'm keeping it as simple as possible because it can easily evolve as it's not part of the public API. --- lldb/include/lldb/Target/Language.h | 6 +- lldb/source/Commands/CommandObjectBreakpoint.cpp | 9 ++--- lldb/source/Plugins/Language/ObjC/ObjCLanguage.h | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index ff7c60bf68bfc..9c2c765ce497f 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -245,7 +245,7 @@ class Language : public PluginInterface { // a match. But we wouldn't want this to match AnotherA::my_function. The // user is specifying a truncated path, not a truncated set of characters. // This function does a language-aware comparison for those purposes. - virtual bool DemangledNameContainsPath(llvm::StringRef path, + virtual bool DemangledNameContainsPath(llvm::StringRef path, ConstString demangled) const; // if a language has a custom format for printing variable declarations that @@ -363,6 +363,10 @@ class Language : public PluginInterface { return false; } + /// Returns true if this Language supports exception breakpoints via a + /// corresponding LanguageRuntime plugin. + virtual bool SupportsExceptionBreakpoints() const { return false; } + protected: // Classes that inherit from Language can see and modify these diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index cd4c7790f447e..a5fe9273fac76 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -308,9 +308,6 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { case eLanguageTypeC_plus_plus_14: m_exception_language = eLanguageTypeC_plus_plus; break; -case eLanguageTypeObjC: - m_exception_language = eLanguageTypeObjC; - break; case eLanguageTypeObjC_plus_plus: error_context = "Set exception breakpoints separately for c++ and objective-c"; @@ -319,6 +316,12 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { error_context = "Unknown language type for exception breakpoint"; break; default: + if (Language *languagePlugin = Language::FindPlugin(language)) { +if (languagePlugin->SupportsExceptionBreakpoints()) { + m_exception_language = language; + break; +} + } error_context = "Unsupported language type for exception breakpoint"; } if (!error_context.empty()) diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h index a50f4b036108d..a61d0f128370d 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h @@ -194,6 +194,8 @@ class ObjCLanguage : public Language { llvm::StringRef GetInstanceVariableName() override { return "self"; } + bool SupportsExceptionBreakpoints() const override { return true; } + // PluginInterface protocol llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); } }; >From e99702d0cafaaa87e06a845e3f3e14868f9e800b Mon Sep 17 00:00:00 2001 From: Walter Erquinigo Date: Thu, 4 Jul 2024 10:02:45 -0400
[Lldb-commits] [lldb] [lldb][DataFormatter] Simplify libc++ std::map::iterator formatter (PR #97713)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes Depends on https://github.com/llvm/llvm-project/pull/97687 Similar to https://github.com/llvm/llvm-project/pull/97579, this patch simplifies the way in which we retrieve the key/value pair of a `std::map` (in this case of the `std::map::iterator`). We do this for the same reason: not only was the old logic hard to follow, and encoded the libc++ layout in non-obvious ways, it was also fragile to alignment miscalculations (https://github.com/llvm/llvm-project/pull/97443); this would break once the new layout of std::map landed as part of https://github.com/llvm/llvm-project/issues/93069. Instead, this patch simply casts the `__iter_pointer` to the `__node_pointer` and uses a straightforward `GetChildMemberWithName("__value_")` to get to the key/value we care about. We can eventually re-use the core-part of the `std::map` and `std::map::iterator` formatters. But it will be an easier to change to review once both simplifications landed. --- Full diff: https://github.com/llvm/llvm-project/pull/97713.diff 4 Files Affected: - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp (-188) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.h (+4-25) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp (+115) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py (+10) ``diff diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index ad467c3966e60..05cfa0568c25d 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -202,194 +202,6 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( return true; } -/* - (lldb) fr var ibeg --raw --ptr-depth 1 - (std::__1::__map_iterator, - std::__1::allocator > >, std::__1::__tree_node, - std::__1::allocator > >, void *> *, long> >) ibeg = { - __i_ = { - __ptr_ = 0x000100103870 { - std::__1::__tree_node_base = { - std::__1::__tree_end_node *> = { - __left_ = 0x - } - __right_ = 0x - __parent_ = 0x0001001038b0 - __is_black_ = true - } - __value_ = { - first = 0 - second = { std::string } - */ - -lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd:: -LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp), m_pair_ptr(), m_pair_sp() { - if (valobj_sp) -Update(); -} - -lldb::ChildCacheState -lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() { - m_pair_sp.reset(); - m_pair_ptr = nullptr; - - ValueObjectSP valobj_sp = m_backend.GetSP(); - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - TargetSP target_sp(valobj_sp->GetTargetSP()); - - if (!target_sp) -return lldb::ChildCacheState::eRefetch; - - // this must be a ValueObject* because it is a child of the ValueObject we - // are producing children for it if were a ValueObjectSP, we would end up - // with a loop (iterator -> synthetic -> child -> parent == iterator) and - // that would in turn leak memory by never allowing the ValueObjects to die - // and free their memory - m_pair_ptr = valobj_sp - ->GetValueForExpressionPath( - ".__i_.__ptr_->__value_", nullptr, nullptr, - ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None), - nullptr) - .get(); - - if (!m_pair_ptr) { -m_pair_ptr = valobj_sp - ->GetValueForExpressionPath( - ".__i_.__ptr_", nullptr, nullptr, - ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None), - nullptr) - .get(); -if (m_pair_ptr) { - auto __i_(valobj_sp->GetChildMemberWithName("__i_")); - if (!__i_) { -m_pair_ptr = nullptr; -return lldb::ChildCacheState::eRefetch; - } - CompilerType pair_type( - __i_->GetCompilerType().GetTypeTemplateArgument(0)); - std::string name; - uint64_t bit_offset_ptr; - uint32_t bitfield_bit_size_ptr; - bool is_bitfield_ptr; - pair_type = pair_type.GetFieldAtIndex( - 0, name, _offset_ptr, _bit_size_ptr, _bitfield_ptr); - if
[Lldb-commits] [lldb] [lldb][DataFormatter] Simplify libc++ std::map::iterator formatter (PR #97713)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/97713 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Lldb/map iterator refactor (PR #97713)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/97713 Depends on https://github.com/llvm/llvm-project/pull/97687 Similar to https://github.com/llvm/llvm-project/pull/97579, this patch simplifies the way in which we retrieve the key/value pair of a `std::map` (in this case of the `std::map::iterator`). We do this for the same reason: not only was the old logic hard to follow, and encoded the libc++ layout in non-obvious ways, it was also fragile to alignment miscalculations (https://github.com/llvm/llvm-project/pull/97443); this would break once the new layout of std::map landed as part of https://github.com/llvm/llvm-project/issues/93069. Instead, this patch simply casts the `__iter_pointer` to the `__node_pointer` and uses a straightforward `GetChildMemberWithName("__value_")` to get to the key/value we care about. We can eventually re-use the core-part of the `std::map` and `std::map::iterator` formatters. But it will be an easier to change to review once both simplifications landed. >From f6b3e6055a9e2263f61e3f70d7a97ddbb7db5ab0 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 4 Jul 2024 09:30:19 +0200 Subject: [PATCH 1/2] [lldb][DataFormatter][NFC] Move std::map iterator formatter into LibCxxMap.cpp The two formatters follow very similar techniques to retrieve data out of the map. We're changing this for `std::map` in https://github.com/llvm/llvm-project/pull/97579 and plan to change it in the same way for the iterator formatter. Having them in the same place will allow us to re-use some of the logic (and we won't have to repeat some of the clarification comments). --- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 188 -- .../Plugins/Language/CPlusPlus/LibCxx.h | 29 +-- .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 187 + 3 files changed, 191 insertions(+), 213 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index ad467c3966e60..05cfa0568c25d 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -202,194 +202,6 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( return true; } -/* - (lldb) fr var ibeg --raw --ptr-depth 1 - (std::__1::__map_iterator, - std::__1::allocator > >, std::__1::__tree_node, - std::__1::allocator > >, void *> *, long> >) ibeg = { - __i_ = { - __ptr_ = 0x000100103870 { - std::__1::__tree_node_base = { - std::__1::__tree_end_node *> = { - __left_ = 0x - } - __right_ = 0x - __parent_ = 0x0001001038b0 - __is_black_ = true - } - __value_ = { - first = 0 - second = { std::string } - */ - -lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd:: -LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp), m_pair_ptr(), m_pair_sp() { - if (valobj_sp) -Update(); -} - -lldb::ChildCacheState -lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() { - m_pair_sp.reset(); - m_pair_ptr = nullptr; - - ValueObjectSP valobj_sp = m_backend.GetSP(); - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - TargetSP target_sp(valobj_sp->GetTargetSP()); - - if (!target_sp) -return lldb::ChildCacheState::eRefetch; - - // this must be a ValueObject* because it is a child of the ValueObject we - // are producing children for it if were a ValueObjectSP, we would end up - // with a loop (iterator -> synthetic -> child -> parent == iterator) and - // that would in turn leak memory by never allowing the ValueObjects to die - // and free their memory - m_pair_ptr = valobj_sp - ->GetValueForExpressionPath( - ".__i_.__ptr_->__value_", nullptr, nullptr, - ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None), - nullptr) - .get(); - - if (!m_pair_ptr) { -m_pair_ptr = valobj_sp - ->GetValueForExpressionPath( - ".__i_.__ptr_", nullptr, nullptr, - ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None), - nullptr) - .get(); -if (m_pair_ptr) { - auto __i_(valobj_sp->GetChildMemberWithName("__i_")); - if (!__i_) { -m_pair_ptr = nullptr;
[Lldb-commits] [lldb] 07b3e2c - [LLDB] XFail on Windows TestThreadAPI.py test_StepInstruction
Author: Muhammad Omair Javaid Date: 2024-07-04T15:59:05+05:00 New Revision: 07b3e2c0c68b93a3d4d89426dc7fd14cc31ca6be URL: https://github.com/llvm/llvm-project/commit/07b3e2c0c68b93a3d4d89426dc7fd14cc31ca6be DIFF: https://github.com/llvm/llvm-project/commit/07b3e2c0c68b93a3d4d89426dc7fd14cc31ca6be.diff LOG: [LLDB] XFail on Windows TestThreadAPI.py test_StepInstruction TestThreadAPI.py test_StepInstruction started failing after #97493 Following assertion fails but I am not sure if test will pass after changing the test. AssertionError: 'void __cdecl call_me(bool)' != 'call_me(bool)' I have marked it as xfail I ll run it on a Windows machine to find an appropriate fix. https://lab.llvm.org/buildbot/#/builders/141/builds/476 Added: Modified: lldb/test/API/python_api/thread/TestThreadAPI.py Removed: diff --git a/lldb/test/API/python_api/thread/TestThreadAPI.py b/lldb/test/API/python_api/thread/TestThreadAPI.py index d5fc77532d859..a74302263aa45 100644 --- a/lldb/test/API/python_api/thread/TestThreadAPI.py +++ b/lldb/test/API/python_api/thread/TestThreadAPI.py @@ -51,7 +51,8 @@ def test_negative_indexing(self): """Test SBThread.frame with negative indexes.""" self.build() self.validate_negative_indexing() - + +@expectedFailureAll(oslist=["windows"]) def test_StepInstruction(self): """Test that StepInstruction preserves the plan stack.""" self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)
@@ -319,6 +316,12 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { error_context = "Unknown language type for exception breakpoint"; break; default: + if (Language *languagePlugin = Language::FindPlugin(language)) { DavidSpickett wrote: You could drop the braces from the first if I think, but this is already in so many sets of braces I'd keep them for clarity's sake. https://github.com/llvm/llvm-project/pull/97675 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)
https://github.com/DavidSpickett approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/97675 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)
@@ -245,7 +245,7 @@ class Language : public PluginInterface { // a match. But we wouldn't want this to match AnotherA::my_function. The // user is specifying a truncated path, not a truncated set of characters. // This function does a language-aware comparison for those purposes. - virtual bool DemangledNameContainsPath(llvm::StringRef path, + virtual bool DemangledNameContainsPath(llvm::StringRef path, DavidSpickett wrote: Unrelated change. https://github.com/llvm/llvm-project/pull/97675 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)
DavidSpickett wrote: > This method is used in addition to the hardcoded list and, as an example, I'm > using it for the ObjC language support. And does this list include languages that are not plugin provided? I was wondering why only Objective C changed, but if the rest are not plugins then this makes sense. https://github.com/llvm/llvm-project/pull/97675 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 328d9f6 - Reland "[lldb] Print empty enums as if they were unrecognised normal enums (#97553)"
Author: David Spickett Date: 2024-07-04T08:51:23Z New Revision: 328d9f62976defb96cba8102ea54f44cf88c8032 URL: https://github.com/llvm/llvm-project/commit/328d9f62976defb96cba8102ea54f44cf88c8032 DIFF: https://github.com/llvm/llvm-project/commit/328d9f62976defb96cba8102ea54f44cf88c8032.diff LOG: Reland "[lldb] Print empty enums as if they were unrecognised normal enums (#97553)" This reverts commit 927def49728371d746476e79a6570cd93a4d335c. I've refactored the tests so that we're explicit about whether the enum is signed or not. Which means we use the proper types throughout. Added: Modified: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-missing-signature.test lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp Removed: diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 9c77a5d6e66ee..f70efe5ed57e4 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -8656,20 +8656,25 @@ static bool DumpEnumValue(const clang::QualType _type, Stream , // every enumerator is either a one bit value or a superset of the previous // enumerators. Also 0 doesn't make sense when the enumerators are used as // flags. - for (auto *enumerator : enum_decl->enumerators()) { -llvm::APSInt init_val = enumerator->getInitVal(); -uint64_t val = -qual_type_is_signed ? init_val.getSExtValue() : init_val.getZExtValue(); -if (qual_type_is_signed) - val = llvm::SignExtend64(val, 8 * byte_size); -if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0) - can_be_bitfield = false; -covered_bits |= val; -++num_enumerators; -if (val == enum_svalue) { - // Found an exact match, that's all we need to do. - s.PutCString(enumerator->getNameAsString()); - return true; + clang::EnumDecl::enumerator_range enumerators = enum_decl->enumerators(); + if (enumerators.empty()) +can_be_bitfield = false; + else { +for (auto *enumerator : enumerators) { + llvm::APSInt init_val = enumerator->getInitVal(); + uint64_t val = qual_type_is_signed ? init_val.getSExtValue() + : init_val.getZExtValue(); + if (qual_type_is_signed) +val = llvm::SignExtend64(val, 8 * byte_size); + if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0) +can_be_bitfield = false; + covered_bits |= val; + ++num_enumerators; + if (val == enum_svalue) { +// Found an exact match, that's all we need to do. +s.PutCString(enumerator->getNameAsString()); +return true; + } } } diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-missing-signature.test b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-missing-signature.test index 548dd6cdbc275..b2c792ed6003e 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-missing-signature.test +++ b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-missing-signature.test @@ -22,5 +22,5 @@ PRINTEC: use of undeclared identifier 'EC' RUN: %lldb %t -b -o "target variable a e ec" | FileCheck --check-prefix=VARS %s VARS: (const (unnamed struct)) a = -VARS: (const (unnamed enum)) e = 0x1 -VARS: (const (unnamed enum)) ec = 0x1 +VARS: (const (unnamed enum)) e = 1 +VARS: (const (unnamed enum)) ec = 1 diff --git a/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp b/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp index a7ccd74721f66..950e981a3f5a4 100644 --- a/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp +++ b/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp @@ -18,6 +18,8 @@ #include "gtest/gtest.h" +#include + using namespace lldb; using namespace lldb_private; @@ -70,28 +72,12 @@ class ValueObjectMockProcessTest : public ::testing::Test { m_type_system = m_holder->GetAST(); } - CompilerType - MakeEnumType(const std::vector> enumerators) { -CompilerType uint_type = m_type_system->GetBuiltinTypeForEncodingAndBitSize( -lldb::eEncodingUint, 32); -CompilerType enum_type = m_type_system->CreateEnumerationType( -"TestEnum", m_type_system->GetTranslationUnitDecl(), -OptionalClangModuleID(), Declaration(), uint_type, false); - -m_type_system->StartTagDeclarationDefinition(enum_type); -Declaration decl; -for (auto [name, value] : enumerators) - m_type_system->AddEnumerationValueToEnumerationType(enum_type, decl, name, - value, 32); -m_type_system->CompleteTagDeclarationDefinition(enum_type); - -return enum_type; - } - - void TestDumpValueObject( - CompilerType enum_type, - const std::vector< -
[Lldb-commits] [lldb] 927def4 - Revert "[lldb] Print empty enums as if they were unrecognised normal enums (#97553)"
Author: David Spickett Date: 2024-07-04T07:49:36Z New Revision: 927def49728371d746476e79a6570cd93a4d335c URL: https://github.com/llvm/llvm-project/commit/927def49728371d746476e79a6570cd93a4d335c DIFF: https://github.com/llvm/llvm-project/commit/927def49728371d746476e79a6570cd93a4d335c.diff LOG: Revert "[lldb] Print empty enums as if they were unrecognised normal enums (#97553)" This reverts commit 41fddc4ec3302f125a5b84ae86c8027dedc89984. Due to build errors with gcc passing signed ints to unsigned ints. Added: Modified: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-missing-signature.test lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp Removed: diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index f70efe5ed57e4..9c77a5d6e66ee 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -8656,25 +8656,20 @@ static bool DumpEnumValue(const clang::QualType _type, Stream , // every enumerator is either a one bit value or a superset of the previous // enumerators. Also 0 doesn't make sense when the enumerators are used as // flags. - clang::EnumDecl::enumerator_range enumerators = enum_decl->enumerators(); - if (enumerators.empty()) -can_be_bitfield = false; - else { -for (auto *enumerator : enumerators) { - llvm::APSInt init_val = enumerator->getInitVal(); - uint64_t val = qual_type_is_signed ? init_val.getSExtValue() - : init_val.getZExtValue(); - if (qual_type_is_signed) -val = llvm::SignExtend64(val, 8 * byte_size); - if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0) -can_be_bitfield = false; - covered_bits |= val; - ++num_enumerators; - if (val == enum_svalue) { -// Found an exact match, that's all we need to do. -s.PutCString(enumerator->getNameAsString()); -return true; - } + for (auto *enumerator : enum_decl->enumerators()) { +llvm::APSInt init_val = enumerator->getInitVal(); +uint64_t val = +qual_type_is_signed ? init_val.getSExtValue() : init_val.getZExtValue(); +if (qual_type_is_signed) + val = llvm::SignExtend64(val, 8 * byte_size); +if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0) + can_be_bitfield = false; +covered_bits |= val; +++num_enumerators; +if (val == enum_svalue) { + // Found an exact match, that's all we need to do. + s.PutCString(enumerator->getNameAsString()); + return true; } } diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-missing-signature.test b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-missing-signature.test index b2c792ed6003e..548dd6cdbc275 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-missing-signature.test +++ b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-missing-signature.test @@ -22,5 +22,5 @@ PRINTEC: use of undeclared identifier 'EC' RUN: %lldb %t -b -o "target variable a e ec" | FileCheck --check-prefix=VARS %s VARS: (const (unnamed struct)) a = -VARS: (const (unnamed enum)) e = 1 -VARS: (const (unnamed enum)) ec = 1 +VARS: (const (unnamed enum)) e = 0x1 +VARS: (const (unnamed enum)) ec = 0x1 diff --git a/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp b/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp index af6fa55bab171..a7ccd74721f66 100644 --- a/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp +++ b/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp @@ -71,13 +71,12 @@ class ValueObjectMockProcessTest : public ::testing::Test { } CompilerType - MakeEnumType(const std::vector> enumerators, - bool is_signed) { -CompilerType int_type = m_type_system->GetBuiltinTypeForEncodingAndBitSize( -is_signed ? lldb::eEncodingSint : lldb::eEncodingUint, 32); + MakeEnumType(const std::vector> enumerators) { +CompilerType uint_type = m_type_system->GetBuiltinTypeForEncodingAndBitSize( +lldb::eEncodingUint, 32); CompilerType enum_type = m_type_system->CreateEnumerationType( "TestEnum", m_type_system->GetTranslationUnitDecl(), -OptionalClangModuleID(), Declaration(), int_type, false); +OptionalClangModuleID(), Declaration(), uint_type, false); m_type_system->StartTagDeclarationDefinition(enum_type); Declaration decl; @@ -124,27 +123,12 @@ class ValueObjectMockProcessTest : public ::testing::Test { lldb::ProcessSP m_process_sp; }; -TEST_F(ValueObjectMockProcessTest, EmptyEnum) { - // All values of an empty enum should be shown as plain numbers. - TestDumpValueObject(MakeEnumType({}, false), - {{0, {},
[Lldb-commits] [lldb] [lldb][DataFormatter][NFC] Move std::map iterator formatter into LibCxxMap.cpp (PR #97687)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes The two formatters follow very similar techniques to retrieve data out of the map. We're changing this for `std::map` in https://github.com/llvm/llvm-project/pull/97579 and plan to change it in the same way for the iterator formatter. Having them in the same place will allow us to re-use some of the logic (and we won't have to repeat some of the clarification comments). --- Full diff: https://github.com/llvm/llvm-project/pull/97687.diff 3 Files Affected: - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp (-188) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.h (+4-25) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp (+187) ``diff diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index ad467c3966e60..05cfa0568c25d 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -202,194 +202,6 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( return true; } -/* - (lldb) fr var ibeg --raw --ptr-depth 1 - (std::__1::__map_iterator, - std::__1::allocator > >, std::__1::__tree_node, - std::__1::allocator > >, void *> *, long> >) ibeg = { - __i_ = { - __ptr_ = 0x000100103870 { - std::__1::__tree_node_base = { - std::__1::__tree_end_node *> = { - __left_ = 0x - } - __right_ = 0x - __parent_ = 0x0001001038b0 - __is_black_ = true - } - __value_ = { - first = 0 - second = { std::string } - */ - -lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd:: -LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp), m_pair_ptr(), m_pair_sp() { - if (valobj_sp) -Update(); -} - -lldb::ChildCacheState -lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() { - m_pair_sp.reset(); - m_pair_ptr = nullptr; - - ValueObjectSP valobj_sp = m_backend.GetSP(); - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - TargetSP target_sp(valobj_sp->GetTargetSP()); - - if (!target_sp) -return lldb::ChildCacheState::eRefetch; - - // this must be a ValueObject* because it is a child of the ValueObject we - // are producing children for it if were a ValueObjectSP, we would end up - // with a loop (iterator -> synthetic -> child -> parent == iterator) and - // that would in turn leak memory by never allowing the ValueObjects to die - // and free their memory - m_pair_ptr = valobj_sp - ->GetValueForExpressionPath( - ".__i_.__ptr_->__value_", nullptr, nullptr, - ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None), - nullptr) - .get(); - - if (!m_pair_ptr) { -m_pair_ptr = valobj_sp - ->GetValueForExpressionPath( - ".__i_.__ptr_", nullptr, nullptr, - ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None), - nullptr) - .get(); -if (m_pair_ptr) { - auto __i_(valobj_sp->GetChildMemberWithName("__i_")); - if (!__i_) { -m_pair_ptr = nullptr; -return lldb::ChildCacheState::eRefetch; - } - CompilerType pair_type( - __i_->GetCompilerType().GetTypeTemplateArgument(0)); - std::string name; - uint64_t bit_offset_ptr; - uint32_t bitfield_bit_size_ptr; - bool is_bitfield_ptr; - pair_type = pair_type.GetFieldAtIndex( - 0, name, _offset_ptr, _bit_size_ptr, _bitfield_ptr); - if (!pair_type) { -m_pair_ptr = nullptr; -return lldb::ChildCacheState::eRefetch; - } - - auto addr(m_pair_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS)); - m_pair_ptr = nullptr; - if (addr && addr != LLDB_INVALID_ADDRESS) { -auto ts = pair_type.GetTypeSystem(); -auto ast_ctx = ts.dyn_cast_or_null(); -if (!ast_ctx) - return lldb::ChildCacheState::eRefetch; - -// Mimick layout of std::__tree_iterator::__ptr_ and read it in -// from process memory. -// -// The following shows the contiguous block of memory: -// -//+-+ class __tree_end_node -// __ptr_ | pointer
[Lldb-commits] [lldb] [lldb][DataFormatter][NFC] Move std::map iterator formatter into LibCxxMap.cpp (PR #97687)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/97687 The two formatters follow very similar techniques to retrieve data out of the map. We're changing this for `std::map` in https://github.com/llvm/llvm-project/pull/97579 and plan to change it in the same way for the iterator formatter. Having them in the same place will allow us to re-use some of the logic (and we won't have to repeat some of the clarification comments). >From f6b3e6055a9e2263f61e3f70d7a97ddbb7db5ab0 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 4 Jul 2024 09:30:19 +0200 Subject: [PATCH] [lldb][DataFormatter][NFC] Move std::map iterator formatter into LibCxxMap.cpp The two formatters follow very similar techniques to retrieve data out of the map. We're changing this for `std::map` in https://github.com/llvm/llvm-project/pull/97579 and plan to change it in the same way for the iterator formatter. Having them in the same place will allow us to re-use some of the logic (and we won't have to repeat some of the clarification comments). --- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 188 -- .../Plugins/Language/CPlusPlus/LibCxx.h | 29 +-- .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 187 + 3 files changed, 191 insertions(+), 213 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index ad467c3966e609..05cfa0568c25d4 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -202,194 +202,6 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( return true; } -/* - (lldb) fr var ibeg --raw --ptr-depth 1 - (std::__1::__map_iterator, - std::__1::allocator > >, std::__1::__tree_node, - std::__1::allocator > >, void *> *, long> >) ibeg = { - __i_ = { - __ptr_ = 0x000100103870 { - std::__1::__tree_node_base = { - std::__1::__tree_end_node *> = { - __left_ = 0x - } - __right_ = 0x - __parent_ = 0x0001001038b0 - __is_black_ = true - } - __value_ = { - first = 0 - second = { std::string } - */ - -lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd:: -LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp), m_pair_ptr(), m_pair_sp() { - if (valobj_sp) -Update(); -} - -lldb::ChildCacheState -lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() { - m_pair_sp.reset(); - m_pair_ptr = nullptr; - - ValueObjectSP valobj_sp = m_backend.GetSP(); - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - TargetSP target_sp(valobj_sp->GetTargetSP()); - - if (!target_sp) -return lldb::ChildCacheState::eRefetch; - - // this must be a ValueObject* because it is a child of the ValueObject we - // are producing children for it if were a ValueObjectSP, we would end up - // with a loop (iterator -> synthetic -> child -> parent == iterator) and - // that would in turn leak memory by never allowing the ValueObjects to die - // and free their memory - m_pair_ptr = valobj_sp - ->GetValueForExpressionPath( - ".__i_.__ptr_->__value_", nullptr, nullptr, - ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None), - nullptr) - .get(); - - if (!m_pair_ptr) { -m_pair_ptr = valobj_sp - ->GetValueForExpressionPath( - ".__i_.__ptr_", nullptr, nullptr, - ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None), - nullptr) - .get(); -if (m_pair_ptr) { - auto __i_(valobj_sp->GetChildMemberWithName("__i_")); - if (!__i_) { -m_pair_ptr = nullptr; -return lldb::ChildCacheState::eRefetch; - } - CompilerType pair_type( - __i_->GetCompilerType().GetTypeTemplateArgument(0)); - std::string name; - uint64_t bit_offset_ptr; - uint32_t bitfield_bit_size_ptr; - bool is_bitfield_ptr; - pair_type = pair_type.GetFieldAtIndex( - 0, name, _offset_ptr, _bit_size_ptr, _bitfield_ptr); - if (!pair_type) { -m_pair_ptr = nullptr; -return lldb::ChildCacheState::eRefetch; - } - - auto addr(m_pair_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS)); -
[Lldb-commits] [lldb] [lldb][DataFormatter] Remove support for old std::map layout (PR #97549)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/97549 >From 5dc61f0721746359cbaa70e5f50dd15de4a1f082 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 3 Jul 2024 12:06:49 +0200 Subject: [PATCH 1/2] [lldb][DataFormatter] Remove support for old std::map layout We currently supported the layout from pre-2016 (before the layout change in 14caaddd3f08e798dcd9ac0ddfc). We have another upcoming layout change in `__tree` and `map` (as part of require rewriting parts of this formatter. Removing the support will make those changes more straightforward to review/maintain. Being backward compatible would be great but we have no tests that actually verify that the old layout still works (and our oldest matrix bot tests clang-15). If anyone feels strongly about keeping this layout, we could possibly factor out that logic and keep it around. --- .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 76 --- 1 file changed, 30 insertions(+), 46 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp index 6c2bc1a34137a..141b525da063b 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp @@ -248,11 +248,6 @@ bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() { deref = m_root_node->Dereference(error); if (!deref || error.Fail()) return false; - deref = deref->GetChildMemberWithName("__value_"); - if (deref) { -m_element_type = deref->GetCompilerType(); -return true; - } deref = m_backend.GetChildAtNamePath({"__tree_", "__pair3_"}); if (!deref) return false; @@ -280,40 +275,35 @@ void lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset( return; if (!node) return; + CompilerType node_type(node->GetCompilerType()); - uint64_t bit_offset; - if (node_type.GetIndexOfFieldWithName("__value_", nullptr, _offset) != - UINT32_MAX) { -// Old layout (pre d05b10ab4fc65) -m_skip_size = bit_offset / 8u; - } else { -auto ast_ctx = node_type.GetTypeSystem().dyn_cast_or_null(); -if (!ast_ctx) - return; -CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( -llvm::StringRef(), -{{"ptr0", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, - {"ptr1", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, - {"ptr2", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, - {"cw", ast_ctx->GetBasicType(lldb::eBasicTypeBool)}, - {"payload", (m_element_type.GetCompleteType(), m_element_type)}}); -std::string child_name; -uint32_t child_byte_size; -int32_t child_byte_offset = 0; -uint32_t child_bitfield_bit_size; -uint32_t child_bitfield_bit_offset; -bool child_is_base_class; -bool child_is_deref_of_parent; -uint64_t language_flags; -auto child_type = -llvm::expectedToStdOptional(tree_node_type.GetChildCompilerTypeAtIndex( -nullptr, 4, true, true, true, child_name, child_byte_size, -child_byte_offset, child_bitfield_bit_size, -child_bitfield_bit_offset, child_is_base_class, -child_is_deref_of_parent, nullptr, language_flags)); -if (child_type && child_type->IsValid()) - m_skip_size = (uint32_t)child_byte_offset; - } + auto ast_ctx = node_type.GetTypeSystem().dyn_cast_or_null(); + if (!ast_ctx) +return; + + CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( + llvm::StringRef(), + {{"ptr0", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, + {"ptr1", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, + {"ptr2", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, + {"cw", ast_ctx->GetBasicType(lldb::eBasicTypeBool)}, + {"payload", (m_element_type.GetCompleteType(), m_element_type)}}); + std::string child_name; + uint32_t child_byte_size; + int32_t child_byte_offset = 0; + uint32_t child_bitfield_bit_size; + uint32_t child_bitfield_bit_offset; + bool child_is_base_class; + bool child_is_deref_of_parent; + uint64_t language_flags; + auto child_type = + llvm::expectedToStdOptional(tree_node_type.GetChildCompilerTypeAtIndex( + nullptr, 4, true, true, true, child_name, child_byte_size, + child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset, + child_is_base_class, child_is_deref_of_parent, nullptr, + language_flags)); + if (child_type && child_type->IsValid()) +m_skip_size = (uint32_t)child_byte_offset; } ValueObjectSP @@ -348,14 +338,8 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetKeyValuePair( return nullptr; GetValueOffset(iterated_sp); -auto child_sp = iterated_sp->GetChildMemberWithName("__value_"); -if (child_sp) { - // Old
[Lldb-commits] [lldb] [lldb][DataFormatter] Remove support for old std::map layout (PR #97549)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/97549 >From 5dc61f0721746359cbaa70e5f50dd15de4a1f082 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 3 Jul 2024 12:06:49 +0200 Subject: [PATCH 1/2] [lldb][DataFormatter] Remove support for old std::map layout We currently supported the layout from pre-2016 (before the layout change in 14caaddd3f08e798dcd9ac0ddfc). We have another upcoming layout change in `__tree` and `map` (as part of require rewriting parts of this formatter. Removing the support will make those changes more straightforward to review/maintain. Being backward compatible would be great but we have no tests that actually verify that the old layout still works (and our oldest matrix bot tests clang-15). If anyone feels strongly about keeping this layout, we could possibly factor out that logic and keep it around. --- .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 76 --- 1 file changed, 30 insertions(+), 46 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp index 6c2bc1a34137a..141b525da063b 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp @@ -248,11 +248,6 @@ bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() { deref = m_root_node->Dereference(error); if (!deref || error.Fail()) return false; - deref = deref->GetChildMemberWithName("__value_"); - if (deref) { -m_element_type = deref->GetCompilerType(); -return true; - } deref = m_backend.GetChildAtNamePath({"__tree_", "__pair3_"}); if (!deref) return false; @@ -280,40 +275,35 @@ void lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset( return; if (!node) return; + CompilerType node_type(node->GetCompilerType()); - uint64_t bit_offset; - if (node_type.GetIndexOfFieldWithName("__value_", nullptr, _offset) != - UINT32_MAX) { -// Old layout (pre d05b10ab4fc65) -m_skip_size = bit_offset / 8u; - } else { -auto ast_ctx = node_type.GetTypeSystem().dyn_cast_or_null(); -if (!ast_ctx) - return; -CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( -llvm::StringRef(), -{{"ptr0", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, - {"ptr1", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, - {"ptr2", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, - {"cw", ast_ctx->GetBasicType(lldb::eBasicTypeBool)}, - {"payload", (m_element_type.GetCompleteType(), m_element_type)}}); -std::string child_name; -uint32_t child_byte_size; -int32_t child_byte_offset = 0; -uint32_t child_bitfield_bit_size; -uint32_t child_bitfield_bit_offset; -bool child_is_base_class; -bool child_is_deref_of_parent; -uint64_t language_flags; -auto child_type = -llvm::expectedToStdOptional(tree_node_type.GetChildCompilerTypeAtIndex( -nullptr, 4, true, true, true, child_name, child_byte_size, -child_byte_offset, child_bitfield_bit_size, -child_bitfield_bit_offset, child_is_base_class, -child_is_deref_of_parent, nullptr, language_flags)); -if (child_type && child_type->IsValid()) - m_skip_size = (uint32_t)child_byte_offset; - } + auto ast_ctx = node_type.GetTypeSystem().dyn_cast_or_null(); + if (!ast_ctx) +return; + + CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( + llvm::StringRef(), + {{"ptr0", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, + {"ptr1", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, + {"ptr2", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, + {"cw", ast_ctx->GetBasicType(lldb::eBasicTypeBool)}, + {"payload", (m_element_type.GetCompleteType(), m_element_type)}}); + std::string child_name; + uint32_t child_byte_size; + int32_t child_byte_offset = 0; + uint32_t child_bitfield_bit_size; + uint32_t child_bitfield_bit_offset; + bool child_is_base_class; + bool child_is_deref_of_parent; + uint64_t language_flags; + auto child_type = + llvm::expectedToStdOptional(tree_node_type.GetChildCompilerTypeAtIndex( + nullptr, 4, true, true, true, child_name, child_byte_size, + child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset, + child_is_base_class, child_is_deref_of_parent, nullptr, + language_flags)); + if (child_type && child_type->IsValid()) +m_skip_size = (uint32_t)child_byte_offset; } ValueObjectSP @@ -348,14 +338,8 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetKeyValuePair( return nullptr; GetValueOffset(iterated_sp); -auto child_sp = iterated_sp->GetChildMemberWithName("__value_"); -if (child_sp) { - // Old
[Lldb-commits] [lldb] 30df629 - [lldb][DataFormatter][NFC] Remove duplicate null-check in std::map iterator formatter
Author: Michael Buch Date: 2024-07-04T08:51:28+02:00 New Revision: 30df62992e890310550259afbe458b845c0d6b89 URL: https://github.com/llvm/llvm-project/commit/30df62992e890310550259afbe458b845c0d6b89 DIFF: https://github.com/llvm/llvm-project/commit/30df62992e890310550259afbe458b845c0d6b89.diff LOG: [lldb][DataFormatter][NFC] Remove duplicate null-check in std::map iterator formatter The nullness is already checked a few lines before this. Added: Modified: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp Removed: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 0f9f93b727ce8..ad467c3966e60 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -245,9 +245,6 @@ lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() { if (!target_sp) return lldb::ChildCacheState::eRefetch; - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - // this must be a ValueObject* because it is a child of the ValueObject we // are producing children for it if were a ValueObjectSP, we would end up // with a loop (iterator -> synthetic -> child -> parent == iterator) and ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Walter Erquinigo (walter-erquinigo) Changes CommandObjectBreakpoint has a harcoded list of languages for which exception breakpoints can be enabled. I'm making this a bit more generic so that my Mojo plugin can get this feature. Basically, I'm adding a new overridable method `Language::SupportsExceptionBreakpoints` that can be used by language plugins to determine whether they support this feature or not. This method is used in addition to the hardcoded list and, as an example, I'm using it for the ObjC language support. Another route is simply to avoid doing the check that it's being done right now and simply try to the create the exception breakpoint for whatever language that is not in the hardcoded list. I'm happy to do that if the reviewers think it's a good idea. As a note, the other possible place for adding this `SupportsExceptionBreakpoints` method is in `LanguageRuntime`. However, accessing it requires having a process, which is not always the case when invoking the `breakpoint set -E` command. The process might not be alive yet, so `Language` is a good second place for this. And as a final note, I don't want to make this `SupportsExceptionBreakpoints` complicated. I'm keeping it as simple as possible because it can easily evolve as it's not part of the public API. --- Full diff: https://github.com/llvm/llvm-project/pull/97675.diff 3 Files Affected: - (modified) lldb/include/lldb/Target/Language.h (+5-1) - (modified) lldb/source/Commands/CommandObjectBreakpoint.cpp (+6-3) - (modified) lldb/source/Plugins/Language/ObjC/ObjCLanguage.h (+2) ``diff diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index ff7c60bf68bfc..9c2c765ce497f 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -245,7 +245,7 @@ class Language : public PluginInterface { // a match. But we wouldn't want this to match AnotherA::my_function. The // user is specifying a truncated path, not a truncated set of characters. // This function does a language-aware comparison for those purposes. - virtual bool DemangledNameContainsPath(llvm::StringRef path, + virtual bool DemangledNameContainsPath(llvm::StringRef path, ConstString demangled) const; // if a language has a custom format for printing variable declarations that @@ -363,6 +363,10 @@ class Language : public PluginInterface { return false; } + /// Returns true if this Language supports exception breakpoints via a + /// corresponding LanguageRuntime plugin. + virtual bool SupportsExceptionBreakpoints() const { return false; } + protected: // Classes that inherit from Language can see and modify these diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index cd4c7790f447e..a5fe9273fac76 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -308,9 +308,6 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { case eLanguageTypeC_plus_plus_14: m_exception_language = eLanguageTypeC_plus_plus; break; -case eLanguageTypeObjC: - m_exception_language = eLanguageTypeObjC; - break; case eLanguageTypeObjC_plus_plus: error_context = "Set exception breakpoints separately for c++ and objective-c"; @@ -319,6 +316,12 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { error_context = "Unknown language type for exception breakpoint"; break; default: + if (Language *languagePlugin = Language::FindPlugin(language)) { +if (languagePlugin->SupportsExceptionBreakpoints()) { + m_exception_language = language; + break; +} + } error_context = "Unsupported language type for exception breakpoint"; } if (!error_context.empty()) diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h index a50f4b036108d..a61d0f128370d 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h @@ -194,6 +194,8 @@ class ObjCLanguage : public Language { llvm::StringRef GetInstanceVariableName() override { return "self"; } + bool SupportsExceptionBreakpoints() const override { return true; } + // PluginInterface protocol llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); } }; `` https://github.com/llvm/llvm-project/pull/97675 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)
https://github.com/walter-erquinigo created https://github.com/llvm/llvm-project/pull/97675 CommandObjectBreakpoint has a harcoded list of languages for which exception breakpoints can be enabled. I'm making this a bit more generic so that my Mojo plugin can get this feature. Basically, I'm adding a new overridable method `Language::SupportsExceptionBreakpoints` that can be used by language plugins to determine whether they support this feature or not. This method is used in addition to the hardcoded list and, as an example, I'm using it for the ObjC language support. Another route is simply to avoid doing the check that it's being done right now and simply try to the create the exception breakpoint for whatever language that is not in the hardcoded list. I'm happy to do that if the reviewers think it's a good idea. As a note, the other possible place for adding this `SupportsExceptionBreakpoints` method is in `LanguageRuntime`. However, accessing it requires having a process, which is not always the case when invoking the `breakpoint set -E` command. The process might not be alive yet, so `Language` is a good second place for this. And as a final note, I don't want to make this `SupportsExceptionBreakpoints` complicated. I'm keeping it as simple as possible because it can easily evolve as it's not part of the public API. >From 5d1a7254d1e1a541a7b901be0d3a84eab42474b2 Mon Sep 17 00:00:00 2001 From: walter erquinigo Date: Thu, 4 Jul 2024 00:34:14 -0400 Subject: [PATCH] [LLDB] Support exception breakpoints for plugin-provided languages CommandObjectBreakpoint has a harcoded list of languages for which exception breakpoints can be enabled. I'm making this a bit more generic so that my Mojo plugin can get this feature. Basically, I'm adding a new overridable method `Language::SupportsExceptionBreakpoints` that can be used by language plugins to determine whether they support this feature or not. This method is used in addition to the hardcoded list and, as an example, I'm using it for the ObjC language support. Another route is simply to avoid doing the check that it's being done right now and simply try to the create the exception breakpoint for whatever language that is not in the hardcoded list. I'm happy to do that if the reviewers think it's a good idea. As a note, the other possible place for adding this `SupportsExceptionBreakpoints` method is in `LanguageRuntime`. However, accessing it requires having a process, which is not always the case when invoking the `breakpoint set -E` command. The process might not be alive yet, so `Language` is a good second place for this. And as a final note, I don't want to make this `SupportsExceptionBreakpoints` complicated. I'm keeping it as simple as possible because it can easily evolve as it's not part of the public API. --- lldb/include/lldb/Target/Language.h | 6 +- lldb/source/Commands/CommandObjectBreakpoint.cpp | 9 ++--- lldb/source/Plugins/Language/ObjC/ObjCLanguage.h | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index ff7c60bf68bfc..9c2c765ce497f 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -245,7 +245,7 @@ class Language : public PluginInterface { // a match. But we wouldn't want this to match AnotherA::my_function. The // user is specifying a truncated path, not a truncated set of characters. // This function does a language-aware comparison for those purposes. - virtual bool DemangledNameContainsPath(llvm::StringRef path, + virtual bool DemangledNameContainsPath(llvm::StringRef path, ConstString demangled) const; // if a language has a custom format for printing variable declarations that @@ -363,6 +363,10 @@ class Language : public PluginInterface { return false; } + /// Returns true if this Language supports exception breakpoints via a + /// corresponding LanguageRuntime plugin. + virtual bool SupportsExceptionBreakpoints() const { return false; } + protected: // Classes that inherit from Language can see and modify these diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index cd4c7790f447e..a5fe9273fac76 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -308,9 +308,6 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { case eLanguageTypeC_plus_plus_14: m_exception_language = eLanguageTypeC_plus_plus; break; -case eLanguageTypeObjC: - m_exception_language = eLanguageTypeObjC; - break; case eLanguageTypeObjC_plus_plus: error_context = "Set exception breakpoints separately for c++ and objective-c"; @@ -319,6 +316,12 @@ class
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
hekota wrote: > I see many places where extra cases have been added for the intangible types > but no corresponding tests. Is that ok? How did you know to update these > places? I looked at similar types in other languages, such as the `image*` types in [OpenCL](https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/OpenCLImageTypes.def) or `__externref_t` in [WebAssembly](https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/WebAssemblyReferenceTypes.def). I used the same implementation style and defaults as these types (except `__externref_t` is a typedef and not a language keyword). Some of the cases are tested when the two `builtin_hlsl_resource_t.hlsl` files are parsed and AST dumped, but it is not possible to test all case until we can actually use the type (llvm/llvm-project#84824). > I also don't see anywhere that actually successfully uses > `__builtin_hlsl_resource_t`. Am I missing it, or should I not expect to see > it? You are correct - the type cannot be directly declared in user code, so the tests only check for errors and that the type shows up properly in AST. It is possible to use this type internally in Clang or in implicit headers though, which are two ways how we could define `RWBuffer` and other builtin types that will internally use `__builtin_hlsl_resource_t` handle. That will come alive in (llvm/llvm-project#84824). https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits