[Lldb-commits] [lldb] Reland "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds" … (PR #88442)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] c1a4456 - Reland "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds" … (#88442)

2024-04-11 Thread via lldb-commits

Author: Chelsea Cassanova
Date: 2024-04-11T20:21:16-07:00
New Revision: c1a44568911b75c98675a3c19a55b4741d861437

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

LOG: Reland "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds" … 
(#88442)

…(#88436)"

This reverts commit 1f5d130df85c2d0550dc8687ad0fa1d96856c318. The
original commit checks that the host system is "Darwin" before setting
the `MallocNanoZone` envvar, but on the Shell lit config this attribute
does not exist at the point where it is being checked which leads to a
build failure.

This commit checks the host OS correctly.

Added: 


Modified: 
lldb/test/API/lit.cfg.py
lldb/test/Shell/lit.cfg.py

Removed: 




diff  --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index f9497b632fc504..9ea389c639a013 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -121,6 +121,7 @@ def delete_module_cache(path):
 config.environment["DYLD_INSERT_LIBRARIES"] = 
find_sanitizer_runtime(
 "libclang_rt.asan_osx_dynamic.dylib"
 )
+config.environment["MallocNanoZone"] = "0"
 
 if "Thread" in config.llvm_use_sanitizer:
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"

diff  --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 31afe5151c0661..290569576ac80d 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -52,6 +52,8 @@
 # Enable sanitizer runtime flags.
 config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
+if platform.system() == "Darwin":
+config.environment["MallocNanoZone"] = "0"
 
 # Support running the test suite under the lldb-repro wrapper. This makes it
 # possible to capture a test suite run and then rerun all the test from the



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


[Lldb-commits] [lldb] Revert "Fix error in unrecognized register name handling for "SBFrame.register"" (PR #88468)

2024-04-11 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Chelsea Cassanova (chelcassanova)


Changes

Reverts llvm/llvm-project#88047. TestFrames.py is failing on x86_64 
GreenDragon: 
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/983/

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


2 Files Affected:

- (modified) lldb/bindings/interface/SBFrameExtensions.i (+1-11) 
- (modified) lldb/test/API/python_api/frame/TestFrames.py (-12) 


``diff
diff --git a/lldb/bindings/interface/SBFrameExtensions.i 
b/lldb/bindings/interface/SBFrameExtensions.i
index e0472280666ab9..43b22ed7a6b325 100644
--- a/lldb/bindings/interface/SBFrameExtensions.i
+++ b/lldb/bindings/interface/SBFrameExtensions.i
@@ -44,16 +44,6 @@ STRING_EXTENSION_OUTSIDE(SBFrame)
 def __init__(self, regs):
 self.regs = regs
 
-def __iter__(self):
-return self.get_registers()
-
-def get_registers(self):
-for i in range(0,len(self.regs)):
-rs = self.regs[i]
-for j in range (0,rs.num_children):
-reg = rs.GetChildAtIndex(j)
-yield reg
-  
 def __getitem__(self, key):
 if type(key) is str:
 for i in range(0,len(self.regs)):
@@ -62,7 +52,7 @@ STRING_EXTENSION_OUTSIDE(SBFrame)
 reg = rs.GetChildAtIndex(j)
 if reg.name == key: return reg
 else:
-return SBValue()
+return lldb.SBValue()
 
 return registers_access(self.registers)
 
diff --git a/lldb/test/API/python_api/frame/TestFrames.py 
b/lldb/test/API/python_api/frame/TestFrames.py
index dfa96d51830bae..a82b129bc8099d 100644
--- a/lldb/test/API/python_api/frame/TestFrames.py
+++ b/lldb/test/API/python_api/frame/TestFrames.py
@@ -73,19 +73,7 @@ def test_get_arg_vals_for_call_stack(self):
 gpr_reg_set = lldbutil.get_GPRs(frame)
 pc_value = gpr_reg_set.GetChildMemberWithName("pc")
 self.assertTrue(pc_value, "We should have a valid PC.")
-# Make sure we can also get this from the "register" property:
-iterator_pc_value = 0
-found_pc = False
-for reg in frame.register:
-if reg.name == "pc":
-found_pc = True
-iterator_pc_value = int(reg.GetValue(), 0)
-break
-
 pc_value_int = int(pc_value.GetValue(), 0)
-self.assertTrue(found_pc, "Found the PC value in the register 
list")
-self.assertEqual(iterator_pc_value, pc_value_int, "The methods 
of finding pc match")
-
 # Make sure on arm targets we dont mismatch PC value on the 
basis of thumb bit.
 # Frame PC will not have thumb bit set in case of a thumb
 # instruction as PC.

``




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


[Lldb-commits] [lldb] Revert "Fix error in unrecognized register name handling for "SBFrame.register"" (PR #88468)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] 9f14914 - Revert "Fix error in unrecognized register name handling for "SBFrame.register"" (#88468)

2024-04-11 Thread via lldb-commits

Author: Chelsea Cassanova
Date: 2024-04-11T20:15:43-07:00
New Revision: 9f14914753599f3879e4c273191959e2f1b3632c

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

LOG: Revert "Fix error in unrecognized register name handling for 
"SBFrame.register"" (#88468)

Reverts llvm/llvm-project#88047. TestFrames.py is failing on x86_64
GreenDragon:
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/983/

Added: 


Modified: 
lldb/bindings/interface/SBFrameExtensions.i
lldb/test/API/python_api/frame/TestFrames.py

Removed: 




diff  --git a/lldb/bindings/interface/SBFrameExtensions.i 
b/lldb/bindings/interface/SBFrameExtensions.i
index e0472280666ab9..43b22ed7a6b325 100644
--- a/lldb/bindings/interface/SBFrameExtensions.i
+++ b/lldb/bindings/interface/SBFrameExtensions.i
@@ -44,16 +44,6 @@ STRING_EXTENSION_OUTSIDE(SBFrame)
 def __init__(self, regs):
 self.regs = regs
 
-def __iter__(self):
-return self.get_registers()
-
-def get_registers(self):
-for i in range(0,len(self.regs)):
-rs = self.regs[i]
-for j in range (0,rs.num_children):
-reg = rs.GetChildAtIndex(j)
-yield reg
-  
 def __getitem__(self, key):
 if type(key) is str:
 for i in range(0,len(self.regs)):
@@ -62,7 +52,7 @@ STRING_EXTENSION_OUTSIDE(SBFrame)
 reg = rs.GetChildAtIndex(j)
 if reg.name == key: return reg
 else:
-return SBValue()
+return lldb.SBValue()
 
 return registers_access(self.registers)
 

diff  --git a/lldb/test/API/python_api/frame/TestFrames.py 
b/lldb/test/API/python_api/frame/TestFrames.py
index dfa96d51830bae..a82b129bc8099d 100644
--- a/lldb/test/API/python_api/frame/TestFrames.py
+++ b/lldb/test/API/python_api/frame/TestFrames.py
@@ -73,19 +73,7 @@ def test_get_arg_vals_for_call_stack(self):
 gpr_reg_set = lldbutil.get_GPRs(frame)
 pc_value = gpr_reg_set.GetChildMemberWithName("pc")
 self.assertTrue(pc_value, "We should have a valid PC.")
-# Make sure we can also get this from the "register" property:
-iterator_pc_value = 0
-found_pc = False
-for reg in frame.register:
-if reg.name == "pc":
-found_pc = True
-iterator_pc_value = int(reg.GetValue(), 0)
-break
-
 pc_value_int = int(pc_value.GetValue(), 0)
-self.assertTrue(found_pc, "Found the PC value in the register 
list")
-self.assertEqual(iterator_pc_value, pc_value_int, "The methods 
of finding pc match")
-
 # Make sure on arm targets we dont mismatch PC value on the 
basis of thumb bit.
 # Frame PC will not have thumb bit set in case of a thumb
 # instruction as PC.



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


[Lldb-commits] [lldb] Revert "Fix error in unrecognized register name handling for "SBFrame.register"" (PR #88468)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/88468

Reverts llvm/llvm-project#88047. TestFrames.py is failing on x86_64 
GreenDragon: 
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/983/

>From 069d90a500ed02067f3f1a5d01c7827623353b85 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 11 Apr 2024 20:12:43 -0700
Subject: [PATCH] =?UTF-8?q?Revert=20"Fix=20error=20in=20unrecognized=20reg?=
 =?UTF-8?q?ister=20name=20handling=20for=20"SBFrame.registe=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit 9a36077e4db30c7da603620762036d4a430e4e62.
---
 lldb/bindings/interface/SBFrameExtensions.i  | 12 +---
 lldb/test/API/python_api/frame/TestFrames.py | 12 
 2 files changed, 1 insertion(+), 23 deletions(-)

diff --git a/lldb/bindings/interface/SBFrameExtensions.i 
b/lldb/bindings/interface/SBFrameExtensions.i
index e0472280666ab9..43b22ed7a6b325 100644
--- a/lldb/bindings/interface/SBFrameExtensions.i
+++ b/lldb/bindings/interface/SBFrameExtensions.i
@@ -44,16 +44,6 @@ STRING_EXTENSION_OUTSIDE(SBFrame)
 def __init__(self, regs):
 self.regs = regs
 
-def __iter__(self):
-return self.get_registers()
-
-def get_registers(self):
-for i in range(0,len(self.regs)):
-rs = self.regs[i]
-for j in range (0,rs.num_children):
-reg = rs.GetChildAtIndex(j)
-yield reg
-  
 def __getitem__(self, key):
 if type(key) is str:
 for i in range(0,len(self.regs)):
@@ -62,7 +52,7 @@ STRING_EXTENSION_OUTSIDE(SBFrame)
 reg = rs.GetChildAtIndex(j)
 if reg.name == key: return reg
 else:
-return SBValue()
+return lldb.SBValue()
 
 return registers_access(self.registers)
 
diff --git a/lldb/test/API/python_api/frame/TestFrames.py 
b/lldb/test/API/python_api/frame/TestFrames.py
index dfa96d51830bae..a82b129bc8099d 100644
--- a/lldb/test/API/python_api/frame/TestFrames.py
+++ b/lldb/test/API/python_api/frame/TestFrames.py
@@ -73,19 +73,7 @@ def test_get_arg_vals_for_call_stack(self):
 gpr_reg_set = lldbutil.get_GPRs(frame)
 pc_value = gpr_reg_set.GetChildMemberWithName("pc")
 self.assertTrue(pc_value, "We should have a valid PC.")
-# Make sure we can also get this from the "register" property:
-iterator_pc_value = 0
-found_pc = False
-for reg in frame.register:
-if reg.name == "pc":
-found_pc = True
-iterator_pc_value = int(reg.GetValue(), 0)
-break
-
 pc_value_int = int(pc_value.GetValue(), 0)
-self.assertTrue(found_pc, "Found the PC value in the register 
list")
-self.assertEqual(iterator_pc_value, pc_value_int, "The methods 
of finding pc match")
-
 # Make sure on arm targets we dont mismatch PC value on the 
basis of thumb bit.
 # Frame PC will not have thumb bit set in case of a thumb
 # instruction as PC.

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


[Lldb-commits] [lldb] Reland "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds" … (PR #88442)

2024-04-11 Thread Jason Molenda via lldb-commits

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

This looks good to me.

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


[Lldb-commits] [lldb] Fix error in unrecognized register name handling for "SBFrame.register" (PR #88047)

2024-04-11 Thread via lldb-commits

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


[Lldb-commits] [lldb] 9a36077 - Fix error in unrecognized register name handling for "SBFrame.register" (#88047)

2024-04-11 Thread via lldb-commits

Author: jimingham
Date: 2024-04-11T15:22:58-07:00
New Revision: 9a36077e4db30c7da603620762036d4a430e4e62

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

LOG: Fix error in unrecognized register name handling for "SBFrame.register" 
(#88047)

The code returned lldb.SBValue() when you passed in an unrecognized
register name. But referring to "lldb" is apparently not legal within
the module.

I changed this to just return SBValue(), but then this construct:

(lldb) script
>>> for reg_set in lldb.target.process.thread[0].frames[0].register
...print(reg)

Runs forever printing "No Value". The __getitem__(key) gets called with
a monotonically increasing by 1 series of integers. I don't know why
Python decided the class we defined should have a generator that returns
positive integers in order, but we can add a more useful one here by
returning an iterator over the flattened list of registers.

Note, the not very aptly named "SBFrame.registers" is an iterator over
register sets, not registers, so the two are not redundant.

Added: 


Modified: 
lldb/bindings/interface/SBFrameExtensions.i
lldb/test/API/python_api/frame/TestFrames.py

Removed: 




diff  --git a/lldb/bindings/interface/SBFrameExtensions.i 
b/lldb/bindings/interface/SBFrameExtensions.i
index 43b22ed7a6b325..e0472280666ab9 100644
--- a/lldb/bindings/interface/SBFrameExtensions.i
+++ b/lldb/bindings/interface/SBFrameExtensions.i
@@ -44,6 +44,16 @@ STRING_EXTENSION_OUTSIDE(SBFrame)
 def __init__(self, regs):
 self.regs = regs
 
+def __iter__(self):
+return self.get_registers()
+
+def get_registers(self):
+for i in range(0,len(self.regs)):
+rs = self.regs[i]
+for j in range (0,rs.num_children):
+reg = rs.GetChildAtIndex(j)
+yield reg
+  
 def __getitem__(self, key):
 if type(key) is str:
 for i in range(0,len(self.regs)):
@@ -52,7 +62,7 @@ STRING_EXTENSION_OUTSIDE(SBFrame)
 reg = rs.GetChildAtIndex(j)
 if reg.name == key: return reg
 else:
-return lldb.SBValue()
+return SBValue()
 
 return registers_access(self.registers)
 

diff  --git a/lldb/test/API/python_api/frame/TestFrames.py 
b/lldb/test/API/python_api/frame/TestFrames.py
index a82b129bc8099d..dfa96d51830bae 100644
--- a/lldb/test/API/python_api/frame/TestFrames.py
+++ b/lldb/test/API/python_api/frame/TestFrames.py
@@ -73,7 +73,19 @@ def test_get_arg_vals_for_call_stack(self):
 gpr_reg_set = lldbutil.get_GPRs(frame)
 pc_value = gpr_reg_set.GetChildMemberWithName("pc")
 self.assertTrue(pc_value, "We should have a valid PC.")
+# Make sure we can also get this from the "register" property:
+iterator_pc_value = 0
+found_pc = False
+for reg in frame.register:
+if reg.name == "pc":
+found_pc = True
+iterator_pc_value = int(reg.GetValue(), 0)
+break
+
 pc_value_int = int(pc_value.GetValue(), 0)
+self.assertTrue(found_pc, "Found the PC value in the register 
list")
+self.assertEqual(iterator_pc_value, pc_value_int, "The methods 
of finding pc match")
+
 # Make sure on arm targets we dont mismatch PC value on the 
basis of thumb bit.
 # Frame PC will not have thumb bit set in case of a thumb
 # instruction as PC.



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


[Lldb-commits] [lldb] Reland "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds" … (PR #88442)

2024-04-11 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Chelsea Cassanova (chelcassanova)


Changes

…(#88436)"

This reverts commit 1f5d130df85c2d0550dc8687ad0fa1d96856c318. The original 
commit checks that the host system is "Darwin" before setting the 
`MallocNanoZone` envvar, but on the Shell lit config this attribute does not 
exist at the point where it is being checked which leads to a build failure.

This commit checks the host OS correctly.

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


2 Files Affected:

- (modified) lldb/test/API/lit.cfg.py (+1) 
- (modified) lldb/test/Shell/lit.cfg.py (+2) 


``diff
diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index f9497b632fc504..9ea389c639a013 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -121,6 +121,7 @@ def delete_module_cache(path):
 config.environment["DYLD_INSERT_LIBRARIES"] = 
find_sanitizer_runtime(
 "libclang_rt.asan_osx_dynamic.dylib"
 )
+config.environment["MallocNanoZone"] = "0"
 
 if "Thread" in config.llvm_use_sanitizer:
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 31afe5151c0661..290569576ac80d 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -52,6 +52,8 @@
 # Enable sanitizer runtime flags.
 config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
+if platform.system() == "Darwin":
+config.environment["MallocNanoZone"] = "0"
 
 # Support running the test suite under the lldb-repro wrapper. This makes it
 # possible to capture a test suite run and then rerun all the test from the

``




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


[Lldb-commits] [lldb] Reland "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds" … (PR #88442)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/88442

…(#88436)"

This reverts commit 1f5d130df85c2d0550dc8687ad0fa1d96856c318. The original 
commit checks that the host system is "Darwin" before setting the 
`MallocNanoZone` envvar, but on the Shell lit config this attribute does not 
exist at the point where it is being checked which leads to a build failure.

This commit checks the host OS correctly.

>From dc964330c1409a2089c54114d1efea43cc835599 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 11 Apr 2024 14:18:22 -0700
Subject: [PATCH] Reland "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan
 builds" (#88436)"

This reverts commit 1f5d130df85c2d0550dc8687ad0fa1d96856c318. The
original commit checks that the host system is "Darwin" before setting
the `MallocNanoZone` envvar, but on the Shell lit config this attribute
does not exist at the point where it is being checked which leads to a
build failure.

This commit checks the host OS correctly.
---
 lldb/test/API/lit.cfg.py   | 1 +
 lldb/test/Shell/lit.cfg.py | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index f9497b632fc504..9ea389c639a013 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -121,6 +121,7 @@ def delete_module_cache(path):
 config.environment["DYLD_INSERT_LIBRARIES"] = 
find_sanitizer_runtime(
 "libclang_rt.asan_osx_dynamic.dylib"
 )
+config.environment["MallocNanoZone"] = "0"
 
 if "Thread" in config.llvm_use_sanitizer:
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 31afe5151c0661..290569576ac80d 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -52,6 +52,8 @@
 # Enable sanitizer runtime flags.
 config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
+if platform.system() == "Darwin":
+config.environment["MallocNanoZone"] = "0"
 
 # Support running the test suite under the lldb-repro wrapper. This makes it
 # possible to capture a test suite run and then rerun all the test from the

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


[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread Usama Hameed via lldb-commits

usama54321 wrote:

> Will this test primarily be run at-desk? Or will it be a part of existing CI? 
> I know we have discussed this previously, I just want to confirm as I'm 
> putting together documentation for this kind of testing for libsanitizers. 
> I'd love to make note somewhere where we expect to run this.
> 
> Otherwise this test lgtm from the sanitizers side.

This is primarily for at-desk testing until libsanitizers is available in the 
CI. Let's add that to internal documentation

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


[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread Usama Hameed via lldb-commits

usama54321 wrote:

Changed the no_libsanitizers function to use the LLDB image list command

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


[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread Usama Hameed via lldb-commits

https://github.com/usama54321 updated 
https://github.com/llvm/llvm-project/pull/88349

>From 59ee9026bc0d35bcde83ff45aacb272bb39902b0 Mon Sep 17 00:00:00 2001
From: usama 
Date: Wed, 10 Apr 2024 21:07:11 -0700
Subject: [PATCH] [LLDB] Add asan tests for libsanitizers.

This patch tests LLDB integration with libsanitizers for ASan. This
integration works through the ASanLibsanitizers plugin in the
InstrumentationRuntime.

rdar://111856681
---
 lldb/test/API/functionalities/asan/Makefile   |  6 +-
 .../functionalities/asan/TestMemoryHistory.py | 73 ++-
 .../functionalities/asan/TestReportData.py| 20 -
 .../API/functionalities/libsanitizers/util.py |  3 +
 4 files changed, 97 insertions(+), 5 deletions(-)
 create mode 100644 lldb/test/API/functionalities/libsanitizers/util.py

diff --git a/lldb/test/API/functionalities/asan/Makefile 
b/lldb/test/API/functionalities/asan/Makefile
index 4913a18d8cc6f9..d66696fed7078f 100644
--- a/lldb/test/API/functionalities/asan/Makefile
+++ b/lldb/test/API/functionalities/asan/Makefile
@@ -1,4 +1,8 @@
 C_SOURCES := main.c
-CFLAGS_EXTRAS := -fsanitize=address -g -gcolumn-info
+asan: CFLAGS_EXTRAS := -fsanitize=address -g -gcolumn-info
+asan: all
+
+libsanitizers: CFLAGS_EXTRAS := -fsanitize=address -fsanitize-stable-abi -g 
-gcolumn-info
+libsanitizers: all
 
 include Makefile.rules
diff --git a/lldb/test/API/functionalities/asan/TestMemoryHistory.py 
b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
index 00162ae8822c74..ee7939203ead18 100644
--- a/lldb/test/API/functionalities/asan/TestMemoryHistory.py
+++ b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
@@ -9,15 +9,21 @@
 from lldbsuite.test import lldbplatform
 from lldbsuite.test import lldbutil
 
+from functionalities.libsanitizers.util import no_libsanitizers
 
 class AsanTestCase(TestBase):
 @skipIfFreeBSD  # llvm.org/pr21136 runtimes not yet available by default
 @expectedFailureNetBSD
 @skipUnlessAddressSanitizer
 def test(self):
-self.build()
+self.build(make_targets=["asan"])
 self.asan_tests()
 
+@skipIf(oslist=no_match(["macosx"]))
+def test_libsanitizers_asan(self):
+self.build(make_targets=["libsanitizers"])
+self.libsanitizer_tests()
+
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
@@ -26,6 +32,71 @@ def setUp(self):
 self.line_free = line_number("main.c", "// free line")
 self.line_breakpoint = line_number("main.c", "// break line")
 
+# Test line numbers: rdar://126237493
+def libsanitizer_tests(self):
+target = self.createTestTarget()
+
+if no_libsanitizers(self):
+self.skipTest("libsanitizers not found")
+
+self.runCmd(
+"env SanitizersAddress=1 MallocSanitizerZone=1 
MallocSecureAllocator=0"
+)
+
+self.runCmd("run")
+
+# In libsanitizers, memory history is not supported until a report has 
been generated
+self.expect(
+"thread list",
+"Process should be stopped due to ASan report",
+substrs=["stopped", "stop reason = Use of deallocated memory"],
+)
+
+# test the 'memory history' command
+self.expect(
+"memory history 'pointer'",
+substrs=[
+"Memory deallocated by Thread",
+"a.out`f2",
+"main.c",
+"Memory allocated by Thread",
+"a.out`f1",
+"main.c",
+],
+)
+
+# do the same using SB API
+process = self.dbg.GetSelectedTarget().process
+val = (
+
process.GetSelectedThread().GetSelectedFrame().EvaluateExpression("pointer")
+)
+addr = val.GetValueAsUnsigned()
+threads = process.GetHistoryThreads(addr)
+self.assertEqual(threads.GetSize(), 2)
+
+history_thread = threads.GetThreadAtIndex(0)
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
+history_thread = threads.GetThreadAtIndex(1)
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
+# let's free the container (SBThreadCollection) and see if the
+# SBThreads still live
+threads = None
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
 def asan_tests(self):
 target = self.createTestTarget()
 
diff --git a/lldb/test/API/functionalities/asan/TestReportData.py 
b/lldb/test/API/functionalities/asan/TestReportData.py
index 543c5fe66a208d..de0c1206a57ad6 

[Lldb-commits] [lldb] Revert "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds" (PR #88436)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] 1f5d130 - Revert "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds" (#88436)

2024-04-11 Thread via lldb-commits

Author: Chelsea Cassanova
Date: 2024-04-11T13:46:32-07:00
New Revision: 1f5d130df85c2d0550dc8687ad0fa1d96856c318

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

LOG: Revert "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds" 
(#88436)

Reverts llvm/llvm-project#88431. A config variable for the host OS is
unrecognized on the Linux builds and is causing a build failure.

Added: 


Modified: 
lldb/test/API/lit.cfg.py
lldb/test/Shell/lit.cfg.py

Removed: 




diff  --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 9ea389c639a013..f9497b632fc504 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -121,7 +121,6 @@ def delete_module_cache(path):
 config.environment["DYLD_INSERT_LIBRARIES"] = 
find_sanitizer_runtime(
 "libclang_rt.asan_osx_dynamic.dylib"
 )
-config.environment["MallocNanoZone"] = "0"
 
 if "Thread" in config.llvm_use_sanitizer:
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"

diff  --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 345627835d2bf2..31afe5151c0661 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -52,8 +52,6 @@
 # Enable sanitizer runtime flags.
 config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
-if "Darwin" in config.host_os:
-config.environment["MallocNanoZone"] = "0"
 
 # Support running the test suite under the lldb-repro wrapper. This makes it
 # possible to capture a test suite run and then rerun all the test from the



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


[Lldb-commits] [lldb] Revert "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds" (PR #88436)

2024-04-11 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Chelsea Cassanova (chelcassanova)


Changes

Reverts llvm/llvm-project#88431. A config variable for the host OS is 
unrecognized on the Linux builds and is causing a build failure.

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


2 Files Affected:

- (modified) lldb/test/API/lit.cfg.py (-1) 
- (modified) lldb/test/Shell/lit.cfg.py (-2) 


``diff
diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 9ea389c639a013..f9497b632fc504 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -121,7 +121,6 @@ def delete_module_cache(path):
 config.environment["DYLD_INSERT_LIBRARIES"] = 
find_sanitizer_runtime(
 "libclang_rt.asan_osx_dynamic.dylib"
 )
-config.environment["MallocNanoZone"] = "0"
 
 if "Thread" in config.llvm_use_sanitizer:
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 345627835d2bf2..31afe5151c0661 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -52,8 +52,6 @@
 # Enable sanitizer runtime flags.
 config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
-if "Darwin" in config.host_os:
-config.environment["MallocNanoZone"] = "0"
 
 # Support running the test suite under the lldb-repro wrapper. This makes it
 # possible to capture a test suite run and then rerun all the test from the

``




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


[Lldb-commits] [lldb] Revert "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds" (PR #88436)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/88436

Reverts llvm/llvm-project#88431. A config variable for the host OS is 
unrecognized on the Linux builds and is causing a build failure.

>From 79a4eb5047d8c90568b04ad5fb90e6421e1aba69 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 11 Apr 2024 13:41:48 -0700
Subject: [PATCH] Revert "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan
 builds (#88431)"

This reverts commit 4df854e1a98ed47c955838d2c94bf2913c50041f.
---
 lldb/test/API/lit.cfg.py   | 1 -
 lldb/test/Shell/lit.cfg.py | 2 --
 2 files changed, 3 deletions(-)

diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 9ea389c639a013..f9497b632fc504 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -121,7 +121,6 @@ def delete_module_cache(path):
 config.environment["DYLD_INSERT_LIBRARIES"] = 
find_sanitizer_runtime(
 "libclang_rt.asan_osx_dynamic.dylib"
 )
-config.environment["MallocNanoZone"] = "0"
 
 if "Thread" in config.llvm_use_sanitizer:
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 345627835d2bf2..31afe5151c0661 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -52,8 +52,6 @@
 # Enable sanitizer runtime flags.
 config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
-if "Darwin" in config.host_os:
-config.environment["MallocNanoZone"] = "0"
 
 # Support running the test suite under the lldb-repro wrapper. This makes it
 # possible to capture a test suite run and then rerun all the test from the

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


[Lldb-commits] [lldb] [lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds (PR #88431)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] 4df854e - [lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds (#88431)

2024-04-11 Thread via lldb-commits

Author: Chelsea Cassanova
Date: 2024-04-11T13:38:26-07:00
New Revision: 4df854e1a98ed47c955838d2c94bf2913c50041f

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

LOG: [lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds (#88431)

When builds on Darwin are configured with ASan, running tests will emit
a warning about malloc's nano zone (`malloc: nano zone abandoned due to 
inability to reserve vm space`) that can interfere with the test
output and cause failures. Setting the environment variable
`MallocNanoZone` to 0 will remove this warning and allow the tests to
run as normal.

Added: 


Modified: 
lldb/test/API/lit.cfg.py
lldb/test/Shell/lit.cfg.py

Removed: 




diff  --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index f9497b632fc504..9ea389c639a013 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -121,6 +121,7 @@ def delete_module_cache(path):
 config.environment["DYLD_INSERT_LIBRARIES"] = 
find_sanitizer_runtime(
 "libclang_rt.asan_osx_dynamic.dylib"
 )
+config.environment["MallocNanoZone"] = "0"
 
 if "Thread" in config.llvm_use_sanitizer:
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"

diff  --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 31afe5151c0661..345627835d2bf2 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -52,6 +52,8 @@
 # Enable sanitizer runtime flags.
 config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
+if "Darwin" in config.host_os:
+config.environment["MallocNanoZone"] = "0"
 
 # Support running the test suite under the lldb-repro wrapper. This makes it
 # possible to capture a test suite run and then rerun all the test from the



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


[Lldb-commits] [lldb] [lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds (PR #88431)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

chelcassanova wrote:

If that's the case then I'll just merge this in.

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


[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread Jonas Devlieghere via lldb-commits

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

`dyld_shared_cache_util` doesn't come preinstalled on macOS (you can build it 
yourself locally from source) so I think we should use lldb to check if the 
library is loaded.

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


[Lldb-commits] [lldb] [lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds (PR #88431)

2024-04-11 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> LGTM! It would be nice to may be put a link to a bot that shows those warnings

Those logs get recycled pretty quickly so that would only be valuable for a 
handful of days. 

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


[Lldb-commits] [lldb] [lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds (PR #88431)

2024-04-11 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds (PR #88431)

2024-04-11 Thread Med Ismail Bennani via lldb-commits

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

LGTM! It would be nice to may be put a link to a bot that shows those warnings

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


[Lldb-commits] [lldb] [lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds (PR #88431)

2024-04-11 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Chelsea Cassanova (chelcassanova)


Changes

When builds on Darwin are configured with ASan, running tests will emit a 
warning about malloc's nano zone that can interfere with the test output and 
cause failures. Setting the environment variable `MallocNanoZone` to 0 will 
remove this warning and allow the tests to run as normal.

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


2 Files Affected:

- (modified) lldb/test/API/lit.cfg.py (+1) 
- (modified) lldb/test/Shell/lit.cfg.py (+2) 


``diff
diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index f9497b632fc504..9ea389c639a013 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -121,6 +121,7 @@ def delete_module_cache(path):
 config.environment["DYLD_INSERT_LIBRARIES"] = 
find_sanitizer_runtime(
 "libclang_rt.asan_osx_dynamic.dylib"
 )
+config.environment["MallocNanoZone"] = "0"
 
 if "Thread" in config.llvm_use_sanitizer:
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 31afe5151c0661..345627835d2bf2 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -52,6 +52,8 @@
 # Enable sanitizer runtime flags.
 config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
+if "Darwin" in config.host_os:
+config.environment["MallocNanoZone"] = "0"
 
 # Support running the test suite under the lldb-repro wrapper. This makes it
 # possible to capture a test suite run and then rerun all the test from the

``




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


[Lldb-commits] [lldb] [lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds (PR #88431)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/88431

When builds on Darwin are configured with ASan, running tests will emit a 
warning about malloc's nano zone that can interfere with the test output and 
cause failures. Setting the environment variable `MallocNanoZone` to 0 will 
remove this warning and allow the tests to run as normal.

>From 13184a3e7da4972feb6fc73878303301b8aa739d Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 11 Apr 2024 11:06:52 -0700
Subject: [PATCH] [lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds

When builds are Darwin are configured with ASan, running tests will emit
a warning that can interfere with the test output and cause failures.
Setting the environment variable `MallocNanoZone` to 0 will remove this
warning and allow the tests to run as normal.
---
 lldb/test/API/lit.cfg.py   | 1 +
 lldb/test/Shell/lit.cfg.py | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index f9497b632fc504..9ea389c639a013 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -121,6 +121,7 @@ def delete_module_cache(path):
 config.environment["DYLD_INSERT_LIBRARIES"] = 
find_sanitizer_runtime(
 "libclang_rt.asan_osx_dynamic.dylib"
 )
+config.environment["MallocNanoZone"] = "0"
 
 if "Thread" in config.llvm_use_sanitizer:
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 31afe5151c0661..345627835d2bf2 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -52,6 +52,8 @@
 # Enable sanitizer runtime flags.
 config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
+if "Darwin" in config.host_os:
+config.environment["MallocNanoZone"] = "0"
 
 # Support running the test suite under the lldb-repro wrapper. This makes it
 # possible to capture a test suite run and then rerun all the test from the

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


[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread via lldb-commits

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


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


[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread via lldb-commits

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


[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread via lldb-commits


@@ -26,6 +33,68 @@ def setUp(self):
 self.line_free = line_number("main.c", "// free line")
 self.line_breakpoint = line_number("main.c", "// break line")
 
+# Test line numbers: rdar://126237493
+def libsanitizer_tests(self):
+target = self.createTestTarget()
+
+self.runCmd(

thetruestblue wrote:

Another instance of where we will need to remove these in the future when 
they're no longer needed.

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


[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread via lldb-commits

thetruestblue wrote:

Will this test primarily be run at-desk? Or will it be a part of existing CI? I 
know we have discussed this previously, I just want to confirm as I'm putting 
together documentation for this kind of testing for libsanitizers

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


[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread Usama Hameed via lldb-commits

usama54321 wrote:

Added a util function to skip tests if libsanitizers is not present in the 
shared cache

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


[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread Usama Hameed via lldb-commits

https://github.com/usama54321 updated 
https://github.com/llvm/llvm-project/pull/88349

>From b25a5a0b5beb249c8a646cbfc02b865ca91ab861 Mon Sep 17 00:00:00 2001
From: usama 
Date: Wed, 10 Apr 2024 21:07:11 -0700
Subject: [PATCH] [LLDB] Add asan tests for libsanitizers.

This patch tests LLDB integration with libsanitizers for ASan. This
integration works through the ASanLibsanitizers plugin in the
InstrumentationRuntime.

rdar://111856681
---
 lldb/test/API/functionalities/asan/Makefile   |  6 +-
 .../functionalities/asan/TestMemoryHistory.py | 71 ++-
 .../functionalities/asan/TestReportData.py| 18 -
 .../API/functionalities/libsanitizers/util.py | 13 
 4 files changed, 103 insertions(+), 5 deletions(-)
 create mode 100644 lldb/test/API/functionalities/libsanitizers/util.py

diff --git a/lldb/test/API/functionalities/asan/Makefile 
b/lldb/test/API/functionalities/asan/Makefile
index 4913a18d8cc6f9..d66696fed7078f 100644
--- a/lldb/test/API/functionalities/asan/Makefile
+++ b/lldb/test/API/functionalities/asan/Makefile
@@ -1,4 +1,8 @@
 C_SOURCES := main.c
-CFLAGS_EXTRAS := -fsanitize=address -g -gcolumn-info
+asan: CFLAGS_EXTRAS := -fsanitize=address -g -gcolumn-info
+asan: all
+
+libsanitizers: CFLAGS_EXTRAS := -fsanitize=address -fsanitize-stable-abi -g 
-gcolumn-info
+libsanitizers: all
 
 include Makefile.rules
diff --git a/lldb/test/API/functionalities/asan/TestMemoryHistory.py 
b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
index 00162ae8822c74..80961984174df7 100644
--- a/lldb/test/API/functionalities/asan/TestMemoryHistory.py
+++ b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
@@ -9,15 +9,22 @@
 from lldbsuite.test import lldbplatform
 from lldbsuite.test import lldbutil
 
+from functionalities.libsanitizers.util import no_libsanitizers
 
 class AsanTestCase(TestBase):
 @skipIfFreeBSD  # llvm.org/pr21136 runtimes not yet available by default
 @expectedFailureNetBSD
 @skipUnlessAddressSanitizer
 def test(self):
-self.build()
+self.build(make_targets=["asan"])
 self.asan_tests()
 
+@skipIf(oslist=no_match(["macosx"]))
+@skipTestIfFn(no_libsanitizers)
+def test_libsanitizers_asan(self):
+self.build(make_targets=["libsanitizers"])
+self.libsanitizer_tests()
+
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
@@ -26,6 +33,68 @@ def setUp(self):
 self.line_free = line_number("main.c", "// free line")
 self.line_breakpoint = line_number("main.c", "// break line")
 
+# Test line numbers: rdar://126237493
+def libsanitizer_tests(self):
+target = self.createTestTarget()
+
+self.runCmd(
+"env SanitizersAddress=1 MallocSanitizerZone=1 
MallocSecureAllocator=0"
+)
+
+self.runCmd("run")
+
+# In libsanitizers, memory history is not supported until a report has 
been generated
+self.expect(
+"thread list",
+"Process should be stopped due to ASan report",
+substrs=["stopped", "stop reason = Use of deallocated memory"],
+)
+
+# test the 'memory history' command
+self.expect(
+"memory history 'pointer'",
+substrs=[
+"Memory deallocated by Thread",
+"a.out`f2",
+"main.c",
+"Memory allocated by Thread",
+"a.out`f1",
+"main.c",
+],
+)
+
+# do the same using SB API
+process = self.dbg.GetSelectedTarget().process
+val = (
+
process.GetSelectedThread().GetSelectedFrame().EvaluateExpression("pointer")
+)
+addr = val.GetValueAsUnsigned()
+threads = process.GetHistoryThreads(addr)
+self.assertEqual(threads.GetSize(), 2)
+
+history_thread = threads.GetThreadAtIndex(0)
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
+history_thread = threads.GetThreadAtIndex(1)
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
+# let's free the container (SBThreadCollection) and see if the
+# SBThreads still live
+threads = None
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
 def asan_tests(self):
 target = self.createTestTarget()
 
diff --git a/lldb/test/API/functionalities/asan/TestReportData.py 
b/lldb/test/API/functionalities/asan/TestReportData.py
index 543c5fe66a208d..43bcbedb56d4c9 100644
--- 

[Lldb-commits] [lldb] [lldb][test] Add tests for evaluating local variables whose name clashes with Objective-C types (PR #87807)

2024-04-11 Thread Michael Buch via lldb-commits

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

>From 734e127b758b00210aa508c84d0222165c036ac4 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 5 Apr 2024 12:10:09 +0100
Subject: [PATCH] [lldb][test] Add tests for evaluating local variables whose
 name clashes with Objective-C types

Depends on https://github.com/llvm/llvm-project/pull/87767
---
 .../objc-builtin-types/TestObjCBuiltinTypes.py  | 13 +
 .../API/lang/objcxx/objc-builtin-types/main.cpp |  8 +++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git 
a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py 
b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
index 611c7388999058..19ae2f091bdd5e 100644
--- a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
+++ b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
@@ -13,6 +13,7 @@ def setUp(self):
 # Find the line numbers to break inside main().
 self.main_source = "main.cpp"
 self.break_line = line_number(self.main_source, "// Set breakpoint 
here.")
+self.bar_break_line = line_number(self.main_source, "return id + 
Class")
 
 @add_test_categories(["pyapi"])
 def test_with_python_api(self):
@@ -26,6 +27,11 @@ def test_with_python_api(self):
 bpt = target.BreakpointCreateByLocation(self.main_source, 
self.break_line)
 self.assertTrue(bpt, VALID_BREAKPOINT)
 
+bar_bpt = target.BreakpointCreateByLocation(
+self.main_source, self.bar_break_line
+)
+self.assertTrue(bar_bpt, VALID_BREAKPOINT)
+
 # Now launch the process, and do not stop at entry point.
 process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
 
@@ -52,3 +58,10 @@ def test_with_python_api(self):
 patterns=["\(id\) \$.* = nil"],
 )
 self.expect("expr --language C++ -- id my_id = 0; my_id", error=True)
+
+lldbutil.continue_to_breakpoint(process, bar_bpt)
+
+self.expect_expr("id", result_value="12", result_type="int")
+self.expect_expr("Class", result_value="15", result_type="int")
+self.expect("expr --language C++ -- id", error=True)
+self.expect("expr --language C++ -- Class", error=True)
diff --git a/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp 
b/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp
index 6dd8cbc6e9fef6..5b35ec0f0b8c98 100644
--- a/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp
+++ b/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp
@@ -2,8 +2,14 @@ namespace ns {
   typedef int id;
 };
 
+int bar() {
+  int id = 12;
+  int Class = 15;
+  return id + Class;
+}
+
 int main()
 {
   ns::id foo = 0;
-  return foo; // Set breakpoint here.
+  return foo + bar(); // Set breakpoint here.
 }

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


[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Don't by default enable Objecitve-C support when evaluating C++ expressions (PR #87767)

2024-04-11 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] 38f8fce - [lldb][ClangExpressionParser] Don't by default enable Objecitve-C support when evaluating C++ expressions (#87767)

2024-04-11 Thread via lldb-commits

Author: Michael Buch
Date: 2024-04-11T20:30:48+02:00
New Revision: 38f8fcea3455ef1d77faf9746579f52b4e18dacc

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

LOG: [lldb][ClangExpressionParser] Don't by default enable Objecitve-C support 
when evaluating C++ expressions (#87767)

This patch attempts to decouple C++ expression evaluation from
Objective-C support. We've previously enabled it by default (if a
runtime existed), but that meant we're opting into extra work we only
need to do for Objective-C, which complicates/slows down C++ expression
evaluation. Of course there's a valid use-case for this, which is
calling Objective-C APIs when stopped in C++ frames (which Objective-C++
developers might want to do). In those cases we should really prompt the
user to add the `expr --language objc++` flag. To accomodate a likely
frequent use-case where a user breaks in a system C++ library (without
debug-symbols) but their application is actually an Objective-C app, we
allow Objective-C support in C++ expressions if the current frame
doesn't have debug-info.

This fixes https://github.com/llvm/llvm-project/issues/75443 and allows
us to add more `LangOpts.ObjC` guards around the expression evaluator in
the future (e.g., we could avoid looking into the Objective-C runtime
during C++ expression evaluation, which we currently do
unconditionally).

Depends on https://github.com/llvm/llvm-project/pull/87657

Added: 
lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/Makefile

lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/TestObjCFromCppFramesWithoutDebugInfo.py
lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/main.cpp

Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
lldb/test/API/commands/expression/options/TestExprOptions.py
lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 822d286cd6c3c4..f48bdc730d9160 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -526,7 +526,10 @@ ClangExpressionParser::ClangExpressionParser(
 [[fallthrough]];
   case lldb::eLanguageTypeC_plus_plus_03:
 lang_opts.CPlusPlus = true;
-if (process_sp)
+if (process_sp
+// We're stopped in a frame without debug-info. The user probably
+// intends to make global queries (which should include Objective-C).
+&& !(frame_sp && frame_sp->HasDebugInformation()))
   lang_opts.ObjC =
   process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC) != nullptr;
 break;

diff  --git 
a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py 
b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
index d64e9897a844f1..ddc1c3598480cf 100644
--- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
+++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
@@ -172,7 +172,7 @@ def test_source_locations_from_objc_modules(self):
 
 # Import foundation so that the Obj-C module is loaded (which contains 
source locations
 # that can be used by LLDB).
-self.runCmd("expr @import Foundation")
+self.runCmd("expr --language objective-c++ -- @import Foundation")
 value = frame.EvaluateExpression("NSLog(1);")
 self.assertFalse(value.GetError().Success())
 # LLDB should print the source line that defines NSLog. To not rely on 
any

diff  --git a/lldb/test/API/commands/expression/options/TestExprOptions.py 
b/lldb/test/API/commands/expression/options/TestExprOptions.py
index 6652c71083a958..01899f3b97cf44 100644
--- a/lldb/test/API/commands/expression/options/TestExprOptions.py
+++ b/lldb/test/API/commands/expression/options/TestExprOptions.py
@@ -59,7 +59,6 @@ def test_expr_options(self):
 self.assertTrue(val.IsValid())
 self.assertFalse(val.GetError().Success())
 
-@skipIfDarwin
 def test_expr_options_lang(self):
 """These expression language options should work as expected."""
 self.build()

diff  --git 
a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py 
b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
index 1eb7205f1bb465..611c7388999058 100644
--- a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
+++ b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
@@ -51,7 +51,4 @@ def 

[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Don't by default enable Objecitve-C support when evaluating C++ expressions (PR #87767)

2024-04-11 Thread Michael Buch via lldb-commits

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

>From f27a547ab85463f182ab63949bb6f11140a2f33f Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 5 Apr 2024 11:51:47 +0100
Subject: [PATCH 1/2] [lldb][ClangExpressionParser] Don't by default enable
 Objecitve-C support when evaluating C++ expressions

This patch attempts to decouple C++ expression evaluation from
Objective-C support. We've previously enabled it by default
(if a runtime existed), but that meant we're opting into extra
work we only need to do for Objective-C, which complicates/slows down
C++ expression evaluation. Of course there's a valid use-case for this,
which is calling Objective-C APIs when stopped in C++ frames (which
Objective-C++ developers might want to do). In those case we should
really prompt the user to add the `expr --language objc++` flag.
To accomodate a likely frequent use-case where a user breaks in a system
C++ library (without debug-symbols) but their application is actually
an Objective-C app, we allow Objective-C support in C++ expressions
if the current frame doesn't have debug-info.

This fixes https://github.com/llvm/llvm-project/issues/75443 and
allows us to add more `LangOpts.ObjC` guards around the expression
evaluator in the future (e.g., we could avoid looking into the
Objective-C runtime during C++ expression evaluation, which we
currently do unconditionally).

Depends on https://github.com/llvm/llvm-project/pull/87657
---
 .../Clang/ClangExpressionParser.cpp |  5 -
 .../diagnostics/TestExprDiagnostics.py  |  2 +-
 .../expression/options/TestExprOptions.py   |  1 -
 .../objc-builtin-types/TestObjCBuiltinTypes.py  |  2 +-
 .../Makefile|  4 
 .../TestObjCFromCppFramesWithoutDebugInfo.py| 17 +
 .../main.cpp|  1 +
 7 files changed, 28 insertions(+), 4 deletions(-)
 create mode 100644 
lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/Makefile
 create mode 100644 
lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/TestObjCFromCppFramesWithoutDebugInfo.py
 create mode 100644 
lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/main.cpp

diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 822d286cd6c3c4..f48bdc730d9160 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -526,7 +526,10 @@ ClangExpressionParser::ClangExpressionParser(
 [[fallthrough]];
   case lldb::eLanguageTypeC_plus_plus_03:
 lang_opts.CPlusPlus = true;
-if (process_sp)
+if (process_sp
+// We're stopped in a frame without debug-info. The user probably
+// intends to make global queries (which should include Objective-C).
+&& !(frame_sp && frame_sp->HasDebugInformation()))
   lang_opts.ObjC =
   process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC) != nullptr;
 break;
diff --git 
a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py 
b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
index d64e9897a844f1..ddc1c3598480cf 100644
--- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
+++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
@@ -172,7 +172,7 @@ def test_source_locations_from_objc_modules(self):
 
 # Import foundation so that the Obj-C module is loaded (which contains 
source locations
 # that can be used by LLDB).
-self.runCmd("expr @import Foundation")
+self.runCmd("expr --language objective-c++ -- @import Foundation")
 value = frame.EvaluateExpression("NSLog(1);")
 self.assertFalse(value.GetError().Success())
 # LLDB should print the source line that defines NSLog. To not rely on 
any
diff --git a/lldb/test/API/commands/expression/options/TestExprOptions.py 
b/lldb/test/API/commands/expression/options/TestExprOptions.py
index 6652c71083a958..01899f3b97cf44 100644
--- a/lldb/test/API/commands/expression/options/TestExprOptions.py
+++ b/lldb/test/API/commands/expression/options/TestExprOptions.py
@@ -59,7 +59,6 @@ def test_expr_options(self):
 self.assertTrue(val.IsValid())
 self.assertFalse(val.GetError().Success())
 
-@skipIfDarwin
 def test_expr_options_lang(self):
 """These expression language options should work as expected."""
 self.build()
diff --git 
a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py 
b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
index 1eb7205f1bb465..280994fbde71ab 100644
--- a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
+++ b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
@@ 

[Lldb-commits] [lldb] [lldb][ClangUserExpression][NFCI] Pass the most specific ExecutionContextScope possible into ClangExpressionParser (PR #87657)

2024-04-11 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] fc52ee3 - [lldb][ClangUserExpression][NFCI] Pass the most specific ExecutionContextScope possible into ClangExpressionParser (#87657)

2024-04-11 Thread via lldb-commits

Author: Michael Buch
Date: 2024-04-11T20:29:18+02:00
New Revision: fc52ee336b394d84110184d625cda1d4f84d8098

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

LOG: [lldb][ClangUserExpression][NFCI] Pass the most specific 
ExecutionContextScope possible into ClangExpressionParser (#87657)

The `ClangExpressionParser` takes an `ExecutionContextScope` which it
uses to query the `Process`/`Target`/`StackFrame` to set various
compiler options in preparation for parsing an expression.

However, `TryParse` constructs the parser with a `Process` or `Target`,
never a `StackFrame`. So when the parser tries to retrieve the current
`StackFrame` from the `exe_scope`, it doesn't succeed. In future patches
we want to query the `StackFrame` from within the
`ClangExpressionParser` constructor.

This patch simplifies `TryParse`, by removing the redundant `exe_scope`
parameter, and instead uses the `exe_ctx` to derive the most fitting
`exe_scope` to pass into `ClangExpressionParser`.

Not entirely sure how to test this. This patch is a prerequisite to get
subsequent patches that set `LangOpts` based on the current `StackFrame`
to work.

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
index 30bc81c9ed8c19..5776b1e94e0721 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -553,9 +553,9 @@ bool ClangUserExpression::PrepareForParsing(
 }
 
 bool ClangUserExpression::TryParse(
-DiagnosticManager _manager, ExecutionContextScope *exe_scope,
-ExecutionContext _ctx, lldb_private::ExecutionPolicy execution_policy,
-bool keep_result_in_memory, bool generate_debug_info) {
+DiagnosticManager _manager, ExecutionContext _ctx,
+lldb_private::ExecutionPolicy execution_policy, bool keep_result_in_memory,
+bool generate_debug_info) {
   m_materializer_up = std::make_unique();
 
   ResetDeclMap(exe_ctx, m_result_delegate, keep_result_in_memory);
@@ -574,7 +574,8 @@ bool ClangUserExpression::TryParse(
   }
 
   m_parser = std::make_unique(
-  exe_scope, *this, generate_debug_info, m_include_directories, 
m_filename);
+  exe_ctx.GetBestExecutionContextScope(), *this, generate_debug_info,
+  m_include_directories, m_filename);
 
   unsigned num_errors = m_parser->Parse(diagnostic_manager);
 
@@ -669,15 +670,8 @@ bool ClangUserExpression::Parse(DiagnosticManager 
_manager,
   // Parse the expression
   //
 
-  Process *process = exe_ctx.GetProcessPtr();
-  ExecutionContextScope *exe_scope = process;
-
-  if (!exe_scope)
-exe_scope = exe_ctx.GetTargetPtr();
-
-  bool parse_success = TryParse(diagnostic_manager, exe_scope, exe_ctx,
-execution_policy, keep_result_in_memory,
-generate_debug_info);
+  bool parse_success = TryParse(diagnostic_manager, exe_ctx, execution_policy,
+keep_result_in_memory, generate_debug_info);
   // If the expression failed to parse, check if retrying parsing with a loaded
   // C++ module is possible.
   if (!parse_success && shouldRetryWithCppModule(*target, execution_policy)) {
@@ -695,9 +689,8 @@ bool ClangUserExpression::Parse(DiagnosticManager 
_manager,
   // so recreate those.
   CreateSourceCode(retry_manager, exe_ctx, m_imported_cpp_modules,
/*for_completion*/ false);
-  parse_success = TryParse(retry_manager, exe_scope, exe_ctx,
-   execution_policy, keep_result_in_memory,
-   generate_debug_info);
+  parse_success = TryParse(retry_manager, exe_ctx, execution_policy,
+   keep_result_in_memory, generate_debug_info);
   // Return the parse diagnostics if we were successful.
   if (parse_success)
 diagnostic_manager = std::move(retry_manager);
@@ -759,6 +752,7 @@ bool ClangUserExpression::Parse(DiagnosticManager 
_manager,
 }
   }
 
+  Process *process = exe_ctx.GetProcessPtr();
   if (process && m_jit_start_addr != LLDB_INVALID_ADDRESS)
 m_jit_process_wp = lldb::ProcessWP(process->shared_from_this());
   return true;
@@ -840,13 +834,8 @@ bool ClangUserExpression::Complete(ExecutionContext 
_ctx,
 DeclMap()->SetLookupsEnabled(true);
   }
 
-  Process *process = exe_ctx.GetProcessPtr();
-  ExecutionContextScope *exe_scope = process;
-
-  if (!exe_scope)
-exe_scope = exe_ctx.GetTargetPtr();
-
-  ClangExpressionParser 

[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread via lldb-commits

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

Please do move the stop reason test up before all the other tests, since it 
conditions them.  

Other than that, this LGTM.


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


[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread Usama Hameed via lldb-commits


@@ -26,6 +31,67 @@ def setUp(self):
 self.line_free = line_number("main.c", "// free line")
 self.line_breakpoint = line_number("main.c", "// break line")
 
+# Test line numbers: rdar://126237493
+def libsanitizer_tests(self):
+target = self.createTestTarget()
+
+self.runCmd(
+"env SanitizersAddress=1 MallocSanitizerZone=1 
MallocSecureAllocator=0"
+)
+
+self.runCmd("run")
+# In libsanitizers, memory history is not supported until a report has 
been generated
+# test the 'memory history' command
+self.expect(
+"memory history 'pointer'",
+substrs=[
+"Memory deallocated by Thread",
+"a.out`f2",
+"main.c",
+"Memory allocated by Thread",
+"a.out`f1",
+"main.c",
+],
+)
+
+# do the same using SB API
+process = self.dbg.GetSelectedTarget().process
+val = (
+
process.GetSelectedThread().GetSelectedFrame().EvaluateExpression("pointer")
+)
+addr = val.GetValueAsUnsigned()
+threads = process.GetHistoryThreads(addr)
+self.assertEqual(threads.GetSize(), 2)
+
+history_thread = threads.GetThreadAtIndex(0)
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
+history_thread = threads.GetThreadAtIndex(1)
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
+# let's free the container (SBThreadCollection) and see if the
+# SBThreads still live
+threads = None
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
+self.expect(

usama54321 wrote:

Thanks. Fixed

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


[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread Usama Hameed via lldb-commits

https://github.com/usama54321 updated 
https://github.com/llvm/llvm-project/pull/88349

>From c336a2ad53121bedd52a80169d11e5617c7058ed Mon Sep 17 00:00:00 2001
From: usama 
Date: Wed, 10 Apr 2024 21:07:11 -0700
Subject: [PATCH] [LLDB] Add asan tests for libsanitizers.

This patch tests LLDB integration with libsanitizers for ASan. This
integration works through the ASanLibsanitizers plugin in the
InstrumentationRuntime.

rdar://111856681
---
 lldb/test/API/functionalities/asan/Makefile   |  6 +-
 .../functionalities/asan/TestMemoryHistory.py | 69 ++-
 .../functionalities/asan/TestReportData.py| 16 -
 3 files changed, 86 insertions(+), 5 deletions(-)

diff --git a/lldb/test/API/functionalities/asan/Makefile 
b/lldb/test/API/functionalities/asan/Makefile
index 4913a18d8cc6f9..d66696fed7078f 100644
--- a/lldb/test/API/functionalities/asan/Makefile
+++ b/lldb/test/API/functionalities/asan/Makefile
@@ -1,4 +1,8 @@
 C_SOURCES := main.c
-CFLAGS_EXTRAS := -fsanitize=address -g -gcolumn-info
+asan: CFLAGS_EXTRAS := -fsanitize=address -g -gcolumn-info
+asan: all
+
+libsanitizers: CFLAGS_EXTRAS := -fsanitize=address -fsanitize-stable-abi -g 
-gcolumn-info
+libsanitizers: all
 
 include Makefile.rules
diff --git a/lldb/test/API/functionalities/asan/TestMemoryHistory.py 
b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
index 00162ae8822c74..83f91388194b61 100644
--- a/lldb/test/API/functionalities/asan/TestMemoryHistory.py
+++ b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
@@ -15,9 +15,14 @@ class AsanTestCase(TestBase):
 @expectedFailureNetBSD
 @skipUnlessAddressSanitizer
 def test(self):
-self.build()
+self.build(make_targets=["asan"])
 self.asan_tests()
 
+@skipIf(oslist=no_match(["macosx"]))
+def test_libsanitizers_asan(self):
+self.build(make_targets=["libsanitizers"])
+self.libsanitizer_tests()
+
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
@@ -26,6 +31,68 @@ def setUp(self):
 self.line_free = line_number("main.c", "// free line")
 self.line_breakpoint = line_number("main.c", "// break line")
 
+# Test line numbers: rdar://126237493
+def libsanitizer_tests(self):
+target = self.createTestTarget()
+
+self.runCmd(
+"env SanitizersAddress=1 MallocSanitizerZone=1 
MallocSecureAllocator=0"
+)
+
+self.runCmd("run")
+
+# In libsanitizers, memory history is not supported until a report has 
been generated
+self.expect(
+"thread list",
+"Process should be stopped due to ASan report",
+substrs=["stopped", "stop reason = Use of deallocated memory"],
+)
+
+# test the 'memory history' command
+self.expect(
+"memory history 'pointer'",
+substrs=[
+"Memory deallocated by Thread",
+"a.out`f2",
+"main.c",
+"Memory allocated by Thread",
+"a.out`f1",
+"main.c",
+],
+)
+
+# do the same using SB API
+process = self.dbg.GetSelectedTarget().process
+val = (
+
process.GetSelectedThread().GetSelectedFrame().EvaluateExpression("pointer")
+)
+addr = val.GetValueAsUnsigned()
+threads = process.GetHistoryThreads(addr)
+self.assertEqual(threads.GetSize(), 2)
+
+history_thread = threads.GetThreadAtIndex(0)
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
+history_thread = threads.GetThreadAtIndex(1)
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
+# let's free the container (SBThreadCollection) and see if the
+# SBThreads still live
+threads = None
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
 def asan_tests(self):
 target = self.createTestTarget()
 
diff --git a/lldb/test/API/functionalities/asan/TestReportData.py 
b/lldb/test/API/functionalities/asan/TestReportData.py
index 543c5fe66a208d..44bf77b501be35 100644
--- a/lldb/test/API/functionalities/asan/TestReportData.py
+++ b/lldb/test/API/functionalities/asan/TestReportData.py
@@ -16,9 +16,14 @@ class AsanTestReportDataCase(TestBase):
 @skipUnlessAddressSanitizer
 @skipIf(archs=["i386"], bugnumber="llvm.org/PR36710")
 def test(self):
-self.build()
+self.build(make_targets=["asan"])
 self.asan_tests()
 
+@skipIf(oslist=no_match(["macosx"]))
+def 

[Lldb-commits] [lldb] [lldb] Fix call to TemplateTemplateParmDecl::Create after #88139 (PR #88417)

2024-04-11 Thread Krystian Stasiowski via lldb-commits

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


[Lldb-commits] [lldb] a417b9b - [lldb] Fix call to TemplateTemplateParmDecl::Create after #88139 (#88417)

2024-04-11 Thread via lldb-commits

Author: Krystian Stasiowski
Date: 2024-04-11T13:46:37-04:00
New Revision: a417b9b759960cc4d7b49e95ddc2ef129b5abe12

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

LOG: [lldb] Fix call to TemplateTemplateParmDecl::Create after #88139 (#88417)

#88139 adds a parameter to `TemplateTemplateParmDecl::Create`, which is
called in LLDB. This adds the missing argument for that parameter.

Added: 


Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index ee634d12b3c41e..44bd02bd4b367d 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1682,10 +1682,11 @@ TypeSystemClang::CreateTemplateTemplateParmDecl(const 
char *template_name) {
   // type that includes a template template argument. Only the name matters for
   // this purpose, so we use dummy values for the other characteristics of the
   // type.
-  return TemplateTemplateParmDecl::Create(
-  ast, decl_ctx, SourceLocation(),
-  /*Depth*/ 0, /*Position*/ 0,
-  /*IsParameterPack*/ false, _info, template_param_list);
+  return TemplateTemplateParmDecl::Create(ast, decl_ctx, SourceLocation(),
+  /*Depth=*/0, /*Position=*/0,
+  /*IsParameterPack=*/false,
+  _info, /*Typename=*/false,
+  template_param_list);
 }
 
 ClassTemplateSpecializationDecl *



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


[Lldb-commits] [lldb] [lldb] Fix call to TemplateTemplateParmDecl::Create after #88139 (PR #88417)

2024-04-11 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Krystian Stasiowski (sdkrystian)


Changes

#88139 adds a parameter to `TemplateTemplateParmDecl::Create`, which is 
called in LLDB. This adds the missing argument for that parameter.

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


1 Files Affected:

- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+5-4) 


``diff
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index ee634d12b3c41e..44bd02bd4b367d 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1682,10 +1682,11 @@ TypeSystemClang::CreateTemplateTemplateParmDecl(const 
char *template_name) {
   // type that includes a template template argument. Only the name matters for
   // this purpose, so we use dummy values for the other characteristics of the
   // type.
-  return TemplateTemplateParmDecl::Create(
-  ast, decl_ctx, SourceLocation(),
-  /*Depth*/ 0, /*Position*/ 0,
-  /*IsParameterPack*/ false, _info, template_param_list);
+  return TemplateTemplateParmDecl::Create(ast, decl_ctx, SourceLocation(),
+  /*Depth=*/0, /*Position=*/0,
+  /*IsParameterPack=*/false,
+  _info, /*Typename=*/false,
+  template_param_list);
 }
 
 ClassTemplateSpecializationDecl *

``




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


[Lldb-commits] [lldb] [lldb] Fix call to TemplateTemplateParmDecl::Create after #88139 (PR #88417)

2024-04-11 Thread Krystian Stasiowski via lldb-commits

https://github.com/sdkrystian created 
https://github.com/llvm/llvm-project/pull/88417

#88139 adds a parameter to `TemplateTemplateParmDecl::Create`, which is called 
in LLDB. This adds the missing argument for that parameter.

>From c332569c0286fa5f7b1d34fc1048f5b73e035a65 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Thu, 11 Apr 2024 13:32:25 -0400
Subject: [PATCH] [lldb] Fix call to TemplateTemplateParmDecl::Create after
 #88139

---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index ee634d12b3c41e..44bd02bd4b367d 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1682,10 +1682,11 @@ TypeSystemClang::CreateTemplateTemplateParmDecl(const 
char *template_name) {
   // type that includes a template template argument. Only the name matters for
   // this purpose, so we use dummy values for the other characteristics of the
   // type.
-  return TemplateTemplateParmDecl::Create(
-  ast, decl_ctx, SourceLocation(),
-  /*Depth*/ 0, /*Position*/ 0,
-  /*IsParameterPack*/ false, _info, template_param_list);
+  return TemplateTemplateParmDecl::Create(ast, decl_ctx, SourceLocation(),
+  /*Depth=*/0, /*Position=*/0,
+  /*IsParameterPack=*/false,
+  _info, /*Typename=*/false,
+  template_param_list);
 }
 
 ClassTemplateSpecializationDecl *

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


[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread via lldb-commits


@@ -26,6 +31,67 @@ def setUp(self):
 self.line_free = line_number("main.c", "// free line")
 self.line_breakpoint = line_number("main.c", "// break line")
 
+# Test line numbers: rdar://126237493
+def libsanitizer_tests(self):
+target = self.createTestTarget()
+
+self.runCmd(
+"env SanitizersAddress=1 MallocSanitizerZone=1 
MallocSecureAllocator=0"
+)
+
+self.runCmd("run")
+# In libsanitizers, memory history is not supported until a report has 
been generated
+# test the 'memory history' command
+self.expect(
+"memory history 'pointer'",
+substrs=[
+"Memory deallocated by Thread",
+"a.out`f2",
+"main.c",
+"Memory allocated by Thread",
+"a.out`f1",
+"main.c",
+],
+)
+
+# do the same using SB API
+process = self.dbg.GetSelectedTarget().process
+val = (
+
process.GetSelectedThread().GetSelectedFrame().EvaluateExpression("pointer")
+)
+addr = val.GetValueAsUnsigned()
+threads = process.GetHistoryThreads(addr)
+self.assertEqual(threads.GetSize(), 2)
+
+history_thread = threads.GetThreadAtIndex(0)
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
+history_thread = threads.GetThreadAtIndex(1)
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
+# let's free the container (SBThreadCollection) and see if the
+# SBThreads still live
+threads = None
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
+self.expect(

jimingham wrote:

Ah, here's where you test the stop reason.  So you can just move this up to 
right after the "run" command.  None of the other tests make any sense if you 
didn't stop for an asan reason, so test that first.

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


[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread via lldb-commits


@@ -26,6 +31,67 @@ def setUp(self):
 self.line_free = line_number("main.c", "// free line")
 self.line_breakpoint = line_number("main.c", "// break line")
 
+# Test line numbers: rdar://126237493
+def libsanitizer_tests(self):
+target = self.createTestTarget()
+
+self.runCmd(
+"env SanitizersAddress=1 MallocSanitizerZone=1 
MallocSecureAllocator=0"
+)
+
+self.runCmd("run")
+# In libsanitizers, memory history is not supported until a report has 
been generated
+# test the 'memory history' command
+self.expect(

jimingham wrote:

The reason you can issue the "memory history" command directly after a "run" is 
I'm assuming because in the normal course of execution this process is going to 
stop with an asan exception, right?

If so, please test that the stop reason is what you expect, both to make sure 
the asan stop message is getting properly delivered and so we get a better 
error in case something unrelated went wrong.

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


[Lldb-commits] [lldb] Reland "[lldb][sbdebugger] Move SBDebugger Broadcast bit enum into ll… (PR #88331)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] 8c3cb6b - Reland "[lldb][sbdebugger] Move SBDebugger Broadcast bit enum into ll… (#88331)

2024-04-11 Thread via lldb-commits

Author: Chelsea Cassanova
Date: 2024-04-11T09:56:22-07:00
New Revision: 8c3cb6b55b688b767e5d65bcc2891b17322e8d05

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

LOG: Reland "[lldb][sbdebugger] Move SBDebugger Broadcast bit enum into ll… 
(#88331)

…db-enumerations.h" (#88324)"

This reverts commit 9f6d08f2566a26144ea1753f80aebb1f2ecfdc63. This broke
the build because of a usage of one of the original SBDebugger broadcast
bits that wasn't updated in the original commit.

Added: 


Modified: 
lldb/include/lldb/API/SBDebugger.h
lldb/include/lldb/lldb-enumerations.h

lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py

lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
lldb/test/API/macosx/rosetta/TestRosetta.py
lldb/tools/lldb-dap/lldb-dap.cpp

Removed: 




diff  --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 62b2f91f5076d5..cf5409a12a056a 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -42,13 +42,6 @@ class LLDB_API SBInputReader {
 
 class LLDB_API SBDebugger {
 public:
-  FLAGS_ANONYMOUS_ENUM(){
-  eBroadcastBitProgress = (1 << 0),
-  eBroadcastBitWarning = (1 << 1),
-  eBroadcastBitError = (1 << 2),
-  eBroadcastBitProgressCategory = (1 << 3),
-  };
-
   SBDebugger();
 
   SBDebugger(const lldb::SBDebugger );

diff  --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 646f7bfda98475..f3b07ea6d20395 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -1339,6 +1339,14 @@ enum AddressMaskRange {
   eAddressMaskRangeAll = eAddressMaskRangeAny,
 };
 
+/// Used by the debugger to indicate which events are being broadcasted.
+enum DebuggerBroadcastBit {
+  eBroadcastBitProgress = (1 << 0),
+  eBroadcastBitWarning = (1 << 1),
+  eBroadcastBitError = (1 << 2),
+  eBroadcastBitProgressCategory = (1 << 3),
+};
+
 } // namespace lldb
 
 #endif // LLDB_LLDB_ENUMERATIONS_H

diff  --git 
a/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py 
b/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
index 36a3be695628f5..6353e3e8cbedbd 100644
--- 
a/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
+++ 
b/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
@@ -15,7 +15,7 @@ def setUp(self):
 self.broadcaster = self.dbg.GetBroadcaster()
 self.listener = lldbutil.start_listening_from(
 self.broadcaster,
-lldb.SBDebugger.eBroadcastBitWarning | 
lldb.SBDebugger.eBroadcastBitError,
+lldb.eBroadcastBitWarning | lldb.eBroadcastBitError,
 )
 
 def test_dwarf_symbol_loading_diagnostic_report(self):

diff  --git 
a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py 
b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
index 9af53845ca1b77..98988d7624da3c 100644
--- a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
+++ b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
@@ -13,7 +13,7 @@ def setUp(self):
 TestBase.setUp(self)
 self.broadcaster = self.dbg.GetBroadcaster()
 self.listener = lldbutil.start_listening_from(
-self.broadcaster, lldb.SBDebugger.eBroadcastBitProgress
+self.broadcaster, lldb.eBroadcastBitProgress
 )
 
 def test_dwarf_symbol_loading_progress_report(self):

diff  --git 
a/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
 
b/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
index 228f676aedf6ac..33c7c269c081e4 100644
--- 
a/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
+++ 
b/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
@@ -34,7 +34,7 @@ def test_clang_module_build_progress_report(self):
 # other unrelated progress events.
 broadcaster = self.dbg.GetBroadcaster()
 listener = lldbutil.start_listening_from(
-broadcaster, lldb.SBDebugger.eBroadcastBitProgress
+broadcaster, lldb.eBroadcastBitProgress
 )
 
 # Trigger module builds.

diff  --git a/lldb/test/API/macosx/rosetta/TestRosetta.py 
b/lldb/test/API/macosx/rosetta/TestRosetta.py
index ce40de475ef16c..669db95a1624c6 100644
--- a/lldb/test/API/macosx/rosetta/TestRosetta.py
+++ 

[Lldb-commits] [lldb] [lldb][ClangUserExpression][NFCI] Pass the most specific ExecutionContextScope possible into ClangExpressionParser (PR #87657)

2024-04-11 Thread via lldb-commits

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

This looks fine to me.  The only lingering issue is the more general discussion 
of use of ExecutionContext vrs. ExecutionContextScope, but I agree with Michael 
that that's much broader than this patch, and shouldn't hold it up.

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


[Lldb-commits] [lldb] Add asan tests for libsanitizers. (PR #88349)

2024-04-11 Thread Usama Hameed via lldb-commits

https://github.com/usama54321 updated 
https://github.com/llvm/llvm-project/pull/88349

>From 3d31b403aad13f8eb8a9377390f05a310bfa0999 Mon Sep 17 00:00:00 2001
From: usama 
Date: Wed, 10 Apr 2024 21:07:11 -0700
Subject: [PATCH] [LLDB] Add asan tests for libsanitizers.

This patch tests LLDB integration with libsanitizers for ASan. This
integration works through the ASanLibsanitizers plugin in the
InstrumentationRuntime.

rdar://111856681
---
 lldb/test/API/functionalities/asan/Makefile   |  6 +-
 .../functionalities/asan/TestMemoryHistory.py | 68 ++-
 .../functionalities/asan/TestReportData.py| 16 -
 3 files changed, 85 insertions(+), 5 deletions(-)

diff --git a/lldb/test/API/functionalities/asan/Makefile 
b/lldb/test/API/functionalities/asan/Makefile
index 4913a18d8cc6f9..d66696fed7078f 100644
--- a/lldb/test/API/functionalities/asan/Makefile
+++ b/lldb/test/API/functionalities/asan/Makefile
@@ -1,4 +1,8 @@
 C_SOURCES := main.c
-CFLAGS_EXTRAS := -fsanitize=address -g -gcolumn-info
+asan: CFLAGS_EXTRAS := -fsanitize=address -g -gcolumn-info
+asan: all
+
+libsanitizers: CFLAGS_EXTRAS := -fsanitize=address -fsanitize-stable-abi -g 
-gcolumn-info
+libsanitizers: all
 
 include Makefile.rules
diff --git a/lldb/test/API/functionalities/asan/TestMemoryHistory.py 
b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
index 00162ae8822c74..ee0ff7175505d1 100644
--- a/lldb/test/API/functionalities/asan/TestMemoryHistory.py
+++ b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
@@ -15,9 +15,14 @@ class AsanTestCase(TestBase):
 @expectedFailureNetBSD
 @skipUnlessAddressSanitizer
 def test(self):
-self.build()
+self.build(make_targets=["asan"])
 self.asan_tests()
 
+@skipIf(oslist=no_match(["macosx"]))
+def test_libsanitizers_asan(self):
+self.build(make_targets=["libsanitizers"])
+self.libsanitizer_tests()
+
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
@@ -26,6 +31,67 @@ def setUp(self):
 self.line_free = line_number("main.c", "// free line")
 self.line_breakpoint = line_number("main.c", "// break line")
 
+# Test line numbers: rdar://126237493
+def libsanitizer_tests(self):
+target = self.createTestTarget()
+
+self.runCmd(
+"env SanitizersAddress=1 MallocSanitizerZone=1 
MallocSecureAllocator=0"
+)
+
+self.runCmd("run")
+# In libsanitizers, memory history is not supported until a report has 
been generated
+# test the 'memory history' command
+self.expect(
+"memory history 'pointer'",
+substrs=[
+"Memory deallocated by Thread",
+"a.out`f2",
+"main.c",
+"Memory allocated by Thread",
+"a.out`f1",
+"main.c",
+],
+)
+
+# do the same using SB API
+process = self.dbg.GetSelectedTarget().process
+val = (
+
process.GetSelectedThread().GetSelectedFrame().EvaluateExpression("pointer")
+)
+addr = val.GetValueAsUnsigned()
+threads = process.GetHistoryThreads(addr)
+self.assertEqual(threads.GetSize(), 2)
+
+history_thread = threads.GetThreadAtIndex(0)
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
+history_thread = threads.GetThreadAtIndex(1)
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
+# let's free the container (SBThreadCollection) and see if the
+# SBThreads still live
+threads = None
+self.assertTrue(history_thread.num_frames >= 2)
+self.assertEqual(
+
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
+"main.c",
+)
+
+self.expect(
+"thread list",
+"Process should be stopped due to ASan report",
+substrs=["stopped", "stop reason = Use of deallocated memory"],
+)
+
 def asan_tests(self):
 target = self.createTestTarget()
 
diff --git a/lldb/test/API/functionalities/asan/TestReportData.py 
b/lldb/test/API/functionalities/asan/TestReportData.py
index 543c5fe66a208d..44bf77b501be35 100644
--- a/lldb/test/API/functionalities/asan/TestReportData.py
+++ b/lldb/test/API/functionalities/asan/TestReportData.py
@@ -16,9 +16,14 @@ class AsanTestReportDataCase(TestBase):
 @skipUnlessAddressSanitizer
 @skipIf(archs=["i386"], bugnumber="llvm.org/PR36710")
 def test(self):
-self.build()
+self.build(make_targets=["asan"])
 self.asan_tests()
 
+@skipIf(oslist=no_match(["macosx"]))
+def 

[Lldb-commits] [lldb] [lldb] Teach LocateExecutableSymbolFile to look into LOCALBASE on FreeBSD (PR #81355)

2024-04-11 Thread Gleb Popov via lldb-commits

arrowd wrote:

Another bump.

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


[Lldb-commits] [lldb] Reland "[lldb][sbdebugger] Move SBDebugger Broadcast bit enum into ll… (PR #88331)

2024-04-11 Thread Med Ismail Bennani via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] [lldb] [llgs] Fix assertion in Handle_qfThreadInfo (PR #88301)

2024-04-11 Thread Ayush Sahay via lldb-commits

https://github.com/ayushsahay1837 updated 
https://github.com/llvm/llvm-project/pull/88301

>From f4794dc0711005be1a98b2208855ba81d0fb3854 Mon Sep 17 00:00:00 2001
From: Ayush Sahay 
Date: Wed, 10 Apr 2024 22:50:04 +0530
Subject: [PATCH] [lldb] [llgs] Fix assertion in Handle_qfThreadInfo
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Currently, GDBRemoteCommunicationServerLLGS::Handle_qfThreadInfo asserts
if the number of processes under debug isn’t 1 and the multiprocess
feature isn’t supported. This is so that we don't string IDs of threads
belonging to different processes together without including the IDs of
the processes themselves in the response when there are multiple
processes under debug. However, it’s conceivable that we have no process
under debug and the multiprocess feature isn’t supported. So, have
GDBRemoteCommunicationServerLLGS::Handle_qfThreadInfo assert if the
number of processes under debug is greater than 1 and the multiprocess
feature isn’t supported.
---
 .../Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 3d37bb226a65fd..ae1a77e5be8321 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -2087,7 +2087,7 @@ void GDBRemoteCommunicationServerLLGS::AddProcessThreads(
 GDBRemoteCommunication::PacketResult
 GDBRemoteCommunicationServerLLGS::Handle_qfThreadInfo(
 StringExtractorGDBRemote ) {
-  assert(m_debugged_processes.size() == 1 ||
+  assert(m_debugged_processes.size() <= 1 ||
  bool(m_extensions_supported &
   NativeProcessProtocol::Extension::multiprocess));
 

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