[Lldb-commits] [PATCH] D142793: Remove -py3 command line arg from swig invocation; generates warning with swig 4.1.1

2023-01-27 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda abandoned this revision.
jasonmolenda added a comment.

hasn't landed it, hasn't beaten me!!!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142793/new/

https://reviews.llvm.org/D142793

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


[Lldb-commits] [PATCH] D142793: Remove -py3 command line arg from swig invocation; generates warning with swig 4.1.1

2023-01-27 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Ismail beat you to it: https://reviews.llvm.org/D142245


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142793/new/

https://reviews.llvm.org/D142793

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


[Lldb-commits] [PATCH] D142793: Remove -py3 command line arg from swig invocation; generates warning with swig 4.1.1

2023-01-27 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda created this revision.
jasonmolenda added a reviewer: JDevlieghere.
jasonmolenda added a project: LLDB.
Herald added a project: All.
jasonmolenda requested review of this revision.
Herald added a subscriber: lldb-commits.

When I touch the bindings and build with ninja, I see

  [5/15] Building LLDB Python wrapper
  Deprecated command line option: -py3. Ignored, this option is no longer 
supported.

with swig 4.1.1.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142793

Files:
  lldb/bindings/python/CMakeLists.txt


Index: lldb/bindings/python/CMakeLists.txt
===
--- lldb/bindings/python/CMakeLists.txt
+++ lldb/bindings/python/CMakeLists.txt
@@ -10,7 +10,6 @@
   -c++
   -shadow
   -python
-  -py3
   -threads
   -outdir ${CMAKE_CURRENT_BINARY_DIR}
   -o ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp


Index: lldb/bindings/python/CMakeLists.txt
===
--- lldb/bindings/python/CMakeLists.txt
+++ lldb/bindings/python/CMakeLists.txt
@@ -10,7 +10,6 @@
   -c++
   -shadow
   -python
-  -py3
   -threads
   -outdir ${CMAKE_CURRENT_BINARY_DIR}
   -o ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D142792: Add SBValue::GetValueAsAddress(), strip off ptrauth, TBI, MTE bits on AArch64 systems

2023-01-27 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda updated this revision to Diff 492951.
jasonmolenda added a comment.

Fix the nits Jonas pointed out, thanks Jonas.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142792/new/

https://reviews.llvm.org/D142792

Files:
  lldb/bindings/interface/SBValue.i
  lldb/include/lldb/API/SBValue.h
  lldb/include/lldb/Core/ValueObject.h
  lldb/source/API/SBValue.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/DataFormatters/ValueObjectPrinter.cpp
  lldb/test/API/api/clear-sbvalue-nonadressable-bits/Makefile
  
lldb/test/API/api/clear-sbvalue-nonadressable-bits/TestClearSBValueNonAddressableBits.py
  lldb/test/API/api/clear-sbvalue-nonadressable-bits/main.c

Index: lldb/test/API/api/clear-sbvalue-nonadressable-bits/main.c
===
--- /dev/null
+++ lldb/test/API/api/clear-sbvalue-nonadressable-bits/main.c
@@ -0,0 +1,14 @@
+#include 
+int main() {
+  int v = 5;
+  int *v_p = &v;
+
+  // Add some metadata in the top byte (this will crash unless the
+  // test is running with TBI enabled, but we won't dereference it)
+
+  intptr_t scratch = (intptr_t)v_p;
+  scratch |= (3ULL << 60);
+  int *v_invalid_p = (int *)scratch;
+
+  return v; // break here
+}
Index: lldb/test/API/api/clear-sbvalue-nonadressable-bits/TestClearSBValueNonAddressableBits.py
===
--- /dev/null
+++ lldb/test/API/api/clear-sbvalue-nonadressable-bits/TestClearSBValueNonAddressableBits.py
@@ -0,0 +1,35 @@
+"""Test that SBValue clears non-addressable bits"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestClearSBValueNonAddressableBits(TestBase):
+
+NO_DEBUG_INFO_TESTCASE = True
+
+# On AArch64 systems, the top bits that are not used for
+# addressing may be used for TBI, MTE, and/or pointer 
+# authentication.
+@skipIf(archs=no_match(['aarch64', 'arm64', 'arm64e']))
+
+def test(self):
+self.source = 'main.c'
+self.build()
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
+   "break here", lldb.SBFileSpec(self.source, False))
+
+if self.TraceOn():
+self.runCmd ("v v v_p v_invalid_p")
+self.runCmd ("v &v &v_p &v_invalid_p")
+
+frame = thread.GetFrameAtIndex(0)
+v_p = frame.FindVariable("v_p")
+v_invalid_p = frame.FindVariable("v_invalid_p")
+
+self.assertEqual(v_p.GetValueAsUnsigned(), v_invalid_p.GetValueAsAddress())
+self.assertNotEqual(v_invalid_p.GetValueAsUnsigned(), v_invalid_p.GetValueAsAddress())
+
+self.assertEqual(5, v_p.Dereference().GetValueAsUnsigned())
+self.assertEqual(5, v_invalid_p.Dereference().GetValueAsUnsigned())
Index: lldb/test/API/api/clear-sbvalue-nonadressable-bits/Makefile
===
--- /dev/null
+++ lldb/test/API/api/clear-sbvalue-nonadressable-bits/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
Index: lldb/source/DataFormatters/ValueObjectPrinter.cpp
===
--- lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -426,6 +426,11 @@
 IsPointerValue(m_valobj->GetCompilerType())) {
 } else {
   m_stream->Printf(" %s", m_value.c_str());
+  addr_t stripped =
+  m_valobj->GetStrippedPointerValue(m_valobj->GetPointerValue());
+  if (stripped != m_valobj->GetPointerValue()) {
+m_stream->Printf(" (actual=0x%" PRIx64 ")", stripped);
+  }
   value_printed = true;
 }
   }
Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -31,6 +31,7 @@
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/Type.h"
 #include "lldb/Symbol/Variable.h"
+#include "lldb/Target/ABI.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Language.h"
 #include "lldb/Target/LanguageRuntime.h"
@@ -1442,6 +1443,14 @@
   return LLDB_INVALID_ADDRESS;
 }
 
+addr_t ValueObject::GetStrippedPointerValue(addr_t address) {
+  ExecutionContext exe_ctx(GetExecutionContextRef());
+  if (Process *process = exe_ctx.GetProcessPtr())
+if (ABISP abi_sp = process->GetABI())
+  return abi_sp->FixCodeAddress(address);
+  return address;
+}
+
 addr_t ValueObject::GetPointerValue(AddressType *address_type) {
   addr_t address = LLDB_INVALID_ADDRESS;
   if (address_type)
@@ -1461,7 +1470,7 @@
   case Value::ValueType::LoadAddress:
   case Value::ValueType::FileAddress: {
 lldb::offset_t data_offset = 0;
-address = m_data.GetAddress(&data_offset);
+address = GetStrippedPoi

[Lldb-commits] [PATCH] D142792: Add SBValue::GetValueAsAddress(), strip off ptrauth, TBI, MTE bits on AArch64 systems

2023-01-27 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/API/SBValue.cpp:935-940
+ProcessSP process_sp = m_opaque_sp->GetProcessSP();
+if (!process_sp)
+  return ret_val;
+ABISP abi_sp = process_sp->GetABI();
+if (abi_sp)
+  return abi_sp->FixCodeAddress(ret_val);

jasonmolenda wrote:
> JDevlieghere wrote:
> > Nit^3: why not do the same as in `GetStrippedPointerValue` and 
> > `CreateValueObjectFromAddress`:
> > 
> > ```
> > if (ProcessSP process_sp = m_opaque_sp->GetProcessSP())
> >   if (ABISP abi_sp = process_sp->GetABI())
> > return abi_sp->FixCodeAddress(ret_val);
> > ```
> This method is static so I had to duplicate the functionality here. :/
I meant the code style rather than the actual code, but yeah good point maybe 
this should be a helper ;-) 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142792/new/

https://reviews.llvm.org/D142792

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


[Lldb-commits] [PATCH] D142792: Add SBValue::GetValueAsAddress(), strip off ptrauth, TBI, MTE bits on AArch64 systems

2023-01-27 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added inline comments.



Comment at: lldb/source/API/SBValue.cpp:935-940
+ProcessSP process_sp = m_opaque_sp->GetProcessSP();
+if (!process_sp)
+  return ret_val;
+ABISP abi_sp = process_sp->GetABI();
+if (abi_sp)
+  return abi_sp->FixCodeAddress(ret_val);

jasonmolenda wrote:
> JDevlieghere wrote:
> > Nit^3: why not do the same as in `GetStrippedPointerValue` and 
> > `CreateValueObjectFromAddress`:
> > 
> > ```
> > if (ProcessSP process_sp = m_opaque_sp->GetProcessSP())
> >   if (ABISP abi_sp = process_sp->GetABI())
> > return abi_sp->FixCodeAddress(ret_val);
> > ```
> This method is static so I had to duplicate the functionality here. :/
(or add an ExecutionContext parameter)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142792/new/

https://reviews.llvm.org/D142792

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


[Lldb-commits] [PATCH] D142792: Add SBValue::GetValueAsAddress(), strip off ptrauth, TBI, MTE bits on AArch64 systems

2023-01-27 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

Thanks for the nits, good points.




Comment at: lldb/source/API/SBValue.cpp:935-940
+ProcessSP process_sp = m_opaque_sp->GetProcessSP();
+if (!process_sp)
+  return ret_val;
+ABISP abi_sp = process_sp->GetABI();
+if (abi_sp)
+  return abi_sp->FixCodeAddress(ret_val);

JDevlieghere wrote:
> Nit^3: why not do the same as in `GetStrippedPointerValue` and 
> `CreateValueObjectFromAddress`:
> 
> ```
> if (ProcessSP process_sp = m_opaque_sp->GetProcessSP())
>   if (ABISP abi_sp = process_sp->GetABI())
> return abi_sp->FixCodeAddress(ret_val);
> ```
This method is static so I had to duplicate the functionality here. :/


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142792/new/

https://reviews.llvm.org/D142792

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


[Lldb-commits] [PATCH] D142792: Add SBValue::GetValueAsAddress(), strip off ptrauth, TBI, MTE bits on AArch64 systems

2023-01-27 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

I figured I'd leave some nits on a Friday afternoon.




Comment at: lldb/bindings/interface/SBValue.i:117-132
+" // Return the value as an address.  On failure, LLDB_INVALID_ADDRESS 
+  // will be returned.  On architectures like AArch64, where the top 
+  // (unaddressable) bits can be used for authentication, memory tagging, 
+  // or top byte ignore,  this method will return the value with those 
+  // top bits cleared.  
+  //
+  // GetValueAsUnsigned returns the actual value, with the 

Nit: no `//` 



Comment at: lldb/source/API/SBValue.cpp:932-934
+if (!success) {
+  return fail_value;
+}

Nit: no braces around single life if for consistency with lines 935 and 393.



Comment at: lldb/source/API/SBValue.cpp:935-940
+ProcessSP process_sp = m_opaque_sp->GetProcessSP();
+if (!process_sp)
+  return ret_val;
+ABISP abi_sp = process_sp->GetABI();
+if (abi_sp)
+  return abi_sp->FixCodeAddress(ret_val);

Nit^3: why not do the same as in `GetStrippedPointerValue` and 
`CreateValueObjectFromAddress`:

```
if (ProcessSP process_sp = m_opaque_sp->GetProcessSP())
  if (ABISP abi_sp = process_sp->GetABI())
return abi_sp->FixCodeAddress(ret_val);
```



Comment at: lldb/source/API/SBValue.cpp:938-940
+ABISP abi_sp = process_sp->GetABI();
+if (abi_sp)
+  return abi_sp->FixCodeAddress(ret_val);

Nit^2: in other places where I upstreamed `FixCodeAddress` calls I went with 
the following LLVM pattern:

```
if (ABISP abi_sp = process_sp->GetABI())
  return abi_sp->FixCodeAddress(ret_val);
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142792/new/

https://reviews.llvm.org/D142792

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


[Lldb-commits] [PATCH] D142792: Add SBValue::GetValueAsAddress(), strip off ptrauth, TBI, MTE bits on AArch64 systems

2023-01-27 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda created this revision.
jasonmolenda added a reviewer: DavidSpickett.
jasonmolenda added a project: LLDB.
Herald added subscribers: omjavaid, JDevlieghere, kristof.beyls.
Herald added a project: All.
jasonmolenda requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch adds a new method to SBValue, `GetValueAsAddress()`, which will take 
the uint64_t value in the SBValue and run it through the ABI's FixAddress 
method to clear any TBI/MTE/ptrauth bits on AArch64 targets.  Script authors 
may want access to both the actual uint64_t value, and the address that will be 
accessed, in an SBValue, so I added a new method in addition to 
GetValueAsUnsigned to provide this.

I currently have SBValue::GetValueAsAddress NOT perform a type check, and 
possibly I should have it check the type's IsPointerType() before doing this, 
but at the same time if the script/driver is calling this method, it's probably 
best to just do that.

There's also changes to methods like 
`ValueObject::CreateValueObjectFromAddress` so we can get SBValue::Dereference 
and such to behave correct when you have an SBValue created from a signed 
pointer.

I have the attached test case set to run on any AArch64 system; on Darwin we do 
the same pointer stripping on any process regardless if it is using pointer 
auth (that is, for both "arm64" and "arm64e").  On Linux, a non-ptrauth process 
may not have an address mask and this test may fail because the bits I mask 
into the top nibble in the test program are not removed by GetValueAsAddress(). 
 I'm not sure exactly, but I can remove this test from running on Linux, or add 
a check for `isAArch64PAuth` or something.  This program never actually 
dereferences this pointer value with bits in the high nibble set, it's only set 
up for lldb to manipulate.

We've used this API inside Apple for a bit and it has worked well for our API 
users; of course if there is consensus that it should be done differently we'll 
find a way to handle that internally.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142792

Files:
  lldb/bindings/interface/SBValue.i
  lldb/include/lldb/API/SBValue.h
  lldb/include/lldb/Core/ValueObject.h
  lldb/source/API/SBValue.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/DataFormatters/ValueObjectPrinter.cpp
  lldb/test/API/api/clear-sbvalue-nonadressable-bits/Makefile
  
lldb/test/API/api/clear-sbvalue-nonadressable-bits/TestClearSBValueNonAddressableBits.py
  lldb/test/API/api/clear-sbvalue-nonadressable-bits/main.c

Index: lldb/test/API/api/clear-sbvalue-nonadressable-bits/main.c
===
--- /dev/null
+++ lldb/test/API/api/clear-sbvalue-nonadressable-bits/main.c
@@ -0,0 +1,15 @@
+#include 
+int main()
+{
+  int v = 5;
+  int *v_p = &v;
+
+  // Add some metadata in the top byte (this will crash unless the
+  // test is running with TBI enabled, but we won't dereference it)
+
+  intptr_t scratch = (intptr_t) v_p;
+  scratch |= (3ULL << 60);
+  int *v_invalid_p = (int *)scratch;
+
+  return v; // break here
+}
Index: lldb/test/API/api/clear-sbvalue-nonadressable-bits/TestClearSBValueNonAddressableBits.py
===
--- /dev/null
+++ lldb/test/API/api/clear-sbvalue-nonadressable-bits/TestClearSBValueNonAddressableBits.py
@@ -0,0 +1,35 @@
+"""Test that SBValue clears non-addressable bits"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestClearSBValueNonAddressableBits(TestBase):
+
+NO_DEBUG_INFO_TESTCASE = True
+
+# On AArch64 systems, the top bits that are not used for
+# addressing may be used for TBI, MTE, and/or pointer 
+# authentication.
+@skipIf(archs=no_match(['aarch64', 'arm64', 'arm64e']))
+
+def test(self):
+self.source = 'main.c'
+self.build()
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
+   "break here", lldb.SBFileSpec(self.source, False))
+
+if self.TraceOn():
+self.runCmd ("v v v_p v_invalid_p")
+self.runCmd ("v &v &v_p &v_invalid_p")
+
+frame = thread.GetFrameAtIndex(0)
+v_p = frame.FindVariable("v_p")
+v_invalid_p = frame.FindVariable("v_invalid_p")
+
+self.assertEqual(v_p.GetValueAsUnsigned(), v_invalid_p.GetValueAsAddress())
+self.assertNotEqual(v_invalid_p.GetValueAsUnsigned(), v_invalid_p.GetValueAsAddress())
+
+self.assertEqual(5, v_p.Dereference().GetValueAsUnsigned())
+self.assertEqual(5, v_invalid_p.Dereference().GetValueAsUnsigned())
Index: lldb/test/API/api/clear-sbvalue-nonadressable-bits/Makefile
===
--- /dev/null
+++ lldb/test/API/api/clear-sbvalue-nonadressable-bits/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include

