[Lldb-commits] [lldb] Add support for reading the dynamic symbol table from PT_DYNAMIC (PR #112596)

2024-10-22 Thread Greg Clayton via lldb-commits

https://github.com/clayborg updated 
https://github.com/llvm/llvm-project/pull/112596

>From 890d2bcf655a2e1e58b025cc0df7b4e42956e4c6 Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Sat, 28 Sep 2024 15:05:37 -0700
Subject: [PATCH 1/3] Add support for reading the dynamic symbol table from
 program headers and PT_DYNAMIC.

Allow LLDB to parse the dynamic symbol table from an ELF file or memory image 
in an ELF file that has no section headers. This patch uses the ability to 
parse the PT_DYNAMIC segment and find the DT_SYMTAB, DT_SYMENT, DT_HASH or 
DT_GNU_HASH to find and parse the dynamic symbol table if the section headers 
are not present. It also adds a helper function to read data from a .dynamic 
key/value pair entry correctly from the file or from memory.
---
 .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp  | 163 -
 .../Plugins/ObjectFile/ELF/ObjectFileELF.h|  34 +
 .../test/Shell/ObjectFile/ELF/elf-dynsym.yaml | 631 ++
 3 files changed, 811 insertions(+), 17 deletions(-)
 create mode 100644 lldb/test/Shell/ObjectFile/ELF/elf-dynsym.yaml

diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 10d09662c0a47a..7374ac10a1e27a 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -44,6 +44,8 @@
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/MipsABIFlags.h"
+#include "lldb/Target/Process.h"
+
 
 #define CASE_AND_STREAM(s, def, width) 
\
   case def:
\
@@ -2990,18 +2992,34 @@ void ObjectFileELF::ParseSymtab(Symtab &lldb_symtab) {
   // section, nomatter if .symtab was already parsed or not. This is because
   // minidebuginfo normally removes the .symtab symbols which have their
   // matching .dynsym counterparts.
+  bool found_dynsym = false;
   if (!symtab ||
   GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"))) {
 Section *dynsym =
 section_list->FindSectionByType(eSectionTypeELFDynamicSymbols, true)
 .get();
 if (dynsym) {
+  found_dynsym = true;
   auto [num_symbols, address_class_map] =
   ParseSymbolTable(&lldb_symtab, symbol_id, dynsym);
   symbol_id += num_symbols;
   m_address_class_map.merge(address_class_map);
 }
   }
+  if (!found_dynsym) {
+// Try and read the dynamic symbol table from the .dynamic section.
+uint32_t num_symbols = 0;
+std::optional symtab_data =
+GetDynsymDataFromDynamic(num_symbols);
+std::optional strtab_data = GetDynstrData();
+if (symtab_data && strtab_data) {
+  auto [num_symbols_parsed, address_class_map] =
+  ParseSymbols(&lldb_symtab, symbol_id, section_list, num_symbols,
+symtab_data.value(), strtab_data.value());
+  symbol_id += num_symbols_parsed;
+  m_address_class_map.merge(address_class_map);
+}
+  }
 
   // DT_JMPREL
   //  If present, this entry's d_ptr member holds the address of
@@ -3811,6 +3829,33 @@ ObjectFileELF::MapFileDataWritable(const FileSpec &file, 
uint64_t Size,
  Offset);
 }
 
+std::optional
+ObjectFileELF::ReadDataFromDynamic(const ELFDynamic *dyn, uint64_t length,
+   uint64_t offset) {
+  // ELFDynamic values contain a "d_ptr" member that will be a load address if
+  // we have an ELF file read from memory, or it will be a file address if it
+  // was read from a ELF file. This function will correctly fetch data pointed
+  // to by the ELFDynamic::d_ptr, or return std::nullopt if the data isn't
+  // available.
+  const lldb::addr_t d_ptr_addr = dyn->d_ptr + offset;
+  if (ProcessSP process_sp = m_process_wp.lock()) {
+if (DataBufferSP data_sp = ReadMemory(process_sp, d_ptr_addr, length))
+  return DataExtractor(data_sp, GetByteOrder(), GetAddressByteSize());
+  } else {
+// We have an ELF file with no section headers or we didn't find the
+// .dynamic section. Try and find the .dynstr section.
+Address addr;
+if (!addr.ResolveAddressUsingFileSections(d_ptr_addr, GetSectionList()))
+  return std::nullopt;
+DataExtractor data;
+addr.GetSection()->GetSectionData(data);
+return DataExtractor(data,
+ d_ptr_addr - addr.GetSection()->GetFileAddress(),
+ length);
+  }
+  return std::nullopt;
+}
+
 std::optional ObjectFileELF::GetDynstrData() {
   if (SectionList *section_list = GetSectionList()) {
 // Find the SHT_DYNAMIC section.
@@ -3846,23 +3891,7 @@ std::optional 
ObjectFileELF::GetDynstrData() {
   if (strtab == nullptr || strsz == nullptr)
 return std::nullopt;
 
-  if (ProcessSP process_sp = m_process_wp.lock()) {
-if (DataBufferSP data_sp =
-ReadMemory(process_s

[Lldb-commits] [lldb] Add SBDebugger:: AddNotificationCallback API (PR #111206)

2024-10-22 Thread Zequan Wu via lldb-commits


@@ -737,19 +752,35 @@ class Debugger : public 
std::enable_shared_from_this,
   lldb::TargetSP m_dummy_target_sp;
   Diagnostics::CallbackID m_diagnostics_callback_id;
 
-  std::mutex m_destroy_callback_mutex;
-  lldb::callback_token_t m_destroy_callback_next_token = 0;
-  struct DestroyCallbackInfo {
-DestroyCallbackInfo() {}
-DestroyCallbackInfo(lldb::callback_token_t token,
-lldb_private::DebuggerDestroyCallback callback,
-void *baton)
+  template  struct CallbackInfo {

ZequanWu wrote:

IIUC, `CallbackInfo` is the base template callback class for all kinds of 
callback (debugger create/destroy, and some other callbacks to be added in the 
future). It's better to place it somewhere else to make easier to extended in 
the future. 

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


[Lldb-commits] [lldb] [lldb] Move ValueObject into its own library (NFC) (PR #113393)

2024-10-22 Thread via lldb-commits

llvmbot wrote:



@llvm/pr-subscribers-lldb

@llvm/pr-subscribers-backend-hexagon

Author: Jonas Devlieghere (JDevlieghere)


Changes

ValueObject is part of lldbCore for historical reasons, but it can totally 
stand on its own. This does introduce a circular dependency between lldbCore 
and lldbValueObject, which is unfortunate but probably unavoidable.

The header includes were updated with the following command:

```
find . -type f -exec sed -i.bak "s%include \"lldb/Core/ValueObject%include 
\"lldb/ValueObject/ValueObject%" '{}' \;
```

---

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


188 Files Affected:

- (modified) lldb/include/lldb/Core/IOHandler.h (-1) 
- (modified) lldb/include/lldb/DataFormatters/FormattersContainer.h (+1-1) 
- (modified) lldb/include/lldb/DataFormatters/TypeFormat.h (+1-1) 
- (modified) lldb/include/lldb/DataFormatters/TypeSynthetic.h (+1-1) 
- (modified) lldb/include/lldb/Expression/ExpressionVariable.h (+1-1) 
- (modified) lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h 
(+1-1) 
- (modified) lldb/include/lldb/Target/LanguageRuntime.h (+1-1) 
- (modified) lldb/include/lldb/Target/StackFrame.h (+1-1) 
- (modified) lldb/include/lldb/Target/StackFrameRecognizer.h (+2-2) 
- (renamed) lldb/include/lldb/ValueObject/ValueObject.h () 
- (renamed) lldb/include/lldb/ValueObject/ValueObjectCast.h (+1-1) 
- (renamed) lldb/include/lldb/ValueObject/ValueObjectChild.h (+1-1) 
- (renamed) lldb/include/lldb/ValueObject/ValueObjectConstResult.h (+2-2) 
- (renamed) lldb/include/lldb/ValueObject/ValueObjectConstResultCast.h (+2-2) 
- (renamed) lldb/include/lldb/ValueObject/ValueObjectConstResultChild.h (+2-2) 
- (renamed) lldb/include/lldb/ValueObject/ValueObjectConstResultImpl.h () 
- (renamed) lldb/include/lldb/ValueObject/ValueObjectDynamicValue.h (+1-1) 
- (renamed) lldb/include/lldb/ValueObject/ValueObjectList.h () 
- (renamed) lldb/include/lldb/ValueObject/ValueObjectMemory.h (+1-1) 
- (renamed) lldb/include/lldb/ValueObject/ValueObjectRegister.h (+1-1) 
- (renamed) lldb/include/lldb/ValueObject/ValueObjectSyntheticFilter.h (+1-1) 
- (renamed) lldb/include/lldb/ValueObject/ValueObjectUpdater.h (+1-1) 
- (renamed) lldb/include/lldb/ValueObject/ValueObjectVTable.h (+1-1) 
- (renamed) lldb/include/lldb/ValueObject/ValueObjectVariable.h (+1-1) 
- (modified) lldb/source/API/CMakeLists.txt (+1) 
- (modified) lldb/source/API/SBBlock.cpp (+1-1) 
- (modified) lldb/source/API/SBFrame.cpp (+3-3) 
- (modified) lldb/source/API/SBModule.cpp (+2-2) 
- (modified) lldb/source/API/SBTarget.cpp (+3-3) 
- (modified) lldb/source/API/SBThread.cpp (+1-1) 
- (modified) lldb/source/API/SBType.cpp (+1-1) 
- (modified) lldb/source/API/SBValue.cpp (+2-2) 
- (modified) lldb/source/API/SBValueList.cpp (+1-1) 
- (modified) lldb/source/Breakpoint/BreakpointLocation.cpp (+1-1) 
- (modified) lldb/source/Breakpoint/Watchpoint.cpp (+2-2) 
- (modified) lldb/source/CMakeLists.txt (+1) 
- (modified) lldb/source/Commands/CommandObjectDWIMPrint.cpp (+1-1) 
- (modified) lldb/source/Commands/CommandObjectFrame.cpp (+1-1) 
- (modified) lldb/source/Commands/CommandObjectMemory.cpp (+1-1) 
- (modified) lldb/source/Commands/CommandObjectTarget.cpp (+1-1) 
- (modified) lldb/source/Commands/CommandObjectThread.cpp (+1-1) 
- (modified) lldb/source/Commands/CommandObjectWatchpoint.cpp (+1-1) 
- (modified) lldb/source/Core/CMakeLists.txt (+1-15) 
- (modified) lldb/source/Core/DumpRegisterValue.cpp (+2-2) 
- (modified) lldb/source/Core/FormatEntity.cpp (+2-2) 
- (modified) lldb/source/Core/IOHandlerCursesGUI.cpp (+3-3) 
- (modified) lldb/source/DataFormatters/CMakeLists.txt (+2-1) 
- (modified) lldb/source/DataFormatters/CXXFunctionPointer.cpp (+1-1) 
- (modified) lldb/source/DataFormatters/DumpValueObjectOptions.cpp (+1-1) 
- (modified) lldb/source/DataFormatters/FormatManager.cpp (+1-1) 
- (modified) lldb/source/DataFormatters/StringPrinter.cpp (+1-1) 
- (modified) lldb/source/DataFormatters/TypeSummary.cpp (+1-1) 
- (modified) lldb/source/DataFormatters/ValueObjectPrinter.cpp (+1-1) 
- (modified) lldb/source/DataFormatters/VectorType.cpp (+2-2) 
- (modified) lldb/source/Expression/CMakeLists.txt (+1) 
- (modified) lldb/source/Expression/FunctionCaller.cpp (+2-2) 
- (modified) lldb/source/Expression/IRInterpreter.cpp (+1-1) 
- (modified) lldb/source/Expression/LLVMUserExpression.cpp (+1-1) 
- (modified) lldb/source/Expression/Materializer.cpp (+2-2) 
- (modified) lldb/source/Expression/UserExpression.cpp (+1-1) 
- (modified) lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp (+1-1) 
- (modified) lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp (+1-1) 
- (modified) lldb/source/Plugins/ABI/AArch64/CMakeLists.txt (+1) 
- (modified) lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp (+3-3) 
- (modified) lldb/source/Plugins/ABI/ARC/CMakeLists.txt (+1) 
- (modified) lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp (+1-1) 
- (modified) lldb/source/Plugins/ABI/ARM/A

[Lldb-commits] [lldb] [lldb] Move ValueObject into its own library (NFC) (PR #113393)

2024-10-22 Thread via lldb-commits

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 395093ec150accf19b8158f9d2327ba470e92867 
9cd8c9fd40ec13d6828d42a8693bf0dc9074d909 --extensions cpp,h -- 
lldb/include/lldb/Core/IOHandler.h 
lldb/include/lldb/DataFormatters/FormattersContainer.h 
lldb/include/lldb/DataFormatters/TypeFormat.h 
lldb/include/lldb/DataFormatters/TypeSynthetic.h 
lldb/include/lldb/Expression/ExpressionVariable.h 
lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h 
lldb/include/lldb/Target/LanguageRuntime.h 
lldb/include/lldb/Target/StackFrame.h 
lldb/include/lldb/Target/StackFrameRecognizer.h lldb/source/API/SBBlock.cpp 
lldb/source/API/SBFrame.cpp lldb/source/API/SBModule.cpp 
lldb/source/API/SBTarget.cpp lldb/source/API/SBThread.cpp 
lldb/source/API/SBType.cpp lldb/source/API/SBValue.cpp 
lldb/source/API/SBValueList.cpp lldb/source/Breakpoint/BreakpointLocation.cpp 
lldb/source/Breakpoint/Watchpoint.cpp 
lldb/source/Commands/CommandObjectDWIMPrint.cpp 
lldb/source/Commands/CommandObjectFrame.cpp 
lldb/source/Commands/CommandObjectMemory.cpp 
lldb/source/Commands/CommandObjectTarget.cpp 
lldb/source/Commands/CommandObjectThread.cpp 
lldb/source/Commands/CommandObjectWatchpoint.cpp 
lldb/source/Core/DumpRegisterValue.cpp lldb/source/Core/FormatEntity.cpp 
lldb/source/Core/IOHandlerCursesGUI.cpp 
lldb/source/DataFormatters/CXXFunctionPointer.cpp 
lldb/source/DataFormatters/DumpValueObjectOptions.cpp 
lldb/source/DataFormatters/FormatManager.cpp 
lldb/source/DataFormatters/StringPrinter.cpp 
lldb/source/DataFormatters/TypeSummary.cpp 
lldb/source/DataFormatters/ValueObjectPrinter.cpp 
lldb/source/DataFormatters/VectorType.cpp 
lldb/source/Expression/FunctionCaller.cpp 
lldb/source/Expression/IRInterpreter.cpp 
lldb/source/Expression/LLVMUserExpression.cpp 
lldb/source/Expression/Materializer.cpp 
lldb/source/Expression/UserExpression.cpp 
lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp 
lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp 
lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp 
lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp 
lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp 
lldb/source/Plugins/ABI/Hexagon/ABISysV_hexagon.cpp 
lldb/source/Plugins/ABI/MSP430/ABISysV_msp430.cpp 
lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp 
lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp 
lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp 
lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp 
lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp 
lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp 
lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.cpp 
lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp 
lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp 
lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionUtil.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h 
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp 
lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
 lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp 
lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp 
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
lldb/source/Plugins/Language/CPlusPlus/Coroutines.h 
lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp 
lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.h 
lldb/source/Plugins/Language/CPlusPlus/Generic.h 
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxx.h 
lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h 
lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxProxyArray.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxValarray.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.h 
lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h 
lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp 
lldb/source/Plugins/Language/ObjC/CF.cpp lldb/source/Plugins/Language/ObjC/CF.h 
lldb/source/Plugins/Language/ObjC/Cocoa

[Lldb-commits] [lldb] [llvm] [lldb] Fix write only file action to truncate the file (PR #112657)

2024-10-22 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/112657

>From 4acbf064144144142a6126f8d9c3e6b5f9cf48e9 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Mon, 14 Oct 2024 22:37:50 -0700
Subject: [PATCH] [lldb] Fix write only file action to truncate the file

---
 lldb/source/Host/common/FileAction.cpp|  2 +-
 .../API/commands/settings/TestSettings.py | 53 +++
 .../python_api/process/io/TestProcessIO.py| 30 +++
 lldb/unittests/Host/FileActionTest.cpp| 25 +
 llvm/docs/ReleaseNotes.md |  3 ++
 5 files changed, 112 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Host/common/FileAction.cpp 
b/lldb/source/Host/common/FileAction.cpp
index f980d3224640e0..e1c3e14a165ea9 100644
--- a/lldb/source/Host/common/FileAction.cpp
+++ b/lldb/source/Host/common/FileAction.cpp
@@ -41,7 +41,7 @@ bool FileAction::Open(int fd, const FileSpec &file_spec, bool 
read,
 else if (read)
   m_arg = O_NOCTTY | O_RDONLY;
 else
-  m_arg = O_NOCTTY | O_CREAT | O_WRONLY;
+  m_arg = O_NOCTTY | O_CREAT | O_WRONLY | O_TRUNC;
 m_file_spec = file_spec;
 return true;
   } else {
diff --git a/lldb/test/API/commands/settings/TestSettings.py 
b/lldb/test/API/commands/settings/TestSettings.py
index 385acceb7a8b5c..2dd813f6b155b3 100644
--- a/lldb/test/API/commands/settings/TestSettings.py
+++ b/lldb/test/API/commands/settings/TestSettings.py
@@ -528,6 +528,59 @@ def test_set_error_output_path(self):
 output, exe=False, startstr="This message should go to standard 
out."
 )
 
+@skipIfDarwinEmbedded  #  debugserver on ios etc 
can't write files
+def test_same_error_output_path(self):
+"""Test that setting target.error and output-path to the same file 
path for the launched process works."""
+self.build()
+
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+# Set the error-path and output-path and verify both are set.
+self.runCmd(
+"settings set target.error-path '{0}'".format(
+lldbutil.append_to_process_working_directory(self, 
"output.txt")
+)
+)
+self.runCmd(
+"settings set target.output-path '{0}".format(
+lldbutil.append_to_process_working_directory(self, 
"output.txt")
+)
+)
+# And add hooks to restore the original settings during tearDown().
+self.addTearDownHook(lambda: self.runCmd("settings clear 
target.output-path"))
+self.addTearDownHook(lambda: self.runCmd("settings clear 
target.error-path"))
+
+self.expect(
+"settings show target.error-path",
+SETTING_MSG("target.error-path"),
+substrs=["target.error-path (file)", 'output.txt"'],
+)
+
+self.expect(
+"settings show target.output-path",
+SETTING_MSG("target.output-path"),
+substrs=["target.output-path (file)", 'output.txt"'],
+)
+
+self.runCmd(
+"process launch --working-dir '{0}'".format(
+self.get_process_working_directory()
+),
+RUN_SUCCEEDED,
+)
+
+output = lldbutil.read_file_from_process_wd(self, "output.txt")
+err_message = "This message should go to standard error."
+out_message = "This message should go to standard out."
+# Error msg should get flushed by the output msg
+self.expect(output, exe=False, substrs=[out_message])
+self.assertNotIn(
+err_message,
+output,
+"Race condition when both stderr/stdout redirects to the same 
file",
+)
+
 def test_print_dictionary_setting(self):
 self.runCmd("settings clear target.env-vars")
 self.runCmd('settings set target.env-vars ["MY_VAR"]=some-value')
diff --git a/lldb/test/API/python_api/process/io/TestProcessIO.py 
b/lldb/test/API/python_api/process/io/TestProcessIO.py
index 5bb91d2758312d..3b5c7c48c51f4d 100644
--- a/lldb/test/API/python_api/process/io/TestProcessIO.py
+++ b/lldb/test/API/python_api/process/io/TestProcessIO.py
@@ -95,6 +95,36 @@ def test_stdout_stderr_redirection(self):
 error = self.read_error_file_and_delete()
 self.check_process_output(output, error)
 
+@skipIfWindows  # stdio manipulation unsupported on Windows
+@expectedFlakeyLinux(bugnumber="llvm.org/pr26437")
+@skipIfDarwinEmbedded  # debugserver can't create/write files on the device
+def test_stdout_stderr_redirection_to_existing_files(self):
+"""Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT and STDERR 
without redirecting STDIN to output files already exist."""
+self.setup_test()
+self.build()
+self.create_target()
+self.write_file_with_placeholder(self.output_file)
+self.write_file_with_placeholder(self.error_file)
+ 

[Lldb-commits] [lldb] [llvm] [lldb] Fix write only file action to truncate the file (PR #112657)

2024-10-22 Thread via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb] Fix write only file action to truncate the file (PR #112657)

2024-10-22 Thread via lldb-commits

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-22 Thread via lldb-commits

https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/112939

>From 9c6705b21df14dc911665e1082c9b31ce00d7e7c Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Thu, 3 Oct 2024 18:24:46 -0700
Subject: [PATCH 01/10] Add the ability to break on call-site locations, report
 the correct position in the virtual inlined call stack when they are hit, and
 step through the inlined stack from there.

---
 .../lldb/Breakpoint/BreakpointLocation.h  |  31 
 lldb/include/lldb/Breakpoint/BreakpointSite.h |   5 +
 lldb/include/lldb/Target/StopInfo.h   |  11 ++
 .../lldb/Target/ThreadPlanStepInRange.h   |   4 +-
 lldb/source/Breakpoint/BreakpointLocation.cpp |  61 ++-
 lldb/source/Breakpoint/BreakpointResolver.cpp |  12 ++
 lldb/source/Breakpoint/BreakpointSite.cpp |  16 ++
 lldb/source/Core/Declaration.cpp  |   2 +-
 lldb/source/Symbol/CompileUnit.cpp| 104 ++-
 lldb/source/Target/StackFrameList.cpp | 170 ++
 lldb/source/Target/StopInfo.cpp   |  55 ++
 lldb/source/Target/Thread.cpp |   8 +
 lldb/source/Target/ThreadPlanStepInRange.cpp  |  24 ++-
 .../source/Target/ThreadPlanStepOverRange.cpp |   2 +-
 .../inline-stepping/TestInlineStepping.py |  54 ++
 .../inline-stepping/calling.cpp   |  31 
 16 files changed, 462 insertions(+), 128 deletions(-)

diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h 
b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
index cca00335bc3c67..f9c258daf137f7 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -11,10 +11,12 @@
 
 #include 
 #include 
+#include 
 
 #include "lldb/Breakpoint/BreakpointOptions.h"
 #include "lldb/Breakpoint/StoppointHitCounter.h"
 #include "lldb/Core/Address.h"
+#include "lldb/Symbol/LineEntry.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-private.h"
 
@@ -281,6 +283,18 @@ class BreakpointLocation
 
   /// Returns the breakpoint location ID.
   lldb::break_id_t GetID() const { return m_loc_id; }
+  
+  // Set the line entry that should be shown to users for this location.
+  // It is up to the caller to verify that this is a valid entry to show.
+  // The current use of this is to distinguish among line entries from a
+  // virtual inlined call stack that all share the same address.
+  void SetPreferredLineEntry(const LineEntry &line_entry) {
+m_preferred_line_entry = line_entry;
+  }
+  
+  const std::optional GetPreferredLineEntry() {
+return m_preferred_line_entry;
+  }
 
 protected:
   friend class BreakpointSite;
@@ -305,6 +319,16 @@ class BreakpointLocation
   /// It also takes care of decrementing the ignore counters.
   /// If it returns false we should continue, otherwise stop.
   bool IgnoreCountShouldStop();
+  
+  // If this location knows that the virtual stack frame it represents is
+  // not frame 0, return the suggested stack frame instead.  This will happen
+  // when the location's address contains a "virtual inlined call stack" and 
the
+  // breakpoint was set on a file & line that are not at the bottom of that
+  // stack.  For now we key off the "preferred line entry" - looking for that
+  // in the blocks that start with the stop PC.
+  // This version of the API doesn't take an "inlined" parameter because it
+  // only changes frames in the inline stack.
+  std::optional GetSuggestedStackFrameIndex();
 
 private:
   void SwapLocation(lldb::BreakpointLocationSP swap_from);
@@ -369,6 +393,13 @@ class BreakpointLocation
   lldb::break_id_t m_loc_id; ///< Breakpoint location ID.
   StoppointHitCounter m_hit_counter; ///< Number of times this breakpoint
  /// location has been hit.
+  std::optional m_preferred_line_entry; // If this exists, use it 
to print the stop
+// description rather than the LineEntry 
+// m_address resolves to directly.  Use 
this
+// for instance when the location was given
+// somewhere in the virtual inlined call
+// stack since the Address always resolves 
+// to the lowest entry in the stack.
 
   void SetShouldResolveIndirectFunctions(bool do_resolve) {
 m_should_resolve_indirect_functions = do_resolve;
diff --git a/lldb/include/lldb/Breakpoint/BreakpointSite.h 
b/lldb/include/lldb/Breakpoint/BreakpointSite.h
index 17b76d51c1ae53..30cb5a80b908e0 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointSite.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointSite.h
@@ -169,6 +169,11 @@ class BreakpointSite : public 
std::enable_shared_from_this,
   ///
   /// \see lldb::DescriptionLevel
   void GetDescription(Stream *s, lldb::DescriptionLevel level);
+  
+  // This runs through all the breakpoint locations owning this

[Lldb-commits] [lldb] [lldb] Extend FindTypes to optionally search by mangled type name (PR #113007)

2024-10-22 Thread Augusto Noronha via lldb-commits

https://github.com/augusto2112 updated 
https://github.com/llvm/llvm-project/pull/113007

>From 7881a25f21ffabc97417a7daa38fe8148615d36c Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Tue, 22 Oct 2024 14:23:43 -0700
Subject: [PATCH] [lldb] Extend FindTypes to optionally search by mangled type
 name

Swift types have mangled type names. This adds functionality to look
up those types through the FindTypes API by searching for the mangled
type name instead of the regular name.
---
 lldb/include/lldb/Symbol/Type.h  |  8 
 .../Plugins/SymbolFile/CTF/SymbolFileCTF.cpp | 16 +++-
 .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp |  9 +
 .../SymbolFile/NativePDB/SymbolFileNativePDB.cpp |  5 -
 .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp |  5 -
 5 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index 03d9f927997476..b90cfc44e907b9 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -84,6 +84,8 @@ FLAGS_ENUM(TypeQueryOptions){
 /// matching type is found. When false, the type query should find all
 /// matching types.
 e_find_one = (1u << 4),
+// If set, treat TypeQuery::m_name as a mangled name that should be 
searched.
+e_search_by_mangled_name = (1u << 5),
 };
 LLDB_MARK_AS_BITMASK_ENUM(TypeQueryOptions)
 
@@ -300,6 +302,12 @@ class TypeQuery {
   m_options &= ~e_find_one;
   }
 
+  /// Returns true if the type query is supposed to treat the name to be 
searched
+  /// as a mangled name.
+  bool GetSearchByMangledName() const {
+return (m_options & e_search_by_mangled_name) != 0;
+  }
+
   /// Access the internal compiler context array.
   ///
   /// Clients can use this to populate the context manually.
diff --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index bb738c3dcc54a0..4d08c53f752098 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -1032,11 +1032,17 @@ void SymbolFileCTF::FindTypes(const 
lldb_private::TypeQuery &match,
 
   ConstString name = match.GetTypeBasename();
   for (TypeSP type_sp : GetTypeList().Types()) {
-if (type_sp && type_sp->GetName() == name) {
-  results.InsertUnique(type_sp);
-  if (results.Done(match))
-return;
-}
+if (!type_sp)
+  continue;
+auto type_name =
+match.GetSearchByMangledName()
+? type_sp->GetForwardCompilerType().GetMangledTypeName()
+: type_sp->GetName();
+if (type_name != name)
+  continue;
+results.InsertUnique(type_sp);
+if (results.Done(match))
+  return;
   }
 }
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index e5b8eee8d08c24..c16f7d8d0f37f9 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2758,6 +2758,15 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
 return true; // Keep iterating over index types, language mismatch.
 }
 
+// Since mangled names are unique, we only need to check if the names are
+// the same.
+if (query.GetSearchByMangledName()) {
+  if (die.GetMangledName() == query.GetTypeBasename().GetStringRef())
+if (Type *matching_type = ResolveType(die, true, true))
+  results.InsertUnique(matching_type->shared_from_this());
+  return !results.Done(query); // Keep iterating if we aren't done.
+}
+
 // Check the context matches
 std::vector die_context;
 if (query.GetModuleSearch())
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp 
b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 7fded6a31a3af5..b55518a136c997 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -1735,7 +1735,10 @@ void SymbolFileNativePDB::FindTypes(const 
lldb_private::TypeQuery &query,
   continue;
 
 // We resolved a type. Get the fully qualified name to ensure it matches.
-ConstString name = type_sp->GetQualifiedName();
+ConstString name =
+query.GetSearchByMangledName()
+? type_sp->GetForwardCompilerType().GetMangledTypeName()
+: type_sp->GetQualifiedName();
 TypeQuery type_match(name.GetStringRef(), TypeQueryOptions::e_exact_match);
 if (query.ContextMatches(type_match.GetContextRef())) {
   results.InsertUnique(type_sp);
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp 
b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index 4fc48b4d133382..0ea18d8f74baa3 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/P

[Lldb-commits] [lldb] [lldb] Extend FindTypes to optionally search by mangled type name (PR #113007)

2024-10-22 Thread Augusto Noronha via lldb-commits

https://github.com/augusto2112 updated 
https://github.com/llvm/llvm-project/pull/113007

>From eab35bd50d89a16494d8f08421a12aef77356c43 Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Tue, 22 Oct 2024 14:34:44 -0700
Subject: [PATCH] [lldb] Extend FindTypes to optionally search by mangled type
 name

Swift types have mangled type names. This adds functionality to look
up those types through the FindTypes API by searching for the mangled
type name instead of the regular name.
---
 lldb/include/lldb/Symbol/Type.h  |  9 +
 .../Plugins/SymbolFile/CTF/SymbolFileCTF.cpp | 16 +++-
 .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp |  9 +
 .../SymbolFile/NativePDB/SymbolFileNativePDB.cpp |  5 -
 .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp |  5 -
 5 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index 03d9f927997476..a8e5b81585e169 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -84,6 +84,9 @@ FLAGS_ENUM(TypeQueryOptions){
 /// matching type is found. When false, the type query should find all
 /// matching types.
 e_find_one = (1u << 4),
+// If set, treat TypeQuery::m_name as a mangled name that should be
+// searched.
+e_search_by_mangled_name = (1u << 5),
 };
 LLDB_MARK_AS_BITMASK_ENUM(TypeQueryOptions)
 
@@ -300,6 +303,12 @@ class TypeQuery {
   m_options &= ~e_find_one;
   }
 
+  /// Returns true if the type query is supposed to treat the name to be
+  /// searched as a mangled name.
+  bool GetSearchByMangledName() const {
+return (m_options & e_search_by_mangled_name) != 0;
+  }
+
   /// Access the internal compiler context array.
   ///
   /// Clients can use this to populate the context manually.
diff --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index bb738c3dcc54a0..4d08c53f752098 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -1032,11 +1032,17 @@ void SymbolFileCTF::FindTypes(const 
lldb_private::TypeQuery &match,
 
   ConstString name = match.GetTypeBasename();
   for (TypeSP type_sp : GetTypeList().Types()) {
-if (type_sp && type_sp->GetName() == name) {
-  results.InsertUnique(type_sp);
-  if (results.Done(match))
-return;
-}
+if (!type_sp)
+  continue;
+auto type_name =
+match.GetSearchByMangledName()
+? type_sp->GetForwardCompilerType().GetMangledTypeName()
+: type_sp->GetName();
+if (type_name != name)
+  continue;
+results.InsertUnique(type_sp);
+if (results.Done(match))
+  return;
   }
 }
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index e5b8eee8d08c24..704c8d64dbfb2f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2758,6 +2758,15 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
 return true; // Keep iterating over index types, language mismatch.
 }
 
+// Since mangled names are unique, we only need to check if the names are
+// the same.
+if (query.GetSearchByMangledName()) {
+  if (die.GetMangledName() == query.GetTypeBasename().GetStringRef())
+if (Type *matching_type = ResolveType(die, true, true))
+  results.InsertUnique(matching_type->shared_from_this());
+  return !results.Done(query); // Keep iterating if we aren't done.
+}
+
 // Check the context matches
 std::vector die_context;
 if (query.GetModuleSearch())
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp 
b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 7fded6a31a3af5..b55518a136c997 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -1735,7 +1735,10 @@ void SymbolFileNativePDB::FindTypes(const 
lldb_private::TypeQuery &query,
   continue;
 
 // We resolved a type. Get the fully qualified name to ensure it matches.
-ConstString name = type_sp->GetQualifiedName();
+ConstString name =
+query.GetSearchByMangledName()
+? type_sp->GetForwardCompilerType().GetMangledTypeName()
+: type_sp->GetQualifiedName();
 TypeQuery type_match(name.GetStringRef(), TypeQueryOptions::e_exact_match);
 if (query.ContextMatches(type_match.GetContextRef())) {
   results.InsertUnique(type_sp);
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp 
b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index 4fc48b4d133382..0ea18d8f74baa3 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/sourc

[Lldb-commits] [lldb] [lldb] Add a compiler/interpreter of LLDB data formatter bytecode to lldb/examples (PR #113398)

2024-10-22 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/113398

>From 3267f7a2001e769217e3192f6efb67fb77973339 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Tue, 22 Oct 2024 16:29:50 -0700
Subject: [PATCH] Add a compiler/interpreter of LLDB data formatter bytecode to
 examples

---
 lldb/examples/formatter-bytecode/Makefile |   8 +
 lldb/examples/formatter-bytecode/compiler.py  | 486 ++
 .../formatter-bytecode/formatter-bytecode.md  | 165 ++
 .../formatter-bytecode/test/MyOptional.cpp|  23 +
 .../formatter-bytecode/test/formatter.py  | 131 +
 5 files changed, 813 insertions(+)
 create mode 100644 lldb/examples/formatter-bytecode/Makefile
 create mode 100644 lldb/examples/formatter-bytecode/compiler.py
 create mode 100644 lldb/examples/formatter-bytecode/formatter-bytecode.md
 create mode 100644 lldb/examples/formatter-bytecode/test/MyOptional.cpp
 create mode 100644 lldb/examples/formatter-bytecode/test/formatter.py

diff --git a/lldb/examples/formatter-bytecode/Makefile 
b/lldb/examples/formatter-bytecode/Makefile
new file mode 100644
index 00..f544fea9d3f28d
--- /dev/null
+++ b/lldb/examples/formatter-bytecode/Makefile
@@ -0,0 +1,8 @@
+all: test
+
+.PHONY: test
+test:
+   python3 compiler.py
+   mkdir -p _test
+   clang++ -std=c++17 test/MyOptional.cpp -g -o _test/MyOptional
+   lldb _test/MyOptional -o "command script import test/formatter.py" -o 
"b -p here" -o "r" -o "v x" -o "v y" -o q
diff --git a/lldb/examples/formatter-bytecode/compiler.py 
b/lldb/examples/formatter-bytecode/compiler.py
new file mode 100644
index 00..b908ec8efdf5d8
--- /dev/null
+++ b/lldb/examples/formatter-bytecode/compiler.py
@@ -0,0 +1,486 @@
+"""
+Specification, compiler, disassembler, and interpreter
+for LLDB dataformatter bytecode.
+
+See formatter-bytecode.md for more details.
+"""
+from __future__ import annotations
+
+# Types
+type_String = 1
+type_Int = 2
+type_UInt = 3
+type_Object = 4
+type_Type = 5
+
+# Opcodes
+opcode = dict()
+
+
+def define_opcode(n, mnemonic, name):
+globals()["op_" + name] = n
+if mnemonic:
+opcode[mnemonic] = n
+opcode[n] = mnemonic
+
+
+define_opcode(1, "dup", "dup")
+define_opcode(2, "drop", "drop")
+define_opcode(3, "pick", "pick")
+define_opcode(4, "over", "over")
+define_opcode(5, "swap", "swap")
+define_opcode(6, "rot", "rot")
+
+define_opcode(0x10, "{", "begin")
+define_opcode(0x11, "if", "if")
+define_opcode(0x12, "ifelse", "ifelse")
+
+define_opcode(0x20, None, "lit_uint")
+define_opcode(0x21, None, "lit_int")
+define_opcode(0x22, None, "lit_string")
+define_opcode(0x23, None, "lit_selector")
+
+define_opcode(0x30, "+", "plus")
+define_opcode(0x31, "-", "minus")
+define_opcode(0x32, "*", "mul")
+define_opcode(0x33, "/", "div")
+define_opcode(0x34, "%", "mod")
+define_opcode(0x35, "<<", "shl")
+define_opcode(0x36, ">>", "shr")
+define_opcode(0x37, "shra", "shra")
+
+define_opcode(0x40, "&", "and")
+define_opcode(0x41, "|", "or")
+define_opcode(0x42, "^", "xor")
+define_opcode(0x43, "~", "not")
+
+define_opcode(0x50, "=", "eq")
+define_opcode(0x51, "!=", "neq")
+define_opcode(0x52, "<", "lt")
+define_opcode(0x53, ">", "gt")
+define_opcode(0x54, "=<", "le")
+define_opcode(0x55, ">=", "ge")
+
+define_opcode(0x60, "call", "call")
+
+# Function signatures
+sig_summary = 0
+sig_init = 1
+sig_get_num_children = 2
+sig_get_child_index = 3
+sig_get_child_at_index = 4
+
+# Selectors
+selector = dict()
+
+
+def define_selector(n, name):
+globals()["sel_" + name] = n
+selector["@" + name] = n
+selector[n] = "@" + name
+
+
+define_selector(0, "summary")
+define_selector(1, "type_summary")
+
+define_selector(0x10, "get_num_children")
+define_selector(0x11, "get_child_at_index")
+define_selector(0x12, "get_child_with_name")
+define_selector(0x13, "get_child_index")
+define_selector(0x15, "get_type")
+define_selector(0x16, "get_template_argument_type")
+define_selector(0x20, "get_value")
+define_selector(0x21, "get_value_as_unsigned")
+define_selector(0x22, "get_value_as_signed")
+define_selector(0x23, "get_value_as_address")
+define_selector(0x24, "cast")
+
+define_selector(0x40, "read_memory_byte")
+define_selector(0x41, "read_memory_uint32")
+define_selector(0x42, "read_memory_int32")
+define_selector(0x43, "read_memory_unsigned")
+define_selector(0x44, "read_memory_signed")
+define_selector(0x45, "read_memory_address")
+define_selector(0x46, "read_memory")
+
+define_selector(0x50, "fmt")
+define_selector(0x51, "sprintf")
+define_selector(0x52, "strlen")
+
+
+
+# Compiler.
+
+
+
+def compile(assembler: str) -> bytearray:
+"""Compile assembler into bytecode"""
+# This is a stack of all in-flight/unterminated blocks.
+bytecode = [bytearray()]
+
+def emit(byte):
+bytecode[-1].appe

[Lldb-commits] [lldb] [lldb] Add a compiler/interpreter of LLDB data formatter bytecode to lldb/examples (PR #113398)

2024-10-22 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add a compiler/interpreter of LLDB data formatter bytecode to lldb/examples (PR #113398)

2024-10-22 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/113398

>From c4360a6979a38f7e9a11edc07f02d8b3ac5bd2aa Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Tue, 22 Oct 2024 16:29:50 -0700
Subject: [PATCH] Add a compiler/interpreter of LLDB data formatter bytecode to
 examples

---
 lldb/examples/formatter-bytecode/Makefile |   8 +
 lldb/examples/formatter-bytecode/compiler.py  | 486 ++
 .../formatter-bytecode/formatter-bytecode.md  | 165 ++
 .../formatter-bytecode/test/MyOptional.cpp|  23 +
 .../formatter-bytecode/test/formatter.py  | 131 +
 5 files changed, 813 insertions(+)
 create mode 100644 lldb/examples/formatter-bytecode/Makefile
 create mode 100644 lldb/examples/formatter-bytecode/compiler.py
 create mode 100644 lldb/examples/formatter-bytecode/formatter-bytecode.md
 create mode 100644 lldb/examples/formatter-bytecode/test/MyOptional.cpp
 create mode 100644 lldb/examples/formatter-bytecode/test/formatter.py

diff --git a/lldb/examples/formatter-bytecode/Makefile 
b/lldb/examples/formatter-bytecode/Makefile
new file mode 100644
index 00..f544fea9d3f28d
--- /dev/null
+++ b/lldb/examples/formatter-bytecode/Makefile
@@ -0,0 +1,8 @@
+all: test
+
+.PHONY: test
+test:
+   python3 compiler.py
+   mkdir -p _test
+   clang++ -std=c++17 test/MyOptional.cpp -g -o _test/MyOptional
+   lldb _test/MyOptional -o "command script import test/formatter.py" -o 
"b -p here" -o "r" -o "v x" -o "v y" -o q
diff --git a/lldb/examples/formatter-bytecode/compiler.py 
b/lldb/examples/formatter-bytecode/compiler.py
new file mode 100644
index 00..b908ec8efdf5d8
--- /dev/null
+++ b/lldb/examples/formatter-bytecode/compiler.py
@@ -0,0 +1,486 @@
+"""
+Specification, compiler, disassembler, and interpreter
+for LLDB dataformatter bytecode.
+
+See formatter-bytecode.md for more details.
+"""
+from __future__ import annotations
+
+# Types
+type_String = 1
+type_Int = 2
+type_UInt = 3
+type_Object = 4
+type_Type = 5
+
+# Opcodes
+opcode = dict()
+
+
+def define_opcode(n, mnemonic, name):
+globals()["op_" + name] = n
+if mnemonic:
+opcode[mnemonic] = n
+opcode[n] = mnemonic
+
+
+define_opcode(1, "dup", "dup")
+define_opcode(2, "drop", "drop")
+define_opcode(3, "pick", "pick")
+define_opcode(4, "over", "over")
+define_opcode(5, "swap", "swap")
+define_opcode(6, "rot", "rot")
+
+define_opcode(0x10, "{", "begin")
+define_opcode(0x11, "if", "if")
+define_opcode(0x12, "ifelse", "ifelse")
+
+define_opcode(0x20, None, "lit_uint")
+define_opcode(0x21, None, "lit_int")
+define_opcode(0x22, None, "lit_string")
+define_opcode(0x23, None, "lit_selector")
+
+define_opcode(0x30, "+", "plus")
+define_opcode(0x31, "-", "minus")
+define_opcode(0x32, "*", "mul")
+define_opcode(0x33, "/", "div")
+define_opcode(0x34, "%", "mod")
+define_opcode(0x35, "<<", "shl")
+define_opcode(0x36, ">>", "shr")
+define_opcode(0x37, "shra", "shra")
+
+define_opcode(0x40, "&", "and")
+define_opcode(0x41, "|", "or")
+define_opcode(0x42, "^", "xor")
+define_opcode(0x43, "~", "not")
+
+define_opcode(0x50, "=", "eq")
+define_opcode(0x51, "!=", "neq")
+define_opcode(0x52, "<", "lt")
+define_opcode(0x53, ">", "gt")
+define_opcode(0x54, "=<", "le")
+define_opcode(0x55, ">=", "ge")
+
+define_opcode(0x60, "call", "call")
+
+# Function signatures
+sig_summary = 0
+sig_init = 1
+sig_get_num_children = 2
+sig_get_child_index = 3
+sig_get_child_at_index = 4
+
+# Selectors
+selector = dict()
+
+
+def define_selector(n, name):
+globals()["sel_" + name] = n
+selector["@" + name] = n
+selector[n] = "@" + name
+
+
+define_selector(0, "summary")
+define_selector(1, "type_summary")
+
+define_selector(0x10, "get_num_children")
+define_selector(0x11, "get_child_at_index")
+define_selector(0x12, "get_child_with_name")
+define_selector(0x13, "get_child_index")
+define_selector(0x15, "get_type")
+define_selector(0x16, "get_template_argument_type")
+define_selector(0x20, "get_value")
+define_selector(0x21, "get_value_as_unsigned")
+define_selector(0x22, "get_value_as_signed")
+define_selector(0x23, "get_value_as_address")
+define_selector(0x24, "cast")
+
+define_selector(0x40, "read_memory_byte")
+define_selector(0x41, "read_memory_uint32")
+define_selector(0x42, "read_memory_int32")
+define_selector(0x43, "read_memory_unsigned")
+define_selector(0x44, "read_memory_signed")
+define_selector(0x45, "read_memory_address")
+define_selector(0x46, "read_memory")
+
+define_selector(0x50, "fmt")
+define_selector(0x51, "sprintf")
+define_selector(0x52, "strlen")
+
+
+
+# Compiler.
+
+
+
+def compile(assembler: str) -> bytearray:
+"""Compile assembler into bytecode"""
+# This is a stack of all in-flight/unterminated blocks.
+bytecode = [bytearray()]
+
+def emit(byte):
+bytecode[-1].appe

[Lldb-commits] [lldb] [lldb] Add a compiler/interpreter of LLDB data formatter bytecode to lldb/examples (PR #113398)

2024-10-22 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl created 
https://github.com/llvm/llvm-project/pull/113398

This PR adds a proof-of-concept for a bytecode designed to ship and run LLDB 
data formatters. More motivation and context can be found in the 
`formatter-bytecode.md` file and on discourse.

>From 642525847da7d874a127f94f155fd738e3d78196 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Tue, 22 Oct 2024 16:29:50 -0700
Subject: [PATCH] Add a compiler/interpreter of LLDB data formatter bytecode to
 examples

---
 lldb/examples/formatter-bytecode/Makefile |   8 +
 lldb/examples/formatter-bytecode/compiler.py  | 437 ++
 .../formatter-bytecode/formatter-bytecode.md  | 165 +++
 .../formatter-bytecode/test/MyOptional.cpp|  23 +
 .../formatter-bytecode/test/formatter.py  | 120 +
 5 files changed, 753 insertions(+)
 create mode 100644 lldb/examples/formatter-bytecode/Makefile
 create mode 100644 lldb/examples/formatter-bytecode/compiler.py
 create mode 100644 lldb/examples/formatter-bytecode/formatter-bytecode.md
 create mode 100644 lldb/examples/formatter-bytecode/test/MyOptional.cpp
 create mode 100644 lldb/examples/formatter-bytecode/test/formatter.py

diff --git a/lldb/examples/formatter-bytecode/Makefile 
b/lldb/examples/formatter-bytecode/Makefile
new file mode 100644
index 00..f544fea9d3f28d
--- /dev/null
+++ b/lldb/examples/formatter-bytecode/Makefile
@@ -0,0 +1,8 @@
+all: test
+
+.PHONY: test
+test:
+   python3 compiler.py
+   mkdir -p _test
+   clang++ -std=c++17 test/MyOptional.cpp -g -o _test/MyOptional
+   lldb _test/MyOptional -o "command script import test/formatter.py" -o 
"b -p here" -o "r" -o "v x" -o "v y" -o q
diff --git a/lldb/examples/formatter-bytecode/compiler.py 
b/lldb/examples/formatter-bytecode/compiler.py
new file mode 100644
index 00..7bbaae78ab4be1
--- /dev/null
+++ b/lldb/examples/formatter-bytecode/compiler.py
@@ -0,0 +1,437 @@
+"""
+Specification, compiler, disassembler, and interpreter
+for LLDB dataformatter bytecode.
+
+See formatter-bytecode.md for more details.
+"""
+from __future__ import annotations
+
+# Types
+type_String = 1
+type_Int = 2
+type_UInt = 3
+type_Object = 4
+type_Type = 5
+
+# Opcodes
+opcode = dict()
+def define_opcode(n, mnemonic, name):
+globals()['op_'+name] = n
+if mnemonic:
+opcode[mnemonic] = n
+opcode[n] = mnemonic
+
+define_opcode(1, 'dup', 'dup')
+define_opcode(2, 'drop', 'drop')
+define_opcode(3, 'pick', 'pick')
+define_opcode(4, 'over', 'over')
+define_opcode(5, 'swap', 'swap')
+define_opcode(6, 'rot', 'rot')
+
+define_opcode(0x10, '{', 'begin')
+define_opcode(0x11, 'if', 'if')
+define_opcode(0x12, 'ifelse', 'ifelse')
+
+define_opcode(0x20, None, 'lit_uint')
+define_opcode(0x21, None, 'lit_int')
+define_opcode(0x22, None, 'lit_string')
+define_opcode(0x23, None, 'lit_selector')
+
+define_opcode(0x30, '+', 'plus')
+define_opcode(0x31, '-', 'minus')
+define_opcode(0x32, '*', 'mul')
+define_opcode(0x33, '/', 'div')
+define_opcode(0x34, '%', 'mod')
+define_opcode(0x35, '<<', 'shl')
+define_opcode(0x36, '>>', 'shr')
+define_opcode(0x37, 'shra', 'shra')
+
+define_opcode(0x40, '&', 'and')
+define_opcode(0x41, '|', 'or')
+define_opcode(0x42, '^', 'xor')
+define_opcode(0x43, '~', 'not')
+
+define_opcode(0x50, '=', 'eq')
+define_opcode(0x51, '!=', 'neq')
+define_opcode(0x52, '<', 'lt')
+define_opcode(0x53, '>', 'gt')
+define_opcode(0x54, '=<', 'le')
+define_opcode(0x55, '>=', 'ge')
+
+define_opcode(0x60, 'call', 'call')
+
+# Function signatures
+sig_summary = 0
+sig_init = 1
+sig_get_num_children = 2
+sig_get_child_index = 3
+sig_get_child_at_index = 4
+
+# Selectors
+selector = dict()
+def define_selector(n, name):
+globals()['sel_'+name] = n
+selector['@'+name] = n
+selector[n] = '@'+name
+
+define_selector(0, 'summary')
+define_selector(1, 'type_summary')
+
+define_selector(0x10, 'get_num_children')
+define_selector(0x11, 'get_child_at_index')
+define_selector(0x12, 'get_child_with_name')
+define_selector(0x13, 'get_child_index')
+define_selector(0x15, 'get_type')
+define_selector(0x16, 'get_template_argument_type')
+define_selector(0x20, 'get_value')
+define_selector(0x21, 'get_value_as_unsigned')
+define_selector(0x22, 'get_value_as_signed')
+define_selector(0x23, 'get_value_as_address')
+define_selector(0x24, 'cast')
+
+define_selector(0x40, 'read_memory_byte')
+define_selector(0x41, 'read_memory_uint32')
+define_selector(0x42, 'read_memory_int32')
+define_selector(0x43, 'read_memory_unsigned')
+define_selector(0x44, 'read_memory_signed')
+define_selector(0x45, 'read_memory_address')
+define_selector(0x46, 'read_memory')
+
+define_selector(0x50, 'fmt')
+define_selector(0x51, 'sprintf')
+define_selector(0x52, 'strlen')
+
+
+
+# Compiler.
+
+
+def compile(assembler: str) -> bytearray:
+"""Comp

[Lldb-commits] [lldb] [lldb] Add a compiler/interpreter of LLDB data formatter bytecode to lldb/examples (PR #113398)

2024-10-22 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)


Changes

This PR adds a proof-of-concept for a bytecode designed to ship and run LLDB 
data formatters. More motivation and context can be found in the 
`formatter-bytecode.md` file and on discourse.

---

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


5 Files Affected:

- (added) lldb/examples/formatter-bytecode/Makefile (+8) 
- (added) lldb/examples/formatter-bytecode/compiler.py (+437) 
- (added) lldb/examples/formatter-bytecode/formatter-bytecode.md (+165) 
- (added) lldb/examples/formatter-bytecode/test/MyOptional.cpp (+23) 
- (added) lldb/examples/formatter-bytecode/test/formatter.py (+120) 


``diff
diff --git a/lldb/examples/formatter-bytecode/Makefile 
b/lldb/examples/formatter-bytecode/Makefile
new file mode 100644
index 00..f544fea9d3f28d
--- /dev/null
+++ b/lldb/examples/formatter-bytecode/Makefile
@@ -0,0 +1,8 @@
+all: test
+
+.PHONY: test
+test:
+   python3 compiler.py
+   mkdir -p _test
+   clang++ -std=c++17 test/MyOptional.cpp -g -o _test/MyOptional
+   lldb _test/MyOptional -o "command script import test/formatter.py" -o 
"b -p here" -o "r" -o "v x" -o "v y" -o q
diff --git a/lldb/examples/formatter-bytecode/compiler.py 
b/lldb/examples/formatter-bytecode/compiler.py
new file mode 100644
index 00..7bbaae78ab4be1
--- /dev/null
+++ b/lldb/examples/formatter-bytecode/compiler.py
@@ -0,0 +1,437 @@
+"""
+Specification, compiler, disassembler, and interpreter
+for LLDB dataformatter bytecode.
+
+See formatter-bytecode.md for more details.
+"""
+from __future__ import annotations
+
+# Types
+type_String = 1
+type_Int = 2
+type_UInt = 3
+type_Object = 4
+type_Type = 5
+
+# Opcodes
+opcode = dict()
+def define_opcode(n, mnemonic, name):
+globals()['op_'+name] = n
+if mnemonic:
+opcode[mnemonic] = n
+opcode[n] = mnemonic
+
+define_opcode(1, 'dup', 'dup')
+define_opcode(2, 'drop', 'drop')
+define_opcode(3, 'pick', 'pick')
+define_opcode(4, 'over', 'over')
+define_opcode(5, 'swap', 'swap')
+define_opcode(6, 'rot', 'rot')
+
+define_opcode(0x10, '{', 'begin')
+define_opcode(0x11, 'if', 'if')
+define_opcode(0x12, 'ifelse', 'ifelse')
+
+define_opcode(0x20, None, 'lit_uint')
+define_opcode(0x21, None, 'lit_int')
+define_opcode(0x22, None, 'lit_string')
+define_opcode(0x23, None, 'lit_selector')
+
+define_opcode(0x30, '+', 'plus')
+define_opcode(0x31, '-', 'minus')
+define_opcode(0x32, '*', 'mul')
+define_opcode(0x33, '/', 'div')
+define_opcode(0x34, '%', 'mod')
+define_opcode(0x35, '<<', 'shl')
+define_opcode(0x36, '>>', 'shr')
+define_opcode(0x37, 'shra', 'shra')
+
+define_opcode(0x40, '&', 'and')
+define_opcode(0x41, '|', 'or')
+define_opcode(0x42, '^', 'xor')
+define_opcode(0x43, '~', 'not')
+
+define_opcode(0x50, '=', 'eq')
+define_opcode(0x51, '!=', 'neq')
+define_opcode(0x52, '<', 'lt')
+define_opcode(0x53, '>', 'gt')
+define_opcode(0x54, '=<', 'le')
+define_opcode(0x55, '>=', 'ge')
+
+define_opcode(0x60, 'call', 'call')
+
+# Function signatures
+sig_summary = 0
+sig_init = 1
+sig_get_num_children = 2
+sig_get_child_index = 3
+sig_get_child_at_index = 4
+
+# Selectors
+selector = dict()
+def define_selector(n, name):
+globals()['sel_'+name] = n
+selector['@'+name] = n
+selector[n] = '@'+name
+
+define_selector(0, 'summary')
+define_selector(1, 'type_summary')
+
+define_selector(0x10, 'get_num_children')
+define_selector(0x11, 'get_child_at_index')
+define_selector(0x12, 'get_child_with_name')
+define_selector(0x13, 'get_child_index')
+define_selector(0x15, 'get_type')
+define_selector(0x16, 'get_template_argument_type')
+define_selector(0x20, 'get_value')
+define_selector(0x21, 'get_value_as_unsigned')
+define_selector(0x22, 'get_value_as_signed')
+define_selector(0x23, 'get_value_as_address')
+define_selector(0x24, 'cast')
+
+define_selector(0x40, 'read_memory_byte')
+define_selector(0x41, 'read_memory_uint32')
+define_selector(0x42, 'read_memory_int32')
+define_selector(0x43, 'read_memory_unsigned')
+define_selector(0x44, 'read_memory_signed')
+define_selector(0x45, 'read_memory_address')
+define_selector(0x46, 'read_memory')
+
+define_selector(0x50, 'fmt')
+define_selector(0x51, 'sprintf')
+define_selector(0x52, 'strlen')
+
+
+
+# Compiler.
+
+
+def compile(assembler: str) -> bytearray:
+"""Compile assembler into bytecode"""
+# This is a stack of all in-flight/unterminated blocks.
+bytecode = [bytearray()]
+
+def emit(byte):
+bytecode[-1].append(byte)
+
+tokens = list(assembler.split(' '))
+tokens.reverse()
+while tokens:
+tok = tokens.pop()
+if tok == '': pass
+elif tok == '{': bytecode.append(bytearray())
+elif tok == '}':
+  

[Lldb-commits] [lldb] [lldb] Move ValueObject into its own library (NFC) (PR #113393)

2024-10-22 Thread via lldb-commits

cmtice wrote:

It appears that in  all the .h files that you moved from Core to ValueObject, 
you did not update the ifdef variable at the top of the file? I would have 
expected, e.g. that "LLDB_CORE_VALUEOBJECT_H"  should be changed to 
"LLDB_VALUEOBJECT_VALUEOBJECT_H". Shouldn't it?

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


[Lldb-commits] [lldb] [lldb] Move ValueObject into its own library (NFC) (PR #113393)

2024-10-22 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> It appears that in all the .h files that you moved from Core to ValueObject, 
> you did not update the ifdef variable at the top of the file? I would have 
> expected, e.g. that "LLDB_CORE_VALUEOBJECT_H" should be changed to 
> "LLDB_VALUEOBJECT_VALUEOBJECT_H". Shouldn't it?

Good point, I forgot the header guards. Fixed. 

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


[Lldb-commits] [lldb] [lldb] Add a compiler/interpreter of LLDB data formatter bytecode to lldb/examples (PR #113398)

2024-10-22 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
2e0506f83bfde6db93454bdf28e4a71c160d4f5b...642525847da7d874a127f94f155fd738e3d78196
 lldb/examples/formatter-bytecode/compiler.py 
lldb/examples/formatter-bytecode/test/formatter.py
``





View the diff from darker here.


``diff
--- compiler.py 2024-10-22 23:29:50.00 +
+++ compiler.py 2024-10-22 23:43:37.694386 +
@@ -13,171 +13,183 @@
 type_Object = 4
 type_Type = 5
 
 # Opcodes
 opcode = dict()
+
+
 def define_opcode(n, mnemonic, name):
-globals()['op_'+name] = n
+globals()["op_" + name] = n
 if mnemonic:
 opcode[mnemonic] = n
 opcode[n] = mnemonic
 
-define_opcode(1, 'dup', 'dup')
-define_opcode(2, 'drop', 'drop')
-define_opcode(3, 'pick', 'pick')
-define_opcode(4, 'over', 'over')
-define_opcode(5, 'swap', 'swap')
-define_opcode(6, 'rot', 'rot')
-
-define_opcode(0x10, '{', 'begin')
-define_opcode(0x11, 'if', 'if')
-define_opcode(0x12, 'ifelse', 'ifelse')
-
-define_opcode(0x20, None, 'lit_uint')
-define_opcode(0x21, None, 'lit_int')
-define_opcode(0x22, None, 'lit_string')
-define_opcode(0x23, None, 'lit_selector')
-
-define_opcode(0x30, '+', 'plus')
-define_opcode(0x31, '-', 'minus')
-define_opcode(0x32, '*', 'mul')
-define_opcode(0x33, '/', 'div')
-define_opcode(0x34, '%', 'mod')
-define_opcode(0x35, '<<', 'shl')
-define_opcode(0x36, '>>', 'shr')
-define_opcode(0x37, 'shra', 'shra')
-
-define_opcode(0x40, '&', 'and')
-define_opcode(0x41, '|', 'or')
-define_opcode(0x42, '^', 'xor')
-define_opcode(0x43, '~', 'not')
-
-define_opcode(0x50, '=', 'eq')
-define_opcode(0x51, '!=', 'neq')
-define_opcode(0x52, '<', 'lt')
-define_opcode(0x53, '>', 'gt')
-define_opcode(0x54, '=<', 'le')
-define_opcode(0x55, '>=', 'ge')
-
-define_opcode(0x60, 'call', 'call')
+
+define_opcode(1, "dup", "dup")
+define_opcode(2, "drop", "drop")
+define_opcode(3, "pick", "pick")
+define_opcode(4, "over", "over")
+define_opcode(5, "swap", "swap")
+define_opcode(6, "rot", "rot")
+
+define_opcode(0x10, "{", "begin")
+define_opcode(0x11, "if", "if")
+define_opcode(0x12, "ifelse", "ifelse")
+
+define_opcode(0x20, None, "lit_uint")
+define_opcode(0x21, None, "lit_int")
+define_opcode(0x22, None, "lit_string")
+define_opcode(0x23, None, "lit_selector")
+
+define_opcode(0x30, "+", "plus")
+define_opcode(0x31, "-", "minus")
+define_opcode(0x32, "*", "mul")
+define_opcode(0x33, "/", "div")
+define_opcode(0x34, "%", "mod")
+define_opcode(0x35, "<<", "shl")
+define_opcode(0x36, ">>", "shr")
+define_opcode(0x37, "shra", "shra")
+
+define_opcode(0x40, "&", "and")
+define_opcode(0x41, "|", "or")
+define_opcode(0x42, "^", "xor")
+define_opcode(0x43, "~", "not")
+
+define_opcode(0x50, "=", "eq")
+define_opcode(0x51, "!=", "neq")
+define_opcode(0x52, "<", "lt")
+define_opcode(0x53, ">", "gt")
+define_opcode(0x54, "=<", "le")
+define_opcode(0x55, ">=", "ge")
+
+define_opcode(0x60, "call", "call")
 
 # Function signatures
 sig_summary = 0
 sig_init = 1
 sig_get_num_children = 2
 sig_get_child_index = 3
 sig_get_child_at_index = 4
 
 # Selectors
 selector = dict()
+
+
 def define_selector(n, name):
-globals()['sel_'+name] = n
-selector['@'+name] = n
-selector[n] = '@'+name
-
-define_selector(0, 'summary')
-define_selector(1, 'type_summary')
-
-define_selector(0x10, 'get_num_children')
-define_selector(0x11, 'get_child_at_index')
-define_selector(0x12, 'get_child_with_name')
-define_selector(0x13, 'get_child_index')
-define_selector(0x15, 'get_type')
-define_selector(0x16, 'get_template_argument_type')
-define_selector(0x20, 'get_value')
-define_selector(0x21, 'get_value_as_unsigned')
-define_selector(0x22, 'get_value_as_signed')
-define_selector(0x23, 'get_value_as_address')
-define_selector(0x24, 'cast')
-
-define_selector(0x40, 'read_memory_byte')
-define_selector(0x41, 'read_memory_uint32')
-define_selector(0x42, 'read_memory_int32')
-define_selector(0x43, 'read_memory_unsigned')
-define_selector(0x44, 'read_memory_signed')
-define_selector(0x45, 'read_memory_address')
-define_selector(0x46, 'read_memory')
-
-define_selector(0x50, 'fmt')
-define_selector(0x51, 'sprintf')
-define_selector(0x52, 'strlen')
+globals()["sel_" + name] = n
+selector["@" + name] = n
+selector[n] = "@" + name
+
+
+define_selector(0, "summary")
+define_selector(1, "type_summary")
+
+define_selector(0x10, "get_num_children")
+define_selector(0x11, "get_child_at_index")
+define_selector(0x12, "get_child_with_name")
+define_selector(0x13, "get_child_index")
+define_selector(0x15, "get_type")
+define_selector(0x16, "get_template_argument_type")
+define_selector(0x20, "get_value")
+define_selector(0x21, "get_value_as_unsigned")
+define_selector(0x22, "get_value_as_signed")
+define_selector(0x23, "get_value_as_address")
+define_selector(0x24, "cast")
+
+define_selector(0x40, "read_memory_byte")
+define_se

[Lldb-commits] [lldb] [lldb] Add a compiler/interpreter of LLDB data formatter bytecode to lldb/examples (PR #113398)

2024-10-22 Thread via lldb-commits

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 2e0506f83bfde6db93454bdf28e4a71c160d4f5b 
642525847da7d874a127f94f155fd738e3d78196 --extensions cpp -- 
lldb/examples/formatter-bytecode/test/MyOptional.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/examples/formatter-bytecode/test/MyOptional.cpp 
b/lldb/examples/formatter-bytecode/test/MyOptional.cpp
index 54fe7f5ccb..abba34439d 100644
--- a/lldb/examples/formatter-bytecode/test/MyOptional.cpp
+++ b/lldb/examples/formatter-bytecode/test/MyOptional.cpp
@@ -1,22 +1,22 @@
 // A bare-bones llvm::Optional reimplementation.
 
-template struct MyOptionalStorage {
+template  struct MyOptionalStorage {
   MyOptionalStorage(T val) : value(val), hasVal(true) {}
   MyOptionalStorage() {}
   T value;
   bool hasVal = false;
 };
 
-template struct MyOptional {
+template  struct MyOptional {
   MyOptionalStorage Storage;
   MyOptional(T val) : Storage(val) {}
   MyOptional() {}
-  T& operator*() { return Storage.value; }
+  T &operator*() { return Storage.value; }
 };
 
 void stop() {}
 
-int main(int argc, char** argv) {
+int main(int argc, char **argv) {
   MyOptional x, y = 42;
   stop(); // break here
   return *y;

``




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


[Lldb-commits] [lldb] [lldb] Move ValueObject into its own library (NFC) (PR #113393)

2024-10-22 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Pavel Labath via lldb-commits
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 



@@ -0,0 +1,46 @@
+// Itanium ABI:
+// RUN: %clang --target=x86_64-pc-linux -gdwarf -c -o %t_linux.o %s
+// RUN: %lldb -f %t_linux.o -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 
mp8 mp9" | FileCheck %s
+//
+// CHECK: (char SI2::*) mp9 = 0x
+
+// Microsoft ABI:
+// RUN: %clang_cl --target=x86_64-windows-msvc -c -gdwarf %s -o %t_win.obj
+// RUN: lld-link /out:%t_win.exe %t_win.obj /nodefaultlib /entry:main /debug
+// RUN: %lldb -f %t_win.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 
mp8 mp9" | FileCheck --check-prefix=CHECK-MSVC %s
+//
+// DWARF has no representation of MSInheritanceAttr, so we cannot determine 
the size
+// of member-pointers yet. For the moment, make sure we don't crash on such 
variables.
+// CHECK-MSVC: error: Unable to determine byte size.
+
+class SI {
+  double si;
+};
+struct SI2 {
+  char si2;
+};
+class MI : SI, SI2 {
+  int mi;
+};
+class MI2 : MI {
+  int mi2;
+};
+class VI : virtual MI {
+  int vi;
+};
+class VI2 : virtual SI, virtual SI2 {
+  int vi;
+};
+class /* __unspecified_inheritance*/ UI;
+
+double SI::*mp1 = nullptr;
+int MI::*mp2 = nullptr;
+int MI2::*mp3 = nullptr;
+int VI::*mp4 = nullptr;
+int VI2::*mp5 = nullptr;
+int UI::*mp6 = nullptr;
+int MI::*mp7 = nullptr;
+int VI2::*mp8 = nullptr;

labath wrote:

What's up with all of these? I think we should either CHECK their results or 
delete them.

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


[Lldb-commits] [lldb] [lldb][NFC] Make the target's SectionLoadList private. (PR #113278)

2024-10-22 Thread via lldb-commits

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

LGTM. Pending Jonas's comment and clang-format

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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Michael Buch via lldb-commits
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 



@@ -0,0 +1,48 @@
+// REQUIRES: lld
+
+// Microsoft ABI:
+// RUN: %clang_cl --target=x86_64-windows-msvc -c -gdwarf %s -o %t_win.obj
+// RUN: lld-link /out:%t_win.exe %t_win.obj /nodefaultlib /entry:main /debug
+// RUN: %lldb -f %t_win.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 
mp8 mp9"
+//
+// DWARF has no representation of MSInheritanceAttr, so we cannot determine 
the size
+// of member-pointers yet. For the moment, make sure we don't crash on such 
variables.
+
+// Itanium ABI:
+// RUN: %clang --target=x86_64-pc-linux -gdwarf -c -o %t_linux.o %s
+// RUN: ld.lld %t_linux.o -o %t_linux
+// RUN: %lldb -f %t_linux -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 
mp8 mp9" | FileCheck %s

Michael137 wrote:

Ah fair enough, latest test changes LGTM

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


[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-22 Thread Martin Storsjö via lldb-commits

mstorsjo wrote:

> The amount of churn is already pretty high -- please make sure the original 
> commit, fixes, and reverts get added to 
> https://github.com/llvm/llvm-project/blob/main/.git-blame-ignore-revs. At the 
> end of the day, we have a number of tests and files which are sensitive to 
> line endings and we have a lot of existing clones of the repo which have been 
> set up to work properly with the current setup, so this is a risky change.

FWIW, while I'm not a fan of checking things out with CRLF per se (or making 
`core.autocrlf` no longer have precedence), I totally don't mind fixing tests 
(or in most cases, adding some individual files to `.gitattributes` to mark 
them as needing to be checked out with LF newlines always), and I don't 
consider that part churn. We have a number of such files marked that way from 
before, but we clearly do need to add a few more.

But I haven't checked all the commits that have gone in to try to fix up tests 
that were failing due to CRLF - in case some of them really should be reverted 
once we're back to checking things out with LF.

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


[Lldb-commits] [lldb] cd4b33c - [lldb] Log errors to the system log if they would otherwise get dropped (#111911)

2024-10-22 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-10-22T09:00:08-07:00
New Revision: cd4b33c9a976543171bb7b3455c485f99cfe654b

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

LOG: [lldb] Log errors to the system log if they would otherwise get dropped 
(#111911)

Log errors to the (always-on) system log if they would otherwise get
dropped by LLDB_LOG_ERROR.

Added: 


Modified: 
lldb/include/lldb/Utility/Log.h
lldb/source/API/SystemInitializerFull.cpp
lldb/source/Utility/Log.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Log.h b/lldb/include/lldb/Utility/Log.h
index ac6347153a1014..1529178cb83b4b 100644
--- a/lldb/include/lldb/Utility/Log.h
+++ b/lldb/include/lldb/Utility/Log.h
@@ -335,6 +335,15 @@ template  Log *GetLog(Cat mask) {
   return LogChannelFor().GetLog(Log::MaskType(mask));
 }
 
+/// Getter and setter for the error log (see g_error_log).
+/// The error log is set to the system log in SystemInitializerFull. We can't
+/// use the system log directly because that would violate the layering between
+/// Utility and Host.
+/// @{
+void SetLLDBErrorLog(Log *log);
+Log *GetLLDBErrorLog();
+/// @}
+
 } // namespace lldb_private
 
 /// The LLDB_LOG* macros defined below are the way to emit log messages.
@@ -384,6 +393,8 @@ template  Log *GetLog(Cat mask) {
   do { 
\
 ::lldb_private::Log *log_private = (log);  
\
 ::llvm::Error error_private = (error); 
\
+if (!log_private)  
\
+  log_private = lldb_private::GetLLDBErrorLog();   
\
 if (log_private && error_private) {
\
   log_private->FormatError(::std::move(error_private), __FILE__, __func__, 
\
__VA_ARGS__);   
\

diff  --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index 8a992a6889a91b..31f3a9f30b81f0 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -84,6 +84,9 @@ llvm::Error SystemInitializerFull::Initialize() {
   // Use the Debugger's LLDBAssert callback.
   SetLLDBAssertCallback(Debugger::AssertCallback);
 
+  // Use the system log to report errors that would otherwise get dropped.
+  SetLLDBErrorLog(GetLog(SystemLog::System));
+
   LLDB_LOG(GetLog(SystemLog::System), "{0}", GetVersion());
 
   return llvm::Error::success();

diff  --git a/lldb/source/Utility/Log.cpp b/lldb/source/Utility/Log.cpp
index 3798f406476370..4c2c33aaafe008 100644
--- a/lldb/source/Utility/Log.cpp
+++ b/lldb/source/Utility/Log.cpp
@@ -43,6 +43,10 @@ char TeeLogHandler::ID;
 
 llvm::ManagedStatic Log::g_channel_map;
 
+// The error log is used by LLDB_LOG_ERROR. If the given log channel passed to
+// LLDB_LOG_ERROR is not enabled, error messages are logged to the error log.
+static std::atomic g_error_log = nullptr;
+
 void Log::ForEachCategory(
 const Log::ChannelMap::value_type &entry,
 llvm::function_ref lambda) {
@@ -460,3 +464,7 @@ void TeeLogHandler::Emit(llvm::StringRef message) {
   m_first_log_handler->Emit(message);
   m_second_log_handler->Emit(message);
 }
+
+void lldb_private::SetLLDBErrorLog(Log *log) { g_error_log.store(log); }
+
+Log *lldb_private::GetLLDBErrorLog() { return g_error_log; }



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Log errors to the system log if they would otherwise get dropped (PR #111911)

2024-10-22 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Log errors to the system log if they would otherwise get dropped (PR #111911)

2024-10-22 Thread Jonas Devlieghere via lldb-commits


@@ -43,6 +43,10 @@ char TeeLogHandler::ID;
 
 llvm::ManagedStatic Log::g_channel_map;
 
+// The error log is used by LLDB_LOG_ERROR and LLDB_LOG_ERRORV. If the given

JDevlieghere wrote:

Already fixed in the latest version of this PR :-) 

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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Zequan Wu via lldb-commits
Stefan =?utf-8?q?Gr=C3=A4nitz?= ,
Stefan =?utf-8?q?Gr=C3=A4nitz?= ,
Stefan =?utf-8?q?Gr=C3=A4nitz?= ,
Stefan =?utf-8?q?Gr=C3=A4nitz?= 
Message-ID:
In-Reply-To: 


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


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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #112079)

2024-10-22 Thread Robert O'Callahan via lldb-commits

https://github.com/rocallahan updated 
https://github.com/llvm/llvm-project/pull/112079

>From bb96e6ddd2d6448be01b1965591cf8ee77e14569 Mon Sep 17 00:00:00 2001
From: Robert O'Callahan 
Date: Fri, 19 Jul 2024 22:46:42 +1200
Subject: [PATCH] [lldb] Implement basic support for reverse-continue

This commit only adds support for the
`SBProcess::ReverseContinue()` API. A user-accessible command
for this will follow in a later commit.

This feature depends on a gdbserver implementation (e.g. `rr`)
providing support for the `bc` and `bs` packets. `lldb-server`
does not support those packets, and there is no plan to change that.
So, for testing purposes, `lldbreverse.py` wraps `lldb-server`
with a Python implementation of *very limited* record-and-replay
functionality.
---
 lldb/include/lldb/API/SBProcess.h |   1 +
 lldb/include/lldb/Target/Process.h|  23 +-
 lldb/include/lldb/Target/StopInfo.h   |   6 +
 lldb/include/lldb/lldb-enumerations.h |   6 +
 .../Python/lldbsuite/test/gdbclientutils.py   |   5 +-
 .../Python/lldbsuite/test/lldbgdbproxy.py | 178 +++
 .../Python/lldbsuite/test/lldbreverse.py  | 445 ++
 .../Python/lldbsuite/test/lldbtest.py |   2 +
 lldb/source/API/SBProcess.cpp |   8 +-
 lldb/source/API/SBThread.cpp  |   2 +
 .../source/Interpreter/CommandInterpreter.cpp |   3 +-
 .../Process/Linux/NativeThreadLinux.cpp   |   3 +
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  |   9 +-
 .../Process/MacOSX-Kernel/ProcessKDP.h|   2 +-
 .../Process/Windows/Common/ProcessWindows.cpp |   9 +-
 .../Process/Windows/Common/ProcessWindows.h   |   2 +-
 .../GDBRemoteCommunicationClient.cpp  |  22 +
 .../gdb-remote/GDBRemoteCommunicationClient.h |   6 +
 .../GDBRemoteCommunicationServerLLGS.cpp  |   1 +
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  88 +++-
 .../Process/gdb-remote/ProcessGDBRemote.h |   2 +-
 .../Process/scripted/ScriptedProcess.cpp  |  10 +-
 .../Process/scripted/ScriptedProcess.h|   2 +-
 lldb/source/Target/Process.cpp|  38 +-
 lldb/source/Target/StopInfo.cpp   |  29 ++
 lldb/source/Target/Thread.cpp |   8 +-
 .../reverse-execution/Makefile|   3 +
 .../TestReverseContinueBreakpoints.py | 123 +
 .../TestReverseContinueNotSupported.py|  30 ++
 .../functionalities/reverse-execution/main.c  |  14 +
 lldb/tools/lldb-dap/JSONUtils.cpp |   3 +
 lldb/tools/lldb-dap/LLDBUtils.cpp |   1 +
 32 files changed, 1034 insertions(+), 50 deletions(-)
 create mode 100644 lldb/packages/Python/lldbsuite/test/lldbgdbproxy.py
 create mode 100644 lldb/packages/Python/lldbsuite/test/lldbreverse.py
 create mode 100644 lldb/test/API/functionalities/reverse-execution/Makefile
 create mode 100644 
lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
 create mode 100644 
lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
 create mode 100644 lldb/test/API/functionalities/reverse-execution/main.c

diff --git a/lldb/include/lldb/API/SBProcess.h 
b/lldb/include/lldb/API/SBProcess.h
index 1624e02070b1b2..8b8ed830b54cc0 100644
--- a/lldb/include/lldb/API/SBProcess.h
+++ b/lldb/include/lldb/API/SBProcess.h
@@ -159,6 +159,7 @@ class LLDB_API SBProcess {
   lldb::SBError Destroy();
 
   lldb::SBError Continue();
+  lldb::SBError Continue(RunDirection direction);
 
   lldb::SBError Stop();
 
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index b8c53a474ba6b9..6efeb0d3694a6a 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -857,10 +857,11 @@ class Process : public 
std::enable_shared_from_this,
   /// \see Thread:Resume()
   /// \see Thread:Step()
   /// \see Thread:Suspend()
-  Status Resume();
+  Status Resume(lldb::RunDirection direction = lldb::eRunForward);
 
   /// Resume a process, and wait for it to stop.
-  Status ResumeSynchronous(Stream *stream);
+  Status ResumeSynchronous(Stream *stream,
+   lldb::RunDirection direction = lldb::eRunForward);
 
   /// Halts a running process.
   ///
@@ -1104,9 +1105,15 @@ class Process : public 
std::enable_shared_from_this,
   /// \see Thread:Resume()
   /// \see Thread:Step()
   /// \see Thread:Suspend()
-  virtual Status DoResume() {
-return Status::FromErrorStringWithFormatv(
-"error: {0} does not support resuming processes", GetPluginName());
+  virtual Status DoResume(lldb::RunDirection direction) {
+if (direction == lldb::RunDirection::eRunForward) {
+  return Status::FromErrorStringWithFormatv(
+  "error: {0} does not support resuming processes", GetPluginName());
+} else {
+  return Status::FromErrorStringWithFormatv(
+  "error: {0} does not support reverse execution of processes",
+  GetPluginName());
+}
   }
 
   

[Lldb-commits] [lldb] [lldb] Support DW_OP_WASM_location in DWARFExpression (PR #78977)

2024-10-22 Thread João Matos via lldb-commits

tritao wrote:

Given this was already approved, what's missing for the merge?

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


[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-22 Thread via lldb-commits

ldrumm wrote:

@AaronBallman you said this has happened before, but I don't see this in 
history. Can you link to the commit to which you're referring?

I only see one other commit (9783f28cb) that touches the root `.gitattributes`

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


[Lldb-commits] [lldb] [lldb][NFC] Make the target's SectionLoadList private. (PR #113278)

2024-10-22 Thread via lldb-commits

jimingham wrote:

This is just naming, but it seems odd to have hidden the SectionLoadList in 
Target, to then have Target::SectionLoadListIsEmpty() as a primary API.  "What 
is this SectionLoadList thing of which you speak???"

Maybe "HasLoadedSections"?

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


[Lldb-commits] [lldb] [lldb][NFC] Make the target's SectionLoadList private. (PR #113278)

2024-10-22 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere commented:

Protecting the section load list seems reasonable. I left one inline comment + 
this needs to be `clang-format`'ed. 

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


[Lldb-commits] [lldb] [lldb][NFC] Make the target's SectionLoadList private. (PR #113278)

2024-10-22 Thread Jonas Devlieghere via lldb-commits


@@ -5066,3 +5066,17 @@ llvm::json::Value
 Target::ReportStatistics(const lldb_private::StatisticsOptions &options) {
   return m_stats.ToJSON(*this, options);
 }
+
+bool Target::SectionLoadListIsEmpty() const {
+  return const_cast(this)->GetSectionLoadList().IsEmpty();

JDevlieghere wrote:

To avoid the `const_cast`, can we have a `const` `GetSectionLoadList` overload? 
`SectionLoadHistory::IsEmpty()` is already `const`. 

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


[Lldb-commits] [lldb] [lldb][NFC] Make the target's SectionLoadList private. (PR #113278)

2024-10-22 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Stefan Gränitz via lldb-commits

https://github.com/weliveindetail updated 
https://github.com/llvm/llvm-project/pull/112928

From bb66f56138cab9651aff4ac09096ede975c90701 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Fri, 18 Oct 2024 17:44:26 +0200
Subject: [PATCH 1/5] [lldb] Fix crash due to missing MSInheritanceAttr on
 CXXRecordDecl for DWARF on Windows

---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index fe0c53a7e9a3ea..a23dce97f3f299 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2771,6 +2771,9 @@ static bool GetCompleteQualType(clang::ASTContext *ast,
 ast, llvm::cast(qual_type)->getModifiedType(),
 allow_completion);
 
+  case clang::Type::MemberPointer:
+return !qual_type.getTypePtr()->isIncompleteType();
+
   default:
 break;
   }

From 6f775566a4face29f85286295aafb16c4367a917 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Tue, 22 Oct 2024 11:11:53 +0200
Subject: [PATCH 2/5] Add test based on
 https://reviews.llvm.org/D130942#change-1PvUCFvQjDIO

---
 .../Shell/SymbolFile/DWARF/x86/ms-abi.cpp | 45 +++
 1 file changed, 45 insertions(+)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp

diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
new file mode 100644
index 00..0e51ec99934f4c
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
@@ -0,0 +1,45 @@
+// REQUIRES: lld
+
+// Check that we don't crash on variables without MSInheritanceAttr
+
+// RUN: %clang -c --target=x86_64-windows-msvc -gdwarf %s -o %t.obj
+// RUN: lld-link /out:%t.exe %t.obj /nodefaultlib /entry:main /debug
+// RUN: %lldb -f %t.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 
mp9"
+
+class SI {
+  int si;
+};
+struct SI2 {
+  int si2;
+};
+class MI : SI, SI2 {
+  int mi;
+};
+class MI2 : MI {
+  int mi2;
+};
+class VI : virtual MI {
+  int vi;
+};
+class VI2 : virtual SI, virtual SI2 {
+  int vi;
+};
+class /* __unspecified_inheritance*/ UI;
+
+typedef void (SI::*SITYPE)();
+typedef void (MI::*MITYPE)();
+typedef void (MI2::*MI2TYPE)();
+typedef void (VI::*VITYPE)();
+typedef void (VI2::*VI2TYPE)();
+typedef void (UI::*UITYPE)();
+SITYPE mp1 = nullptr;
+MITYPE mp2 = nullptr;
+MI2TYPE mp3 = nullptr;
+VITYPE mp4 = nullptr;
+VI2TYPE mp5 = nullptr;
+UITYPE mp6 = nullptr;
+MITYPE *mp7 = nullptr;
+VI2TYPE *mp8 = nullptr;
+int SI::*mp9 = nullptr;
+
+int main() {}

From a892f5eba8e79dbc115cffb1eb26501cdef56f80 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Tue, 22 Oct 2024 15:27:33 +0200
Subject: [PATCH 3/5] Polish test and add coverage for Itanium

---
 .../SymbolFile/DWARF/x86/member-pointers.cpp  | 48 +++
 .../Shell/SymbolFile/DWARF/x86/ms-abi.cpp | 45 -
 2 files changed, 48 insertions(+), 45 deletions(-)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
 delete mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp

diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
new file mode 100644
index 00..93fa999416b74e
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
@@ -0,0 +1,48 @@
+// REQUIRES: lld
+
+// Microsoft ABI:
+// RUN: %clang_cl --target=x86_64-windows-msvc -c -gdwarf %s -o %t_win.obj
+// RUN: lld-link /out:%t_win.exe %t_win.obj /nodefaultlib /entry:main /debug
+// RUN: %lldb -f %t_win.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 
mp8 mp9"
+//
+// DWARF has no representation of MSInheritanceAttr, so we cannot determine 
the size
+// of member-pointers yet. For the moment, make sure we don't crash on such 
variables.
+
+// Itanium ABI:
+// RUN: %clang --target=x86_64-pc-linux -gdwarf -c -o %t_linux.o %s
+// RUN: ld.lld %t_linux.o -o %t_linux
+// RUN: %lldb -f %t_linux -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 
mp8 mp9" | FileCheck %s
+//
+// CHECK: (char SI2::*) mp9 = 0x
+
+class SI {
+  double si;
+};
+struct SI2 {
+  char si2;
+};
+class MI : SI, SI2 {
+  int mi;
+};
+class MI2 : MI {
+  int mi2;
+};
+class VI : virtual MI {
+  int vi;
+};
+class VI2 : virtual SI, virtual SI2 {
+  int vi;
+};
+class /* __unspecified_inheritance*/ UI;
+
+double SI::* mp1 = nullptr;
+int MI::* mp2 = nullptr;
+int MI2::* mp3 = nullptr;
+int VI::* mp4 = nullptr;
+int VI2::* mp5 = nullptr;
+int UI::* mp6 = nullptr;
+int MI::* mp7 = nullptr;
+int VI2::* mp8 = nullptr;
+char SI2::* mp9 = &SI2::si2;
+
+int main() { return 0; }
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
deleted file mode 100644

[Lldb-commits] [lldb] [lldb][NFC] Make the target's SectionLoadList private. (PR #113278)

2024-10-22 Thread via lldb-commits

jimingham wrote:

BTW, the general change seems fine to me, none of the clients actually needed 
to know about the list, they were just asking "can I use load addresses" and 
"resolve this load address for me" so they didn't need to know how that was 
done.

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


[Lldb-commits] [lldb] [lldb][test] Fix TestUseSourceCache for readonly source trees (PR #113251)

2024-10-22 Thread Igor Kudrin via lldb-commits

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

LGTM. Thanks!

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


[Lldb-commits] [lldb] [lldb] Log errors to the system log if they would otherwise get dropped (PR #111911)

2024-10-22 Thread Pavel Labath via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Log errors to the system log if they would otherwise get dropped (PR #111911)

2024-10-22 Thread Pavel Labath via lldb-commits


@@ -43,6 +43,10 @@ char TeeLogHandler::ID;
 
 llvm::ManagedStatic Log::g_channel_map;
 
+// The error log is used by LLDB_LOG_ERROR and LLDB_LOG_ERRORV. If the given

labath wrote:

```suggestion
// The error log is used by LLDB_LOG_ERROR. If the given
```

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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Stefan Gränitz via lldb-commits


@@ -0,0 +1,48 @@
+// REQUIRES: lld
+
+// Microsoft ABI:
+// RUN: %clang_cl --target=x86_64-windows-msvc -c -gdwarf %s -o %t_win.obj
+// RUN: lld-link /out:%t_win.exe %t_win.obj /nodefaultlib /entry:main /debug
+// RUN: %lldb -f %t_win.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 
mp8 mp9"
+//
+// DWARF has no representation of MSInheritanceAttr, so we cannot determine 
the size
+// of member-pointers yet. For the moment, make sure we don't crash on such 
variables.
+
+// Itanium ABI:
+// RUN: %clang --target=x86_64-pc-linux -gdwarf -c -o %t_linux.o %s
+// RUN: ld.lld %t_linux.o -o %t_linux
+// RUN: %lldb -f %t_linux -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 
mp8 mp9" | FileCheck %s

weliveindetail wrote:

Agree, added `CHECK-MSVC: error: Unable to determine byte size.` and dropped 
link-step for Itanium case. The latter doesn't seem to work for the MS case. It 
fails early with:
```
error: unable to resolve the module for file address 0x0 for variable 'mp1' in
S:\path\to\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\member-pointers.cpp.tmp_win.obj
```

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


[Lldb-commits] [lldb] 5942be0 - [lldb][test] Fix TestUseSourceCache for readonly source trees (#113251)

2024-10-22 Thread via lldb-commits

Author: Jordan Rupprecht
Date: 2024-10-22T10:34:15-05:00
New Revision: 5942be03eadc8abd320e3dad1abcc4e87ce4171a

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

LOG: [lldb][test] Fix TestUseSourceCache for readonly source trees (#113251)

TestUseSourceCache attempts to write to a build artifact copied from the
source tree, and asserts the write succeeded. If the source tree is read
only, the copy will also be read only, causing it to fail. When
producing the build artifact, ensure that it is writable.

Added: 


Modified: 
lldb/test/API/commands/settings/use_source_cache/Makefile

Removed: 




diff  --git a/lldb/test/API/commands/settings/use_source_cache/Makefile 
b/lldb/test/API/commands/settings/use_source_cache/Makefile
index 791cb7d868d87e..6c1c64fae074d1 100644
--- a/lldb/test/API/commands/settings/use_source_cache/Makefile
+++ b/lldb/test/API/commands/settings/use_source_cache/Makefile
@@ -6,3 +6,4 @@ include Makefile.rules
 # Copy file into the build folder to enable the test to modify it.
 main-copy.cpp: main.cpp
cp -f $< $@
+   chmod u+w $@



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test] Fix TestUseSourceCache for readonly source trees (PR #113251)

2024-10-22 Thread Jordan Rupprecht via lldb-commits

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


[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-22 Thread Martin Storsjö via lldb-commits

mstorsjo wrote:

> > > It's my understanding that text=auto does not override core.autocrlf. As 
> > > far as I can tell from the documentation it honours the user's 
> > > configuration for core.eol in combination with core.autocrlf - from git 
> > > config --help:
> 
> > This doesn't match my experience.
> 
> I think this is due to a subtly of config. Setting `core.autocrlf` to `false` 
> doesn't actually do anything since it's the default. 

It most definitely does something. Please have another look at 
https://github.com/mstorsjo/llvm-project/commit/inspect-newlines and the output 
of the log at 
https://github.com/mstorsjo/llvm-project/actions/runs/11407224268/job/31742748818.

First we do a checkout without setting anything. We get files with CRLF. Then 
we set `core.autocrlf` to `false`, which is the common way of dealing with 
this, then we do another checkout, and we get files with LF.

Do you dispute the above?

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


[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-22 Thread Martin Storsjö via lldb-commits

mstorsjo wrote:

> So if I've read that correctly, `core.autocrlf=false` is a red herring and 
> you should really set `core.eol=lf` if you want git to use `lf` on windows.

That perhaps may be the case, but all common docs and all common practices 
around this revolve around setting `core.autocrlf`, not setting `core.eol`. 
Before this discussion, I have never seen a guide recommending setting 
`core.eol`.

While so far, all docs related to this say that it is `core.autocrlf` one 
should set: 
https://github.com/llvm/llvm-project/blob/llvmorg-19.1.2/clang/www/get_started.html#L151-L154
 and 
https://github.com/llvm/llvm-project/blob/llvmorg-19.1.2/llvm/docs/GettingStarted.rst?plain=1#L37.

> > Would we get there by setting the wildcard rule in .gitattrubtes to * text 
> > eof=lf, or something along those lines?
> 
> This patch is about respecting local config, which is the exact opposite of 
> that suggestion. It would be a way to solve the line-ending issue by fiat, 
> not by co-operation, so I'm against it on principle. To be clear I very much 
> don't like CRLF, but I also very much don't like it when someone forces me to 
> use wrong-handed tools. Windows users would be forced to use wrong handed 
> tools if we force line-endings one way or another

But if every single Windows developer involved here say that they want LF, and 
they don't want any ambiguity about it? Is it more important to give 
hypothetical users the choice to pick what they like, at the cost of every 
single current developer who do not want that, and breaking every established 
setup routine?

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


[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-22 Thread Martin Storsjö via lldb-commits

mstorsjo wrote:

> This patch is about respecting local config, which is the exact opposite of 
> that suggestion. It would be a way to solve the line-ending issue by fiat, 
> not by co-operation, so I'm against it on principle. To be clear I very much 
> don't like CRLF, but I also very much don't like it when someone forces me to 
> use wrong-handed tools. Windows users would be forced to use wrong handed 
> tools if we force line-endings one way or another

Also FWIW, I wouldn't that much mind letting users pick whichever form of line 
endings they would like, if all tests would have been cleaned up _before_ this, 
so that they pass regardless of the user choice or tool defaults - but alas, 
there still are >70 Clang tests failing.



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


[Lldb-commits] [lldb] [lldb][NFC] Make the target's SectionLoadList private. (PR #113278)

2024-10-22 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Greg Clayton (clayborg)


Changes

Lots of code around LLDB was directly accessing the target's section load list. 
This NFC patch makes the section load list private to the Target class can 
access it, but everyone else now uses accessor functions. This allows us to 
control the resolving of addresses and will allow for functionality in LLDB 
which can lazily resolve addresses in JIT plug-ins with a future patch.

---

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


33 Files Affected:

- (modified) lldb/include/lldb/Target/Target.h (+12-3) 
- (modified) lldb/source/API/SBBreakpoint.cpp (+2-2) 
- (modified) lldb/source/Breakpoint/BreakpointLocationList.cpp (+1-2) 
- (modified) lldb/source/Commands/CommandObjectDisassemble.cpp (+3-3) 
- (modified) lldb/source/Commands/CommandObjectRegister.cpp (+2-2) 
- (modified) lldb/source/Commands/CommandObjectSource.cpp (+4-5) 
- (modified) lldb/source/Commands/CommandObjectTarget.cpp (+7-8) 
- (modified) lldb/source/Core/Address.cpp (+3-5) 
- (modified) lldb/source/Core/Disassembler.cpp (+1-5) 
- (modified) lldb/source/Core/DumpDataExtractor.cpp (+4-6) 
- (modified) lldb/source/Core/FormatEntity.cpp (+1-1) 
- (modified) lldb/source/Core/Section.cpp (+2-2) 
- (modified) lldb/source/Core/Value.cpp (+2-3) 
- (modified) lldb/source/DataFormatters/CXXFunctionPointer.cpp (+2-3) 
- (modified) lldb/source/Expression/ObjectFileJIT.cpp (+2-2) 
- (modified) lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp (+1-2) 
- (modified) lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp 
(+3-3) 
- (modified) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp (+1-1) 
- (modified) lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp 
(+2-2) 
- (modified) 
lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp 
(+3-6) 
- (modified) lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp (+1-1) 
- (modified) 
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp (+8-10) 
- (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (+1-2) 
- (modified) lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (+5-5) 
- (modified) lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp (+1-1) 
- (modified) 
lldb/source/Plugins/ObjectFile/Placeholder/ObjectFilePlaceholder.cpp (+1-2) 
- (modified) lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp (+2-2) 
- (modified) lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp 
(+1-1) 
- (modified) lldb/source/Symbol/ObjectFile.cpp (+1-2) 
- (modified) lldb/source/Target/ProcessTrace.cpp (+1-1) 
- (modified) lldb/source/Target/Target.cpp (+14) 
- (modified) lldb/source/Target/ThreadPlanStepInRange.cpp (+1-2) 
- (modified) lldb/source/Target/ThreadPlanTracer.cpp (+1-2) 


``diff
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index e4848f19e64d62..5f43b4f5060d0a 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1140,9 +1140,14 @@ class Target : public 
std::enable_shared_from_this,
  Address &pointer_addr,
  bool force_live_memory = false);
 
-  SectionLoadList &GetSectionLoadList() {
-return m_section_load_history.GetCurrentSectionLoadList();
-  }
+
+  bool SectionLoadListIsEmpty() const;
+
+  lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP §ion_sp);
+
+  void ClearSectionLoadList();
+
+  void DumpSectionLoadList(Stream &s);
 
   static Target *GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
const SymbolContext *sc_ptr);
@@ -1653,6 +1658,10 @@ class Target : public 
std::enable_shared_from_this,
 
   Target(const Target &) = delete;
   const Target &operator=(const Target &) = delete;
+
+  SectionLoadList &GetSectionLoadList() {
+return m_section_load_history.GetCurrentSectionLoadList();
+  }
 };
 
 } // namespace lldb_private
diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index b2ed034d19983c..87fadbcec4f26b 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -137,7 +137,7 @@ SBBreakpointLocation 
SBBreakpoint::FindLocationByAddress(addr_t vm_addr) {
   bkpt_sp->GetTarget().GetAPIMutex());
   Address address;
   Target &target = bkpt_sp->GetTarget();
-  if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) {
+  if (!target.ResolveLoadAddress(vm_addr, address)) {
 address.SetRawAddress(vm_addr);
   }
   sb_bp_location.SetLocation(bkpt_sp->FindLocationByAddress(address));
@@ -157,7 +157,7 @@ break_id_t SBBreakpoint::FindLocationIDByAddress(addr_t 
vm_addr) {
 bkpt_sp->GetTarget().GetAPIMutex());
 Address address;
 Target &target = bkpt_sp->GetTarget();
-if (!target.GetSecti

[Lldb-commits] [lldb] [lldb][NFC] Make the target's SectionLoadList private. (PR #113278)

2024-10-22 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-22 Thread Martin Storsjö via lldb-commits

mstorsjo wrote:

> I think this is due to a subtly of config. Setting `core.autocrlf` to `false` 
> doesn't actually do anything since it's the default. 

In Git for Windows, the default actually is `core.autocrlf` set to `true`. When 
manually installing, the installer wizard used to ask the user which way they 
want their defaults to be set, not sure if this still is the case. But in e.g. 
Github Actions runners, you get it set to `true` by default - see 
https://github.com/mstorsjo/llvm-project/actions/runs/11459095411/job/31882864878.

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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Michael Buch via lldb-commits
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 


https://github.com/Michael137 commented:

`TypeSystemClang.cpp` change LGTM. Though It'd be nice if we added the same 
test-coverage also for non-MSVC (only found shell tests for PDB, and 1 API test 
that didn't enumerate all the cases).

I guess a follow-up question is how to set the `MSInheritanceAttr`. Infer it 
from the class DIE? Or add a new DWARF attribute? Also, whether we still want 
to issue a warning when debugging using DWARF and the MS ABI (like suggested in 
https://reviews.llvm.org/D130942).

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


[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-22 Thread via lldb-commits

ldrumm wrote:

>> It's my understanding that text=auto does not override core.autocrlf. As far 
>> as I can tell from the documentation it honours the user's configuration for 
>> core.eol in combination with core.autocrlf - from git config --help:

> This doesn't match my experience.

I think this is due to a subtly of config. Setting `core.autocrlf` to `false` 
doesn't actually do anything since it's the default. In that case git is still 
in "no opinion" mode - which means it stores the input line endings and does no 
conversion.

However, once `eol=auto` is set in a `.gitattributes`, it forces git to use the 
configured eol config:

```c
static int text_eol_is_crlf(void)
{
if (auto_crlf == AUTO_CRLF_TRUE)
return 1;
else if (auto_crlf == AUTO_CRLF_INPUT)
return 0;
if (core_eol == EOL_CRLF)
return 1;
if (core_eol == EOL_UNSET && EOL_NATIVE == EOL_CRLF)
return 1;
return 0;
}

static enum eol output_eol(enum convert_crlf_action crlf_action)
{
switch (crlf_action) {
case CRLF_BINARY:
return EOL_UNSET;
case CRLF_TEXT_CRLF:
return EOL_CRLF;
case CRLF_TEXT_INPUT:
return EOL_LF;
case CRLF_UNDEFINED:
case CRLF_AUTO_CRLF:
return EOL_CRLF;
case CRLF_AUTO_INPUT:
return EOL_LF;
case CRLF_TEXT:
case CRLF_AUTO:
/* fall through */
return text_eol_is_crlf() ? EOL_CRLF : EOL_LF;
}
warning(_("illegal crlf_action %d"), (int)crlf_action);
return core_eol;
}
```
`output_eol` is the git function that decides to write out a file with CRLF or 
LF endings

Notice that now we hit the `CRLF_AUTO`  case so it's `text_eol_is_crlf() ? 
EOL_CRLF : EOL_LF;`
 
`text_eol_is_crlf()` checks against `core.autocrlf`. Since you've stated that 
it's `false`, then it then it checks `core.eol`.

So if I've read that correctly, `core.autocrlf=false` is a red herring and you 
should really set `core.eol=lf` if you want git to use `lf` on windows.

> Would we get there by setting the wildcard rule in .gitattrubtes to * text 
> eof=lf, or something along those lines?

This patch is about respecting local config, which is the exact opposite of 
that suggestion. It would be a way to solve the line-ending issue by fiat, not 
by co-operation, so I'm against it on principle. To be clear I very much don't 
like CRLF, but I also very much don't like it when someone forces me to use 
wrong-handed tools. Windows users would be forced to use wrong handed tools if 
we force line-endings one way or another

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


[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-22 Thread via lldb-commits

ldrumm wrote:

> It always ends like this.

Ends Like what?
As far as I can see all this has done has exposed latent bugs in our testing 
and in clang's parser


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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread via lldb-commits
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 


llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Stefan Gränitz (weliveindetail)


Changes

In the MS ABI, member pointers to `CXXRecordDecl`s must have a 
`MSInheritanceAttr` in order to be complete. Otherwise we cannot query their 
size in memory. This patch checks `MemberPointer` types for completeness 
(eventually looking at the existence of the attribute) to avoid a crash 
[further down in the clang AST 
context](https://github.com/llvm/llvm-project/blob/release/19.x/clang/lib/AST/MicrosoftCXXABI.cpp#L282).

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


2 Files Affected:

- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+3) 
- (added) lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp (+45) 


``diff
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index fe0c53a7e9a3ea..a23dce97f3f299 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2771,6 +2771,9 @@ static bool GetCompleteQualType(clang::ASTContext *ast,
 ast, llvm::cast(qual_type)->getModifiedType(),
 allow_completion);
 
+  case clang::Type::MemberPointer:
+return !qual_type.getTypePtr()->isIncompleteType();
+
   default:
 break;
   }
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
new file mode 100644
index 00..0e51ec99934f4c
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
@@ -0,0 +1,45 @@
+// REQUIRES: lld
+
+// Check that we don't crash on variables without MSInheritanceAttr
+
+// RUN: %clang -c --target=x86_64-windows-msvc -gdwarf %s -o %t.obj
+// RUN: lld-link /out:%t.exe %t.obj /nodefaultlib /entry:main /debug
+// RUN: %lldb -f %t.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 
mp9"
+
+class SI {
+  int si;
+};
+struct SI2 {
+  int si2;
+};
+class MI : SI, SI2 {
+  int mi;
+};
+class MI2 : MI {
+  int mi2;
+};
+class VI : virtual MI {
+  int vi;
+};
+class VI2 : virtual SI, virtual SI2 {
+  int vi;
+};
+class /* __unspecified_inheritance*/ UI;
+
+typedef void (SI::*SITYPE)();
+typedef void (MI::*MITYPE)();
+typedef void (MI2::*MI2TYPE)();
+typedef void (VI::*VITYPE)();
+typedef void (VI2::*VI2TYPE)();
+typedef void (UI::*UITYPE)();
+SITYPE mp1 = nullptr;
+MITYPE mp2 = nullptr;
+MI2TYPE mp3 = nullptr;
+VITYPE mp4 = nullptr;
+VI2TYPE mp5 = nullptr;
+UITYPE mp6 = nullptr;
+MITYPE *mp7 = nullptr;
+VI2TYPE *mp8 = nullptr;
+int SI::*mp9 = nullptr;
+
+int main() {}

``




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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Stefan Gränitz via lldb-commits

https://github.com/weliveindetail updated 
https://github.com/llvm/llvm-project/pull/112928

From bb66f56138cab9651aff4ac09096ede975c90701 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Fri, 18 Oct 2024 17:44:26 +0200
Subject: [PATCH 1/3] [lldb] Fix crash due to missing MSInheritanceAttr on
 CXXRecordDecl for DWARF on Windows

---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index fe0c53a7e9a3ea..a23dce97f3f299 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2771,6 +2771,9 @@ static bool GetCompleteQualType(clang::ASTContext *ast,
 ast, llvm::cast(qual_type)->getModifiedType(),
 allow_completion);
 
+  case clang::Type::MemberPointer:
+return !qual_type.getTypePtr()->isIncompleteType();
+
   default:
 break;
   }

From 6f775566a4face29f85286295aafb16c4367a917 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Tue, 22 Oct 2024 11:11:53 +0200
Subject: [PATCH 2/3] Add test based on
 https://reviews.llvm.org/D130942#change-1PvUCFvQjDIO

---
 .../Shell/SymbolFile/DWARF/x86/ms-abi.cpp | 45 +++
 1 file changed, 45 insertions(+)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp

diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
new file mode 100644
index 00..0e51ec99934f4c
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
@@ -0,0 +1,45 @@
+// REQUIRES: lld
+
+// Check that we don't crash on variables without MSInheritanceAttr
+
+// RUN: %clang -c --target=x86_64-windows-msvc -gdwarf %s -o %t.obj
+// RUN: lld-link /out:%t.exe %t.obj /nodefaultlib /entry:main /debug
+// RUN: %lldb -f %t.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 
mp9"
+
+class SI {
+  int si;
+};
+struct SI2 {
+  int si2;
+};
+class MI : SI, SI2 {
+  int mi;
+};
+class MI2 : MI {
+  int mi2;
+};
+class VI : virtual MI {
+  int vi;
+};
+class VI2 : virtual SI, virtual SI2 {
+  int vi;
+};
+class /* __unspecified_inheritance*/ UI;
+
+typedef void (SI::*SITYPE)();
+typedef void (MI::*MITYPE)();
+typedef void (MI2::*MI2TYPE)();
+typedef void (VI::*VITYPE)();
+typedef void (VI2::*VI2TYPE)();
+typedef void (UI::*UITYPE)();
+SITYPE mp1 = nullptr;
+MITYPE mp2 = nullptr;
+MI2TYPE mp3 = nullptr;
+VITYPE mp4 = nullptr;
+VI2TYPE mp5 = nullptr;
+UITYPE mp6 = nullptr;
+MITYPE *mp7 = nullptr;
+VI2TYPE *mp8 = nullptr;
+int SI::*mp9 = nullptr;
+
+int main() {}

From a892f5eba8e79dbc115cffb1eb26501cdef56f80 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Tue, 22 Oct 2024 15:27:33 +0200
Subject: [PATCH 3/3] Polish test and add coverage for Itanium

---
 .../SymbolFile/DWARF/x86/member-pointers.cpp  | 48 +++
 .../Shell/SymbolFile/DWARF/x86/ms-abi.cpp | 45 -
 2 files changed, 48 insertions(+), 45 deletions(-)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
 delete mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp

diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
new file mode 100644
index 00..93fa999416b74e
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
@@ -0,0 +1,48 @@
+// REQUIRES: lld
+
+// Microsoft ABI:
+// RUN: %clang_cl --target=x86_64-windows-msvc -c -gdwarf %s -o %t_win.obj
+// RUN: lld-link /out:%t_win.exe %t_win.obj /nodefaultlib /entry:main /debug
+// RUN: %lldb -f %t_win.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 
mp8 mp9"
+//
+// DWARF has no representation of MSInheritanceAttr, so we cannot determine 
the size
+// of member-pointers yet. For the moment, make sure we don't crash on such 
variables.
+
+// Itanium ABI:
+// RUN: %clang --target=x86_64-pc-linux -gdwarf -c -o %t_linux.o %s
+// RUN: ld.lld %t_linux.o -o %t_linux
+// RUN: %lldb -f %t_linux -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 
mp8 mp9" | FileCheck %s
+//
+// CHECK: (char SI2::*) mp9 = 0x
+
+class SI {
+  double si;
+};
+struct SI2 {
+  char si2;
+};
+class MI : SI, SI2 {
+  int mi;
+};
+class MI2 : MI {
+  int mi2;
+};
+class VI : virtual MI {
+  int vi;
+};
+class VI2 : virtual SI, virtual SI2 {
+  int vi;
+};
+class /* __unspecified_inheritance*/ UI;
+
+double SI::* mp1 = nullptr;
+int MI::* mp2 = nullptr;
+int MI2::* mp3 = nullptr;
+int VI::* mp4 = nullptr;
+int VI2::* mp5 = nullptr;
+int UI::* mp6 = nullptr;
+int MI::* mp7 = nullptr;
+int VI2::* mp8 = nullptr;
+char SI2::* mp9 = &SI2::si2;
+
+int main() { return 0; }
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
deleted file mode 100644

[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread via lldb-commits
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 


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 9255850e89b1e538e11fcc8b71cfd0b320546a75 
a892f5eba8e79dbc115cffb1eb26501cdef56f80 --extensions cpp -- 
lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
index 93fa999416..b50c0f990a 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
@@ -35,14 +35,14 @@ class VI2 : virtual SI, virtual SI2 {
 };
 class /* __unspecified_inheritance*/ UI;
 
-double SI::* mp1 = nullptr;
-int MI::* mp2 = nullptr;
-int MI2::* mp3 = nullptr;
-int VI::* mp4 = nullptr;
-int VI2::* mp5 = nullptr;
-int UI::* mp6 = nullptr;
-int MI::* mp7 = nullptr;
-int VI2::* mp8 = nullptr;
-char SI2::* mp9 = &SI2::si2;
+double SI::*mp1 = nullptr;
+int MI::*mp2 = nullptr;
+int MI2::*mp3 = nullptr;
+int VI::*mp4 = nullptr;
+int VI2::*mp5 = nullptr;
+int UI::*mp6 = nullptr;
+int MI::*mp7 = nullptr;
+int VI2::*mp8 = nullptr;
+char SI2::*mp9 = &SI2::si2;
 
 int main() { return 0; }

``




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


[Lldb-commits] [lldb] [lldb] Add a compiler/interpreter of LLDB data formatter bytecode to lldb/examples (PR #113398)

2024-10-22 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

Man, this is fantastic. I'll try to implement a little compiler for this for my 
language (Mojo).

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


[Lldb-commits] [lldb] [lldb][NFC] Make the target's SectionLoadList private. (PR #113278)

2024-10-22 Thread Greg Clayton via lldb-commits


@@ -5066,3 +5066,17 @@ llvm::json::Value
 Target::ReportStatistics(const lldb_private::StatisticsOptions &options) {
   return m_stats.ToJSON(*this, options);
 }
+
+bool Target::SectionLoadListIsEmpty() const {
+  return const_cast(this)->GetSectionLoadList().IsEmpty();

clayborg wrote:

We actually can't because `SectionLoadHistory::GetCurrentSectionLoadList()` 
needs to be able to create an empty section load for the special stop ID of 
`eStopIDNow` if the section load list is empty. I don't thing we want to change 
section load list to have the load list be mutable. Let me know if you disagree 
or have another solution?

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


[Lldb-commits] [lldb] [lldb][NFC] Make the target's SectionLoadList private. (PR #113278)

2024-10-22 Thread Greg Clayton via lldb-commits


@@ -5066,3 +5066,17 @@ llvm::json::Value
 Target::ReportStatistics(const lldb_private::StatisticsOptions &options) {
   return m_stats.ToJSON(*this, options);
 }
+
+bool Target::SectionLoadListIsEmpty() const {
+  return const_cast(this)->GetSectionLoadList().IsEmpty();

clayborg wrote:

I found a way to fix this. We don't need the  this function to be `const`

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


[Lldb-commits] [lldb] [lldb] Avoid repeated hash lookups (NFC) (PR #113412)

2024-10-22 Thread Kazu Hirata via lldb-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/113412

None

>From 89c932a72dc2289dd194f7b7950623589948e872 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Tue, 22 Oct 2024 08:10:43 -0700
Subject: [PATCH] [lldb] Avoid repeated hash lookups (NFC)

---
 .../InstEmulation/UnwindAssemblyInstEmulation.cpp  | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git 
a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
 
b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
index 49edd40544e32a..1a680d80a9d3d7 100644
--- 
a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
+++ 
b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
@@ -461,8 +461,7 @@ size_t UnwindAssemblyInstEmulation::WriteMemory(
 
 if (reg_num != LLDB_INVALID_REGNUM &&
 generic_regnum != LLDB_REGNUM_GENERIC_SP) {
-  if (m_pushed_regs.find(reg_num) == m_pushed_regs.end()) {
-m_pushed_regs[reg_num] = addr;
+  if (m_pushed_regs.try_emplace(reg_num, addr).second) {
 const int32_t offset = addr - m_initial_sp;
 m_curr_row->SetRegisterLocationToAtCFAPlusOffset(reg_num, offset,
  /*can_replace=*/true);
@@ -608,8 +607,8 @@ bool UnwindAssemblyInstEmulation::WriteRegister(
 generic_regnum != LLDB_REGNUM_GENERIC_SP) {
   switch (context.GetInfoType()) {
   case EmulateInstruction::eInfoTypeAddress:
-if (m_pushed_regs.find(reg_num) != m_pushed_regs.end() &&
-context.info.address == m_pushed_regs[reg_num]) {
+if (auto it = m_pushed_regs.find(reg_num);
+it != m_pushed_regs.end() && context.info.address == it->second) {
   m_curr_row->SetRegisterLocationToSame(reg_num,
 false /*must_replace*/);
   m_curr_row_modified = true;

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Avoid repeated hash lookups (NFC) (PR #113412)

2024-10-22 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Kazu Hirata (kazutakahirata)


Changes



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


1 Files Affected:

- (modified) 
lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
 (+3-4) 


``diff
diff --git 
a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
 
b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
index 49edd40544e32a..1a680d80a9d3d7 100644
--- 
a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
+++ 
b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
@@ -461,8 +461,7 @@ size_t UnwindAssemblyInstEmulation::WriteMemory(
 
 if (reg_num != LLDB_INVALID_REGNUM &&
 generic_regnum != LLDB_REGNUM_GENERIC_SP) {
-  if (m_pushed_regs.find(reg_num) == m_pushed_regs.end()) {
-m_pushed_regs[reg_num] = addr;
+  if (m_pushed_regs.try_emplace(reg_num, addr).second) {
 const int32_t offset = addr - m_initial_sp;
 m_curr_row->SetRegisterLocationToAtCFAPlusOffset(reg_num, offset,
  /*can_replace=*/true);
@@ -608,8 +607,8 @@ bool UnwindAssemblyInstEmulation::WriteRegister(
 generic_regnum != LLDB_REGNUM_GENERIC_SP) {
   switch (context.GetInfoType()) {
   case EmulateInstruction::eInfoTypeAddress:
-if (m_pushed_regs.find(reg_num) != m_pushed_regs.end() &&
-context.info.address == m_pushed_regs[reg_num]) {
+if (auto it = m_pushed_regs.find(reg_num);
+it != m_pushed_regs.end() && context.info.address == it->second) {
   m_curr_row->SetRegisterLocationToSame(reg_num,
 false /*must_replace*/);
   m_curr_row_modified = true;

``




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


[Lldb-commits] [lldb] [lldb] Expose structured command diagnostics via the SBAPI. (PR #112109)

2024-10-22 Thread Jordan Rupprecht via lldb-commits

rupprecht wrote:

The `command-expr-diagnostics.test` test added here (migrated from API->shell, 
really) is flaky for me. It expects this:

```
(lldb) p a+b
 ˄ ˄
 │ ╰─ error: use of undeclared identifier 'b'
 ╰─ error: use of undeclared identifier 'a'
```

But half the time I see this:

```
(lldb) p a+b
   ˄
   │error: use of undeclared identifier 'a'
   ╰─ error: use of undeclared identifier 'b'
```

I haven't dug into why this is the case. One strange thing is that the 
brokenness is consistent within an LLDB invocation; i.e. running `lldb -o "p 
a+b"` has a 50% success rate, but running `p a+b` 10 times within a single LLDB 
session will either work 10 times or fail 10 times. The non-determinism must be 
something tied to global state/cached/etc.

Has anyone else noticed this? Any ideas what might be going on?

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


[Lldb-commits] [lldb] [lldb] Expose structured command diagnostics via the SBAPI. (PR #112109)

2024-10-22 Thread Jordan Rupprecht via lldb-commits

rupprecht wrote:

I'm unable to observe this issue with a fully optimized build, hinting that 
this is some UB conveniently being optimized out in release builds, but 
sanitizers aren't picking anything up.

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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Stefan Gränitz via lldb-commits

https://github.com/weliveindetail updated 
https://github.com/llvm/llvm-project/pull/112928

From bb66f56138cab9651aff4ac09096ede975c90701 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Fri, 18 Oct 2024 17:44:26 +0200
Subject: [PATCH 1/2] [lldb] Fix crash due to missing MSInheritanceAttr on
 CXXRecordDecl for DWARF on Windows

---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index fe0c53a7e9a3ea..a23dce97f3f299 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2771,6 +2771,9 @@ static bool GetCompleteQualType(clang::ASTContext *ast,
 ast, llvm::cast(qual_type)->getModifiedType(),
 allow_completion);
 
+  case clang::Type::MemberPointer:
+return !qual_type.getTypePtr()->isIncompleteType();
+
   default:
 break;
   }

From 6f775566a4face29f85286295aafb16c4367a917 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Tue, 22 Oct 2024 11:11:53 +0200
Subject: [PATCH 2/2] Add test based on
 https://reviews.llvm.org/D130942#change-1PvUCFvQjDIO

---
 .../Shell/SymbolFile/DWARF/x86/ms-abi.cpp | 45 +++
 1 file changed, 45 insertions(+)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp

diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
new file mode 100644
index 00..0e51ec99934f4c
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
@@ -0,0 +1,45 @@
+// REQUIRES: lld
+
+// Check that we don't crash on variables without MSInheritanceAttr
+
+// RUN: %clang -c --target=x86_64-windows-msvc -gdwarf %s -o %t.obj
+// RUN: lld-link /out:%t.exe %t.obj /nodefaultlib /entry:main /debug
+// RUN: %lldb -f %t.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 
mp9"
+
+class SI {
+  int si;
+};
+struct SI2 {
+  int si2;
+};
+class MI : SI, SI2 {
+  int mi;
+};
+class MI2 : MI {
+  int mi2;
+};
+class VI : virtual MI {
+  int vi;
+};
+class VI2 : virtual SI, virtual SI2 {
+  int vi;
+};
+class /* __unspecified_inheritance*/ UI;
+
+typedef void (SI::*SITYPE)();
+typedef void (MI::*MITYPE)();
+typedef void (MI2::*MI2TYPE)();
+typedef void (VI::*VITYPE)();
+typedef void (VI2::*VI2TYPE)();
+typedef void (UI::*UITYPE)();
+SITYPE mp1 = nullptr;
+MITYPE mp2 = nullptr;
+MI2TYPE mp3 = nullptr;
+VITYPE mp4 = nullptr;
+VI2TYPE mp5 = nullptr;
+UITYPE mp6 = nullptr;
+MITYPE *mp7 = nullptr;
+VI2TYPE *mp8 = nullptr;
+int SI::*mp9 = nullptr;
+
+int main() {}

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Michael Buch via lldb-commits
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 


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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Stefan Gränitz via lldb-commits

weliveindetail wrote:

Ok right, member function pointers are more than just offsets. So, hard-coding 
`clang::Type::MemberPointer` to the system pointer size wouldn't work there.

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


[Lldb-commits] [lldb] [lldb][NFC] Make the target's SectionLoadList private. (PR #113278)

2024-10-22 Thread via lldb-commits

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 dc84337f7b5bb2447e30f3364ebc863e9e04b8be 
851ee7a3fd4f1ae294f3e0baaf0944caeadb7d05 --extensions cpp,h -- 
lldb/include/lldb/Target/Target.h lldb/source/API/SBBreakpoint.cpp 
lldb/source/Breakpoint/BreakpointLocationList.cpp 
lldb/source/Commands/CommandObjectDisassemble.cpp 
lldb/source/Commands/CommandObjectRegister.cpp 
lldb/source/Commands/CommandObjectSource.cpp 
lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Core/Address.cpp 
lldb/source/Core/Disassembler.cpp lldb/source/Core/DumpDataExtractor.cpp 
lldb/source/Core/FormatEntity.cpp lldb/source/Core/Section.cpp 
lldb/source/Core/Value.cpp lldb/source/DataFormatters/CXXFunctionPointer.cpp 
lldb/source/Expression/ObjectFileJIT.cpp 
lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp 
lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp 
lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp 
lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp 
lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp 
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp 
lldb/source/Plugins/ObjectFile/Placeholder/ObjectFilePlaceholder.cpp 
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp 
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp 
lldb/source/Symbol/ObjectFile.cpp lldb/source/Target/ProcessTrace.cpp 
lldb/source/Target/Target.cpp lldb/source/Target/ThreadPlanStepInRange.cpp 
lldb/source/Target/ThreadPlanTracer.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 5f43b4f506..a1577d2108 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1140,7 +1140,6 @@ public:
  Address &pointer_addr,
  bool force_live_memory = false);
 
-
   bool SectionLoadListIsEmpty() const;
 
   lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP §ion_sp);
diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp 
b/lldb/source/Commands/CommandObjectDisassemble.cpp
index 22b29b1e8a..74699a101d 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.cpp
+++ b/lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -256,7 +256,7 @@ CommandObjectDisassemble::GetContainingAddressRanges() {
   Target &target = GetTarget();
   if (!target.SectionLoadListIsEmpty()) {
 Address symbol_containing_address;
-if (target.ResolveLoadAddress(m_options.symbol_containing_addr, 
+if (target.ResolveLoadAddress(m_options.symbol_containing_addr,
   symbol_containing_address)) {
   get_range(symbol_containing_address);
 }
diff --git a/lldb/source/Commands/CommandObjectRegister.cpp 
b/lldb/source/Commands/CommandObjectRegister.cpp
index cb53d7c21b..fbb92e5c63 100644
--- a/lldb/source/Commands/CommandObjectRegister.cpp
+++ b/lldb/source/Commands/CommandObjectRegister.cpp
@@ -95,7 +95,7 @@ public:
 addr_t reg_addr = reg_value.GetAsUInt64(LLDB_INVALID_ADDRESS);
 if (reg_addr != LLDB_INVALID_ADDRESS) {
   Address so_reg_addr;
-  if (exe_ctx.GetTargetRef().ResolveLoadAddress(reg_addr, 
+  if (exe_ctx.GetTargetRef().ResolveLoadAddress(reg_addr,
 so_reg_addr)) {
 strm.PutCString("  ");
 so_reg_addr.Dump(&strm, exe_ctx.GetBestExecutionContextScope(),
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 3642d22a9b..b324eb7287 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -2974,7 +2974,7 @@ protected:
   sect_name);
   break;
 } else {
-  if (target.SetSectionLoadAddress(section_sp, 
+  if (target.SetSectionLoadAddress(section_sp,
load_addr))
 changed = true;
   result.AppendMessageWithFormat(
diff --git a/lldb/source/Core/Disassembler.cpp 
b/lldb/source/Core/Disassembler.cpp
index 6c4f43ca06..e57a150f86 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -102,7 +102,11 @@ static Address ResolveAddress(Target &target, const 
Address &addr) {
 Address resolved_addr;
 // If we weren't passed in a section off

[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Michael Buch via lldb-commits
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 



@@ -2771,6 +2771,9 @@ static bool GetCompleteQualType(clang::ASTContext *ast,
 ast, llvm::cast(qual_type)->getModifiedType(),
 allow_completion);
 
+  case clang::Type::MemberPointer:
+return !qual_type.getTypePtr()->isIncompleteType();

Michael137 wrote:

I see, so for non-MSVC ABI `isIncompleteType` will pretty much work as before, 
and trivially return true. Otherwise we check for the `MSInheritanceAttr`. 
Seems reasonable to me

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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Michael Buch via lldb-commits
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 


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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Michael Buch via lldb-commits
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 


Michael137 wrote:

> > I guess a follow-up question is how to set the MSInheritanceAttr. Infer it 
> > from the class DIE? Or add a new DWARF attribute?
> > Well, maybe, but not sure. I believe it has a set of attributes that convey 
> > the information that MSInheritanceAttr has in the MS ABI. Would such 
> > duplication be accepted? And as long as it's just about member pointers, it 
> > might not be worth the effort. Let's see.
> 
> I did some more digging and now I wonder: Couldn't 
> `TypeSystemClang::GetBitSize()` just return the pointer-size in bits for 
> `clang::Type::MemberPointer`? That shouldn't even depend on the object it 
> refers to, right?

It is ABI dependent, and we probably do want to rely on Clang to tell us this 
so we don't reimplement all that logic. E.g., for Itanium, the size for would 
be `sizeof(ptrdiff_t)` for data members (and double that for function 
pointers). With the MS ABI it gets more complicated it seems.

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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Stefan Gränitz via lldb-commits


@@ -0,0 +1,48 @@
+// REQUIRES: lld
+
+// Microsoft ABI:
+// RUN: %clang_cl --target=x86_64-windows-msvc -c -gdwarf %s -o %t_win.obj
+// RUN: lld-link /out:%t_win.exe %t_win.obj /nodefaultlib /entry:main /debug
+// RUN: %lldb -f %t_win.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 
mp8 mp9"
+//
+// DWARF has no representation of MSInheritanceAttr, so we cannot determine 
the size
+// of member-pointers yet. For the moment, make sure we don't crash on such 
variables.
+
+// Itanium ABI:
+// RUN: %clang --target=x86_64-pc-linux -gdwarf -c -o %t_linux.o %s
+// RUN: ld.lld %t_linux.o -o %t_linux
+// RUN: %lldb -f %t_linux -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 
mp8 mp9" | FileCheck %s

weliveindetail wrote:

@Michael137 You think that's ok as test-coverage also for non-MSVC?

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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Michael Buch via lldb-commits
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 



@@ -0,0 +1,48 @@
+// REQUIRES: lld
+
+// Microsoft ABI:
+// RUN: %clang_cl --target=x86_64-windows-msvc -c -gdwarf %s -o %t_win.obj
+// RUN: lld-link /out:%t_win.exe %t_win.obj /nodefaultlib /entry:main /debug
+// RUN: %lldb -f %t_win.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 
mp8 mp9"
+//
+// DWARF has no representation of MSInheritanceAttr, so we cannot determine 
the size
+// of member-pointers yet. For the moment, make sure we don't crash on such 
variables.
+
+// Itanium ABI:
+// RUN: %clang --target=x86_64-pc-linux -gdwarf -c -o %t_linux.o %s
+// RUN: ld.lld %t_linux.o -o %t_linux
+// RUN: %lldb -f %t_linux -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 
mp8 mp9" | FileCheck %s

Michael137 wrote:

Yup, thanks!

Don't think we even need to link (in either case).

Also lets add a `CHECK-MSVC:` as well. That'd also notify us once that 
byte-size issue gets fixed on Windows

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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Michael Buch via lldb-commits
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 


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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Michael Buch via lldb-commits
Stefan =?utf-8?q?Gr=C3=A4nitz?= ,
Stefan =?utf-8?q?Gr=C3=A4nitz?= ,
Stefan =?utf-8?q?Gr=C3=A4nitz?= 
Message-ID:
In-Reply-To: 


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

lgtm (modulo test comment)

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


[Lldb-commits] [lldb] [lldb][test] Fix TestUseSourceCache for readonly source trees (PR #113251)

2024-10-22 Thread Jordan Rupprecht via lldb-commits

https://github.com/rupprecht updated 
https://github.com/llvm/llvm-project/pull/113251

>From 0d27f7643007805bc2b1f2965edbd71d6563dae3 Mon Sep 17 00:00:00 2001
From: Jordan Rupprecht 
Date: Mon, 21 Oct 2024 19:29:50 -0700
Subject: [PATCH 1/2] [lldb][test] Fix TestUseSourceCache for readonly source
 trees

TestUseSourceCache attempts to write to a build artifact copied from the source 
tree, and asserts the write succeeded. If the source tree is read only, the 
copy will also be read only, causing it to fail. When producing the build 
artifact, ensure that it is writable.

I use `chmod` as a build step to do this, but I believe that is linuxish-only 
thing, so I excluded this extra command for Windows.
---
 lldb/test/API/commands/settings/use_source_cache/Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lldb/test/API/commands/settings/use_source_cache/Makefile 
b/lldb/test/API/commands/settings/use_source_cache/Makefile
index 791cb7d868d87e..0090acf5591daa 100644
--- a/lldb/test/API/commands/settings/use_source_cache/Makefile
+++ b/lldb/test/API/commands/settings/use_source_cache/Makefile
@@ -6,3 +6,6 @@ include Makefile.rules
 # Copy file into the build folder to enable the test to modify it.
 main-copy.cpp: main.cpp
cp -f $< $@
+ifneq "$(OS)" "Windows_NT"  # chmod is not available on Windows
+   chmod u+w $@
+endif

>From ffec54648ac581c7d43cc406b9b7a0b53fd4a331 Mon Sep 17 00:00:00 2001
From: Jordan Rupprecht 
Date: Tue, 22 Oct 2024 07:45:02 -0700
Subject: [PATCH 2/2] Remove windows guard

---
 lldb/test/API/commands/settings/use_source_cache/Makefile | 2 --
 1 file changed, 2 deletions(-)

diff --git a/lldb/test/API/commands/settings/use_source_cache/Makefile 
b/lldb/test/API/commands/settings/use_source_cache/Makefile
index 0090acf5591daa..6c1c64fae074d1 100644
--- a/lldb/test/API/commands/settings/use_source_cache/Makefile
+++ b/lldb/test/API/commands/settings/use_source_cache/Makefile
@@ -6,6 +6,4 @@ include Makefile.rules
 # Copy file into the build folder to enable the test to modify it.
 main-copy.cpp: main.cpp
cp -f $< $@
-ifneq "$(OS)" "Windows_NT"  # chmod is not available on Windows
chmod u+w $@
-endif

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test] Fix TestUseSourceCache for readonly source trees (PR #113251)

2024-10-22 Thread Jordan Rupprecht via lldb-commits


@@ -6,3 +6,6 @@ include Makefile.rules
 # Copy file into the build folder to enable the test to modify it.
 main-copy.cpp: main.cpp
cp -f $< $@
+ifneq "$(OS)" "Windows_NT"  # chmod is not available on Windows

rupprecht wrote:

Excellent. Removed the condition.

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


[Lldb-commits] [lldb] [lldb][test] Fix TestUseSourceCache for readonly source trees (PR #113251)

2024-10-22 Thread Jordan Rupprecht via lldb-commits

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


[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-22 Thread Aaron Ballman via lldb-commits

AaronBallman wrote:

> But if every single Windows developer involved here say that they want LF, 
> and they don't want any ambiguity about it? Is it more important to give 
> hypothetical users the choice to pick what they like, at the cost of every 
> single current developer who do not want that, and breaking every established 
> setup routine?

+1; I was [on the 
fence](https://github.com/llvm/llvm-project/pull/86318#pullrequestreview-2023166237)
 about the changes because what happened here has [happened 
before](https://github.com/llvm/llvm-project/pull/86318#issuecomment-2427230026).

The amount of churn is already pretty high -- please make sure the original 
commit, fixes, and reverts get added to 
https://github.com/llvm/llvm-project/blob/main/.git-blame-ignore-revs. At the 
end of the day, we have a number of tests and files which are sensitive to line 
endings and we have a lot of existing clones of the repo which have been set up 
to work properly with the current setup, so this is a risky change.

Has there been a recent RFC asking if the community wants to go down this path? 
If not, we should run one before attempting further changes (aside from fixing 
anything up that still needs fixing, if anything).

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


[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-22 Thread via lldb-commits

ldrumm wrote:

Yes. An RFC makes sense. None of us here speak for every windows developer. I 
will submit one to discourse once I iron out the kinks and am ready to try again

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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Stefan Gränitz via lldb-commits

weliveindetail wrote:

> This might be related to https://github.com/llvm/llvm-project/issues/56458 
> even though my repro is different.

Actually, rather this one: https://github.com/llvm/llvm-project/issues/56449 It 
adds `MSInheritanceAttr` support in NativePDB. The patch in this PR is about 
DWARF and the Microsoft ABI. Let's avoid the crash right now and consider 
adding a DWARF attribute for MSInheritanceAttr in a next step.

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


[Lldb-commits] [lldb] [lldb] Avoid repeated hash lookups (NFC) (PR #113248)

2024-10-22 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Stefan Gränitz via lldb-commits

https://github.com/weliveindetail updated 
https://github.com/llvm/llvm-project/pull/112928

From bb66f56138cab9651aff4ac09096ede975c90701 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Fri, 18 Oct 2024 17:44:26 +0200
Subject: [PATCH 1/4] [lldb] Fix crash due to missing MSInheritanceAttr on
 CXXRecordDecl for DWARF on Windows

---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index fe0c53a7e9a3ea..a23dce97f3f299 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2771,6 +2771,9 @@ static bool GetCompleteQualType(clang::ASTContext *ast,
 ast, llvm::cast(qual_type)->getModifiedType(),
 allow_completion);
 
+  case clang::Type::MemberPointer:
+return !qual_type.getTypePtr()->isIncompleteType();
+
   default:
 break;
   }

From 6f775566a4face29f85286295aafb16c4367a917 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Tue, 22 Oct 2024 11:11:53 +0200
Subject: [PATCH 2/4] Add test based on
 https://reviews.llvm.org/D130942#change-1PvUCFvQjDIO

---
 .../Shell/SymbolFile/DWARF/x86/ms-abi.cpp | 45 +++
 1 file changed, 45 insertions(+)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp

diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
new file mode 100644
index 00..0e51ec99934f4c
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
@@ -0,0 +1,45 @@
+// REQUIRES: lld
+
+// Check that we don't crash on variables without MSInheritanceAttr
+
+// RUN: %clang -c --target=x86_64-windows-msvc -gdwarf %s -o %t.obj
+// RUN: lld-link /out:%t.exe %t.obj /nodefaultlib /entry:main /debug
+// RUN: %lldb -f %t.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 
mp9"
+
+class SI {
+  int si;
+};
+struct SI2 {
+  int si2;
+};
+class MI : SI, SI2 {
+  int mi;
+};
+class MI2 : MI {
+  int mi2;
+};
+class VI : virtual MI {
+  int vi;
+};
+class VI2 : virtual SI, virtual SI2 {
+  int vi;
+};
+class /* __unspecified_inheritance*/ UI;
+
+typedef void (SI::*SITYPE)();
+typedef void (MI::*MITYPE)();
+typedef void (MI2::*MI2TYPE)();
+typedef void (VI::*VITYPE)();
+typedef void (VI2::*VI2TYPE)();
+typedef void (UI::*UITYPE)();
+SITYPE mp1 = nullptr;
+MITYPE mp2 = nullptr;
+MI2TYPE mp3 = nullptr;
+VITYPE mp4 = nullptr;
+VI2TYPE mp5 = nullptr;
+UITYPE mp6 = nullptr;
+MITYPE *mp7 = nullptr;
+VI2TYPE *mp8 = nullptr;
+int SI::*mp9 = nullptr;
+
+int main() {}

From a892f5eba8e79dbc115cffb1eb26501cdef56f80 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Tue, 22 Oct 2024 15:27:33 +0200
Subject: [PATCH 3/4] Polish test and add coverage for Itanium

---
 .../SymbolFile/DWARF/x86/member-pointers.cpp  | 48 +++
 .../Shell/SymbolFile/DWARF/x86/ms-abi.cpp | 45 -
 2 files changed, 48 insertions(+), 45 deletions(-)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
 delete mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp

diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
new file mode 100644
index 00..93fa999416b74e
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/member-pointers.cpp
@@ -0,0 +1,48 @@
+// REQUIRES: lld
+
+// Microsoft ABI:
+// RUN: %clang_cl --target=x86_64-windows-msvc -c -gdwarf %s -o %t_win.obj
+// RUN: lld-link /out:%t_win.exe %t_win.obj /nodefaultlib /entry:main /debug
+// RUN: %lldb -f %t_win.exe -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 
mp8 mp9"
+//
+// DWARF has no representation of MSInheritanceAttr, so we cannot determine 
the size
+// of member-pointers yet. For the moment, make sure we don't crash on such 
variables.
+
+// Itanium ABI:
+// RUN: %clang --target=x86_64-pc-linux -gdwarf -c -o %t_linux.o %s
+// RUN: ld.lld %t_linux.o -o %t_linux
+// RUN: %lldb -f %t_linux -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 
mp8 mp9" | FileCheck %s
+//
+// CHECK: (char SI2::*) mp9 = 0x
+
+class SI {
+  double si;
+};
+struct SI2 {
+  char si2;
+};
+class MI : SI, SI2 {
+  int mi;
+};
+class MI2 : MI {
+  int mi2;
+};
+class VI : virtual MI {
+  int vi;
+};
+class VI2 : virtual SI, virtual SI2 {
+  int vi;
+};
+class /* __unspecified_inheritance*/ UI;
+
+double SI::* mp1 = nullptr;
+int MI::* mp2 = nullptr;
+int MI2::* mp3 = nullptr;
+int VI::* mp4 = nullptr;
+int VI2::* mp5 = nullptr;
+int UI::* mp6 = nullptr;
+int MI::* mp7 = nullptr;
+int VI2::* mp8 = nullptr;
+char SI2::* mp9 = &SI2::si2;
+
+int main() { return 0; }
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/ms-abi.cpp
deleted file mode 100644

[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-22 Thread Stefan Gränitz via lldb-commits

weliveindetail wrote:

I think it's valuable to get the full config log on buildbots. If this check 
becomes too much of a burden, I'd rather propose to either turn the error into 
a warning or revisit the option to guard it by 
`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS` (see my original patch for details). 
What about that? @GkvJwa

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


[Lldb-commits] [lldb] [lldb] Avoid repeated hash lookups (NFC) (PR #113248)

2024-10-22 Thread Nikita Popov via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Stefan Gränitz via lldb-commits

weliveindetail wrote:

Thanks for the feedback! Yes, I think fixing the crash is a valuable addition 
on its own. It broke use-cases where we just want to set a breakpoint and 
encounter this type on the way, but don't actually care about its byte size.

> I guess a follow-up question is how to set the MSInheritanceAttr. Infer it 
> from the class DIE? Or add a new DWARF attribute?
Well, maybe, but not sure. I believe it has a set of attributes that convey the 
information that MSInheritanceAttr has in the MS ABI. Would such duplication be 
accepted? And as long as it's just about member pointers, it might not be worth 
the effort. Let's see.

I did some more digging and now I wonder: Couldn't 
`TypeSystemClang::GetBitSize()` just return the pointer-size in bits for 
`clang::Type::MemberPointer`? That shouldn't even depend on the object it 
refers to, right?

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


[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-22 Thread via lldb-commits

ldrumm wrote:

> if all tests would have been cleaned up before this

That was most certainly my intention, and I saw green before merging, so I 
must've looked in the wrong place

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


[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-22 Thread Martin Storsjö via lldb-commits

mstorsjo wrote:

> > if all tests would have been cleaned up before this
> 
> That was most certainly my intention, and I saw green before merging, so I 
> must've looked in the wrong place

Ah, right - as we've seen that the CI runner normally only updates an existing 
checkout, where changes to gitattributes like these don't really take effect, I 
guess this can be understood.

(Plus there are a number of tests in less frequently executed testsuites, like 
compiler-rt, clang-tools-extra, and in `llvm/utils/lit/tests`, that don't 
necessarily get included in each normal run in CI.)

On that topic - some of the scripts that orchestrate that premerge testing 
lives in `.ci/generate-buildkite-pipeline-premerge`. By editing that script, it 
should be possible to trigger it to run all possible testsuites, not just the 
ones currently touched. And I'm wondering if there's anything we could add 
there temporarily (both right now, to flush the current checkouts on the 
premerge cluster, and when testing PRs like this one), to force it to check 
files out again?

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


[Lldb-commits] [lldb] Make the target's SectionLoadList private. (PR #113278)

2024-10-22 Thread Greg Clayton via lldb-commits

https://github.com/clayborg created 
https://github.com/llvm/llvm-project/pull/113278

Lots of code around LLDB was directly accessing the target's section load list. 
This NFC patch makes the section load list private to the Target class can 
access it, but everyone else now uses accessor functions. This allows us to 
control the resolving of addresses and will allow for functionality in LLDB 
which can lazily resolve addresses in JIT plug-ins with a future patch.

>From 851ee7a3fd4f1ae294f3e0baaf0944caeadb7d05 Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Tue, 22 Oct 2024 01:16:40 -0700
Subject: [PATCH] Make the target's SectionLoadList private.

Lots of code around LLDB was directly accessing the target's section load list. 
This NFC patch makes the section load list private to the Target class can 
access it, but everyone else now uses accessor functions. This allows us to 
control the resolving of addresses and will allow for functionality in LLDB 
which can lazily resolve addresses in JIT plug-ins with a future patch.
---
 lldb/include/lldb/Target/Target.h  | 15 ---
 lldb/source/API/SBBreakpoint.cpp   |  4 ++--
 .../Breakpoint/BreakpointLocationList.cpp  |  3 +--
 .../Commands/CommandObjectDisassemble.cpp  |  6 +++---
 lldb/source/Commands/CommandObjectRegister.cpp |  4 ++--
 lldb/source/Commands/CommandObjectSource.cpp   |  9 -
 lldb/source/Commands/CommandObjectTarget.cpp   | 15 +++
 lldb/source/Core/Address.cpp   |  8 +++-
 lldb/source/Core/Disassembler.cpp  |  6 +-
 lldb/source/Core/DumpDataExtractor.cpp | 10 --
 lldb/source/Core/FormatEntity.cpp  |  2 +-
 lldb/source/Core/Section.cpp   |  4 ++--
 lldb/source/Core/Value.cpp |  5 ++---
 .../DataFormatters/CXXFunctionPointer.cpp  |  5 ++---
 lldb/source/Expression/ObjectFileJIT.cpp   |  4 ++--
 .../Architecture/Mips/ArchitectureMips.cpp |  3 +--
 .../Disassembler/LLVMC/DisassemblerLLVMC.cpp   |  6 +++---
 .../MacOSX-DYLD/DynamicLoaderMacOS.cpp |  2 +-
 .../Static/DynamicLoaderStatic.cpp |  4 ++--
 .../TSan/InstrumentationRuntimeTSan.cpp|  9 +++--
 .../Plugins/JITLoader/GDB/JITLoaderGDB.cpp |  2 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp   | 18 --
 .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp   |  3 +--
 .../ObjectFile/Mach-O/ObjectFileMachO.cpp  | 10 +-
 .../ObjectFile/PECOFF/ObjectFilePECOFF.cpp |  2 +-
 .../Placeholder/ObjectFilePlaceholder.cpp  |  3 +--
 .../Process/minidump/ProcessMinidump.cpp   |  4 ++--
 .../Trace/intel-pt/TraceIntelPTBundleSaver.cpp |  2 +-
 lldb/source/Symbol/ObjectFile.cpp  |  3 +--
 lldb/source/Target/ProcessTrace.cpp|  2 +-
 lldb/source/Target/Target.cpp  | 14 ++
 lldb/source/Target/ThreadPlanStepInRange.cpp   |  3 +--
 lldb/source/Target/ThreadPlanTracer.cpp|  3 +--
 33 files changed, 96 insertions(+), 97 deletions(-)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index e4848f19e64d62..5f43b4f5060d0a 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1140,9 +1140,14 @@ class Target : public 
std::enable_shared_from_this,
  Address &pointer_addr,
  bool force_live_memory = false);
 
-  SectionLoadList &GetSectionLoadList() {
-return m_section_load_history.GetCurrentSectionLoadList();
-  }
+
+  bool SectionLoadListIsEmpty() const;
+
+  lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP §ion_sp);
+
+  void ClearSectionLoadList();
+
+  void DumpSectionLoadList(Stream &s);
 
   static Target *GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
const SymbolContext *sc_ptr);
@@ -1653,6 +1658,10 @@ class Target : public 
std::enable_shared_from_this,
 
   Target(const Target &) = delete;
   const Target &operator=(const Target &) = delete;
+
+  SectionLoadList &GetSectionLoadList() {
+return m_section_load_history.GetCurrentSectionLoadList();
+  }
 };
 
 } // namespace lldb_private
diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index b2ed034d19983c..87fadbcec4f26b 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -137,7 +137,7 @@ SBBreakpointLocation 
SBBreakpoint::FindLocationByAddress(addr_t vm_addr) {
   bkpt_sp->GetTarget().GetAPIMutex());
   Address address;
   Target &target = bkpt_sp->GetTarget();
-  if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) {
+  if (!target.ResolveLoadAddress(vm_addr, address)) {
 address.SetRawAddress(vm_addr);
   }
   sb_bp_location.SetLocation(bkpt_sp->FindLocationByAddress(address));
@@ -157,7 +157,7 @@ break_id_t SBBreakpoint::FindLocationIDByAddress(

[Lldb-commits] [lldb] [lldb][NFC] Make the target's SectionLoadList private. (PR #113278)

2024-10-22 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Stefan Gränitz via lldb-commits

weliveindetail wrote:

The test caused a crash in the past:
```
> bin/lldb.exe 
> llvm-project-build-main/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/ms-abi.cpp.tmp.exe
>  -b -o "target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 mp9"
Exception Code: 0x8003
...
 #6 0x7ffabb6be846 clang::MSInheritanceAttr::getInheritanceModel 
llvm-project-build-main\tools\clang\include\clang\AST\Attrs.inc:6878:0
 #7 0x7ffabb6be846 clang::CXXRecordDecl::getMSInheritanceModel(void) const 
llvm-project\clang\lib\AST\MicrosoftCXXABI.cpp:235:0
 #8 0x7ffabb6be8f8 llvm::PointerUnion::getFromOpaqueValue 
llvm-project\llvm\include\llvm\ADT\PointerUnion.h:196:0
 #9 0x7ffabb6be8f8 
llvm::PointerLikeTypeTraits >::getFromVoidPointer 
llvm-project\llvm\include\llvm\ADT\PointerUnion.h:271:0
#10 0x7ffabb6be8f8 llvm::PointerIntPairInfo,3,llvm::PointerLikeTypeTraits > >::getPointer 
llvm-project\llvm\include\llvm\ADT\PointerIntPair.h:191:0
#11 0x7ffabb6be8f8 llvm::PointerIntPair,3,unsigned 
int,llvm::PointerLikeTypeTraits 
>,llvm::PointerIntPairInfo,3,llvm::PointerLikeTypeTraits > > >::getPointer 
llvm-project\llvm\include\llvm\ADT\PointerIntPair.h:94:0
#12 0x7ffabb6be8f8 clang::QualType::isNull 
llvm-project\clang\include\clang\AST\Type.h:1013:0
#13 0x7ffabb6be8f8 clang::QualType::getCommonPtr 
llvm-project\clang\include\clang\AST\Type.h:961:0
#14 0x7ffabb6be8f8 clang::QualType::getTypePtr 
llvm-project\clang\include\clang\AST\Type.h:7923:0
#15 0x7ffabb6be8f8 clang::QualType::operator-> 
llvm-project\clang\include\clang\AST\Type.h:1005:0
#16 0x7ffabb6be8f8 clang::MemberPointerType::isMemberFunctionPointer 
llvm-project\clang\include\clang\AST\Type.h:3541:0
#17 0x7ffabb6be8f8 getMSMemberPointerSlots 
llvm-project\clang\lib\AST\MicrosoftCXXABI.cpp:285:0
#18 0x7ffabb6bef45 `anonymous 
namespace'::MicrosoftCXXABI::getMemberPointerInfo 
llvm-project\clang\lib\AST\MicrosoftCXXABI.cpp:310:0
#19 0x7ffabb340010 clang::ASTContext::getTypeInfoImpl(class clang::Type 
const *) const llvm-project\clang\lib\AST\ASTContext.cpp:2305:0
#20 0x7ffabb33f24c clang::ASTContext::getTypeInfo(class clang::Type const 
*) const llvm-project\clang\lib\AST\ASTContext.cpp:1930:0
#21 0x7ffab4a6c2f7 clang::ASTContext::getTypeSize(class clang::QualType) 
const llvm-project\clang\include\clang\AST\ASTContext.h:2466:0
#22 0x7ffab4aa9e75 lldb_private::TypeSystemClang::GetBitSize(void *, class 
lldb_private::ExecutionContextScope *) 
llvm-project\lldb\source\Plugins\TypeSystem\Clang\TypeSystemClang.cpp:4825:0
```

Now it survives:
```
(lldb) target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 mp9
(SITYPE) mp1 = 
(MITYPE) mp2 = 
(MI2TYPE) mp3 = 
(VITYPE) mp4 = 
(VI2TYPE) mp5 = 
(UITYPE) mp6 = 
(MITYPE *) mp7 = 0x
(VI2TYPE *) mp8 = 0x
error: Unable to determine byte size.
```

Next, we might want to query the complete type on demand to determine the 
actual byte sizes.

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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-22 Thread Stefan Gränitz via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [DebugInfo] Add explicit visibility macros to CodeView template functions (PR #113102)

2024-10-22 Thread Vassil Vassilev via lldb-commits

https://github.com/vgvassilev updated 
https://github.com/llvm/llvm-project/pull/113102

>From 1001412f5d48385cf2e7489e44ea7b6b08e65258 Mon Sep 17 00:00:00 2001
From: Thomas Fransham 
Date: Mon, 12 Aug 2024 16:04:12 +0100
Subject: [PATCH 1/2] [DebugInfo] Add explicit visibility macros to CodeView
 template functions

These will be needed for when llvm is built as a shared library on windows with
explicit visibility macros enabled.
Change UnionRecord to class instead of a struct so we can use X macros from
CodeViewTypes.def to forward declare all record classes.

This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and LLVM plugins on 
window.
---
 .../SymbolFile/NativePDB/SymbolFileNativePDB.h |  2 +-
 .../DebugInfo/CodeView/ContinuationRecordBuilder.h | 14 ++
 .../llvm/DebugInfo/CodeView/SimpleTypeSerializer.h | 13 +
 llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h  |  3 ++-
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h 
b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
index 669c44aa131edc..297f11451afb75 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
@@ -32,7 +32,7 @@ class ClassRecord;
 class EnumRecord;
 class ModifierRecord;
 class PointerRecord;
-struct UnionRecord;
+class UnionRecord;
 } // namespace codeview
 } // namespace llvm
 
diff --git a/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h 
b/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h
index 84cef520a2f460..8347ef870d0676 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h
@@ -50,6 +50,20 @@ class ContinuationRecordBuilder {
 
   std::vector end(TypeIndex Index);
 };
+
+// Needed by RandomAccessVisitorTest.cpp
+#define TYPE_RECORD(EnumName, EnumVal, Name)
+#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#define MEMBER_RECORD(EnumName, EnumVal, Name) 
\
+  extern template LLVM_TEMPLATE_ABI void 
ContinuationRecordBuilder::writeMemberType(\
+  Name##Record &Record);
+#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
+#undef TYPE_RECORD
+#undef TYPE_RECORD_ALIAS
+#undef MEMBER_RECORD
+#undef MEMBER_RECORD_ALIAS
+
 } // namespace codeview
 } // namespace llvm
 
diff --git a/llvm/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h 
b/llvm/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h
index fcc0452a6ae9a7..713798fc38d2d8 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h
@@ -32,6 +32,19 @@ class SimpleTypeSerializer {
   ArrayRef serialize(const FieldListRecord &Record) = delete;
 };
 
+// Needed by RandomAccessVisitorTest.cpp
+#define TYPE_RECORD(EnumName, EnumVal, Name)   
\
+  class Name##Record;  
\
+  extern template LLVM_TEMPLATE_ABI ArrayRef 
llvm::codeview::SimpleTypeSerializer::serialize(  \
+  Name##Record &Record);
+#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#define MEMBER_RECORD(EnumName, EnumVal, Name)
+#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
+#undef TYPE_RECORD
+#undef TYPE_RECORD_ALIAS
+#undef MEMBER_RECORD
+#undef MEMBER_RECORD_ALIAS
 } // end namespace codeview
 } // end namespace llvm
 
diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h 
b/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h
index 5a84fac5f59034..484e05b5adc672 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h
@@ -495,7 +495,8 @@ class ClassRecord : public TagRecord {
 };
 
 // LF_UNION
-struct UnionRecord : public TagRecord {
+class UnionRecord : public TagRecord {
+public:
   UnionRecord() = default;
   explicit UnionRecord(TypeRecordKind Kind) : TagRecord(Kind) {}
   UnionRecord(uint16_t MemberCount, ClassOptions Options, TypeIndex FieldList,

>From d9de70aab0258f652be5803c1ed24b3c0f348cf2 Mon Sep 17 00:00:00 2001
From: Thomas Fransham 
Date: Sun, 20 Oct 2024 20:35:48 +0100
Subject: [PATCH 2/2] Fix formatting

---
 .../llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h   | 4 ++--
 llvm/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h   | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h 
b/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h
index 8347ef870d0676..3de138f37be2d2 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuil

[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-22 Thread Martin Storsjö via lldb-commits

mstorsjo wrote:

> I must have missed this PR originally. I oppose letting Git change any line 
> endings. It always ends like this.

Also just for context - the Clang precommit CI is allegedly still broken, 
because those buildbots happened to be restarted when we had these 
gitattributes in place, so all files are checked out with CRLF right now, and 
any incremental update on top doesn't change that, as long as those files 
aren't touched: 
https://discourse.llvm.org/t/windows-premerge-buildbot-broken-for-5-days/82571/6

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


[Lldb-commits] [lldb] 5dbfb49 - [lldb] Avoid repeated hash lookups (NFC) (#113248)

2024-10-22 Thread via lldb-commits

Author: Kazu Hirata
Date: 2024-10-22T07:59:41-07:00
New Revision: 5dbfb49490c5f06c9c7843051471956b11ef2abd

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

LOG: [lldb] Avoid repeated hash lookups (NFC) (#113248)

Added: 


Modified: 

lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
 
b/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
index 7c678faaae7fd5..8391467c375f42 100644
--- 
a/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
+++ 
b/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
@@ -552,9 +552,9 @@ bool DynamicLoaderFreeBSDKernel::ParseKmods(Address 
linker_files_head_addr) {
   m_process->GetTarget().ModulesDidUnload(remove_modules, false);
 
   for (KModImageInfo &image_info : linker_files_list) {
-if (m_kld_name_to_uuid.find(image_info.GetName()) !=
-m_kld_name_to_uuid.end())
-  image_info.SetUUID(m_kld_name_to_uuid[image_info.GetName()]);
+auto it = m_kld_name_to_uuid.find(image_info.GetName());
+if (it != m_kld_name_to_uuid.end())
+  image_info.SetUUID(it->second);
 bool failed_to_load = false;
 if (!image_info.LoadImageUsingMemoryModule(m_process)) {
   image_info.LoadImageUsingFileAddress(m_process);



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Avoid repeated hash lookups (NFC) (PR #113248)

2024-10-22 Thread Kazu Hirata via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-22 Thread via lldb-commits
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 


GkvJwa wrote:

> I think it's valuable to get the full config log on buildbots. If this check 
> becomes too much of a burden, I'd rather propose to either turn the error 
> into a warning or revisit the option to guard it by 
> `LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS` (see my original patch for details). 
> What about that? @GkvJwa

Personally, warnings are better than errors for developers

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