[Lldb-commits] [mlir] [clang-tools-extra] [lld] [lldb] [libcxx] [llvm] [compiler-rt] [clang] [hwasan] Add `__hwasan_get_tag_from_pointer` (PR #75267)

2023-12-12 Thread Vitaly Buka via lldb-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/75267

>From 7fa7ea4786d3c8244aff575d3147d421c761e02a Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 17:01:54 -0800
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 .../TestCases/Posix/fork_threaded.cpp | 86 +++
 .../sanitizer_common/sanitizer_specific.h | 16 
 2 files changed, 102 insertions(+)
 create mode 100644 
compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp

diff --git 
a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp 
b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
new file mode 100644
index 0..72a2f78a5a3e7
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
@@ -0,0 +1,86 @@
+// RUN: %clangxx -O0 %s -o %t && %env_tool_opts=die_after_fork=0 %run %t
+
+// UNSUPPORTED: asan, lsan, hwasan
+
+// Forking in multithread environment is unsupported. However we already have
+// some workarounds, and will add more, so this is the test.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sanitizer_common/sanitizer_specific.h"
+
+static const size_t kBufferSize = 1 << 20;
+
+static void *background(void *arg) { return nullptr; }
+
+pthread_barrier_t bar;
+
+void CanDeadLock() {
+  // Don't bother with leaks, we try to trigger allocator or lsan deadlock.
+  __lsan::ScopedDisabler disable;
+  char *volatile p = new char[10];
+  __lsan_do_recoverable_leak_check();
+  delete[] p;
+}
+
+// Prevent stack buffer cleanup by instrumentation.
+#define NOSAN __attribute__((no_sanitize("address", "hwaddress", "memory")))
+
+NOSAN static void *inparent(void *arg) {
+  fprintf(stderr, "inparent %d\n", gettid());
+
+  char t[kBufferSize];
+  make_mem_bad(t, sizeof(t));
+
+  pthread_barrier_wait(&bar);
+
+  for (;;)
+CanDeadLock();
+
+  return 0;
+}
+
+NOSAN static void *inchild(void *arg) {
+  char t[kBufferSize];
+  check_mem_is_good(t, sizeof(t));
+  CanDeadLock();
+  return 0;
+}
+
+int main(void) {
+  pid_t pid;
+
+  pthread_barrier_init(&bar, nullptr, 2);
+  pthread_t thread_id;
+  while (pthread_create(&thread_id, 0, &inparent, 0) != 0) {
+  }
+  pthread_barrier_wait(&bar);
+
+  pid = fork();
+  switch (pid) {
+  case -1:
+perror("fork");
+return -1;
+  case 0:
+while (pthread_create(&thread_id, 0, &inchild, 0) != 0) {
+}
+break;
+  default: {
+fprintf(stderr, "fork %d\n", pid);
+int status;
+while (waitpid(-1, &status, __WALL) != pid) {
+}
+assert(WIFEXITED(status) && WEXITSTATUS(status) == 0);
+break;
+  }
+  }
+
+  return 0;
+}
diff --git a/compiler-rt/test/sanitizer_common/sanitizer_specific.h 
b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
index 1a802020cfd66..963d91cb305f6 100644
--- a/compiler-rt/test/sanitizer_common/sanitizer_specific.h
+++ b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
@@ -1,6 +1,12 @@
 #ifndef __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 #define __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 
+#include 
+
+__attribute__((weak)) int __lsan_do_recoverable_leak_check() { return 0; }
+__attribute__((weak)) void __lsan_disable(void) {}
+__attribute__((weak)) void __lsan_enable(void) {}
+
 #ifndef __has_feature
 #  define __has_feature(x) 0
 #endif
@@ -10,6 +16,8 @@
 static void check_mem_is_good(void *p, size_t s) {
   __msan_check_mem_is_initialized(p, s);
 }
+static void make_mem_good(void *p, size_t s) { __msan_unpoison(p, s); }
+static void make_mem_bad(void *p, size_t s) { __msan_poison(p, s); }
 #elif __has_feature(address_sanitizer)
 #  include 
 #  include 
@@ -17,8 +25,16 @@ static void check_mem_is_good(void *p, size_t s) {
   if (__asan_region_is_poisoned(p, s))
 abort();
 }
+static void make_mem_good(void *p, size_t s) {
+  __asan_unpoison_memory_region(p, s);
+}
+static void make_mem_bad(void *p, size_t s) {
+  __asan_poison_memory_region(p, s);
+}
 #else
 static void check_mem_is_good(void *p, size_t s) {}
+static void make_mem_good(void *p, size_t s) {}
+static void make_mem_bad(void *p, size_t s) {}
 #endif
 
 #endif // __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
\ No newline at end of file

>From 6ed9198c136ead9c6726e5bfd83978e891522f5b Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 17:09:19 -0800
Subject: [PATCH 2/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20introduced=20through=20rebase?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 compiler-rt/test/sanitizer_common/sanitizer_specific.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/test

[Lldb-commits] [mlir] [compiler-rt] [lldb] [clang-tools-extra] [clang] [llvm] [hwasan] Add `__hwasan_get_tag_from_pointer` (PR #75267)

2023-12-12 Thread Vitaly Buka via lldb-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/75267

>From 7fa7ea4786d3c8244aff575d3147d421c761e02a Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 17:01:54 -0800
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 .../TestCases/Posix/fork_threaded.cpp | 86 +++
 .../sanitizer_common/sanitizer_specific.h | 16 
 2 files changed, 102 insertions(+)
 create mode 100644 
compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp

diff --git 
a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp 
b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
new file mode 100644
index 00..72a2f78a5a3e77
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
@@ -0,0 +1,86 @@
+// RUN: %clangxx -O0 %s -o %t && %env_tool_opts=die_after_fork=0 %run %t
+
+// UNSUPPORTED: asan, lsan, hwasan
+
+// Forking in multithread environment is unsupported. However we already have
+// some workarounds, and will add more, so this is the test.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sanitizer_common/sanitizer_specific.h"
+
+static const size_t kBufferSize = 1 << 20;
+
+static void *background(void *arg) { return nullptr; }
+
+pthread_barrier_t bar;
+
+void CanDeadLock() {
+  // Don't bother with leaks, we try to trigger allocator or lsan deadlock.
+  __lsan::ScopedDisabler disable;
+  char *volatile p = new char[10];
+  __lsan_do_recoverable_leak_check();
+  delete[] p;
+}
+
+// Prevent stack buffer cleanup by instrumentation.
+#define NOSAN __attribute__((no_sanitize("address", "hwaddress", "memory")))
+
+NOSAN static void *inparent(void *arg) {
+  fprintf(stderr, "inparent %d\n", gettid());
+
+  char t[kBufferSize];
+  make_mem_bad(t, sizeof(t));
+
+  pthread_barrier_wait(&bar);
+
+  for (;;)
+CanDeadLock();
+
+  return 0;
+}
+
+NOSAN static void *inchild(void *arg) {
+  char t[kBufferSize];
+  check_mem_is_good(t, sizeof(t));
+  CanDeadLock();
+  return 0;
+}
+
+int main(void) {
+  pid_t pid;
+
+  pthread_barrier_init(&bar, nullptr, 2);
+  pthread_t thread_id;
+  while (pthread_create(&thread_id, 0, &inparent, 0) != 0) {
+  }
+  pthread_barrier_wait(&bar);
+
+  pid = fork();
+  switch (pid) {
+  case -1:
+perror("fork");
+return -1;
+  case 0:
+while (pthread_create(&thread_id, 0, &inchild, 0) != 0) {
+}
+break;
+  default: {
+fprintf(stderr, "fork %d\n", pid);
+int status;
+while (waitpid(-1, &status, __WALL) != pid) {
+}
+assert(WIFEXITED(status) && WEXITSTATUS(status) == 0);
+break;
+  }
+  }
+
+  return 0;
+}
diff --git a/compiler-rt/test/sanitizer_common/sanitizer_specific.h 
b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
index 1a802020cfd668..963d91cb305f60 100644
--- a/compiler-rt/test/sanitizer_common/sanitizer_specific.h
+++ b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
@@ -1,6 +1,12 @@
 #ifndef __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 #define __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 
+#include 
+
+__attribute__((weak)) int __lsan_do_recoverable_leak_check() { return 0; }
+__attribute__((weak)) void __lsan_disable(void) {}
+__attribute__((weak)) void __lsan_enable(void) {}
+
 #ifndef __has_feature
 #  define __has_feature(x) 0
 #endif
@@ -10,6 +16,8 @@
 static void check_mem_is_good(void *p, size_t s) {
   __msan_check_mem_is_initialized(p, s);
 }
+static void make_mem_good(void *p, size_t s) { __msan_unpoison(p, s); }
+static void make_mem_bad(void *p, size_t s) { __msan_poison(p, s); }
 #elif __has_feature(address_sanitizer)
 #  include 
 #  include 
@@ -17,8 +25,16 @@ static void check_mem_is_good(void *p, size_t s) {
   if (__asan_region_is_poisoned(p, s))
 abort();
 }
+static void make_mem_good(void *p, size_t s) {
+  __asan_unpoison_memory_region(p, s);
+}
+static void make_mem_bad(void *p, size_t s) {
+  __asan_poison_memory_region(p, s);
+}
 #else
 static void check_mem_is_good(void *p, size_t s) {}
+static void make_mem_good(void *p, size_t s) {}
+static void make_mem_bad(void *p, size_t s) {}
 #endif
 
 #endif // __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
\ No newline at end of file

>From 6ed9198c136ead9c6726e5bfd83978e891522f5b Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 17:09:19 -0800
Subject: [PATCH 2/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20introduced=20through=20rebase?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 compiler-rt/test/sanitizer_common/sanitizer_specific.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/

[Lldb-commits] [lldb] [mlir] [compiler-rt] [clang] [llvm] [hwasan] Add `__hwasan_get_tag_from_pointer` (PR #75267)

2023-12-12 Thread Vitaly Buka via lldb-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/75267

>From 7fa7ea4786d3c8244aff575d3147d421c761e02a Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 17:01:54 -0800
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 .../TestCases/Posix/fork_threaded.cpp | 86 +++
 .../sanitizer_common/sanitizer_specific.h | 16 
 2 files changed, 102 insertions(+)
 create mode 100644 
compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp

diff --git 
a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp 
b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
new file mode 100644
index 0..72a2f78a5a3e7
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
@@ -0,0 +1,86 @@
+// RUN: %clangxx -O0 %s -o %t && %env_tool_opts=die_after_fork=0 %run %t
+
+// UNSUPPORTED: asan, lsan, hwasan
+
+// Forking in multithread environment is unsupported. However we already have
+// some workarounds, and will add more, so this is the test.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sanitizer_common/sanitizer_specific.h"
+
+static const size_t kBufferSize = 1 << 20;
+
+static void *background(void *arg) { return nullptr; }
+
+pthread_barrier_t bar;
+
+void CanDeadLock() {
+  // Don't bother with leaks, we try to trigger allocator or lsan deadlock.
+  __lsan::ScopedDisabler disable;
+  char *volatile p = new char[10];
+  __lsan_do_recoverable_leak_check();
+  delete[] p;
+}
+
+// Prevent stack buffer cleanup by instrumentation.
+#define NOSAN __attribute__((no_sanitize("address", "hwaddress", "memory")))
+
+NOSAN static void *inparent(void *arg) {
+  fprintf(stderr, "inparent %d\n", gettid());
+
+  char t[kBufferSize];
+  make_mem_bad(t, sizeof(t));
+
+  pthread_barrier_wait(&bar);
+
+  for (;;)
+CanDeadLock();
+
+  return 0;
+}
+
+NOSAN static void *inchild(void *arg) {
+  char t[kBufferSize];
+  check_mem_is_good(t, sizeof(t));
+  CanDeadLock();
+  return 0;
+}
+
+int main(void) {
+  pid_t pid;
+
+  pthread_barrier_init(&bar, nullptr, 2);
+  pthread_t thread_id;
+  while (pthread_create(&thread_id, 0, &inparent, 0) != 0) {
+  }
+  pthread_barrier_wait(&bar);
+
+  pid = fork();
+  switch (pid) {
+  case -1:
+perror("fork");
+return -1;
+  case 0:
+while (pthread_create(&thread_id, 0, &inchild, 0) != 0) {
+}
+break;
+  default: {
+fprintf(stderr, "fork %d\n", pid);
+int status;
+while (waitpid(-1, &status, __WALL) != pid) {
+}
+assert(WIFEXITED(status) && WEXITSTATUS(status) == 0);
+break;
+  }
+  }
+
+  return 0;
+}
diff --git a/compiler-rt/test/sanitizer_common/sanitizer_specific.h 
b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
index 1a802020cfd66..963d91cb305f6 100644
--- a/compiler-rt/test/sanitizer_common/sanitizer_specific.h
+++ b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
@@ -1,6 +1,12 @@
 #ifndef __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 #define __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 
+#include 
+
+__attribute__((weak)) int __lsan_do_recoverable_leak_check() { return 0; }
+__attribute__((weak)) void __lsan_disable(void) {}
+__attribute__((weak)) void __lsan_enable(void) {}
+
 #ifndef __has_feature
 #  define __has_feature(x) 0
 #endif
@@ -10,6 +16,8 @@
 static void check_mem_is_good(void *p, size_t s) {
   __msan_check_mem_is_initialized(p, s);
 }
+static void make_mem_good(void *p, size_t s) { __msan_unpoison(p, s); }
+static void make_mem_bad(void *p, size_t s) { __msan_poison(p, s); }
 #elif __has_feature(address_sanitizer)
 #  include 
 #  include 
@@ -17,8 +25,16 @@ static void check_mem_is_good(void *p, size_t s) {
   if (__asan_region_is_poisoned(p, s))
 abort();
 }
+static void make_mem_good(void *p, size_t s) {
+  __asan_unpoison_memory_region(p, s);
+}
+static void make_mem_bad(void *p, size_t s) {
+  __asan_poison_memory_region(p, s);
+}
 #else
 static void check_mem_is_good(void *p, size_t s) {}
+static void make_mem_good(void *p, size_t s) {}
+static void make_mem_bad(void *p, size_t s) {}
 #endif
 
 #endif // __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
\ No newline at end of file

>From 6ed9198c136ead9c6726e5bfd83978e891522f5b Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 17:09:19 -0800
Subject: [PATCH 2/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20introduced=20through=20rebase?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 compiler-rt/test/sanitizer_common/sanitizer_specific.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/test

[Lldb-commits] [lldb] [mlir] [compiler-rt] [clang] [llvm] [hwasan] Add `__hwasan_get_tag_from_pointer` (PR #75267)

2023-12-12 Thread Vitaly Buka via lldb-commits

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


[Lldb-commits] [lldb] [mlir] [compiler-rt] [clang] [llvm] [test][sanitizer] Allow fork_threaded test on Msan, Tsan, Ubsan (PR #75260)

2023-12-12 Thread Vitaly Buka via lldb-commits

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


[Lldb-commits] [lldb] [mlir] [compiler-rt] [clang] [llvm] [test][sanitizer] Allow fork_threaded test on Msan, Tsan, Ubsan (PR #75260)

2023-12-12 Thread Vitaly Buka via lldb-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/75260

>From 2dad66c39ce65a06df39cd761362624b355951e3 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 16:20:07 -0800
Subject: [PATCH 1/4] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 .../TestCases/Posix/fork_threaded.cpp | 86 +++
 .../sanitizer_common/sanitizer_specific.h | 16 
 2 files changed, 102 insertions(+)
 create mode 100644 
compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp

diff --git 
a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp 
b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
new file mode 100644
index 00..2264c558166388
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
@@ -0,0 +1,86 @@
+// RUN: %clangxx -O0 %s -o %t && %env_tool_opts=die_after_fork=0 %run %t
+
+// UNSUPPORTED: *
+
+// Forking in multithread environment is unsupported. However we already have
+// some workarounds, and will add more, so this is the test.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sanitizer_common/sanitizer_specific.h"
+
+static const size_t kBufferSize = 1 << 20;
+
+static void *background(void *arg) { return nullptr; }
+
+pthread_barrier_t bar;
+
+void CanDeadLock() {
+  // Don't bother with leaks, we try to trigger allocator or lsan deadlock.
+  __lsan::ScopedDisabler disable;
+  char *volatile p = new char[10];
+  __lsan_do_recoverable_leak_check();
+  delete[] p;
+}
+
+// Prevent stack buffer cleanup by instrumentation.
+#define NOSAN __attribute__((no_sanitize("address", "hwaddress", "memory")))
+
+NOSAN static void *inparent(void *arg) {
+  fprintf(stderr, "inparent %d\n", gettid());
+
+  char t[kBufferSize];
+  make_mem_bad(t, sizeof(t));
+
+  pthread_barrier_wait(&bar);
+
+  for (;;)
+CanDeadLock();
+
+  return 0;
+}
+
+NOSAN static void *inchild(void *arg) {
+  char t[kBufferSize];
+  check_mem_is_good(t, sizeof(t));
+  CanDeadLock();
+  return 0;
+}
+
+int main(void) {
+  pid_t pid;
+
+  pthread_barrier_init(&bar, nullptr, 2);
+  pthread_t thread_id;
+  while (pthread_create(&thread_id, 0, &inparent, 0) != 0) {
+  }
+  pthread_barrier_wait(&bar);
+
+  pid = fork();
+  switch (pid) {
+  case -1:
+perror("fork");
+return -1;
+  case 0:
+while (pthread_create(&thread_id, 0, &inchild, 0) != 0) {
+}
+break;
+  default: {
+fprintf(stderr, "fork %d\n", pid);
+int status;
+while (waitpid(-1, &status, __WALL) != pid) {
+}
+assert(WIFEXITED(status) && WEXITSTATUS(status) == 0);
+break;
+  }
+  }
+
+  return 0;
+}
diff --git a/compiler-rt/test/sanitizer_common/sanitizer_specific.h 
b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
index 1a802020cfd668..963d91cb305f60 100644
--- a/compiler-rt/test/sanitizer_common/sanitizer_specific.h
+++ b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
@@ -1,6 +1,12 @@
 #ifndef __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 #define __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 
+#include 
+
+__attribute__((weak)) int __lsan_do_recoverable_leak_check() { return 0; }
+__attribute__((weak)) void __lsan_disable(void) {}
+__attribute__((weak)) void __lsan_enable(void) {}
+
 #ifndef __has_feature
 #  define __has_feature(x) 0
 #endif
@@ -10,6 +16,8 @@
 static void check_mem_is_good(void *p, size_t s) {
   __msan_check_mem_is_initialized(p, s);
 }
+static void make_mem_good(void *p, size_t s) { __msan_unpoison(p, s); }
+static void make_mem_bad(void *p, size_t s) { __msan_poison(p, s); }
 #elif __has_feature(address_sanitizer)
 #  include 
 #  include 
@@ -17,8 +25,16 @@ static void check_mem_is_good(void *p, size_t s) {
   if (__asan_region_is_poisoned(p, s))
 abort();
 }
+static void make_mem_good(void *p, size_t s) {
+  __asan_unpoison_memory_region(p, s);
+}
+static void make_mem_bad(void *p, size_t s) {
+  __asan_poison_memory_region(p, s);
+}
 #else
 static void check_mem_is_good(void *p, size_t s) {}
+static void make_mem_good(void *p, size_t s) {}
+static void make_mem_bad(void *p, size_t s) {}
 #endif
 
 #endif // __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
\ No newline at end of file

>From 5c4317f5610316cfe5550f1366e1323116529799 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 17:09:13 -0800
Subject: [PATCH 2/4] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20introduced=20through=20rebase?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 compiler-rt/test/sanitizer_common/sanitizer_specific.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/test/sanitizer_co

[Lldb-commits] [mlir] [clang] [lldb] [compiler-rt] [llvm] [test][sanitizer] Allow fork_threaded test on Msan, Tsan, Ubsan (PR #75260)

2023-12-12 Thread Vitaly Buka via lldb-commits

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


[Lldb-commits] [mlir] [clang] [lldb] [compiler-rt] [llvm] [test][sanitizer] Allow fork_threaded test on Msan, Tsan (PR #75260)

2023-12-12 Thread Vitaly Buka via lldb-commits

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


[Lldb-commits] [mlir] [clang] [lldb] [compiler-rt] [llvm] [sanitizer] Pre-commit disabled test for fork (PR #75257)

2023-12-12 Thread Vitaly Buka via lldb-commits

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


[Lldb-commits] [mlir] [clang] [lldb] [compiler-rt] [llvm] [sanitizer] Pre-commit disabled test for fork (PR #75257)

2023-12-12 Thread Vitaly Buka via lldb-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/75257

>From db7b2abf12add7fcbac65c7f7fad5f60be58de2f Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 16:08:56 -0800
Subject: [PATCH 1/5] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 .../TestCases/Posix/fork_threaded.cpp | 86 +++
 .../sanitizer_common/sanitizer_specific.h | 16 
 2 files changed, 102 insertions(+)
 create mode 100644 
compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp

diff --git 
a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp 
b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
new file mode 100644
index 0..d5c60bbb7c943
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
@@ -0,0 +1,86 @@
+// RUN: %clangxx -O0 %s -o %t && %env_tool_opts=die_after_fork=0 %run %t
+
+// UNSUPPORTED: *
+
+// Forking in multithread environment is unsupported. However we already have
+// some workarounds, and will add more, so this is the test.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sanitizer_common/sanitizer_specific.h"
+
+static const size_t kBufferSize = 1 << 20;
+
+static void *background(void *arg) { return nullptr; }
+
+pthread_barrier_t bar;
+
+void CanDeadLock() {
+  // Don't bother with leaks, we try to trigger allocator or lsan deadlock.
+  __lsan::ScopedDisabler disable;
+  char *volatile p = new char[10];
+  __lsan_do_recoverable_leak_check();
+  delete[] p;
+}
+
+// Prevent stack buffer cleanup by instrumentation.
+#define NOSAN __attribute__((no_sanitize("address", "hwaddress", "memory")))
+
+NOSAN static void *inparent(void *arg) {
+  fprintf(stderr, "inparent %d\n", gettid());
+
+  char t[kBufferSize];
+  make_mem_bad(t, sizeof(t));
+
+  pthread_barrier_wait(&bar);
+
+  for (;;)
+CanDeadLock();
+
+  return 0;
+}
+
+NOSAN static void *inchild(void *arg) {
+  char t[kBufferSize];
+  check_mem_is_good(t, sizeof(t));
+  CanDeadLock();
+  return 0;
+}
+
+int main(void) {
+  pid_t pid;
+
+  pthread_barrier_init(&bar, nullptr, 2);
+  pthread_t thread_id;
+  while (pthread_create(&thread_id, 0, &inparent, 0) != 0) {
+  }
+  pthread_barrier_wait(&bar);
+
+  pid = fork();
+  switch (pid) {
+  case -1:
+perror("fork");
+return -1;
+  case 0:
+while (pthread_create(&thread_id, 0, &inchild, 0) != 0) {
+}
+break;
+  default: {
+fprintf(stderr, "fork %d\n", pid);
+int status;
+while (waitpid(-1, &status, __WALL) != pid) {
+}
+assert(WIFEXITED(status) && WEXITSTATUS(status) == 0);
+break;
+  }
+  }
+
+  return 0;
+}
\ No newline at end of file
diff --git a/compiler-rt/test/sanitizer_common/sanitizer_specific.h 
b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
index 1a802020cfd66..963d91cb305f6 100644
--- a/compiler-rt/test/sanitizer_common/sanitizer_specific.h
+++ b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
@@ -1,6 +1,12 @@
 #ifndef __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 #define __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 
+#include 
+
+__attribute__((weak)) int __lsan_do_recoverable_leak_check() { return 0; }
+__attribute__((weak)) void __lsan_disable(void) {}
+__attribute__((weak)) void __lsan_enable(void) {}
+
 #ifndef __has_feature
 #  define __has_feature(x) 0
 #endif
@@ -10,6 +16,8 @@
 static void check_mem_is_good(void *p, size_t s) {
   __msan_check_mem_is_initialized(p, s);
 }
+static void make_mem_good(void *p, size_t s) { __msan_unpoison(p, s); }
+static void make_mem_bad(void *p, size_t s) { __msan_poison(p, s); }
 #elif __has_feature(address_sanitizer)
 #  include 
 #  include 
@@ -17,8 +25,16 @@ static void check_mem_is_good(void *p, size_t s) {
   if (__asan_region_is_poisoned(p, s))
 abort();
 }
+static void make_mem_good(void *p, size_t s) {
+  __asan_unpoison_memory_region(p, s);
+}
+static void make_mem_bad(void *p, size_t s) {
+  __asan_poison_memory_region(p, s);
+}
 #else
 static void check_mem_is_good(void *p, size_t s) {}
+static void make_mem_good(void *p, size_t s) {}
+static void make_mem_bad(void *p, size_t s) {}
 #endif
 
 #endif // __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
\ No newline at end of file

>From 3ceddfbc5d928a8297e41923cfb3ac63d0af2a03 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 16:11:58 -0800
Subject: [PATCH 2/5] newline

Created using spr 1.3.4
---
 .../test/sanitizer_common/TestCases/Posix/fork_threaded.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp 
b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
index d5c60bbb7c943..2264c55816638 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_

[Lldb-commits] [lldb] [llvm] [mlir] [compiler-rt] [sanitizer] Pre-commit disabled test for fork (PR #75257)

2023-12-12 Thread Vitaly Buka via lldb-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/75257

>From db7b2abf12add7fcbac65c7f7fad5f60be58de2f Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 16:08:56 -0800
Subject: [PATCH 1/5] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 .../TestCases/Posix/fork_threaded.cpp | 86 +++
 .../sanitizer_common/sanitizer_specific.h | 16 
 2 files changed, 102 insertions(+)
 create mode 100644 
compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp

diff --git 
a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp 
b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
new file mode 100644
index 00..d5c60bbb7c9430
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
@@ -0,0 +1,86 @@
+// RUN: %clangxx -O0 %s -o %t && %env_tool_opts=die_after_fork=0 %run %t
+
+// UNSUPPORTED: *
+
+// Forking in multithread environment is unsupported. However we already have
+// some workarounds, and will add more, so this is the test.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sanitizer_common/sanitizer_specific.h"
+
+static const size_t kBufferSize = 1 << 20;
+
+static void *background(void *arg) { return nullptr; }
+
+pthread_barrier_t bar;
+
+void CanDeadLock() {
+  // Don't bother with leaks, we try to trigger allocator or lsan deadlock.
+  __lsan::ScopedDisabler disable;
+  char *volatile p = new char[10];
+  __lsan_do_recoverable_leak_check();
+  delete[] p;
+}
+
+// Prevent stack buffer cleanup by instrumentation.
+#define NOSAN __attribute__((no_sanitize("address", "hwaddress", "memory")))
+
+NOSAN static void *inparent(void *arg) {
+  fprintf(stderr, "inparent %d\n", gettid());
+
+  char t[kBufferSize];
+  make_mem_bad(t, sizeof(t));
+
+  pthread_barrier_wait(&bar);
+
+  for (;;)
+CanDeadLock();
+
+  return 0;
+}
+
+NOSAN static void *inchild(void *arg) {
+  char t[kBufferSize];
+  check_mem_is_good(t, sizeof(t));
+  CanDeadLock();
+  return 0;
+}
+
+int main(void) {
+  pid_t pid;
+
+  pthread_barrier_init(&bar, nullptr, 2);
+  pthread_t thread_id;
+  while (pthread_create(&thread_id, 0, &inparent, 0) != 0) {
+  }
+  pthread_barrier_wait(&bar);
+
+  pid = fork();
+  switch (pid) {
+  case -1:
+perror("fork");
+return -1;
+  case 0:
+while (pthread_create(&thread_id, 0, &inchild, 0) != 0) {
+}
+break;
+  default: {
+fprintf(stderr, "fork %d\n", pid);
+int status;
+while (waitpid(-1, &status, __WALL) != pid) {
+}
+assert(WIFEXITED(status) && WEXITSTATUS(status) == 0);
+break;
+  }
+  }
+
+  return 0;
+}
\ No newline at end of file
diff --git a/compiler-rt/test/sanitizer_common/sanitizer_specific.h 
b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
index 1a802020cfd668..963d91cb305f60 100644
--- a/compiler-rt/test/sanitizer_common/sanitizer_specific.h
+++ b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
@@ -1,6 +1,12 @@
 #ifndef __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 #define __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 
+#include 
+
+__attribute__((weak)) int __lsan_do_recoverable_leak_check() { return 0; }
+__attribute__((weak)) void __lsan_disable(void) {}
+__attribute__((weak)) void __lsan_enable(void) {}
+
 #ifndef __has_feature
 #  define __has_feature(x) 0
 #endif
@@ -10,6 +16,8 @@
 static void check_mem_is_good(void *p, size_t s) {
   __msan_check_mem_is_initialized(p, s);
 }
+static void make_mem_good(void *p, size_t s) { __msan_unpoison(p, s); }
+static void make_mem_bad(void *p, size_t s) { __msan_poison(p, s); }
 #elif __has_feature(address_sanitizer)
 #  include 
 #  include 
@@ -17,8 +25,16 @@ static void check_mem_is_good(void *p, size_t s) {
   if (__asan_region_is_poisoned(p, s))
 abort();
 }
+static void make_mem_good(void *p, size_t s) {
+  __asan_unpoison_memory_region(p, s);
+}
+static void make_mem_bad(void *p, size_t s) {
+  __asan_poison_memory_region(p, s);
+}
 #else
 static void check_mem_is_good(void *p, size_t s) {}
+static void make_mem_good(void *p, size_t s) {}
+static void make_mem_bad(void *p, size_t s) {}
 #endif
 
 #endif // __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
\ No newline at end of file

>From 3ceddfbc5d928a8297e41923cfb3ac63d0af2a03 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 16:11:58 -0800
Subject: [PATCH 2/5] newline

Created using spr 1.3.4
---
 .../test/sanitizer_common/TestCases/Posix/fork_threaded.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp 
b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
index d5c60bbb7c9430..2264c558166388 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix

[Lldb-commits] [lldb] [lldb] Fix buildbots after PR 74786 (PR #75272)

2023-12-12 Thread Greg Clayton via lldb-commits

clayborg wrote:

Also fixed the `SymbolFilePDBTests` unit test code. I can't compile windows 
code, if anyone on windows can help try to build the `SymbolFilePDBTests` cmake 
target and then run the resulting binary to see if it passes that would really 
help. The perf win for this patch is quite high, so any help in getting this 
tested would really help out. The build must have the `LLVM_ENABLE_DIA_SDK` 
cmake variable set.

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


[Lldb-commits] [lldb] [lldb] Fix buildbots after PR 74786 (PR #75272)

2023-12-12 Thread Greg Clayton via lldb-commits

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

>From 5646faa2b21fe01f8a379beda1ca77190c0df1f1 Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Tue, 12 Dec 2023 18:16:04 -0800
Subject: [PATCH 1/2] [lldb] Fix buildbots after PR 74786

Fix unexpected pass after https://github.com/llvm/llvm-project/pull/74786.
---
 .../cpp/union-static-data-members/TestCppUnionStaticMembers.py  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/test/API/lang/cpp/union-static-data-members/TestCppUnionStaticMembers.py 
b/lldb/test/API/lang/cpp/union-static-data-members/TestCppUnionStaticMembers.py
index 1988e997499b22..dff23da8662a04 100644
--- 
a/lldb/test/API/lang/cpp/union-static-data-members/TestCppUnionStaticMembers.py
+++ 
b/lldb/test/API/lang/cpp/union-static-data-members/TestCppUnionStaticMembers.py
@@ -42,7 +42,7 @@ def test_expr_union_static_members(self):
 name="val", value="42"
 )])
 
-@expectedFailureAll
+@expectedFailureWindows
 def test_union_in_anon_namespace(self):
 """Tests that frame variable and expr work
for union static data members in anonymous

>From 7ee5696f02eeafd053b7422b108d7ba81e1db689 Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Tue, 12 Dec 2023 18:57:23 -0800
Subject: [PATCH 2/2] Add fixes for windows buildbots.

---
 .../SymbolFile/PDB/SymbolFilePDBTests.cpp | 91 ++-
 1 file changed, 46 insertions(+), 45 deletions(-)

diff --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp 
b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
index acd381ccad13d2..afa600a89cbc0f 100644
--- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -362,10 +362,9 @@ TEST_F(SymbolFilePDBTests, TestSimpleClassTypes) {
   SymbolFilePDB *symfile =
   static_cast(module->GetSymbolFile());
   llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
-  llvm::DenseSet searched_files;
-  TypeMap results;
-  symfile->FindTypes(ConstString("Class"), CompilerDeclContext(), 0,
- searched_files, results);
+  TypeResults query_results;
+  symfile->FindTypes(TypeQuery("Class"), query_results);
+  TypeMap &results = query_results.GetTypeMap();
   EXPECT_EQ(1u, results.GetSize());
   lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
   EXPECT_EQ(ConstString("Class"), udt_type->GetName());
@@ -383,7 +382,6 @@ TEST_F(SymbolFilePDBTests, TestNestedClassTypes) {
   SymbolFilePDB *symfile =
   static_cast(module->GetSymbolFile());
   llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
-  llvm::DenseSet searched_files;
   TypeMap results;
 
   auto clang_ast_ctx_or_err =
@@ -394,8 +392,10 @@ TEST_F(SymbolFilePDBTests, TestNestedClassTypes) {
   llvm::dyn_cast_or_null(clang_ast_ctx_or_err->get());
   EXPECT_NE(nullptr, clang_ast_ctx);
 
-  symfile->FindTypes(ConstString("Class"), CompilerDeclContext(), 0,
- searched_files, results);
+  TypeResults query_results;
+  symfile->FindTypes(TypeQuery("Class"), query_results);
+  TypeMap &results = query_results.GetTypeMap();
+
   EXPECT_EQ(1u, results.GetSize());
 
   auto Class = results.GetTypeAtIndex(0);
@@ -413,10 +413,11 @@ TEST_F(SymbolFilePDBTests, TestNestedClassTypes) {
   // compiler type for both, but `FindTypes` may return more than one type
   // (with the same compiler type) because the symbols have different IDs.
 
-  TypeMap more_results;
   auto ClassCompilerDeclCtx = CompilerDeclContext(clang_ast_ctx, ClassDeclCtx);
-  symfile->FindTypes(ConstString("NestedClass"), ClassCompilerDeclCtx, 0,
- searched_files, more_results);
+  TypeResults query_results;
+  symfile->FindTypes(TypeQuery(ClassCompilerDeclCtx, "NestedClass"),
+ query_results);
+  TypeMap &more_results = query_results.GetTypeMap();
   EXPECT_LE(1u, more_results.GetSize());
 
   lldb::TypeSP udt_type = more_results.GetTypeAtIndex(0);
@@ -437,9 +438,6 @@ TEST_F(SymbolFilePDBTests, TestClassInNamespace) {
   SymbolFilePDB *symfile =
   static_cast(module->GetSymbolFile());
   llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
-  llvm::DenseSet searched_files;
-  TypeMap results;
-
   auto clang_ast_ctx_or_err =
   symfile->GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
   ASSERT_THAT_EXPECTED(clang_ast_ctx_or_err, llvm::Succeeded());
@@ -456,12 +454,14 @@ TEST_F(SymbolFilePDBTests, TestClassInNamespace) {
   symfile->ParseDeclsForContext(CompilerDeclContext(
   clang_ast_ctx, static_cast(tu)));
 
-  auto ns_namespace =
+  auto ns_namespace_decl_ctx =
   symfile->FindNamespace(ConstString("NS"), CompilerDeclContext(), true);
-  EXPECT_TRUE(ns_namespace.IsValid());
+  EXPECT_TRUE(ns_namespace_decl_ctx.IsValid());
 
-  symfile->FindTypes(ConstString("NSClass"), ns_namespace, 0, searched_files,
- results);
+  TypeResults query_results;
+  symfile->Find

[Lldb-commits] [lldb] [lldb-dap] Emit more structured info along with variables (PR #75244)

2023-12-12 Thread Greg Clayton via lldb-commits


@@ -1103,28 +1116,52 @@ std::string 
CreateUniqueVariableNameForDisplay(lldb::SBValue v,
 //   can use this optional information to present the
 //   children in a paged UI and fetch them in chunks."
 // }
+//
+//
+// // Unofficial extensions to the protocol:
+//

clayborg wrote:

Do we want to add these inside of an object with a unique name that VS code 
will never use? Like:
```
{ "$__lldb_extensions": { 
"inMemoryValue": true, 
"summary": "...", 
"autoSummary": "..." 
  }
}
```

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


[Lldb-commits] [lldb] Make only one function that needs to be implemented when searching for types (PR #74786)

2023-12-12 Thread Greg Clayton via lldb-commits

clayborg wrote:

Buildbots are failing due to an unexpeted pass!

https://github.com/llvm/llvm-project/pull/75272

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


[Lldb-commits] [lldb] [lldb] Fix buildbots after PR 74786 (PR #75272)

2023-12-12 Thread Greg Clayton via lldb-commits

clayborg wrote:

This test now passes after the new type lookup stuff went in due to improved 
lookups!

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


[Lldb-commits] [lldb] [lldb] Fix buildbots after PR 74786 (PR #75272)

2023-12-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Greg Clayton (clayborg)


Changes

Fix unexpected pass after https://github.com/llvm/llvm-project/pull/74786.

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


1 Files Affected:

- (modified) 
lldb/test/API/lang/cpp/union-static-data-members/TestCppUnionStaticMembers.py 
(+1-1) 


``diff
diff --git 
a/lldb/test/API/lang/cpp/union-static-data-members/TestCppUnionStaticMembers.py 
b/lldb/test/API/lang/cpp/union-static-data-members/TestCppUnionStaticMembers.py
index 1988e997499b2..dff23da8662a0 100644
--- 
a/lldb/test/API/lang/cpp/union-static-data-members/TestCppUnionStaticMembers.py
+++ 
b/lldb/test/API/lang/cpp/union-static-data-members/TestCppUnionStaticMembers.py
@@ -42,7 +42,7 @@ def test_expr_union_static_members(self):
 name="val", value="42"
 )])
 
-@expectedFailureAll
+@expectedFailureWindows
 def test_union_in_anon_namespace(self):
 """Tests that frame variable and expr work
for union static data members in anonymous

``




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


[Lldb-commits] [lldb] [lldb] Fix buildbots after PR 74786 (PR #75272)

2023-12-12 Thread Greg Clayton via lldb-commits

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

Fix unexpected pass after https://github.com/llvm/llvm-project/pull/74786.

>From 5646faa2b21fe01f8a379beda1ca77190c0df1f1 Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Tue, 12 Dec 2023 18:16:04 -0800
Subject: [PATCH] [lldb] Fix buildbots after PR 74786

Fix unexpected pass after https://github.com/llvm/llvm-project/pull/74786.
---
 .../cpp/union-static-data-members/TestCppUnionStaticMembers.py  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/test/API/lang/cpp/union-static-data-members/TestCppUnionStaticMembers.py 
b/lldb/test/API/lang/cpp/union-static-data-members/TestCppUnionStaticMembers.py
index 1988e997499b2..dff23da8662a0 100644
--- 
a/lldb/test/API/lang/cpp/union-static-data-members/TestCppUnionStaticMembers.py
+++ 
b/lldb/test/API/lang/cpp/union-static-data-members/TestCppUnionStaticMembers.py
@@ -42,7 +42,7 @@ def test_expr_union_static_members(self):
 name="val", value="42"
 )])
 
-@expectedFailureAll
+@expectedFailureWindows
 def test_union_in_anon_namespace(self):
 """Tests that frame variable and expr work
for union static data members in anonymous

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


[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)

2023-12-12 Thread Saleem Abdulrasool via lldb-commits

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


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


[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)

2023-12-12 Thread Saleem Abdulrasool via lldb-commits


@@ -175,3 +179,30 @@ Status TargetThreadWindows::DoResume() {
 
   return Status();
 }
+
+const char *TargetThreadWindows::GetName() {
+  Log *log = GetLog(LLDBLog::Thread);
+  HMODULE hModule = ::LoadLibraryW(L"Kernel32.dll");
+  if (hModule) {
+auto GetThreadDescription =
+reinterpret_cast(
+::GetProcAddress(hModule, "GetThreadDescription"));

compnerd wrote:

There is the set name below though.

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


[Lldb-commits] [compiler-rt] [mlir] [llvm] [lldb] [sanitizer] Pre-commit disabled test for fork (PR #75257)

2023-12-12 Thread Vitaly Buka via lldb-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/75257

>From db7b2abf12add7fcbac65c7f7fad5f60be58de2f Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 16:08:56 -0800
Subject: [PATCH 1/4] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 .../TestCases/Posix/fork_threaded.cpp | 86 +++
 .../sanitizer_common/sanitizer_specific.h | 16 
 2 files changed, 102 insertions(+)
 create mode 100644 
compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp

diff --git 
a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp 
b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
new file mode 100644
index 00..d5c60bbb7c9430
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
@@ -0,0 +1,86 @@
+// RUN: %clangxx -O0 %s -o %t && %env_tool_opts=die_after_fork=0 %run %t
+
+// UNSUPPORTED: *
+
+// Forking in multithread environment is unsupported. However we already have
+// some workarounds, and will add more, so this is the test.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sanitizer_common/sanitizer_specific.h"
+
+static const size_t kBufferSize = 1 << 20;
+
+static void *background(void *arg) { return nullptr; }
+
+pthread_barrier_t bar;
+
+void CanDeadLock() {
+  // Don't bother with leaks, we try to trigger allocator or lsan deadlock.
+  __lsan::ScopedDisabler disable;
+  char *volatile p = new char[10];
+  __lsan_do_recoverable_leak_check();
+  delete[] p;
+}
+
+// Prevent stack buffer cleanup by instrumentation.
+#define NOSAN __attribute__((no_sanitize("address", "hwaddress", "memory")))
+
+NOSAN static void *inparent(void *arg) {
+  fprintf(stderr, "inparent %d\n", gettid());
+
+  char t[kBufferSize];
+  make_mem_bad(t, sizeof(t));
+
+  pthread_barrier_wait(&bar);
+
+  for (;;)
+CanDeadLock();
+
+  return 0;
+}
+
+NOSAN static void *inchild(void *arg) {
+  char t[kBufferSize];
+  check_mem_is_good(t, sizeof(t));
+  CanDeadLock();
+  return 0;
+}
+
+int main(void) {
+  pid_t pid;
+
+  pthread_barrier_init(&bar, nullptr, 2);
+  pthread_t thread_id;
+  while (pthread_create(&thread_id, 0, &inparent, 0) != 0) {
+  }
+  pthread_barrier_wait(&bar);
+
+  pid = fork();
+  switch (pid) {
+  case -1:
+perror("fork");
+return -1;
+  case 0:
+while (pthread_create(&thread_id, 0, &inchild, 0) != 0) {
+}
+break;
+  default: {
+fprintf(stderr, "fork %d\n", pid);
+int status;
+while (waitpid(-1, &status, __WALL) != pid) {
+}
+assert(WIFEXITED(status) && WEXITSTATUS(status) == 0);
+break;
+  }
+  }
+
+  return 0;
+}
\ No newline at end of file
diff --git a/compiler-rt/test/sanitizer_common/sanitizer_specific.h 
b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
index 1a802020cfd668..963d91cb305f60 100644
--- a/compiler-rt/test/sanitizer_common/sanitizer_specific.h
+++ b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
@@ -1,6 +1,12 @@
 #ifndef __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 #define __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 
+#include 
+
+__attribute__((weak)) int __lsan_do_recoverable_leak_check() { return 0; }
+__attribute__((weak)) void __lsan_disable(void) {}
+__attribute__((weak)) void __lsan_enable(void) {}
+
 #ifndef __has_feature
 #  define __has_feature(x) 0
 #endif
@@ -10,6 +16,8 @@
 static void check_mem_is_good(void *p, size_t s) {
   __msan_check_mem_is_initialized(p, s);
 }
+static void make_mem_good(void *p, size_t s) { __msan_unpoison(p, s); }
+static void make_mem_bad(void *p, size_t s) { __msan_poison(p, s); }
 #elif __has_feature(address_sanitizer)
 #  include 
 #  include 
@@ -17,8 +25,16 @@ static void check_mem_is_good(void *p, size_t s) {
   if (__asan_region_is_poisoned(p, s))
 abort();
 }
+static void make_mem_good(void *p, size_t s) {
+  __asan_unpoison_memory_region(p, s);
+}
+static void make_mem_bad(void *p, size_t s) {
+  __asan_poison_memory_region(p, s);
+}
 #else
 static void check_mem_is_good(void *p, size_t s) {}
+static void make_mem_good(void *p, size_t s) {}
+static void make_mem_bad(void *p, size_t s) {}
 #endif
 
 #endif // __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
\ No newline at end of file

>From 3ceddfbc5d928a8297e41923cfb3ac63d0af2a03 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 16:11:58 -0800
Subject: [PATCH 2/4] newline

Created using spr 1.3.4
---
 .../test/sanitizer_common/TestCases/Posix/fork_threaded.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp 
b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
index d5c60bbb7c9430..2264c558166388 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix

[Lldb-commits] [compiler-rt] [mlir] [llvm] [lldb] [sanitizer] Pre-commit disabled test for fork (PR #75257)

2023-12-12 Thread Florian Mayer via lldb-commits


@@ -18,10 +18,10 @@
 
 static const size_t kBufferSize = 1 << 20;
 
-static void *background(void *arg) { return nullptr; }
-
 pthread_barrier_t bar;
 
+// Without appropriate workarounds this code can cause the forked process to
+// start with locked internal mutexes.

fmayer wrote:

optional nit: call it `ShouldNotDeadlock`?

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


[Lldb-commits] [lldb] [llvm] [compiler-rt] [mlir] [sanitizer] Pre-commit disabled test for fork (PR #75257)

2023-12-12 Thread Florian Mayer via lldb-commits




fmayer wrote:

would appreciate a short comment that explains what this test does in an 
abstract sense, like

"sets up memory like so and so and verifies that this and this doesn't happen"

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


[Lldb-commits] [mlir] [llvm] [compiler-rt] [lldb] [sanitizer] Pre-commit disabled test for fork (PR #75257)

2023-12-12 Thread Florian Mayer via lldb-commits

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


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


[Lldb-commits] [lldb] [compiler-rt] [mlir] [llvm] [sanitizer] Pre-commit disabled test for fork (PR #75257)

2023-12-12 Thread Florian Mayer via lldb-commits

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


[Lldb-commits] [compiler-rt] [mlir] [llvm] [lldb] [sanitizer] Pre-commit disabled test for fork (PR #75257)

2023-12-12 Thread Vitaly Buka via lldb-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/75257

>From db7b2abf12add7fcbac65c7f7fad5f60be58de2f Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 16:08:56 -0800
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 .../TestCases/Posix/fork_threaded.cpp | 86 +++
 .../sanitizer_common/sanitizer_specific.h | 16 
 2 files changed, 102 insertions(+)
 create mode 100644 
compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp

diff --git 
a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp 
b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
new file mode 100644
index 00..d5c60bbb7c9430
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
@@ -0,0 +1,86 @@
+// RUN: %clangxx -O0 %s -o %t && %env_tool_opts=die_after_fork=0 %run %t
+
+// UNSUPPORTED: *
+
+// Forking in multithread environment is unsupported. However we already have
+// some workarounds, and will add more, so this is the test.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sanitizer_common/sanitizer_specific.h"
+
+static const size_t kBufferSize = 1 << 20;
+
+static void *background(void *arg) { return nullptr; }
+
+pthread_barrier_t bar;
+
+void CanDeadLock() {
+  // Don't bother with leaks, we try to trigger allocator or lsan deadlock.
+  __lsan::ScopedDisabler disable;
+  char *volatile p = new char[10];
+  __lsan_do_recoverable_leak_check();
+  delete[] p;
+}
+
+// Prevent stack buffer cleanup by instrumentation.
+#define NOSAN __attribute__((no_sanitize("address", "hwaddress", "memory")))
+
+NOSAN static void *inparent(void *arg) {
+  fprintf(stderr, "inparent %d\n", gettid());
+
+  char t[kBufferSize];
+  make_mem_bad(t, sizeof(t));
+
+  pthread_barrier_wait(&bar);
+
+  for (;;)
+CanDeadLock();
+
+  return 0;
+}
+
+NOSAN static void *inchild(void *arg) {
+  char t[kBufferSize];
+  check_mem_is_good(t, sizeof(t));
+  CanDeadLock();
+  return 0;
+}
+
+int main(void) {
+  pid_t pid;
+
+  pthread_barrier_init(&bar, nullptr, 2);
+  pthread_t thread_id;
+  while (pthread_create(&thread_id, 0, &inparent, 0) != 0) {
+  }
+  pthread_barrier_wait(&bar);
+
+  pid = fork();
+  switch (pid) {
+  case -1:
+perror("fork");
+return -1;
+  case 0:
+while (pthread_create(&thread_id, 0, &inchild, 0) != 0) {
+}
+break;
+  default: {
+fprintf(stderr, "fork %d\n", pid);
+int status;
+while (waitpid(-1, &status, __WALL) != pid) {
+}
+assert(WIFEXITED(status) && WEXITSTATUS(status) == 0);
+break;
+  }
+  }
+
+  return 0;
+}
\ No newline at end of file
diff --git a/compiler-rt/test/sanitizer_common/sanitizer_specific.h 
b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
index 1a802020cfd668..963d91cb305f60 100644
--- a/compiler-rt/test/sanitizer_common/sanitizer_specific.h
+++ b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
@@ -1,6 +1,12 @@
 #ifndef __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 #define __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 
+#include 
+
+__attribute__((weak)) int __lsan_do_recoverable_leak_check() { return 0; }
+__attribute__((weak)) void __lsan_disable(void) {}
+__attribute__((weak)) void __lsan_enable(void) {}
+
 #ifndef __has_feature
 #  define __has_feature(x) 0
 #endif
@@ -10,6 +16,8 @@
 static void check_mem_is_good(void *p, size_t s) {
   __msan_check_mem_is_initialized(p, s);
 }
+static void make_mem_good(void *p, size_t s) { __msan_unpoison(p, s); }
+static void make_mem_bad(void *p, size_t s) { __msan_poison(p, s); }
 #elif __has_feature(address_sanitizer)
 #  include 
 #  include 
@@ -17,8 +25,16 @@ static void check_mem_is_good(void *p, size_t s) {
   if (__asan_region_is_poisoned(p, s))
 abort();
 }
+static void make_mem_good(void *p, size_t s) {
+  __asan_unpoison_memory_region(p, s);
+}
+static void make_mem_bad(void *p, size_t s) {
+  __asan_poison_memory_region(p, s);
+}
 #else
 static void check_mem_is_good(void *p, size_t s) {}
+static void make_mem_good(void *p, size_t s) {}
+static void make_mem_bad(void *p, size_t s) {}
 #endif
 
 #endif // __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
\ No newline at end of file

>From 3ceddfbc5d928a8297e41923cfb3ac63d0af2a03 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 16:11:58 -0800
Subject: [PATCH 2/3] newline

Created using spr 1.3.4
---
 .../test/sanitizer_common/TestCases/Posix/fork_threaded.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp 
b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
index d5c60bbb7c9430..2264c558166388 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix

[Lldb-commits] [lldb] [compiler-rt] [mlir] [llvm] [sanitizer] Pre-commit disabled test for fork (PR #75257)

2023-12-12 Thread Vitaly Buka via lldb-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/75257

>From db7b2abf12add7fcbac65c7f7fad5f60be58de2f Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 16:08:56 -0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 .../TestCases/Posix/fork_threaded.cpp | 86 +++
 .../sanitizer_common/sanitizer_specific.h | 16 
 2 files changed, 102 insertions(+)
 create mode 100644 
compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp

diff --git 
a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp 
b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
new file mode 100644
index 00..d5c60bbb7c9430
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
@@ -0,0 +1,86 @@
+// RUN: %clangxx -O0 %s -o %t && %env_tool_opts=die_after_fork=0 %run %t
+
+// UNSUPPORTED: *
+
+// Forking in multithread environment is unsupported. However we already have
+// some workarounds, and will add more, so this is the test.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sanitizer_common/sanitizer_specific.h"
+
+static const size_t kBufferSize = 1 << 20;
+
+static void *background(void *arg) { return nullptr; }
+
+pthread_barrier_t bar;
+
+void CanDeadLock() {
+  // Don't bother with leaks, we try to trigger allocator or lsan deadlock.
+  __lsan::ScopedDisabler disable;
+  char *volatile p = new char[10];
+  __lsan_do_recoverable_leak_check();
+  delete[] p;
+}
+
+// Prevent stack buffer cleanup by instrumentation.
+#define NOSAN __attribute__((no_sanitize("address", "hwaddress", "memory")))
+
+NOSAN static void *inparent(void *arg) {
+  fprintf(stderr, "inparent %d\n", gettid());
+
+  char t[kBufferSize];
+  make_mem_bad(t, sizeof(t));
+
+  pthread_barrier_wait(&bar);
+
+  for (;;)
+CanDeadLock();
+
+  return 0;
+}
+
+NOSAN static void *inchild(void *arg) {
+  char t[kBufferSize];
+  check_mem_is_good(t, sizeof(t));
+  CanDeadLock();
+  return 0;
+}
+
+int main(void) {
+  pid_t pid;
+
+  pthread_barrier_init(&bar, nullptr, 2);
+  pthread_t thread_id;
+  while (pthread_create(&thread_id, 0, &inparent, 0) != 0) {
+  }
+  pthread_barrier_wait(&bar);
+
+  pid = fork();
+  switch (pid) {
+  case -1:
+perror("fork");
+return -1;
+  case 0:
+while (pthread_create(&thread_id, 0, &inchild, 0) != 0) {
+}
+break;
+  default: {
+fprintf(stderr, "fork %d\n", pid);
+int status;
+while (waitpid(-1, &status, __WALL) != pid) {
+}
+assert(WIFEXITED(status) && WEXITSTATUS(status) == 0);
+break;
+  }
+  }
+
+  return 0;
+}
\ No newline at end of file
diff --git a/compiler-rt/test/sanitizer_common/sanitizer_specific.h 
b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
index 1a802020cfd668..963d91cb305f60 100644
--- a/compiler-rt/test/sanitizer_common/sanitizer_specific.h
+++ b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
@@ -1,6 +1,12 @@
 #ifndef __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 #define __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
 
+#include 
+
+__attribute__((weak)) int __lsan_do_recoverable_leak_check() { return 0; }
+__attribute__((weak)) void __lsan_disable(void) {}
+__attribute__((weak)) void __lsan_enable(void) {}
+
 #ifndef __has_feature
 #  define __has_feature(x) 0
 #endif
@@ -10,6 +16,8 @@
 static void check_mem_is_good(void *p, size_t s) {
   __msan_check_mem_is_initialized(p, s);
 }
+static void make_mem_good(void *p, size_t s) { __msan_unpoison(p, s); }
+static void make_mem_bad(void *p, size_t s) { __msan_poison(p, s); }
 #elif __has_feature(address_sanitizer)
 #  include 
 #  include 
@@ -17,8 +25,16 @@ static void check_mem_is_good(void *p, size_t s) {
   if (__asan_region_is_poisoned(p, s))
 abort();
 }
+static void make_mem_good(void *p, size_t s) {
+  __asan_unpoison_memory_region(p, s);
+}
+static void make_mem_bad(void *p, size_t s) {
+  __asan_poison_memory_region(p, s);
+}
 #else
 static void check_mem_is_good(void *p, size_t s) {}
+static void make_mem_good(void *p, size_t s) {}
+static void make_mem_bad(void *p, size_t s) {}
 #endif
 
 #endif // __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__
\ No newline at end of file

>From 3ceddfbc5d928a8297e41923cfb3ac63d0af2a03 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 12 Dec 2023 16:11:58 -0800
Subject: [PATCH 2/2] newline

Created using spr 1.3.4
---
 .../test/sanitizer_common/TestCases/Posix/fork_threaded.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp 
b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
index d5c60bbb7c9430..2264c558166388 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix

[Lldb-commits] [mlir] [clang-tools-extra] [lldb] [llvm] [libc] [libcxx] [clang] [libcxxabi] [libunwind] [compiler-rt] [flang] [lld] [libc++] Implement ranges::contains (PR #65148)

2023-12-12 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/65148

>From 02e9afd761228f401df4d9f8dfaaca44ffae0c6e Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 31 Aug 2023 20:08:32 +
Subject: [PATCH 01/21] [libc++] Implement ranges::contains

Differential Revision: https://reviews.llvm.org/D159232
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__algorithm/ranges_contains.h  |  60 ++
 libcxx/include/algorithm  |   9 +
 ...obust_against_copying_projections.pass.cpp |   4 +
 .../alg.contains/ranges.contains.pass.cpp | 190 ++
 .../niebloid.compile.pass.cpp |   1 +
 6 files changed, 265 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 77a7269121ec14..024aa8959fb720 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,7 @@ set(files
   __algorithm/ranges_any_of.h
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
+  __algorithm/ranges_contains.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains.h 
b/libcxx/include/__algorithm/ranges_contains.h
new file mode 100644
index 00..647b7ea34be342
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains.h
@@ -0,0 +1,60 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+
+#include <__algorithm/in_in_result.h>
+#include <__algorithm/ranges_find.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains {
+struct __fn {
+  template  _Sent, class _Type, 
class _Proj = identity>
+requires indirect_binary_predicate, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = 
{}) const {
+return ranges::find(std::move(__first), std::move(__last), __value, 
std::ref(__proj)) != __last;
+  }
+
+  template 
+requires indirect_binary_predicate, _Proj>, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
+return ranges::find(ranges::begin(__range), ranges::end(__range), __value, 
std::ref(__proj)) != ranges::end(__range);
+  }
+};
+} // namespace __contains
+inline namespace __cpo {
+inline constexpr auto contains = __contains::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 76e0d22bf73ef8..003bf132b38b4d 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -226,6 +226,14 @@ namespace ranges {
   template
 using copy_backward_result = in_out_result;
 // since C++20
 
+  template S, class T, class Proj = identity>
+requires indirect_binary_predicate, 
const T*>
+constexpr bool ranges::contains(I first, S last, const T& value, Proj proj 
= {});   // since C++23
+
+  template
+requires indirect_binary_predicate, Proj>, const T*>
+constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {});
 // since C++23
+
   template S, weakly_incrementable O>
 requires indirectly_copyable
 constexpr ranges::copy_result ranges::copy(I first, S last, O 
result);// since C++20
@@ -1827,6 +1835,7 @@ template 
 #include <__algorithm/ranges_any_of.h>
 #include <__algorithm/ranges_binary_search.h>
 #include <__algorithm/ranges_clamp.h>
+#include <__algorithm/ranges_contains.h>
 #include <__algorithm/ranges_copy.h>
 #include <__algorithm/ranges_copy_backward.h>
 #include <__algorithm/ranges_copy_if.h>
diff --git 
a/libcxx/test/libcxx/algorithms/ranges_robust_against_copying

[Lldb-commits] [lldb] Make only one function that needs to be implemented when searching for types (PR #74786)

2023-12-12 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [clang-tools-extra] [lldb] [compiler-rt] [libcxx] [lld] [clang] [llvm] [mlir] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-12-12 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/66963

>From 5a2c930770cf548c5e3f3451e76b48cb067e6762 Mon Sep 17 00:00:00 2001
From: Zijun Zhao 
Date: Wed, 13 Sep 2023 14:26:01 -0700
Subject: [PATCH 1/6] [libc++] Implement ranges::contains_subrange

---
 libcxx/include/CMakeLists.txt |   1 +
 .../__algorithm/ranges_contains_subrange.h| 145 +
 libcxx/include/algorithm  |  14 +
 ...obust_against_copying_projections.pass.cpp |   4 +
 .../ranges.contains_subrange.pass.cpp | 293 ++
 .../niebloid.compile.pass.cpp |   3 +
 6 files changed, 460 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains_subrange.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains_subrange.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 2ec755236dbae..b096259f85f6a 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,7 @@ set(files
   __algorithm/ranges_any_of.h
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
+  __algorithm/ranges_contains_subrange.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains_subrange.h 
b/libcxx/include/__algorithm/ranges_contains_subrange.h
new file mode 100644
index 0..16de6c29cb2a1
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains_subrange.h
@@ -0,0 +1,145 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
+
+#include <__algorithm/ranges_starts_with.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains_subrange {
+struct __fn {
+  template  _Sent1,
+input_iterator _Iter2,
+sentinel_for<_Iter2> _Sent2,
+class _Pred,
+class _Proj1,
+class _Proj2,
+class _Offset>
+  static _LIBCPP_HIDE_FROM_ABI constexpr bool __contains_subrange_fn_impl(
+  _Iter1 __first1,
+  _Sent1 __last1,
+  _Iter2 __first2,
+  _Sent2 __last2,
+  _Pred& __pred,
+  _Proj1& __proj1,
+  _Proj2& __proj2,
+  _Offset __offset) {
+if (__offset < 0)
+  return false;
+else {
+  for (; __offset >= 0; __offset--, __first1++) {
+auto result = ranges::starts_with(
+std::move(__first1),
+std::move(__last1),
+std::move(__first2),
+std::move(__last2),
+std::ref(__pred),
+std::ref(__proj1),
+std::ref(__proj2));
+if (result)
+  return true;
+  }
+  return false;
+}
+  }
+
+  template  _Sent1,
+input_iterator _Iter2,
+sentinel_for<_Iter2> _Sent2,
+class _Pred  = ranges::equal_to,
+class _Proj1 = identity,
+class _Proj2 = identity>
+requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+  _Iter1 __first1,
+  _Sent1 __last1,
+  _Iter2 __first2,
+  _Sent2 __last2,
+  _Pred __pred   = {},
+  _Proj1 __proj1 = {},
+  _Proj2 __proj2 = {}) const {
+auto __n1 = ranges::distance(__first1, __last1);
+auto __n2 = ranges::distance(__first2, __last2);
+auto __offset = __n1 - __n2;
+
+return __contains_subrange_fn_impl(
+std::move(__first1),
+std::move(__last1),
+std::move(__first2),
+std::move(__last2),
+__pred,
+__proj1,
+__proj2,
+std::move(__offset));
+  }
+
+  template 
+requires indirectly_comparable, iterator_t<_Range2>, 
_Pred, _Proj1, _Proj2>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+  _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 
__proj1 = {}, _Proj2 __proj2 = {}) const {
+auto __n1 = 0;
+auto __n2 = 0;
+
+if constexpr (s

[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [libcxx] [libunwind] [lld] [libcxxabi] [clang] [libc] [flang] [llvm] [mlir] [libc++] Implement ranges::contains (PR #65148)

2023-12-12 Thread via lldb-commits


@@ -0,0 +1,49 @@
+//===--===//

ZijunZhaoCCK wrote:

Done! already add here: 
https://github.com/llvm/llvm-project/pull/65148#issue-1876098703 Thank you for 
helping review!

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


[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [libcxx] [libunwind] [lld] [libcxxabi] [clang] [libc] [flang] [llvm] [mlir] [libc++] Implement ranges::contains (PR #65148)

2023-12-12 Thread via lldb-commits

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


[Lldb-commits] [llvm] [lldb] [compiler-rt] [libcxx] [clang-tools-extra] [clang] [mlir] [libc] [libcxxabi] [lld] [libunwind] [flang] [libc++] Implement ranges::contains (PR #65148)

2023-12-12 Thread via lldb-commits

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


[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [libcxx] [libunwind] [lld] [libcxxabi] [clang] [libc] [flang] [llvm] [mlir] [libc++] Implement ranges::contains (PR #65148)

2023-12-12 Thread via lldb-commits

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


[Lldb-commits] [llvm] [lldb] [compiler-rt] [libcxx] [clang-tools-extra] [clang] [mlir] [libc] [libcxxabi] [lld] [libunwind] [flang] [libc++] Implement ranges::contains (PR #65148)

2023-12-12 Thread via lldb-commits

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


[Lldb-commits] [mlir] [clang-tools-extra] [lldb] [llvm] [libc] [libcxx] [clang] [libcxxabi] [libunwind] [compiler-rt] [flang] [lld] [libc++] Implement ranges::contains (PR #65148)

2023-12-12 Thread via lldb-commits

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


[Lldb-commits] [llvm] [lldb] [compiler-rt] [libcxx] [clang-tools-extra] [clang] [mlir] [libc] [libcxxabi] [lld] [libunwind] [flang] [libc++] Implement ranges::contains (PR #65148)

2023-12-12 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/65148

>From 02e9afd761228f401df4d9f8dfaaca44ffae0c6e Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 31 Aug 2023 20:08:32 +
Subject: [PATCH 01/20] [libc++] Implement ranges::contains

Differential Revision: https://reviews.llvm.org/D159232
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__algorithm/ranges_contains.h  |  60 ++
 libcxx/include/algorithm  |   9 +
 ...obust_against_copying_projections.pass.cpp |   4 +
 .../alg.contains/ranges.contains.pass.cpp | 190 ++
 .../niebloid.compile.pass.cpp |   1 +
 6 files changed, 265 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 77a7269121ec1..024aa8959fb72 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,7 @@ set(files
   __algorithm/ranges_any_of.h
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
+  __algorithm/ranges_contains.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains.h 
b/libcxx/include/__algorithm/ranges_contains.h
new file mode 100644
index 0..647b7ea34be34
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains.h
@@ -0,0 +1,60 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+
+#include <__algorithm/in_in_result.h>
+#include <__algorithm/ranges_find.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains {
+struct __fn {
+  template  _Sent, class _Type, 
class _Proj = identity>
+requires indirect_binary_predicate, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = 
{}) const {
+return ranges::find(std::move(__first), std::move(__last), __value, 
std::ref(__proj)) != __last;
+  }
+
+  template 
+requires indirect_binary_predicate, _Proj>, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
+return ranges::find(ranges::begin(__range), ranges::end(__range), __value, 
std::ref(__proj)) != ranges::end(__range);
+  }
+};
+} // namespace __contains
+inline namespace __cpo {
+inline constexpr auto contains = __contains::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 76e0d22bf73ef..003bf132b38b4 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -226,6 +226,14 @@ namespace ranges {
   template
 using copy_backward_result = in_out_result;
 // since C++20
 
+  template S, class T, class Proj = identity>
+requires indirect_binary_predicate, 
const T*>
+constexpr bool ranges::contains(I first, S last, const T& value, Proj proj 
= {});   // since C++23
+
+  template
+requires indirect_binary_predicate, Proj>, const T*>
+constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {});
 // since C++23
+
   template S, weakly_incrementable O>
 requires indirectly_copyable
 constexpr ranges::copy_result ranges::copy(I first, S last, O 
result);// since C++20
@@ -1827,6 +1835,7 @@ template 
 #include <__algorithm/ranges_any_of.h>
 #include <__algorithm/ranges_binary_search.h>
 #include <__algorithm/ranges_clamp.h>
+#include <__algorithm/ranges_contains.h>
 #include <__algorithm/ranges_copy.h>
 #include <__algorithm/ranges_copy_backward.h>
 #include <__algorithm/ranges_copy_if.h>
diff --git 
a/libcxx/test/libcxx/algorithms/ranges_robust_against_copying_proje

[Lldb-commits] [lldb] Make only one function that needs to be implemented when searching for types (PR #74786)

2023-12-12 Thread Greg Clayton via lldb-commits

clayborg wrote:

Never mind, ran `git fetch upstream && git rebase upstream/main` and it fixed 
everything...

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


[Lldb-commits] [lld] [llvm] [mlir] [compiler-rt] [clang] [libcxx] [clang-tools-extra] [lldb] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-12-12 Thread Konstantin Varlamov via lldb-commits

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


[Lldb-commits] [llvm] [compiler-rt] [lldb] [clang] [clang-tools-extra] [lld] [mlir] [libcxx] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-12-12 Thread Konstantin Varlamov via lldb-commits

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


[Lldb-commits] [llvm] [lldb] [compiler-rt] [libcxx] [clang-tools-extra] [clang] [mlir] [libc] [libcxxabi] [lld] [libunwind] [flang] [libc++] Implement ranges::contains (PR #65148)

2023-12-12 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/65148

>From 02e9afd761228f401df4d9f8dfaaca44ffae0c6e Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 31 Aug 2023 20:08:32 +
Subject: [PATCH 01/19] [libc++] Implement ranges::contains

Differential Revision: https://reviews.llvm.org/D159232
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__algorithm/ranges_contains.h  |  60 ++
 libcxx/include/algorithm  |   9 +
 ...obust_against_copying_projections.pass.cpp |   4 +
 .../alg.contains/ranges.contains.pass.cpp | 190 ++
 .../niebloid.compile.pass.cpp |   1 +
 6 files changed, 265 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 77a7269121ec14..024aa8959fb720 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,7 @@ set(files
   __algorithm/ranges_any_of.h
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
+  __algorithm/ranges_contains.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains.h 
b/libcxx/include/__algorithm/ranges_contains.h
new file mode 100644
index 00..647b7ea34be342
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains.h
@@ -0,0 +1,60 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+
+#include <__algorithm/in_in_result.h>
+#include <__algorithm/ranges_find.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains {
+struct __fn {
+  template  _Sent, class _Type, 
class _Proj = identity>
+requires indirect_binary_predicate, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = 
{}) const {
+return ranges::find(std::move(__first), std::move(__last), __value, 
std::ref(__proj)) != __last;
+  }
+
+  template 
+requires indirect_binary_predicate, _Proj>, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
+return ranges::find(ranges::begin(__range), ranges::end(__range), __value, 
std::ref(__proj)) != ranges::end(__range);
+  }
+};
+} // namespace __contains
+inline namespace __cpo {
+inline constexpr auto contains = __contains::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 76e0d22bf73ef8..003bf132b38b4d 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -226,6 +226,14 @@ namespace ranges {
   template
 using copy_backward_result = in_out_result;
 // since C++20
 
+  template S, class T, class Proj = identity>
+requires indirect_binary_predicate, 
const T*>
+constexpr bool ranges::contains(I first, S last, const T& value, Proj proj 
= {});   // since C++23
+
+  template
+requires indirect_binary_predicate, Proj>, const T*>
+constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {});
 // since C++23
+
   template S, weakly_incrementable O>
 requires indirectly_copyable
 constexpr ranges::copy_result ranges::copy(I first, S last, O 
result);// since C++20
@@ -1827,6 +1835,7 @@ template 
 #include <__algorithm/ranges_any_of.h>
 #include <__algorithm/ranges_binary_search.h>
 #include <__algorithm/ranges_clamp.h>
+#include <__algorithm/ranges_contains.h>
 #include <__algorithm/ranges_copy.h>
 #include <__algorithm/ranges_copy_backward.h>
 #include <__algorithm/ranges_copy_if.h>
diff --git 
a/libcxx/test/libcxx/algorithms/ranges_robust_against_copying

[Lldb-commits] [libcxxabi] [libc] [mlir] [clang-tools-extra] [lld] [llvm] [libcxx] [libunwind] [flang] [clang] [compiler-rt] [lldb] [libc++] Implement ranges::contains (PR #65148)

2023-12-12 Thread Konstantin Varlamov via lldb-commits


@@ -0,0 +1,49 @@
+//===--===//

var-const wrote:

Thanks a lot for adding the benchmark! Can you please post the results you're 
getting in the patch/commit description for potential future reference?

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


[Lldb-commits] [libunwind] [llvm] [libcxxabi] [compiler-rt] [clang-tools-extra] [lld] [libcxx] [flang] [lldb] [clang] [libc] [mlir] [libc++] Implement ranges::contains (PR #65148)

2023-12-12 Thread Konstantin Varlamov via lldb-commits

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


[Lldb-commits] [mlir] [flang] [llvm] [libc] [libunwind] [lldb] [libcxxabi] [clang] [libcxx] [lld] [clang-tools-extra] [compiler-rt] [libc++] Implement ranges::contains (PR #65148)

2023-12-12 Thread Konstantin Varlamov via lldb-commits


@@ -0,0 +1,49 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include 
+#include 
+#include 
+
+#include "test_iterators.h"

var-const wrote:

Nit: please move the `` include above so that it goes right after 
``.

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


[Lldb-commits] [libunwind] [llvm] [clang-tools-extra] [clang] [mlir] [libc] [lldb] [libcxx] [lld] [compiler-rt] [libcxxabi] [flang] [libc++] Implement ranges::contains (PR #65148)

2023-12-12 Thread Konstantin Varlamov via lldb-commits

https://github.com/var-const approved this pull request.

Thanks a lot for working on this! LGTM with a couple simple comments.

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


[Lldb-commits] [lld] [openmp] [flang] [compiler-rt] [clang] [libc] [lldb] [mlir] [libcxx] [llvm] [clang-tools-extra] fix issue 73559. (PR #74926)

2023-12-12 Thread via lldb-commits

ChipsSpectre wrote:

The tests also pass after the review comments, I just validated on my machine.

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


[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-12-12 Thread Kevin Frei via lldb-commits

kevinfrei wrote:

Ran the first script, sudo nina install-distribution, then ran the second 
script.

I don't see the build depending on what's been installed, as it looks like 
setting LLVM_DIR makes the .so dependency on the binary sitting in the 
rel-llvm/lib directory instead.

[build.log.gz](https://github.com/llvm/llvm-project/files/13653581/build.log.gz)


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


[Lldb-commits] [lld] [compiler-rt] [clang] [flang] [lldb] [libc] [libcxx] [clang-tools-extra] [llvm] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

2023-12-12 Thread Stanislav Mekhanoshin via lldb-commits

rampitec wrote:

Yet another part to fix disjoint memory checks with LDS DMA: 
https://github.com/llvm/llvm-project/pull/75249

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


[Lldb-commits] [lld] [compiler-rt] [clang] [flang] [lldb] [libc] [libcxx] [clang-tools-extra] [llvm] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

2023-12-12 Thread Stanislav Mekhanoshin via lldb-commits

rampitec wrote:

Another part is improving memoperand info: 
https://github.com/llvm/llvm-project/pull/75247. This is NFCI just by itself.

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


[Lldb-commits] [lldb] [lldb-dap] Implement command directives (PR #74808)

2023-12-12 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Implement command directives (PR #74808)

2023-12-12 Thread Greg Clayton via lldb-commits


@@ -33,18 +39,59 @@ void RunLLDBCommands(llvm::StringRef prefix,
   const char *error = result.GetError();
   strm << error;
 }
+  };
+
+  lldb::SBCommandInterpreter interp = g_dap.debugger.GetCommandInterpreter();
+  for (llvm::StringRef command : commands) {
+lldb::SBCommandReturnObject result;
+bool quiet_on_success = false;
+bool check_error = false;
+
+while (parse_command_directives) {
+  if (command.starts_with("?")) {
+command = command.drop_front();
+quiet_on_success = true;
+  } else if (command.starts_with("!")) {
+command = command.drop_front();
+check_error = true;
+  } else {
+break;
+  }
+}
+
+interp.HandleCommand(command.str().c_str(), result);
+const bool got_error = !result.Succeeded();
+// The if statement below is assuming we always print out `!` prefixed
+// lines. The only time we don't print is when we have `quiet_on_success ==
+// true` and we don't have an error.
+if (quiet_on_success ? got_error : true)
+  print_result(command, result, strm);
+if (check_error && got_error)
+  return false; // Stop running commands.
   }
+  return true;
 }
 
 std::string RunLLDBCommands(llvm::StringRef prefix,
-const llvm::ArrayRef &commands) {
+const llvm::ArrayRef &commands,
+bool &fatal_error, bool parse_command_directives) {

clayborg wrote:

The more I think about it `fatal_error` sounds bad, how about we do 
`required_command_failed` and rename everywhere?

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


[Lldb-commits] [lldb] [lldb-dap] Implement command directives (PR #74808)

2023-12-12 Thread Greg Clayton via lldb-commits

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

Just one variable rename and inline the `print_result` and this is good to go.

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


[Lldb-commits] [lldb] [lldb-dap] Implement command directives (PR #74808)

2023-12-12 Thread Greg Clayton via lldb-commits


@@ -33,18 +39,59 @@ void RunLLDBCommands(llvm::StringRef prefix,
   const char *error = result.GetError();
   strm << error;
 }
+  };
+
+  lldb::SBCommandInterpreter interp = g_dap.debugger.GetCommandInterpreter();
+  for (llvm::StringRef command : commands) {
+lldb::SBCommandReturnObject result;
+bool quiet_on_success = false;
+bool check_error = false;
+
+while (parse_command_directives) {
+  if (command.starts_with("?")) {
+command = command.drop_front();
+quiet_on_success = true;
+  } else if (command.starts_with("!")) {
+command = command.drop_front();
+check_error = true;
+  } else {
+break;
+  }
+}
+
+interp.HandleCommand(command.str().c_str(), result);
+const bool got_error = !result.Succeeded();
+// The if statement below is assuming we always print out `!` prefixed
+// lines. The only time we don't print is when we have `quiet_on_success ==
+// true` and we don't have an error.
+if (quiet_on_success ? got_error : true)
+  print_result(command, result, strm);

clayborg wrote:

only one place we call `print_result` now, so inline it inside this if statement

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


[Lldb-commits] [lld] [compiler-rt] [clang] [flang] [lldb] [libc] [libcxx] [clang-tools-extra] [llvm] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

2023-12-12 Thread Stanislav Mekhanoshin via lldb-commits

rampitec wrote:

To make it easier I am splitting the patch. I have pre-comitted the test, and 
there is a part which fixes lack of wait on GFX10 : 
https://github.com/llvm/llvm-project/pull/75245

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


[Lldb-commits] [compiler-rt] [flang] [libcxx] [clang] [openmp] [libc] [clang-tools-extra] [lldb] [mlir] [lld] [llvm] fix issue 73559. (PR #74926)

2023-12-12 Thread via lldb-commits

https://github.com/ChipsSpectre updated 
https://github.com/llvm/llvm-project/pull/74926

>From 8269060e6b50721a847742ff8d0af2c819e52578 Mon Sep 17 00:00:00 2001
From: ChipsSpectre 
Date: Sat, 9 Dec 2023 12:07:02 +0100
Subject: [PATCH 1/6] fix issue 73559.

---
 clang/lib/Parse/ParseDecl.cpp| 3 ++-
 clang/lib/Parse/ParseDeclCXX.cpp | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index ece3698967e2f..5d1c19ae07cb5 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -3483,7 +3483,8 @@ void Parser::ParseDeclarationSpecifiers(
 
 case tok::coloncolon: // ::foo::bar
   // C++ scope specifier.  Annotate and loop, or bail out on error.
-  if (TryAnnotateCXXScopeToken(EnteringContext)) {
+  if (getLangOpts().CPlusPlus &&
+  TryAnnotateCXXScopeToken(EnteringContext)) {
 if (!DS.hasTypeSpecifier())
   DS.SetTypeSpecError();
 goto DoneWithDeclSpec;
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 910112ecae964..eba7ea65beee9 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -2702,7 +2702,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
   bool MalformedTypeSpec = false;
   if (!TemplateInfo.Kind &&
   Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
-if (TryAnnotateCXXScopeToken())
+if (getLangOpts().CPlusPlus && TryAnnotateCXXScopeToken())
   MalformedTypeSpec = true;
 
 bool isAccessDecl;

>From e8419c3750f7b1cf877b042942204abaab48344b Mon Sep 17 00:00:00 2001
From: ChipsSpectre 
Date: Mon, 11 Dec 2023 22:31:10 +0100
Subject: [PATCH 2/6] address review comments.

---
 clang/docs/ReleaseNotes.rst  | 2 ++
 clang/lib/Parse/ParseDeclCXX.cpp | 6 --
 clang/test/Parser/cxx-in-c.c | 1 +
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6e4009deaf874..39dd8c68dbbcb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -641,6 +641,8 @@ Bug Fixes in This Version
   Fixes (`#67317 `_)
 - Clang now properly diagnoses use of stand-alone OpenMP directives after a
   label (including ``case`` or ``default`` labels).
+- Fix crash when using C++ only tokens like *::* in C compiler clang.
+  Fixes (`#73559 https://github.com/llvm/llvm-project/issues/73559`_)
 
   Before:
 
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index eba7ea65beee9..89a97cc96111d 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -2678,7 +2678,9 @@ Parser::DeclGroupPtrTy
 Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
ParsedAttributes &AccessAttrs,
const ParsedTemplateInfo &TemplateInfo,
-   ParsingDeclRAIIObject *TemplateDiags) {
+   ParsingDeclRAIIObject *TemplateDiags) { 
 
+  assert(getLangOpts().CPlusPlus &&
+ "Call sites of this function should be guarded by checking for C++"); 
 
   if (Tok.is(tok::at)) {
 if (getLangOpts().ObjC && NextToken().isObjCAtKeyword(tok::objc_defs))
   Diag(Tok, diag::err_at_defs_cxx);
@@ -2702,7 +2704,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
   bool MalformedTypeSpec = false;
   if (!TemplateInfo.Kind &&
   Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
-if (getLangOpts().CPlusPlus && TryAnnotateCXXScopeToken())
+if (TryAnnotateCXXScopeToken())
   MalformedTypeSpec = true;
 
 bool isAccessDecl;
diff --git a/clang/test/Parser/cxx-in-c.c b/clang/test/Parser/cxx-in-c.c
index f5fa39bd0cb99..bd304260571c4 100644
--- a/clang/test/Parser/cxx-in-c.c
+++ b/clang/test/Parser/cxx-in-c.c
@@ -3,3 +3,4 @@
 // PR9137
 void f0(int x) : {}; // expected-error{{expected function body after function 
declarator}}
 void f1(int x) try {}; // expected-error{{expected function body after 
function declarator}}
+::; // expected-error{{expected that double colon marker does not appear in c}}

>From ac0d1c6d440b9c94af9bf95dc27687e2437ce39b Mon Sep 17 00:00:00 2001
From: ChipsSpectre 
Date: Mon, 11 Dec 2023 22:35:17 +0100
Subject: [PATCH 3/6] enforce coding style

---
 clang/lib/Parse/ParseDeclCXX.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 89a97cc96111d..1cf16a752cfcd 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -2678,9 +2678,9 @@ Parser::DeclGroupPtrTy
 Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
ParsedAttributes &AccessAttrs,
  

[Lldb-commits] [compiler-rt] [flang] [libcxx] [clang] [openmp] [libc] [clang-tools-extra] [lldb] [mlir] [lld] [llvm] fix issue 73559. (PR #74926)

2023-12-12 Thread via lldb-commits

https://github.com/ChipsSpectre updated 
https://github.com/llvm/llvm-project/pull/74926

>From 8269060e6b50721a847742ff8d0af2c819e52578 Mon Sep 17 00:00:00 2001
From: ChipsSpectre 
Date: Sat, 9 Dec 2023 12:07:02 +0100
Subject: [PATCH 1/5] fix issue 73559.

---
 clang/lib/Parse/ParseDecl.cpp| 3 ++-
 clang/lib/Parse/ParseDeclCXX.cpp | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index ece3698967e2f6..5d1c19ae07cb54 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -3483,7 +3483,8 @@ void Parser::ParseDeclarationSpecifiers(
 
 case tok::coloncolon: // ::foo::bar
   // C++ scope specifier.  Annotate and loop, or bail out on error.
-  if (TryAnnotateCXXScopeToken(EnteringContext)) {
+  if (getLangOpts().CPlusPlus &&
+  TryAnnotateCXXScopeToken(EnteringContext)) {
 if (!DS.hasTypeSpecifier())
   DS.SetTypeSpecError();
 goto DoneWithDeclSpec;
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 910112ecae964c..eba7ea65beee94 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -2702,7 +2702,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
   bool MalformedTypeSpec = false;
   if (!TemplateInfo.Kind &&
   Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
-if (TryAnnotateCXXScopeToken())
+if (getLangOpts().CPlusPlus && TryAnnotateCXXScopeToken())
   MalformedTypeSpec = true;
 
 bool isAccessDecl;

>From e8419c3750f7b1cf877b042942204abaab48344b Mon Sep 17 00:00:00 2001
From: ChipsSpectre 
Date: Mon, 11 Dec 2023 22:31:10 +0100
Subject: [PATCH 2/5] address review comments.

---
 clang/docs/ReleaseNotes.rst  | 2 ++
 clang/lib/Parse/ParseDeclCXX.cpp | 6 --
 clang/test/Parser/cxx-in-c.c | 1 +
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6e4009deaf8746..39dd8c68dbbcb1 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -641,6 +641,8 @@ Bug Fixes in This Version
   Fixes (`#67317 `_)
 - Clang now properly diagnoses use of stand-alone OpenMP directives after a
   label (including ``case`` or ``default`` labels).
+- Fix crash when using C++ only tokens like *::* in C compiler clang.
+  Fixes (`#73559 https://github.com/llvm/llvm-project/issues/73559`_)
 
   Before:
 
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index eba7ea65beee94..89a97cc96111d8 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -2678,7 +2678,9 @@ Parser::DeclGroupPtrTy
 Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
ParsedAttributes &AccessAttrs,
const ParsedTemplateInfo &TemplateInfo,
-   ParsingDeclRAIIObject *TemplateDiags) {
+   ParsingDeclRAIIObject *TemplateDiags) { 
 
+  assert(getLangOpts().CPlusPlus &&
+ "Call sites of this function should be guarded by checking for C++"); 
 
   if (Tok.is(tok::at)) {
 if (getLangOpts().ObjC && NextToken().isObjCAtKeyword(tok::objc_defs))
   Diag(Tok, diag::err_at_defs_cxx);
@@ -2702,7 +2704,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
   bool MalformedTypeSpec = false;
   if (!TemplateInfo.Kind &&
   Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
-if (getLangOpts().CPlusPlus && TryAnnotateCXXScopeToken())
+if (TryAnnotateCXXScopeToken())
   MalformedTypeSpec = true;
 
 bool isAccessDecl;
diff --git a/clang/test/Parser/cxx-in-c.c b/clang/test/Parser/cxx-in-c.c
index f5fa39bd0cb99b..bd304260571c4d 100644
--- a/clang/test/Parser/cxx-in-c.c
+++ b/clang/test/Parser/cxx-in-c.c
@@ -3,3 +3,4 @@
 // PR9137
 void f0(int x) : {}; // expected-error{{expected function body after function 
declarator}}
 void f1(int x) try {}; // expected-error{{expected function body after 
function declarator}}
+::; // expected-error{{expected that double colon marker does not appear in c}}

>From ac0d1c6d440b9c94af9bf95dc27687e2437ce39b Mon Sep 17 00:00:00 2001
From: ChipsSpectre 
Date: Mon, 11 Dec 2023 22:35:17 +0100
Subject: [PATCH 3/5] enforce coding style

---
 clang/lib/Parse/ParseDeclCXX.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 89a97cc96111d8..1cf16a752cfcdc 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -2678,9 +2678,9 @@ Parser::DeclGroupPtrTy
 Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
ParsedAttributes &AccessAttrs,
  

[Lldb-commits] [lldb] [lldb-dap] Emit more structured info along with variables (PR #75244)

2023-12-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Walter Erquinigo (walter-erquinigo)


Changes

In order to allow smarter vscode extensions, it's useful to send additional 
structured information of SBValues to the client. Specifically, I'm now sending 
error, summary, autoSummary and inMemoryValue in addition to the existing 
properties being sent. This is cheap because these properties have to be 
calculated anyway to generate the display value of the variable, but they are 
now available for extensions to better analyze variables. For example, if the 
error field is not present, the extension might be able to provide cool 
features, and the current way to do that is to look for the `"

[Lldb-commits] [lldb] [lldb-dap] Emit more structured info along with variables (PR #75244)

2023-12-12 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Emit more structured info along with variables (PR #75244)

2023-12-12 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/75244

In order to allow smarter vscode extensions, it's useful to send additional 
structured information of SBValues to the client. Specifically, I'm now sending 
error, summary, autoSummary and inMemoryValue in addition to the existing 
properties being sent. This is cheap because these properties have to be 
calculated anyway to generate the display value of the variable, but they are 
now available for extensions to better analyze variables. For example, if the 
error field is not present, the extension might be able to provide cool 
features, and the current way to do that is to look for the "From 3dbe79ffdbff7283c8d462dcb7f681f38e451a18 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 8 Dec 2023 12:58:30 -0500
Subject: [PATCH] [lldb-dap] Emit more structured info along with variables

In order to allow smarter vscode extensions, it's useful to send additional 
structured information of SBValues to the client. Specifically, I'm now sending 
error, summary, autoSummary and inMemoryValue in addition to the existing 
properties being sent. This is cheap because these properties have to be 
calculated anyway to generate the display value of the variable, but they are 
now available for extensions to better analyze variables. For example, if the 
error field is not present, the extension might be able to provide cool 
features, and the current way to do that is to look for the " 
TryCreateAutoSummary(lldb::SBValue value) {
   return TryCreateAutoSummaryForContainer(value);
 }
 
-std::string ValueToString(lldb::SBValue v) {
-  std::string result;
-  llvm::raw_string_ostream strm(result);
-
-  lldb::SBError error = v.GetError();
-  if (!error.Success()) {
-strm << "";
-  } else {
-llvm::StringRef value = v.GetValue();
-llvm::StringRef nonAutoSummary = v.GetSummary();
-std::optional summary = !nonAutoSummary.empty()
- ? nonAutoSummary.str()
- : TryCreateAutoSummary(v);
-if (!value.empty()) {
-  strm << value;
-  if (summary)
-strm << ' ' << *summary;
-} else if (summary) {
-  strm << *summary;
-
-  // As last resort, we print its type and address if available.
-} else {
-  if (llvm::StringRef type_name = v.GetType().GetDisplayTypeName();
-  !type_name.empty()) {
-strm << type_name;
-lldb::addr_t address = v.GetLoadAddress();
-if (address != LLDB_INVALID_ADDRESS)
-  strm << " @ " << llvm::format_hex(address, 0);
-  }
-}
-  }
-  return result;
-}
-
-void SetValueForKey(lldb::SBValue &v, llvm::json::Object &object,
-llvm::StringRef key) {
-  std::string result = ValueToString(v);
-  EmplaceSafeString(object, key, result);
-}
-
 void FillResponse(const llvm::json::Object &request,
   llvm::json::Object &response) {
   // Fill in all of the needed response fields to a "request" and set "success"
@@ -1044,6 +1004,59 @@ std::string 
CreateUniqueVariableNameForDisplay(lldb::SBValue v,
   return name_builder.GetData();
 }
 
+VariableDescription::VariableDescription(
+lldb::SBValue v, bool format_hex, bool is_name_duplicated,
+std::optional custom_name) {
+  name = custom_name
+ ? *custom_name
+ : CreateUniqueVariableNameForDisplay(v, is_name_duplicated);
+
+  type_obj = v.GetType();
+  std::string raw_display_type_name =
+  llvm::StringRef(type_obj.GetDisplayTypeName()).str();
+  display_type_name =
+  !raw_display_type_name.empty() ? raw_display_type_name : NO_TYPENAME;
+
+  if (format_hex)
+v.SetFormat(lldb::eFormatHex);
+
+  llvm::raw_string_ostream os_display_value(display_value);
+
+  if (lldb::SBError sb_error = v.GetError(); sb_error.Fail()) {
+error = sb_error.GetCString();
+os_display_value << "";
+  } else {
+in_memory_value = llvm::StringRef(v.GetValue()).str();
+summary = llvm::StringRef(v.GetSummary()).str();
+if (summary.empty())
+  auto_summary = TryCreateAutoSummary(v);
+
+std::optional effective_summary =
+!summary.empty() ? summary : auto_summary;
+
+if (!in_memory_value.empty()) {
+  os_display_value << in_memory_value;
+  if (effective_summary)
+os_display_value << " " << *effective_summary;
+} else if (effective_summary) {
+  os_display_value << *effective_summary;
+
+  // As last resort, we print its type and address if available.
+} else {
+  if (!raw_display_type_name.empty()) {
+os_display_value << raw_display_type_name;
+lldb::addr_t address = v.GetLoadAddress();
+if (address != LLDB_INVALID_ADDRESS)
+  os_display_value << " @ " << llvm::format_hex(address, 0);
+  }
+}
+  }
+
+  lldb::SBStream evaluateStream;
+  v.GetExpressionPath(evaluateStream);
+  evaluate_name = llvm::StringRef(evaluateStream.GetData()).str()

[Lldb-commits] [lldb] [lldb] Correctly check and report error states in StackFrame.cpp (PR #74414)

2023-12-12 Thread Pete Lawrence via lldb-commits

PortalPete wrote:

> Clicking merge on @PortalPete 's behalf

Thank you, sir!


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


[Lldb-commits] [flang] [llvm] [libcxx] [compiler-rt] [lld] [clang-tools-extra] [libc] [clang] [lldb] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

2023-12-12 Thread Stanislav Mekhanoshin via lldb-commits

https://github.com/rampitec updated 
https://github.com/llvm/llvm-project/pull/74537

>From 7e382620cdc5999c645ed0746f242595f0294c58 Mon Sep 17 00:00:00 2001
From: Stanislav Mekhanoshin 
Date: Mon, 4 Dec 2023 16:11:53 -0800
Subject: [PATCH 1/7] [AMDGPU] Use alias info to relax waitcounts for LDS DMA

LDA DMA loads increase VMCNT and a load from the LDS stored must
wait on this counter to only read memory after it is written.
Wait count insertion pass does not track memory dependencies, it
tracks register dependencies. To model the LDS dependency a
psuedo register is used in the scoreboard, acting like if LDS DMA
writes it and LDS load reads it.

This patch adds 8 more pseudo registers to use for independent LDS
locations if we can prove they are disjoint using alias analysis.

Fixes: SWDEV-433427
---
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp   |  16 +-
 llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp |  73 +-
 llvm/lib/Target/AMDGPU/SIInstrInfo.cpp  |   4 +-
 llvm/lib/Target/AMDGPU/SIInstrInfo.h|   8 +
 llvm/lib/Target/AMDGPU/lds-dma-waits.ll | 154 
 llvm/test/CodeGen/AMDGPU/llc-pipeline.ll|   2 +
 6 files changed, 241 insertions(+), 16 deletions(-)
 create mode 100644 llvm/lib/Target/AMDGPU/lds-dma-waits.ll

diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp 
b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index a7f4d63229b7ef..2e079404b087fa 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -1128,11 +1128,10 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo 
&Info,
 MachineMemOperand::MOStore |
 MachineMemOperand::MODereferenceable;
 
-  // XXX - Should this be volatile without known ordering?
-  Info.flags |= MachineMemOperand::MOVolatile;
-
   switch (IntrID) {
   default:
+// XXX - Should this be volatile without known ordering?
+Info.flags |= MachineMemOperand::MOVolatile;
 break;
   case Intrinsic::amdgcn_raw_buffer_load_lds:
   case Intrinsic::amdgcn_raw_ptr_buffer_load_lds:
@@ -1140,6 +1139,7 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo 
&Info,
   case Intrinsic::amdgcn_struct_ptr_buffer_load_lds: {
 unsigned Width = 
cast(CI.getArgOperand(2))->getZExtValue();
 Info.memVT = EVT::getIntegerVT(CI.getContext(), Width * 8);
+Info.ptrVal = CI.getArgOperand(1);
 return true;
   }
   }
@@ -1268,8 +1268,8 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo 
&Info,
 Info.opc = ISD::INTRINSIC_VOID;
 unsigned Width = cast(CI.getArgOperand(2))->getZExtValue();
 Info.memVT = EVT::getIntegerVT(CI.getContext(), Width * 8);
-Info.flags |= MachineMemOperand::MOLoad | MachineMemOperand::MOStore |
-  MachineMemOperand::MOVolatile;
+Info.ptrVal = CI.getArgOperand(1);
+Info.flags |= MachineMemOperand::MOLoad | MachineMemOperand::MOStore;
 return true;
   }
   case Intrinsic::amdgcn_ds_bvh_stack_rtn: {
@@ -9084,7 +9084,9 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op,
 MachinePointerInfo LoadPtrI = LoadMMO->getPointerInfo();
 
 MachinePointerInfo StorePtrI = LoadPtrI;
-StorePtrI.V = nullptr;
+LoadPtrI.V = UndefValue::get(
+PointerType::get(*DAG.getContext(), AMDGPUAS::GLOBAL_ADDRESS));
+LoadPtrI.AddrSpace = AMDGPUAS::GLOBAL_ADDRESS;
 StorePtrI.AddrSpace = AMDGPUAS::LOCAL_ADDRESS;
 
 auto F = LoadMMO->getFlags() &
@@ -9162,6 +9164,8 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op,
 MachinePointerInfo LoadPtrI = LoadMMO->getPointerInfo();
 LoadPtrI.Offset = Op->getConstantOperandVal(5);
 MachinePointerInfo StorePtrI = LoadPtrI;
+LoadPtrI.V = UndefValue::get(
+PointerType::get(*DAG.getContext(), AMDGPUAS::GLOBAL_ADDRESS));
 LoadPtrI.AddrSpace = AMDGPUAS::GLOBAL_ADDRESS;
 StorePtrI.AddrSpace = AMDGPUAS::LOCAL_ADDRESS;
 auto F = LoadMMO->getFlags() &
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp 
b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index ede4841b8a5fd7..50ad22130e939e 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -31,6 +31,7 @@
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/PostOrderIterator.h"
 #include "llvm/ADT/Sequence.h"
+#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/CodeGen/MachineLoopInfo.h"
 #include "llvm/CodeGen/MachinePostDominators.h"
 #include "llvm/InitializePasses.h"
@@ -121,8 +122,13 @@ enum RegisterMapping {
   SQ_MAX_PGM_VGPRS = 512, // Maximum programmable VGPRs across all targets.
   AGPR_OFFSET = 256,  // Maximum programmable ArchVGPRs across all targets.
   SQ_MAX_PGM_SGPRS = 256, // Maximum programmable SGPRs across all targets.
-  NUM_EXTRA_VGPRS = 1,// A reserved slot for DS.
-  EXTRA_VGPR_LDS = 0, // An artificial register to track LDS writes.
+  NUM_EXTRA_VGPRS = 9,// Reserved slots f

[Lldb-commits] [lldb] [lldb-dap] Implement command directives (PR #74808)

2023-12-12 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/74808

>From e4c6bed8327aaedab1b5bd0a13e7408dc4d152e4 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 8 Dec 2023 00:11:19 -0500
Subject: [PATCH] [lldb-dap] Implement quiet commands

This adds support for optionally prefixing any command with `?`, which 
effectively prevents the output of these commands to be printed to the console 
unless they fail. This comes handy when programmaticaly running commands on 
behalf of the user without wanting them to know unless they fail.

In a later PR I plan to implement the `!` prefix for commands that abort 
lldb-dap upon errors.
---
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  7 ++
 .../test/API/tools/lldb-dap/commands/Makefile |  3 +
 .../lldb-dap/commands/TestDAP_commands.py | 75 +++
 .../test/API/tools/lldb-dap/commands/main.cpp |  1 +
 lldb/tools/lldb-dap/DAP.cpp   | 49 ++--
 lldb/tools/lldb-dap/DAP.h | 17 +++--
 lldb/tools/lldb-dap/LLDBUtils.cpp | 69 ++---
 lldb/tools/lldb-dap/LLDBUtils.h   | 37 -
 lldb/tools/lldb-dap/lldb-dap.cpp  | 45 ---
 lldb/tools/lldb-dap/package.json  | 24 +++---
 10 files changed, 278 insertions(+), 49 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/commands/Makefile
 create mode 100644 lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py
 create mode 100644 lldb/test/API/tools/lldb-dap/commands/main.cpp

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 4ccd6014e54be..7436b9900e98b 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -291,6 +291,7 @@ def attach(
 postRunCommands=None,
 sourceMap=None,
 sourceInitFile=False,
+expectFailure=False,
 ):
 """Build the default Makefile target, create the DAP debug adaptor,
 and attach to the process.
@@ -322,6 +323,8 @@ def cleanup():
 postRunCommands=postRunCommands,
 sourceMap=sourceMap,
 )
+if expectFailure:
+return response
 if not (response and response["success"]):
 self.assertTrue(
 response["success"], "attach failed (%s)" % 
(response["message"])
@@ -437,6 +440,8 @@ def build_and_launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+launchCommands=None,
+expectFailure=False,
 ):
 """Build the default Makefile target, create the DAP debug adaptor,
 and launch the process.
@@ -470,4 +475,6 @@ def build_and_launch(
 commandEscapePrefix=commandEscapePrefix,
 customFrameFormat=customFrameFormat,
 customThreadFormat=customThreadFormat,
+launchCommands=launchCommands,
+expectFailure=expectFailure,
 )
diff --git a/lldb/test/API/tools/lldb-dap/commands/Makefile 
b/lldb/test/API/tools/lldb-dap/commands/Makefile
new file mode 100644
index 0..8b20bcb05
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/commands/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git a/lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py 
b/lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py
new file mode 100644
index 0..16794982c10fb
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py
@@ -0,0 +1,75 @@
+import os
+
+import dap_server
+import lldbdap_testcase
+from lldbsuite.test import lldbtest, lldbutil
+from lldbsuite.test.decorators import *
+
+
+class TestDAP_commands(lldbdap_testcase.DAPTestCaseBase):
+def test_command_directive_quiet_on_success(self):
+program = self.getBuildArtifact("a.out")
+command_quiet = (
+"settings set target.show-hex-variable-values-with-leading-zeroes 
false"
+)
+command_not_quiet = (
+"settings set target.show-hex-variable-values-with-leading-zeroes 
true"
+)
+self.build_and_launch(
+program,
+initCommands=["?" + command_quiet, command_not_quiet],
+terminateCommands=["?" + command_quiet, command_not_quiet],
+stopCommands=["?" + command_quiet, command_not_quiet],
+exitCommands=["?" + command_quiet, command_not_quiet],
+)
+full_output = self.collect_console(duration=1.0)
+self.assertNotIn(command_quiet, full_output)
+self.assertIn(command_not_quiet, full_output)
+
+def do_test_abort_on_error(
+self,
+use_init_commands=False,
+use_launch_commands=False,
+use_pre_run_commands=False,
+):
+program = self.get

[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-12-12 Thread Michał Górny via lldb-commits

mgorny wrote:

Did you `ninja install-distribution` rather than regular `install`? Did it pick 
the right installation? Could you attach the build logs?

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


[Lldb-commits] [mlir] [openmp] [flang] [libc] [clang-tools-extra] [llvm] [lldb] [lld] [libcxxabi] [compiler-rt] [libcxx] [clang] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-12 Thread Jon Roelofs via lldb-commits

jroelofs wrote:

ping

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


[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)

2023-12-12 Thread via lldb-commits


@@ -175,3 +179,30 @@ Status TargetThreadWindows::DoResume() {
 
   return Status();
 }
+
+const char *TargetThreadWindows::GetName() {
+  Log *log = GetLog(LLDBLog::Thread);
+  HMODULE hModule = ::LoadLibraryW(L"Kernel32.dll");
+  if (hModule) {
+auto GetThreadDescription =

oltolm wrote:

done

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


[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)

2023-12-12 Thread via lldb-commits


@@ -175,3 +179,30 @@ Status TargetThreadWindows::DoResume() {
 
   return Status();
 }
+
+const char *TargetThreadWindows::GetName() {
+  Log *log = GetLog(LLDBLog::Thread);
+  HMODULE hModule = ::LoadLibraryW(L"Kernel32.dll");
+  if (hModule) {
+auto GetThreadDescription =
+reinterpret_cast(
+::GetProcAddress(hModule, "GetThreadDescription"));
+LLDB_LOGF(log, "GetProcAddress: %p",
+  reinterpret_cast(GetThreadDescription));
+if (GetThreadDescription) {

oltolm wrote:

done

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


[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)

2023-12-12 Thread via lldb-commits


@@ -175,3 +179,30 @@ Status TargetThreadWindows::DoResume() {
 
   return Status();
 }
+
+const char *TargetThreadWindows::GetName() {
+  Log *log = GetLog(LLDBLog::Thread);
+  HMODULE hModule = ::LoadLibraryW(L"Kernel32.dll");
+  if (hModule) {
+auto GetThreadDescription =
+reinterpret_cast(
+::GetProcAddress(hModule, "GetThreadDescription"));

oltolm wrote:

You are talking about setting thread names, but I implemented getting a thread 
name from Windows.

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


[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)

2023-12-12 Thread via lldb-commits

https://github.com/oltolm updated 
https://github.com/llvm/llvm-project/pull/74731

>From 9383b8b92849c71a96b4b4e7e55f615d8f2efedb Mon Sep 17 00:00:00 2001
From: oltolm 
Date: Fri, 1 Dec 2023 16:49:13 +0100
Subject: [PATCH 1/3] lldb: add support for thread names on Windows

---
 .../Windows/Common/TargetThreadWindows.cpp| 31 +++
 .../Windows/Common/TargetThreadWindows.h  |  2 ++
 2 files changed, 33 insertions(+)

diff --git a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
index 37dc8f6d6d14a..047019ac30f49 100644
--- a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
@@ -15,6 +15,7 @@
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/State.h"
+#include "llvm/Support/ConvertUTF.h"
 
 #include "ProcessWindows.h"
 #include "ProcessWindowsLog.h"
@@ -33,6 +34,9 @@
 using namespace lldb;
 using namespace lldb_private;
 
+using GetThreadDescriptionFunctionPtr = HRESULT
+WINAPI (*)(HANDLE hThread, PWSTR *ppszThreadDescription);
+
 TargetThreadWindows::TargetThreadWindows(ProcessWindows &process,
  const HostThread &thread)
 : Thread(process, thread.GetNativeThread().GetThreadId()),
@@ -175,3 +179,30 @@ Status TargetThreadWindows::DoResume() {
 
   return Status();
 }
+
+const char *TargetThreadWindows::GetName() {
+  Log *log = GetLog(LLDBLog::Thread);
+  HMODULE hModule = ::LoadLibraryW(L"Kernel32.dll");
+  if (hModule) {
+auto GetThreadDescription =
+reinterpret_cast(
+::GetProcAddress(hModule, "GetThreadDescription"));
+LLDB_LOGF(log, "GetProcAddress: %p",
+  reinterpret_cast(GetThreadDescription));
+if (GetThreadDescription) {
+  PWSTR pszThreadName;
+  if (SUCCEEDED(GetThreadDescription(
+  m_host_thread.GetNativeThread().GetSystemHandle(),
+  &pszThreadName))) {
+LLDB_LOGF(log, "GetThreadDescription: %ls", pszThreadName);
+llvm::convertUTF16ToUTF8String(
+llvm::ArrayRef(reinterpret_cast(pszThreadName),
+   wcslen(pszThreadName) * sizeof(wchar_t)),
+m_name);
+::LocalFree(pszThreadName);
+  }
+}
+  }
+
+  return m_name.c_str();
+}
diff --git a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.h 
b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.h
index 2845847738f60..07e1db464ad59 100644
--- a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.h
+++ b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.h
@@ -34,6 +34,7 @@ class TargetThreadWindows : public lldb_private::Thread {
   lldb::RegisterContextSP
   CreateRegisterContextForFrame(StackFrame *frame) override;
   bool CalculateStopInfo() override;
+  const char *GetName() override;
 
   Status DoResume();
 
@@ -42,6 +43,7 @@ class TargetThreadWindows : public lldb_private::Thread {
 private:
   lldb::RegisterContextSP m_thread_reg_ctx_sp;
   HostThread m_host_thread;
+  std::string m_name;
 };
 } // namespace lldb_private
 

>From 89ea63ca021da9e350bbb3016da601d7543d7e50 Mon Sep 17 00:00:00 2001
From: oltolm 
Date: Fri, 8 Dec 2023 19:42:48 +0100
Subject: [PATCH 2/3] [lldb] add unit test for Windows thread names

---
 lldb/unittests/Thread/CMakeLists.txt |  2 +
 lldb/unittests/Thread/ThreadTest.cpp | 71 
 2 files changed, 73 insertions(+)

diff --git a/lldb/unittests/Thread/CMakeLists.txt 
b/lldb/unittests/Thread/CMakeLists.txt
index d6e365adac5dd..f6c8795f349a5 100644
--- a/lldb/unittests/Thread/CMakeLists.txt
+++ b/lldb/unittests/Thread/CMakeLists.txt
@@ -11,5 +11,7 @@ add_lldb_unittest(ThreadTests
   lldbInterpreter
   lldbBreakpoint
   lldbPluginPlatformLinux
+  lldbPluginPlatformWindows
+  lldbPluginProcessWindowsCommon
   )
 
diff --git a/lldb/unittests/Thread/ThreadTest.cpp 
b/lldb/unittests/Thread/ThreadTest.cpp
index bd8cdce99f172..4c660e9815c3e 100644
--- a/lldb/unittests/Thread/ThreadTest.cpp
+++ b/lldb/unittests/Thread/ThreadTest.cpp
@@ -8,9 +8,20 @@
 
 #include "lldb/Target/Thread.h"
 #include "Plugins/Platform/Linux/PlatformLinux.h"
+#include 
+#ifdef _WIN32
+#include "lldb/Host/windows/HostThreadWindows.h"
+#include "lldb/Host/windows/windows.h"
+
+#include "Plugins/Platform/Windows/PlatformWindows.h"
+#include "Plugins/Process/Windows/Common/LocalDebugDelegate.h"
+#include "Plugins/Process/Windows/Common/ProcessWindows.h"
+#include "Plugins/Process/Windows/Common/TargetThreadWindows.h"
+#endif
 #include "lldb/Core/Debugger.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
+#include "lldb/Host/HostThread.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/StopInfo.h"
 #include "lldb/Utility/ArchSpec.h"
@@ -21,14 +32,33 @@ using namespace lldb_private::repro;
 using namespace l

[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-12-12 Thread Kevin Frei via lldb-commits

kevinfrei wrote:

I've spent 5 or 6 more hours fighting this and I'm fully stuck on "No Repro". I 
have a libLLVM-git18.so built, independent of building LLDB. Then I configured 
LLDB to build against that as a standalone entity and validated that it worked 
(all on my personal machine, which is running Kali Linux under WSL2: basically 
just Ubuntu). Below, you'll find shell scripts that I've been  using to 
configure the build (both for LLVM and then for the standalone LLDB build). 
Please tell me what I need to change in these scripts to repro the problem.

```
#!/bin/sh
# Configure LLVM for subsequent use by an LLDB build
cmake -G Ninja \
  -B rel-llvm \
  -S llvm/llvm \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_ENABLE_PROJECTS=clang \
  -DCMAKE_INSTALL_PREFIX=/usr \
  -DLLVM_APPEND_VC_REV=OFF \
  -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm/18 \
  -DBUILD_SHARED_LIBS=OFF \
  -DLLVM_BUILD_LLVM_DYLIB=ON \
  -DLLVM_LINK_LLVM_DYLIB=ON \
  -DLLVM_TARGETS_TO_BUILD="AArch64;X86" \
  -DLLVM_INCLUDE_BENCHMARKS=OFF \
  -DLLVM_ENABLE_ZSTD=yes \
  -DLLVM_ENABLE_CURL=yes \
  -DLLVM_HOST_TRIPLE=i686-pc-linux-gnu \
  
-DLLVM_DISTRIBUTION_COMPONENTS="LLVM;LTO;Remarks;llvm-config;cmake-exports;llvm-headers;LLVMDemangle;LLVMSupport;LLVMTableGen;llvm-tblgen;dsymutil;llc;lli;llvm-addr2line;llvm-ar;llvm-as;llvm-bcanalyzer;llvm-bitcode-strip;llvm-c-test;llvm-cat;llvm-cfi-verify;llvm-config;llvm-cov;llvm-cvtres;llvm-cxxdump;llvm-cxxfilt;llvm-cxxmap;llvm-debuginfo-analyzer;llvm-debuginfod-find;llvm-diff;llvm-dis;llvm-dlltool;llvm-dwarfdump;llvm-dwarfutil;llvm-dwp;llvm-exegesis;llvm-extract;llvm-gsymutil;llvm-ifs;llvm-install-name-tool;llvm-jitlink;llvm-lib;llvm-libtool-darwin;llvm-link;llvm-lipo;llvm-lto;llvm-lto2;llvm-mc;llvm-mca;llvm-ml;llvm-modextract;llvm-mt;llvm-nm;llvm-objcopy;llvm-objdump;llvm-opt-report;llvm-otool;llvm-pdbutil;llvm-profdata;llvm-profgen;llvm-ranlib;llvm-rc;llvm-readelf;llvm-readobj;llvm-readtapi;llvm-reduce;llvm-remarkutil;llvm-rtdyld;llvm-sim;llvm-size;llvm-split;llvm-stress;llvm-strings;llvm-strip;llvm-symbolizer;llvm-tli-checker;llvm-undname;llvm-windres;llvm-xray;opt;sancov;sanstats;verify-uselistorder;opt-viewer;llvm-debuginfod"
```
and this one for the lldb build:
```
#!/bin/sh
cmake -G Ninja \
  -B rel-lldb \
  -S llvm/lldb \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_TARGETS_TO_BUILD="AArch64;X86" \
  -DCMAKE_INSTALL_PREFIX=/usr \
  -DLLVM_ENABLE_LIBEDIT=yes \
  -DLLVM_ENABLE_TERMINFO=yes \
  -DLLVM_ENABLE_LIBXML2=yes \
  -DLLVM_ENABLE_EH=ON \
  -DLLVM_ENABLE_RTTI=ON \
  -DLLVM_ENABLE_CURL=yes \
  -DLLVM_HOST_TRIPLE=i686-pc-linux-gnu \
  -DPython3_EXECUTABLE=/usr/bin/python3 \
  -DLLVM_DIR=/home/freik/src/rel-llvm/lib/cmake/llvm
```

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


[Lldb-commits] [lldb] Add a test for evicting unreachable modules from the global module cache (PR #74894)

2023-12-12 Thread via lldb-commits

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


[Lldb-commits] [lldb] 2684281 - Add a test for evicting unreachable modules from the global module cache (#74894)

2023-12-12 Thread via lldb-commits

Author: jimingham
Date: 2023-12-12T11:28:06-08:00
New Revision: 2684281d208612a746b05c891f346bd7b95318d5

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

LOG: Add a test for evicting unreachable modules from the global module cache 
(#74894)

When you debug a binary and the change & rebuild and then rerun in lldb
w/o quitting lldb, the Modules in the Global Module Cache for the old
binary & .o files if used are now "unreachable". Nothing in lldb is
holding them alive, and they've already been unlinked. lldb will
properly discard them if there's not another Target referencing them.

However, this only works in simple cases at present. If you have several
Targets that reference the same modules, it's pretty easy to end up
stranding Modules that are no longer reachable, and if you use a
sequence of SBDebuggers unreachable modules can also get stranded. If
you run a long-lived lldb process and are iteratively developing on a
large code base, lldb's memory gets filled with useless Modules.

This patch adds a test for the mode that currently works:

(lldb) target create foo
(lldb) run

(lldb) run

In that case, we do delete the unreachable Modules.

The next step will be to add tests for the cases where we fail to do
this, then see how to safely/efficiently evict unreachable modules in
those cases as well.

Added: 
lldb/test/API/python_api/global_module_cache/Makefile
lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
lldb/test/API/python_api/global_module_cache/one-print.c
lldb/test/API/python_api/global_module_cache/two-print.c

Modified: 


Removed: 




diff  --git a/lldb/test/API/python_api/global_module_cache/Makefile 
b/lldb/test/API/python_api/global_module_cache/Makefile
new file mode 100644
index 00..22f1051530f871
--- /dev/null
+++ b/lldb/test/API/python_api/global_module_cache/Makefile
@@ -0,0 +1 @@
+include Makefile.rules

diff  --git 
a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py 
b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
new file mode 100644
index 00..98ebdec0404eb4
--- /dev/null
+++ b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
@@ -0,0 +1,169 @@
+"""
+Test the use of the global module cache in lldb
+"""
+
+import lldb
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+import os
+import shutil
+from pathlib import Path
+import time
+
+class GlobalModuleCacheTestCase(TestBase):
+# NO_DEBUG_INFO_TESTCASE = True
+
+def check_counter_var(self, thread, value):
+frame = thread.frames[0]
+var = frame.FindVariable("counter")
+self.assertTrue(var.GetError().Success(), "Got counter variable")
+self.assertEqual(var.GetValueAsUnsigned(), value, "This was one-print")
+
+def copy_to_main(self, src, dst):
+# We are relying on the source file being newer than the .o file from
+# a previous build, so sleep a bit here to ensure that the touch is 
later.
+time.sleep(2)
+try:
+shutil.copy(src, dst)
+except:
+self.fail(f"Could not copy {src} to {dst}")
+Path(dst).touch()
+
+# The rerun tests indicate rerunning on Windows doesn't really work, so
+# this one won't either.
+@skipIfWindows
+def test_OneTargetOneDebugger(self):
+self.do_test(True, True)
+
+# This behaves as implemented but that behavior is not desirable.
+# This test tests for the desired behavior as an expected fail.
+@skipIfWindows
+@expectedFailureAll
+def test_TwoTargetsOneDebugger(self):
+self.do_test(False, True)
+
+@skipIfWindows
+@expectedFailureAll
+def test_OneTargetTwoDebuggers(self):
+self.do_test(True, False)
+
+def do_test(self, one_target, one_debugger):
+# Make sure that if we have one target, and we run, then
+# change the binary and rerun, the binary (and any .o files
+# if using dwarf in .o file debugging) get removed from the
+# shared module cache.  They are no longer reachable.
+debug_style = self.getDebugInfo()
+
+# Before we do anything, clear the global module cache so we don't
+# see objects from other runs:
+lldb.SBDebugger.MemoryPressureDetected()
+
+# Set up the paths for our two versions of main.c:
+main_c_path = os.path.join(self.getBuildDir(), "main.c")
+one_print_path = os.path.join(self.getSourceDir(), "one-print.c")
+two_print_path = os.path.join(self.getSourceDir(), "two-print.c")
+main_filespec = lldb.SBFileSpec(main_c_path)
+
+# First copy the one-print.c to main.c in the build folder and

[Lldb-commits] [lldb] Add a test for evicting unreachable modules from the global module cache (PR #74894)

2023-12-12 Thread via lldb-commits

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

>From 438d35a7a7fca454718062583f91776ca018b2b1 Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Fri, 8 Dec 2023 14:43:14 -0800
Subject: [PATCH 1/4] Add a test for evicting unreachable modules from the
 global module cache.

---
 .../python_api/global_module_cache/Makefile   |   1 +
 .../TestGlobalModuleCache.py  | 110 ++
 .../global_module_cache/one-print.c   |   8 ++
 .../global_module_cache/two-print.c   |   9 ++
 4 files changed, 128 insertions(+)
 create mode 100644 lldb/test/API/python_api/global_module_cache/Makefile
 create mode 100644 
lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
 create mode 100644 lldb/test/API/python_api/global_module_cache/one-print.c
 create mode 100644 lldb/test/API/python_api/global_module_cache/two-print.c

diff --git a/lldb/test/API/python_api/global_module_cache/Makefile 
b/lldb/test/API/python_api/global_module_cache/Makefile
new file mode 100644
index 00..22f1051530f871
--- /dev/null
+++ b/lldb/test/API/python_api/global_module_cache/Makefile
@@ -0,0 +1 @@
+include Makefile.rules
diff --git 
a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py 
b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
new file mode 100644
index 00..ff74d09a128183
--- /dev/null
+++ b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
@@ -0,0 +1,110 @@
+"""
+Test the use of the global module cache in lldb
+"""
+
+import lldb
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+import os
+import shutil
+from pathlib import Path
+import time
+
+
+class GlobalModuleCacheTestCase(TestBase):
+# NO_DEBUG_INFO_TESTCASE = True
+
+def check_counter_var(self, thread, value):
+frame = thread.frames[0]
+var = frame.FindVariable("counter")
+self.assertTrue(var.GetError().Success(), "Got counter variable")
+self.assertEqual(var.GetValueAsUnsigned(), value, "This was one-print")
+
+def copy_to_main(self, src, dst):
+# We are relying on the source file being newer than the .o file from
+# a previous build, so sleep a bit here to ensure that the touch is 
later.
+time.sleep(2)
+try:
+shutil.copy(src, dst)
+except:
+self.fail(f"Could not copy {src} to {dst}")
+Path(dst).touch()
+
+# The rerun tests indicate rerunning on Windows doesn't really work, so
+# this one won't either.
+@skipIfWindows
+def test_OneTargetOneDebugger(self):
+# Make sure that if we have one target, and we run, then
+# change the binary and rerun, the binary (and any .o files
+# if using dwarf in .o file debugging) get removed from the
+# shared module cache.  They are no longer reachable.
+debug_style = self.getDebugInfo()
+
+# Before we do anything, clear the global module cache so we don't
+# see objects from other runs:
+lldb.SBDebugger.MemoryPressureDetected()
+
+# Set up the paths for our two versions of main.c:
+main_c_path = os.path.join(self.getBuildDir(), "main.c")
+one_print_path = os.path.join(self.getSourceDir(), "one-print.c")
+two_print_path = os.path.join(self.getSourceDir(), "two-print.c")
+main_filespec = lldb.SBFileSpec(main_c_path)
+
+# First copy the one-print.c to main.c in the build folder and
+# build our a.out from there:
+self.copy_to_main(one_print_path, main_c_path)
+self.build(dictionary={"C_SOURCES": main_c_path, "EXE": "a.out"})
+
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "return counter;", main_filespec
+)
+
+# Make sure we ran the version we intended here:
+self.check_counter_var(thread, 1)
+process.Kill()
+
+# Now copy two-print.c over main.c, rebuild, and rerun:
+# os.unlink(target.GetExecutable().fullpath)
+self.copy_to_main(two_print_path, main_c_path)
+
+self.build(dictionary={"C_SOURCES": main_c_path, "EXE": "a.out"})
+error = lldb.SBError()
+(_, process, thread, _) = lldbutil.run_to_breakpoint_do_run(self, 
target, bkpt)
+# In two-print.c counter will be 2:
+self.check_counter_var(thread, 2)
+
+num_a_dot_out_entries = 1
+# For dSYM's there will be two lines of output, one for the a.out and 
one
+# for the dSYM.
+if debug_style == "dsym":
+num_a_dot_out_entries += 1
+
+self.check_image_list_result(num_a_dot_out_entries, 1)
+
+def check_image_list_result(self, num_a_dot_out, num_main_dot_o):
+# Now look at the global module list, there should only be one a.out, 
and if we are
+# doing dwarf in .o file, there should onl

[Lldb-commits] [clang] [compiler-rt] [flang] [llvm] [lldb] [mlir] [clang-tools-extra] [Profile] Add binary profile correlation for code coverage. (PR #69493)

2023-12-12 Thread Zequan Wu via lldb-commits


@@ -0,0 +1,9 @@
+// RUN: %clang_cc1  -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-o - %s | FileCheck %s
+// RUN: %clang_cc1 -mllvm -profile-correlate=binary -fprofile-instrument=clang 
-fcoverage-mapping -emit-llvm -o - %s | FileCheck %s 
--check-prefix=BIN-CORRELATE
+
+// CHECK: @__llvm_profile_raw_version = {{.*}} i64 9

ZequanWu wrote:

ditto

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


[Lldb-commits] [clang] [llvm] [lldb] [mlir] [compiler-rt] [clang-tools-extra] [flang] [Profile] Add binary profile correlation for code coverage. (PR #69493)

2023-12-12 Thread Zequan Wu via lldb-commits


@@ -1829,6 +1833,22 @@ void CoverageMappingModuleGen::emit() {
  llvm::GlobalValue::InternalLinkage, NamesArrVal,
  llvm::getCoverageUnusedNamesVarName());
   }
+  const StringRef VarName(INSTR_PROF_QUOTE(INSTR_PROF_RAW_VERSION_VAR));
+  llvm::Type *IntTy64 = llvm::Type::getInt64Ty(Ctx);
+  uint64_t ProfileVersion = INSTR_PROF_RAW_VERSION;
+  if (llvm::ProfileCorrelate == llvm::InstrProfCorrelator::BINARY)
+ProfileVersion |= VARIANT_MASK_BIN_CORRELATE;

ZequanWu wrote:

ditto

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


[Lldb-commits] [llvm] [compiler-rt] [lldb] [clang] [mlir] [flang] [clang-tools-extra] [Profile] Add binary profile correlation for code coverage. (PR #69493)

2023-12-12 Thread Zequan Wu via lldb-commits


@@ -1829,6 +1833,22 @@ void CoverageMappingModuleGen::emit() {
  llvm::GlobalValue::InternalLinkage, NamesArrVal,
  llvm::getCoverageUnusedNamesVarName());
   }
+  const StringRef VarName(INSTR_PROF_QUOTE(INSTR_PROF_RAW_VERSION_VAR));

ZequanWu wrote:

I already reverted changes in Clang because `VARIANT_MASK_BIN_CORRELATE` flag 
is no longer necessary: 
https://github.com/llvm/llvm-project/pull/69493#issuecomment-1815324995

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


[Lldb-commits] [lldb] Make only one function that needs to be implemented when searching for types (PR #74786)

2023-12-12 Thread Greg Clayton via lldb-commits

clayborg wrote:

> Given that Michael is okay with it, too, let's land this!

I am testing on linux and windows to make sure everything is working and I will 
land this soon!


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


[Lldb-commits] [mlir] [flang] [clang-tools-extra] [lldb] [compiler-rt] [clang] [llvm] [Profile] Add binary profile correlation for code coverage. (PR #69493)

2023-12-12 Thread David Li via lldb-commits


@@ -1829,6 +1833,22 @@ void CoverageMappingModuleGen::emit() {
  llvm::GlobalValue::InternalLinkage, NamesArrVal,
  llvm::getCoverageUnusedNamesVarName());
   }
+  const StringRef VarName(INSTR_PROF_QUOTE(INSTR_PROF_RAW_VERSION_VAR));

david-xl wrote:

Add some comments for this segment.

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


[Lldb-commits] [flang] [llvm] [compiler-rt] [clang] [lldb] [mlir] [clang-tools-extra] [Profile] Add binary profile correlation for code coverage. (PR #69493)

2023-12-12 Thread David Li via lldb-commits

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


[Lldb-commits] [clang] [llvm] [flang] [mlir] [compiler-rt] [lldb] [clang-tools-extra] [Profile] Add binary profile correlation for code coverage. (PR #69493)

2023-12-12 Thread David Li via lldb-commits

https://github.com/david-xl approved this pull request.

LGTM. Thanks for the new feature. (Wait a few days in case other reviewers have 
additional comments).

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


[Lldb-commits] [flang] [clang] [lldb] [mlir] [compiler-rt] [clang-tools-extra] [llvm] [Profile] Add binary profile correlation for code coverage. (PR #69493)

2023-12-12 Thread David Li via lldb-commits


@@ -1829,6 +1833,22 @@ void CoverageMappingModuleGen::emit() {
  llvm::GlobalValue::InternalLinkage, NamesArrVal,
  llvm::getCoverageUnusedNamesVarName());
   }
+  const StringRef VarName(INSTR_PROF_QUOTE(INSTR_PROF_RAW_VERSION_VAR));
+  llvm::Type *IntTy64 = llvm::Type::getInt64Ty(Ctx);
+  uint64_t ProfileVersion = INSTR_PROF_RAW_VERSION;
+  if (llvm::ProfileCorrelate == llvm::InstrProfCorrelator::BINARY)
+ProfileVersion |= VARIANT_MASK_BIN_CORRELATE;

david-xl wrote:

This might overwrite other modifier bits set else where.

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


[Lldb-commits] [lldb] [llvm] [clang-tools-extra] [compiler-rt] [mlir] [clang] [flang] [Profile] Add binary profile correlation for code coverage. (PR #69493)

2023-12-12 Thread David Li via lldb-commits


@@ -0,0 +1,9 @@
+// RUN: %clang_cc1  -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-o - %s | FileCheck %s
+// RUN: %clang_cc1 -mllvm -profile-correlate=binary -fprofile-instrument=clang 
-fcoverage-mapping -emit-llvm -o - %s | FileCheck %s 
--check-prefix=BIN-CORRELATE
+
+// CHECK: @__llvm_profile_raw_version = {{.*}} i64 9

david-xl wrote:

why is it 9?

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


[Lldb-commits] [lldb] Make only one function that needs to be implemented when searching for types (PR #74786)

2023-12-12 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl approved this pull request.

Given that Michael is okay with it, too, let's land this!

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


[Lldb-commits] [mlir] [llvm] [compiler-rt] [clang] [clang-tools-extra] [libcxxabi] [flang] [openmp] [lldb] [libcxx] [MachineCopyPropagation] When the source of PreviousCopy is undef, we cannot replace

2023-12-12 Thread via lldb-commits

DianQK wrote:

> I don't believe the undef is the issue - I think the issue is that 
> AArch64InstrInfo::isCopyInstrImpl is saying that a W-reg orr is a copy, even 
> if it is really a zextend because the entire X output register is depended 
> upon.

Thanks for the explanation.

> Can you try and add something to isCopyInstrImpl instead, that says: If the 
> register is virtual then it should not be a subreg, and if the register is 
> physical then there should not be an implicit def of the X reg. Would that 
> solve your issue, and would it cause other problems in AArch64 codegen? Thanks

I'm not sure if I'm misunderstanding anything. But I tried to file the #75184 
PR.

It breaks the original commit 
https://github.com/llvm/llvm-project/commit/53726588f672a915c6f907569356091552500f23.
 It looks like it's because we're generating the mov instruction for the 
ORRWsr. (At this point this is a copy instruction?) I'm not sure exactly what 
is going wrong. Maybe we need to add a new method to TargetRegisterInfo?

Or are you going to fix this issue? I'm not familiar with MIR.
Alternatively, we can add implicit-def to MachineCopyPropagation? But that 
doesn't seem right either.


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


[Lldb-commits] [flang] [lld] [clang] [lldb] [mlir] [compiler-rt] [llvm] [libcxx] [openmp] [clang-tools-extra] [libc] [libcxxabi] [libc++] Fix `take_view::__sentinel`'s `operator==` (PR #74655)

2023-12-12 Thread Jakub Mazurkiewicz via lldb-commits

https://github.com/JMazurkiewicz updated 
https://github.com/llvm/llvm-project/pull/74655

>From b3de573887cdd86fd6ce168bdcc6d729d73b13b2 Mon Sep 17 00:00:00 2001
From: Jakub Mazurkiewicz 
Date: Wed, 6 Dec 2023 14:03:51 +0100
Subject: [PATCH 01/11] [libc++] Fix `take_view::__sentinel`'s `operator==`

---
 libcxx/include/__ranges/take_view.h   |   2 +-
 .../base.pass.cpp |   5 +-
 .../ctor.pass.cpp |   0
 .../range.take.sentinel/eq.pass.cpp   | 192 ++
 .../range.take/sentinel/eq.pass.cpp   |  55 -
 5 files changed, 194 insertions(+), 60 deletions(-)
 rename libcxx/test/std/ranges/range.adaptors/range.take/{sentinel => 
range.take.sentinel}/base.pass.cpp (83%)
 rename libcxx/test/std/ranges/range.adaptors/range.take/{sentinel => 
range.take.sentinel}/ctor.pass.cpp (100%)
 create mode 100644 
libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
 delete mode 100644 
libcxx/test/std/ranges/range.adaptors/range.take/sentinel/eq.pass.cpp

diff --git a/libcxx/include/__ranges/take_view.h 
b/libcxx/include/__ranges/take_view.h
index 4204017d9249bc..811428e529f59a 100644
--- a/libcxx/include/__ranges/take_view.h
+++ b/libcxx/include/__ranges/take_view.h
@@ -183,7 +183,7 @@ class take_view<_View>::__sentinel {
   template
 requires sentinel_for, 
iterator_t<__maybe_const<_OtherConst, _View>>>
   _LIBCPP_HIDE_FROM_ABI
-  friend constexpr bool operator==(const _Iter<_Const>& __lhs, const 
__sentinel& __rhs) {
+  friend constexpr bool operator==(const _Iter<_OtherConst>& __lhs, const 
__sentinel& __rhs) {
 return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
   }
 };
diff --git 
a/libcxx/test/std/ranges/range.adaptors/range.take/sentinel/base.pass.cpp 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp
similarity index 83%
rename from 
libcxx/test/std/ranges/range.adaptors/range.take/sentinel/base.pass.cpp
rename to 
libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp
index c949eb7cc08469..15b2b5476e86dd 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.take/sentinel/base.pass.cpp
+++ 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp
@@ -8,10 +8,7 @@
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17
 
-// sentinel() = default;
-// constexpr explicit sentinel(sentinel_t end);
-// constexpr sentinel(sentinel s)
-//   requires Const && convertible_to, sentinel_t>;
+// constexpr sentinel_t base() const;
 
 #include 
 #include 
diff --git 
a/libcxx/test/std/ranges/range.adaptors/range.take/sentinel/ctor.pass.cpp 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/ctor.pass.cpp
similarity index 100%
rename from 
libcxx/test/std/ranges/range.adaptors/range.take/sentinel/ctor.pass.cpp
rename to 
libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/ctor.pass.cpp
diff --git 
a/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
new file mode 100644
index 00..f20c29b4c64714
--- /dev/null
+++ 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
@@ -0,0 +1,192 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// friend constexpr bool operator==(const CI& y, const sentinel& x);
+// template
+//   requires sentinel_for, 
iterator_t>>
+// friend constexpr bool operator==(const CI& y, const sentinel& 
x);
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_iterators.h"
+
+template 
+class StrictIterator {
+  using Base = std::conditional_t;
+  Base base_;
+
+public:
+  using value_type  = int;
+  using difference_type = std::ptrdiff_t;
+
+  constexpr explicit StrictIterator(Base base) : base_(base) {}
+
+  StrictIterator(StrictIterator&&)= default;
+  StrictIterator& operator=(StrictIterator&&) = default;
+
+  constexpr StrictIterator& operator++() {
+++base_;
+return *this;
+  }
+
+  constexpr void operator++(int) { ++*this; }
+  constexpr decltype(auto) operator*() const { return *base_; }
+  constexpr Base base() const { return base_; }
+};
+
+static_assert(std::input_iterator>);
+static_assert(!std::copyable>);
+static_assert(!std::forward_iterator>);
+static_assert(std::input_iterator>);
+static_assert(!std::copyable>);
+static_assert(!std::forward_iterator>);
+
+template 
+class StrictSentinel {
+  using Base = std::conditional_t;
+  Base base_;
+
+public:
+  StrictSentinel() = def

[Lldb-commits] [lldb] [lldb] Correctly check and report error states in StackFrame.cpp (PR #74414)

2023-12-12 Thread Felipe de Azevedo Piovezan via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Correctly check and report error states in StackFrame.cpp (PR #74414)

2023-12-12 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

Clicking merge on @PortalPete 's behalf 

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


[Lldb-commits] [lldb] 0e9879e - [lldb] Correctly check and report error states in StackFrame.cpp (#74414)

2023-12-12 Thread via lldb-commits

Author: Pete Lawrence
Date: 2023-12-12T09:50:18-03:00
New Revision: 0e9879ed9711ac280c5e1ea47f77a033393d6baa

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

LOG: [lldb] Correctly check and report error states in StackFrame.cpp (#74414)

This commits fixes a few subtle bugs where the method:
1. Declares a local `Status error` which eclipses the method's parameter
`Status &error`.
- The method then sets the error state to the local `error` and returns
without ever touching the parameter `&error`.
- This effectively traps the error state and its message from ever
reaching the caller.
- I also threw in a null pointer check in case the callee doesn't set
its `Status` parameter but returns `0`/`nullptr`.

2. Declares a local `Status deref_error` (good), passes it to the
`Dereference` method (also good), but then checks the status of the
method's `Status &error` parameter (not good).
- The fix checks `deref_error` instead and also checks for a `nullptr`
return value.
- There's a good opportunity here for a future PR that changes the
`Dereference` method to fold an error state into the `ValueObject`
return value's `m_error` instead of using a parameter.

3. Declares another local `Status error`, which it doesn't pass to a
method (because there isn't a parameter for it), and then checks for an
error condition that never happens.
- The fix just checks the callee's return value, because that's all it
has to go on.
- This likely comes from a copy/paste from issue 1 above.


rdar://119155810

Added: 


Modified: 
lldb/source/Target/StackFrame.cpp

Removed: 




diff  --git a/lldb/source/Target/StackFrame.cpp 
b/lldb/source/Target/StackFrame.cpp
index f0d78d8aa5fefc..50cf01e63cd493 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -652,7 +652,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
 Status deref_error;
 if (valobj_sp->GetCompilerType().IsReferenceType()) {
   valobj_sp = valobj_sp->GetSyntheticValue()->Dereference(deref_error);
-  if (error.Fail()) {
+  if (!valobj_sp || deref_error.Fail()) {
 error.SetErrorStringWithFormatv(
 "Failed to dereference reference type: %s", deref_error);
 return ValueObjectSP();
@@ -660,7 +660,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
 }
 
 valobj_sp = valobj_sp->Dereference(deref_error);
-if (error.Fail()) {
+if (!valobj_sp || deref_error.Fail()) {
   error.SetErrorStringWithFormatv(
   "Failed to dereference sythetic value: {0}", deref_error);
   return ValueObjectSP();
@@ -795,9 +795,9 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
   // what we have is *ptr[low]. the most similar C++ syntax is to deref
   // ptr and extract bit low out of it. reading array item low would be
   // done by saying ptr[low], without a deref * sign
-  Status error;
-  ValueObjectSP temp(valobj_sp->Dereference(error));
-  if (error.Fail()) {
+  Status deref_error;
+  ValueObjectSP temp(valobj_sp->Dereference(deref_error));
+  if (!temp || deref_error.Fail()) {
 valobj_sp->GetExpressionPath(var_expr_path_strm);
 error.SetErrorStringWithFormat(
 "could not dereference \"(%s) %s\"",
@@ -813,9 +813,8 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
   // arr[0] (an operation that is equivalent to deref-ing arr) and
   // extract bit low out of it. reading array item low would be done by
   // saying arr[low], without a deref * sign
-  Status error;
   ValueObjectSP temp(valobj_sp->GetChildAtIndex(0));
-  if (error.Fail()) {
+  if (!temp) {
 valobj_sp->GetExpressionPath(var_expr_path_strm);
 error.SetErrorStringWithFormat(
 "could not get item 0 for \"(%s) %s\"",
@@ -994,9 +993,9 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
 // deref ptr and extract bits low thru high out of it. reading array
 // items low thru high would be done by saying ptr[low-high], without a
 // deref * sign
-Status error;
-ValueObjectSP temp(valobj_sp->Dereference(error));
-if (error.Fail()) {
+Status deref_error;
+ValueObjectSP temp(valobj_sp->Dereference(deref_error));
+if (!temp || deref_error.Fail()) {
   valobj_sp->GetExpressionPath(var_expr_path_strm);
   error.SetErrorStringWithFormat(
   "could not dereference \"(%s) %s\"",
@@ -1011,9 +1010,8 @@ ValueObjectSP 
StackFrame::GetValueForVariableExpressionPath(
 /

[Lldb-commits] [compiler-rt] [clang-tools-extra] [libcxx] [llvm] [libunwind] [lldb] [openmp] [libcxxabi] [flang] [mlir] [clang] [libc] [lld] [C23] Implement N3018: The constexpr specifier for object d

2023-12-12 Thread Mariya Podchishchaeva via lldb-commits


@@ -0,0 +1,287 @@
+// RUN: %clang_cc1 -std=c2x -verify -triple x86_64 -pedantic -Wno-conversion 
-Wno-constant-conversion -Wno-div-by-zero %s
+
+// Check that constexpr only applies to variables.
+constexpr void f0() {} // expected-error {{'constexpr' can only be used in 
variable declarations}}
+constexpr const int f1() { return 0; } // expected-error {{'constexpr' can 
only be used in variable declarations}}
+
+constexpr struct S1 { int f; }; //expected-error {{struct cannot be marked 
constexpr}}
+constexpr struct S2 ; // expected-error {{struct cannot be marked constexpr}}
+constexpr union U1; // expected-error {{union cannot be marked constexpr}}
+constexpr union U2 {int a; float b;}; // expected-error {{union cannot be 
marked constexpr}}
+constexpr enum E1 {A = 1, B = 2} ; // expected-error {{enum cannot be marked 
constexpr}}
+struct S3 {
+  static constexpr int f = 0; // expected-error {{type name does not allow 
storage class}}
+  // expected-error@-1 {{type name does not allow constexpr}}
+  // expected-error@-2 {{expected ';' at end}}
+  constexpr int f1 = 0;
+  // expected-error@-1 {{type name does not allow constexpr}}
+  // expected-error@-2 {{expected ';' at end}}
+};
+
+constexpr; // expected-error {{'constexpr' can only be used in variable 
declarations}}
+constexpr int V1 = 3;
+constexpr float V2 = 7.0;
+int V3 = (constexpr)3; // expected-error {{expected expression}}
+
+void f2() {
+  constexpr int a = 0;
+  constexpr float b = 1.7f;
+}
+
+// Check how constexpr works with other storage-class specifiers.
+constexpr auto V4 = 1;
+constexpr static auto V5 = 1;
+constexpr static const auto V6 = 1;
+constexpr static const int V7 = 1;
+constexpr static int V8 = 1;

Fznamznon wrote:

Makes sense, thanks, done.

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


[Lldb-commits] [compiler-rt] [clang-tools-extra] [libcxx] [llvm] [libunwind] [lldb] [openmp] [libcxxabi] [flang] [mlir] [clang] [libc] [lld] [C23] Implement N3018: The constexpr specifier for object d

2023-12-12 Thread Mariya Podchishchaeva via lldb-commits

https://github.com/Fznamznon updated 
https://github.com/llvm/llvm-project/pull/73099

>From 1d70b7726e7d1f11622a6d5c8246b0737e024c8d Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Tue, 19 Sep 2023 08:37:18 -0700
Subject: [PATCH 1/9] [C23] Implement N3018: The constexpr specifier for object
 definitions

The implementation mostly reuses C++ code paths where possible,
including narrowing check in order to provide diagnostic messages in
case initializer for constexpr variable is not exactly representable in
target type.

The following won't work due to lack of support for other features:
- Diagnosing of underspecified declarations involving constexpr
- Constexpr attached to compound literals

Also due to lack of support for char8_t some of examples with utf-8
strings don't work properly.
---
 clang/docs/ReleaseNotes.rst   |   1 +
 .../clang/Basic/DiagnosticSemaKinds.td|  16 +
 clang/include/clang/Basic/TokenKinds.def  |   2 +-
 clang/lib/AST/Decl.cpp|  16 +-
 clang/lib/AST/ExprConstant.cpp|  17 +-
 clang/lib/Parse/ParseDecl.cpp |   2 +
 clang/lib/Sema/SemaDecl.cpp   | 204 +++--
 clang/lib/Sema/SemaOverload.cpp   |  36 ++-
 clang/test/C/C2x/n3018.c  |  86 ++
 clang/test/Parser/c23-constexpr.c |   6 +
 clang/test/Sema/constexpr.c   | 275 ++
 clang/www/c_status.html   |   2 +-
 12 files changed, 627 insertions(+), 36 deletions(-)
 create mode 100644 clang/test/C/C2x/n3018.c
 create mode 100644 clang/test/Parser/c23-constexpr.c
 create mode 100644 clang/test/Sema/constexpr.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b65106b9106d4..cae1707f3e30f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -208,6 +208,7 @@ C23 Feature Support
 
 - Clang now supports  which defines several macros for 
performing
   checked integer arithmetic. It is also exposed in pre-C23 modes.
+- Clang now supports ``N3018 The constexpr specifier for object definitions``.
 
 - Completed the implementation of
   `N2508 `_. We
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 990692c06d7d3..11f24583dc55a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2932,6 +2932,22 @@ def warn_private_extern : Warning<
 def note_private_extern : Note<
   "use __attribute__((visibility(\"hidden\"))) attribute instead">;
 
+// C23 constexpr
+def err_c23_thread_local_constexpr : Error<
+  "thread-local storage is not allowed with constexpr">;
+def err_c23_extern_constexpr : Error<
+  "extern specifier is not allowed with constexpr">;
+def err_c23_constexpr_not_variable : Error<
+  "constexpr is only allowed in variable declarations">;
+def err_c23_constexpr_invalid_type : Error<
+  "constexpr variable cannot have type %0">;
+def err_c23_constexpr_init_not_representable : Error<
+  "constexpr initializer evaluates to %0 which is not exactly representable in 
type %1">;
+def err_c23_constexpr_init_type_mismatch : Error<
+  "constexpr initializer for type %0 is of type %1">;
+def err_c23_constexpr_pointer_not_null : Error<
+  "constexpr pointer initializer is not null">;
+
 // C++ Concepts
 def err_concept_decls_may_only_appear_in_global_namespace_scope : Error<
   "concept declarations may only appear in global or namespace scope">;
diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 3ab420821d82b..e9e8f59247662 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -393,7 +393,7 @@ CXX11_KEYWORD(alignas   , KEYC23)
 CXX11_UNARY_EXPR_OR_TYPE_TRAIT(alignof, AlignOf, KEYC23)
 CXX11_KEYWORD(char16_t  , KEYNOMS18)
 CXX11_KEYWORD(char32_t  , KEYNOMS18)
-CXX11_KEYWORD(constexpr , 0)
+CXX11_KEYWORD(constexpr , KEYC23)
 CXX11_KEYWORD(decltype  , 0)
 CXX11_KEYWORD(noexcept  , 0)
 CXX11_KEYWORD(nullptr   , KEYC23)
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index c5c2edf1bfe3a..678a366ed29ad 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2461,7 +2461,7 @@ bool VarDecl::mightBeUsableInConstantExpressions(const 
ASTContext &C) const {
 
   // OpenCL permits const integral variables to be used in constant
   // expressions, like in C++98.
-  if (!Lang.CPlusPlus && !Lang.OpenCL)
+  if (!Lang.CPlusPlus && !Lang.OpenCL && !Lang.C23)
 return false;
 
   // Function parameters are never usable in constant expressions.
@@ -2485,12 +2485,12 @@ bool VarDecl::mightBeUsableInConstantExpressions(const 
ASTContext &C) const {
 
   // In C++, const, non-volatile var

[Lldb-commits] [compiler-rt] [clang-tools-extra] [libcxx] [lldb] [llvm] [openmp] [flang] [mlir] [clang] [libc] [lld] fix issue 73559. (PR #74926)

2023-12-12 Thread Mariya Podchishchaeva via lldb-commits


@@ -641,6 +641,8 @@ Bug Fixes in This Version
   Fixes (`#67317 `_)
 - Clang now properly diagnoses use of stand-alone OpenMP directives after a
   label (including ``case`` or ``default`` labels).
+- Fix crash when using C++ only tokens like *::* in C compiler clang.

Fznamznon wrote:

```suggestion
- Fix crash when using C++ only tokens like ``::`` in C compiler clang.
```

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


[Lldb-commits] [llvm] [openmp] [lld] [mlir] [lldb] [flang] [libc] [compiler-rt] [clang] [libcxx] [clang-tools-extra] fix issue 73559. (PR #74926)

2023-12-12 Thread Mariya Podchishchaeva via lldb-commits

https://github.com/Fznamznon commented:

The PR can be landed after a formal approval. Please see 
https://llvm.org/docs/CodeReview.html#lgtm-how-a-patch-is-accepted .

I gave a couple of NITs otherwise the patch looks ok to me. I'm a bit new here, 
so someone else should approve. I added more folks to reviewers list.

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


[Lldb-commits] [flang] [llvm] [mlir] [openmp] [clang-tools-extra] [clang] [lldb] [libc] [lld] [compiler-rt] [libcxx] fix issue 73559. (PR #74926)

2023-12-12 Thread Mariya Podchishchaeva via lldb-commits

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


[Lldb-commits] [compiler-rt] [clang] [lld] [llvm] [openmp] [clang-tools-extra] [libcxx] [lldb] [libc] [flang] [mlir] fix issue 73559. (PR #74926)

2023-12-12 Thread Mariya Podchishchaeva via lldb-commits


@@ -3,3 +3,4 @@
 // PR9137
 void f0(int x) : {}; // expected-error{{expected function body after function 
declarator}}
 void f1(int x) try {}; // expected-error{{expected function body after 
function declarator}}
+::; // expected-error{{expected identifier or '('}}

Fznamznon wrote:

```suggestion

// GH73559
::; // expected-error{{expected identifier or '('}}
```

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-12 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -246,8 +246,8 @@ class Address {
   /// \see Address::DumpStyle
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
-uint32_t addr_byte_size = UINT32_MAX,
-bool all_ranges = false) const;
+uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
+const char *pattern = nullptr) const;

DavidSpickett wrote:

So in code that would be roughly:
```
struct information {
pattern, prefix, sufix
}

PutCStringHighlighted(., std::optional pattern_info);
```

Which tells the reader clearly that if they want to provide any one of the 3 
they must provide all 3. Otherwise they must provide none of them.

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-12 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -246,8 +246,8 @@ class Address {
   /// \see Address::DumpStyle
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
-uint32_t addr_byte_size = UINT32_MAX,
-bool all_ranges = false) const;
+uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
+const char *pattern = nullptr) const;

DavidSpickett wrote:

>When we use std::move(regex2) to pass it to test_func3, it's essentially 
>moved, and after the move, the regex2 in LookupSymbolInModule becomes garbage.

This is where I get on my Rust powered soapbox and preach about C++ move not 
being what you'd think it is. :)

Good research anyway. Sound like it's what I suspected is that the regex is 
carrying around the match "engine"'s state.

On the struct, yes, the struct itself would be optional. If you do pass an 
instance of it you must provide all 3.

To be honest, once we're packing all this into a struct, that's quite an 
obvious signal to the programmer that this is no ordinary string. So you could 
do just try the struct idea without using the `Regex` type.

And ok, it's not perfect because all 3 struct members have the same type still, 
but if making the pattern a `Regex` is this much trouble it's probably not 
worth it.

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


[Lldb-commits] [libcxx] [flang] [clang] [compiler-rt] [lld] [clang-tools-extra] [llvm] [lldb] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

2023-12-12 Thread Stanislav Mekhanoshin via lldb-commits

rampitec wrote:

Ping

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


[Lldb-commits] [libcxx] [flang] [clang] [compiler-rt] [lld] [clang-tools-extra] [llvm] [lldb] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

2023-12-12 Thread Stanislav Mekhanoshin via lldb-commits

https://github.com/rampitec updated 
https://github.com/llvm/llvm-project/pull/74537

>From 7e382620cdc5999c645ed0746f242595f0294c58 Mon Sep 17 00:00:00 2001
From: Stanislav Mekhanoshin 
Date: Mon, 4 Dec 2023 16:11:53 -0800
Subject: [PATCH 1/7] [AMDGPU] Use alias info to relax waitcounts for LDS DMA

LDA DMA loads increase VMCNT and a load from the LDS stored must
wait on this counter to only read memory after it is written.
Wait count insertion pass does not track memory dependencies, it
tracks register dependencies. To model the LDS dependency a
psuedo register is used in the scoreboard, acting like if LDS DMA
writes it and LDS load reads it.

This patch adds 8 more pseudo registers to use for independent LDS
locations if we can prove they are disjoint using alias analysis.

Fixes: SWDEV-433427
---
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp   |  16 +-
 llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp |  73 +-
 llvm/lib/Target/AMDGPU/SIInstrInfo.cpp  |   4 +-
 llvm/lib/Target/AMDGPU/SIInstrInfo.h|   8 +
 llvm/lib/Target/AMDGPU/lds-dma-waits.ll | 154 
 llvm/test/CodeGen/AMDGPU/llc-pipeline.ll|   2 +
 6 files changed, 241 insertions(+), 16 deletions(-)
 create mode 100644 llvm/lib/Target/AMDGPU/lds-dma-waits.ll

diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp 
b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index a7f4d63229b7ef..2e079404b087fa 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -1128,11 +1128,10 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo 
&Info,
 MachineMemOperand::MOStore |
 MachineMemOperand::MODereferenceable;
 
-  // XXX - Should this be volatile without known ordering?
-  Info.flags |= MachineMemOperand::MOVolatile;
-
   switch (IntrID) {
   default:
+// XXX - Should this be volatile without known ordering?
+Info.flags |= MachineMemOperand::MOVolatile;
 break;
   case Intrinsic::amdgcn_raw_buffer_load_lds:
   case Intrinsic::amdgcn_raw_ptr_buffer_load_lds:
@@ -1140,6 +1139,7 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo 
&Info,
   case Intrinsic::amdgcn_struct_ptr_buffer_load_lds: {
 unsigned Width = 
cast(CI.getArgOperand(2))->getZExtValue();
 Info.memVT = EVT::getIntegerVT(CI.getContext(), Width * 8);
+Info.ptrVal = CI.getArgOperand(1);
 return true;
   }
   }
@@ -1268,8 +1268,8 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo 
&Info,
 Info.opc = ISD::INTRINSIC_VOID;
 unsigned Width = cast(CI.getArgOperand(2))->getZExtValue();
 Info.memVT = EVT::getIntegerVT(CI.getContext(), Width * 8);
-Info.flags |= MachineMemOperand::MOLoad | MachineMemOperand::MOStore |
-  MachineMemOperand::MOVolatile;
+Info.ptrVal = CI.getArgOperand(1);
+Info.flags |= MachineMemOperand::MOLoad | MachineMemOperand::MOStore;
 return true;
   }
   case Intrinsic::amdgcn_ds_bvh_stack_rtn: {
@@ -9084,7 +9084,9 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op,
 MachinePointerInfo LoadPtrI = LoadMMO->getPointerInfo();
 
 MachinePointerInfo StorePtrI = LoadPtrI;
-StorePtrI.V = nullptr;
+LoadPtrI.V = UndefValue::get(
+PointerType::get(*DAG.getContext(), AMDGPUAS::GLOBAL_ADDRESS));
+LoadPtrI.AddrSpace = AMDGPUAS::GLOBAL_ADDRESS;
 StorePtrI.AddrSpace = AMDGPUAS::LOCAL_ADDRESS;
 
 auto F = LoadMMO->getFlags() &
@@ -9162,6 +9164,8 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op,
 MachinePointerInfo LoadPtrI = LoadMMO->getPointerInfo();
 LoadPtrI.Offset = Op->getConstantOperandVal(5);
 MachinePointerInfo StorePtrI = LoadPtrI;
+LoadPtrI.V = UndefValue::get(
+PointerType::get(*DAG.getContext(), AMDGPUAS::GLOBAL_ADDRESS));
 LoadPtrI.AddrSpace = AMDGPUAS::GLOBAL_ADDRESS;
 StorePtrI.AddrSpace = AMDGPUAS::LOCAL_ADDRESS;
 auto F = LoadMMO->getFlags() &
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp 
b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index ede4841b8a5fd7..50ad22130e939e 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -31,6 +31,7 @@
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/PostOrderIterator.h"
 #include "llvm/ADT/Sequence.h"
+#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/CodeGen/MachineLoopInfo.h"
 #include "llvm/CodeGen/MachinePostDominators.h"
 #include "llvm/InitializePasses.h"
@@ -121,8 +122,13 @@ enum RegisterMapping {
   SQ_MAX_PGM_VGPRS = 512, // Maximum programmable VGPRs across all targets.
   AGPR_OFFSET = 256,  // Maximum programmable ArchVGPRs across all targets.
   SQ_MAX_PGM_SGPRS = 256, // Maximum programmable SGPRs across all targets.
-  NUM_EXTRA_VGPRS = 1,// A reserved slot for DS.
-  EXTRA_VGPR_LDS = 0, // An artificial register to track LDS writes.
+  NUM_EXTRA_VGPRS = 9,// Reserved slots f

[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-12 Thread via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -246,8 +246,8 @@ class Address {
   /// \see Address::DumpStyle
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
-uint32_t addr_byte_size = UINT32_MAX,
-bool all_ranges = false) const;
+uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
+const char *pattern = nullptr) const;

taalhaataahir0102 wrote:

Hi @DavidSpickett! Sorry for the delay 🙏

`test_func3(strm, std::move(regex2))` works but it gives the following problem. 
When we use `std::move(regex2)` to pass it to `test_func3`, it's essentially 
moved, and after the move, the `regex2` in `LookupSymbolInModule` becomes 
garbage.

So in functions where pattern is moved multiple times like this:

```
static void DumpAddress(ExecutionContextScope *exe_scope,
const Address &so_addr, bool verbose, bool all_ranges,
Stream &strm, std::optional pattern = 
std::nullopt) {
 ...
 ...
 so_addr.Dump(&strm, exe_scope, Address::DumpStyleResolvedDescription,
   Address::DumpStyleInvalid, UINT32_MAX, false, 
std::move(pattern));
 ...
 ...
 if (verbose) {
strm.EOL();
so_addr.Dump(&strm, exe_scope, Address::DumpStyleDetailedSymbolContext,
 Address::DumpStyleInvalid, UINT32_MAX, all_ranges, 
std::move(pattern));
  }
 ...
}
```
The second `std::move(pattern)`, does not move the original pattern value but 
some garbage value. The only way is to make a copy of the original pattern and 
then use it with `std::move(copy_pattern)` every time (which doesn't look okay 
:-/).

This is the example code and output if I couldn't explain it properly above:
CODE:
```
static void test_func3(Stream &strm, const std::optional pattern = 
std::nullopt) {
  if (pattern.has_value() && pattern.value().match("main")) {
strm.Printf("Pattern matches 'main' inside test_func3\n");
}
}

static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter,
 Stream &strm, Module *module,
 const char *name, bool name_is_regex,
 bool verbose, bool all_ranges) {
  // test_func1(strm, std::make_optional(name));
  std::optional regex2 = std::make_optional(name);
  if (regex2.has_value()) {
strm.Printf("Pattern has a value\n");
if(regex2.value().match("main")) {
  strm.Printf("Pattern matches main\n");
}
else{
  strm.Printf("Pattern doesn't match main\n");
}
  } else {
strm.Printf("Pattern doesn't have a value\n");
  }
  test_func3(strm, std::move(regex2));
  if (regex2.has_value()) {
strm.Printf("Pattern has a value\n");
if(regex2.value().match("main")) {
  strm.Printf("Pattern matches main\n");
}
else{
  strm.Printf("Pattern doesn't match main\n");
}
  } else {
strm.Printf("Pattern doesn't have a value\n");
  }  ...
  ...
}
```
OUTPUT:
```
talha@talha-ROG-Strix-G513QE-G513QE:~/Desktop/LLDB/build/bin$ ./lldb a.out 
(lldb) target create "a.out"
Current executable set to '/home/talha/Desktop/LLDB/build/bin/a.out' (x86_64).
(lldb) image lookup -r -s main
Pattern has a value
Pattern matches main
Pattern matches 'main' inside test_func3
Pattern has a value
Pattern doesn't match main
...
...
```
So after `std::move(pattern)`, `pattern != "main"` within the same function 

Similarly passing `std::make_optional(name)` to func3 also causes 
problem problem:
i.e., `test_func3(strm, std::make_optional(name));`

When we directly pass `std::make_optional(name)`, it creates a 
temporary `std::optional` object that is passed directly to 
`test_func3`. This temporary object can be moved without requiring an explicit 
`std::move` because I guess temporaries are considered rvalues, and 
`std::optional` has appropriate move constructors to handle them.
But storing the result of `std::make_optional(name)` in a variable 
and then passing it without using `std::move`, if the variable is passed as an 
argument to the function, it attempts to perform a copy unless we use 
`std::move`. So, initially we can pass it directly to the next dumping function 
but further passing it will require `std::move` and the same problem comes 
back. 

Also 1 last thing for clarification, as discussed later i.e., 

> I think we may be able to reduce the boilerplate by putting the 
> prefix/suffix/pattern in a struct, and passing that as an optional assuming 
> we can figure out the move issue with regex. But this is for a future change 
> if at all.


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-12 Thread via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


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