[Lldb-commits] [lldb] 9000a36 - Manual DWARF index: don't skip over -gmodules debug info

2023-01-27 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2023-01-27T15:59:46-08:00
New Revision: 9000a36f5cbd2993cd9c746610f7666ed173991a

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

LOG: Manual DWARF index: don't skip over -gmodules debug info

This fixes a regression introduced by
https://reviews.llvm.org/D131437. The intention of the patch was to
avoid indexing DWO skeleton units, but it also skipped over full DWARF
compile units linked via a -gmodules DW_AT_dwo_name attribute. This
patch restores the functionality and adds a test for it.

Differential Revision: https://reviews.llvm.org/D142683

Added: 
lldb/test/Shell/SymbolFile/DWARF/Inputs/pch.h
lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index a70628a3866a..bc55b093e894 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -223,6 +223,8 @@ class DWARFUnit : public lldb_private::UserID {
 
   uint8_t GetUnitType() const { return m_header.GetUnitType(); }
   bool IsTypeUnit() const { return m_header.IsTypeUnit(); }
+  /// Note that this check only works for DWARF5+.
+  bool IsSkeletonUnit() const { return GetUnitType() == 
llvm::dwarf::DW_UT_skeleton; }
 
   std::optional GetStringOffsetSectionItem(uint32_t index) const;
 

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index a31622fc8b99..90ac5afb179a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -162,12 +162,13 @@ void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, 
SymbolFileDWARFDwo *dwp,
   // though as some functions have template parameter types and other things
   // that cause extra copies of types to be included, but we should find these
   // types in the .dwo file only as methods could have return types removed and
-  // we don't have to index incomplete types from the skeletone compile unit.
+  // we don't have to index incomplete types from the skeleton compile unit.
   if (unit.GetDWOId()) {
+// Index the .dwo or dwp instead of the skeleton unit.
 if (SymbolFileDWARFDwo *dwo_symbol_file = unit.GetDwoSymbolFile()) {
   // Type units in a dwp file are indexed separately, so we just need to
-  // process the split unit here. However, if the split unit is in a dwo 
file,
-  // then we need to process type units here.
+  // process the split unit here. However, if the split unit is in a dwo
+  // file, then we need to process type units here.
   if (dwo_symbol_file == dwp) {
 IndexUnitImpl(unit.GetNonSkeletonUnit(), cu_language, set);
   } else {
@@ -175,11 +176,22 @@ void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, 
SymbolFileDWARFDwo *dwp,
 for (size_t i = 0; i < dwo_info.GetNumUnits(); ++i)
   IndexUnitImpl(*dwo_info.GetUnitAtIndex(i), cu_language, set);
   }
+  return;
 }
-  } else {
-// We either have a normal compile unit which we want to index.
-IndexUnitImpl(unit, cu_language, set);
+// This was a DWARF5 skeleton CU and the .dwo file couldn't be located.
+if (unit.GetVersion() >= 5 && unit.IsSkeletonUnit())
+  return;
+
+// Either this is a DWARF 4 + fission CU with the .dwo file
+// missing, or it's a -gmodules pch or pcm. Try to detect the
+// latter by checking whether the first DIE is a DW_TAG_module.
+// If it's a pch/pcm, continue indexing it.
+if (unit.GetDIE(unit.GetFirstDIEOffset()).GetFirstChild().Tag() !=
+llvm::dwarf::DW_TAG_module)
+  return;
   }
+  // We have a normal compile unit which we want to index.
+  IndexUnitImpl(unit, cu_language, set);
 }
 
 void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/Inputs/pch.h 
b/lldb/test/Shell/SymbolFile/DWARF/Inputs/pch.h
new file mode 100644
index ..a478d907e837
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/Inputs/pch.h
@@ -0,0 +1,5 @@
+typedef int anchor_t;
+
+struct TypeFromPCH {
+  int field;
+};

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c 
b/lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c
new file mode 100644
index ..f42a5d3907df
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c
@@ -0,0 +1,18 @@
+// UNSUPPORTED: system-windows
+
+// Test that LLDB can follow DWO links produced by -gmodules debug
+// info to find a type in a precomp

[Lldb-commits] [PATCH] D142683: Manual DWARF index: don't skip over -gmodules debug info

2023-01-27 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9000a36f5cbd: Manual DWARF index: don't skip over 
-gmodules debug info (authored by aprantl).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D142683?vs=492852&id=492939#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142683/new/

https://reviews.llvm.org/D142683

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/test/Shell/SymbolFile/DWARF/Inputs/pch.h
  lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c


Index: lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c
@@ -0,0 +1,18 @@
+// UNSUPPORTED: system-windows
+
+// Test that LLDB can follow DWO links produced by -gmodules debug
+// info to find a type in a precompiled header.
+//
+// RUN: %clangxx_host -g -gmodules -fmodules -std=c99 -x c-header 
%S/Inputs/pch.h -g -c -o %t.pch
+// RUN: %clangxx_host -g -gmodules -fmodules -std=c99 -x c -include-pch %t.pch 
%s -c -o %t.o
+// RUN: %clangxx_host %t.o -o %t.exe
+// RUN: lldb-test symbols -dump-clang-ast -find type --language=C99 \
+// RUN:   -compiler-context 'AnyModule:*,Struct:TypeFromPCH' %t.exe | 
FileCheck %s
+
+anchor_t anchor;
+
+int main(int argc, char **argv) { return 0; }
+
+// CHECK: Found 1 type
+// CHECK: "TypeFromPCH"
+// CHECK: FieldDecl {{.*}} field
Index: lldb/test/Shell/SymbolFile/DWARF/Inputs/pch.h
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/Inputs/pch.h
@@ -0,0 +1,5 @@
+typedef int anchor_t;
+
+struct TypeFromPCH {
+  int field;
+};
Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -162,12 +162,13 @@
   // though as some functions have template parameter types and other things
   // that cause extra copies of types to be included, but we should find these
   // types in the .dwo file only as methods could have return types removed and
-  // we don't have to index incomplete types from the skeletone compile unit.
+  // we don't have to index incomplete types from the skeleton compile unit.
   if (unit.GetDWOId()) {
+// Index the .dwo or dwp instead of the skeleton unit.
 if (SymbolFileDWARFDwo *dwo_symbol_file = unit.GetDwoSymbolFile()) {
   // Type units in a dwp file are indexed separately, so we just need to
-  // process the split unit here. However, if the split unit is in a dwo 
file,
-  // then we need to process type units here.
+  // process the split unit here. However, if the split unit is in a dwo
+  // file, then we need to process type units here.
   if (dwo_symbol_file == dwp) {
 IndexUnitImpl(unit.GetNonSkeletonUnit(), cu_language, set);
   } else {
@@ -175,11 +176,22 @@
 for (size_t i = 0; i < dwo_info.GetNumUnits(); ++i)
   IndexUnitImpl(*dwo_info.GetUnitAtIndex(i), cu_language, set);
   }
+  return;
 }
-  } else {
-// We either have a normal compile unit which we want to index.
-IndexUnitImpl(unit, cu_language, set);
+// This was a DWARF5 skeleton CU and the .dwo file couldn't be located.
+if (unit.GetVersion() >= 5 && unit.IsSkeletonUnit())
+  return;
+
+// Either this is a DWARF 4 + fission CU with the .dwo file
+// missing, or it's a -gmodules pch or pcm. Try to detect the
+// latter by checking whether the first DIE is a DW_TAG_module.
+// If it's a pch/pcm, continue indexing it.
+if (unit.GetDIE(unit.GetFirstDIEOffset()).GetFirstChild().Tag() !=
+llvm::dwarf::DW_TAG_module)
+  return;
   }
+  // We have a normal compile unit which we want to index.
+  IndexUnitImpl(unit, cu_language, set);
 }
 
 void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -223,6 +223,8 @@
 
   uint8_t GetUnitType() const { return m_header.GetUnitType(); }
   bool IsTypeUnit() const { return m_header.IsTypeUnit(); }
+  /// Note that this check only works for DWARF5+.
+  bool IsSkeletonUnit() const { return GetUnitType() == 
llvm::dwarf::DW_UT_skeleton; }
 
   std::optional GetStringOffsetSectionItem(uint32_t index) const;
 


Index: lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c
@@ -

[Lldb-commits] [lldb] f58de21 - [lldb][Test] TestVSCode_completions.py: fix expected type strings

2023-01-27 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-01-27T23:21:52Z
New Revision: f58de2125caf75ec0d40bc3e094a93c0b314a66a

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

LOG: [lldb][Test] TestVSCode_completions.py: fix expected type strings

Fixes build failures following https://reviews.llvm.org/D141828

Added: 


Modified: 
lldb/test/API/tools/lldb-vscode/completions/TestVSCode_completions.py

Removed: 




diff  --git 
a/lldb/test/API/tools/lldb-vscode/completions/TestVSCode_completions.py 
b/lldb/test/API/tools/lldb-vscode/completions/TestVSCode_completions.py
index ca9860d4633c..fd215c67c940 100644
--- a/lldb/test/API/tools/lldb-vscode/completions/TestVSCode_completions.py
+++ b/lldb/test/API/tools/lldb-vscode/completions/TestVSCode_completions.py
@@ -41,7 +41,7 @@ def test_completions(self):
 [
 {
 "text": "var",
-"label": "var -- vector, allocator>, allocator, allocator>>> &",
+"label": "var -- vector > &",
 }
 ],
 [{"text": "var1", "label": "var1 -- int &"}],
@@ -66,7 +66,7 @@ def test_completions(self):
 [
 {
 "text": "var",
-"label": "var -- vector, allocator >, allocator, allocator > > > &",
+"label": "var -- vector > &",
 }
 ],
 )



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


[Lldb-commits] [PATCH] D141828: [lldb] Add support for DW_AT_default_value in template params

2023-01-27 Thread Michael Buch via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGce6a56e66781: Reland "[lldb] Add support for 
DW_AT_default_value in template params" (authored by Michael137).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141828/new/

https://reviews.llvm.org/D141828

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  
lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py
  
lldb/test/API/commands/expression/import-std-module/retry-with-std-module/TestRetryWithStdModule.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
  lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
  lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_default_value-test.yaml

Index: lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_default_value-test.yaml
===
--- /dev/null
+++ lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_default_value-test.yaml
@@ -0,0 +1,314 @@
+# template 
+# class foo {};
+#
+# template  class CT = foo>
+# class baz {};
+#
+# template >
+# class bar {};
+#
+# int main() {
+# bar<> br;
+# baz<> bz;
+# return 0;
+# }
+#
+# YAML generated on Linux using obj2yaml on the above program
+# compiled with Clang.
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_AARCH64
+  SectionHeaderStringTable: .strtab
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+AddressAlign:0x4
+Content: FF4300D1E0031F2AFF0F00B9FF430091C0035FD6
+  - Name:.linker-options
+Type:SHT_LLVM_LINKER_OPTIONS
+Flags:   [ SHF_EXCLUDE ]
+AddressAlign:0x1
+Content: ''
+  - Name:.debug_abbrev
+Type:SHT_PROGBITS
+AddressAlign:0x1
+Content: 011101252513050325721710171B25111B12067317022E0B1206401803253A0B3B0B49133F19033400021803253A0B3B0B491304240003253E0B0B0B050201360B03250B0B3A0B3B0B062F00491303251E19073000491303251E191C0D083000491303251E191C0F09020003253C190A8682010003251E1990422500
+  - Name:.debug_info
+Type:SHT_PROGBITS
+AddressAlign:0x1
+Content: 7F000500010801002100010200140002001400016F03000B49000302910B05000C4D000302910A0E000D780404050405050D010009066E000707490008030872000A010676000C000406080104090201090B0505110100050A0F10
+  - Name:.debug_str_offsets
+Type:SHT_PROGBITS
+AddressAlign:0x1
+Content: 4C000500
+  - Name:.comment
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x1
+EntSize: 0x1
+Content: 00636C616E672076657273696F6E2031362E302E30202868747470733A2F2F6769746875622E636F6D2F6C6C766D2F6C6C766D2D70726F6A65637420343764323862376138323638653337616130646537366238353966343530386533646261633663652900
+  - Name:.note.GNU-stack
+Type:SHT_PROGBITS
+AddressAlign:0x1
+  - Name:.eh_frame
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC ]
+AddressAlign:0x8
+Content: 117A5200017C1E011B0C1F001800180014440E104C0E
+  - Name:.debug_line
+Type:SHT_PROGBITS
+AddressAlign:0x1
+Content: 5800050008003700010101FB0E0D000101010100010101011F0103011F020F051E010019537E33C1D1006B79E3D1C33D6EE6A3040902030A0105050ABD0208000101
+  - Name:.debug_line_str
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x1
+EntSize: 0x1
+Content: 2F686F6D652F6761726465690064656661756C74732E63707000
+  - Name:.rela.debug_info
+Type:SHT_RELA
+Flags:   [ SHF_INFO_LINK ]
+Link:.symtab
+AddressAlign:0x8
+Info:.debug_info
+Relocations:
+  - Offset:  

[Lldb-commits] [lldb] ce6a56e - Reland "[lldb] Add support for DW_AT_default_value in template params"

2023-01-27 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-01-27T22:49:46Z
New Revision: ce6a56e66781eaad11c7285d37c1c410414676de

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

LOG: Reland "[lldb] Add support for DW_AT_default_value in template params"

**Summary**

This patch makes LLDB understand the `DW_AT_default_value` on
template argument DIEs. As a result, type summaries will no
longer contain the defaulted template arguments, reducing
noise substantially. E.g.,

Before:
```
(lldb) v nested
(std::vector, 
std::allocator >, std::allocator, std::allocator > > >, 
std::allocator, 
std::allocator >, std::allocator, std::allocator  > > > > >) nested = size=0 {}
```

After:
```
(lldb) v nested
(std::vector > >) nested = size=0 {}
```

See discussion in https://reviews.llvm.org/D140423

**Testing**

* Adjust API tests
* Added unit-test

Differential Revision: https://reviews.llvm.org/D141828

Added: 
lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_default_value-test.yaml

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py

lldb/test/API/commands/expression/import-std-module/retry-with-std-module/TestRetryWithStdModule.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 49c8fae64ed8a..4429b4fcae2a0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2003,6 +2003,7 @@ bool DWARFASTParserClang::ParseTemplateDIE(
 CompilerType clang_type;
 uint64_t uval64 = 0;
 bool uval64_valid = false;
+bool is_default_template_arg = false;
 if (num_attributes > 0) {
   DWARFFormValue form_value;
   for (size_t i = 0; i < num_attributes; ++i) {
@@ -2033,6 +2034,10 @@ bool DWARFASTParserClang::ParseTemplateDIE(
 uval64 = form_value.Unsigned();
   }
   break;
+case DW_AT_default_value:
+  if (attributes.ExtractFormValueAtIndex(i, form_value))
+is_default_template_arg = form_value.Boolean();
+  break;
 default:
   break;
 }
@@ -2058,16 +2063,19 @@ bool DWARFASTParserClang::ParseTemplateDIE(
   template_param_infos.InsertArg(
   name,
   clang::TemplateArgument(ast, llvm::APSInt(apint, !is_signed),
-  ClangUtil::GetQualType(clang_type)));
+  ClangUtil::GetQualType(clang_type),
+  is_default_template_arg));
 } else {
   template_param_infos.InsertArg(
-  name,
-  clang::TemplateArgument(ClangUtil::GetQualType(clang_type)));
+  name, clang::TemplateArgument(ClangUtil::GetQualType(clang_type),
+/*isNullPtr*/ false,
+is_default_template_arg));
 }
   } else {
 auto *tplt_type = m_ast.CreateTemplateTemplateParmDecl(template_name);
 template_param_infos.InsertArg(
-name, clang::TemplateArgument(clang::TemplateName(tplt_type)));
+name, clang::TemplateArgument(clang::TemplateName(tplt_type),
+  is_default_template_arg));
   }
 }
   }

diff  --git 
a/lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py
 
b/lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py
index 8f40e92e70d24..3e8910a79e4be 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py
@@ -31,22 +31,16 @@ def test(self):
 ValueCheck(value="2"),
 ]
 
-# The debug info vector type doesn't know about the default template
-# arguments,

[Lldb-commits] [PATCH] D142513: [lldb][test] Set minimum compiler_versions

2023-01-27 Thread Dave Lee via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG47f0384bb969: [lldb][test] Set minimum compiler_versions 
(authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142513/new/

https://reviews.llvm.org/D142513

Files:
  
lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
  lldb/test/API/lang/objc/objc_direct-methods/TestObjCDirectMethods.py


Index: lldb/test/API/lang/objc/objc_direct-methods/TestObjCDirectMethods.py
===
--- lldb/test/API/lang/objc/objc_direct-methods/TestObjCDirectMethods.py
+++ lldb/test/API/lang/objc/objc_direct-methods/TestObjCDirectMethods.py
@@ -1,6 +1,6 @@
 from lldbsuite.test import lldbinline
 from lldbsuite.test import decorators
 
-decor = [decorators.skipIf(compiler="clang", compiler_version=['<', '13.0'])]
+decor = [decorators.skipIf(compiler="clang", compiler_version=['<', '16.0'])]
 lldbinline.MakeInlineTest(
 __file__, globals(), decor)
Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
@@ -28,7 +28,8 @@
 children=self.check_string_vec_children())
 
 @add_test_categories(["libc++"])
-@skipIf(compiler=no_match("clang"), compiler_version=['<', '16.0'])
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler="clang", compiler_version=['<', '16.0'])
 def test_with_run_command(self):
 """Test that std::ranges::ref_view is formatted correctly when printed.
 """
Index: 
lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
===
--- 
lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
+++ 
lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
@@ -12,6 +12,7 @@
 
 @add_test_categories(["libc++"])
 @skipIf(compiler=no_match("clang"))
+@skipIf(compiler="clang", compiler_version=['<', '12.0'])
 def test(self):
 self.build()
 
Index: 
lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
===
--- 
lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
+++ 
lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
@@ -12,6 +12,7 @@
 
 @add_test_categories(["libc++"])
 @skipIf(compiler=no_match("clang"))
+@skipIf(compiler="clang", compiler_version=['<', '12.0'])
 def test(self):
 self.build()
 
Index: 
lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
===
--- 
lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
+++ 
lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
@@ -11,6 +11,7 @@
 
 @add_test_categories(["libc++"])
 @skipIf(compiler=no_match("clang"))
+@skipIf(compiler="clang", compiler_version=['<', '12.0'])
 def test(self):
 self.build()
 


Index: lldb/test/API/lang/objc/objc_direct-methods/TestObjCDirectMethods.py
===
--- lldb/test/API/lang/objc/objc_direct-methods/TestObjCDirectMethods.py
+++ lldb/test/API/lang/objc/objc_direct-methods/TestObjCDirectMethods.py
@@ -1,6 +1,6 @@
 from lldbsuite.test import lldbinline
 from lldbsuite.test import decorators
 
-decor = [decorators.skipIf(compiler="clang", compiler_version=['<', '13.0'])]
+decor = [decorators.skipIf(compiler="clang", compiler_version=['<', '16.0'])]
 lldbinline.MakeInlineTest(
 __file__, globals(), decor)
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/Te

[Lldb-commits] [lldb] 47f0384 - [lldb][test] Set minimum compiler_versions

2023-01-27 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2023-01-27T14:29:45-08:00
New Revision: 47f0384bb96964e1416a52fc03b184a37fe05588

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

LOG: [lldb][test] Set minimum compiler_versions

Set compiler_versions on these tests, as they fail if tested on lower compiler
versions versions.

Differential Revision: https://reviews.llvm.org/D142513

Added: 


Modified: 

lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py

lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py

lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
lldb/test/API/lang/objc/objc_direct-methods/TestObjCDirectMethods.py

Removed: 




diff  --git 
a/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
index d375e06c7964c..cf2f63d6b669b 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
@@ -11,6 +11,7 @@ class TestDbgInfoContentDeque(TestBase):
 
 @add_test_categories(["libc++"])
 @skipIf(compiler=no_match("clang"))
+@skipIf(compiler="clang", compiler_version=['<', '12.0'])
 def test(self):
 self.build()
 

diff  --git 
a/lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
index 32b838c9e63c8..0c6d62a4267f9 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
@@ -12,6 +12,7 @@ class TestDbgInfoContentList(TestBase):
 
 @add_test_categories(["libc++"])
 @skipIf(compiler=no_match("clang"))
+@skipIf(compiler="clang", compiler_version=['<', '12.0'])
 def test(self):
 self.build()
 

diff  --git 
a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
index 7da615c3084d5..c4cfedb5e597d 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
@@ -12,6 +12,7 @@ class TestDbgInfoContentVector(TestBase):
 
 @add_test_categories(["libc++"])
 @skipIf(compiler=no_match("clang"))
+@skipIf(compiler="clang", compiler_version=['<', '12.0'])
 def test(self):
 self.build()
 

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
index 1fc8026babb9b..ff897b2ca875b 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
@@ -28,7 +28,8 @@ def check_foo(self):
 children=self.check_string_vec_children())
 
 @add_test_categories(["libc++"])
-@skipIf(compiler=no_match("clang"), compiler_version=['<', '16.0'])
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler="clang", compiler_version=['<', '16.0'])
 def test_with_run_command(self):
 """Test that std::ranges::ref_view is formatted correctly when printed.
 """

diff  --git 
a/lldb/test/API/lang/objc/objc_direct-methods/TestObjCDirectMethods.py 
b/lldb/test/API/lang/objc/objc_direct-methods/TestObjCDirectMethods.py
index ed89377d9b7ac..c7e83becba66c 100644
--- a/lldb/test/API/lang/objc/objc_direct-methods/TestObjCDirectMethods.py
+++ b/lldb/test/API/lang/objc/objc_direct-methods/TestObjCDirectMethods.py
@@ -1,6 +1,6 @@
 from lldbsuite.test import lldbinline
 from lldbsuite.test im

[Lldb-commits] [PATCH] D142733: Add _Optional as fast qualifier

2023-01-27 Thread Richard Smith - zygoloid via Phabricator via lldb-commits
rsmith added a comment.

Including a link to the RFC 
(https://discourse.llvm.org/t/rfc-optional-a-type-qualifier-to-indicate-pointer-nullability/68004/2)
 in each of the patches in this series would be helpful.

Assuming that we want to go in this direction, it seems quite expensive to 
model this as a fast qualifier rather than an extended qualifier. Are these 
annotations expected to be so common that it's better to increase the alignment 
of all types than perform extra allocations and indirections for `_Optional` 
qualifiers? Have you measured the memory impact of increasing the alignment of 
`Type`? I think that should be a prerequisite to adding any new kind of fast 
qualifier, and if we do add such a qualifier, we should select carefully which 
qualifier gets this precious bit in `QualType`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142733/new/

https://reviews.llvm.org/D142733

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


[Lldb-commits] [PATCH] D142683: Manual DWARF index: don't skip over -gmodules debug info

2023-01-27 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Much better, thanks for making sure we don't end up indexing real skeleton 
units as they cause problems if they do get indexed.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142683/new/

https://reviews.llvm.org/D142683

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


[Lldb-commits] [PATCH] D138618: [LLDB] Enable 64 bit debug/type offset

2023-01-27 Thread Alexander Yermolovich via Phabricator via lldb-commits
ayermolo added a comment.

In D138618#4086789 , @labath wrote:

> I'm sorry, but that patch does not fix the problem I am trying to point out. 
> In fact, I think it makes things a lot worse.
>
> We clearly have some kind of a communication problem, but I am running out of 
> ideas of what can I do about it. Let me try rephrasing it one more time:
>
> - this patch creates two path for converting a DIERef to a user_id_t -- a) 
> `ref.get_id()`; and b) `dwarf.GetUID(ref)`
> - of those two ways, one is clearly more intuitive
> - of those two ways, one is always correct
> - those two ways aren't the same -- (a) is simpler; (b) is correct
> - you can't fix that by simply taking (b) away. All that does is make the API 
> misuse even more likely. That patch essentially just deletes GetUID, and 
> inlines it into all its callers.
>
> Forget about the what the code does for a moment, and tell me which of these 
> snippets looks better:
> i)
>
>   if (IsValid())
> return GetDWARF()->GetUID(*this);
>
> ii)
>
>   const std::optional &ref = this->GetDIERef();
>   if (ref)
> return DIERef(GetID(), ref->section(), ref->die_offset()).get_id();
>
> iii)
>
>   if (IsValid())
> return GetDIERef()->get_id();
>
> Now look up the implementation and tell me which one is correct.

Thank you for providing an example. Yes sometimes it's hard to communicate over 
comments.
In this context yes first one is better.
Question is what should it look "under the hood".
For example:
DIERef::Decode
SymbolFileDWARF::GetUID
SymbolFileDWARF::DecodeUID
There are all these bit shifts scattered around.

If this is such a blocker I did expand on your diff, and added 64 bit support 
(it still has to be cleaned up a bit like various static constexpr probably 
moved out of DIERef to #define in dwarfh, but for illustrative purposes) 
https://reviews.llvm.org/D142779


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138618/new/

https://reviews.llvm.org/D138618

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


[Lldb-commits] [PATCH] D142779: [LLDB][DRAFT] Add 64bit support to LLDB

2023-01-27 Thread Alexander Yermolovich via Phabricator via lldb-commits
ayermolo created this revision.
Herald added subscribers: hoy, modimo, wenlei.
Herald added a project: All.
ayermolo requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Test Plan:


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142779

Files:
  lldb/include/lldb/Core/dwarf.h
  lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
  lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
  lldb/unittests/Expression/DWARFExpressionTest.cpp

Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -683,7 +683,7 @@
 - AbbrCode:0x1
   Values:
 - CStr:   "dwo_unit"
-- Value:   0x01020304
+- Value:   0x0120304
 - AbbrCode:0x0
 )";
 
Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
===
--- lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
+++ lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
@@ -8,7 +8,7 @@
 # RUN:   -o exit | FileCheck %s
 
 # Failure was the block range 1..2 was not printed plus:
-# error: DW_AT_range-DW_FORM_sec_offset.s.tmp {0x003f}: DIE has DW_AT_ranges(0xc) attribute, but range extraction failed (missing or invalid range list table), please file a bug and attach the file at the start of this error message
+# error: DW_AT_range-DW_FORM_sec_offset.s.tmp {0x003f}: DIE has DW_AT_ranges(0xc) attribute, but range extraction failed (missing or invalid range list table), please file a bug and attach the file at the start of this error message
 
 # CHECK-LABEL: image lookup -v -s lookup_rnglists
 # CHECK:  Function: id = {0x0029}, name = "rnglists", range = [0x-0x0003)
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -41,7 +41,7 @@
   DWARFDIE
   GetDIE(const DIERef &die_ref) override;
 
-  std::optional GetDwoNum() override { return GetID() >> 32; }
+  std::optional GetDwoNum() override { return GetID(); }
 
   lldb::offset_t
   GetVendorDWARFOpcodeSize(const lldb_private::DataExtractor &data,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -29,7 +29,7 @@
 : SymbolFileDWARF(objfile, objfile->GetSectionList(
/*update_module_section_list*/ false)),
   m_base_symbol_file(base_symbol_file) {
-  SetID(user_id_t(id) << 32);
+  SetID(id);
 
   // Parsing of the dwarf unit index is not thread-safe, so we need to prime it
   // to enable subsequent concurrent lookups.
@@ -42,7 +42,7 @@
   if (auto *unit_contrib = entry->getContribution())
 return llvm::dyn_cast_or_null(
 DebugInfo().GetUnitAtOffset(DIERef::Section::DebugInfo,
-unit_contrib->getOffset32()));
+unit_contrib->getOffset()));
 }
 return nullptr;
   }
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -17,9 +17,9 @@
 #include 
 #include 
 
+#include "SymbolFileDWARF.h"
 #include "UniqueDWARFASTType.h"
 
-class SymbolFileDWARF;
 class DWARFCompileUnit;
 class DWARFDebugAranges;
 class DWARFDeclContext;
@@ -208,9 +208,9 @@
   /// the given index contains.
   lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override;
 
-  static uint32_t GetOSOIndexFromUserID(lldb::user_id_t uid) {
-return (uint32_t)((uid >> 32ull) - 1ull);
-  }
+  lldb::user_id_t GetUID(SymbolFileDWARF::DecodedUID decoded_uid);
+
+  std::optional DecodeUID(lldb::user_id_t uid);
 
   static SymbolFileDWARF *GetSymbolFileAsSymbolFileDWARF(SymbolFile *sym_file);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/S

[Lldb-commits] [PATCH] D142683: Manual DWARF index: don't skip over -gmodules debug info

2023-01-27 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 492852.
aprantl added a comment.

Added another heuristic to distinguish gmodules and fission.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142683/new/

https://reviews.llvm.org/D142683

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/test/Shell/SymbolFile/DWARF/Inputs/pch.h
  lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c


Index: lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c
@@ -0,0 +1,18 @@
+// UNSUPPORTED: system-windows
+
+// Test that LLDB can follow DWO links produced by -gmodules debug
+// info to find a type in a precompiled header.
+// 
+// RUN: %clangxx_host -g -gmodules -fmodules -std=c99 -x c-header 
%S/Inputs/pch.h -g -c -o %t.pch
+// RUN: %clangxx_host -g -gmodules -fmodules -std=c99 -x c -include-pch %t.pch 
%s -c -o %t.o
+// RUN: %clangxx_host %t.o -o %t.exe
+// RUN: lldb-test symbols -dump-clang-ast -find type --language=C99 \
+// RUN:   -compiler-context 'AnyModule:*,Struct:TypeFromPCH' %t.exe | 
FileCheck %s
+
+anchor_t anchor;
+
+int main(int argc, char **argv) { return 0; }
+
+// CHECK: Found 1 type
+// CHECK: "TypeFromPCH"
+// CHECK: FieldDecl {{.*}} field
Index: lldb/test/Shell/SymbolFile/DWARF/Inputs/pch.h
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/Inputs/pch.h
@@ -0,0 +1,5 @@
+typedef int anchor_t;
+
+struct TypeFromPCH {
+  int field;
+};
Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -162,12 +162,13 @@
   // though as some functions have template parameter types and other things
   // that cause extra copies of types to be included, but we should find these
   // types in the .dwo file only as methods could have return types removed and
-  // we don't have to index incomplete types from the skeletone compile unit.
+  // we don't have to index incomplete types from the skeleton compile unit.
   if (unit.GetDWOId()) {
+// Index the .dwo or dwp instead of the skeleton unit.
 if (SymbolFileDWARFDwo *dwo_symbol_file = unit.GetDwoSymbolFile()) {
   // Type units in a dwp file are indexed separately, so we just need to
-  // process the split unit here. However, if the split unit is in a dwo 
file,
-  // then we need to process type units here.
+  // process the split unit here. However, if the split unit is in a dwo
+  // file, then we need to process type units here.
   if (dwo_symbol_file == dwp) {
 IndexUnitImpl(unit.GetNonSkeletonUnit(), cu_language, set);
   } else {
@@ -175,11 +176,21 @@
 for (size_t i = 0; i < dwo_info.GetNumUnits(); ++i)
   IndexUnitImpl(*dwo_info.GetUnitAtIndex(i), cu_language, set);
   }
+  return;
 }
-  } else {
-// We either have a normal compile unit which we want to index.
-IndexUnitImpl(unit, cu_language, set);
+// This was a DWARF5 skeleton CU and the .dwo file couldn't be located.
+if (unit.GetVersion() >= 5 && unit.IsSkeletonUnit())
+  return;
+
+// Either this is a DWARF 4 + fission CU with the .dwo file
+// missing, or it's a -gmodules pch or pcm. Try to detect the
+// latter by checking whether the first DIE is a DW_TAG_module.
+if (unit.GetDIE(unit.GetFirstDIEOffset()).GetFirstChild().Tag() !=
+llvm::dwarf::DW_TAG_module)
+  return;
   }
+  // We have a normal compile unit which we want to index.
+  IndexUnitImpl(unit, cu_language, set);
 }
 
 void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -223,6 +223,8 @@
 
   uint8_t GetUnitType() const { return m_header.GetUnitType(); }
   bool IsTypeUnit() const { return m_header.IsTypeUnit(); }
+  /// Note that this check only works for DWARF5+.
+  bool IsSkeletonUnit() const { return GetUnitType() == 
llvm::dwarf::DW_UT_skeleton; }
 
   std::optional GetStringOffsetSectionItem(uint32_t index) const;
 


Index: lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c
@@ -0,0 +1,18 @@
+// UNSUPPORTED: system-windows
+
+// Test that LLDB can follow DWO links produced by -gmodules debug
+// info to find a type in a precompiled header.
+// 
+// RUN: %clangxx_host -g -gmodules -fmodules -std=c99 -x c-header %S/Inputs/pch.h -g -

[Lldb-commits] [PATCH] D138618: [LLDB] Enable 64 bit debug/type offset

2023-01-27 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I'm sorry, but that patch does not fix the problem I am trying to point out. In 
fact, I think it makes things a lot worse.

We clearly have some kind of a communication problem, but I am running out of 
ideas of what can I do about it. Let me try rephrasing it one more time:

- this patch creates two path for converting a DIERef to a user_id_t -- a) 
`ref.get_id()`; and b) `dwarf.GetUID(ref)`
- of those two ways, one is clearly more intuitive
- of those two ways, one is always correct
- those two ways aren't the same -- (a) is simpler; (b) is correct
- you can't fix that by simply taking (b) away. All that does is make the API 
misuse even more likely. That patch essentially just deletes GetUID, and 
inlines it into all its callers.

Forget about the what the code does for a moment, and tell me which of these 
snippets looks better:
i)

  if (IsValid())
return GetDWARF()->GetUID(*this);

ii)

  const std::optional &ref = this->GetDIERef();
  if (ref)
return DIERef(GetID(), ref->section(), ref->die_offset()).get_id();

iii)

  if (IsValid())
return GetDIERef()->get_id();

Now look up the implementation and tell me which one is correct.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138618/new/

https://reviews.llvm.org/D138618

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


[Lldb-commits] [PATCH] D142775: [LLDB] Remove GetUID API

2023-01-27 Thread Alexander Yermolovich via Phabricator via lldb-commits
ayermolo updated this revision to Diff 492848.
ayermolo added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142775/new/

https://reviews.llvm.org/D142775

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -265,16 +265,6 @@
 
   DWARFDIE GetDIE(lldb::user_id_t uid);
 
-  lldb::user_id_t GetUID(const DWARFBaseDIE &die) {
-return GetUID(die.GetDIERef());
-  }
-
-  lldb::user_id_t GetUID(const std::optional &ref) {
-return ref ? GetUID(*ref) : LLDB_INVALID_UID;
-  }
-
-  lldb::user_id_t GetUID(DIERef ref);
-
   std::shared_ptr
   GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu,
  const DWARFDebugInfoEntry &cu_die);
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1404,10 +1404,6 @@
 decl_ctx);
 }
 
-user_id_t SymbolFileDWARF::GetUID(DIERef ref) {
-  return DIERef(GetID(), ref.section(), ref.die_offset()).get_id();
-}
-
 std::optional
 SymbolFileDWARF::DecodeUID(lldb::user_id_t uid) {
   // This method can be called without going through the symbol vendor so we
@@ -3601,8 +3597,10 @@
 return nullptr;
   }
 
+  const std::optional &ref = type_die_form.Reference().GetDIERef();
   auto type_sp = std::make_shared(
-  *this, GetUID(type_die_form.Reference()));
+  *this, ref ? DIERef(GetID(), ref->section(), ref->die_offset()).get_id()
+ : LLDB_INVALID_UID);
 
   if (use_type_size_for_value && type_sp->GetType()) {
 DWARFExpression *location = location_list.GetMutableExpressionAtAddress();
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
@@ -70,8 +70,10 @@
 }
 
 lldb::user_id_t DWARFBaseDIE::GetID() const {
-  if (IsValid())
-return GetDWARF()->GetUID(*this);
+  const std::optional &ref = this->GetDIERef();
+  if (ref)
+return DIERef(GetID(), ref->section(), ref->die_offset()).get_id();
+
   return LLDB_INVALID_UID;
 }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -517,6 +517,14 @@
   return UpdateSymbolContextScopeForType(sc, die, type_sp);
 }
 
+namespace {
+lldb::user_id_t getUIDHelper(SymbolFileDWARF &dwarf, const DWARFBaseDIE &die) {
+  const std::optional &ref = die.GetDIERef();
+  return ref ? DIERef(dwarf.GetID(), ref->section(), ref->die_offset()).get_id()
+ : LLDB_INVALID_UID;
+}
+} // namespace
+
 lldb::TypeSP
 DWARFASTParserClang::ParseTypeModifier(const SymbolContext &sc,
const DWARFDIE &die,
@@ -731,10 +739,11 @@
 }
   }
 
-  type_sp = dwarf->MakeType(
-  die.GetID(), attrs.name, attrs.byte_size, nullptr,
-  dwarf->GetUID(attrs.type.Reference()), encoding_data_type, &attrs.decl,
-  clang_type, resolve_state, TypePayloadClang(GetOwningClangModule(die)));
+  type_sp = dwarf->MakeType(die.GetID(), attrs.name, attrs.byte_size, nullptr,
+getUIDHelper(*dwarf, attrs.type.Reference()),
+encoding_data_type, &attrs.decl, clang_type,
+resolve_state,
+TypePayloadClang(GetOwningClangModule(die)));
 
   dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
   return type_sp;
@@ -835,7 +844,7 @@
   LinkDeclContextToDIE(TypeSystemClang::GetDeclContextForType(clang_type), die);
 
   type_sp = dwarf->MakeType(die.GetID(), attrs.name, attrs.byte_size, nullptr,
-dwarf->GetUID(attrs.type.Reference()),
+getUIDHelper(*dwarf, attrs.type.Reference()),
 Type::eEncodingIsUID, &attrs.decl, clang_type,
 Type::ResolveState::Forward,
 TypePayloadClang(GetOwningClangModule(die)));
@@ -1334,10 +1343,10 @@
 m_ast.CreateArrayType(array_element_type, 0, attrs.is_vector);
   }
   ConstString empty_name;
-  TypeSP type_sp =
-  dwarf->MakeType(die.GetID(), empty_name, array_element_bit_stride / 8,
- 

[Lldb-commits] [PATCH] D138618: [LLDB] Enable 64 bit debug/type offset

2023-01-27 Thread Alexander Yermolovich via Phabricator via lldb-commits
ayermolo added a comment.

Created commit that removes getUID(...) https://reviews.llvm.org/D142775
Seems like it's isolated to SymbolFile and DWARF code.
So now userid goes through DIERef.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138618/new/

https://reviews.llvm.org/D138618

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


[Lldb-commits] [PATCH] D142775: [LLDB] Remove GetUID API

2023-01-27 Thread Alexander Yermolovich via Phabricator via lldb-commits
ayermolo created this revision.
Herald added a reviewer: shafik.
Herald added subscribers: hoy, modimo, wenlei.
Herald added a project: All.
ayermolo requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Removed the GetUID API to make it explicit that ID creation goes through DIERef.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142775

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -265,16 +265,6 @@
 
   DWARFDIE GetDIE(lldb::user_id_t uid);
 
-  lldb::user_id_t GetUID(const DWARFBaseDIE &die) {
-return GetUID(die.GetDIERef());
-  }
-
-  lldb::user_id_t GetUID(const std::optional &ref) {
-return ref ? GetUID(*ref) : LLDB_INVALID_UID;
-  }
-
-  lldb::user_id_t GetUID(DIERef ref);
-
   std::shared_ptr
   GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu,
  const DWARFDebugInfoEntry &cu_die);
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1404,10 +1404,6 @@
 decl_ctx);
 }
 
-user_id_t SymbolFileDWARF::GetUID(DIERef ref) {
-  return DIERef(GetID(), ref.section(), ref.die_offset()).get_id();
-}
-
 std::optional
 SymbolFileDWARF::DecodeUID(lldb::user_id_t uid) {
   // This method can be called without going through the symbol vendor so we
@@ -3601,8 +3597,10 @@
 return nullptr;
   }
 
+  const std::optional &ref = type_die_form.Reference().GetDIERef();
   auto type_sp = std::make_shared(
-  *this, GetUID(type_die_form.Reference()));
+  *this, ref ? DIERef(GetID(), ref->section(), ref->die_offset()).get_id()
+ : LLDB_INVALID_UID);
 
   if (use_type_size_for_value && type_sp->GetType()) {
 DWARFExpression *location = location_list.GetMutableExpressionAtAddress();
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
@@ -70,8 +70,10 @@
 }
 
 lldb::user_id_t DWARFBaseDIE::GetID() const {
-  if (IsValid())
-return GetDWARF()->GetUID(*this);
+  const std::optional &ref = this->GetDIERef();
+  if (ref)
+return DIERef(GetID(), ref->section(), ref->die_offset()).get_id();
+
   return LLDB_INVALID_UID;
 }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -517,6 +517,14 @@
   return UpdateSymbolContextScopeForType(sc, die, type_sp);
 }
 
+namespace {
+lldb::user_id_t getUIDHelper(SymbolFileDWARF &dwarf, const DWARFBaseDIE &die) {
+  const std::optional &ref = die.GetDIERef();
+  return ref ? DIERef(dwarf.GetID(), ref->section(), ref->die_offset()).get_id()
+ : LLDB_INVALID_UID;
+}
+} // namespace
+
 lldb::TypeSP
 DWARFASTParserClang::ParseTypeModifier(const SymbolContext &sc,
const DWARFDIE &die,
@@ -731,10 +739,11 @@
 }
   }
 
-  type_sp = dwarf->MakeType(
-  die.GetID(), attrs.name, attrs.byte_size, nullptr,
-  dwarf->GetUID(attrs.type.Reference()), encoding_data_type, &attrs.decl,
-  clang_type, resolve_state, TypePayloadClang(GetOwningClangModule(die)));
+  type_sp = dwarf->MakeType(die.GetID(), attrs.name, attrs.byte_size, nullptr,
+getUIDHelper(*dwarf, attrs.type.Reference()),
+encoding_data_type, &attrs.decl, clang_type,
+resolve_state,
+TypePayloadClang(GetOwningClangModule(die)));
 
   dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
   return type_sp;
@@ -835,7 +844,7 @@
   LinkDeclContextToDIE(TypeSystemClang::GetDeclContextForType(clang_type), die);
 
   type_sp = dwarf->MakeType(die.GetID(), attrs.name, attrs.byte_size, nullptr,
-dwarf->GetUID(attrs.type.Reference()),
+getUIDHelper(*dwarf, attrs.type.Reference()),
 Type::eEncodingIsUID, &attrs.decl, clang_type,
 Type::ResolveState::Forward,
 TypePayloadClang(GetOwningClangModule(die)));
@@ -1334,10 +1343,10 @@
 m_ast.CreateA

[Lldb-commits] [PATCH] D139957: [LLDB] Change OSO to use DieRef

2023-01-27 Thread Alexander Yermolovich via Phabricator via lldb-commits
ayermolo updated this revision to Diff 492842.
ayermolo marked an inline comment as done.
ayermolo added a comment.

addressed comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139957/new/

https://reviews.llvm.org/D139957

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwo.s

Index: lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwo.s
===
--- lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwo.s
+++ lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwo.s
@@ -4,9 +4,9 @@
 # RUN:   -o exit | FileCheck %s
 
 # CHECK-LABEL: image lookup -v -s lookup_rnglists
-# CHECK:  Function: id = {0x4028}, name = "rnglists", range = [0x-0x0003)
-# CHECK:Blocks: id = {0x4028}, range = [0x-0x0003)
-# CHECK-NEXT:   id = {0x4037}, range = [0x0001-0x0002)
+# CHECK:  Function: id = {0x2028}, name = "rnglists", range = [0x-0x0003)
+# CHECK:Blocks: id = {0x2028}, range = [0x-0x0003)
+# CHECK-NEXT:   id = {0x2037}, range = [0x0001-0x0002)
 
 .text
 rnglists:
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -9,6 +9,7 @@
 #ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDEBUGMAP_H
 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDEBUGMAP_H
 
+#include "DIERef.h"
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Utility/RangeMap.h"
 #include "llvm/Support/Chrono.h"
@@ -209,7 +210,9 @@
   lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override;
 
   static uint32_t GetOSOIndexFromUserID(lldb::user_id_t uid) {
-return (uint32_t)((uid >> 32ull) - 1ull);
+std::optional OsoNum = DIERef(uid).oso_num();
+lldbassert(OsoNum && "Invalid OSO Index");
+return *OsoNum;
   }
 
   static SymbolFileDWARF *GetSymbolFileAsSymbolFileDWARF(SymbolFile *sym_file);
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -211,7 +211,7 @@
 // Set the ID of the symbol file DWARF to the index of the OSO
 // shifted left by 32 bits to provide a unique prefix for any
 // UserID's that get created in the symbol file.
-oso_symfile->SetID(((uint64_t)m_cu_idx + 1ull) << 32ull);
+oso_symfile->SetID((uint64_t)m_cu_idx + 1ull);
   }
   return symfile;
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1405,9 +1405,6 @@
 }
 
 user_id_t SymbolFileDWARF::GetUID(DIERef ref) {
-  if (GetDebugMapSymfile())
-return GetID() | ref.die_offset();
-
   return DIERef(GetID(), ref.section(), ref.die_offset()).get_id();
 }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
@@ -27,18 +27,21 @@
 class DIERef {
 public:
   enum Section : uint8_t { DebugInfo, DebugTypes };
+  enum IndexType : uint8_t { DWONum, OSONum };
 
-  DIERef(std::optional dwo_num, Section section,
+  DIERef(std::optional dwo_oso_num, Section section,
  dw_offset_t die_offset)
-  : m_die_offset(die_offset), m_dwo_num(dwo_num.value_or(0)),
-m_dwo_num_valid(dwo_num ? true : false), m_section(section) {
-assert(this->dwo_num() == dwo_num && "Dwo number out of range?");
+  : m_die_offset(die_offset), m_dwo_oso_num(dwo_oso_num.value_or(0)),
+m_dwo_num_valid(dwo_oso_num ? true : false), m_oso_num_valid(0),
+m_section(section) {
+assert(this->dwo_num() == dwo_oso_num && "Dwo number out of range?");
   }
 
   explicit DIERef(lldb::user_id_t uid) {
 m_die_offset = uid & k_die_offset_mask;
 m_dwo_num_valid = (uid & k_dwo_num_valid_bit) != 0;
-m_dwo_num =
+m_oso_num_valid = (uid & k_oso_num_valid_bit) != 0;
+m_dwo_oso_num =
 m_dwo_num_valid ? (uid >> k_die_offset_bit_size) & k_dwo_num_mask : 0;
 m_section =
 (uid & k_secti

[Lldb-commits] [PATCH] D139957: [LLDB] Change OSO to use DieRef

2023-01-27 Thread Alexander Yermolovich via Phabricator via lldb-commits
ayermolo marked 2 inline comments as done.
ayermolo added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DIERef.h:32
 
-  DIERef(std::optional dwo_num, Section section,
+  DIERef(std::optional dwo_oso_num, Section section,
  dw_offset_t die_offset)

labath wrote:
> ayermolo wrote:
> > labath wrote:
> > > Where is this constructor being used?
> > In SymbolFileDWARF.cpp
> > SymbolFileDWARF::GetUID
> > SymbolFileDWARF::DecodeUID
> I'm sorry, I must have clicked the wrong line. My question was about the 
> constructor below this (line 40).
Ah yes, sorry. Removed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139957/new/

https://reviews.llvm.org/D139957

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


[Lldb-commits] [PATCH] D138618: [LLDB] Enable 64 bit debug/type offset

2023-01-27 Thread Alexander Yermolovich via Phabricator via lldb-commits
ayermolo updated this revision to Diff 492841.
ayermolo added a comment.

addressed comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138618/new/

https://reviews.llvm.org/D138618

Files:
  lldb/include/lldb/Core/dwarf.h
  lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
  lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
  lldb/unittests/Expression/DWARFExpressionTest.cpp
  lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp

Index: lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp
===
--- lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp
+++ lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp
@@ -45,6 +45,26 @@
   EncodeDecode(DIERef(200, DIERef::Section::DebugTypes, 0x11223344));
 }
 
+TEST(DWARFIndexCachingTest, DIERefEncodeDecodeMax) {
+  // Tests DIERef::Encode(...) and DIERef::Decode(...)
+  EncodeDecode(DIERef(llvm::None, DIERef::Section::DebugInfo,
+  DIERef::k_die_offset_mask));
+  EncodeDecode(DIERef(llvm::None, DIERef::Section::DebugTypes,
+  DIERef::k_die_offset_mask));
+  EncodeDecode(
+  DIERef(100, DIERef::Section::DebugInfo, DIERef::k_die_offset_mask));
+  EncodeDecode(
+  DIERef(200, DIERef::Section::DebugTypes, DIERef::k_die_offset_mask));
+  EncodeDecode(DIERef(DIERef::k_dwo_num_mask, DIERef::Section::DebugInfo,
+  DIERef::k_dwo_num_mask));
+  EncodeDecode(DIERef(DIERef::k_dwo_num_mask, DIERef::Section::DebugTypes,
+  DIERef::k_dwo_num_mask));
+  EncodeDecode(
+  DIERef(DIERef::k_dwo_num_mask, DIERef::Section::DebugInfo, 0x11223344));
+  EncodeDecode(
+  DIERef(DIERef::k_dwo_num_mask, DIERef::Section::DebugTypes, 0x11223344));
+}
+
 static void EncodeDecode(const NameToDIE &object, ByteOrder byte_order) {
   const uint8_t addr_size = 8;
   DataEncoder encoder(byte_order, addr_size);
Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -713,7 +713,7 @@
   //   Entries:
   // - AbbrCode:0x1
   //   Values:
-  // - Value:   0x01020304
+  // - Value:   0x0120304
   // - AbbrCode:0x0
   const char *dwo_yamldata = R"(
 --- !ELF
@@ -750,7 +750,7 @@
   auto dwo_module_sp = std::make_shared(dwo_file->moduleSpec());
   SymbolFileDWARFDwo dwo_symfile(
   skeleton_symfile, dwo_module_sp->GetObjectFile()->shared_from_this(),
-  0x01020304);
+  0x0120304);
   auto *dwo_dwarf_unit = dwo_symfile.DebugInfo().GetUnitAtIndex(0);
 
   testExpressionVendorExtensions(dwo_module_sp, *dwo_dwarf_unit);
Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
===
--- lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
+++ lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
@@ -8,7 +8,7 @@
 # RUN:   -o exit | FileCheck %s
 
 # Failure was the block range 1..2 was not printed plus:
-# error: DW_AT_range-DW_FORM_sec_offset.s.tmp {0x003f}: DIE has DW_AT_ranges(0xc) attribute, but range extraction failed (missing or invalid range list table), please file a bug and attach the file at the start of this error message
+# error: DW_AT_range-DW_FORM_sec_offset.s.tmp {0x003f}: DIE has DW_AT_ranges(0xc) attribute, but range extraction failed (missing or invalid range list table), please file a bug and attach the file at the start of this error message
 
 # CHECK-LABEL: image lookup -v -s lookup_rnglists
 # CHECK:  Function: id = {0x0029}, name = "rnglists", range = [0x-0x0003)
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -41,7 +41,7 @@
   DWARFDIE
   GetDIE(const DIERef &die_ref) override;
 
-  std::optional GetDwoNum() override { return GetID() >> 32; }
+  std::optional GetDwoNum() override { return GetID(); }
 
   lldb::offset_t
   GetVendorDWARFOpcodeSize(const lldb_priva

[Lldb-commits] [PATCH] D142683: Manual DWARF index: don't skip over -gmodules debug info

2023-01-27 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp:180-182
+// The unit has a dwo_id, but this isn't a .dwo skeleton unit, so
+// the assumption is that this is a file produced by -gmodules and
+// that we want to index it.

clayborg wrote:
> Can we do a bit more to ensure we aren't using fission here? Are there no 
> other differences between -gmodules and fission we can key off of? Existence 
> of .debug_addr section for fission only?
The `.debug_addr` section only exists in DWARF 5 so the IsSkeletonUnit() check 
covers this.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142683/new/

https://reviews.llvm.org/D142683

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


[Lldb-commits] [PATCH] D142683: Manual DWARF index: don't skip over -gmodules debug info

2023-01-27 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

In D142683#4086026 , @aprantl wrote:

> It shouldn't be able to interfere with the declarations in the (missing) .dwo 
> file in that case, right?

Maybe I should have bothered reading your comment in the code. That's exactly 
the case you were trying to avoid m-(


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142683/new/

https://reviews.llvm.org/D142683

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


[Lldb-commits] [PATCH] D142672: [lldb] Make SBSection::GetSectionData call Section::GetSectionData.

2023-01-27 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
jgorbe marked an inline comment as done.
Closed by commit rG805600c7d573: [lldb] Make SBSection::GetSectionData call 
Section::GetSectionData. (authored by jgorbe).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142672/new/

https://reviews.llvm.org/D142672

Files:
  lldb/source/API/SBSection.cpp
  lldb/test/API/python_api/section/TestSectionAPI.py
  lldb/test/API/python_api/section/compressed-sections.yaml


Index: lldb/test/API/python_api/section/compressed-sections.yaml
===
--- /dev/null
+++ lldb/test/API/python_api/section/compressed-sections.yaml
@@ -0,0 +1,11 @@
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_386
+Sections:
+  - Name:.compressed
+Type:SHT_PROGBITS
+Flags:   [ SHF_COMPRESSED ]
+Content: 010008000100789c533070084828689809c802c1
Index: lldb/test/API/python_api/section/TestSectionAPI.py
===
--- lldb/test/API/python_api/section/TestSectionAPI.py
+++ lldb/test/API/python_api/section/TestSectionAPI.py
@@ -48,3 +48,18 @@
 section = target.modules[0].sections[0]
 self.assertEqual(section.GetAlignment(), 0x1000)
 self.assertEqual(section.alignment, 0x1000)
+
+def test_compressed_section_data(self):
+exe = self.getBuildArtifact("compressed-sections.out")
+self.yaml2obj("compressed-sections.yaml", exe)
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+# exe contains a single section with SHF_COMPRESSED. Check that
+# GetSectionData returns the uncompressed data and not the raw contents
+# of the section.
+section = target.modules[0].sections[0]
+section_data = section.GetSectionData().uint8s
+self.assertEqual(section_data,
+ [0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90])
+
Index: lldb/source/API/SBSection.cpp
===
--- lldb/source/API/SBSection.cpp
+++ lldb/source/API/SBSection.cpp
@@ -182,35 +182,10 @@
   SBData sb_data;
   SectionSP section_sp(GetSP());
   if (section_sp) {
-const uint64_t sect_file_size = section_sp->GetFileSize();
-if (sect_file_size > 0) {
-  ModuleSP module_sp(section_sp->GetModule());
-  if (module_sp) {
-ObjectFile *objfile = module_sp->GetObjectFile();
-if (objfile) {
-  const uint64_t sect_file_offset =
-  objfile->GetFileOffset() + section_sp->GetFileOffset();
-  const uint64_t file_offset = sect_file_offset + offset;
-  uint64_t file_size = size;
-  if (file_size == UINT64_MAX) {
-file_size = section_sp->GetByteSize();
-if (file_size > offset)
-  file_size -= offset;
-else
-  file_size = 0;
-  }
-  auto data_buffer_sp = FileSystem::Instance().CreateDataBuffer(
-  objfile->GetFileSpec().GetPath(), file_size, file_offset);
-  if (data_buffer_sp && data_buffer_sp->GetByteSize() > 0) {
-DataExtractorSP data_extractor_sp(
-new DataExtractor(data_buffer_sp, objfile->GetByteOrder(),
-  objfile->GetAddressByteSize()));
-
-sb_data.SetOpaque(data_extractor_sp);
-  }
-}
-  }
-}
+DataExtractor section_data;
+section_sp->GetSectionData(section_data);
+sb_data.SetOpaque(
+std::make_shared(section_data, offset, size));
   }
   return sb_data;
 }


Index: lldb/test/API/python_api/section/compressed-sections.yaml
===
--- /dev/null
+++ lldb/test/API/python_api/section/compressed-sections.yaml
@@ -0,0 +1,11 @@
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_386
+Sections:
+  - Name:.compressed
+Type:SHT_PROGBITS
+Flags:   [ SHF_COMPRESSED ]
+Content: 010008000100789c533070084828689809c802c1
Index: lldb/test/API/python_api/section/TestSectionAPI.py
===
--- lldb/test/API/python_api/section/TestSectionAPI.py
+++ lldb/test/API/python_api/section/TestSectionAPI.py
@@ -48,3 +48,18 @@
 section = target.modules[0].sections[0]
 self.assertEqual(section.GetAlignment(), 0x1000)
 self.assertEqual(section.alignment, 0x1000)
+
+def test_compressed_section_data(self):
+exe = self.getBuildArtifact("compressed-sections.out")
+self.yaml2obj("compressed-sections.yaml", exe)
+  

[Lldb-commits] [lldb] 805600c - [lldb] Make SBSection::GetSectionData call Section::GetSectionData.

2023-01-27 Thread Jorge Gorbe Moya via lldb-commits

Author: Jorge Gorbe Moya
Date: 2023-01-27T10:15:35-08:00
New Revision: 805600c7d573cf88cf035d01a2ea9389fc24d435

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

LOG: [lldb] Make SBSection::GetSectionData call Section::GetSectionData.

`SBSection::GetSectionData` and `Section::GetSectionData` are
implemented differently, and the `SBSection` method doesn't handle
compressed sections correctly.

Differential Revision: https://reviews.llvm.org/D142672

Added: 
lldb/test/API/python_api/section/compressed-sections.yaml

Modified: 
lldb/source/API/SBSection.cpp
lldb/test/API/python_api/section/TestSectionAPI.py

Removed: 




diff  --git a/lldb/source/API/SBSection.cpp b/lldb/source/API/SBSection.cpp
index 3a9cf20e484a5..b7b94f3ece1a6 100644
--- a/lldb/source/API/SBSection.cpp
+++ b/lldb/source/API/SBSection.cpp
@@ -182,35 +182,10 @@ SBData SBSection::GetSectionData(uint64_t offset, 
uint64_t size) {
   SBData sb_data;
   SectionSP section_sp(GetSP());
   if (section_sp) {
-const uint64_t sect_file_size = section_sp->GetFileSize();
-if (sect_file_size > 0) {
-  ModuleSP module_sp(section_sp->GetModule());
-  if (module_sp) {
-ObjectFile *objfile = module_sp->GetObjectFile();
-if (objfile) {
-  const uint64_t sect_file_offset =
-  objfile->GetFileOffset() + section_sp->GetFileOffset();
-  const uint64_t file_offset = sect_file_offset + offset;
-  uint64_t file_size = size;
-  if (file_size == UINT64_MAX) {
-file_size = section_sp->GetByteSize();
-if (file_size > offset)
-  file_size -= offset;
-else
-  file_size = 0;
-  }
-  auto data_buffer_sp = FileSystem::Instance().CreateDataBuffer(
-  objfile->GetFileSpec().GetPath(), file_size, file_offset);
-  if (data_buffer_sp && data_buffer_sp->GetByteSize() > 0) {
-DataExtractorSP data_extractor_sp(
-new DataExtractor(data_buffer_sp, objfile->GetByteOrder(),
-  objfile->GetAddressByteSize()));
-
-sb_data.SetOpaque(data_extractor_sp);
-  }
-}
-  }
-}
+DataExtractor section_data;
+section_sp->GetSectionData(section_data);
+sb_data.SetOpaque(
+std::make_shared(section_data, offset, size));
   }
   return sb_data;
 }

diff  --git a/lldb/test/API/python_api/section/TestSectionAPI.py 
b/lldb/test/API/python_api/section/TestSectionAPI.py
index ab9ae56238c8b..b01ddece0de36 100644
--- a/lldb/test/API/python_api/section/TestSectionAPI.py
+++ b/lldb/test/API/python_api/section/TestSectionAPI.py
@@ -48,3 +48,18 @@ def test_get_alignment(self):
 section = target.modules[0].sections[0]
 self.assertEqual(section.GetAlignment(), 0x1000)
 self.assertEqual(section.alignment, 0x1000)
+
+def test_compressed_section_data(self):
+exe = self.getBuildArtifact("compressed-sections.out")
+self.yaml2obj("compressed-sections.yaml", exe)
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+# exe contains a single section with SHF_COMPRESSED. Check that
+# GetSectionData returns the uncompressed data and not the raw contents
+# of the section.
+section = target.modules[0].sections[0]
+section_data = section.GetSectionData().uint8s
+self.assertEqual(section_data,
+ [0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90])
+

diff  --git a/lldb/test/API/python_api/section/compressed-sections.yaml 
b/lldb/test/API/python_api/section/compressed-sections.yaml
new file mode 100644
index 0..a41307ef7d1fc
--- /dev/null
+++ b/lldb/test/API/python_api/section/compressed-sections.yaml
@@ -0,0 +1,11 @@
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_386
+Sections:
+  - Name:.compressed
+Type:SHT_PROGBITS
+Flags:   [ SHF_COMPRESSED ]
+Content: 010008000100789c533070084828689809c802c1



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


[Lldb-commits] [PATCH] D142733: Add _Optional as fast qualifier

2023-01-27 Thread River Riddle via Phabricator via lldb-commits
rriddle added a comment.

I don't understand the MLIR changes here, how are they relevant to the patch?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142733/new/

https://reviews.llvm.org/D142733

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


[Lldb-commits] [PATCH] D142662: Allow bytes-only mach-o corefile to load into lldb

2023-01-27 Thread Jason Molenda via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG841b26f1d80f: Don't flag memory-only mach-o corefiles 
as invalid (authored by jasonmolenda).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142662/new/

https://reviews.llvm.org/D142662

Files:
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp


Index: lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
===
--- lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -483,13 +483,6 @@
 return error;
   }
 
-  if (core_objfile->GetNumThreadContexts() == 0) {
-error.SetErrorString("core file doesn't contain any LC_THREAD load "
- "commands, or the LC_THREAD architecture is not "
- "supported in this lldb");
-return error;
-  }
-
   SetCanJIT(false);
 
   // The corefile's architecture is our best starting point.


Index: lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
===
--- lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -483,13 +483,6 @@
 return error;
   }
 
-  if (core_objfile->GetNumThreadContexts() == 0) {
-error.SetErrorString("core file doesn't contain any LC_THREAD load "
- "commands, or the LC_THREAD architecture is not "
- "supported in this lldb");
-return error;
-  }
-
   SetCanJIT(false);
 
   // The corefile's architecture is our best starting point.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D142663: Improve disable-language-runtime-unwindplans description to be more searchable

2023-01-27 Thread Jason Molenda via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8112bd2cb484: disable-language-runtime-unwindplans desc 
rewrite to be searchable (authored by jasonmolenda).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142663/new/

https://reviews.llvm.org/D142663

Files:
  lldb/source/Target/TargetProperties.td


Index: lldb/source/Target/TargetProperties.td
===
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -216,7 +216,7 @@
   def DisableLangRuntimeUnwindPlans: 
Property<"disable-language-runtime-unwindplans", "Boolean">,
 Global,
 DefaultFalse,
-Desc<"If true, LanguageRuntime plugins' UnwindPlans will not be used when 
backtracing.">;
+Desc<"If true, language runtime augmented/overidden backtraces will not be 
used when printing a stack trace.">;
   def DetachKeepsStopped: Property<"detach-keeps-stopped", "Boolean">,
 Global,
 DefaultFalse,


Index: lldb/source/Target/TargetProperties.td
===
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -216,7 +216,7 @@
   def DisableLangRuntimeUnwindPlans: Property<"disable-language-runtime-unwindplans", "Boolean">,
 Global,
 DefaultFalse,
-Desc<"If true, LanguageRuntime plugins' UnwindPlans will not be used when backtracing.">;
+Desc<"If true, language runtime augmented/overidden backtraces will not be used when printing a stack trace.">;
   def DetachKeepsStopped: Property<"detach-keeps-stopped", "Boolean">,
 Global,
 DefaultFalse,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 8112bd2 - disable-language-runtime-unwindplans desc rewrite to be searchable

2023-01-27 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2023-01-27T09:40:54-08:00
New Revision: 8112bd2cb4845e0449088c764ad36748514259b8

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

LOG: disable-language-runtime-unwindplans desc rewrite to be searchable

The description for disable-language-runtime-unwindplans did not
include likely search terms ("backtrace", "stack"), rewrite it
to include those so it is more easily discoverable with apropos.
The text is still not the clearest description of what a language
runtime is / what it might do, but this is better.

Differential Revision: https://reviews.llvm.org/D142663

Added: 


Modified: 
lldb/source/Target/TargetProperties.td

Removed: 




diff  --git a/lldb/source/Target/TargetProperties.td 
b/lldb/source/Target/TargetProperties.td
index 202304174bc15..51bfd28914af9 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -216,7 +216,7 @@ let Definition = "process" in {
   def DisableLangRuntimeUnwindPlans: 
Property<"disable-language-runtime-unwindplans", "Boolean">,
 Global,
 DefaultFalse,
-Desc<"If true, LanguageRuntime plugins' UnwindPlans will not be used when 
backtracing.">;
+Desc<"If true, language runtime augmented/overidden backtraces will not be 
used when printing a stack trace.">;
   def DetachKeepsStopped: Property<"detach-keeps-stopped", "Boolean">,
 Global,
 DefaultFalse,



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


[Lldb-commits] [lldb] 841b26f - Don't flag memory-only mach-o corefiles as invalid

2023-01-27 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2023-01-27T09:40:54-08:00
New Revision: 841b26f1d80f69c45bbf2426761f3e3b9c927d86

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

LOG: Don't flag memory-only mach-o corefiles as invalid

It is possible to have a memory-only mach-o corefile, with the
threads provided by an os-plugin thread provider, or a scripted
process, in Python.

Differential Revision: https://reviews.llvm.org/D142662
rdar://102579544

Added: 


Modified: 
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp 
b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
index fbf57fc3bf8e3..11e9b0e369f09 100644
--- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -483,13 +483,6 @@ Status ProcessMachCore::DoLoadCore() {
 return error;
   }
 
-  if (core_objfile->GetNumThreadContexts() == 0) {
-error.SetErrorString("core file doesn't contain any LC_THREAD load "
- "commands, or the LC_THREAD architecture is not "
- "supported in this lldb");
-return error;
-  }
-
   SetCanJIT(false);
 
   // The corefile's architecture is our best starting point.



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


[Lldb-commits] [PATCH] D142683: Manual DWARF index: don't skip over -gmodules debug info

2023-01-27 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 492782.
aprantl added a comment.

I added an unambiguous check for DWARF5+. The remaining incorrectly handled 
case is a DWARF4 + GNU fission extension where the .dwo file has been deleted. 
Is there any harm in indexing the skeleton in that case? It shouldn't be able 
to interfere with the declarations in the (missing) .dwo file in that case, 
right?
Let me know if this is not enough and I'll try finding another heuristic that 
we could apply here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142683/new/

https://reviews.llvm.org/D142683

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/test/Shell/SymbolFile/DWARF/Inputs/pch.h
  lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c


Index: lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c
@@ -0,0 +1,18 @@
+// UNSUPPORTED: system-windows
+
+// Test that LLDB can follow DWO links produced by -gmodules debug
+// info to find a type in a precompiled header.
+// 
+// RUN: %clangxx_host -g -gmodules -fmodules -std=c99 -x c-header 
%S/Inputs/pch.h -g -c -o %t.pch
+// RUN: %clangxx_host -g -gmodules -fmodules -std=c99 -x c -include-pch %t.pch 
%s -c -o %t.o
+// RUN: %clangxx_host %t.o -o %t.exe
+// RUN: lldb-test symbols -dump-clang-ast -find type --language=C99 \
+// RUN:   -compiler-context 'AnyModule:*,Struct:TypeFromPCH' %t.exe | 
FileCheck %s
+
+anchor_t anchor;
+
+int main(int argc, char **argv) { return 0; }
+
+// CHECK: Found 1 type
+// CHECK: "TypeFromPCH"
+// CHECK: FieldDecl {{.*}} field
Index: lldb/test/Shell/SymbolFile/DWARF/Inputs/pch.h
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/Inputs/pch.h
@@ -0,0 +1,5 @@
+typedef int anchor_t;
+
+struct TypeFromPCH {
+  int field;
+};
Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -162,12 +162,13 @@
   // though as some functions have template parameter types and other things
   // that cause extra copies of types to be included, but we should find these
   // types in the .dwo file only as methods could have return types removed and
-  // we don't have to index incomplete types from the skeletone compile unit.
+  // we don't have to index incomplete types from the skeleton compile unit.
   if (unit.GetDWOId()) {
+// Index the .dwo or dwp instead of the skeleton unit.
 if (SymbolFileDWARFDwo *dwo_symbol_file = unit.GetDwoSymbolFile()) {
   // Type units in a dwp file are indexed separately, so we just need to
-  // process the split unit here. However, if the split unit is in a dwo 
file,
-  // then we need to process type units here.
+  // process the split unit here. However, if the split unit is in a dwo
+  // file, then we need to process type units here.
   if (dwo_symbol_file == dwp) {
 IndexUnitImpl(unit.GetNonSkeletonUnit(), cu_language, set);
   } else {
@@ -175,11 +176,18 @@
 for (size_t i = 0; i < dwo_info.GetNumUnits(); ++i)
   IndexUnitImpl(*dwo_info.GetUnitAtIndex(i), cu_language, set);
   }
+  return;
 }
-  } else {
-// We either have a normal compile unit which we want to index.
-IndexUnitImpl(unit, cu_language, set);
+// This was a DWARF5 skeleton CU and the .dwo file couldn't be located.
+if (unit.IsSkeletonUnit())
+  return;
+
+// Otherwise, the unit has a dwo_id, but this isn't a .dwo
+// skeleton unit, so the assumption is that this is a file
+// produced by -gmodules and that we want to index it.
   }
+  // We have a normal compile unit which we want to index.
+  IndexUnitImpl(unit, cu_language, set);
 }
 
 void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -223,6 +223,8 @@
 
   uint8_t GetUnitType() const { return m_header.GetUnitType(); }
   bool IsTypeUnit() const { return m_header.IsTypeUnit(); }
+  /// Note that this check only works for DWARF5+.
+  bool IsSkeletonUnit() const { return GetUnitType() == 
llvm::dwarf::DW_UT_skeleton; }
 
   std::optional GetStringOffsetSectionItem(uint32_t index) const;
 


Index: lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c
@@ -0,0 +1,18 @@
+// UNSUPPORTED: system-windows
+
+// Test that

[Lldb-commits] [PATCH] D142733: Add _Optional as fast qualifier

2023-01-27 Thread Christopher Bazley via Phabricator via lldb-commits
chrisbazley created this revision.
Herald added subscribers: Moerafaat, zero9178, bzcheeseman, sdasgup3, 
wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, jdoerfert, 
msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, 
arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini, thopre, martong, 
hiraditya.
Herald added a reviewer: shafik.
Herald added a reviewer: shafik.
Herald added a reviewer: rriddle.
Herald added a project: All.
chrisbazley requested review of this revision.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits, 
stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, LLDB, MLIR, LLVM.

A new pointee type qualifier for the purpose of
adding pointer nullability information to C
programs. Its goal is to provide value not only
for static analysis and documentation, but also
for compilers which report errors based only on
existing type-compatibility rules. The syntax
and semantics are designed to be as familiar (to
C programmers) and ergonomic as possible.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142733

Files:
  clang/include/clang/AST/APValue.h
  clang/include/clang/AST/CanonicalType.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaType.cpp
  lldb/include/lldb/Symbol/Type.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
  lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  lldb/source/Symbol/Type.cpp
  llvm/docs/LangRef.rst
  llvm/docs/SourceLevelDebugging.rst
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/DebugInfo/CodeView/CodeView.h
  llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
  llvm/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h
  llvm/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeSymbolEnumerator.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeArray.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeEnum.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeFunctionSig.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeTypePointer.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeUDT.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeVTShape.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolData.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolThunk.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
  llvm/lib/DWARFLinker/DWARFLinker.cpp
  llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
  llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
  llvm/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeSymbolEnumerator.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeTypeArray.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeTypeBuiltin.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeTypeFunctionSig.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeTypePointer.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeTypeVTShape.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp
  llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
  llvm/lib/Target/BPF/BPFPreserveDIType.cpp
  llvm/lib/Target/BPF/BTF.def
  llvm/lib/Target/BPF/BTFDebug.cpp
  llvm/tools/llvm-pdb

[Lldb-commits] [PATCH] D142714: [lldb][CXXModuleHandler] Set TemplateArgument::IsDefaulted

2023-01-27 Thread Michael Buch via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG12e8e3fe90c9: [lldb][CXXModuleHandler] Set 
TemplateArgument::IsDefaulted (authored by Michael137).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142714/new/

https://reviews.llvm.org/D142714

Files:
  lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp


Index: lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
@@ -239,7 +239,8 @@
 LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
 return std::nullopt;
   }
-  imported_args.push_back(TemplateArgument(*type));
+  imported_args.push_back(
+  TemplateArgument(*type, /*isNullPtr*/ false, arg.getIsDefaulted()));
   break;
 }
 case TemplateArgument::Integral: {
@@ -250,8 +251,8 @@
 LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
 return std::nullopt;
   }
-  imported_args.push_back(
-  TemplateArgument(d->getASTContext(), integral, *type));
+  imported_args.push_back(TemplateArgument(d->getASTContext(), integral,
+   *type, arg.getIsDefaulted()));
   break;
 }
 default:


Index: lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
@@ -239,7 +239,8 @@
 LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
 return std::nullopt;
   }
-  imported_args.push_back(TemplateArgument(*type));
+  imported_args.push_back(
+  TemplateArgument(*type, /*isNullPtr*/ false, arg.getIsDefaulted()));
   break;
 }
 case TemplateArgument::Integral: {
@@ -250,8 +251,8 @@
 LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
 return std::nullopt;
   }
-  imported_args.push_back(
-  TemplateArgument(d->getASTContext(), integral, *type));
+  imported_args.push_back(TemplateArgument(d->getASTContext(), integral,
+   *type, arg.getIsDefaulted()));
   break;
 }
 default:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 12e8e3f - [lldb][CXXModuleHandler] Set TemplateArgument::IsDefaulted

2023-01-27 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-01-27T16:39:18Z
New Revision: 12e8e3fe90c976d08d466b24ce21a7f7e86f4249

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

LOG: [lldb][CXXModuleHandler] Set TemplateArgument::IsDefaulted

Since https://reviews.llvm.org/D141827 this field gets used
to print type names. Thus propagate it after importing TemplateArguments
from modules.

**Testing**

* Confirmed that this fixes the ongoing `import-std-module` test
  failures.

Differential Revision: https://reviews.llvm.org/D142714

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
index 3eda04dc022a7..c201153fd7ceb 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
@@ -239,7 +239,8 @@ std::optional 
CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) {
 LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
 return std::nullopt;
   }
-  imported_args.push_back(TemplateArgument(*type));
+  imported_args.push_back(
+  TemplateArgument(*type, /*isNullPtr*/ false, arg.getIsDefaulted()));
   break;
 }
 case TemplateArgument::Integral: {
@@ -250,8 +251,8 @@ std::optional 
CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) {
 LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
 return std::nullopt;
   }
-  imported_args.push_back(
-  TemplateArgument(d->getASTContext(), integral, *type));
+  imported_args.push_back(TemplateArgument(d->getASTContext(), integral,
+   *type, arg.getIsDefaulted()));
   break;
 }
 default:



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


[Lldb-commits] [PATCH] D141828: [lldb] Add support for DW_AT_default_value in template params

2023-01-27 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 492749.
Michael137 added a comment.

- Remove redundant HostInfo calls


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141828/new/

https://reviews.llvm.org/D141828

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  
lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py
  
lldb/test/API/commands/expression/import-std-module/retry-with-std-module/TestRetryWithStdModule.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
  lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
  lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_default_value-test.yaml

Index: lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_default_value-test.yaml
===
--- /dev/null
+++ lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_default_value-test.yaml
@@ -0,0 +1,314 @@
+# template 
+# class foo {};
+#
+# template  class CT = foo>
+# class baz {};
+#
+# template >
+# class bar {};
+#
+# int main() {
+# bar<> br;
+# baz<> bz;
+# return 0;
+# }
+#
+# YAML generated on Linux using obj2yaml on the above program
+# compiled with Clang.
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_AARCH64
+  SectionHeaderStringTable: .strtab
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+AddressAlign:0x4
+Content: FF4300D1E0031F2AFF0F00B9FF430091C0035FD6
+  - Name:.linker-options
+Type:SHT_LLVM_LINKER_OPTIONS
+Flags:   [ SHF_EXCLUDE ]
+AddressAlign:0x1
+Content: ''
+  - Name:.debug_abbrev
+Type:SHT_PROGBITS
+AddressAlign:0x1
+Content: 011101252513050325721710171B25111B12067317022E0B1206401803253A0B3B0B49133F19033400021803253A0B3B0B491304240003253E0B0B0B050201360B03250B0B3A0B3B0B062F00491303251E19073000491303251E191C0D083000491303251E191C0F09020003253C190A8682010003251E1990422500
+  - Name:.debug_info
+Type:SHT_PROGBITS
+AddressAlign:0x1
+Content: 7F000500010801002100010200140002001400016F03000B49000302910B05000C4D000302910A0E000D780404050405050D010009066E000707490008030872000A010676000C000406080104090201090B0505110100050A0F10
+  - Name:.debug_str_offsets
+Type:SHT_PROGBITS
+AddressAlign:0x1
+Content: 4C000500
+  - Name:.comment
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x1
+EntSize: 0x1
+Content: 00636C616E672076657273696F6E2031362E302E30202868747470733A2F2F6769746875622E636F6D2F6C6C766D2F6C6C766D2D70726F6A65637420343764323862376138323638653337616130646537366238353966343530386533646261633663652900
+  - Name:.note.GNU-stack
+Type:SHT_PROGBITS
+AddressAlign:0x1
+  - Name:.eh_frame
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC ]
+AddressAlign:0x8
+Content: 117A5200017C1E011B0C1F001800180014440E104C0E
+  - Name:.debug_line
+Type:SHT_PROGBITS
+AddressAlign:0x1
+Content: 5800050008003700010101FB0E0D000101010100010101011F0103011F020F051E010019537E33C1D1006B79E3D1C33D6EE6A3040902030A0105050ABD0208000101
+  - Name:.debug_line_str
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x1
+EntSize: 0x1
+Content: 2F686F6D652F6761726465690064656661756C74732E63707000
+  - Name:.rela.debug_info
+Type:SHT_RELA
+Flags:   [ SHF_INFO_LINK ]
+Link:.symtab
+AddressAlign:0x8
+Info:.debug_info
+Relocations:
+  - Offset:  0x8
+Symbol:  .debug_abbrev
+Type:R_AARCH64_ABS32
+ 

[Lldb-commits] [PATCH] D142715: [LLDB] Apply FixCodeAddress to all forms of address arguments

2023-01-27 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added reviewers: JDevlieghere, jasonmolenda.
DavidSpickett added a comment.

Apologies it took me so long to get around to this.

As a superset of your change I presume the test you added will still pass. I 
don't have a Mac to confirm that myself.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142715/new/

https://reviews.llvm.org/D142715

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


[Lldb-commits] [PATCH] D142715: [LLDB] Apply FixCodeAddress to all forms of address arguments

2023-01-27 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This is a follow up to https://reviews.llvm.org/D141629
and applies the change it made to all paths through ToAddress
(now DoToAddress).

I have included the test from my previous attempt
https://reviews.llvm.org/D136938.

The initial change only applied fixing to addresses that
would parse as integers, so my test case failed. Since
ToAddress has multiple exit points, I've wrapped it into
a new method DoToAddress.

Now you can call ToAddress, it will call DoToAddress and
no matter what path you take, the address will be fixed.

For the memory tagging commands we actually want the full
address (to work out mismatches). So I added ToRawAddress
for that.

I have tested this on a QEMU AArch64 Linux system with
Memory Tagging, Pointer Authentication and Top Byte Ignore
enabled. By running the new test and all other tests in
API/linux/aarch64.

Some commands have had calls to the ABI plugin removed
as ToAddress now does this for them.

The "memory region" command still needs to use the ABI plugin
to detect the end of memory when there are non-address bits.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142715

Files:
  lldb/include/lldb/Interpreter/OptionArgParser.h
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Commands/CommandObjectMemoryTag.cpp
  lldb/source/Interpreter/OptionArgParser.cpp
  lldb/test/API/linux/aarch64/non_address_bit_code_break/Makefile
  
lldb/test/API/linux/aarch64/non_address_bit_code_break/TestAArch64LinuxNonAddressBitCodeBreak.py
  lldb/test/API/linux/aarch64/non_address_bit_code_break/main.c

Index: lldb/test/API/linux/aarch64/non_address_bit_code_break/main.c
===
--- /dev/null
+++ lldb/test/API/linux/aarch64/non_address_bit_code_break/main.c
@@ -0,0 +1,18 @@
+#include 
+
+void foo(void) {}
+typedef void (*FooPtr)(void);
+
+int main() {
+  FooPtr fnptr = foo;
+  // Set top byte.
+  fnptr = (FooPtr)((uintptr_t)fnptr | (uintptr_t)0xff << 56);
+  // Then apply a PAuth signature to it.
+  __asm__ __volatile__("pacdza %0" : "=r"(fnptr) : "r"(fnptr));
+  // fnptr is now:
+  // <8 bit top byte tag>
+
+  foo(); // Set break point at this line.
+
+  return 0;
+}
Index: lldb/test/API/linux/aarch64/non_address_bit_code_break/TestAArch64LinuxNonAddressBitCodeBreak.py
===
--- /dev/null
+++ lldb/test/API/linux/aarch64/non_address_bit_code_break/TestAArch64LinuxNonAddressBitCodeBreak.py
@@ -0,0 +1,57 @@
+"""
+Test that "breakpoint set -a" uses the ABI plugin to remove non-address bits
+before attempting to set a breakpoint.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class AArch64LinuxNonAddressBitCodeBreak(TestBase):
+
+NO_DEBUG_INFO_TESTCASE = True
+
+def do_tagged_break(self, hardware):
+if not self.isAArch64PAuth():
+self.skipTest('Target must support pointer authentication.')
+
+self.build()
+self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
+
+lldbutil.run_break_set_by_file_and_line(self, "main.c",
+line_number('main.c', '// Set break point at this line.'),
+num_expected_locations=1)
+
+self.runCmd("run", RUN_SUCCEEDED)
+
+if self.process().GetState() == lldb.eStateExited:
+self.fail("Test program failed to run.")
+
+self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+cmd = "breakpoint set -a fnptr"
+# LLDB only has the option to force hardware break, not software.
+# It prefers sofware break when it can and this will be one of those cases.
+if hardware:
+cmd += " --hardware"
+self.expect(cmd)
+
+self.runCmd("continue")
+self.assertEqual(self.process().GetState(), lldb.eStateStopped)
+self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+substrs=['stopped', '`foo at main.c', 'stop reason = breakpoint'])
+
+# AArch64 Linux always enables the top byte ignore feature
+@skipUnlessArch("aarch64")
+@skipUnlessPlatform(["linux"])
+def test_software_break(self):
+self.do_tagged_break(False)
+
+@skipUnlessArch("aarch64")
+@skipUnlessPlatform(["linux"])
+def test_hardware_break(self):
+self.do_tagged_break(True)
Index: lldb/test/API/linux/aarch64/non_address_bit_code_break/Makefile
===
--- /dev/null
+++ lldb/test/API/linux/aarch64/non_address_bit_code_break/Makefile
@@ -0,0 +1,5 @@
+C_SOURCES := main.c
+
+C

[Lldb-commits] [PATCH] D141828: [lldb] Add support for DW_AT_default_value in template params

2023-01-27 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

API tests should all work once following lands:

- https://reviews.llvm.org/D142713
- https://reviews.llvm.org/D142714

Just the Linux unit-test issue left now


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141828/new/

https://reviews.llvm.org/D141828

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


[Lldb-commits] [PATCH] D141828: [lldb] Add support for DW_AT_default_value in template params

2023-01-27 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 492733.
Michael137 added a comment.

- Fix `import-std-module` API tests


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141828/new/

https://reviews.llvm.org/D141828

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  
lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py
  
lldb/test/API/commands/expression/import-std-module/retry-with-std-module/TestRetryWithStdModule.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
  lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
  lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_default_value-test.yaml

Index: lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_default_value-test.yaml
===
--- /dev/null
+++ lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_default_value-test.yaml
@@ -0,0 +1,314 @@
+# template 
+# class foo {};
+#
+# template  class CT = foo>
+# class baz {};
+#
+# template >
+# class bar {};
+#
+# int main() {
+# bar<> br;
+# baz<> bz;
+# return 0;
+# }
+#
+# YAML generated on Linux using obj2yaml on the above program
+# compiled with Clang.
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_AARCH64
+  SectionHeaderStringTable: .strtab
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+AddressAlign:0x4
+Content: FF4300D1E0031F2AFF0F00B9FF430091C0035FD6
+  - Name:.linker-options
+Type:SHT_LLVM_LINKER_OPTIONS
+Flags:   [ SHF_EXCLUDE ]
+AddressAlign:0x1
+Content: ''
+  - Name:.debug_abbrev
+Type:SHT_PROGBITS
+AddressAlign:0x1
+Content: 011101252513050325721710171B25111B12067317022E0B1206401803253A0B3B0B49133F19033400021803253A0B3B0B491304240003253E0B0B0B050201360B03250B0B3A0B3B0B062F00491303251E19073000491303251E191C0D083000491303251E191C0F09020003253C190A8682010003251E1990422500
+  - Name:.debug_info
+Type:SHT_PROGBITS
+AddressAlign:0x1
+Content: 7F000500010801002100010200140002001400016F03000B49000302910B05000C4D000302910A0E000D780404050405050D010009066E000707490008030872000A010676000C000406080104090201090B0505110100050A0F10
+  - Name:.debug_str_offsets
+Type:SHT_PROGBITS
+AddressAlign:0x1
+Content: 4C000500
+  - Name:.comment
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x1
+EntSize: 0x1
+Content: 00636C616E672076657273696F6E2031362E302E30202868747470733A2F2F6769746875622E636F6D2F6C6C766D2F6C6C766D2D70726F6A65637420343764323862376138323638653337616130646537366238353966343530386533646261633663652900
+  - Name:.note.GNU-stack
+Type:SHT_PROGBITS
+AddressAlign:0x1
+  - Name:.eh_frame
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC ]
+AddressAlign:0x8
+Content: 117A5200017C1E011B0C1F001800180014440E104C0E
+  - Name:.debug_line
+Type:SHT_PROGBITS
+AddressAlign:0x1
+Content: 5800050008003700010101FB0E0D000101010100010101011F0103011F020F051E010019537E33C1D1006B79E3D1C33D6EE6A3040902030A0105050ABD0208000101
+  - Name:.debug_line_str
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x1
+EntSize: 0x1
+Content: 2F686F6D652F6761726465690064656661756C74732E63707000
+  - Name:.rela.debug_info
+Type:SHT_RELA
+Flags:   [ SHF_INFO_LINK ]
+Link:.symtab
+AddressAlign:0x8
+Info:.debug_info
+Relocations:
+  - Offset:  0x8
+Symbol:  .debug_abbrev
+Type:R_AARCH64_ABS32

[Lldb-commits] [PATCH] D142714: [lldb][CXXModuleHandler] Set TemplateArgument::IsDefaulted

2023-01-27 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added reviewers: aprantl, labath.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Since https://reviews.llvm.org/D141827 this field gets used
to print type names. Thus propagate it after importing TemplateArguments
from modules.

**Testing**

- Confirmed that this fixes the ongoing `import-std-module` test failures.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142714

Files:
  lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp


Index: lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
@@ -239,7 +239,8 @@
 LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
 return std::nullopt;
   }
-  imported_args.push_back(TemplateArgument(*type));
+  imported_args.push_back(
+  TemplateArgument(*type, /*isNullPtr*/ false, arg.getIsDefaulted()));
   break;
 }
 case TemplateArgument::Integral: {
@@ -250,8 +251,8 @@
 LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
 return std::nullopt;
   }
-  imported_args.push_back(
-  TemplateArgument(d->getASTContext(), integral, *type));
+  imported_args.push_back(TemplateArgument(d->getASTContext(), integral,
+   *type, arg.getIsDefaulted()));
   break;
 }
 default:


Index: lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
@@ -239,7 +239,8 @@
 LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
 return std::nullopt;
   }
-  imported_args.push_back(TemplateArgument(*type));
+  imported_args.push_back(
+  TemplateArgument(*type, /*isNullPtr*/ false, arg.getIsDefaulted()));
   break;
 }
 case TemplateArgument::Integral: {
@@ -250,8 +251,8 @@
 LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
 return std::nullopt;
   }
-  imported_args.push_back(
-  TemplateArgument(d->getASTContext(), integral, *type));
+  imported_args.push_back(TemplateArgument(d->getASTContext(), integral,
+   *type, arg.getIsDefaulted()));
   break;
 }
 default:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D142709: [lldb][Target] GetScratchTypeSystems: sort TypeSystems with strict weak ordering

2023-01-27 Thread Michael Buch via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG78fee46d8d8e: [lldb][Target] GetScratchTypeSystems: sort 
TypeSystems with strict weak ordering (authored by Michael137).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142709/new/

https://reviews.llvm.org/D142709

Files:
  lldb/source/Target/Target.cpp


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -2385,10 +2385,8 @@
   if (auto ts = *type_system_or_err)
 scratch_type_systems.push_back(ts);
   }
-  std::sort(scratch_type_systems.begin(), scratch_type_systems.end(),
-[](lldb::TypeSystemSP a, lldb::TypeSystemSP b) {
-  return a.get() <= b.get();
-});
+
+  std::sort(scratch_type_systems.begin(), scratch_type_systems.end());
   scratch_type_systems.erase(
   std::unique(scratch_type_systems.begin(), scratch_type_systems.end()),
   scratch_type_systems.end());


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -2385,10 +2385,8 @@
   if (auto ts = *type_system_or_err)
 scratch_type_systems.push_back(ts);
   }
-  std::sort(scratch_type_systems.begin(), scratch_type_systems.end(),
-[](lldb::TypeSystemSP a, lldb::TypeSystemSP b) {
-  return a.get() <= b.get();
-});
+
+  std::sort(scratch_type_systems.begin(), scratch_type_systems.end());
   scratch_type_systems.erase(
   std::unique(scratch_type_systems.begin(), scratch_type_systems.end()),
   scratch_type_systems.end());
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 78fee46 - [lldb][Target] GetScratchTypeSystems: sort TypeSystems with strict weak ordering

2023-01-27 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-01-27T13:22:11Z
New Revision: 78fee46d8d8e82158b79a4ad948e8723e89f7f65

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

LOG: [lldb][Target] GetScratchTypeSystems: sort TypeSystems with strict weak 
ordering

`std::sort` requires a comparison operator that obides by strict weak
ordering. `operator<=` on pointer does not and leads to undefined
behaviour. Specifically, when we grow the `scratch_type_systems` vector
slightly larger (and thus take `std::sort` down a slightly different
codepath), we segfault. This happened while working on a patch that
would in fact grow this vector. In such a case ASAN reports:

```
$ ./bin/lldb 
./lldb-test-build.noindex/lang/cpp/complete-type-check/TestCppIsTypeComplete.test_builtin_types/a.out
 -o "script -- lldb.target.FindFirstType(\"void\")"
(lldb) script -- lldb.target.FindFirstType("void")
=
==59975==ERROR: AddressSanitizer: container-overflow on address 0x000108f6b510 
at pc 0x000280177b4c bp 0x00016b7d7430 sp 0x00016b7d7428
READ of size 8 at 0x000108f6b510 thread T0
#0 0x280177b48 in 
std::__1::shared_ptr::shared_ptr[abi:v15006](std::__1::shared_ptr
 const&)+0xb4 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0x177b48)
(BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
#1 0x280dcc008 in void std::__1::__introsort*>(std::__1::shared_ptr*,
 std::__1::shared_
ptr*, 
lldb_private::Target::GetScratchTypeSystems(bool)::$_3&, 
std::__1::iterator_traits*>::difference_type)+0x1050
 (/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblld
b.17.0.0git.dylib:arm64+0xdcc008) (BuildId: 
ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
#2 0x280d88788 in lldb_private::Target::GetScratchTypeSystems(bool)+0x5a4 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0xd88788)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
#3 0x28021f0b4 in lldb::SBTarget::FindFirstType(char const*)+0x624 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0x21f0b4)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
#4 0x2804e9590 in _wrap_SBTarget_FindFirstType(_object*, _object*)+0x26c 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0x4e9590)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
#5 0x1062d3ad4 in cfunction_call+0x5c 
(/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/Python:arm64+0xcfad4)
 (BuildId: c9efc4bbb1943f9a9b7cc4e91fce4777320021000d00)

<--- snipped --->

0x000108f6b510 is located 400 bytes inside of 512-byte region 
[0x000108f6b380,0x000108f6b580)
allocated by thread T0 here:
#0 0x105209414 in wrap__Znwm+0x74 
(/Applications/Xcode2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:arm64e+0x51414)
 (BuildId: 0a44828ceb64337bbfff60b22cd838f032
0021000b00)
#1 0x280dca3b4 in 
std::__1::__split_buffer, 
std::__1::allocator>&>::__split_buffer(unsigned
 long, unsigned long, std::__1::allocator>&)+0x11c 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0xdca3b4)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
#2 0x280dc978c in void 
std::__1::vector, 
std::__1::allocator>>::__push_back_slow_path
 const&>(std::__1::s
hared_ptr const&)+0x13c 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0xdc978c)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
#3 0x280d88dec in 
std::__1::vector, 
std::__1::allocator>>::push_back[abi:v15006](std::__1::shared_ptr
 const&)+0x80 (/Users/mic
haelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0xd88dec)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
#4 0x280d8857c in lldb_private::Target::GetScratchTypeSystems(bool)+0x398 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0xd8857c)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
#5 0x28021f0b4 in lldb::SBTarget::FindFirstType(char const*)+0x624 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0x21f0b4)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
#6 0x2804e9590 in _wrap_SBTarget_FindFirstType(_object*, _object*)+0x26c 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0x4e9590)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
#7 0x1062d

[Lldb-commits] [PATCH] D142709: [lldb][Target] GetScratchTypeSystems: sort TypeSystems with strict weak ordering

2023-01-27 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: JDevlieghere.

oops


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142709/new/

https://reviews.llvm.org/D142709

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


[Lldb-commits] [PATCH] D139957: [LLDB] Change OSO to use DieRef

2023-01-27 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DIERef.h:32
 
-  DIERef(std::optional dwo_num, Section section,
+  DIERef(std::optional dwo_oso_num, Section section,
  dw_offset_t die_offset)

ayermolo wrote:
> labath wrote:
> > Where is this constructor being used?
> In SymbolFileDWARF.cpp
> SymbolFileDWARF::GetUID
> SymbolFileDWARF::DecodeUID
I'm sorry, I must have clicked the wrong line. My question was about the 
constructor below this (line 40).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139957/new/

https://reviews.llvm.org/D139957

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


[Lldb-commits] [PATCH] D142709: [lldb][Target] GetScratchTypeSystems: sort TypeSystems with strict weak ordering

2023-01-27 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added reviewers: aprantl, labath.
Herald added subscribers: mgrang, kristof.beyls.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

`std::sort` requires a comparison operator that obides by strict weak
ordering. `operator<=` on pointer does not and leads to undefined
behaviour. Specifically, when we grow the `scratch_type_systems` vector
slightly larger (and thus take `std::sort` down a slightly different
codepath), we segfault. This happened while working on a patch that
would in fact grow this vector. In such a case ASAN reports:

  $ ./bin/lldb 
./lldb-test-build.noindex/lang/cpp/complete-type-check/TestCppIsTypeComplete.test_builtin_types/a.out
 -o "script -- lldb.target.FindFirstType(\"void\")"
  (lldb) script -- lldb.target.FindFirstType("void")
  =
  ==59975==ERROR: AddressSanitizer: container-overflow on address 
0x000108f6b510 at pc 0x000280177b4c bp 0x00016b7d7430 sp 0x00016b7d7428
  READ of size 8 at 0x000108f6b510 thread T0
  #0 0x280177b48 in 
std::__1::shared_ptr::shared_ptr[abi:v15006](std::__1::shared_ptr
 const&)+0xb4 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0x177b48)
  (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
  #1 0x280dcc008 in void std::__1::__introsort*>(std::__1::shared_ptr*,
 std::__1::shared_
  ptr*, 
lldb_private::Target::GetScratchTypeSystems(bool)::$_3&, 
std::__1::iterator_traits*>::difference_type)+0x1050
 (/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblld
  b.17.0.0git.dylib:arm64+0xdcc008) (BuildId: 
ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
  #2 0x280d88788 in lldb_private::Target::GetScratchTypeSystems(bool)+0x5a4 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0xd88788)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
  #3 0x28021f0b4 in lldb::SBTarget::FindFirstType(char const*)+0x624 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0x21f0b4)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
  #4 0x2804e9590 in _wrap_SBTarget_FindFirstType(_object*, _object*)+0x26c 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0x4e9590)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
  #5 0x1062d3ad4 in cfunction_call+0x5c 
(/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/Python:arm64+0xcfad4)
 (BuildId: c9efc4bbb1943f9a9b7cc4e91fce4777320021000d00)
  
  <--- snipped --->
  
  0x000108f6b510 is located 400 bytes inside of 512-byte region 
[0x000108f6b380,0x000108f6b580)
  allocated by thread T0 here:
  #0 0x105209414 in wrap__Znwm+0x74 
(/Applications/Xcode2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:arm64e+0x51414)
 (BuildId: 0a44828ceb64337bbfff60b22cd838f032
  0021000b00)
  #1 0x280dca3b4 in 
std::__1::__split_buffer, 
std::__1::allocator>&>::__split_buffer(unsigned
 long, unsigned long, std::__1::allocator>&)+0x11c 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0xdca3b4)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
  #2 0x280dc978c in void 
std::__1::vector, 
std::__1::allocator>>::__push_back_slow_path
 const&>(std::__1::s
  hared_ptr const&)+0x13c 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0xdc978c)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
  #3 0x280d88dec in 
std::__1::vector, 
std::__1::allocator>>::push_back[abi:v15006](std::__1::shared_ptr
 const&)+0x80 (/Users/mic
  
haelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0xd88dec)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
  #4 0x280d8857c in lldb_private::Target::GetScratchTypeSystems(bool)+0x398 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0xd8857c)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
  #5 0x28021f0b4 in lldb::SBTarget::FindFirstType(char const*)+0x624 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0x21f0b4)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
  #6 0x2804e9590 in _wrap_SBTarget_FindFirstType(_object*, _object*)+0x26c 
(/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0x4e9590)
 (BuildId: ea963d2c0d47354fb647f5c5f32b76d9320021000d00)
  #7 0x1062d3ad4 in cfunction_call+0x5c 
(/opt/homebrew/Cellar

[Lldb-commits] [PATCH] D138618: [LLDB] Enable 64 bit debug/type offset

2023-01-27 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D138618#4083481 , @clayborg wrote:

> We just need to create all DIERef objects using the GetID() from the symbol 
> file as the file index, and we should be able to remove the 
> SymbolFile::GetUID() function now. As long as file index zero is reserved for 
> "vanilla DWARF that doesn't use DWO or OSO we will know the difference. We 
> might want to not have SymbolFileDWARF inherit from UserID at all, and switch 
> over to have SymbolFileDWARF add a virtual function:
>
>   uint32_t m_file_index = 0; // Zero means main DWARF file, 1...N identifies 
> the Nth DWO file or OSO file
>   virtual uint32_t GetFileIndex() { return m_file_index; }
>
> Then anyone can set the file index correctly for DWO or OSO files. And we 
> avoid using user_id_t values for the symbol files since they aren't needed.

This isn't about the "user id" of a symbol file. I'm totally happy with the 
changes there -- though I also wouldn't be opposed to changing the "user id" 
field to something more explicit (like the file index).

My problem is with the "user id"s of individual DIEs. Currently, if I have a 
DWARFDIE, the only way to get its user id is to do something like 
`die.GetDWARF()->GetUID(die)`. With this patch, there are two ways:

1. the same as before
2. `die.GetDIERef()->get_id()`

The problem is that the second way is not going to be correct for OSO files 
because that path will not set the "oso" component of the DIERef. The worst 
part is that the second method is much shorter than the first one, so I think 
it will be very tempting to use it -- and it will actually be right most of the 
time, until that code is used in an OSO context.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138618/new/

https://reviews.llvm.org/D138618

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


[Lldb-commits] [PATCH] D142266: [lldb] Add PlatformMetadata for ScriptedPlatform

2023-01-27 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

I wouldn't exactly use the word happy, but I also don't have the time to come 
up with an alternative proposal.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142266/new/

https://reviews.llvm.org/D142266

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


[Lldb-commits] [PATCH] D141828: [lldb] Add support for DW_AT_default_value in template params

2023-01-27 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

In D141828#4085191 , @Michael137 
wrote:

> In D141828#4085190 , @DavidSpickett 
> wrote:
>
>> I've reverted this due to test failures on Arm and AArch64. They were 
>> obscured by the build failure so once you'd fixed that the bot was silent 
>> about it.
>>
>> Here's one of the builds: 
>> https://lab.llvm.org/buildbot/#/builders/96/builds/34718
>>
>>   SymbolFileDWARFTests: 
>> ../llvm-project/lldb/source/Host/linux/HostInfoLinux.cpp:47: static void 
>> lldb_private::HostInfoLinux::Terminate(): Assertion `g_fields && "Missing 
>> call to Initialize?"' failed.
>
> Thanks for letting me know. The Darwin bots were also failing (but in a 
> different test https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/)
>
> Looking

The matrix bot failures are due to https://reviews.llvm.org/D141827. Fix is 
in-progress

Unit-test failures are odd since I do call `HostInfo::Initialize` in the test 
fixture setup. Investigating..


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141828/new/

https://reviews.llvm.org/D141828

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


[Lldb-commits] [PATCH] D141828: [lldb] Add support for DW_AT_default_value in template params

2023-01-27 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

It appears that they passed on Windows, could be a Linux only issue.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141828/new/

https://reviews.llvm.org/D141828

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


[Lldb-commits] [PATCH] D141828: [lldb] Add support for DW_AT_default_value in template params

2023-01-27 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

In D141828#4085190 , @DavidSpickett 
wrote:

> I've reverted this due to test failures on Arm and AArch64. They were 
> obscured by the build failure so once you'd fixed that the bot was silent 
> about it.
>
> Here's one of the builds: 
> https://lab.llvm.org/buildbot/#/builders/96/builds/34718
>
>   SymbolFileDWARFTests: 
> ../llvm-project/lldb/source/Host/linux/HostInfoLinux.cpp:47: static void 
> lldb_private::HostInfoLinux::Terminate(): Assertion `g_fields && "Missing 
> call to Initialize?"' failed.

Thanks taking a look. The Darwin bots were also failing (but in a different 
test https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/)

Looking


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141828/new/

https://reviews.llvm.org/D141828

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


[Lldb-commits] [PATCH] D141828: [lldb] Add support for DW_AT_default_value in template params

2023-01-27 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

I've reverted this due to test failures on Arm and AArch64. They were obscured 
by the build failure so once you'd fixed that the bot was silent about it.

Here's one of the builds: 
https://lab.llvm.org/buildbot/#/builders/96/builds/34718

  SymbolFileDWARFTests: 
../llvm-project/lldb/source/Host/linux/HostInfoLinux.cpp:47: static void 
lldb_private::HostInfoLinux::Terminate(): Assertion `g_fields && "Missing call 
to Initialize?"' failed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141828/new/

https://reviews.llvm.org/D141828

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


[Lldb-commits] [lldb] 1efde67 - Revert "[lldb] Add support for DW_AT_default_value in template params"

2023-01-27 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-01-27T11:36:42Z
New Revision: 1efde67d990c198b1480b2ab7b820f86388b84da

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

LOG: Revert "[lldb] Add support for DW_AT_default_value in template params"

This reverts commit 1cf52e540242f968e0cf789587bcf76c01332aeb.

Due to test failures on Arm and AArch64 bots:
https://lab.llvm.org/buildbot/#/builders/96/builds/34718

(which were obscured by an earlier build failure)

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp

Removed: 
lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_default_value-test.yaml



diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 4429b4fcae2a0..49c8fae64ed8a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2003,7 +2003,6 @@ bool DWARFASTParserClang::ParseTemplateDIE(
 CompilerType clang_type;
 uint64_t uval64 = 0;
 bool uval64_valid = false;
-bool is_default_template_arg = false;
 if (num_attributes > 0) {
   DWARFFormValue form_value;
   for (size_t i = 0; i < num_attributes; ++i) {
@@ -2034,10 +2033,6 @@ bool DWARFASTParserClang::ParseTemplateDIE(
 uval64 = form_value.Unsigned();
   }
   break;
-case DW_AT_default_value:
-  if (attributes.ExtractFormValueAtIndex(i, form_value))
-is_default_template_arg = form_value.Boolean();
-  break;
 default:
   break;
 }
@@ -2063,19 +2058,16 @@ bool DWARFASTParserClang::ParseTemplateDIE(
   template_param_infos.InsertArg(
   name,
   clang::TemplateArgument(ast, llvm::APSInt(apint, !is_signed),
-  ClangUtil::GetQualType(clang_type),
-  is_default_template_arg));
+  ClangUtil::GetQualType(clang_type)));
 } else {
   template_param_infos.InsertArg(
-  name, clang::TemplateArgument(ClangUtil::GetQualType(clang_type),
-/*isNullPtr*/ false,
-is_default_template_arg));
+  name,
+  clang::TemplateArgument(ClangUtil::GetQualType(clang_type)));
 }
   } else {
 auto *tplt_type = m_ast.CreateTemplateTemplateParmDecl(template_name);
 template_param_infos.InsertArg(
-name, clang::TemplateArgument(clang::TemplateName(tplt_type),
-  is_default_template_arg));
+name, clang::TemplateArgument(clang::TemplateName(tplt_type)));
   }
 }
   }

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
index b20ac521c7c32..c646fccc2f5eb 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
@@ -60,7 +60,7 @@ def test_shared_ptr_variables(self):
 
 valobj = self.expect_var_path(
 "sp_str",
-type="std::shared_ptr >",
+type="std::shared_ptr, std::allocator > >",
 children=[ValueCheck(name="__ptr_", summary='"hello"')],
 )
 self.assertRegex(valobj.summary, r'^"hello"( strong=1)? weak=1$')

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
index 7ac0efb4ca742..07b1aff74cfcd 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
+++ 
b/lldb/test/API/functiona

[Lldb-commits] [PATCH] D141907: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected

2023-01-27 Thread LJC via Phabricator via lldb-commits
paperchalice updated this revision to Diff 492684.
paperchalice added a comment.

Use `LLVM_LIBRARY_OUTPUT_INTDIR`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141907/new/

https://reviews.llvm.org/D141907

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Tooling/CMakeLists.txt
  clang/runtime/CMakeLists.txt
  cmake/Modules/GetClangResourceDir.cmake
  compiler-rt/cmake/base-config-ix.cmake
  lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
  lldb/unittests/Expression/ClangParserTest.cpp
  llvm/cmake/modules/LLVMExternalProjectUtils.cmake
  openmp/CMakeLists.txt

Index: openmp/CMakeLists.txt
===
--- openmp/CMakeLists.txt
+++ openmp/CMakeLists.txt
@@ -86,8 +86,8 @@
 if(${OPENMP_STANDALONE_BUILD})
   set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}")
 else()
-  string(REGEX MATCH "[0-9]+" CLANG_VERSION ${PACKAGE_VERSION})
-  set(LIBOMP_HEADERS_INSTALL_PATH "${OPENMP_INSTALL_LIBDIR}/clang/${CLANG_VERSION}/include")
+  include(GetClangResourceDir)
+  get_clang_resource_dir(LIBOMP_HEADERS_INSTALL_PATH SUBDIR include)
 endif()
 
 # Build host runtime library, after LIBOMPTARGET variables are set since they are needed
Index: llvm/cmake/modules/LLVMExternalProjectUtils.cmake
===
--- llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -257,7 +257,11 @@
 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
   string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR
  ${PACKAGE_VERSION})
-  set(resource_dir "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION_MAJOR}")
+  if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "")
+set(resource_dir ${LLVM_TOOLS_BINARY_DIR}/${CLANG_RESOURCE_DIR})
+  else()
+set(resource_dir "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION_MAJOR}")
+  endif()
   set(flag_types ASM C CXX MODULE_LINKER SHARED_LINKER EXE_LINKER)
   foreach(type ${flag_types})
 set(${type}_flag -DCMAKE_${type}_FLAGS=-resource-dir=${resource_dir})
Index: lldb/unittests/Expression/ClangParserTest.cpp
===
--- lldb/unittests/Expression/ClangParserTest.cpp
+++ lldb/unittests/Expression/ClangParserTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 
 #include "Plugins/ExpressionParser/Clang/ClangHost.h"
 #include "TestingSupport/SubsystemRAII.h"
@@ -37,12 +38,16 @@
 TEST_F(ClangHostTest, ComputeClangResourceDirectory) {
 #if !defined(_WIN32)
   std::string path_to_liblldb = "/foo/bar/lib/";
-  std::string path_to_clang_dir =
-  "/foo/bar/" LLDB_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING;
+  std::string path_to_clang_dir = std::string(CLANG_RESOURCE_DIR).empty()
+  ? "/foo/bar/" LLDB_INSTALL_LIBDIR_BASENAME
+"/clang/" CLANG_VERSION_MAJOR_STRING
+  : "/foo/bar/bin/" CLANG_RESOURCE_DIR;
 #else
   std::string path_to_liblldb = "C:\\foo\\bar\\lib";
   std::string path_to_clang_dir =
-  "C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_MAJOR_STRING;
+  std::string(CLANG_RESOURCE_DIR).empty()
+  ? "C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_MAJOR_STRING
+  : "C:\\foo\\bar\\bin\\" CLANG_RESOURCE_DIR;
 #endif
   EXPECT_EQ(ComputeClangResourceDir(path_to_liblldb), path_to_clang_dir);
 
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
@@ -54,8 +54,11 @@
 
   static const llvm::StringRef kResourceDirSuffixes[] = {
   // LLVM.org's build of LLDB uses the clang resource directory placed
-  // in $install_dir/lib{,64}/clang/$clang_version.
-  CLANG_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING,
+  // in $install_dir/lib{,64}/clang/$clang_version or
+  // $install_dir/bin/$CLANG_RESOURCE_DIR
+  llvm::StringRef(CLANG_RESOURCE_DIR).empty()
+  ? CLANG_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING
+  : "bin/" CLANG_RESOURCE_DIR,
   // swift-lldb uses the clang resource directory copied from swift, which
   // by default is placed in $install_dir/lib{,64}/lldb/clang. LLDB places
   // it there, so we use LLDB_INSTALL_LIBDIR_BASENAME.
Index: compiler-rt/cmake/base-config-ix.cmake
===
--- compiler-rt/cmake/base-config-ix.cmake
+++ compiler-rt/cmake/base-config-ix.cmake
@@ -7,6 +7,7 @@
 include(CheckIncludeFile)
 include(CheckCXXSourceCompiles)
 include(GNUInstall