[Lldb-commits] [lldb] [lldb] Support new libc++ __compressed_pair layout (PR #96538)

2024-09-15 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/96538

>From 16ae2c3c04d908807d78224a8fee34f772a337fa Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 29 Jan 2024 16:23:16 +
Subject: [PATCH 1/4] [lldb] Support new libc++ __compressed_pair layout

---
 lldb/examples/synthetic/libcxx.py |  26 ++-
 .../Plugins/Language/CPlusPlus/LibCxx.cpp |  85 ++---
 .../Plugins/Language/CPlusPlus/LibCxx.h   |   3 +-
 .../Plugins/Language/CPlusPlus/LibCxxList.cpp |  72 +---
 .../Plugins/Language/CPlusPlus/LibCxxMap.cpp  |  41 +++--
 .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 166 +++---
 .../Language/CPlusPlus/LibCxxVector.cpp   |  38 ++--
 .../list/TestDataFormatterGenericList.py  |   2 +-
 8 files changed, 282 insertions(+), 151 deletions(-)

diff --git a/lldb/examples/synthetic/libcxx.py 
b/lldb/examples/synthetic/libcxx.py
index 474aaa428fa23a..060ff901008497 100644
--- a/lldb/examples/synthetic/libcxx.py
+++ b/lldb/examples/synthetic/libcxx.py
@@ -721,6 +721,12 @@ def _get_value_of_compressed_pair(self, pair):
 def update(self):
 logger = lldb.formatters.Logger.Logger()
 try:
+has_compressed_pair_layout = True
+alloc_valobj = self.valobj.GetChildMemberWithName("__alloc_")
+size_valobj = self.valobj.GetChildMemberWithName("__size_")
+if alloc_valobj.IsValid() and size_valobj.IsValid():
+has_compressed_pair_layout = False
+
 # A deque is effectively a two-dim array, with fixed width.
 # 'map' contains pointers to the rows of this array. The
 # full memory area allocated by the deque is delimited
@@ -734,9 +740,13 @@ def update(self):
 # variable tells which element in this NxM array is the 0th
 # one, and the 'size' element gives the number of elements
 # in the deque.
-count = self._get_value_of_compressed_pair(
-self.valobj.GetChildMemberWithName("__size_")
-)
+if has_compressed_pair_layout:
+count = self._get_value_of_compressed_pair(
+self.valobj.GetChildMemberWithName("__size_")
+)
+else:
+count = size_valobj.GetValueAsUnsigned(0)
+
 # give up now if we cant access memory reliably
 if self.block_size < 0:
 logger.write("block_size < 0")
@@ -748,9 +758,13 @@ def update(self):
 self.map_begin = map_.GetChildMemberWithName("__begin_")
 map_begin = self.map_begin.GetValueAsUnsigned(0)
 map_end = 
map_.GetChildMemberWithName("__end_").GetValueAsUnsigned(0)
-map_endcap = self._get_value_of_compressed_pair(
-map_.GetChildMemberWithName("__end_cap_")
-)
+
+if has_compressed_pair_layout:
+map_endcap = self._get_value_of_compressed_pair(
+map_.GetChildMemberWithName("__end_cap_")
+)
+else:
+map_endcap = 
map_.GetChildMemberWithName("__end_cap_").GetValueAsUnsigned(0)
 
 # check consistency
 if not map_first <= map_begin <= map_end <= map_endcap:
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index feaa51a96843ab..7d3b2410a7296e 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -27,6 +27,7 @@
 #include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
 #include 
 #include 
 
@@ -34,6 +35,32 @@ using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::formatters;
 
+static void consumeInlineNamespace(llvm::StringRef &name) {
+  // Delete past an inline namespace, if any: __[a-zA-Z0-9_]+::
+  auto scratch = name;
+  if (scratch.consume_front("__") && std::isalnum(scratch[0])) {
+scratch = scratch.drop_while([](char c) { return std::isalnum(c); });
+if (scratch.consume_front("::")) {
+  // Successfully consumed a namespace.
+  name = scratch;
+}
+  }
+}
+
+bool lldb_private::formatters::isOldCompressedPairLayout(
+ValueObject &pair_obj) {
+  return isStdTemplate(pair_obj.GetTypeName(), "__compressed_pair");
+}
+
+bool lldb_private::formatters::isStdTemplate(ConstString type_name,
+ llvm::StringRef type) {
+  llvm::StringRef name = type_name.GetStringRef();
+  // The type name may be prefixed with `std::__::`.
+  if (name.consume_front("std::"))
+consumeInlineNamespace(name);
+  return name.consume_front(type) && name.starts_with("<");
+}
+
 lldb::ValueObjectSP lldb_private::formatters::GetChildMemberWithName(
 ValueObject &obj, llvm::ArrayRef alternative_nam

[Lldb-commits] [lldb] [lldb][test] Add a new __compressed_pair layout to libcxx simulator tests (PR #99012)

2024-09-15 Thread Michael Buch via lldb-commits

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/99012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test] Add a new __compressed_pair layout to libcxx simulator tests (PR #99012)

2024-09-15 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/99012

>From e3ec030cb404c407ead39b10d5ea0baa4a0683ff Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 10 Jul 2024 15:37:45 +0100
Subject: [PATCH 1/4] [WIP][lldb][test] Add a new __compressed_pair layout to
 libcxx simulator tests

---
 .../compressed_pair.h | 34 ++-
 .../TestDataFormatterLibcxxStringSimulator.py | 19 ++-
 .../libcxx-simulators/string/main.cpp | 33 +++---
 ...stDataFormatterLibcxxUniquePtrSimulator.py | 14 ++--
 .../libcxx-simulators/unique_ptr/main.cpp |  5 +++
 5 files changed, 81 insertions(+), 24 deletions(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
 
b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
index 026e7183ab27a0..f2c1b626bd46f7 100644
--- 
a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
+++ 
b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
@@ -7,7 +7,7 @@
 namespace std {
 namespace __lldb {
 
-// Post-c88580c layout
+#if COMPRESSED_PAIR_REV == 0 // Post-c88580c layout
 struct __value_init_tag {};
 struct __default_init_tag {};
 
@@ -52,6 +52,38 @@ class __compressed_pair : private 
__compressed_pair_elem<_T1, 0>,
 
   _T1 &first() { return static_cast<_Base1 &>(*this).__get(); }
 };
+#elif COMPRESSED_PAIR_REV == 1
+template  class __compressed_pair_padding {
+  char __padding_[(is_empty<_ToPad>::value && 
!__libcpp_is_final<_ToPad>::value)
+  ? 0
+  : sizeof(_ToPad) - __datasizeof(_ToPad)];
+};
+
+#define _LLDB_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2)  
\
+  [[__gnu__::__aligned__(alignof(T2))]] [[no_unique_address]] T1 Initializer1; 
\
+  [[no_unique_address]] __compressed_pair_padding __padding1_; 
\
+  [[no_unique_address]] T2 Initializer2;   
\
+  [[no_unique_address]] __compressed_pair_padding __padding2_;
+
+#define _LLDB_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3,
\
+Initializer3)  
\
+  [[using __gnu__: __aligned__(alignof(T2)),   
\
+__aligned__(alignof(T3))]] [[no_unique_address]] T1 Initializer1;  
\
+  [[no_unique_address]] __compressed_pair_padding __padding1_; 
\
+  [[no_unique_address]] T2 Initializer2;   
\
+  [[no_unique_address]] __compressed_pair_padding __padding2_; 
\
+  [[no_unique_address]] T3 Initializer3;   
\
+  [[no_unique_address]] __compressed_pair_padding __padding3_;
+#elif COMPRESSED_PAIR_REV == 2
+#define _LLDB_COMPRESSED_PAIR(T1, Name1, T2, Name2)
\
+  [[no_unique_address]] T1 Name1;  
\
+  [[no_unique_address]] T2 Name2
+
+#define _LLDB_COMPRESSED_TRIPLE(T1, Name1, T2, Name2, T3, Name3)   
\
+  [[no_unique_address]] T1 Name1;  
\
+  [[no_unique_address]] T2 Name2;  
\
+  [[no_unique_address]] T3 Name3
+#endif
 } // namespace __lldb
 } // namespace std
 
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
index 3e5c493692c4f0..0d4270ef58568a 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
@@ -25,12 +25,13 @@ def _run_test(self, defines):
 
 for v in [None, "ALTERNATE_LAYOUT"]:
 for r in range(5):
-name = "test_r%d" % r
-defines = ["REVISION=%d" % r]
-if v:
-name += "_" + v
-defines += [v]
-f = functools.partialmethod(
-LibcxxStringDataFormatterSimulatorTestCase._run_test, defines
-)
-setattr(LibcxxStringDataFormatterSimulatorTestCase, name, f)
+for c in range(3):
+name = "test_r%d_c%d" % (r, c)
+defines = ["REVISION=%d" % r, "COMPRESSED_PAIR_REV=%d" % c]
+if v:
+name += "_" + v
+defines += [v]
+f = functools.partialmethod(
+LibcxxStringDataFormatterSimulatorTestCase._run_test, defines
+)
+setattr(LibcxxStringDataFormatterSimulatorTestCase, name, f)
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/

[Lldb-commits] [lldb] [lldb][test] Add a new __compressed_pair layout to libcxx simulator tests (PR #99012)

2024-09-15 Thread Michael Buch via lldb-commits

https://github.com/Michael137 ready_for_review 
https://github.com/llvm/llvm-project/pull/99012
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test] Add a new __compressed_pair layout to libcxx simulator tests (PR #99012)

2024-09-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

This is a follow-up to https://github.com/llvm/llvm-project/pull/98330 for the 
upcoming `__compressed_pair` refactor in 
https://github.com/llvm/llvm-project/issues/93069

This patch just adds the 2 new copies of `_LIBCPP_COMPRESSED_PAIR` layouts to 
the simulator tests.

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


5 Files Affected:

- (modified) 
lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
 (+33-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
 (+10-9) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/main.cpp
 (+31-12) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/TestDataFormatterLibcxxUniquePtrSimulator.py
 (+13-2) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp
 (+5) 


``diff
diff --git 
a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
 
b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
index 026e7183ab27a0..f2c1b626bd46f7 100644
--- 
a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
+++ 
b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
@@ -7,7 +7,7 @@
 namespace std {
 namespace __lldb {
 
-// Post-c88580c layout
+#if COMPRESSED_PAIR_REV == 0 // Post-c88580c layout
 struct __value_init_tag {};
 struct __default_init_tag {};
 
@@ -52,6 +52,38 @@ class __compressed_pair : private 
__compressed_pair_elem<_T1, 0>,
 
   _T1 &first() { return static_cast<_Base1 &>(*this).__get(); }
 };
+#elif COMPRESSED_PAIR_REV == 1
+template  class __compressed_pair_padding {
+  char __padding_[(is_empty<_ToPad>::value && 
!__libcpp_is_final<_ToPad>::value)
+  ? 0
+  : sizeof(_ToPad) - __datasizeof(_ToPad)];
+};
+
+#define _LLDB_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2)  
\
+  [[__gnu__::__aligned__(alignof(T2))]] [[no_unique_address]] T1 Initializer1; 
\
+  [[no_unique_address]] __compressed_pair_padding __padding1_; 
\
+  [[no_unique_address]] T2 Initializer2;   
\
+  [[no_unique_address]] __compressed_pair_padding __padding2_;
+
+#define _LLDB_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3,
\
+Initializer3)  
\
+  [[using __gnu__: __aligned__(alignof(T2)),   
\
+__aligned__(alignof(T3))]] [[no_unique_address]] T1 Initializer1;  
\
+  [[no_unique_address]] __compressed_pair_padding __padding1_; 
\
+  [[no_unique_address]] T2 Initializer2;   
\
+  [[no_unique_address]] __compressed_pair_padding __padding2_; 
\
+  [[no_unique_address]] T3 Initializer3;   
\
+  [[no_unique_address]] __compressed_pair_padding __padding3_;
+#elif COMPRESSED_PAIR_REV == 2
+#define _LLDB_COMPRESSED_PAIR(T1, Name1, T2, Name2)
\
+  [[no_unique_address]] T1 Name1;  
\
+  [[no_unique_address]] T2 Name2
+
+#define _LLDB_COMPRESSED_TRIPLE(T1, Name1, T2, Name2, T3, Name3)   
\
+  [[no_unique_address]] T1 Name1;  
\
+  [[no_unique_address]] T2 Name2;  
\
+  [[no_unique_address]] T3 Name3
+#endif
 } // namespace __lldb
 } // namespace std
 
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
index 98d2c7320003e4..afe6374e55a355 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
@@ -28,12 +28,13 @@ def _run_test(self, defines):
 
 for v in [None, "ALTERNATE_LAYOUT"]:
 for r in range(5):
-name = "test_r%d" % r
-defines = ["REVISION=%d" % r]
-if v:
-name += "_" + v
-defines += [v]
-f = functools.partialmethod(
-LibcxxStringDataFormatterSimulatorTestCase._run_test, defines
-)
-setattr(LibcxxStringDataFormatterSimulatorTestCase, name, f)
+for c in range(3):
+name = "test_r%d_c%d" % (r, c)
+defines = ["REVI

[Lldb-commits] [lldb] [lldb] Nits on uses of llvm::raw_string_ostream (NFC) (PR #108745)

2024-09-15 Thread Youngsuk Kim via lldb-commits

https://github.com/JOE1994 created 
https://github.com/llvm/llvm-project/pull/108745

* Don't call raw_string_ostream::flush(), which is essentially a no-op.
* Avoid unneeded calls to raw_string_ostream::str(), to avoid excess 
indirection.

>From 35f463d394ec57a38a4e940a61af5cd1f527a00d Mon Sep 17 00:00:00 2001
From: JOE1994 
Date: Sun, 15 Sep 2024 05:16:25 -0400
Subject: [PATCH] [lldb] Nits on uses of llvm::raw_string_ostream (NFC)

* Don't call raw_string_ostream::flush(), which is essentially a no-op.
* Avoid unneeded calls to raw_string_ostream::str(), to avoid excess 
indirection.
---
 lldb/include/lldb/Utility/Instrumentation.h  | 2 +-
 lldb/source/Breakpoint/Breakpoint.cpp| 2 +-
 lldb/source/Commands/CommandObjectLog.cpp| 8 
 lldb/source/Commands/CommandObjectRegexCommand.cpp   | 2 +-
 lldb/source/Core/Module.cpp  | 4 ++--
 lldb/source/Expression/IRExecutionUnit.cpp   | 2 --
 lldb/source/Expression/IRInterpreter.cpp | 4 
 lldb/source/Host/windows/PipeWindows.cpp | 1 -
 lldb/source/Interpreter/Options.cpp  | 2 +-
 .../Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp | 2 --
 .../ExpressionParser/Clang/ClangExpressionParser.cpp | 2 --
 .../ExpressionParser/Clang/ClangModulesDeclVendor.cpp| 1 -
 .../Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp   | 3 ---
 .../Plugins/ExpressionParser/Clang/IRForTarget.cpp   | 9 -
 .../ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 2 +-
 .../Process/Windows/Common/NativeProcessWindows.cpp  | 2 +-
 .../Plugins/Process/Windows/Common/ProcessWindows.cpp| 6 +++---
 .../Process/gdb-remote/GDBRemoteCommunicationClient.cpp  | 5 +
 .../Plugins/Process/gdb-remote/ProcessGDBRemote.cpp  | 2 +-
 lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp | 4 ++--
 .../Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp| 2 +-
 .../source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 2 +-
 .../Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp  | 2 +-
 lldb/source/Symbol/Symtab.cpp| 2 +-
 lldb/source/Target/Statistics.cpp| 2 +-
 lldb/source/Target/Target.cpp| 2 +-
 lldb/source/Utility/LLDBAssert.cpp   | 2 +-
 lldb/source/Utility/Log.cpp  | 2 +-
 lldb/tools/lldb-dap/DAP.cpp  | 6 ++
 lldb/tools/lldb-dap/JSONUtils.cpp| 1 -
 lldb/tools/lldb-dap/LLDBUtils.cpp| 1 -
 lldb/tools/lldb-dap/lldb-dap.cpp | 3 ---
 lldb/tools/lldb-instr/Instrument.cpp | 4 ++--
 lldb/tools/lldb-server/LLDBServerUtilities.cpp   | 2 +-
 lldb/tools/lldb-test/lldb-test.cpp   | 2 +-
 lldb/unittests/Symbol/PostfixExpressionTest.cpp  | 2 +-
 .../NativePDB/PdbFPOProgramToDWARFExpressionTests.cpp| 2 +-
 37 files changed, 35 insertions(+), 69 deletions(-)

diff --git a/lldb/include/lldb/Utility/Instrumentation.h 
b/lldb/include/lldb/Utility/Instrumentation.h
index 4a9ac810eb05e9..1a86bfb38654b5 100644
--- a/lldb/include/lldb/Utility/Instrumentation.h
+++ b/lldb/include/lldb/Utility/Instrumentation.h
@@ -70,7 +70,7 @@ template  inline std::string 
stringify_args(const Ts &...ts) {
   std::string buffer;
   llvm::raw_string_ostream ss(buffer);
   stringify_helper(ss, ts...);
-  return ss.str();
+  return buffer;
 }
 
 /// RAII object for instrumenting LLDB API functions.
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index 3268ce0b6857da..54ebafc3f65b5c 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -1127,7 +1127,7 @@ json::Value Breakpoint::GetStatistics() {
 llvm::raw_string_ostream ss(buffer);
 json::OStream json_os(ss);
 bp_data_sp->Serialize(json_os);
-if (auto expected_value = llvm::json::parse(ss.str())) {
+if (auto expected_value = llvm::json::parse(buffer)) {
   bp.try_emplace("details", std::move(*expected_value));
 } else {
   std::string details_error = toString(expected_value.takeError());
diff --git a/lldb/source/Commands/CommandObjectLog.cpp 
b/lldb/source/Commands/CommandObjectLog.cpp
index 9eb68ddb73b6e9..5fb2dfaab8de03 100644
--- a/lldb/source/Commands/CommandObjectLog.cpp
+++ b/lldb/source/Commands/CommandObjectLog.cpp
@@ -204,7 +204,7 @@ class CommandObjectLogEnable : public CommandObjectParsed {
 channel, args.GetArgumentArrayRef(), log_file, m_options.log_options,
 m_options.buffer_size.GetCurrentValue(), m_options.handler,
 error_stream);
-result.GetErrorStream() << error_stream.str();
+result.GetErrorStream() << error;
 
 if (success)
   result.SetStatus(eReturnStatusSuccessFinishNoResult);
@@ -273,7 +273,7 @@ class CommandObjectLogDisable : pu

[Lldb-commits] [lldb] [lldb] Nits on uses of llvm::raw_string_ostream (NFC) (PR #108745)

2024-09-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Youngsuk Kim (JOE1994)


Changes

* Don't call raw_string_ostream::flush(), which is essentially a no-op.
* Avoid unneeded calls to raw_string_ostream::str(), to avoid excess 
indirection.

---

Patch is 26.83 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/108745.diff


37 Files Affected:

- (modified) lldb/include/lldb/Utility/Instrumentation.h (+1-1) 
- (modified) lldb/source/Breakpoint/Breakpoint.cpp (+1-1) 
- (modified) lldb/source/Commands/CommandObjectLog.cpp (+4-4) 
- (modified) lldb/source/Commands/CommandObjectRegexCommand.cpp (+1-1) 
- (modified) lldb/source/Core/Module.cpp (+2-2) 
- (modified) lldb/source/Expression/IRExecutionUnit.cpp (-2) 
- (modified) lldb/source/Expression/IRInterpreter.cpp (-4) 
- (modified) lldb/source/Host/windows/PipeWindows.cpp (-1) 
- (modified) lldb/source/Interpreter/Options.cpp (+1-1) 
- (modified) lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp (-2) 
- (modified) 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (-2) 
- (modified) 
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp (-1) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp 
(-3) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (-9) 
- (modified) 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 (+1-1) 
- (modified) 
lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp (+1-1) 
- (modified) lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp 
(+3-3) 
- (modified) 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (+1-4) 
- (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+1-1) 
- (modified) lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp (+2-2) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
(+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp (+1-1) 
- (modified) lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp 
(+1-1) 
- (modified) lldb/source/Symbol/Symtab.cpp (+1-1) 
- (modified) lldb/source/Target/Statistics.cpp (+1-1) 
- (modified) lldb/source/Target/Target.cpp (+1-1) 
- (modified) lldb/source/Utility/LLDBAssert.cpp (+1-1) 
- (modified) lldb/source/Utility/Log.cpp (+1-1) 
- (modified) lldb/tools/lldb-dap/DAP.cpp (+2-4) 
- (modified) lldb/tools/lldb-dap/JSONUtils.cpp (-1) 
- (modified) lldb/tools/lldb-dap/LLDBUtils.cpp (-1) 
- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (-3) 
- (modified) lldb/tools/lldb-instr/Instrument.cpp (+2-2) 
- (modified) lldb/tools/lldb-server/LLDBServerUtilities.cpp (+1-1) 
- (modified) lldb/tools/lldb-test/lldb-test.cpp (+1-1) 
- (modified) lldb/unittests/Symbol/PostfixExpressionTest.cpp (+1-1) 
- (modified) 
lldb/unittests/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpressionTests.cpp 
(+1-1) 


``diff
diff --git a/lldb/include/lldb/Utility/Instrumentation.h 
b/lldb/include/lldb/Utility/Instrumentation.h
index 4a9ac810eb05e9..1a86bfb38654b5 100644
--- a/lldb/include/lldb/Utility/Instrumentation.h
+++ b/lldb/include/lldb/Utility/Instrumentation.h
@@ -70,7 +70,7 @@ template  inline std::string 
stringify_args(const Ts &...ts) {
   std::string buffer;
   llvm::raw_string_ostream ss(buffer);
   stringify_helper(ss, ts...);
-  return ss.str();
+  return buffer;
 }
 
 /// RAII object for instrumenting LLDB API functions.
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index 3268ce0b6857da..54ebafc3f65b5c 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -1127,7 +1127,7 @@ json::Value Breakpoint::GetStatistics() {
 llvm::raw_string_ostream ss(buffer);
 json::OStream json_os(ss);
 bp_data_sp->Serialize(json_os);
-if (auto expected_value = llvm::json::parse(ss.str())) {
+if (auto expected_value = llvm::json::parse(buffer)) {
   bp.try_emplace("details", std::move(*expected_value));
 } else {
   std::string details_error = toString(expected_value.takeError());
diff --git a/lldb/source/Commands/CommandObjectLog.cpp 
b/lldb/source/Commands/CommandObjectLog.cpp
index 9eb68ddb73b6e9..5fb2dfaab8de03 100644
--- a/lldb/source/Commands/CommandObjectLog.cpp
+++ b/lldb/source/Commands/CommandObjectLog.cpp
@@ -204,7 +204,7 @@ class CommandObjectLogEnable : public CommandObjectParsed {
 channel, args.GetArgumentArrayRef(), log_file, m_options.log_options,
 m_options.buffer_size.GetCurrentValue(), m_options.handler,
 error_stream);
-result.GetErrorStream() << error_stream.str();
+result.GetErrorStream() << error;
 
 if (success)
   result.SetStatus(eReturnStatusSuccessFinishNoResult);
@@ -273,7 +273,7 @@ class CommandObjectLogDisable : public CommandObjectParsed {
   if (Log::DisableLogChannel(channel, args.GetArgumentArrayRef(),

[Lldb-commits] [lldb] [lldb] Conditionalize context_switch attribute based on kernel version (PR #105715)

2024-09-15 Thread via lldb-commits

root-kidik wrote:

Ping

https://github.com/llvm/llvm-project/pull/105715
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Nits on uses of llvm::raw_string_ostream (NFC) (PR #108745)

2024-09-15 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere approved this pull request.

Okay this is safe because after 65b13610a5226b84889b923bae884ba395ad084d, 
`raw_string_ostream` is always unbuffered so you (1) don't need to flush and 
(2) can use the underlying buffer directly. That makes sense. Please include 
that in your commit message. 

I would have split this up into two PRs/commits as the changes are related but 
can stand on their own, but it's not important enough to make you do more work. 
LGTM. 

https://github.com/llvm/llvm-project/pull/108745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Nits on uses of llvm::raw_string_ostream (NFC) (PR #108745)

2024-09-15 Thread Youngsuk Kim via lldb-commits

https://github.com/JOE1994 edited 
https://github.com/llvm/llvm-project/pull/108745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Nits on uses of llvm::raw_string_ostream (NFC) (PR #108745)

2024-09-15 Thread Youngsuk Kim via lldb-commits

https://github.com/JOE1994 edited 
https://github.com/llvm/llvm-project/pull/108745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Nits on uses of llvm::raw_string_ostream (NFC) (PR #108745)

2024-09-15 Thread Youngsuk Kim via lldb-commits

https://github.com/JOE1994 edited 
https://github.com/llvm/llvm-project/pull/108745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] d779685 - [lldb] Nits on uses of llvm::raw_string_ostream (NFC) (#108745)

2024-09-15 Thread via lldb-commits

Author: Youngsuk Kim
Date: 2024-09-16T00:26:51-04:00
New Revision: d7796855b87911b8ae6c726ab5df4949f173dbd2

URL: 
https://github.com/llvm/llvm-project/commit/d7796855b87911b8ae6c726ab5df4949f173dbd2
DIFF: 
https://github.com/llvm/llvm-project/commit/d7796855b87911b8ae6c726ab5df4949f173dbd2.diff

LOG: [lldb] Nits on uses of llvm::raw_string_ostream (NFC) (#108745)

As specified in the docs,
1) raw_string_ostream is always unbuffered and
2) the underlying buffer may be used directly

( 65b13610a5226b84889b923bae884ba395ad084d for further reference )

* Don't call raw_string_ostream::flush(), which is essentially a no-op.
* Avoid unneeded calls to raw_string_ostream::str(), to avoid excess
indirection.

Added: 


Modified: 
lldb/include/lldb/Utility/Instrumentation.h
lldb/source/Breakpoint/Breakpoint.cpp
lldb/source/Commands/CommandObjectLog.cpp
lldb/source/Commands/CommandObjectRegexCommand.cpp
lldb/source/Core/Module.cpp
lldb/source/Expression/IRExecutionUnit.cpp
lldb/source/Expression/IRInterpreter.cpp
lldb/source/Host/windows/PipeWindows.cpp
lldb/source/Interpreter/Options.cpp
lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp
lldb/source/Symbol/Symtab.cpp
lldb/source/Target/Statistics.cpp
lldb/source/Target/Target.cpp
lldb/source/Utility/LLDBAssert.cpp
lldb/source/Utility/Log.cpp
lldb/tools/lldb-dap/DAP.cpp
lldb/tools/lldb-dap/JSONUtils.cpp
lldb/tools/lldb-dap/LLDBUtils.cpp
lldb/tools/lldb-dap/lldb-dap.cpp
lldb/tools/lldb-instr/Instrument.cpp
lldb/tools/lldb-server/LLDBServerUtilities.cpp
lldb/tools/lldb-test/lldb-test.cpp
lldb/unittests/Symbol/PostfixExpressionTest.cpp
lldb/unittests/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpressionTests.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Instrumentation.h 
b/lldb/include/lldb/Utility/Instrumentation.h
index 4a9ac810eb05e9..1a86bfb38654b5 100644
--- a/lldb/include/lldb/Utility/Instrumentation.h
+++ b/lldb/include/lldb/Utility/Instrumentation.h
@@ -70,7 +70,7 @@ template  inline std::string 
stringify_args(const Ts &...ts) {
   std::string buffer;
   llvm::raw_string_ostream ss(buffer);
   stringify_helper(ss, ts...);
-  return ss.str();
+  return buffer;
 }
 
 /// RAII object for instrumenting LLDB API functions.

diff  --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index 3268ce0b6857da..54ebafc3f65b5c 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -1127,7 +1127,7 @@ json::Value Breakpoint::GetStatistics() {
 llvm::raw_string_ostream ss(buffer);
 json::OStream json_os(ss);
 bp_data_sp->Serialize(json_os);
-if (auto expected_value = llvm::json::parse(ss.str())) {
+if (auto expected_value = llvm::json::parse(buffer)) {
   bp.try_emplace("details", std::move(*expected_value));
 } else {
   std::string details_error = toString(expected_value.takeError());

diff  --git a/lldb/source/Commands/CommandObjectLog.cpp 
b/lldb/source/Commands/CommandObjectLog.cpp
index 9eb68ddb73b6e9..5fb2dfaab8de03 100644
--- a/lldb/source/Commands/CommandObjectLog.cpp
+++ b/lldb/source/Commands/CommandObjectLog.cpp
@@ -204,7 +204,7 @@ class CommandObjectLogEnable : public CommandObjectParsed {
 channel, args.GetArgumentArrayRef(), log_file, m_options.log_options,
 m_options.buffer_size.GetCurrentValue(), m_options.handler,
 error_stream);
-result.GetErrorStream() << error_stream.str();
+result.GetErrorStream() << error;
 
 if (success)
   result.SetStatus(eReturnStatusSuccessFinishNoResult);
@@ -273,7 +273,7 @@ class CommandObjectLogDisable : public CommandObjectParsed {
   if (Log::DisableLogChannel(channel, args.GetArgumentArrayRef(),
  error_stream))
 result.SetStatus(eReturnStatusSuccessFinishNoResult);
-  result.GetErrorStream() << error_stream.str();
+  result.GetErrorStream() << e

[Lldb-commits] [lldb] [lldb] Nits on uses of llvm::raw_string_ostream (NFC) (PR #108745)

2024-09-15 Thread Youngsuk Kim via lldb-commits

https://github.com/JOE1994 closed 
https://github.com/llvm/llvm-project/pull/108745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [compiler-rt] [libcxx] [lldb] [llvm] Rename Sanitizer Coverage => Coverage Sanitizer (PR #106505)

2024-09-15 Thread Vitaly Buka via lldb-commits

https://github.com/vitalybuka requested changes to this pull request.

I think it change the meaning completly.
I read "Coverage Sanitizer" as a tool which finds bugs in Coverage.
When "Sanitizer Coverage" as a coverage used by sanitizers.

https://github.com/llvm/llvm-project/pull/106505
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [compiler-rt] [libcxx] [lldb] [llvm] Rename Sanitizer Coverage => Coverage Sanitizer (PR #106505)

2024-09-15 Thread Vitaly Buka via lldb-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/106505
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [compiler-rt] [libcxx] [lldb] [llvm] Rename Sanitizer Coverage => Coverage Sanitizer (PR #106505)

2024-09-15 Thread Vitaly Buka via lldb-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/106505
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits