[Lldb-commits] [lldb] [lldb] add settings to control how synthetic symbol names are generated (PR #137512)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Ely Ronnen (eronnen) Changes Adds a setting that makes lldb generate synthetic symbol names according to the file address of the function instead of the index, this could make it easier when debugging crashes and stack traces to understand which function the unnamed symbols corrresponds to --- Full diff: https://github.com/llvm/llvm-project/pull/137512.diff 6 Files Affected: - (modified) lldb/include/lldb/Core/ModuleList.h (+14) - (modified) lldb/include/lldb/Symbol/Symbol.h (+1) - (modified) lldb/include/lldb/lldb-enumerations.h (+6) - (modified) lldb/source/Core/CoreProperties.td (+5) - (modified) lldb/source/Core/ModuleList.cpp (+7) - (modified) lldb/source/Symbol/Symbol.cpp (+9-1) ``diff diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h index 909ee08f9ba62..23f64a153d47d 100644 --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -67,6 +67,19 @@ static constexpr OptionEnumValueElement g_auto_download_enum_values[] = { }, }; +static constexpr OptionEnumValueElement g_synthetic_symbols_name_style_values[] = { + { + lldb::eSyntheticSymbolsNameStyleIndex, + "index", + "Function index style", + }, + { +lldb::eSyntheticSymbolsNameStyleFileAddress, + "file-address", + "Function file address in module style", + }, +}; + class ModuleListProperties : public Properties { mutable llvm::sys::RWMutex m_symlink_paths_mutex; PathMappingList m_symlink_paths; @@ -91,6 +104,7 @@ class ModuleListProperties : public Properties { bool GetLoadSymbolOnDemand(); lldb::SymbolDownload GetSymbolAutoDownload() const; + lldb::SyntheticSymbolsNameStyle GetSyntheticSymbolsNameStyle() const; PathMappingList GetSymlinkMappings() const; }; diff --git a/lldb/include/lldb/Symbol/Symbol.h b/lldb/include/lldb/Symbol/Symbol.h index e05c845a69f3e..5c37b33e7442e 100644 --- a/lldb/include/lldb/Symbol/Symbol.h +++ b/lldb/include/lldb/Symbol/Symbol.h @@ -339,6 +339,7 @@ class Symbol : public SymbolContextScope { m_is_weak : 1, m_type : 6;// Values from the lldb::SymbolType enum. mutable Mangled m_mangled; // uniqued symbol name/mangled name pair + AddressRange m_addr_range; // Contains the value, or the section offset // address when the value is an address in a // section, and the size (if any) diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 6d10cc8bcffcb..26e83cefbe571 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -1391,6 +1391,12 @@ enum StopDisassemblyType { eStopDisassemblyTypeAlways }; +/// Format to use for unknown symbols. +enum SyntheticSymbolsNameStyle { + eSyntheticSymbolsNameStyleIndex = 0, + eSyntheticSymbolsNameStyleFileAddress = 1, +}; + } // namespace lldb #endif // LLDB_LLDB_ENUMERATIONS_H diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td index a1a4e994c3b9c..7eaecb729c36d 100644 --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -46,6 +46,11 @@ let Definition = "modulelist" in { Global, DefaultFalse, Desc<"Enable on demand symbol loading in LLDB. LLDB will load debug info on demand for each module based on various conditions (e.g. matched breakpoint, resolved stack frame addresses and matched global variables/function symbols in symbol table) to improve performance. Please refer to docs/use/ondemand.rst for details.">; + def SyntheticSymbolsNameStyle: Property<"synthetic-symbols-name-style", "Enum">, +Global, +DefaultEnumValue<"eSyntheticSymbolsNameStyleIndex">, +EnumValues<"OptionEnumValues(g_synthetic_symbols_name_style_values)">, +Desc<"Determines the way synthetic symbol names are generated for unknown symbols">; } let Definition = "debugger" in { diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 6052cc151744d..a507d1c2efaf5 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -115,6 +115,13 @@ SymbolDownload ModuleListProperties::GetSymbolAutoDownload() const { g_modulelist_properties[idx].default_uint_value)); } +lldb::SyntheticSymbolsNameStyle ModuleListProperties::GetSyntheticSymbolsNameStyle() const { + const uint32_t idx = ePropertySyntheticSymbolsNameStyle; + return GetPropertyAtIndexAs( + idx, static_cast( + g_modulelist_properties[idx].default_uint_value)); +} + FileSpec ModuleListProperties::GetClangModulesCachePath() const { const uint32_t idx = ePropertyClangModulesCachePath; return GetPropertyAtIndexAs(idx, {}); diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp index 4828de4fdfa37..0e17662ee14ba 100644 --- a/lldb/source/Symbol/Symbol.cpp +++ b/l
[Lldb-commits] [lldb] [lldb] add settings to control how synthetic symbol names are generated (PR #137512)
@@ -639,7 +639,18 @@ void Symbol::SynthesizeNameIfNeeded() const { // breakpoints on them. llvm::SmallString<256> name; llvm::raw_svector_ostream os(name); -os << GetSyntheticSymbolPrefix() << GetID(); +os << GetSyntheticSymbolPrefix(); +switch (ModuleList::GetGlobalModuleListProperties() eronnen wrote: Not sure whether it's better to cache this setting for the session or not https://github.com/llvm/llvm-project/pull/137512 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add settings to control how synthetic symbol names are generated (PR #137512)
https://github.com/eronnen deleted https://github.com/llvm/llvm-project/pull/137512 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add settings to control how synthetic symbol names are generated (PR #137512)
@@ -639,7 +639,18 @@ void Symbol::SynthesizeNameIfNeeded() const { // breakpoints on them. llvm::SmallString<256> name; llvm::raw_svector_ostream os(name); -os << GetSyntheticSymbolPrefix() << GetID(); +os << GetSyntheticSymbolPrefix(); eronnen wrote: Not sure whether it's better to cache this setting for the session or not https://github.com/llvm/llvm-project/pull/137512 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add settings to control how synthetic symbol names are generated (PR #137512)
https://github.com/eronnen updated https://github.com/llvm/llvm-project/pull/137512 >From fd74de70151567d402eb7c0326a6234a21cb2db7 Mon Sep 17 00:00:00 2001 From: Ely Ronnen Date: Sun, 27 Apr 2025 13:48:45 +0200 Subject: [PATCH] [lldb] add settings to control how synthetic symbol names are generated --- lldb/include/lldb/Core/ModuleList.h | 15 +++ lldb/include/lldb/lldb-enumerations.h | 6 ++ lldb/source/Core/CoreProperties.td| 5 + lldb/source/Core/ModuleList.cpp | 8 lldb/source/Symbol/Symbol.cpp | 13 - 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h index 909ee08f9ba62..baed175be5313 100644 --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -67,6 +67,20 @@ static constexpr OptionEnumValueElement g_auto_download_enum_values[] = { }, }; +static constexpr OptionEnumValueElement +g_synthetic_symbols_name_style_values[] = { +{ +lldb::eSyntheticSymbolsNameStyleIndex, +"index", +"Function index style", +}, +{ +lldb::eSyntheticSymbolsNameStyleFileAddress, +"file-address", +"Function file address in module style", +}, +}; + class ModuleListProperties : public Properties { mutable llvm::sys::RWMutex m_symlink_paths_mutex; PathMappingList m_symlink_paths; @@ -91,6 +105,7 @@ class ModuleListProperties : public Properties { bool GetLoadSymbolOnDemand(); lldb::SymbolDownload GetSymbolAutoDownload() const; + lldb::SyntheticSymbolsNameStyle GetSyntheticSymbolsNameStyle() const; PathMappingList GetSymlinkMappings() const; }; diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 6d10cc8bcffcb..26e83cefbe571 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -1391,6 +1391,12 @@ enum StopDisassemblyType { eStopDisassemblyTypeAlways }; +/// Format to use for unknown symbols. +enum SyntheticSymbolsNameStyle { + eSyntheticSymbolsNameStyleIndex = 0, + eSyntheticSymbolsNameStyleFileAddress = 1, +}; + } // namespace lldb #endif // LLDB_LLDB_ENUMERATIONS_H diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td index a1a4e994c3b9c..7eaecb729c36d 100644 --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -46,6 +46,11 @@ let Definition = "modulelist" in { Global, DefaultFalse, Desc<"Enable on demand symbol loading in LLDB. LLDB will load debug info on demand for each module based on various conditions (e.g. matched breakpoint, resolved stack frame addresses and matched global variables/function symbols in symbol table) to improve performance. Please refer to docs/use/ondemand.rst for details.">; + def SyntheticSymbolsNameStyle: Property<"synthetic-symbols-name-style", "Enum">, +Global, +DefaultEnumValue<"eSyntheticSymbolsNameStyleIndex">, +EnumValues<"OptionEnumValues(g_synthetic_symbols_name_style_values)">, +Desc<"Determines the way synthetic symbol names are generated for unknown symbols">; } let Definition = "debugger" in { diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 6052cc151744d..c48c5bbfb5e92 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -115,6 +115,14 @@ SymbolDownload ModuleListProperties::GetSymbolAutoDownload() const { g_modulelist_properties[idx].default_uint_value)); } +lldb::SyntheticSymbolsNameStyle +ModuleListProperties::GetSyntheticSymbolsNameStyle() const { + const uint32_t idx = ePropertySyntheticSymbolsNameStyle; + return GetPropertyAtIndexAs( + idx, static_cast( + g_modulelist_properties[idx].default_uint_value)); +} + FileSpec ModuleListProperties::GetClangModulesCachePath() const { const uint32_t idx = ePropertyClangModulesCachePath; return GetPropertyAtIndexAs(idx, {}); diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp index 4828de4fdfa37..825ca5babe28e 100644 --- a/lldb/source/Symbol/Symbol.cpp +++ b/lldb/source/Symbol/Symbol.cpp @@ -639,7 +639,18 @@ void Symbol::SynthesizeNameIfNeeded() const { // breakpoints on them. llvm::SmallString<256> name; llvm::raw_svector_ostream os(name); -os << GetSyntheticSymbolPrefix() << GetID(); +os << GetSyntheticSymbolPrefix(); +switch (ModuleList::GetGlobalModuleListProperties() +.GetSyntheticSymbolsNameStyle()) { +case eSyntheticSymbolsNameStyleIndex: + os << GetID(); + break; +case eSyntheticSymbolsNameStyleFileAddress: + os << "_" + << llvm::format_hex_no_prefix( +m_addr_range.GetBaseAddress().GetFileAddress(), 0); + break; +} m_mangled.SetDemangledName(ConstString(os.str())); }
[Lldb-commits] [lldb] [lldb] print a notice when `source list` paging reaches the end of th… (PR #137515)
https://github.com/hapee created https://github.com/llvm/llvm-project/pull/137515 This PR fixes the issue where the `list` command does not output a prompt when reaching the end of the file. Closes #128507. >From 2d66140f9d62cb9bae44951df0999b595da05e58 Mon Sep 17 00:00:00 2001 From: hapee <623151...@qq.com> Date: Sun, 27 Apr 2025 18:27:04 +0800 Subject: [PATCH] [lldb] print a notice when `source list` paging reaches the end of the file --- lldb/source/Core/SourceManager.cpp | 7 +-- .../Commands/command-list-reach-end-of-file.test | 16 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 lldb/test/Shell/Commands/command-list-reach-end-of-file.test diff --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp index d63d42de14e80..b57d8b3e20316 100644 --- a/lldb/source/Core/SourceManager.cpp +++ b/lldb/source/Core/SourceManager.cpp @@ -360,8 +360,11 @@ size_t SourceManager::DisplayMoreWithLineNumbers( GetDefaultFileAndLine(); if (last_file_sp) { -if (m_last_line == UINT32_MAX) - return 0; +if (m_last_line == UINT32_MAX) { + Stream::ByteDelta delta(*s); + s->Printf("note: reached the end of current file, no more to page\n"); + return *delta; +} if (reverse && m_last_line == 1) return 0; diff --git a/lldb/test/Shell/Commands/command-list-reach-end-of-file.test b/lldb/test/Shell/Commands/command-list-reach-end-of-file.test new file mode 100644 index 0..61237ce4af542 --- /dev/null +++ b/lldb/test/Shell/Commands/command-list-reach-end-of-file.test @@ -0,0 +1,16 @@ +# RUN: %clang_host -g -O0 %S/Inputs/sigchld.c -o %t.out +# RUN: %lldb %t.out -b -s %s | FileCheck %s + +b main +r +list +# CHECK: assert (child_pid != -1); + +list +# CHECK: printf("signo = %d\n", SIGCHLD); + +list +# CHECK: return 0; + +list +# CHECK: note: reached the end of current file, no more to page ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ee4b34c - [NFC][lldb] Fix unresolved test in buildbot lldb-aarch64-windows (#137516)
Author: Ebuka Ezike Date: 2025-04-27T15:32:43+01:00 New Revision: ee4b34cf3292382b153ba777fa1092858bea13f5 URL: https://github.com/llvm/llvm-project/commit/ee4b34cf3292382b153ba777fa1092858bea13f5 DIFF: https://github.com/llvm/llvm-project/commit/ee4b34cf3292382b153ba777fa1092858bea13f5.diff LOG: [NFC][lldb] Fix unresolved test in buildbot lldb-aarch64-windows (#137516) object indexing causes key error. Initial commit #290ba2 Added: Modified: lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py Removed: diff --git a/lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py b/lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py index d47e485c7f9d9..08c225b3cada4 100644 --- a/lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py +++ b/lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py @@ -67,45 +67,55 @@ def build_and_run_until_breakpoint(self): def verify_frames_source( self, frames, main_frame_assembly: bool, other_frame_assembly: bool ): +self.assertLessEqual(2, len(frames), "expect at least 2 frames") +source_0 = frames[0].get("source") +source_1 = frames[1].get("source") +self.assertIsNotNone(source_0, "Expects a source object in frame 0") +self.assertIsNotNone(source_1, "Expects a source object in frame 1") + +# it does not always have a path. +source_0_path: str = source_0.get("path", "") +source_1_path: str = source_1.get("path", "") + if other_frame_assembly: self.assertFalse( -frames[0]["source"]["path"].endswith("other.c"), +source_0_path.endswith("other.c"), "Expect original source path to not be in unavailable source frame (other.c)", ) self.assertIn( "sourceReference", -frames[0]["source"], +source_0, "Expect sourceReference to be in unavailable source frame (other.c)", ) else: self.assertTrue( -frames[0]["source"]["path"].endswith("other.c"), +source_0_path.endswith("other.c"), "Expect original source path to be in normal source frame (other.c)", ) self.assertNotIn( "sourceReference", -frames[0]["source"], +source_0, "Expect sourceReference to not be in normal source frame (other.c)", ) if main_frame_assembly: self.assertFalse( -frames[1]["source"]["path"].endswith("main.c"), +source_1_path.endswith("main.c"), "Expect original source path to not be in unavailable source frame (main.c)", ) self.assertIn( "sourceReference", -frames[1]["source"], +source_1, "Expect sourceReference to be in unavailable source frame (main.c)", ) else: self.assertTrue( -frames[1]["source"]["path"].endswith("main.c"), +source_1_path.endswith("main.c"), "Expect original source path to be in normal source frame (main.c)", ) self.assertNotIn( "sourceReference", -frames[1]["source"], +source_1, "Expect sourceReference to not be in normal source code frame (main.c)", ) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][lldb] Fix unresolved test in buildbot lldb-aarch64-windows (PR #137516)
https://github.com/da-viper closed https://github.com/llvm/llvm-project/pull/137516 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][lldb] Fix unresolved test in buildbot lldb-aarch64-windows (PR #137516)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Ebuka Ezike (da-viper) Changes object indexing causes key error. Initial commit #290ba2 --- Full diff: https://github.com/llvm/llvm-project/pull/137516.diff 1 Files Affected: - (modified) lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py (+18-8) ``diff diff --git a/lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py b/lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py index d47e485c7f9d9..08c225b3cada4 100644 --- a/lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py +++ b/lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py @@ -67,45 +67,55 @@ def build_and_run_until_breakpoint(self): def verify_frames_source( self, frames, main_frame_assembly: bool, other_frame_assembly: bool ): +self.assertLessEqual(2, len(frames), "expect at least 2 frames") +source_0 = frames[0].get("source") +source_1 = frames[1].get("source") +self.assertIsNotNone(source_0, "Expects a source object in frame 0") +self.assertIsNotNone(source_1, "Expects a source object in frame 1") + +# it does not always have a path. +source_0_path: str = source_0.get("path", "") +source_1_path: str = source_1.get("path", "") + if other_frame_assembly: self.assertFalse( -frames[0]["source"]["path"].endswith("other.c"), +source_0_path.endswith("other.c"), "Expect original source path to not be in unavailable source frame (other.c)", ) self.assertIn( "sourceReference", -frames[0]["source"], +source_0, "Expect sourceReference to be in unavailable source frame (other.c)", ) else: self.assertTrue( -frames[0]["source"]["path"].endswith("other.c"), +source_0_path.endswith("other.c"), "Expect original source path to be in normal source frame (other.c)", ) self.assertNotIn( "sourceReference", -frames[0]["source"], +source_0, "Expect sourceReference to not be in normal source frame (other.c)", ) if main_frame_assembly: self.assertFalse( -frames[1]["source"]["path"].endswith("main.c"), +source_1_path.endswith("main.c"), "Expect original source path to not be in unavailable source frame (main.c)", ) self.assertIn( "sourceReference", -frames[1]["source"], +source_1, "Expect sourceReference to be in unavailable source frame (main.c)", ) else: self.assertTrue( -frames[1]["source"]["path"].endswith("main.c"), +source_1_path.endswith("main.c"), "Expect original source path to be in normal source frame (main.c)", ) self.assertNotIn( "sourceReference", -frames[1]["source"], +source_1, "Expect sourceReference to not be in normal source code frame (main.c)", ) `` https://github.com/llvm/llvm-project/pull/137516 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][docs] Document new frame-format variables (PR #137522)
Michael137 wrote: Need to reformat things a bit https://github.com/llvm/llvm-project/pull/137522 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][docs] Document new frame-format variables (PR #137522)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/137522 Documents https://github.com/llvm/llvm-project/pull/131836 >From 2388b0951a3e9b0e2ebd297881f17423c8d68b4e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sun, 27 Apr 2025 11:23:20 +0100 Subject: [PATCH] [lldb][docs] Document new frame-format variables --- lldb/docs/use/formatting.rst | 50 +++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/lldb/docs/use/formatting.rst b/lldb/docs/use/formatting.rst index 7b3f01eebc891..6063a47e279f0 100644 --- a/lldb/docs/use/formatting.rst +++ b/lldb/docs/use/formatting.rst @@ -85,10 +85,24 @@ A complete list of currently supported format string variables is listed below: +---+-+ | ``function.name`` | The name of the current function or symbol. | +---+-+ -| ``function.name-with-args`` | The name of the current function with arguments and values or the symbol name. | +| ``function.name-with-args`` | The name of the current function with arguments and values or the symbol name. The name will be displayed according to the current frame's language if possible. | +---+-+ | ``function.name-without-args``| The name of the current function without arguments and values (used to include a function name in-line in the ``disassembly-format``) | +---+-+ +| ``function.basename``| The basename of the current function depending on the frame's language. E.g., for C++ the basename for `void ns::foo::bar(int) const` is `bar`. | ++---+-+ +| ``function.scope``| The scope qualifiers of the current function depending on the frame's language. E.g., for C++ the scope for `void ns::foo::bar(int) const` is `ns::foo`. | ++---+-+ +| ``function.template-arguments``| The template arguments of the current function depending on the frame's language. E.g., for C++ the template arguments for `void ns::foo::bar(int) const` are ``. | ++---
[Lldb-commits] [lldb] [lldb][Format] Make function name frame-format variables work without debug-info (PR #137408)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/137408 >From db417e84e944ee80f045414a4ce0f83a3e423e45 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 25 Apr 2025 22:49:36 +0100 Subject: [PATCH 1/2] [lldb][CPlusPLus] Make C++ frame-format work without debug-info --- lldb/source/Core/FormatEntity.cpp | 9 +++-- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 38 ++- .../TestFrameFormatFunctionBasename.test | 4 ++ ...FrameFormatFunctionFormattedArguments.test | 9 + .../TestFrameFormatFunctionQualifiers.test| 4 ++ .../TestFrameFormatFunctionReturn.test| 4 ++ .../TestFrameFormatFunctionScope.test | 7 +++- ...tFrameFormatFunctionTemplateArguments.test | 8 +++- 8 files changed, 73 insertions(+), 10 deletions(-) diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index e352d07fe487d..4ac50e2d30f3c 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -1809,11 +1809,12 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, case Entry::Type::FunctionReturnRight: case Entry::Type::FunctionReturnLeft: case Entry::Type::FunctionQualifiers: { -if (!sc->function) - return false; +Language *language_plugin = nullptr; +if (sc->function) + language_plugin = Language::FindPlugin(sc->function->GetLanguage()); +else if (sc->symbol) + language_plugin = Language::FindPlugin(sc->symbol->GetLanguage()); -Language *language_plugin = -Language::FindPlugin(sc->function->GetLanguage()); if (!language_plugin) return false; diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 283e867d53bb7..ab8e9883868ce 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -381,6 +381,34 @@ GetDemangledScope(const SymbolContext &sc) { return demangled_name.slice(info->ScopeRange.first, info->ScopeRange.second); } +static bool PrintDemangledArgumentList(Stream &s, const SymbolContext &sc) { + assert(sc.symbol); + + Mangled mangled = sc.GetPossiblyInlinedFunctionName(); + if (!mangled) +return false; + + auto demangled_name = mangled.GetDemangledName().GetStringRef(); + if (demangled_name.empty()) +return false; + + const std::optional &info = mangled.GetDemangledInfo(); + if (!info) +return false; + + // Function without a basename is nonsense. + if (!info->hasBasename()) +return false; + + if (info->ArgumentsRange.second < info->ArgumentsRange.first) +return false; + + s << demangled_name.slice(info->ArgumentsRange.first, +info->ArgumentsRange.second); + + return true; +} + bool CPlusPlusLanguage::CxxMethodName::TrySimplifiedParse() { // This method tries to parse simple method definitions which are presumably // most comman in user programs. Definitions that can be parsed by this @@ -1890,8 +1918,6 @@ bool CPlusPlusLanguage::GetFunctionDisplayName( bool CPlusPlusLanguage::HandleFrameFormatVariable( const SymbolContext &sc, const ExecutionContext *exe_ctx, FormatEntity::Entry::Type type, Stream &s) { - assert(sc.function); - switch (type) { case FormatEntity::Entry::Type::FunctionScope: { std::optional scope = GetDemangledScope(sc); @@ -1925,6 +1951,14 @@ bool CPlusPlusLanguage::HandleFrameFormatVariable( } case FormatEntity::Entry::Type::FunctionFormattedArguments: { +// This ensures we print the arguments even when no debug-info is available. +// +// FIXME: we should have a Entry::Type::FunctionArguments and +// use it in the plugin.cplusplus.display.function-name-format +// once we have a "fallback operator" in the frame-format language. +if (!sc.function && sc.symbol) + return PrintDemangledArgumentList(s, sc); + VariableList args; if (auto variable_list_sp = GetFunctionVariableList(sc)) variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument, diff --git a/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test b/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test index a2cb1c6adf064..7e34fbd3855d0 100644 --- a/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test +++ b/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test @@ -7,6 +7,10 @@ # RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \ # RUN: | FileCheck %s # +# RUN: %clang_host -O0 %t/main.cpp -o %t-nodebug.out +# RUN: %lldb -x -b -s %t/commands.input %t-nodebug.out -o exit 2>&1 \ +# RUN: | FileCheck %s + #--- main.cpp namespace ns { template diff --git a/lldb/test/Shell/Settings/TestFrameFormatFunctionFormattedArguments.test b/lldb/test/Shell/Settings/TestFrameFormatFunctionFormattedArguments.test index c4c9062b640f1..04f51701a2a2d 10064
[Lldb-commits] [lldb] [lldb][Format] Make function name frame-format variables work without debug-info (PR #137408)
@@ -38,7 +42,7 @@ int main() { #--- commands.input settings set -f frame-format "custom-frame '${function.basename}'\n" -break set -l 5 -f main.cpp +break set -n bar Michael137 wrote: Without this for some reason Linux PR CI was failing with: ``` (lldb) settings set -f frame-format "custom-frame '${function.basename}'\n" check:50'0 check:50'1 ? possible intended match 9: (lldb) break set -l 5 -f main.cpp check:50'0 ~~ 10: Breakpoint 1: no locations (pending). check:50'0 ~~ 11: WARNING: Unable to resolve breakpoint to any actual locations. check:50'0 ~~~ ``` https://github.com/llvm/llvm-project/pull/137408 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Format] Make function name frame-format variables work without debug-info (PR #137408)
@@ -29,7 +33,7 @@ int main() { return bar(); } #--- commands.input settings set -f frame-format "custom-frame '${function.template-arguments}'\n" -break set -l 4 -f main.cpp +break set -n func Michael137 wrote: Without this for some reason Linux PR CI was failing with: ``` (lldb) settings set -f frame-format "custom-frame '${function.basename}'\n" check:50'0 check:50'1 ? possible intended match 9: (lldb) break set -l 5 -f main.cpp check:50'0 ~~ 10: Breakpoint 1: no locations (pending). check:50'0 ~~ 11: WARNING: Unable to resolve breakpoint to any actual locations. check:50'0 ~~~ ``` https://github.com/llvm/llvm-project/pull/137408 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add settings to control how synthetic symbol names are generated (PR #137512)
https://github.com/eronnen created https://github.com/llvm/llvm-project/pull/137512 Adds a setting that makes lldb generate synthetic symbol names according to the file address of the function instead of the index, this could make it easier when debugging crashes and stack traces to understand which function the unnamed symbols corrresponds to >From 62d7d6635a2e8c3be8916148d0572f8f36ce4db1 Mon Sep 17 00:00:00 2001 From: Ely Ronnen Date: Sun, 27 Apr 2025 13:48:45 +0200 Subject: [PATCH] [lldb] add settings to control how synthetic symbol names are generated --- lldb/include/lldb/Core/ModuleList.h | 14 ++ lldb/include/lldb/Symbol/Symbol.h | 1 + lldb/include/lldb/lldb-enumerations.h | 6 ++ lldb/source/Core/CoreProperties.td| 5 + lldb/source/Core/ModuleList.cpp | 7 +++ lldb/source/Symbol/Symbol.cpp | 10 +- 6 files changed, 42 insertions(+), 1 deletion(-) diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h index 909ee08f9ba62..23f64a153d47d 100644 --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -67,6 +67,19 @@ static constexpr OptionEnumValueElement g_auto_download_enum_values[] = { }, }; +static constexpr OptionEnumValueElement g_synthetic_symbols_name_style_values[] = { + { + lldb::eSyntheticSymbolsNameStyleIndex, + "index", + "Function index style", + }, + { +lldb::eSyntheticSymbolsNameStyleFileAddress, + "file-address", + "Function file address in module style", + }, +}; + class ModuleListProperties : public Properties { mutable llvm::sys::RWMutex m_symlink_paths_mutex; PathMappingList m_symlink_paths; @@ -91,6 +104,7 @@ class ModuleListProperties : public Properties { bool GetLoadSymbolOnDemand(); lldb::SymbolDownload GetSymbolAutoDownload() const; + lldb::SyntheticSymbolsNameStyle GetSyntheticSymbolsNameStyle() const; PathMappingList GetSymlinkMappings() const; }; diff --git a/lldb/include/lldb/Symbol/Symbol.h b/lldb/include/lldb/Symbol/Symbol.h index e05c845a69f3e..5c37b33e7442e 100644 --- a/lldb/include/lldb/Symbol/Symbol.h +++ b/lldb/include/lldb/Symbol/Symbol.h @@ -339,6 +339,7 @@ class Symbol : public SymbolContextScope { m_is_weak : 1, m_type : 6;// Values from the lldb::SymbolType enum. mutable Mangled m_mangled; // uniqued symbol name/mangled name pair + AddressRange m_addr_range; // Contains the value, or the section offset // address when the value is an address in a // section, and the size (if any) diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 6d10cc8bcffcb..26e83cefbe571 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -1391,6 +1391,12 @@ enum StopDisassemblyType { eStopDisassemblyTypeAlways }; +/// Format to use for unknown symbols. +enum SyntheticSymbolsNameStyle { + eSyntheticSymbolsNameStyleIndex = 0, + eSyntheticSymbolsNameStyleFileAddress = 1, +}; + } // namespace lldb #endif // LLDB_LLDB_ENUMERATIONS_H diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td index a1a4e994c3b9c..7eaecb729c36d 100644 --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -46,6 +46,11 @@ let Definition = "modulelist" in { Global, DefaultFalse, Desc<"Enable on demand symbol loading in LLDB. LLDB will load debug info on demand for each module based on various conditions (e.g. matched breakpoint, resolved stack frame addresses and matched global variables/function symbols in symbol table) to improve performance. Please refer to docs/use/ondemand.rst for details.">; + def SyntheticSymbolsNameStyle: Property<"synthetic-symbols-name-style", "Enum">, +Global, +DefaultEnumValue<"eSyntheticSymbolsNameStyleIndex">, +EnumValues<"OptionEnumValues(g_synthetic_symbols_name_style_values)">, +Desc<"Determines the way synthetic symbol names are generated for unknown symbols">; } let Definition = "debugger" in { diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 6052cc151744d..a507d1c2efaf5 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -115,6 +115,13 @@ SymbolDownload ModuleListProperties::GetSymbolAutoDownload() const { g_modulelist_properties[idx].default_uint_value)); } +lldb::SyntheticSymbolsNameStyle ModuleListProperties::GetSyntheticSymbolsNameStyle() const { + const uint32_t idx = ePropertySyntheticSymbolsNameStyle; + return GetPropertyAtIndexAs( + idx, static_cast( + g_modulelist_properties[idx].default_uint_value)); +} + FileSpec ModuleListProperties::GetClangModulesCachePath() const { const uint32_t idx = ePropertyClangModulesCachePath; return GetPropertyAtIndexAs(idx, {}); di
[Lldb-commits] [lldb] [lldb] add settings to control how synthetic symbol names are generated (PR #137512)
https://github.com/eronnen updated https://github.com/llvm/llvm-project/pull/137512 >From 10d4c2497a55ccac91c27009ceafc2042476e7ab Mon Sep 17 00:00:00 2001 From: Ely Ronnen Date: Sun, 27 Apr 2025 13:48:45 +0200 Subject: [PATCH] [lldb] add settings to control how synthetic symbol names are generated --- lldb/include/lldb/Core/ModuleList.h | 15 +++ lldb/include/lldb/lldb-enumerations.h | 6 ++ lldb/source/Core/CoreProperties.td| 7 +++ lldb/source/Core/ModuleList.cpp | 8 lldb/source/Symbol/Symbol.cpp | 13 - 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h index 909ee08f9ba62..baed175be5313 100644 --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -67,6 +67,20 @@ static constexpr OptionEnumValueElement g_auto_download_enum_values[] = { }, }; +static constexpr OptionEnumValueElement +g_synthetic_symbols_name_style_values[] = { +{ +lldb::eSyntheticSymbolsNameStyleIndex, +"index", +"Function index style", +}, +{ +lldb::eSyntheticSymbolsNameStyleFileAddress, +"file-address", +"Function file address in module style", +}, +}; + class ModuleListProperties : public Properties { mutable llvm::sys::RWMutex m_symlink_paths_mutex; PathMappingList m_symlink_paths; @@ -91,6 +105,7 @@ class ModuleListProperties : public Properties { bool GetLoadSymbolOnDemand(); lldb::SymbolDownload GetSymbolAutoDownload() const; + lldb::SyntheticSymbolsNameStyle GetSyntheticSymbolsNameStyle() const; PathMappingList GetSymlinkMappings() const; }; diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 6d10cc8bcffcb..26e83cefbe571 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -1391,6 +1391,12 @@ enum StopDisassemblyType { eStopDisassemblyTypeAlways }; +/// Format to use for unknown symbols. +enum SyntheticSymbolsNameStyle { + eSyntheticSymbolsNameStyleIndex = 0, + eSyntheticSymbolsNameStyleFileAddress = 1, +}; + } // namespace lldb #endif // LLDB_LLDB_ENUMERATIONS_H diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td index a1a4e994c3b9c..84326abc650b6 100644 --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -46,6 +46,13 @@ let Definition = "modulelist" in { Global, DefaultFalse, Desc<"Enable on demand symbol loading in LLDB. LLDB will load debug info on demand for each module based on various conditions (e.g. matched breakpoint, resolved stack frame addresses and matched global variables/function symbols in symbol table) to improve performance. Please refer to docs/use/ondemand.rst for details.">; + def SyntheticSymbolsNameStyle + : Property<"synthetic-symbols-name-style", "Enum">, +Global, +DefaultEnumValue<"eSyntheticSymbolsNameStyleIndex">, +EnumValues<"OptionEnumValues(g_synthetic_symbols_name_style_values)">, +Desc<"Determines the way synthetic symbol names are generated for " + "unknown symbols">; } let Definition = "debugger" in { diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 6052cc151744d..c48c5bbfb5e92 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -115,6 +115,14 @@ SymbolDownload ModuleListProperties::GetSymbolAutoDownload() const { g_modulelist_properties[idx].default_uint_value)); } +lldb::SyntheticSymbolsNameStyle +ModuleListProperties::GetSyntheticSymbolsNameStyle() const { + const uint32_t idx = ePropertySyntheticSymbolsNameStyle; + return GetPropertyAtIndexAs( + idx, static_cast( + g_modulelist_properties[idx].default_uint_value)); +} + FileSpec ModuleListProperties::GetClangModulesCachePath() const { const uint32_t idx = ePropertyClangModulesCachePath; return GetPropertyAtIndexAs(idx, {}); diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp index 4828de4fdfa37..825ca5babe28e 100644 --- a/lldb/source/Symbol/Symbol.cpp +++ b/lldb/source/Symbol/Symbol.cpp @@ -639,7 +639,18 @@ void Symbol::SynthesizeNameIfNeeded() const { // breakpoints on them. llvm::SmallString<256> name; llvm::raw_svector_ostream os(name); -os << GetSyntheticSymbolPrefix() << GetID(); +os << GetSyntheticSymbolPrefix(); +switch (ModuleList::GetGlobalModuleListProperties() +.GetSyntheticSymbolsNameStyle()) { +case eSyntheticSymbolsNameStyleIndex: + os << GetID(); + break; +case eSyntheticSymbolsNameStyleFileAddress: + os << "_" + << llvm::format_hex_no_prefix( +m_addr_range.GetBaseAddress().GetFileAddress(), 0); + break; +} m_mangled.SetD
[Lldb-commits] [lldb] [llvm] [lldb-dap] Migrating breakpointLocations request to use typed RequestHandler (PR #137426)
https://github.com/eronnen edited https://github.com/llvm/llvm-project/pull/137426 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add settings to control how synthetic symbol names are generated (PR #137512)
https://github.com/eronnen edited https://github.com/llvm/llvm-project/pull/137512 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb-dap] migrate set breakpoint requests (PR #137448)
https://github.com/eronnen updated https://github.com/llvm/llvm-project/pull/137448 >From dc8388b0027c75dba465c72009ac0c25750ae877 Mon Sep 17 00:00:00 2001 From: Ely Ronnen Date: Sat, 26 Apr 2025 10:25:21 +0200 Subject: [PATCH] adding breakpoints protocol types add all breakpoint requests JSON types decouple JSON from DAP Breakpoint classes forgor exception breakpoint response migrating breakpoint requests migrate breakpoints requests handler implementations remove CreateBreakpoint data breakpoint requests serialization fix GetFrame fix data breakpoint return exception breakpoints list restore exception breakpoints --- lldb/tools/lldb-dap/Breakpoint.cpp| 22 +- lldb/tools/lldb-dap/Breakpoint.h | 6 +- lldb/tools/lldb-dap/BreakpointBase.cpp| 12 +- lldb/tools/lldb-dap/BreakpointBase.h | 8 +- lldb/tools/lldb-dap/DAP.cpp | 11 +- lldb/tools/lldb-dap/DAP.h | 1 + lldb/tools/lldb-dap/FunctionBreakpoint.cpp| 8 +- lldb/tools/lldb-dap/FunctionBreakpoint.h | 3 +- .../DataBreakpointInfoRequestHandler.cpp | 175 -- .../Handler/InitializeRequestHandler.cpp | 2 +- lldb/tools/lldb-dap/Handler/RequestHandler.h | 51 ++-- .../Handler/SetBreakpointsRequestHandler.cpp | 180 +++--- .../SetDataBreakpointsRequestHandler.cpp | 98 ++-- .../SetFunctionBreakpointsRequestHandler.cpp | 115 ++--- ...etInstructionBreakpointsRequestHandler.cpp | 223 ++ ...TestGetTargetBreakpointsRequestHandler.cpp | 2 +- lldb/tools/lldb-dap/InstructionBreakpoint.cpp | 15 +- lldb/tools/lldb-dap/InstructionBreakpoint.h | 4 +- lldb/tools/lldb-dap/JSONUtils.cpp | 161 + lldb/tools/lldb-dap/JSONUtils.h | 67 +- .../lldb-dap/Protocol/ProtocolRequests.cpp| 70 ++ .../lldb-dap/Protocol/ProtocolRequests.h | 147 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp | 127 ++ lldb/tools/lldb-dap/Protocol/ProtocolTypes.h | 181 ++ lldb/tools/lldb-dap/SourceBreakpoint.cpp | 13 +- lldb/tools/lldb-dap/SourceBreakpoint.h| 3 +- lldb/tools/lldb-dap/Watchpoint.cpp| 26 +- lldb/tools/lldb-dap/Watchpoint.h | 6 +- llvm/include/llvm/Support/JSON.h | 8 + 29 files changed, 790 insertions(+), 955 deletions(-) diff --git a/lldb/tools/lldb-dap/Breakpoint.cpp b/lldb/tools/lldb-dap/Breakpoint.cpp index 5679fd545d53f..26d633d1d172e 100644 --- a/lldb/tools/lldb-dap/Breakpoint.cpp +++ b/lldb/tools/lldb-dap/Breakpoint.cpp @@ -14,7 +14,6 @@ #include "lldb/API/SBLineEntry.h" #include "lldb/API/SBMutex.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/Support/JSON.h" #include #include #include @@ -30,13 +29,16 @@ void Breakpoint::SetHitCondition() { m_bp.SetIgnoreCount(hitCount - 1); } -void Breakpoint::CreateJsonObject(llvm::json::Object &object) { +protocol::Breakpoint Breakpoint::ToProtocolBreakpoint() { + protocol::Breakpoint breakpoint; + // Each breakpoint location is treated as a separate breakpoint for VS code. // They don't have the notion of a single breakpoint with multiple locations. if (!m_bp.IsValid()) -return; - object.try_emplace("verified", m_bp.GetNumResolvedLocations() > 0); - object.try_emplace("id", m_bp.GetID()); +return breakpoint; + + breakpoint.verified = m_bp.GetNumResolvedLocations() > 0; + breakpoint.id = m_bp.GetID(); // VS Code DAP doesn't currently allow one breakpoint to have multiple // locations so we just report the first one. If we report all locations // then the IDE starts showing the wrong line numbers and locations for @@ -60,16 +62,18 @@ void Breakpoint::CreateJsonObject(llvm::json::Object &object) { if (bp_addr.IsValid()) { std::string formatted_addr = "0x" + llvm::utohexstr(bp_addr.GetLoadAddress(m_bp.GetTarget())); -object.try_emplace("instructionReference", formatted_addr); +breakpoint.instructionReference = formatted_addr; auto line_entry = bp_addr.GetLineEntry(); const auto line = line_entry.GetLine(); if (line != UINT32_MAX) - object.try_emplace("line", line); + breakpoint.line = line; const auto column = line_entry.GetColumn(); if (column != 0) - object.try_emplace("column", column); -object.try_emplace("source", CreateSource(line_entry)); + breakpoint.column = column; +breakpoint.source = CreateSource(line_entry); } + + return breakpoint; } bool Breakpoint::MatchesName(const char *name) { diff --git a/lldb/tools/lldb-dap/Breakpoint.h b/lldb/tools/lldb-dap/Breakpoint.h index 580017125af44..c4f1fa291f181 100644 --- a/lldb/tools/lldb-dap/Breakpoint.h +++ b/lldb/tools/lldb-dap/Breakpoint.h @@ -17,14 +17,16 @@ namespace lldb_dap { class Breakpoint : public BreakpointBase { public: - Breakpoint(DAP &d, const llvm::json::Object &obj) : BreakpointBase(d, obj)
[Lldb-commits] [lldb] [lldb] print a notice when `source list` paging reaches the end of th… (PR #137515)
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/137515 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] print a notice when `source list` paging reaches the end of th… (PR #137515)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (hapee) Changes This PR fixes the issue where the `list` command does not output a prompt when reaching the end of the file. Closes #128507. --- Full diff: https://github.com/llvm/llvm-project/pull/137515.diff 2 Files Affected: - (modified) lldb/source/Core/SourceManager.cpp (+5-2) - (added) lldb/test/Shell/Commands/command-list-reach-end-of-file.test (+16) ``diff diff --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp index d63d42de14e80..b57d8b3e20316 100644 --- a/lldb/source/Core/SourceManager.cpp +++ b/lldb/source/Core/SourceManager.cpp @@ -360,8 +360,11 @@ size_t SourceManager::DisplayMoreWithLineNumbers( GetDefaultFileAndLine(); if (last_file_sp) { -if (m_last_line == UINT32_MAX) - return 0; +if (m_last_line == UINT32_MAX) { + Stream::ByteDelta delta(*s); + s->Printf("note: reached the end of current file, no more to page\n"); + return *delta; +} if (reverse && m_last_line == 1) return 0; diff --git a/lldb/test/Shell/Commands/command-list-reach-end-of-file.test b/lldb/test/Shell/Commands/command-list-reach-end-of-file.test new file mode 100644 index 0..61237ce4af542 --- /dev/null +++ b/lldb/test/Shell/Commands/command-list-reach-end-of-file.test @@ -0,0 +1,16 @@ +# RUN: %clang_host -g -O0 %S/Inputs/sigchld.c -o %t.out +# RUN: %lldb %t.out -b -s %s | FileCheck %s + +b main +r +list +# CHECK: assert (child_pid != -1); + +list +# CHECK: printf("signo = %d\n", SIGCHLD); + +list +# CHECK: return 0; + +list +# CHECK: note: reached the end of current file, no more to page `` https://github.com/llvm/llvm-project/pull/137515 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][lldb] Fix unresolved test in buildbot lldb-aarch64-windows (PR #137516)
https://github.com/da-viper created https://github.com/llvm/llvm-project/pull/137516 object indexing causes key error. Initial commit #290ba2 >From f0279f88319ab70d0748d3fcde0cc0d279916e6e Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Sun, 27 Apr 2025 15:03:19 +0100 Subject: [PATCH] [NFC][lldb] Fix unresolved test in buildbot lldb-aarch64-windows object indexing causes key error. Initial commit #290ba281e819d60be4903436cbc07efc12e22d4c --- .../TestDAP_stackTraceDisassemblyDisplay.py | 26 +-- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py b/lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py index d47e485c7f9d9..08c225b3cada4 100644 --- a/lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py +++ b/lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py @@ -67,45 +67,55 @@ def build_and_run_until_breakpoint(self): def verify_frames_source( self, frames, main_frame_assembly: bool, other_frame_assembly: bool ): +self.assertLessEqual(2, len(frames), "expect at least 2 frames") +source_0 = frames[0].get("source") +source_1 = frames[1].get("source") +self.assertIsNotNone(source_0, "Expects a source object in frame 0") +self.assertIsNotNone(source_1, "Expects a source object in frame 1") + +# it does not always have a path. +source_0_path: str = source_0.get("path", "") +source_1_path: str = source_1.get("path", "") + if other_frame_assembly: self.assertFalse( -frames[0]["source"]["path"].endswith("other.c"), +source_0_path.endswith("other.c"), "Expect original source path to not be in unavailable source frame (other.c)", ) self.assertIn( "sourceReference", -frames[0]["source"], +source_0, "Expect sourceReference to be in unavailable source frame (other.c)", ) else: self.assertTrue( -frames[0]["source"]["path"].endswith("other.c"), +source_0_path.endswith("other.c"), "Expect original source path to be in normal source frame (other.c)", ) self.assertNotIn( "sourceReference", -frames[0]["source"], +source_0, "Expect sourceReference to not be in normal source frame (other.c)", ) if main_frame_assembly: self.assertFalse( -frames[1]["source"]["path"].endswith("main.c"), +source_1_path.endswith("main.c"), "Expect original source path to not be in unavailable source frame (main.c)", ) self.assertIn( "sourceReference", -frames[1]["source"], +source_1, "Expect sourceReference to be in unavailable source frame (main.c)", ) else: self.assertTrue( -frames[1]["source"]["path"].endswith("main.c"), +source_1_path.endswith("main.c"), "Expect original source path to be in normal source frame (main.c)", ) self.assertNotIn( "sourceReference", -frames[1]["source"], +source_1, "Expect sourceReference to not be in normal source code frame (main.c)", ) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][docs] Document new frame-format variables (PR #137522)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/137522 >From 2388b0951a3e9b0e2ebd297881f17423c8d68b4e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sun, 27 Apr 2025 11:23:20 +0100 Subject: [PATCH 1/2] [lldb][docs] Document new frame-format variables --- lldb/docs/use/formatting.rst | 50 +++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/lldb/docs/use/formatting.rst b/lldb/docs/use/formatting.rst index 7b3f01eebc891..6063a47e279f0 100644 --- a/lldb/docs/use/formatting.rst +++ b/lldb/docs/use/formatting.rst @@ -85,10 +85,24 @@ A complete list of currently supported format string variables is listed below: +---+-+ | ``function.name`` | The name of the current function or symbol. | +---+-+ -| ``function.name-with-args`` | The name of the current function with arguments and values or the symbol name. | +| ``function.name-with-args`` | The name of the current function with arguments and values or the symbol name. The name will be displayed according to the current frame's language if possible. | +---+-+ | ``function.name-without-args``| The name of the current function without arguments and values (used to include a function name in-line in the ``disassembly-format``) | +---+-+ +| ``function.basename``| The basename of the current function depending on the frame's language. E.g., for C++ the basename for `void ns::foo::bar(int) const` is `bar`. | ++---+-+ +| ``function.scope``| The scope qualifiers of the current function depending on the frame's language. E.g., for C++ the scope for `void ns::foo::bar(int) const` is `ns::foo`. | ++---+-+ +| ``function.template-arguments``| The template arguments of the current function depending on the frame's language. E.g., for C++ the template arguments for `void ns::foo::bar(int) const` are ``. | ++---+---
[Lldb-commits] [lldb] [lldb][Format] Make function name frame-format variables work without debug-info (PR #137408)
https://github.com/Michael137 deleted https://github.com/llvm/llvm-project/pull/137408 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d605a0d - [lldb][test] FrameFormat tests: Specify filename when setting breakpoints
Author: Michael Buch Date: 2025-04-27T11:21:01+01:00 New Revision: d605a0d70e3c2f53209c4320c2b6a9a9d86c8227 URL: https://github.com/llvm/llvm-project/commit/d605a0d70e3c2f53209c4320c2b6a9a9d86c8227 DIFF: https://github.com/llvm/llvm-project/commit/d605a0d70e3c2f53209c4320c2b6a9a9d86c8227.diff LOG: [lldb][test] FrameFormat tests: Specify filename when setting breakpoints Try to work around following error on some of the Linux CI: ``` 8: (lldb) settings set -f frame-format "custom-frame '${function.basename}'\n" check:50'0 check:50'1 ? possible intended match 9: (lldb) break set -l 5 check:50'0 ~~ 10: error: No selected frame to use to find the default file. check:50'0 ~~ 11: error: No file supplied and no default file available. check:50'0 ~~~ 12: (lldb) exit check:50'0 ``` Added: Modified: lldb/test/Shell/Settings/TestCxxFrameFormat.test lldb/test/Shell/Settings/TestCxxFrameFormatObjC.test lldb/test/Shell/Settings/TestCxxFrameFormatPartialFailure.test lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test lldb/test/Shell/Settings/TestFrameFormatFunctionTemplateArguments.test Removed: diff --git a/lldb/test/Shell/Settings/TestCxxFrameFormat.test b/lldb/test/Shell/Settings/TestCxxFrameFormat.test index 0db3bfa1b4a10..d70db582e9750 100644 --- a/lldb/test/Shell/Settings/TestCxxFrameFormat.test +++ b/lldb/test/Shell/Settings/TestCxxFrameFormat.test @@ -24,7 +24,7 @@ int main(int argc, char const *argv[]) { #--- commands.input settings set plugin.cplusplus.display.function-name-format "${function.scope}${function.basename}" settings set -f frame-format "custom-frame '${function.name-with-args}'\n" -break set -l 3 +break set -l 3 -f main.cpp run bt diff --git a/lldb/test/Shell/Settings/TestCxxFrameFormatObjC.test b/lldb/test/Shell/Settings/TestCxxFrameFormatObjC.test index ba57bc8a8..03075d8f32a64 100644 --- a/lldb/test/Shell/Settings/TestCxxFrameFormatObjC.test +++ b/lldb/test/Shell/Settings/TestCxxFrameFormatObjC.test @@ -17,7 +17,7 @@ int main() { return bar(10); } #--- commands.input settings set plugin.cplusplus.display.function-name-format "this affects C++ only" settings set -f frame-format "custom-frame '${function.name-with-args}'\n" -break set -l 3 +break set -l 3 -f main.m run bt diff --git a/lldb/test/Shell/Settings/TestCxxFrameFormatPartialFailure.test b/lldb/test/Shell/Settings/TestCxxFrameFormatPartialFailure.test index f10de878b8d88..e914ff7a010dd 100644 --- a/lldb/test/Shell/Settings/TestCxxFrameFormatPartialFailure.test +++ b/lldb/test/Shell/Settings/TestCxxFrameFormatPartialFailure.test @@ -22,7 +22,7 @@ int main(int argc, const char *argv[]) { #--- commands.input settings set plugin.cplusplus.display.function-name-format "${function.basename}${script.target:invalid_func}" settings set -f frame-format "custom-frame '${function.name-with-args}'\n" -break set -l 2 +break set -l 2 -f main.cpp run bt diff --git a/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test b/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test index a2cb1c6adf064..fdb90a064e273 100644 --- a/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test +++ b/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test @@ -38,7 +38,7 @@ int main() { #--- commands.input settings set -f frame-format "custom-frame '${function.basename}'\n" -break set -l 5 +break set -l 5 -f main.cpp run bt diff --git a/lldb/test/Shell/Settings/TestFrameFormatFunctionTemplateArguments.test b/lldb/test/Shell/Settings/TestFrameFormatFunctionTemplateArguments.test index f0c29bcee2ce5..1b5113fb66732 100644 --- a/lldb/test/Shell/Settings/TestFrameFormatFunctionTemplateArguments.test +++ b/lldb/test/Shell/Settings/TestFrameFormatFunctionTemplateArguments.test @@ -29,7 +29,7 @@ int main() { return bar(); } #--- commands.input settings set -f frame-format "custom-frame '${function.template-arguments}'\n" -break set -l 4 +break set -l 4 -f main.cpp run bt ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Format] Make function name frame-format variables work without debug-info (PR #137408)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/137408 >From db417e84e944ee80f045414a4ce0f83a3e423e45 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 25 Apr 2025 22:49:36 +0100 Subject: [PATCH] [lldb][CPlusPLus] Make C++ frame-format work without debug-info --- lldb/source/Core/FormatEntity.cpp | 9 +++-- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 38 ++- .../TestFrameFormatFunctionBasename.test | 4 ++ ...FrameFormatFunctionFormattedArguments.test | 9 + .../TestFrameFormatFunctionQualifiers.test| 4 ++ .../TestFrameFormatFunctionReturn.test| 4 ++ .../TestFrameFormatFunctionScope.test | 7 +++- ...tFrameFormatFunctionTemplateArguments.test | 8 +++- 8 files changed, 73 insertions(+), 10 deletions(-) diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index e352d07fe487d..4ac50e2d30f3c 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -1809,11 +1809,12 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, case Entry::Type::FunctionReturnRight: case Entry::Type::FunctionReturnLeft: case Entry::Type::FunctionQualifiers: { -if (!sc->function) - return false; +Language *language_plugin = nullptr; +if (sc->function) + language_plugin = Language::FindPlugin(sc->function->GetLanguage()); +else if (sc->symbol) + language_plugin = Language::FindPlugin(sc->symbol->GetLanguage()); -Language *language_plugin = -Language::FindPlugin(sc->function->GetLanguage()); if (!language_plugin) return false; diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 283e867d53bb7..ab8e9883868ce 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -381,6 +381,34 @@ GetDemangledScope(const SymbolContext &sc) { return demangled_name.slice(info->ScopeRange.first, info->ScopeRange.second); } +static bool PrintDemangledArgumentList(Stream &s, const SymbolContext &sc) { + assert(sc.symbol); + + Mangled mangled = sc.GetPossiblyInlinedFunctionName(); + if (!mangled) +return false; + + auto demangled_name = mangled.GetDemangledName().GetStringRef(); + if (demangled_name.empty()) +return false; + + const std::optional &info = mangled.GetDemangledInfo(); + if (!info) +return false; + + // Function without a basename is nonsense. + if (!info->hasBasename()) +return false; + + if (info->ArgumentsRange.second < info->ArgumentsRange.first) +return false; + + s << demangled_name.slice(info->ArgumentsRange.first, +info->ArgumentsRange.second); + + return true; +} + bool CPlusPlusLanguage::CxxMethodName::TrySimplifiedParse() { // This method tries to parse simple method definitions which are presumably // most comman in user programs. Definitions that can be parsed by this @@ -1890,8 +1918,6 @@ bool CPlusPlusLanguage::GetFunctionDisplayName( bool CPlusPlusLanguage::HandleFrameFormatVariable( const SymbolContext &sc, const ExecutionContext *exe_ctx, FormatEntity::Entry::Type type, Stream &s) { - assert(sc.function); - switch (type) { case FormatEntity::Entry::Type::FunctionScope: { std::optional scope = GetDemangledScope(sc); @@ -1925,6 +1951,14 @@ bool CPlusPlusLanguage::HandleFrameFormatVariable( } case FormatEntity::Entry::Type::FunctionFormattedArguments: { +// This ensures we print the arguments even when no debug-info is available. +// +// FIXME: we should have a Entry::Type::FunctionArguments and +// use it in the plugin.cplusplus.display.function-name-format +// once we have a "fallback operator" in the frame-format language. +if (!sc.function && sc.symbol) + return PrintDemangledArgumentList(s, sc); + VariableList args; if (auto variable_list_sp = GetFunctionVariableList(sc)) variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument, diff --git a/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test b/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test index a2cb1c6adf064..7e34fbd3855d0 100644 --- a/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test +++ b/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test @@ -7,6 +7,10 @@ # RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \ # RUN: | FileCheck %s # +# RUN: %clang_host -O0 %t/main.cpp -o %t-nodebug.out +# RUN: %lldb -x -b -s %t/commands.input %t-nodebug.out -o exit 2>&1 \ +# RUN: | FileCheck %s + #--- main.cpp namespace ns { template diff --git a/lldb/test/Shell/Settings/TestFrameFormatFunctionFormattedArguments.test b/lldb/test/Shell/Settings/TestFrameFormatFunctionFormattedArguments.test index c4c9062b640f1..04f51701a2a2d 100644 --
[Lldb-commits] [lldb] [llvm] [lldb-dap] migrate set breakpoint requests (PR #137448)
https://github.com/eronnen edited https://github.com/llvm/llvm-project/pull/137448 ___ 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 the Module Event (PR #137380)
https://github.com/da-viper approved this pull request. https://github.com/llvm/llvm-project/pull/137380 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Make lldb-dap.executable-path machine specific (PR #137485)
https://github.com/da-viper approved this pull request. https://github.com/llvm/llvm-project/pull/137485 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Complete ToJSON for OptionValues (PR #137375)
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/137375 >From a87d7be70ce0d82b159c163b1b319a349cb162ea Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Fri, 25 Apr 2025 18:20:24 +0100 Subject: [PATCH 1/4] [lldb] Add ToJson for OptionValueArch --- lldb/include/lldb/Interpreter/OptionValueArch.h | 2 ++ lldb/source/Interpreter/OptionValueArch.cpp | 8 lldb/test/API/commands/settings/TestSettings.py | 4 3 files changed, 14 insertions(+) diff --git a/lldb/include/lldb/Interpreter/OptionValueArch.h b/lldb/include/lldb/Interpreter/OptionValueArch.h index e175208794474..7e7b7657d7963 100644 --- a/lldb/include/lldb/Interpreter/OptionValueArch.h +++ b/lldb/include/lldb/Interpreter/OptionValueArch.h @@ -38,6 +38,8 @@ class OptionValueArch : public Cloneable { void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override; + llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override; + Status SetValueFromString(llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign) override; diff --git a/lldb/source/Interpreter/OptionValueArch.cpp b/lldb/source/Interpreter/OptionValueArch.cpp index a2fed7737fc3e..72d8769c565a4 100644 --- a/lldb/source/Interpreter/OptionValueArch.cpp +++ b/lldb/source/Interpreter/OptionValueArch.cpp @@ -33,6 +33,14 @@ void OptionValueArch::DumpValue(const ExecutionContext *exe_ctx, Stream &strm, } } +llvm::json::Value OptionValueArch::ToJSON(const ExecutionContext *exe_ctx) { + if (m_current_value.IsValid()) { +return llvm::json::Value(m_current_value.GetArchitectureName()); + } + + return {}; +} + Status OptionValueArch::SetValueFromString(llvm::StringRef value, VarSetOperationType op) { Status error; diff --git a/lldb/test/API/commands/settings/TestSettings.py b/lldb/test/API/commands/settings/TestSettings.py index f05a285b47d16..4eb868430b006 100644 --- a/lldb/test/API/commands/settings/TestSettings.py +++ b/lldb/test/API/commands/settings/TestSettings.py @@ -1044,6 +1044,10 @@ def test_settings_api(self): # Test OptionValueEnumeration self.verify_setting_value_json("target.x86-disassembly-flavor", "intel") +# Test OptionValueArch +self.verify_setting_value_json("target.default-arch", "x86_64") +self.runCmd("settings clear target.default-arch") + def test_global_option(self): # This command used to crash the settings because -g was signaled by a # NULL execution context (not one with an empty Target...) and in the >From 5d9b7e4d6e9d080d1b0c84e849d491da76dc86da Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Fri, 25 Apr 2025 18:20:47 +0100 Subject: [PATCH 2/4] [lldb] Add ToJson for OptionValueFileColonLine --- .../lldb/Interpreter/OptionValueFileColonLine.h | 2 ++ .../source/Interpreter/OptionValueFileColonLine.cpp | 13 + 2 files changed, 15 insertions(+) diff --git a/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h b/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h index 181ef18bbcdf1..efe8a641e22f2 100644 --- a/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h +++ b/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h @@ -29,6 +29,8 @@ class OptionValueFileColonLine : void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override; + llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override; + Status SetValueFromString(llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign) override; diff --git a/lldb/source/Interpreter/OptionValueFileColonLine.cpp b/lldb/source/Interpreter/OptionValueFileColonLine.cpp index 87d390d1b5ef4..312ee7f705e42 100644 --- a/lldb/source/Interpreter/OptionValueFileColonLine.cpp +++ b/lldb/source/Interpreter/OptionValueFileColonLine.cpp @@ -46,6 +46,19 @@ void OptionValueFileColonLine::DumpValue(const ExecutionContext *exe_ctx, } } +llvm::json::Value +OptionValueFileColonLine::ToJSON(const ExecutionContext *exe_ctx) { + StreamString stream; + if (m_file_spec) +stream << '"' << m_file_spec.GetPath().c_str() << '"'; + if (m_line_number != LLDB_INVALID_LINE_NUMBER) +stream.Printf(":%d", m_line_number); + if (m_column_number != LLDB_INVALID_COLUMN_NUMBER) +stream.Printf(":%d", m_column_number); + + return llvm::json::Value(stream.GetString()); +} + Status OptionValueFileColonLine::SetValueFromString(llvm::StringRef value, VarSetOperationType op) { Status error; >From 20d5251d6bbb12fbe48dae8e8a8ce93f9d85cccd Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Fri, 25 Apr 2025 18:25:31 +0100 Subject: [PATCH 3/4] [lldb] Make OptionValue::ToJSON abstract --- lldb/include/lldb/Interpreter/OptionValue.h| 10 +- lldb/include/lldb/Interpreter/O
[Lldb-commits] [lldb] [lldb][lldb-dap] Respect x86 disassembly flavor setting (PR #134722)
https://github.com/da-viper closed https://github.com/llvm/llvm-project/pull/134722 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb-dap] migrate set breakpoint requests (PR #137448)
llvmbot wrote: @llvm/pr-subscribers-llvm-support Author: Ely Ronnen (eronnen) Changes - Migrate set breakpoint requests to use typed RequestHandler - `SetBreakpointsRequestHandler` - `SetDataBreakpointsRequestHandler` - `SetFunctionBreakpointsRequestHandler` - `SetInstructionBreakpointsRequestHandler` - `DataBreakpointInfoRequestHandler` --- Patch is 96.22 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/137448.diff 29 Files Affected: - (modified) lldb/tools/lldb-dap/Breakpoint.cpp (+13-9) - (modified) lldb/tools/lldb-dap/Breakpoint.h (+4-2) - (modified) lldb/tools/lldb-dap/BreakpointBase.cpp (+5-7) - (modified) lldb/tools/lldb-dap/BreakpointBase.h (+5-3) - (modified) lldb/tools/lldb-dap/DAP.cpp (+8-3) - (modified) lldb/tools/lldb-dap/DAP.h (+1) - (modified) lldb/tools/lldb-dap/FunctionBreakpoint.cpp (+4-4) - (modified) lldb/tools/lldb-dap/FunctionBreakpoint.h (+2-1) - (modified) lldb/tools/lldb-dap/Handler/DataBreakpointInfoRequestHandler.cpp (+40-135) - (modified) lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp (+1-1) - (modified) lldb/tools/lldb-dap/Handler/RequestHandler.h (+35-16) - (modified) lldb/tools/lldb-dap/Handler/SetBreakpointsRequestHandler.cpp (+38-142) - (modified) lldb/tools/lldb-dap/Handler/SetDataBreakpointsRequestHandler.cpp (+17-81) - (modified) lldb/tools/lldb-dap/Handler/SetFunctionBreakpointsRequestHandler.cpp (+16-99) - (modified) lldb/tools/lldb-dap/Handler/SetInstructionBreakpointsRequestHandler.cpp (+16-207) - (modified) lldb/tools/lldb-dap/Handler/TestGetTargetBreakpointsRequestHandler.cpp (+1-1) - (modified) lldb/tools/lldb-dap/InstructionBreakpoint.cpp (+7-8) - (modified) lldb/tools/lldb-dap/InstructionBreakpoint.h (+3-1) - (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+12-149) - (modified) lldb/tools/lldb-dap/JSONUtils.h (+3-64) - (modified) lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp (+70) - (modified) lldb/tools/lldb-dap/Protocol/ProtocolRequests.h (+147) - (modified) lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp (+127) - (modified) lldb/tools/lldb-dap/Protocol/ProtocolTypes.h (+181) - (modified) lldb/tools/lldb-dap/SourceBreakpoint.cpp (+6-7) - (modified) lldb/tools/lldb-dap/SourceBreakpoint.h (+2-1) - (modified) lldb/tools/lldb-dap/Watchpoint.cpp (+14-12) - (modified) lldb/tools/lldb-dap/Watchpoint.h (+4-2) - (modified) llvm/include/llvm/Support/JSON.h (+8) ``diff diff --git a/lldb/tools/lldb-dap/Breakpoint.cpp b/lldb/tools/lldb-dap/Breakpoint.cpp index 5679fd545d53f..26d633d1d172e 100644 --- a/lldb/tools/lldb-dap/Breakpoint.cpp +++ b/lldb/tools/lldb-dap/Breakpoint.cpp @@ -14,7 +14,6 @@ #include "lldb/API/SBLineEntry.h" #include "lldb/API/SBMutex.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/Support/JSON.h" #include #include #include @@ -30,13 +29,16 @@ void Breakpoint::SetHitCondition() { m_bp.SetIgnoreCount(hitCount - 1); } -void Breakpoint::CreateJsonObject(llvm::json::Object &object) { +protocol::Breakpoint Breakpoint::ToProtocolBreakpoint() { + protocol::Breakpoint breakpoint; + // Each breakpoint location is treated as a separate breakpoint for VS code. // They don't have the notion of a single breakpoint with multiple locations. if (!m_bp.IsValid()) -return; - object.try_emplace("verified", m_bp.GetNumResolvedLocations() > 0); - object.try_emplace("id", m_bp.GetID()); +return breakpoint; + + breakpoint.verified = m_bp.GetNumResolvedLocations() > 0; + breakpoint.id = m_bp.GetID(); // VS Code DAP doesn't currently allow one breakpoint to have multiple // locations so we just report the first one. If we report all locations // then the IDE starts showing the wrong line numbers and locations for @@ -60,16 +62,18 @@ void Breakpoint::CreateJsonObject(llvm::json::Object &object) { if (bp_addr.IsValid()) { std::string formatted_addr = "0x" + llvm::utohexstr(bp_addr.GetLoadAddress(m_bp.GetTarget())); -object.try_emplace("instructionReference", formatted_addr); +breakpoint.instructionReference = formatted_addr; auto line_entry = bp_addr.GetLineEntry(); const auto line = line_entry.GetLine(); if (line != UINT32_MAX) - object.try_emplace("line", line); + breakpoint.line = line; const auto column = line_entry.GetColumn(); if (column != 0) - object.try_emplace("column", column); -object.try_emplace("source", CreateSource(line_entry)); + breakpoint.column = column; +breakpoint.source = CreateSource(line_entry); } + + return breakpoint; } bool Breakpoint::MatchesName(const char *name) { diff --git a/lldb/tools/lldb-dap/Breakpoint.h b/lldb/tools/lldb-dap/Breakpoint.h index 580017125af44..c4f1fa291f181 100644 --- a/lldb/tools/lldb-dap/Breakpoint.h +++ b/lldb/tools/lldb-dap/Breakpoint.h @@ -17,14 +17,16 @@ namespace lldb_dap { class Breakpoint : public BreakpointBase { public: - Breakpoint(DAP &d, const llvm::
[Lldb-commits] [lldb] [llvm] [lldb-dap] migrate set breakpoint requests (PR #137448)
https://github.com/eronnen ready_for_review https://github.com/llvm/llvm-project/pull/137448 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb-dap] migrate set breakpoint requests (PR #137448)
eronnen wrote: CC @ashgti https://github.com/llvm/llvm-project/pull/137448 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb-dap] migrate set breakpoint requests (PR #137448)
https://github.com/eronnen edited https://github.com/llvm/llvm-project/pull/137448 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][docs] Document new frame-format variables (PR #137522)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes Documents https://github.com/llvm/llvm-project/pull/131836 --- Full diff: https://github.com/llvm/llvm-project/pull/137522.diff 1 Files Affected: - (modified) lldb/docs/use/formatting.rst (+49-1) ``diff diff --git a/lldb/docs/use/formatting.rst b/lldb/docs/use/formatting.rst index 7b3f01eebc891..6063a47e279f0 100644 --- a/lldb/docs/use/formatting.rst +++ b/lldb/docs/use/formatting.rst @@ -85,10 +85,24 @@ A complete list of currently supported format string variables is listed below: +---+-+ | ``function.name`` | The name of the current function or symbol. | +---+-+ -| ``function.name-with-args`` | The name of the current function with arguments and values or the symbol name. | +| ``function.name-with-args`` | The name of the current function with arguments and values or the symbol name. The name will be displayed according to the current frame's language if possible. | +---+-+ | ``function.name-without-args``| The name of the current function without arguments and values (used to include a function name in-line in the ``disassembly-format``) | +---+-+ +| ``function.basename``| The basename of the current function depending on the frame's language. E.g., for C++ the basename for `void ns::foo::bar(int) const` is `bar`. | ++---+-+ +| ``function.scope``| The scope qualifiers of the current function depending on the frame's language. E.g., for C++ the scope for `void ns::foo::bar(int) const` is `ns::foo`. | ++---+-+ +| ``function.template-arguments``| The template arguments of the current function depending on the frame's language. E.g., for C++ the template arguments for `void ns::foo::bar(int) const` are ``. | ++---+--
[Lldb-commits] [lldb] b546baf - [lldb-dap] Support the Module Event (#137380)
Author: Jonas Devlieghere Date: 2025-04-27T10:21:19-07:00 New Revision: b546baff48767d54da03049d4f30690649a5e599 URL: https://github.com/llvm/llvm-project/commit/b546baff48767d54da03049d4f30690649a5e599 DIFF: https://github.com/llvm/llvm-project/commit/b546baff48767d54da03049d4f30690649a5e599.diff LOG: [lldb-dap] Support the Module Event (#137380) The module event indicates that some information about a module has changed. The event is supported by the Emacs and Visual Studio DAP clients. This PR adds support for emitting the event from lldb-dap. Fixes #137058 Added: Modified: lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py lldb/test/API/tools/lldb-dap/module/TestDAP_module.py lldb/tools/lldb-dap/DAP.cpp lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp Removed: diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 40bdcf99e5b09..99fcc423894b6 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -135,6 +135,7 @@ def __init__(self, recv, send, init_commands, log_file=None): self.breakpoint_events = [] self.progress_events = [] self.reverse_requests = [] +self.module_events = [] self.sequence = 1 self.threads = None self.recv_thread.start() @@ -255,6 +256,11 @@ def handle_recv_packet(self, packet): # and 'progressEnd' events. Keep these around in case test # cases want to verify them. self.progress_events.append(packet) +elif event == "module": +# Module events indicate that some information about a module has changed. +self.module_events.append(packet) +# no need to add 'module' event packets to our packets list +return keepGoing elif packet_type == "response": if packet["command"] == "disconnect": diff --git a/lldb/test/API/tools/lldb-dap/module/TestDAP_module.py b/lldb/test/API/tools/lldb-dap/module/TestDAP_module.py index a4e0f04d450d9..210819cfdd732 100644 --- a/lldb/test/API/tools/lldb-dap/module/TestDAP_module.py +++ b/lldb/test/API/tools/lldb-dap/module/TestDAP_module.py @@ -57,6 +57,27 @@ def checkSymbolsLoadedWithSize(): self.assertEqual(program, program_module["path"]) self.assertIn("addressRange", program_module) +# Collect all the module names we saw as events. +module_new_names = [] +module_changed_names = [] +for module_event in self.dap_server.module_events: +module_name = module_event["body"]["module"]["name"] +reason = module_event["body"]["reason"] +if reason == "new": +module_new_names.append(module_name) +elif reason == "changed": +module_changed_names.append(module_name) + +# Make sure we got an event for every active module. +self.assertNotEqual(len(module_new_names), 0) +for module in active_modules: +self.assertIn(module, module_new_names) + +# Make sure we got an update event for the program module when the +# symbols got added. +self.assertNotEqual(len(module_changed_names), 0) +self.assertIn(program_module["name"], module_changed_names) + @skipIfWindows def test_modules(self): """ diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index 55d49667b6398..b593353110787 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -693,7 +693,11 @@ void DAP::SetTarget(const lldb::SBTarget target) { lldb::SBListener listener = this->debugger.GetListener(); listener.StartListeningForEvents( this->target.GetBroadcaster(), -lldb::SBTarget::eBroadcastBitBreakpointChanged); +lldb::SBTarget::eBroadcastBitBreakpointChanged | +lldb::SBTarget::eBroadcastBitModulesLoaded | +lldb::SBTarget::eBroadcastBitModulesUnloaded | +lldb::SBTarget::eBroadcastBitSymbolsLoaded | +lldb::SBTarget::eBroadcastBitSymbolsChanged); listener.StartListeningForEvents(this->broadcaster, eBroadcastBitStopEventThread); } diff --git a/lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp index 7d8ac676ba935..ce34c52bcc334 100644 --- a/lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp @@ -15,6 +15,8 @@ #include "lldb/API/SBEvent.h" #include "lldb/API/SBListener.h" #include "lldb/API/SBStream.h" +#include "lldb/API/SBTarget.h" +#include using namespace lldb
[Lldb-commits] [lldb] [lldb-dap] Support the Module Event (PR #137380)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/137380 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][docs] Document new frame-format variables (PR #137522)
https://github.com/JDevlieghere approved this pull request. LGTM but please format the table before merging. https://github.com/llvm/llvm-project/pull/137522 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][docs] Document new frame-format variables (PR #137522)
@@ -85,10 +85,27 @@ A complete list of currently supported format string variables is listed below: +---+-+ | ``function.name`` | The name of the current function or symbol. | +---+-+ -| ``function.name-with-args`` | The name of the current function with arguments and values or the symbol name. | +| ``function.name-with-args`` | The name of the current function with arguments and values or the symbol name. The name will be displayed according to the current frame's language if possible. | +---+-+ | ``function.name-without-args``| The name of the current function without arguments and values (used to include a function name in-line in the ``disassembly-format``) | +---+-+ +| ``function.basename`` | The basename of the current function depending on the frame's language. E.g., for C++ the basename for `void ns::foo::bar(int) const` is `bar`. | JDevlieghere wrote: The description should use double backticks. ```suggestion | ``function.basename`` | The basename of the current function depending on the frame's language. E.g., for C++ the basename for ``void ns::foo::bar(int) const`` is ``bar``. | ``` https://github.com/llvm/llvm-project/pull/137522 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb-dap] Migrating breakpointLocations request to use typed RequestHandler (PR #137426)
https://github.com/ashgti approved this pull request. Awesome! https://github.com/llvm/llvm-project/pull/137426 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Make lldb-dap.executable-path machine specific (PR #137485)
https://github.com/ashgti approved this pull request. https://github.com/llvm/llvm-project/pull/137485 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][docs] Document new frame-format variables (PR #137522)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/137522 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate DNBTimer away from PThreadMutex (NFC) (PR #137540)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/137540 The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates DNBTimer away from that class in preparation for removing PThreadMutex. >From 3a5fe9e31fc5b5e97e7442a628dd51454da6bc63 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Sun, 27 Apr 2025 11:21:34 -0700 Subject: [PATCH] [debugserver] Migrate DNBTimer away from PThreadMutex (NFC) The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates DNBTimer away from that class in preparation for removing PThreadMutex. --- lldb/tools/debugserver/source/DNBTimer.h | 42 +--- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/lldb/tools/debugserver/source/DNBTimer.h b/lldb/tools/debugserver/source/DNBTimer.h index 2251c50fb8768..78b64c6583d3d 100644 --- a/lldb/tools/debugserver/source/DNBTimer.h +++ b/lldb/tools/debugserver/source/DNBTimer.h @@ -14,7 +14,6 @@ #define LLDB_TOOLS_DEBUGSERVER_SOURCE_DNBTIMER_H #include "DNBDefs.h" -#include "PThreadMutex.h" #include #include #include @@ -22,17 +21,17 @@ class DNBTimer { public: // Constructors and Destructors - DNBTimer(bool threadSafe) : m_mutexAP() { + DNBTimer(bool threadSafe) { if (threadSafe) - m_mutexAP.reset(new PThreadMutex(PTHREAD_MUTEX_RECURSIVE)); + m_mutex_up = std::make_unique(); Reset(); } - DNBTimer(const DNBTimer &rhs) : m_mutexAP() { + DNBTimer(const DNBTimer &rhs) { // Create a new mutex to make this timer thread safe as well if // the timer we are copying is thread safe if (rhs.IsThreadSafe()) - m_mutexAP.reset(new PThreadMutex(PTHREAD_MUTEX_RECURSIVE)); + m_mutex_up = std::make_unique(); m_timeval = rhs.m_timeval; } @@ -40,35 +39,43 @@ class DNBTimer { // Create a new mutex to make this timer thread safe as well if // the timer we are copying is thread safe if (rhs.IsThreadSafe()) - m_mutexAP.reset(new PThreadMutex(PTHREAD_MUTEX_RECURSIVE)); + m_mutex_up = std::make_unique(); m_timeval = rhs.m_timeval; return *this; } ~DNBTimer() {} - bool IsThreadSafe() const { return m_mutexAP.get() != NULL; } + bool IsThreadSafe() const { return static_cast(m_mutex_up); } // Reset the time value to now void Reset() { -PTHREAD_MUTEX_LOCKER(locker, m_mutexAP.get()); +auto guard = m_mutex_up + ? std::unique_lock() + : std::unique_lock(*m_mutex_up); gettimeofday(&m_timeval, NULL); } // Get the total microseconds since Jan 1, 1970 uint64_t TotalMicroSeconds() const { -PTHREAD_MUTEX_LOCKER(locker, m_mutexAP.get()); +auto guard = m_mutex_up + ? std::unique_lock() + : std::unique_lock(*m_mutex_up); return (uint64_t)(m_timeval.tv_sec) * 100ull + (uint64_t)m_timeval.tv_usec; } void GetTime(uint64_t &sec, uint32_t &usec) const { -PTHREAD_MUTEX_LOCKER(locker, m_mutexAP.get()); +auto guard = m_mutex_up + ? std::unique_lock() + : std::unique_lock(*m_mutex_up); sec = m_timeval.tv_sec; usec = m_timeval.tv_usec; } // Return the number of microseconds elapsed between now and the // m_timeval uint64_t ElapsedMicroSeconds(bool update) { -PTHREAD_MUTEX_LOCKER(locker, m_mutexAP.get()); +auto guard = m_mutex_up + ? std::unique_lock() + : std::unique_lock(*m_mutex_up); struct timeval now; gettimeofday(&now, NULL); uint64_t now_usec = @@ -115,19 +122,16 @@ class DNBTimer { OffsetTimeOfDay(&now); if (now.tv_sec > ts.tv_sec) return true; -else if (now.tv_sec < ts.tv_sec) +if (now.tv_sec < ts.tv_sec) return false; -else { - if (now.tv_nsec > ts.tv_nsec) -return true; - else -return false; -} +if (now.tv_nsec > ts.tv_nsec) + return true; +return false; } protected: // Classes that inherit from DNBTimer can see and modify these - std::unique_ptr m_mutexAP; + std::unique_ptr m_mutex_up; struct timeval m_timeval; }; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] daa1e17 - [lldb-dap] Make lldb-dap.executable-path machine specific (#137485)
Author: Jonas Devlieghere Date: 2025-04-27T11:25:56-07:00 New Revision: daa1e175531495b0ba07179a2c7fc609eb7d371c URL: https://github.com/llvm/llvm-project/commit/daa1e175531495b0ba07179a2c7fc609eb7d371c DIFF: https://github.com/llvm/llvm-project/commit/daa1e175531495b0ba07179a2c7fc609eb7d371c.diff LOG: [lldb-dap] Make lldb-dap.executable-path machine specific (#137485) Change the scope [1] of lldb-dap.executable-path to "machine-overridable": > Machine specific settings that can be overridden by workspace or > folder settings. Practically speaking, this means that the path won't be synced across machines and "(Not synced)" will show up next to the setting. I believe it doesn't make sense to sync this setting (and I remember a bug report where this caused trouble when using VS Code remotely), plus it matches what clangd does for its corresponding setting. The extension has logic to find the binary in your path or with `xcrun` which in most cases should do the right thing and prevent you from having to override this setting. [1] https://code.visualstudio.com/api/references/contribution-points#Configuration-property-schema Added: Modified: lldb/tools/lldb-dap/package.json Removed: diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json index 3957e3f27f297..c25d5033d09f1 100644 --- a/lldb/tools/lldb-dap/package.json +++ b/lldb/tools/lldb-dap/package.json @@ -74,7 +74,8 @@ "lldb-dap.executable-path": { "scope": "resource", "type": "string", - "description": "The path to the lldb-dap binary." + "scope": "machine-overridable", + "description": "The path to the lldb-dap binary, e.g. /usr/local/bin/lldb-dap" }, "lldb-dap.arguments": { "scope": "resource", ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate DNBTimer away from PThreadMutex (NFC) (PR #137540)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates DNBTimer away from that class in preparation for removing PThreadMutex. --- Full diff: https://github.com/llvm/llvm-project/pull/137540.diff 1 Files Affected: - (modified) lldb/tools/debugserver/source/DNBTimer.h (+23-19) ``diff diff --git a/lldb/tools/debugserver/source/DNBTimer.h b/lldb/tools/debugserver/source/DNBTimer.h index 2251c50fb8768..78b64c6583d3d 100644 --- a/lldb/tools/debugserver/source/DNBTimer.h +++ b/lldb/tools/debugserver/source/DNBTimer.h @@ -14,7 +14,6 @@ #define LLDB_TOOLS_DEBUGSERVER_SOURCE_DNBTIMER_H #include "DNBDefs.h" -#include "PThreadMutex.h" #include #include #include @@ -22,17 +21,17 @@ class DNBTimer { public: // Constructors and Destructors - DNBTimer(bool threadSafe) : m_mutexAP() { + DNBTimer(bool threadSafe) { if (threadSafe) - m_mutexAP.reset(new PThreadMutex(PTHREAD_MUTEX_RECURSIVE)); + m_mutex_up = std::make_unique(); Reset(); } - DNBTimer(const DNBTimer &rhs) : m_mutexAP() { + DNBTimer(const DNBTimer &rhs) { // Create a new mutex to make this timer thread safe as well if // the timer we are copying is thread safe if (rhs.IsThreadSafe()) - m_mutexAP.reset(new PThreadMutex(PTHREAD_MUTEX_RECURSIVE)); + m_mutex_up = std::make_unique(); m_timeval = rhs.m_timeval; } @@ -40,35 +39,43 @@ class DNBTimer { // Create a new mutex to make this timer thread safe as well if // the timer we are copying is thread safe if (rhs.IsThreadSafe()) - m_mutexAP.reset(new PThreadMutex(PTHREAD_MUTEX_RECURSIVE)); + m_mutex_up = std::make_unique(); m_timeval = rhs.m_timeval; return *this; } ~DNBTimer() {} - bool IsThreadSafe() const { return m_mutexAP.get() != NULL; } + bool IsThreadSafe() const { return static_cast(m_mutex_up); } // Reset the time value to now void Reset() { -PTHREAD_MUTEX_LOCKER(locker, m_mutexAP.get()); +auto guard = m_mutex_up + ? std::unique_lock() + : std::unique_lock(*m_mutex_up); gettimeofday(&m_timeval, NULL); } // Get the total microseconds since Jan 1, 1970 uint64_t TotalMicroSeconds() const { -PTHREAD_MUTEX_LOCKER(locker, m_mutexAP.get()); +auto guard = m_mutex_up + ? std::unique_lock() + : std::unique_lock(*m_mutex_up); return (uint64_t)(m_timeval.tv_sec) * 100ull + (uint64_t)m_timeval.tv_usec; } void GetTime(uint64_t &sec, uint32_t &usec) const { -PTHREAD_MUTEX_LOCKER(locker, m_mutexAP.get()); +auto guard = m_mutex_up + ? std::unique_lock() + : std::unique_lock(*m_mutex_up); sec = m_timeval.tv_sec; usec = m_timeval.tv_usec; } // Return the number of microseconds elapsed between now and the // m_timeval uint64_t ElapsedMicroSeconds(bool update) { -PTHREAD_MUTEX_LOCKER(locker, m_mutexAP.get()); +auto guard = m_mutex_up + ? std::unique_lock() + : std::unique_lock(*m_mutex_up); struct timeval now; gettimeofday(&now, NULL); uint64_t now_usec = @@ -115,19 +122,16 @@ class DNBTimer { OffsetTimeOfDay(&now); if (now.tv_sec > ts.tv_sec) return true; -else if (now.tv_sec < ts.tv_sec) +if (now.tv_sec < ts.tv_sec) return false; -else { - if (now.tv_nsec > ts.tv_nsec) -return true; - else -return false; -} +if (now.tv_nsec > ts.tv_nsec) + return true; +return false; } protected: // Classes that inherit from DNBTimer can see and modify these - std::unique_ptr m_mutexAP; + std::unique_ptr m_mutex_up; struct timeval m_timeval; }; `` https://github.com/llvm/llvm-project/pull/137540 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Make lldb-dap.executable-path machine specific (PR #137485)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/137485 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate DNBLog away from PThreadMutex (NFC) (PR #137541)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/137541 The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates DNBLog away from that class in preparation for removing PThreadMutex. >From d0dc2fd47305687005cc80b054611ee6c207296e Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Sun, 27 Apr 2025 11:26:30 -0700 Subject: [PATCH] [debugserver] Migrate DNBLog away from PThreadMutex (NFC) The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates DNBLog away from that class in preparation for removing PThreadMutex. --- lldb/tools/debugserver/source/DNBLog.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lldb/tools/debugserver/source/DNBLog.cpp b/lldb/tools/debugserver/source/DNBLog.cpp index d3045ace16f3d..6ad6b6598d1c3 100644 --- a/lldb/tools/debugserver/source/DNBLog.cpp +++ b/lldb/tools/debugserver/source/DNBLog.cpp @@ -17,7 +17,6 @@ static int g_verbose = 0; #if defined(DNBLOG_ENABLED) -#include "PThreadMutex.h" #include #include #include @@ -64,8 +63,8 @@ bool DNBLogEnabledForAny(uint32_t mask) { } static inline void _DNBLogVAPrintf(uint32_t flags, const char *format, va_list args) { - static PThreadMutex g_LogThreadedMutex(PTHREAD_MUTEX_RECURSIVE); - PTHREAD_MUTEX_LOCKER(locker, g_LogThreadedMutex); + static std::recursive_mutex g_LogThreadedMutex; + std::lock_guard guard(g_LogThreadedMutex); if (g_log_callback) g_log_callback(g_log_baton, flags, format, args); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate DNBLog away from PThreadMutex (NFC) (PR #137541)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates DNBLog away from that class in preparation for removing PThreadMutex. --- Full diff: https://github.com/llvm/llvm-project/pull/137541.diff 1 Files Affected: - (modified) lldb/tools/debugserver/source/DNBLog.cpp (+2-3) ``diff diff --git a/lldb/tools/debugserver/source/DNBLog.cpp b/lldb/tools/debugserver/source/DNBLog.cpp index d3045ace16f3d..6ad6b6598d1c3 100644 --- a/lldb/tools/debugserver/source/DNBLog.cpp +++ b/lldb/tools/debugserver/source/DNBLog.cpp @@ -17,7 +17,6 @@ static int g_verbose = 0; #if defined(DNBLOG_ENABLED) -#include "PThreadMutex.h" #include #include #include @@ -64,8 +63,8 @@ bool DNBLogEnabledForAny(uint32_t mask) { } static inline void _DNBLogVAPrintf(uint32_t flags, const char *format, va_list args) { - static PThreadMutex g_LogThreadedMutex(PTHREAD_MUTEX_RECURSIVE); - PTHREAD_MUTEX_LOCKER(locker, g_LogThreadedMutex); + static std::recursive_mutex g_LogThreadedMutex; + std::lock_guard guard(g_LogThreadedMutex); if (g_log_callback) g_log_callback(g_log_baton, flags, format, args); `` https://github.com/llvm/llvm-project/pull/137541 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate MachThreadList away from PThreadMutex (NFC) (PR #137542)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates MachThreadList away from that class in preparation for removing PThreadMutex. --- Full diff: https://github.com/llvm/llvm-project/pull/137542.diff 2 Files Affected: - (modified) lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp (+18-20) - (modified) lldb/tools/debugserver/source/MacOSX/MachThreadList.h (+1-1) ``diff diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp index cf3687985173f..36e6c1942b35f 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp @@ -23,8 +23,7 @@ #include MachThreadList::MachThreadList() -: m_threads(), m_threads_mutex(PTHREAD_MUTEX_RECURSIVE), - m_is_64_bit(false) {} +: m_threads(), m_threads_mutex(), m_is_64_bit(false) {} MachThreadList::~MachThreadList() = default; @@ -116,7 +115,7 @@ const char *MachThreadList::GetThreadInfo(nub_thread_t tid) const { } MachThreadSP MachThreadList::GetThreadByID(nub_thread_t tid) const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); MachThreadSP thread_sp; const size_t num_threads = m_threads.size(); for (size_t idx = 0; idx < num_threads; ++idx) { @@ -130,7 +129,7 @@ MachThreadSP MachThreadList::GetThreadByID(nub_thread_t tid) const { MachThreadSP MachThreadList::GetThreadByMachPortNumber(thread_t mach_port_number) const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); MachThreadSP thread_sp; const size_t num_threads = m_threads.size(); for (size_t idx = 0; idx < num_threads; ++idx) { @@ -144,7 +143,7 @@ MachThreadList::GetThreadByMachPortNumber(thread_t mach_port_number) const { nub_thread_t MachThreadList::GetThreadIDByMachPortNumber(thread_t mach_port_number) const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); MachThreadSP thread_sp; const size_t num_threads = m_threads.size(); for (size_t idx = 0; idx < num_threads; ++idx) { @@ -157,7 +156,7 @@ MachThreadList::GetThreadIDByMachPortNumber(thread_t mach_port_number) const { thread_t MachThreadList::GetMachPortNumberByThreadID( nub_thread_t globally_unique_id) const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); MachThreadSP thread_sp; const size_t num_threads = m_threads.size(); for (size_t idx = 0; idx < num_threads; ++idx) { @@ -219,12 +218,12 @@ bool MachThreadList::RestoreRegisterState(nub_thread_t tid, uint32_t save_id) { } nub_size_t MachThreadList::NumThreads() const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); return m_threads.size(); } nub_thread_t MachThreadList::ThreadIDAtIndex(nub_size_t idx) const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); if (idx < m_threads.size()) return m_threads[idx]->ThreadID(); return INVALID_NUB_THREAD; @@ -248,7 +247,7 @@ bool MachThreadList::NotifyException(MachException::Data &exc) { } void MachThreadList::Clear() { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); m_threads.clear(); } @@ -259,7 +258,7 @@ MachThreadList::UpdateThreadList(MachProcess *process, bool update, DNBLogThreadedIf(LOG_THREAD, "MachThreadList::UpdateThreadList (pid = %4.4x, " "update = %u) process stop count = %u", process->ProcessID(), update, process->StopCount()); - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); if (process->StopCount() == 0) { int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, process->ProcessID()}; @@ -346,8 +345,7 @@ MachThreadList::UpdateThreadList(MachProcess *process, bool update, } void MachThreadList::CurrentThread(MachThreadSP &thread_sp) { - // locker will keep a mutex locked until it goes out of scope - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); if (m_current_thread.get() == NULL) { // Figure out which thread is going to be our current thread. // This is currently done by finding the first thread in the list @@ -364,7 +362,7 @@ void MachThreadList::CurrentThread(MachThreadSP &thread_sp) { } void MachThreadList::Dump() const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); const size_t num_threads = m_threads.size(); for (uint32_t idx = 0; idx < num_threads; ++idx) { m_threads[idx]->Dump(idx); @@ -373,7 +371,7 @@ void MachThreadList::Dump() const { void MachThreadLi
[Lldb-commits] [lldb] [debugserver] Migrate MachThreadList away from PThreadMutex (NFC) (PR #137542)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/137542 The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates MachThreadList away from that class in preparation for removing PThreadMutex. >From a02500a733b590acf7008e5963df19f2a7617f26 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Sun, 27 Apr 2025 11:29:39 -0700 Subject: [PATCH] [debugserver] Migrate MachThreadList away from PThreadMutex (NFC) The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates MachThreadList away from that class in preparation for removing PThreadMutex. --- .../source/MacOSX/MachThreadList.cpp | 38 +-- .../source/MacOSX/MachThreadList.h| 2 +- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp index cf3687985173f..36e6c1942b35f 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp @@ -23,8 +23,7 @@ #include MachThreadList::MachThreadList() -: m_threads(), m_threads_mutex(PTHREAD_MUTEX_RECURSIVE), - m_is_64_bit(false) {} +: m_threads(), m_threads_mutex(), m_is_64_bit(false) {} MachThreadList::~MachThreadList() = default; @@ -116,7 +115,7 @@ const char *MachThreadList::GetThreadInfo(nub_thread_t tid) const { } MachThreadSP MachThreadList::GetThreadByID(nub_thread_t tid) const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); MachThreadSP thread_sp; const size_t num_threads = m_threads.size(); for (size_t idx = 0; idx < num_threads; ++idx) { @@ -130,7 +129,7 @@ MachThreadSP MachThreadList::GetThreadByID(nub_thread_t tid) const { MachThreadSP MachThreadList::GetThreadByMachPortNumber(thread_t mach_port_number) const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); MachThreadSP thread_sp; const size_t num_threads = m_threads.size(); for (size_t idx = 0; idx < num_threads; ++idx) { @@ -144,7 +143,7 @@ MachThreadList::GetThreadByMachPortNumber(thread_t mach_port_number) const { nub_thread_t MachThreadList::GetThreadIDByMachPortNumber(thread_t mach_port_number) const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); MachThreadSP thread_sp; const size_t num_threads = m_threads.size(); for (size_t idx = 0; idx < num_threads; ++idx) { @@ -157,7 +156,7 @@ MachThreadList::GetThreadIDByMachPortNumber(thread_t mach_port_number) const { thread_t MachThreadList::GetMachPortNumberByThreadID( nub_thread_t globally_unique_id) const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); MachThreadSP thread_sp; const size_t num_threads = m_threads.size(); for (size_t idx = 0; idx < num_threads; ++idx) { @@ -219,12 +218,12 @@ bool MachThreadList::RestoreRegisterState(nub_thread_t tid, uint32_t save_id) { } nub_size_t MachThreadList::NumThreads() const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); return m_threads.size(); } nub_thread_t MachThreadList::ThreadIDAtIndex(nub_size_t idx) const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); if (idx < m_threads.size()) return m_threads[idx]->ThreadID(); return INVALID_NUB_THREAD; @@ -248,7 +247,7 @@ bool MachThreadList::NotifyException(MachException::Data &exc) { } void MachThreadList::Clear() { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); m_threads.clear(); } @@ -259,7 +258,7 @@ MachThreadList::UpdateThreadList(MachProcess *process, bool update, DNBLogThreadedIf(LOG_THREAD, "MachThreadList::UpdateThreadList (pid = %4.4x, " "update = %u) process stop count = %u", process->ProcessID(), update, process->StopCount()); - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); if (process->StopCount() == 0) { int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, process->ProcessID()}; @@ -346,8 +345,7 @@ MachThreadList::UpdateThreadList(MachProcess *process, bool update, } void MachThreadList::CurrentThread(MachThreadSP &thread_sp) { - // locker will keep a mutex locked until it goes out of scope - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); if (m_current_thread.get() == NULL) { // Figure out which thread is going to be our current thread. // This is currently done by finding the first thread in the list @@ -364,7 +362,7 @@ void MachThreadList::CurrentThread(MachThreadSP &thread_sp)
[Lldb-commits] [lldb] Complete ToJSON for OptionValues (PR #137375)
https://github.com/da-viper closed https://github.com/llvm/llvm-project/pull/137375 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7670af5 - [lldb][lldb-dap] Respect x86 disassembly flavor setting (#134722)
Author: Ebuka Ezike Date: 2025-04-27T12:13:38+01:00 New Revision: 7670af5a274b801adf83fcc0c7c4011e0be0bc91 URL: https://github.com/llvm/llvm-project/commit/7670af5a274b801adf83fcc0c7c4011e0be0bc91 DIFF: https://github.com/llvm/llvm-project/commit/7670af5a274b801adf83fcc0c7c4011e0be0bc91.diff LOG: [lldb][lldb-dap] Respect x86 disassembly flavor setting (#134722) Ensure the disassembly respects the "target.x86-disassembly-flavor" setting for x86 and x86_64 targets. Depends on #134626 - Signed-off-by: Ebuka Ezike Co-authored-by: Jonas Devlieghere Added: Modified: lldb/source/Commands/CommandObjectDisassemble.cpp lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp Removed: diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp index 70e687e19ac6d..5774effb9e9ba 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.cpp +++ b/lldb/source/Commands/CommandObjectDisassemble.cpp @@ -190,6 +190,7 @@ void CommandObjectDisassemble::CommandOptions::OptionParsingStarting( // architecture. For now GetDisassemblyFlavor is really only valid for x86 // (and for the llvm assembler plugin, but I'm papering over that since that // is the only disassembler plugin we have... +// This logic is duplicated in `Handler/DisassembleRequestHandler`. if (target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86 || target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86_64) { diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp index f0cb7be70210d..d738f54ff1a9f 100644 --- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp @@ -116,7 +116,24 @@ void DisassembleRequestHandler::operator()( const auto inst_count = GetInteger(arguments, "instructionCount").value_or(0); - lldb::SBInstructionList insts = dap.target.ReadInstructions(addr, inst_count); + + std::string flavor_string; + const auto target_triple = llvm::StringRef(dap.target.GetTriple()); + // This handles both 32 and 64bit x86 architecture. The logic is duplicated in + // `CommandObjectDisassemble::CommandOptions::OptionParsingStarting` + if (target_triple.starts_with("x86")) { +const lldb::SBStructuredData flavor = +dap.debugger.GetSetting("target.x86-disassembly-flavor"); + +const size_t str_length = flavor.GetStringValue(nullptr, 0); +if (str_length != 0) { + flavor_string.resize(str_length + 1); + flavor.GetStringValue(flavor_string.data(), flavor_string.length()); +} + } + + lldb::SBInstructionList insts = + dap.target.ReadInstructions(addr, inst_count, flavor_string.c_str()); if (!insts.IsValid()) { response["success"] = false; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d1adb0b - Complete ToJSON for OptionValues (#137375)
Author: Ebuka Ezike Date: 2025-04-27T12:11:14+01:00 New Revision: d1adb0b8cd64607ef64d8bebc3197964a06de73a URL: https://github.com/llvm/llvm-project/commit/d1adb0b8cd64607ef64d8bebc3197964a06de73a DIFF: https://github.com/llvm/llvm-project/commit/d1adb0b8cd64607ef64d8bebc3197964a06de73a.diff LOG: Complete ToJSON for OptionValues (#137375) Completes the ToJSON function for `OptionValue` types and make the interface function pure virtual - Co-authored-by: Jonas Devlieghere Added: Modified: lldb/include/lldb/Interpreter/OptionValue.h lldb/include/lldb/Interpreter/OptionValueArch.h lldb/include/lldb/Interpreter/OptionValueArray.h lldb/include/lldb/Interpreter/OptionValueBoolean.h lldb/include/lldb/Interpreter/OptionValueChar.h lldb/include/lldb/Interpreter/OptionValueDictionary.h lldb/include/lldb/Interpreter/OptionValueEnumeration.h lldb/include/lldb/Interpreter/OptionValueFileColonLine.h lldb/include/lldb/Interpreter/OptionValueFileSpec.h lldb/include/lldb/Interpreter/OptionValueFileSpecList.h lldb/include/lldb/Interpreter/OptionValueFormat.h lldb/include/lldb/Interpreter/OptionValueFormatEntity.h lldb/include/lldb/Interpreter/OptionValueLanguage.h lldb/include/lldb/Interpreter/OptionValuePathMappings.h lldb/include/lldb/Interpreter/OptionValueProperties.h lldb/include/lldb/Interpreter/OptionValueRegex.h lldb/include/lldb/Interpreter/OptionValueSInt64.h lldb/include/lldb/Interpreter/OptionValueString.h lldb/include/lldb/Interpreter/OptionValueUInt64.h lldb/include/lldb/Interpreter/OptionValueUUID.h lldb/include/lldb/Target/PathMappingList.h lldb/source/Interpreter/OptionValueArch.cpp lldb/source/Interpreter/OptionValueArray.cpp lldb/source/Interpreter/OptionValueDictionary.cpp lldb/source/Interpreter/OptionValueEnumeration.cpp lldb/source/Interpreter/OptionValueFileColonLine.cpp lldb/source/Interpreter/OptionValueFileSpecList.cpp lldb/source/Interpreter/OptionValueFormat.cpp lldb/source/Interpreter/OptionValueFormatEntity.cpp lldb/source/Interpreter/OptionValueLanguage.cpp lldb/source/Interpreter/OptionValuePathMappings.cpp lldb/source/Interpreter/OptionValueProperties.cpp lldb/source/Target/PathMappingList.cpp lldb/test/API/commands/settings/TestSettings.py Removed: diff --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h index ebc438517a7b1..e3c139155b0ef 100644 --- a/lldb/include/lldb/Interpreter/OptionValue.h +++ b/lldb/include/lldb/Interpreter/OptionValue.h @@ -93,15 +93,7 @@ class OptionValue { virtual void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) = 0; - // TODO: make this function pure virtual after implementing it in all - // child classes. - virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) { -// Return nullptr which will create a llvm::json::Value() that is a NULL -// value. No setting should ever really have a NULL value in JSON. This -// indicates an error occurred and if/when we add a FromJSON() it will know -// to fail if someone tries to set it with a NULL JSON value. -return nullptr; - } + virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const = 0; virtual Status SetValueFromString(llvm::StringRef value, diff --git a/lldb/include/lldb/Interpreter/OptionValueArch.h b/lldb/include/lldb/Interpreter/OptionValueArch.h index e175208794474..3ba07b65dd618 100644 --- a/lldb/include/lldb/Interpreter/OptionValueArch.h +++ b/lldb/include/lldb/Interpreter/OptionValueArch.h @@ -38,6 +38,8 @@ class OptionValueArch : public Cloneable { void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override; + llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override; + Status SetValueFromString(llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign) override; diff --git a/lldb/include/lldb/Interpreter/OptionValueArray.h b/lldb/include/lldb/Interpreter/OptionValueArray.h index 0e1bae103d41f..34170ef06a188 100644 --- a/lldb/include/lldb/Interpreter/OptionValueArray.h +++ b/lldb/include/lldb/Interpreter/OptionValueArray.h @@ -29,7 +29,7 @@ class OptionValueArray : public Cloneable { void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override; - llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override; + llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override; Status SetValueFromString(llvm::StringRef value, diff --git a/lldb/include/lldb/Interpreter/OptionValueBoolean.h b/lldb/include/lldb/Interpreter/OptionValueBoolean.h index 01e7c6c09d8e8..6d15dcd2fca5d 100644 --- a/lldb/include/lldb/
[Lldb-commits] [lldb] [debugserver] Migrate MachThread away from PThreadMutex (NFC) (PR #137543)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/137543 The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates MachThread away from PThreadMutex in preparation for removing it. >From bf532b6d9095d58d66f74cd3d8adfff21ec541c4 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Sun, 27 Apr 2025 11:33:57 -0700 Subject: [PATCH] [debugserver] Migrate MachThread away from PThreadMutex (NFC) The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates MachThread away from PThreadMutex in preparation for removing it. --- .../debugserver/source/MacOSX/MachThread.cpp | 15 +++ lldb/tools/debugserver/source/MacOSX/MachThread.h | 4 +--- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp index 69e1c9bb0e252..e161b8b5d 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp @@ -28,11 +28,11 @@ MachThread::MachThread(MachProcess *process, bool is_64_bit, uint64_t unique_thread_id, thread_t mach_port_num) : m_process(process), m_unique_id(unique_thread_id), m_mach_port_number(mach_port_num), m_seq_id(GetSequenceID()), - m_state(eStateUnloaded), m_state_mutex(PTHREAD_MUTEX_RECURSIVE), - m_suspend_count(0), m_stop_exception(), - m_arch_up(DNBArchProtocol::Create(this)), m_reg_sets(NULL), - m_num_reg_sets(0), m_extended_info(), m_dispatch_queue_name(), - m_is_64_bit(is_64_bit), m_pthread_qos_class_decode(nullptr) { + m_state(eStateUnloaded), m_state_mutex(), m_suspend_count(0), + m_stop_exception(), m_arch_up(DNBArchProtocol::Create(this)), + m_reg_sets(NULL), m_num_reg_sets(0), m_extended_info(), + m_dispatch_queue_name(), m_is_64_bit(is_64_bit), + m_pthread_qos_class_decode(nullptr) { nub_size_t num_reg_sets = 0; m_reg_sets = m_arch_up->GetRegisterSetInfo(&num_reg_sets); m_num_reg_sets = num_reg_sets; @@ -469,13 +469,12 @@ bool MachThread::NotifyException(MachException::Data &exc) { } nub_state_t MachThread::GetState() { - // If any other threads access this we will need a mutex for it - PTHREAD_MUTEX_LOCKER(locker, m_state_mutex); + std::lock_guard guard(m_state_mutex); return m_state; } void MachThread::SetState(nub_state_t state) { - PTHREAD_MUTEX_LOCKER(locker, m_state_mutex); + std::lock_guard guard(m_state_mutex); m_state = state; DNBLogThreadedIf(LOG_THREAD, "MachThread::SetState ( %s ) for tid = 0x%8.8" PRIx64 "", diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.h b/lldb/tools/debugserver/source/MacOSX/MachThread.h index 0c78ef1a337ed..1086b7c986f11 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThread.h +++ b/lldb/tools/debugserver/source/MacOSX/MachThread.h @@ -24,8 +24,6 @@ #include "DNBArch.h" #include "DNBRegisterInfo.h" #include "MachException.h" -#include "PThreadCondition.h" -#include "PThreadMutex.h" #include "ThreadInfo.h" @@ -139,7 +137,7 @@ class MachThread { // namesp. uint32_t m_seq_id; // A Sequential ID that increments with each new thread nub_state_t m_state; // The state of our process - PThreadMutex m_state_mutex;// Multithreaded protection for m_state + std::recursive_mutex m_state_mutex;// Multithreaded protection for m_state struct thread_basic_info m_basic_info; // Basic information for a thread used // to see if a thread is valid int32_t m_suspend_count; // The current suspend count > 0 means we have ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate MachThread away from PThreadMutex (NFC) (PR #137543)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates MachThread away from PThreadMutex in preparation for removing it. --- Full diff: https://github.com/llvm/llvm-project/pull/137543.diff 2 Files Affected: - (modified) lldb/tools/debugserver/source/MacOSX/MachThread.cpp (+7-8) - (modified) lldb/tools/debugserver/source/MacOSX/MachThread.h (+1-3) ``diff diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp index 69e1c9bb0e252..e161b8b5d 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp @@ -28,11 +28,11 @@ MachThread::MachThread(MachProcess *process, bool is_64_bit, uint64_t unique_thread_id, thread_t mach_port_num) : m_process(process), m_unique_id(unique_thread_id), m_mach_port_number(mach_port_num), m_seq_id(GetSequenceID()), - m_state(eStateUnloaded), m_state_mutex(PTHREAD_MUTEX_RECURSIVE), - m_suspend_count(0), m_stop_exception(), - m_arch_up(DNBArchProtocol::Create(this)), m_reg_sets(NULL), - m_num_reg_sets(0), m_extended_info(), m_dispatch_queue_name(), - m_is_64_bit(is_64_bit), m_pthread_qos_class_decode(nullptr) { + m_state(eStateUnloaded), m_state_mutex(), m_suspend_count(0), + m_stop_exception(), m_arch_up(DNBArchProtocol::Create(this)), + m_reg_sets(NULL), m_num_reg_sets(0), m_extended_info(), + m_dispatch_queue_name(), m_is_64_bit(is_64_bit), + m_pthread_qos_class_decode(nullptr) { nub_size_t num_reg_sets = 0; m_reg_sets = m_arch_up->GetRegisterSetInfo(&num_reg_sets); m_num_reg_sets = num_reg_sets; @@ -469,13 +469,12 @@ bool MachThread::NotifyException(MachException::Data &exc) { } nub_state_t MachThread::GetState() { - // If any other threads access this we will need a mutex for it - PTHREAD_MUTEX_LOCKER(locker, m_state_mutex); + std::lock_guard guard(m_state_mutex); return m_state; } void MachThread::SetState(nub_state_t state) { - PTHREAD_MUTEX_LOCKER(locker, m_state_mutex); + std::lock_guard guard(m_state_mutex); m_state = state; DNBLogThreadedIf(LOG_THREAD, "MachThread::SetState ( %s ) for tid = 0x%8.8" PRIx64 "", diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.h b/lldb/tools/debugserver/source/MacOSX/MachThread.h index 0c78ef1a337ed..1086b7c986f11 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThread.h +++ b/lldb/tools/debugserver/source/MacOSX/MachThread.h @@ -24,8 +24,6 @@ #include "DNBArch.h" #include "DNBRegisterInfo.h" #include "MachException.h" -#include "PThreadCondition.h" -#include "PThreadMutex.h" #include "ThreadInfo.h" @@ -139,7 +137,7 @@ class MachThread { // namesp. uint32_t m_seq_id; // A Sequential ID that increments with each new thread nub_state_t m_state; // The state of our process - PThreadMutex m_state_mutex;// Multithreaded protection for m_state + std::recursive_mutex m_state_mutex;// Multithreaded protection for m_state struct thread_basic_info m_basic_info; // Basic information for a thread used // to see if a thread is valid int32_t m_suspend_count; // The current suspend count > 0 means we have `` https://github.com/llvm/llvm-project/pull/137543 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate MachThread away from PThreadMutex (NFC) (PR #137543)
JDevlieghere wrote: Depends on https://github.com/llvm/llvm-project/pull/137542 because `MachThreadList` relies on `MachThread` to transitively include `PThreadMutex.h`. https://github.com/llvm/llvm-project/pull/137543 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb-dap] migrate set breakpoint requests (PR #137448)
https://github.com/eronnen updated https://github.com/llvm/llvm-project/pull/137448 >From dc8388b0027c75dba465c72009ac0c25750ae877 Mon Sep 17 00:00:00 2001 From: Ely Ronnen Date: Sat, 26 Apr 2025 10:25:21 +0200 Subject: [PATCH 1/2] adding breakpoints protocol types add all breakpoint requests JSON types decouple JSON from DAP Breakpoint classes forgor exception breakpoint response migrating breakpoint requests migrate breakpoints requests handler implementations remove CreateBreakpoint data breakpoint requests serialization fix GetFrame fix data breakpoint return exception breakpoints list restore exception breakpoints --- lldb/tools/lldb-dap/Breakpoint.cpp| 22 +- lldb/tools/lldb-dap/Breakpoint.h | 6 +- lldb/tools/lldb-dap/BreakpointBase.cpp| 12 +- lldb/tools/lldb-dap/BreakpointBase.h | 8 +- lldb/tools/lldb-dap/DAP.cpp | 11 +- lldb/tools/lldb-dap/DAP.h | 1 + lldb/tools/lldb-dap/FunctionBreakpoint.cpp| 8 +- lldb/tools/lldb-dap/FunctionBreakpoint.h | 3 +- .../DataBreakpointInfoRequestHandler.cpp | 175 -- .../Handler/InitializeRequestHandler.cpp | 2 +- lldb/tools/lldb-dap/Handler/RequestHandler.h | 51 ++-- .../Handler/SetBreakpointsRequestHandler.cpp | 180 +++--- .../SetDataBreakpointsRequestHandler.cpp | 98 ++-- .../SetFunctionBreakpointsRequestHandler.cpp | 115 ++--- ...etInstructionBreakpointsRequestHandler.cpp | 223 ++ ...TestGetTargetBreakpointsRequestHandler.cpp | 2 +- lldb/tools/lldb-dap/InstructionBreakpoint.cpp | 15 +- lldb/tools/lldb-dap/InstructionBreakpoint.h | 4 +- lldb/tools/lldb-dap/JSONUtils.cpp | 161 + lldb/tools/lldb-dap/JSONUtils.h | 67 +- .../lldb-dap/Protocol/ProtocolRequests.cpp| 70 ++ .../lldb-dap/Protocol/ProtocolRequests.h | 147 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp | 127 ++ lldb/tools/lldb-dap/Protocol/ProtocolTypes.h | 181 ++ lldb/tools/lldb-dap/SourceBreakpoint.cpp | 13 +- lldb/tools/lldb-dap/SourceBreakpoint.h| 3 +- lldb/tools/lldb-dap/Watchpoint.cpp| 26 +- lldb/tools/lldb-dap/Watchpoint.h | 6 +- llvm/include/llvm/Support/JSON.h | 8 + 29 files changed, 790 insertions(+), 955 deletions(-) diff --git a/lldb/tools/lldb-dap/Breakpoint.cpp b/lldb/tools/lldb-dap/Breakpoint.cpp index 5679fd545d53f..26d633d1d172e 100644 --- a/lldb/tools/lldb-dap/Breakpoint.cpp +++ b/lldb/tools/lldb-dap/Breakpoint.cpp @@ -14,7 +14,6 @@ #include "lldb/API/SBLineEntry.h" #include "lldb/API/SBMutex.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/Support/JSON.h" #include #include #include @@ -30,13 +29,16 @@ void Breakpoint::SetHitCondition() { m_bp.SetIgnoreCount(hitCount - 1); } -void Breakpoint::CreateJsonObject(llvm::json::Object &object) { +protocol::Breakpoint Breakpoint::ToProtocolBreakpoint() { + protocol::Breakpoint breakpoint; + // Each breakpoint location is treated as a separate breakpoint for VS code. // They don't have the notion of a single breakpoint with multiple locations. if (!m_bp.IsValid()) -return; - object.try_emplace("verified", m_bp.GetNumResolvedLocations() > 0); - object.try_emplace("id", m_bp.GetID()); +return breakpoint; + + breakpoint.verified = m_bp.GetNumResolvedLocations() > 0; + breakpoint.id = m_bp.GetID(); // VS Code DAP doesn't currently allow one breakpoint to have multiple // locations so we just report the first one. If we report all locations // then the IDE starts showing the wrong line numbers and locations for @@ -60,16 +62,18 @@ void Breakpoint::CreateJsonObject(llvm::json::Object &object) { if (bp_addr.IsValid()) { std::string formatted_addr = "0x" + llvm::utohexstr(bp_addr.GetLoadAddress(m_bp.GetTarget())); -object.try_emplace("instructionReference", formatted_addr); +breakpoint.instructionReference = formatted_addr; auto line_entry = bp_addr.GetLineEntry(); const auto line = line_entry.GetLine(); if (line != UINT32_MAX) - object.try_emplace("line", line); + breakpoint.line = line; const auto column = line_entry.GetColumn(); if (column != 0) - object.try_emplace("column", column); -object.try_emplace("source", CreateSource(line_entry)); + breakpoint.column = column; +breakpoint.source = CreateSource(line_entry); } + + return breakpoint; } bool Breakpoint::MatchesName(const char *name) { diff --git a/lldb/tools/lldb-dap/Breakpoint.h b/lldb/tools/lldb-dap/Breakpoint.h index 580017125af44..c4f1fa291f181 100644 --- a/lldb/tools/lldb-dap/Breakpoint.h +++ b/lldb/tools/lldb-dap/Breakpoint.h @@ -17,14 +17,16 @@ namespace lldb_dap { class Breakpoint : public BreakpointBase { public: - Breakpoint(DAP &d, const llvm::json::Object &obj) : BreakpointBase(d,
[Lldb-commits] [lldb] [llvm] [lldb-dap] migrate set breakpoint requests (PR #137448)
@@ -322,6 +323,186 @@ enum SteppingGranularity : unsigned { bool fromJSON(const llvm::json::Value &, SteppingGranularity &, llvm::json::Path); +/// Information about a breakpoint created in `setBreakpoints`, +/// `setFunctionBreakpoints`, `setInstructionBreakpoints`, or +/// `setDataBreakpoints` requests. +struct Breakpoint { + /// A machine-readable explanation of why a breakpoint may not be verified. + enum class Reason : unsigned { +/// Indicates a breakpoint might be verified in the future, but +/// the adapter cannot verify it in the current state. +eBreakpointReasonPending, +/// Indicates a breakpoint was not able to be verified, and the +/// adapter does not believe it can be verified without intervention. +eBreakpointReasonFailed, + }; + + /// The identifier for the breakpoint. It is needed if breakpoint events are + /// used to update or remove breakpoints. + std::optional id; + + /// If true, the breakpoint could be set (but not necessarily at the desired + /// location). + bool verified; + + /// A message about the state of the breakpoint. + /// This is shown to the user and can be used to explain why a breakpoint + /// could not be verified. + std::optional message; + + /// The source where the breakpoint is located. + std::optional source; + + /// The start line of the actual range covered by the breakpoint. + std::optional line; + + /// Start position of the source range covered by the breakpoint. It is + /// measured in UTF-16 code units and the client capability `columnsStartAt1` + /// determines whether it is 0- or 1-based. + std::optional column; + + /// The end line of the actual range covered by the breakpoint. + std::optional endLine; + + /// End position of the source range covered by the breakpoint. It is measured + /// in UTF-16 code units and the client capability `columnsStartAt1` + /// determines whether it is 0- or 1-based. If no end line is given, then the + /// end column is assumed to be in the start line. + std::optional endColumn; + + /// A memory reference to where the breakpoint is set. + std::optional instructionReference; + + /// The offset from the instruction reference. + /// This can be negative. + std::optional offset; + + /// A machine-readable explanation of why a breakpoint may not be verified. If + /// a breakpoint is verified or a specific reason is not known, the adapter + /// should omit this property. + std::optional reason; +}; +llvm::json::Value toJSON(const Breakpoint &); + +/// Properties of a breakpoint or logpoint passed to the `setBreakpoints` +/// request +struct SourceBreakpoint { + /// The source line of the breakpoint or logpoint. + uint32_t line; eronnen wrote: added https://github.com/llvm/llvm-project/pull/137448 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb-dap] migrate set breakpoint requests (PR #137448)
@@ -43,6 +43,32 @@ bool fromJSON(const json::Value &Params, Source &S, json::Path P) { O.map("sourceReference", S.sourceReference); } +static llvm::json::Value ToString(PresentationHint hint) { eronnen wrote: :100: https://github.com/llvm/llvm-project/pull/137448 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][docs] Document new frame-format variables (PR #137522)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/137522 >From 2388b0951a3e9b0e2ebd297881f17423c8d68b4e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sun, 27 Apr 2025 11:23:20 +0100 Subject: [PATCH 1/6] [lldb][docs] Document new frame-format variables --- lldb/docs/use/formatting.rst | 50 +++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/lldb/docs/use/formatting.rst b/lldb/docs/use/formatting.rst index 7b3f01eebc891..6063a47e279f0 100644 --- a/lldb/docs/use/formatting.rst +++ b/lldb/docs/use/formatting.rst @@ -85,10 +85,24 @@ A complete list of currently supported format string variables is listed below: +---+-+ | ``function.name`` | The name of the current function or symbol. | +---+-+ -| ``function.name-with-args`` | The name of the current function with arguments and values or the symbol name. | +| ``function.name-with-args`` | The name of the current function with arguments and values or the symbol name. The name will be displayed according to the current frame's language if possible. | +---+-+ | ``function.name-without-args``| The name of the current function without arguments and values (used to include a function name in-line in the ``disassembly-format``) | +---+-+ +| ``function.basename``| The basename of the current function depending on the frame's language. E.g., for C++ the basename for `void ns::foo::bar(int) const` is `bar`. | ++---+-+ +| ``function.scope``| The scope qualifiers of the current function depending on the frame's language. E.g., for C++ the scope for `void ns::foo::bar(int) const` is `ns::foo`. | ++---+-+ +| ``function.template-arguments``| The template arguments of the current function depending on the frame's language. E.g., for C++ the template arguments for `void ns::foo::bar(int) const` are ``. | ++---+---
[Lldb-commits] [lldb] cf035e8 - [lldb] Add missing include
Author: Adrian Prantl Date: 2025-04-27T14:32:13-07:00 New Revision: cf035e8abbf50efc9ea64c8bf4cdcb7133255a08 URL: https://github.com/llvm/llvm-project/commit/cf035e8abbf50efc9ea64c8bf4cdcb7133255a08 DIFF: https://github.com/llvm/llvm-project/commit/cf035e8abbf50efc9ea64c8bf4cdcb7133255a08.diff LOG: [lldb] Add missing include Added: Modified: lldb/tools/debugserver/source/MacOSX/MachThread.h Removed: diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.h b/lldb/tools/debugserver/source/MacOSX/MachThread.h index 1086b7c986f11..69567425542ff 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThread.h +++ b/lldb/tools/debugserver/source/MacOSX/MachThread.h @@ -13,6 +13,7 @@ #ifndef LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_MACHTHREAD_H #define LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_MACHTHREAD_H +#include #include #include ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb-dap] migrate set breakpoint requests (PR #137448)
https://github.com/eronnen edited https://github.com/llvm/llvm-project/pull/137448 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b15adef - [lldb] Add missing include
Author: Adrian Prantl Date: 2025-04-27T14:35:40-07:00 New Revision: b15adefefffb23fc5de7e26892b22a8716a53621 URL: https://github.com/llvm/llvm-project/commit/b15adefefffb23fc5de7e26892b22a8716a53621 DIFF: https://github.com/llvm/llvm-project/commit/b15adefefffb23fc5de7e26892b22a8716a53621.diff LOG: [lldb] Add missing include Added: Modified: lldb/tools/debugserver/source/DNBTimer.h Removed: diff --git a/lldb/tools/debugserver/source/DNBTimer.h b/lldb/tools/debugserver/source/DNBTimer.h index 78b64c6583d3d..70d14e002cc81 100644 --- a/lldb/tools/debugserver/source/DNBTimer.h +++ b/lldb/tools/debugserver/source/DNBTimer.h @@ -16,6 +16,7 @@ #include "DNBDefs.h" #include #include +#include #include class DNBTimer { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate RNBRemote away from PThreadMutex (NFC) (PR #137547)
https://github.com/jasonmolenda approved this pull request. https://github.com/llvm/llvm-project/pull/137547 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate PThreadEvent away from PThreadMutex (NFC) (PR #137554)
https://github.com/jasonmolenda approved this pull request. https://github.com/llvm/llvm-project/pull/137554 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Remove PThreadMutex (NFC) (PR #137555)
https://github.com/jasonmolenda approved this pull request. lol thanks for updating the xcode project file, it's sometimes handy to build debugserver alone without the rest of lldb. https://github.com/llvm/llvm-project/pull/137555 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate RNBRemote away from PThreadMutex (NFC) (PR #137547)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/137547 The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates RNBRemote away from PThreadMutex in preparation for removing it. >From 10a1f5b8f615f502a92e23a39e233265cca6d8ba Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Sun, 27 Apr 2025 13:39:07 -0700 Subject: [PATCH] [debugserver] Migrate RNBRemote away from PThreadMutex (NFC) The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates RNBRemote away from PThreadMutex in preparation for removing it. --- lldb/tools/debugserver/source/RNBRemote.cpp | 4 ++-- lldb/tools/debugserver/source/RNBRemote.h | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index eb7c5ca32c02a..e0831023e7ae4 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -820,7 +820,7 @@ rnb_err_t RNBRemote::GetPacketPayload(std::string &return_packet) { // (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__); { -PThreadMutex::Locker locker(m_mutex); +std::lock_guard guard(m_mutex); if (m_rx_packets.empty()) { // Only reset the remote command available event if we have no more // packets @@ -1052,7 +1052,7 @@ void RNBRemote::CommDataReceived(const std::string &new_data) { // (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__); // Put the packet data into the buffer in a thread safe fashion - PThreadMutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); std::string data; // See if we have any left over data from a previous call to this diff --git a/lldb/tools/debugserver/source/RNBRemote.h b/lldb/tools/debugserver/source/RNBRemote.h index c552713551013..ad254ae90e2f7 100644 --- a/lldb/tools/debugserver/source/RNBRemote.h +++ b/lldb/tools/debugserver/source/RNBRemote.h @@ -14,7 +14,6 @@ #define LLDB_TOOLS_DEBUGSERVER_SOURCE_RNBREMOTE_H #include "DNB.h" -#include "PThreadMutex.h" #include "RNBContext.h" #include "RNBDefs.h" #include "RNBSocket.h" @@ -25,7 +24,6 @@ class RNBSocket; class RNBContext; -class PThreadEvents; enum event_loop_mode { debug_nub, gdb_remote_protocol, done }; @@ -379,7 +377,7 @@ class RNBRemote { std::string m_arch; nub_thread_t m_continue_thread; // thread to continue; 0 for any, -1 for all nub_thread_t m_thread; // thread for other ops; 0 for any, -1 for all - PThreadMutex m_mutex; // Mutex that protects + std::mutex m_mutex; // Mutex that protects DispatchQueueOffsets m_dispatch_queue_offsets; nub_addr_t m_dispatch_queue_offsets_addr; uint32_t m_qSymbol_index; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate RNBRemote away from PThreadMutex (NFC) (PR #137547)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates RNBRemote away from PThreadMutex in preparation for removing it. --- Full diff: https://github.com/llvm/llvm-project/pull/137547.diff 2 Files Affected: - (modified) lldb/tools/debugserver/source/RNBRemote.cpp (+2-2) - (modified) lldb/tools/debugserver/source/RNBRemote.h (+1-3) ``diff diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index eb7c5ca32c02a..e0831023e7ae4 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -820,7 +820,7 @@ rnb_err_t RNBRemote::GetPacketPayload(std::string &return_packet) { // (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__); { -PThreadMutex::Locker locker(m_mutex); +std::lock_guard guard(m_mutex); if (m_rx_packets.empty()) { // Only reset the remote command available event if we have no more // packets @@ -1052,7 +1052,7 @@ void RNBRemote::CommDataReceived(const std::string &new_data) { // (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__); // Put the packet data into the buffer in a thread safe fashion - PThreadMutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); std::string data; // See if we have any left over data from a previous call to this diff --git a/lldb/tools/debugserver/source/RNBRemote.h b/lldb/tools/debugserver/source/RNBRemote.h index c552713551013..ad254ae90e2f7 100644 --- a/lldb/tools/debugserver/source/RNBRemote.h +++ b/lldb/tools/debugserver/source/RNBRemote.h @@ -14,7 +14,6 @@ #define LLDB_TOOLS_DEBUGSERVER_SOURCE_RNBREMOTE_H #include "DNB.h" -#include "PThreadMutex.h" #include "RNBContext.h" #include "RNBDefs.h" #include "RNBSocket.h" @@ -25,7 +24,6 @@ class RNBSocket; class RNBContext; -class PThreadEvents; enum event_loop_mode { debug_nub, gdb_remote_protocol, done }; @@ -379,7 +377,7 @@ class RNBRemote { std::string m_arch; nub_thread_t m_continue_thread; // thread to continue; 0 for any, -1 for all nub_thread_t m_thread; // thread for other ops; 0 for any, -1 for all - PThreadMutex m_mutex; // Mutex that protects + std::mutex m_mutex; // Mutex that protects DispatchQueueOffsets m_dispatch_queue_offsets; nub_addr_t m_dispatch_queue_offsets_addr; uint32_t m_qSymbol_index; `` https://github.com/llvm/llvm-project/pull/137547 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 10f379e - [lldb][test] TestFrameFormat: set breakpoints by name
Author: Michael Buch Date: 2025-04-27T21:43:27+01:00 New Revision: 10f379e68660af931e367dba988ef2e3a1073bf5 URL: https://github.com/llvm/llvm-project/commit/10f379e68660af931e367dba988ef2e3a1073bf5 DIFF: https://github.com/llvm/llvm-project/commit/10f379e68660af931e367dba988ef2e3a1073bf5.diff LOG: [lldb][test] TestFrameFormat: set breakpoints by name Without this for some reason Linux PR CI was failing with: ``` (lldb) settings set -f frame-format "custom-frame '${function.basename}'\n" check:50'0 check:50'1 ? possible intended match 9: (lldb) break set -l 5 -f main.cpp check:50'0 ~~ 10: Breakpoint 1: no locations (pending). check:50'0 ~~ 11: WARNING: Unable to resolve breakpoint to any actual locations. check:50'0 ~~~ ``` Added: Modified: lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test lldb/test/Shell/Settings/TestFrameFormatFunctionTemplateArguments.test Removed: diff --git a/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test b/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test index fdb90a064e273..61af2b49886ec 100644 --- a/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test +++ b/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test @@ -38,7 +38,7 @@ int main() { #--- commands.input settings set -f frame-format "custom-frame '${function.basename}'\n" -break set -l 5 -f main.cpp +break set -n bar run bt diff --git a/lldb/test/Shell/Settings/TestFrameFormatFunctionTemplateArguments.test b/lldb/test/Shell/Settings/TestFrameFormatFunctionTemplateArguments.test index 1b5113fb66732..5687dd7fba26b 100644 --- a/lldb/test/Shell/Settings/TestFrameFormatFunctionTemplateArguments.test +++ b/lldb/test/Shell/Settings/TestFrameFormatFunctionTemplateArguments.test @@ -29,7 +29,7 @@ int main() { return bar(); } #--- commands.input settings set -f frame-format "custom-frame '${function.template-arguments}'\n" -break set -l 4 -f main.cpp +break set -n func run bt ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Format] Make function name frame-format variables work without debug-info (PR #137408)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/137408 >From db417e84e944ee80f045414a4ce0f83a3e423e45 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 25 Apr 2025 22:49:36 +0100 Subject: [PATCH 1/2] [lldb][CPlusPLus] Make C++ frame-format work without debug-info --- lldb/source/Core/FormatEntity.cpp | 9 +++-- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 38 ++- .../TestFrameFormatFunctionBasename.test | 4 ++ ...FrameFormatFunctionFormattedArguments.test | 9 + .../TestFrameFormatFunctionQualifiers.test| 4 ++ .../TestFrameFormatFunctionReturn.test| 4 ++ .../TestFrameFormatFunctionScope.test | 7 +++- ...tFrameFormatFunctionTemplateArguments.test | 8 +++- 8 files changed, 73 insertions(+), 10 deletions(-) diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index e352d07fe487d..4ac50e2d30f3c 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -1809,11 +1809,12 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, case Entry::Type::FunctionReturnRight: case Entry::Type::FunctionReturnLeft: case Entry::Type::FunctionQualifiers: { -if (!sc->function) - return false; +Language *language_plugin = nullptr; +if (sc->function) + language_plugin = Language::FindPlugin(sc->function->GetLanguage()); +else if (sc->symbol) + language_plugin = Language::FindPlugin(sc->symbol->GetLanguage()); -Language *language_plugin = -Language::FindPlugin(sc->function->GetLanguage()); if (!language_plugin) return false; diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 283e867d53bb7..ab8e9883868ce 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -381,6 +381,34 @@ GetDemangledScope(const SymbolContext &sc) { return demangled_name.slice(info->ScopeRange.first, info->ScopeRange.second); } +static bool PrintDemangledArgumentList(Stream &s, const SymbolContext &sc) { + assert(sc.symbol); + + Mangled mangled = sc.GetPossiblyInlinedFunctionName(); + if (!mangled) +return false; + + auto demangled_name = mangled.GetDemangledName().GetStringRef(); + if (demangled_name.empty()) +return false; + + const std::optional &info = mangled.GetDemangledInfo(); + if (!info) +return false; + + // Function without a basename is nonsense. + if (!info->hasBasename()) +return false; + + if (info->ArgumentsRange.second < info->ArgumentsRange.first) +return false; + + s << demangled_name.slice(info->ArgumentsRange.first, +info->ArgumentsRange.second); + + return true; +} + bool CPlusPlusLanguage::CxxMethodName::TrySimplifiedParse() { // This method tries to parse simple method definitions which are presumably // most comman in user programs. Definitions that can be parsed by this @@ -1890,8 +1918,6 @@ bool CPlusPlusLanguage::GetFunctionDisplayName( bool CPlusPlusLanguage::HandleFrameFormatVariable( const SymbolContext &sc, const ExecutionContext *exe_ctx, FormatEntity::Entry::Type type, Stream &s) { - assert(sc.function); - switch (type) { case FormatEntity::Entry::Type::FunctionScope: { std::optional scope = GetDemangledScope(sc); @@ -1925,6 +1951,14 @@ bool CPlusPlusLanguage::HandleFrameFormatVariable( } case FormatEntity::Entry::Type::FunctionFormattedArguments: { +// This ensures we print the arguments even when no debug-info is available. +// +// FIXME: we should have a Entry::Type::FunctionArguments and +// use it in the plugin.cplusplus.display.function-name-format +// once we have a "fallback operator" in the frame-format language. +if (!sc.function && sc.symbol) + return PrintDemangledArgumentList(s, sc); + VariableList args; if (auto variable_list_sp = GetFunctionVariableList(sc)) variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument, diff --git a/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test b/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test index a2cb1c6adf064..7e34fbd3855d0 100644 --- a/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test +++ b/lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test @@ -7,6 +7,10 @@ # RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \ # RUN: | FileCheck %s # +# RUN: %clang_host -O0 %t/main.cpp -o %t-nodebug.out +# RUN: %lldb -x -b -s %t/commands.input %t-nodebug.out -o exit 2>&1 \ +# RUN: | FileCheck %s + #--- main.cpp namespace ns { template diff --git a/lldb/test/Shell/Settings/TestFrameFormatFunctionFormattedArguments.test b/lldb/test/Shell/Settings/TestFrameFormatFunctionFormattedArguments.test index c4c9062b640f1..04f51701a2a2d 10064
[Lldb-commits] [lldb] [debugserver] Migrate MachProcess away from PThreadMutex (NFC) (PR #137553)
https://github.com/jasonmolenda approved this pull request. https://github.com/llvm/llvm-project/pull/137553 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang] Add `__ptrauth_restricted_intptr` qualifier (PR #137580)
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/137580 >From 0129e28643f667febb23dba1521134a6151c2f7d Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Sun, 27 Apr 2025 22:33:44 -0700 Subject: [PATCH] [clang] Add `__ptrauth_restricted_intptr` qualifier __ptrauth_restricted_intptr provides a mechanism to apply pointer authentication to pointer sized integer types. --- clang/docs/PointerAuthentication.rst | 14 ++ clang/docs/ReleaseNotes.rst | 2 +- clang/include/clang/AST/Type.h| 52 +++-- clang/include/clang/Basic/Attr.td | 3 +- .../clang/Basic/DiagnosticSemaKinds.td| 31 ++- clang/include/clang/Basic/Features.def| 1 + clang/include/clang/Basic/TokenKinds.def | 1 + clang/include/clang/Sema/Sema.h | 3 +- clang/lib/AST/ASTContext.cpp | 3 + clang/lib/AST/Type.cpp| 6 + clang/lib/AST/TypePrinter.cpp | 5 +- clang/lib/CodeGen/CGExprConstant.cpp | 4 + clang/lib/CodeGen/CGExprScalar.cpp| 2 +- clang/lib/CodeGen/CGPointerAuth.cpp | 22 +- clang/lib/Parse/ParseDecl.cpp | 9 +- clang/lib/Sema/SemaCast.cpp | 2 +- clang/lib/Sema/SemaChecking.cpp | 10 +- clang/lib/Sema/SemaDecl.cpp | 3 +- clang/lib/Sema/SemaDeclCXX.cpp| 2 +- clang/lib/Sema/SemaObjCProperty.cpp | 6 +- clang/lib/Sema/SemaType.cpp | 49 ++-- clang/lib/Sema/TreeTransform.h| 21 +- .../ptrauth-restricted-intptr-qualifier.c | 220 ++ .../ptrauth-restricted-intptr-qualifier.c | 45 clang/test/SemaCXX/ptrauth-triviality.cpp | 44 .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 7 +- 26 files changed, 491 insertions(+), 76 deletions(-) create mode 100644 clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c create mode 100644 clang/test/Sema/ptrauth-restricted-intptr-qualifier.c diff --git a/clang/docs/PointerAuthentication.rst b/clang/docs/PointerAuthentication.rst index 41818d43ac687..2278971d757c9 100644 --- a/clang/docs/PointerAuthentication.rst +++ b/clang/docs/PointerAuthentication.rst @@ -326,6 +326,20 @@ a discriminator determined as follows: is ``ptrauth_blend_discriminator(&x, discriminator)``; see `ptrauth_blend_discriminator`_. +__ptrauth_restricted_intptr qualifier +^ +This is a variant of the ``__ptrauth`` qualifier, that applies to pointer sized +integers. See the documentation for ``__ptrauth qualifier``. + +This feature exists to support older APIs that use [u]intptrs to hold opaque +pointer types. + +Care must be taken to avoid using the signature bit components of the signed +integers or subsequent authentication of the signed value may fail. + +Note: When applied to a global initialiser a signed uintptr can only be +initialised with the value 0 or a global address. + ~~~ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index eb2e8f2b8a6c0..fe9badf7ba97a 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -608,7 +608,7 @@ Arm and AArch64 Support ARM targets, however this will now disable NEON instructions being generated. The ``simd`` option is also now printed when the ``--print-supported-extensions`` option is used. -- Support for __ptrauth type qualifier has been added. +- Support for __ptrauth and __ptrauth_restricted_intptr type qualifiers has been added. - For AArch64, added support for generating executable-only code sections by using the ``-mexecute-only`` or ``-mpure-code`` compiler flags. (#GH125688) diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 3e1fb05ad537c..246b4aeba7876 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -168,8 +168,13 @@ class PointerAuthQualifier { AuthenticatesNullValuesBits = 1, AuthenticatesNullValuesMask = ((1 << AuthenticatesNullValuesBits) - 1) << AuthenticatesNullValuesShift, -KeyShift = AuthenticatesNullValuesShift + AuthenticatesNullValuesBits, -KeyBits = 10, +RestrictedIntegralShift = +AuthenticatesNullValuesShift + AuthenticatesNullValuesBits, +RestrictedIntegralBits = 1, +RestrictedIntegralMask = ((1 << RestrictedIntegralBits) - 1) + << RestrictedIntegralShift, +KeyShift = RestrictedIntegralShift + RestrictedIntegralBits, +KeyBits = 9, KeyMask = ((1 << KeyBits) - 1) << KeyShift, DiscriminatorShift = KeyShift + KeyBits, DiscriminatorBits = 16, @@ -178,32 +183,33 @@ class PointerAuthQualifier { // bits: |0 |1 |2..3 |4 | // |Enabled|Address|AuthenticationMode|ISA pointer| - // bits: |5
[Lldb-commits] [lldb] [llvm] [lldb-dap] migrate set breakpoint requests (PR #137448)
@@ -322,6 +323,186 @@ enum SteppingGranularity : unsigned { bool fromJSON(const llvm::json::Value &, SteppingGranularity &, llvm::json::Path); +/// Information about a breakpoint created in `setBreakpoints`, +/// `setFunctionBreakpoints`, `setInstructionBreakpoints`, or +/// `setDataBreakpoints` requests. +struct Breakpoint { + /// A machine-readable explanation of why a breakpoint may not be verified. + enum class Reason : unsigned { +/// Indicates a breakpoint might be verified in the future, but +/// the adapter cannot verify it in the current state. +eBreakpointReasonPending, +/// Indicates a breakpoint was not able to be verified, and the +/// adapter does not believe it can be verified without intervention. +eBreakpointReasonFailed, + }; + + /// The identifier for the breakpoint. It is needed if breakpoint events are + /// used to update or remove breakpoints. + std::optional id; + + /// If true, the breakpoint could be set (but not necessarily at the desired + /// location). + bool verified; ashgti wrote: Should we default this to `false`? In the `Breakpoint.cpp` if the `SBBreakpiont.IsValid()` returns false we return the `Breakpoint` without initializing this value. https://github.com/llvm/llvm-project/pull/137448 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb-dap] migrate set breakpoint requests (PR #137448)
@@ -322,6 +323,186 @@ enum SteppingGranularity : unsigned { bool fromJSON(const llvm::json::Value &, SteppingGranularity &, llvm::json::Path); +/// Information about a breakpoint created in `setBreakpoints`, +/// `setFunctionBreakpoints`, `setInstructionBreakpoints`, or +/// `setDataBreakpoints` requests. +struct Breakpoint { + /// A machine-readable explanation of why a breakpoint may not be verified. + enum class Reason : unsigned { +/// Indicates a breakpoint might be verified in the future, but +/// the adapter cannot verify it in the current state. +eBreakpointReasonPending, +/// Indicates a breakpoint was not able to be verified, and the +/// adapter does not believe it can be verified without intervention. +eBreakpointReasonFailed, + }; + + /// The identifier for the breakpoint. It is needed if breakpoint events are + /// used to update or remove breakpoints. + std::optional id; + + /// If true, the breakpoint could be set (but not necessarily at the desired + /// location). + bool verified; + + /// A message about the state of the breakpoint. + /// This is shown to the user and can be used to explain why a breakpoint + /// could not be verified. + std::optional message; + + /// The source where the breakpoint is located. + std::optional source; + + /// The start line of the actual range covered by the breakpoint. + std::optional line; + + /// Start position of the source range covered by the breakpoint. It is + /// measured in UTF-16 code units and the client capability `columnsStartAt1` + /// determines whether it is 0- or 1-based. + std::optional column; + + /// The end line of the actual range covered by the breakpoint. + std::optional endLine; + + /// End position of the source range covered by the breakpoint. It is measured + /// in UTF-16 code units and the client capability `columnsStartAt1` + /// determines whether it is 0- or 1-based. If no end line is given, then the + /// end column is assumed to be in the start line. + std::optional endColumn; + + /// A memory reference to where the breakpoint is set. + std::optional instructionReference; + + /// The offset from the instruction reference. + /// This can be negative. + std::optional offset; + + /// A machine-readable explanation of why a breakpoint may not be verified. If + /// a breakpoint is verified or a specific reason is not known, the adapter + /// should omit this property. + std::optional reason; +}; +llvm::json::Value toJSON(const Breakpoint &); + +/// Properties of a breakpoint or logpoint passed to the `setBreakpoints` +/// request +struct SourceBreakpoint { + /// The source line of the breakpoint or logpoint. + uint32_t line; ashgti wrote: Should we default this to `LLDB_INVALID_LINE_NUMBER`? https://github.com/llvm/llvm-project/pull/137448 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][docs] Document new frame-format variables (PR #137522)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/137522 >From 2388b0951a3e9b0e2ebd297881f17423c8d68b4e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sun, 27 Apr 2025 11:23:20 +0100 Subject: [PATCH 1/4] [lldb][docs] Document new frame-format variables --- lldb/docs/use/formatting.rst | 50 +++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/lldb/docs/use/formatting.rst b/lldb/docs/use/formatting.rst index 7b3f01eebc891..6063a47e279f0 100644 --- a/lldb/docs/use/formatting.rst +++ b/lldb/docs/use/formatting.rst @@ -85,10 +85,24 @@ A complete list of currently supported format string variables is listed below: +---+-+ | ``function.name`` | The name of the current function or symbol. | +---+-+ -| ``function.name-with-args`` | The name of the current function with arguments and values or the symbol name. | +| ``function.name-with-args`` | The name of the current function with arguments and values or the symbol name. The name will be displayed according to the current frame's language if possible. | +---+-+ | ``function.name-without-args``| The name of the current function without arguments and values (used to include a function name in-line in the ``disassembly-format``) | +---+-+ +| ``function.basename``| The basename of the current function depending on the frame's language. E.g., for C++ the basename for `void ns::foo::bar(int) const` is `bar`. | ++---+-+ +| ``function.scope``| The scope qualifiers of the current function depending on the frame's language. E.g., for C++ the scope for `void ns::foo::bar(int) const` is `ns::foo`. | ++---+-+ +| ``function.template-arguments``| The template arguments of the current function depending on the frame's language. E.g., for C++ the template arguments for `void ns::foo::bar(int) const` are ``. | ++---+---
[Lldb-commits] [lldb] [llvm] [lldb-dap] migrate set breakpoint requests (PR #137448)
https://github.com/ashgti approved this pull request. https://github.com/llvm/llvm-project/pull/137448 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb-dap] migrate set breakpoint requests (PR #137448)
@@ -322,6 +323,186 @@ enum SteppingGranularity : unsigned { bool fromJSON(const llvm::json::Value &, SteppingGranularity &, llvm::json::Path); +/// Information about a breakpoint created in `setBreakpoints`, +/// `setFunctionBreakpoints`, `setInstructionBreakpoints`, or +/// `setDataBreakpoints` requests. +struct Breakpoint { + /// A machine-readable explanation of why a breakpoint may not be verified. + enum class Reason : unsigned { +/// Indicates a breakpoint might be verified in the future, but +/// the adapter cannot verify it in the current state. +eBreakpointReasonPending, +/// Indicates a breakpoint was not able to be verified, and the +/// adapter does not believe it can be verified without intervention. +eBreakpointReasonFailed, + }; ashgti wrote: style nit, in lldb enums are usually not nested like this, how about moving this out of the Breakpoint struct? You could use `BreakpointReason` as well, thats already repeated in the enum names. https://github.com/llvm/llvm-project/pull/137448 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate MachThread away from PThreadMutex (NFC) (PR #137543)
https://github.com/jasonmolenda approved this pull request. https://github.com/llvm/llvm-project/pull/137543 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 33a0a78 - [debugserver] Migrate MachThread away from PThreadMutex (NFC) (#137543)
Author: Jonas Devlieghere Date: 2025-04-27T13:25:40-07:00 New Revision: 33a0a786f2002cf1b0a13a8984d0933e7dc048d7 URL: https://github.com/llvm/llvm-project/commit/33a0a786f2002cf1b0a13a8984d0933e7dc048d7 DIFF: https://github.com/llvm/llvm-project/commit/33a0a786f2002cf1b0a13a8984d0933e7dc048d7.diff LOG: [debugserver] Migrate MachThread away from PThreadMutex (NFC) (#137543) The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates MachThread away from PThreadMutex in preparation for removing it. Added: Modified: lldb/tools/debugserver/source/MacOSX/MachThread.cpp lldb/tools/debugserver/source/MacOSX/MachThread.h Removed: diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp index 69e1c9bb0e252..e161b8b5d 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp @@ -28,11 +28,11 @@ MachThread::MachThread(MachProcess *process, bool is_64_bit, uint64_t unique_thread_id, thread_t mach_port_num) : m_process(process), m_unique_id(unique_thread_id), m_mach_port_number(mach_port_num), m_seq_id(GetSequenceID()), - m_state(eStateUnloaded), m_state_mutex(PTHREAD_MUTEX_RECURSIVE), - m_suspend_count(0), m_stop_exception(), - m_arch_up(DNBArchProtocol::Create(this)), m_reg_sets(NULL), - m_num_reg_sets(0), m_extended_info(), m_dispatch_queue_name(), - m_is_64_bit(is_64_bit), m_pthread_qos_class_decode(nullptr) { + m_state(eStateUnloaded), m_state_mutex(), m_suspend_count(0), + m_stop_exception(), m_arch_up(DNBArchProtocol::Create(this)), + m_reg_sets(NULL), m_num_reg_sets(0), m_extended_info(), + m_dispatch_queue_name(), m_is_64_bit(is_64_bit), + m_pthread_qos_class_decode(nullptr) { nub_size_t num_reg_sets = 0; m_reg_sets = m_arch_up->GetRegisterSetInfo(&num_reg_sets); m_num_reg_sets = num_reg_sets; @@ -469,13 +469,12 @@ bool MachThread::NotifyException(MachException::Data &exc) { } nub_state_t MachThread::GetState() { - // If any other threads access this we will need a mutex for it - PTHREAD_MUTEX_LOCKER(locker, m_state_mutex); + std::lock_guard guard(m_state_mutex); return m_state; } void MachThread::SetState(nub_state_t state) { - PTHREAD_MUTEX_LOCKER(locker, m_state_mutex); + std::lock_guard guard(m_state_mutex); m_state = state; DNBLogThreadedIf(LOG_THREAD, "MachThread::SetState ( %s ) for tid = 0x%8.8" PRIx64 "", diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.h b/lldb/tools/debugserver/source/MacOSX/MachThread.h index 0c78ef1a337ed..1086b7c986f11 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThread.h +++ b/lldb/tools/debugserver/source/MacOSX/MachThread.h @@ -24,8 +24,6 @@ #include "DNBArch.h" #include "DNBRegisterInfo.h" #include "MachException.h" -#include "PThreadCondition.h" -#include "PThreadMutex.h" #include "ThreadInfo.h" @@ -139,7 +137,7 @@ class MachThread { // namesp. uint32_t m_seq_id; // A Sequential ID that increments with each new thread nub_state_t m_state; // The state of our process - PThreadMutex m_state_mutex;// Multithreaded protection for m_state + std::recursive_mutex m_state_mutex;// Multithreaded protection for m_state struct thread_basic_info m_basic_info; // Basic information for a thread used // to see if a thread is valid int32_t m_suspend_count; // The current suspend count > 0 means we have ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate MachThread away from PThreadMutex (NFC) (PR #137543)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/137543 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang] Add `__ptrauth_restricted_intptr` qualifier (PR #137580)
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/137580 __ptrauth_restricted_intptr provides a mechanism to apply pointer authentication to pointer sized integer types. >From 7af378bbec4c7cf3896f6f7bc95d816e398930f2 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Sun, 27 Apr 2025 22:33:44 -0700 Subject: [PATCH] [clang] Add `__ptrauth_restricted_intptr` qualifier __ptrauth_restricted_intptr provides a mechanism to apply pointer authentication to pointer sized integer types. --- clang/docs/PointerAuthentication.rst | 14 ++ clang/docs/ReleaseNotes.rst | 2 +- clang/include/clang/AST/Type.h| 52 +++-- clang/include/clang/Basic/Attr.td | 3 +- .../clang/Basic/DiagnosticSemaKinds.td| 31 ++- clang/include/clang/Basic/Features.def| 1 + clang/include/clang/Basic/TokenKinds.def | 1 + clang/include/clang/Sema/Sema.h | 3 +- clang/lib/AST/ASTContext.cpp | 3 + clang/lib/AST/Type.cpp| 6 + clang/lib/AST/TypePrinter.cpp | 5 +- clang/lib/CodeGen/CGExprConstant.cpp | 3 + clang/lib/CodeGen/CGExprScalar.cpp| 2 +- clang/lib/CodeGen/CGPointerAuth.cpp | 22 +- clang/lib/Parse/ParseDecl.cpp | 9 +- clang/lib/Sema/SemaCast.cpp | 2 +- clang/lib/Sema/SemaChecking.cpp | 11 +- clang/lib/Sema/SemaDecl.cpp | 3 +- clang/lib/Sema/SemaDeclCXX.cpp| 2 +- clang/lib/Sema/SemaObjCProperty.cpp | 6 +- clang/lib/Sema/SemaType.cpp | 43 ++-- clang/lib/Sema/TreeTransform.h| 21 +- .../ptrauth-restricted-intptr-qualifier.c | 220 ++ .../ptrauth-restricted-intptr-qualifier.c | 45 clang/test/SemaCXX/ptrauth-triviality.cpp | 44 .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 7 +- 26 files changed, 487 insertions(+), 74 deletions(-) create mode 100644 clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c create mode 100644 clang/test/Sema/ptrauth-restricted-intptr-qualifier.c diff --git a/clang/docs/PointerAuthentication.rst b/clang/docs/PointerAuthentication.rst index 41818d43ac687..2278971d757c9 100644 --- a/clang/docs/PointerAuthentication.rst +++ b/clang/docs/PointerAuthentication.rst @@ -326,6 +326,20 @@ a discriminator determined as follows: is ``ptrauth_blend_discriminator(&x, discriminator)``; see `ptrauth_blend_discriminator`_. +__ptrauth_restricted_intptr qualifier +^ +This is a variant of the ``__ptrauth`` qualifier, that applies to pointer sized +integers. See the documentation for ``__ptrauth qualifier``. + +This feature exists to support older APIs that use [u]intptrs to hold opaque +pointer types. + +Care must be taken to avoid using the signature bit components of the signed +integers or subsequent authentication of the signed value may fail. + +Note: When applied to a global initialiser a signed uintptr can only be +initialised with the value 0 or a global address. + ~~~ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index eb2e8f2b8a6c0..fe9badf7ba97a 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -608,7 +608,7 @@ Arm and AArch64 Support ARM targets, however this will now disable NEON instructions being generated. The ``simd`` option is also now printed when the ``--print-supported-extensions`` option is used. -- Support for __ptrauth type qualifier has been added. +- Support for __ptrauth and __ptrauth_restricted_intptr type qualifiers has been added. - For AArch64, added support for generating executable-only code sections by using the ``-mexecute-only`` or ``-mpure-code`` compiler flags. (#GH125688) diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 3e1fb05ad537c..6516c976e66c5 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -168,8 +168,13 @@ class PointerAuthQualifier { AuthenticatesNullValuesBits = 1, AuthenticatesNullValuesMask = ((1 << AuthenticatesNullValuesBits) - 1) << AuthenticatesNullValuesShift, -KeyShift = AuthenticatesNullValuesShift + AuthenticatesNullValuesBits, -KeyBits = 10, +RestrictedIntegralShift = + AuthenticatesNullValuesShift + AuthenticatesNullValuesBits, +RestrictedIntegralBits = 1, +RestrictedIntegralMask = ((1 << RestrictedIntegralBits) - 1) + << RestrictedIntegralShift, +KeyShift = RestrictedIntegralShift + RestrictedIntegralBits, +KeyBits = 9, KeyMask = ((1 << KeyBits) - 1) << KeyShift, DiscriminatorShift = KeyShift + KeyBits, DiscriminatorBits = 16, @@ -178,32 +183,33 @@ class PointerAuthQualifier { // bits: |0 |1 |2..3
[Lldb-commits] [clang] [lldb] [clang] Add `__ptrauth_restricted_intptr` qualifier (PR #137580)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: Oliver Hunt (ojhunt) Changes __ptrauth_restricted_intptr provides a mechanism to apply pointer authentication to pointer sized integer types. --- Patch is 49.31 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/137580.diff 26 Files Affected: - (modified) clang/docs/PointerAuthentication.rst (+14) - (modified) clang/docs/ReleaseNotes.rst (+1-1) - (modified) clang/include/clang/AST/Type.h (+35-17) - (modified) clang/include/clang/Basic/Attr.td (+2-1) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+19-12) - (modified) clang/include/clang/Basic/Features.def (+1) - (modified) clang/include/clang/Basic/TokenKinds.def (+1) - (modified) clang/include/clang/Sema/Sema.h (+2-1) - (modified) clang/lib/AST/ASTContext.cpp (+3) - (modified) clang/lib/AST/Type.cpp (+6) - (modified) clang/lib/AST/TypePrinter.cpp (+4-1) - (modified) clang/lib/CodeGen/CGExprConstant.cpp (+3) - (modified) clang/lib/CodeGen/CGExprScalar.cpp (+1-1) - (modified) clang/lib/CodeGen/CGPointerAuth.cpp (+13-9) - (modified) clang/lib/Parse/ParseDecl.cpp (+7-2) - (modified) clang/lib/Sema/SemaCast.cpp (+1-1) - (modified) clang/lib/Sema/SemaChecking.cpp (+7-4) - (modified) clang/lib/Sema/SemaDecl.cpp (+2-1) - (modified) clang/lib/Sema/SemaDeclCXX.cpp (+1-1) - (modified) clang/lib/Sema/SemaObjCProperty.cpp (+3-3) - (modified) clang/lib/Sema/SemaType.cpp (+29-14) - (modified) clang/lib/Sema/TreeTransform.h (+17-4) - (added) clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c (+220) - (added) clang/test/Sema/ptrauth-restricted-intptr-qualifier.c (+45) - (modified) clang/test/SemaCXX/ptrauth-triviality.cpp (+44) - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+6-1) ``diff diff --git a/clang/docs/PointerAuthentication.rst b/clang/docs/PointerAuthentication.rst index 41818d43ac687..2278971d757c9 100644 --- a/clang/docs/PointerAuthentication.rst +++ b/clang/docs/PointerAuthentication.rst @@ -326,6 +326,20 @@ a discriminator determined as follows: is ``ptrauth_blend_discriminator(&x, discriminator)``; see `ptrauth_blend_discriminator`_. +__ptrauth_restricted_intptr qualifier +^ +This is a variant of the ``__ptrauth`` qualifier, that applies to pointer sized +integers. See the documentation for ``__ptrauth qualifier``. + +This feature exists to support older APIs that use [u]intptrs to hold opaque +pointer types. + +Care must be taken to avoid using the signature bit components of the signed +integers or subsequent authentication of the signed value may fail. + +Note: When applied to a global initialiser a signed uintptr can only be +initialised with the value 0 or a global address. + ~~~ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index eb2e8f2b8a6c0..fe9badf7ba97a 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -608,7 +608,7 @@ Arm and AArch64 Support ARM targets, however this will now disable NEON instructions being generated. The ``simd`` option is also now printed when the ``--print-supported-extensions`` option is used. -- Support for __ptrauth type qualifier has been added. +- Support for __ptrauth and __ptrauth_restricted_intptr type qualifiers has been added. - For AArch64, added support for generating executable-only code sections by using the ``-mexecute-only`` or ``-mpure-code`` compiler flags. (#GH125688) diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 3e1fb05ad537c..6516c976e66c5 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -168,8 +168,13 @@ class PointerAuthQualifier { AuthenticatesNullValuesBits = 1, AuthenticatesNullValuesMask = ((1 << AuthenticatesNullValuesBits) - 1) << AuthenticatesNullValuesShift, -KeyShift = AuthenticatesNullValuesShift + AuthenticatesNullValuesBits, -KeyBits = 10, +RestrictedIntegralShift = + AuthenticatesNullValuesShift + AuthenticatesNullValuesBits, +RestrictedIntegralBits = 1, +RestrictedIntegralMask = ((1 << RestrictedIntegralBits) - 1) + << RestrictedIntegralShift, +KeyShift = RestrictedIntegralShift + RestrictedIntegralBits, +KeyBits = 9, KeyMask = ((1 << KeyBits) - 1) << KeyShift, DiscriminatorShift = KeyShift + KeyBits, DiscriminatorBits = 16, @@ -178,32 +183,33 @@ class PointerAuthQualifier { // bits: |0 |1 |2..3 |4 | // |Enabled|Address|AuthenticationMode|ISA pointer| - // bits: |5|6..15| 16...31 | - // |AuthenticatesNull|Key |Discriminator| + // bits: |5|6 |7..15| 16...31 | + // |AuthenticatesNull|RestrictedIntegral|K
[Lldb-commits] [clang] [lldb] [clang] Add `__ptrauth_restricted_intptr` qualifier (PR #137580)
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 HEAD~1 HEAD --extensions cpp,c,h -- clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c clang/test/Sema/ptrauth-restricted-intptr-qualifier.c clang/include/clang/AST/Type.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTContext.cpp clang/lib/AST/Type.cpp clang/lib/AST/TypePrinter.cpp clang/lib/CodeGen/CGExprConstant.cpp clang/lib/CodeGen/CGExprScalar.cpp clang/lib/CodeGen/CGPointerAuth.cpp clang/lib/Parse/ParseDecl.cpp clang/lib/Sema/SemaCast.cpp clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaObjCProperty.cpp clang/lib/Sema/SemaType.cpp clang/lib/Sema/TreeTransform.h clang/test/SemaCXX/ptrauth-triviality.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 6516c976e..246b4aeba 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -169,7 +169,7 @@ class PointerAuthQualifier { AuthenticatesNullValuesMask = ((1 << AuthenticatesNullValuesBits) - 1) << AuthenticatesNullValuesShift, RestrictedIntegralShift = - AuthenticatesNullValuesShift + AuthenticatesNullValuesBits, +AuthenticatesNullValuesShift + AuthenticatesNullValuesBits, RestrictedIntegralBits = 1, RestrictedIntegralMask = ((1 << RestrictedIntegralBits) - 1) << RestrictedIntegralShift, diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index d196e39ea..ebe6bb805 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -2445,8 +2445,9 @@ ConstantEmitter::tryEmitPrivate(const APValue &Value, QualType DestType, .tryEmit(); case APValue::Int: if (PointerAuthQualifier PointerAuth = DestType.getPointerAuth(); -PointerAuth && (PointerAuth.authenticatesNullValues() || Value.getInt() != 0)) -return nullptr; +PointerAuth && +(PointerAuth.authenticatesNullValues() || Value.getInt() != 0)) + return nullptr; return llvm::ConstantInt::get(CGM.getLLVMContext(), Value.getInt()); case APValue::FixedPoint: return llvm::ConstantInt::get(CGM.getLLVMContext(), diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 561f6309d..89a92491c 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -1562,8 +1562,7 @@ bool Sema::checkPointerAuthDiscriminatorArg(const AttributeCommonInfo &AttrInfo, std::optional Result = Arg->getIntegerConstantExpr(Context); StringRef AttrName = AttrInfo.getAttrName()->getName(); if (!Result) { -Diag(Arg->getExprLoc(), diag::err_ptrauth_arg_not_ice) -<< AttrName; +Diag(Arg->getExprLoc(), diag::err_ptrauth_arg_not_ice) << AttrName; return false; } diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index d22517be9..d99f13fd3 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8372,11 +8372,12 @@ static void HandlePtrAuthQualifier(ASTContext &Ctx, QualType &T, bool IsInvalid = false; unsigned IsAddressDiscriminated, ExtraDiscriminator; - IsInvalid |= !S.checkPointerAuthDiscriminatorArg(Attr, IsAddressDiscriminatedArg, - Sema::PADAK_AddrDiscPtrAuth, - IsAddressDiscriminated); - IsInvalid |= !S.checkPointerAuthDiscriminatorArg(Attr, - ExtraDiscriminatorArg, Sema::PADAK_ExtraDiscPtrAuth, ExtraDiscriminator); + IsInvalid |= !S.checkPointerAuthDiscriminatorArg( + Attr, IsAddressDiscriminatedArg, Sema::PADAK_AddrDiscPtrAuth, + IsAddressDiscriminated); + IsInvalid |= !S.checkPointerAuthDiscriminatorArg(Attr, ExtraDiscriminatorArg, + Sema::PADAK_ExtraDiscPtrAuth, + ExtraDiscriminator); if (IsInvalid) { Attr.setInvalid(); @@ -8417,7 +8418,8 @@ static void HandlePtrAuthQualifier(ASTContext &Ctx, QualType &T, "address discriminator arg should be either 0 or 1"); PointerAuthQualifier Qual = PointerAuthQualifier::Create( Key, IsAddressDiscriminated, ExtraDiscriminator, - PointerAuthenticationMode::SignAndAuth, /*IsIsaPointer=*/false, /*AuthenticatesNullValues=*/false, IsRestrictedIntegral); + PointerAuthenticationMode::SignAndAuth, /*IsIsaPointer=*/false, + /*AuthenticatesNullValues=*/false, IsRestrictedIntegral); T = S.Context.getPointerAuthType(T, Qual); } `` https://github.com/llvm/llvm-project/pull/137580 _
[Lldb-commits] [lldb] ae71055 - [debugserver] Migrate DNBTimer away from PThreadMutex (NFC) (#137540)
Author: Jonas Devlieghere Date: 2025-04-27T13:07:52-07:00 New Revision: ae71055e6664caf7f74f2e21fb76513bef22a099 URL: https://github.com/llvm/llvm-project/commit/ae71055e6664caf7f74f2e21fb76513bef22a099 DIFF: https://github.com/llvm/llvm-project/commit/ae71055e6664caf7f74f2e21fb76513bef22a099.diff LOG: [debugserver] Migrate DNBTimer away from PThreadMutex (NFC) (#137540) The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates DNBTimer away from that class in preparation for removing PThreadMutex. Added: Modified: lldb/tools/debugserver/source/DNBTimer.h Removed: diff --git a/lldb/tools/debugserver/source/DNBTimer.h b/lldb/tools/debugserver/source/DNBTimer.h index 2251c50fb8768..78b64c6583d3d 100644 --- a/lldb/tools/debugserver/source/DNBTimer.h +++ b/lldb/tools/debugserver/source/DNBTimer.h @@ -14,7 +14,6 @@ #define LLDB_TOOLS_DEBUGSERVER_SOURCE_DNBTIMER_H #include "DNBDefs.h" -#include "PThreadMutex.h" #include #include #include @@ -22,17 +21,17 @@ class DNBTimer { public: // Constructors and Destructors - DNBTimer(bool threadSafe) : m_mutexAP() { + DNBTimer(bool threadSafe) { if (threadSafe) - m_mutexAP.reset(new PThreadMutex(PTHREAD_MUTEX_RECURSIVE)); + m_mutex_up = std::make_unique(); Reset(); } - DNBTimer(const DNBTimer &rhs) : m_mutexAP() { + DNBTimer(const DNBTimer &rhs) { // Create a new mutex to make this timer thread safe as well if // the timer we are copying is thread safe if (rhs.IsThreadSafe()) - m_mutexAP.reset(new PThreadMutex(PTHREAD_MUTEX_RECURSIVE)); + m_mutex_up = std::make_unique(); m_timeval = rhs.m_timeval; } @@ -40,35 +39,43 @@ class DNBTimer { // Create a new mutex to make this timer thread safe as well if // the timer we are copying is thread safe if (rhs.IsThreadSafe()) - m_mutexAP.reset(new PThreadMutex(PTHREAD_MUTEX_RECURSIVE)); + m_mutex_up = std::make_unique(); m_timeval = rhs.m_timeval; return *this; } ~DNBTimer() {} - bool IsThreadSafe() const { return m_mutexAP.get() != NULL; } + bool IsThreadSafe() const { return static_cast(m_mutex_up); } // Reset the time value to now void Reset() { -PTHREAD_MUTEX_LOCKER(locker, m_mutexAP.get()); +auto guard = m_mutex_up + ? std::unique_lock() + : std::unique_lock(*m_mutex_up); gettimeofday(&m_timeval, NULL); } // Get the total microseconds since Jan 1, 1970 uint64_t TotalMicroSeconds() const { -PTHREAD_MUTEX_LOCKER(locker, m_mutexAP.get()); +auto guard = m_mutex_up + ? std::unique_lock() + : std::unique_lock(*m_mutex_up); return (uint64_t)(m_timeval.tv_sec) * 100ull + (uint64_t)m_timeval.tv_usec; } void GetTime(uint64_t &sec, uint32_t &usec) const { -PTHREAD_MUTEX_LOCKER(locker, m_mutexAP.get()); +auto guard = m_mutex_up + ? std::unique_lock() + : std::unique_lock(*m_mutex_up); sec = m_timeval.tv_sec; usec = m_timeval.tv_usec; } // Return the number of microseconds elapsed between now and the // m_timeval uint64_t ElapsedMicroSeconds(bool update) { -PTHREAD_MUTEX_LOCKER(locker, m_mutexAP.get()); +auto guard = m_mutex_up + ? std::unique_lock() + : std::unique_lock(*m_mutex_up); struct timeval now; gettimeofday(&now, NULL); uint64_t now_usec = @@ -115,19 +122,16 @@ class DNBTimer { OffsetTimeOfDay(&now); if (now.tv_sec > ts.tv_sec) return true; -else if (now.tv_sec < ts.tv_sec) +if (now.tv_sec < ts.tv_sec) return false; -else { - if (now.tv_nsec > ts.tv_nsec) -return true; - else -return false; -} +if (now.tv_nsec > ts.tv_nsec) + return true; +return false; } protected: // Classes that inherit from DNBTimer can see and modify these - std::unique_ptr m_mutexAP; + std::unique_ptr m_mutex_up; struct timeval m_timeval; }; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate DNBTimer away from PThreadMutex (NFC) (PR #137540)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/137540 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0755e02 - [debugserver] Migrate DNBLog away from PThreadMutex (NFC) (#137541)
Author: Jonas Devlieghere Date: 2025-04-27T13:08:04-07:00 New Revision: 0755e024fcfc9313d866ed5432133f8755901c95 URL: https://github.com/llvm/llvm-project/commit/0755e024fcfc9313d866ed5432133f8755901c95 DIFF: https://github.com/llvm/llvm-project/commit/0755e024fcfc9313d866ed5432133f8755901c95.diff LOG: [debugserver] Migrate DNBLog away from PThreadMutex (NFC) (#137541) The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates DNBLog away from that class in preparation for removing PThreadMutex. Added: Modified: lldb/tools/debugserver/source/DNBLog.cpp Removed: diff --git a/lldb/tools/debugserver/source/DNBLog.cpp b/lldb/tools/debugserver/source/DNBLog.cpp index d3045ace16f3d..6ad6b6598d1c3 100644 --- a/lldb/tools/debugserver/source/DNBLog.cpp +++ b/lldb/tools/debugserver/source/DNBLog.cpp @@ -17,7 +17,6 @@ static int g_verbose = 0; #if defined(DNBLOG_ENABLED) -#include "PThreadMutex.h" #include #include #include @@ -64,8 +63,8 @@ bool DNBLogEnabledForAny(uint32_t mask) { } static inline void _DNBLogVAPrintf(uint32_t flags, const char *format, va_list args) { - static PThreadMutex g_LogThreadedMutex(PTHREAD_MUTEX_RECURSIVE); - PTHREAD_MUTEX_LOCKER(locker, g_LogThreadedMutex); + static std::recursive_mutex g_LogThreadedMutex; + std::lock_guard guard(g_LogThreadedMutex); if (g_log_callback) g_log_callback(g_log_baton, flags, format, args); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate DNBLog away from PThreadMutex (NFC) (PR #137541)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/137541 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 503ebad - [debugserver] Migrate MachThreadList away from PThreadMutex (NFC) (#137542)
Author: Jonas Devlieghere Date: 2025-04-27T13:08:26-07:00 New Revision: 503ebad14cd9d147ae9aae27f935ff450a685748 URL: https://github.com/llvm/llvm-project/commit/503ebad14cd9d147ae9aae27f935ff450a685748 DIFF: https://github.com/llvm/llvm-project/commit/503ebad14cd9d147ae9aae27f935ff450a685748.diff LOG: [debugserver] Migrate MachThreadList away from PThreadMutex (NFC) (#137542) The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates MachThreadList away from that class in preparation for removing PThreadMutex. Added: Modified: lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp lldb/tools/debugserver/source/MacOSX/MachThreadList.h Removed: diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp index cf3687985173f..36e6c1942b35f 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp @@ -23,8 +23,7 @@ #include MachThreadList::MachThreadList() -: m_threads(), m_threads_mutex(PTHREAD_MUTEX_RECURSIVE), - m_is_64_bit(false) {} +: m_threads(), m_threads_mutex(), m_is_64_bit(false) {} MachThreadList::~MachThreadList() = default; @@ -116,7 +115,7 @@ const char *MachThreadList::GetThreadInfo(nub_thread_t tid) const { } MachThreadSP MachThreadList::GetThreadByID(nub_thread_t tid) const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); MachThreadSP thread_sp; const size_t num_threads = m_threads.size(); for (size_t idx = 0; idx < num_threads; ++idx) { @@ -130,7 +129,7 @@ MachThreadSP MachThreadList::GetThreadByID(nub_thread_t tid) const { MachThreadSP MachThreadList::GetThreadByMachPortNumber(thread_t mach_port_number) const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); MachThreadSP thread_sp; const size_t num_threads = m_threads.size(); for (size_t idx = 0; idx < num_threads; ++idx) { @@ -144,7 +143,7 @@ MachThreadList::GetThreadByMachPortNumber(thread_t mach_port_number) const { nub_thread_t MachThreadList::GetThreadIDByMachPortNumber(thread_t mach_port_number) const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); MachThreadSP thread_sp; const size_t num_threads = m_threads.size(); for (size_t idx = 0; idx < num_threads; ++idx) { @@ -157,7 +156,7 @@ MachThreadList::GetThreadIDByMachPortNumber(thread_t mach_port_number) const { thread_t MachThreadList::GetMachPortNumberByThreadID( nub_thread_t globally_unique_id) const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); MachThreadSP thread_sp; const size_t num_threads = m_threads.size(); for (size_t idx = 0; idx < num_threads; ++idx) { @@ -219,12 +218,12 @@ bool MachThreadList::RestoreRegisterState(nub_thread_t tid, uint32_t save_id) { } nub_size_t MachThreadList::NumThreads() const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); return m_threads.size(); } nub_thread_t MachThreadList::ThreadIDAtIndex(nub_size_t idx) const { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); if (idx < m_threads.size()) return m_threads[idx]->ThreadID(); return INVALID_NUB_THREAD; @@ -248,7 +247,7 @@ bool MachThreadList::NotifyException(MachException::Data &exc) { } void MachThreadList::Clear() { - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); m_threads.clear(); } @@ -259,7 +258,7 @@ MachThreadList::UpdateThreadList(MachProcess *process, bool update, DNBLogThreadedIf(LOG_THREAD, "MachThreadList::UpdateThreadList (pid = %4.4x, " "update = %u) process stop count = %u", process->ProcessID(), update, process->StopCount()); - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); if (process->StopCount() == 0) { int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, process->ProcessID()}; @@ -346,8 +345,7 @@ MachThreadList::UpdateThreadList(MachProcess *process, bool update, } void MachThreadList::CurrentThread(MachThreadSP &thread_sp) { - // locker will keep a mutex locked until it goes out of scope - PTHREAD_MUTEX_LOCKER(locker, m_threads_mutex); + std::lock_guard guard(m_threads_mutex); if (m_current_thread.get() == NULL) { // Figure out which thread is going to be our current thread. // This is currently done by finding the first thread in the list @@ -364,7 +362,7 @@ void MachThreadList::CurrentThread(MachThreadSP &thread_sp) { } void MachThreadList::Dump() const { - PTHREAD_MUTEX_LOCKER(locker, m_th
[Lldb-commits] [lldb] [debugserver] Migrate MachThreadList away from PThreadMutex (NFC) (PR #137542)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/137542 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][docs] Document new frame-format variables (PR #137522)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/137522 >From 2388b0951a3e9b0e2ebd297881f17423c8d68b4e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sun, 27 Apr 2025 11:23:20 +0100 Subject: [PATCH 1/7] [lldb][docs] Document new frame-format variables --- lldb/docs/use/formatting.rst | 50 +++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/lldb/docs/use/formatting.rst b/lldb/docs/use/formatting.rst index 7b3f01eebc891..6063a47e279f0 100644 --- a/lldb/docs/use/formatting.rst +++ b/lldb/docs/use/formatting.rst @@ -85,10 +85,24 @@ A complete list of currently supported format string variables is listed below: +---+-+ | ``function.name`` | The name of the current function or symbol. | +---+-+ -| ``function.name-with-args`` | The name of the current function with arguments and values or the symbol name. | +| ``function.name-with-args`` | The name of the current function with arguments and values or the symbol name. The name will be displayed according to the current frame's language if possible. | +---+-+ | ``function.name-without-args``| The name of the current function without arguments and values (used to include a function name in-line in the ``disassembly-format``) | +---+-+ +| ``function.basename``| The basename of the current function depending on the frame's language. E.g., for C++ the basename for `void ns::foo::bar(int) const` is `bar`. | ++---+-+ +| ``function.scope``| The scope qualifiers of the current function depending on the frame's language. E.g., for C++ the scope for `void ns::foo::bar(int) const` is `ns::foo`. | ++---+-+ +| ``function.template-arguments``| The template arguments of the current function depending on the frame's language. E.g., for C++ the template arguments for `void ns::foo::bar(int) const` are ``. | ++---+---
[Lldb-commits] [lldb] 89f3dc9 - [debugserver] Migrate MachProcess away from PThreadMutex (NFC) (#137553)
Author: Jonas Devlieghere Date: 2025-04-27T17:50:35-07:00 New Revision: 89f3dc9074d9672cd8ff49deccf8d9cd1be6ec7d URL: https://github.com/llvm/llvm-project/commit/89f3dc9074d9672cd8ff49deccf8d9cd1be6ec7d DIFF: https://github.com/llvm/llvm-project/commit/89f3dc9074d9672cd8ff49deccf8d9cd1be6ec7d.diff LOG: [debugserver] Migrate MachProcess away from PThreadMutex (NFC) (#137553) The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates MachProcess away from PThreadMutex in preparation for removing it. Added: Modified: lldb/tools/debugserver/source/MacOSX/MachProcess.h lldb/tools/debugserver/source/MacOSX/MachProcess.mm Removed: diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.h b/lldb/tools/debugserver/source/MacOSX/MachProcess.h index ec0a13b482267..56bc9d6c7461e 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachProcess.h +++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.h @@ -34,7 +34,6 @@ #include "MachVMMemory.h" #include "PThreadCondition.h" #include "PThreadEvent.h" -#include "PThreadMutex.h" #include "RNBContext.h" #include "ThreadInfo.h" @@ -413,7 +412,7 @@ class MachProcess { uint32_t m_stop_count; // A count of many times have we stopped pthread_t m_stdio_thread; // Thread ID for the thread that watches for child // process stdio - PThreadMutex m_stdio_mutex; // Multithreaded protection for stdio + std::recursive_mutex m_stdio_mutex; // Multithreaded protection for stdio std::string m_stdout_data; bool m_profile_enabled; // A flag to indicate if profiling is enabled @@ -423,7 +422,7 @@ class MachProcess { m_profile_scan_type; // Indicates what needs to be profiled pthread_t m_profile_thread; // Thread ID for the thread that profiles the inferior - PThreadMutex + std::recursive_mutex m_profile_data_mutex; // Multithreaded protection for profile info data std::vector m_profile_data; // Profile data, must be protected by m_profile_data_mutex @@ -435,15 +434,16 @@ class MachProcess { // caught when // listening to the // exception port - PThreadMutex m_exception_and_signal_mutex; // Multithreaded protection for - // exceptions and signals. + std::recursive_mutex + m_exception_and_signal_mutex; // Multithreaded protection for +// exceptions and signals. MachThreadList m_thread_list; // A list of threads that is maintained/updated // after each stop Genealogy m_activities; // A list of activities that is updated after every // stop lazily nub_state_t m_state;// The state of our process - PThreadMutex m_state_mutex; // Multithreaded protection for m_state + std::recursive_mutex m_state_mutex; // Multithreaded protection for m_state PThreadEvent m_events; // Process related events in the child processes // lifetime can be waited upon PThreadEvent m_private_events; // Used to coordinate running and stopping the diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm index 447ebbe7fb9e5..3afaaa2f64c00 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm +++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm @@ -522,19 +522,17 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options, MachProcess::MachProcess() : m_pid(0), m_cpu_type(0), m_child_stdin(-1), m_child_stdout(-1), m_child_stderr(-1), m_path(), m_args(), m_task(this), - m_flags(eMachProcessFlagsNone), m_stdio_thread(0), - m_stdio_mutex(PTHREAD_MUTEX_RECURSIVE), m_stdout_data(), - m_profile_enabled(false), m_profile_interval_usec(0), m_profile_thread(0), - m_profile_data_mutex(PTHREAD_MUTEX_RECURSIVE), m_profile_data(), + m_flags(eMachProcessFlagsNone), m_stdio_thread(0), m_stdio_mutex(), + m_stdout_data(), m_profile_enabled(false), m_profile_interval_usec(0), + m_profile_thread(0), m_profile_data_mutex(), m_profile_data(), m_profile_events(0, eMachProcessProfileCancel), m_thread_actions(), - m_exception_messages(), - m_exception_and_signal_mutex(PTHREAD_MUTEX_RECURSIVE), m_thread_list(), - m_activities(), m_state(eStateUnloaded), - m_state_mutex(PTHREAD_MUTEX_RECURSIVE), m_events(0, kAllEventsMask), - m_private_events(0, kAllEventsMask), m_breakpoints(), m_watchpoints(), - m_name_to_addr_callback(NULL), m_name_to_addr_baton(NULL), - m_image_infos_callback(NULL), m_image_infos_baton(NULL), -
[Lldb-commits] [lldb] [debugserver] Migrate MachProcess away from PThreadMutex (NFC) (PR #137553)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/137553 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb-dap] migrate set breakpoint requests (PR #137448)
@@ -43,6 +43,32 @@ bool fromJSON(const json::Value &Params, Source &S, json::Path P) { O.map("sourceReference", S.sourceReference); } +static llvm::json::Value ToString(PresentationHint hint) { ashgti wrote: toJSON? Then on line 67 you don't need to add `ToString`, it would be handled by the existing overloads. https://github.com/llvm/llvm-project/pull/137448 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate DNBLog away from PThreadMutex (NFC) (PR #137541)
https://github.com/jasonmolenda approved this pull request. https://github.com/llvm/llvm-project/pull/137541 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Remove PThreadMutex (NFC) (PR #137555)
JDevlieghere wrote: Depends on: - #137554 - #137553 - #137547 - #137543 - #137542 - #137541 - #137540 https://github.com/llvm/llvm-project/pull/137555 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e886ba1 - [debugserver] Migrate RNBRemote away from PThreadMutex (NFC) (#137547)
Author: Jonas Devlieghere Date: 2025-04-27T15:16:42-07:00 New Revision: e886ba1d5971ddb3b9242f7300cc97646670e9ce URL: https://github.com/llvm/llvm-project/commit/e886ba1d5971ddb3b9242f7300cc97646670e9ce DIFF: https://github.com/llvm/llvm-project/commit/e886ba1d5971ddb3b9242f7300cc97646670e9ce.diff LOG: [debugserver] Migrate RNBRemote away from PThreadMutex (NFC) (#137547) The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates RNBRemote away from PThreadMutex in preparation for removing it. Added: Modified: lldb/tools/debugserver/source/RNBRemote.cpp lldb/tools/debugserver/source/RNBRemote.h Removed: diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index eb7c5ca32c02a..e0831023e7ae4 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -820,7 +820,7 @@ rnb_err_t RNBRemote::GetPacketPayload(std::string &return_packet) { // (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__); { -PThreadMutex::Locker locker(m_mutex); +std::lock_guard guard(m_mutex); if (m_rx_packets.empty()) { // Only reset the remote command available event if we have no more // packets @@ -1052,7 +1052,7 @@ void RNBRemote::CommDataReceived(const std::string &new_data) { // (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__); // Put the packet data into the buffer in a thread safe fashion - PThreadMutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); std::string data; // See if we have any left over data from a previous call to this diff --git a/lldb/tools/debugserver/source/RNBRemote.h b/lldb/tools/debugserver/source/RNBRemote.h index c552713551013..ad254ae90e2f7 100644 --- a/lldb/tools/debugserver/source/RNBRemote.h +++ b/lldb/tools/debugserver/source/RNBRemote.h @@ -14,7 +14,6 @@ #define LLDB_TOOLS_DEBUGSERVER_SOURCE_RNBREMOTE_H #include "DNB.h" -#include "PThreadMutex.h" #include "RNBContext.h" #include "RNBDefs.h" #include "RNBSocket.h" @@ -25,7 +24,6 @@ class RNBSocket; class RNBContext; -class PThreadEvents; enum event_loop_mode { debug_nub, gdb_remote_protocol, done }; @@ -379,7 +377,7 @@ class RNBRemote { std::string m_arch; nub_thread_t m_continue_thread; // thread to continue; 0 for any, -1 for all nub_thread_t m_thread; // thread for other ops; 0 for any, -1 for all - PThreadMutex m_mutex; // Mutex that protects + std::mutex m_mutex; // Mutex that protects DispatchQueueOffsets m_dispatch_queue_offsets; nub_addr_t m_dispatch_queue_offsets_addr; uint32_t m_qSymbol_index; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate RNBRemote away from PThreadMutex (NFC) (PR #137547)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/137547 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate DNBTimer away from PThreadMutex (NFC) (PR #137540)
https://github.com/jasonmolenda approved this pull request. https://github.com/llvm/llvm-project/pull/137540 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [debugserver] Migrate MachThreadList away from PThreadMutex (NFC) (PR #137542)
https://github.com/jasonmolenda approved this pull request. https://github.com/llvm/llvm-project/pull/137542 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits