[Lldb-commits] [PATCH] D155256: [lldb][x86_64] Add fs_base/gs_base support for Linux

2023-07-20 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

Tests LGTM, thanks.

@clayborg please approve if they look good to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155256

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


[Lldb-commits] [PATCH] D155768: [lldb] [NFC] Remove some dead code from Watchpoint class, and a method that makes no sense

2023-07-20 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.
This revision is now accepted and ready to land.

I don't understand the logic for if the hit counter is < the number of false 
alarms. I'm not even sure that's possible given that a false alarm would have 
to come from a reported hit, wouldn't it?

Maybe there is a behaviour difference when using UndohitCount but I don't think 
it's worth worrying about. LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155768

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


[Lldb-commits] [PATCH] D155198: [lldb] Consider OP_addrx in DWARFExpression::Update_DW_OP_addr

2023-07-20 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve added a comment.

Hi @clayborg, just wanted to make sure this doesn't fall off your radar :)
This fixes all outstanding DWARF 5 issues with Debug Maps, so it would be cool 
if we could get this in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155198

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


[Lldb-commits] [lldb] 8ef0448 - Reland "[CUDA][HIP] Use the same default language std as C++""

2023-07-20 Thread Yaxun Liu via lldb-commits

Author: Yaxun (Sam) Liu
Date: 2023-07-20T12:02:33-04:00
New Revision: 8ef04488d128853715a55683f0181d6398d23c61

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

LOG: Reland "[CUDA][HIP] Use the same default language std as C++""

Reland after fixing regression in lldb.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/LangStandards.def
clang/lib/Basic/LangStandards.cpp
clang/test/CodeGenCUDA/long-double.cu
clang/test/Driver/unknown-std.cpp
clang/test/Preprocessor/lang-std.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2287ff9d70da3f..ef1cc898c21f6d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -886,6 +886,9 @@ RISC-V Support
 
 CUDA/HIP Language Changes
 ^
+- Clang has been updated to align its default language standard for CUDA/HIP 
with
+  that of C++. The standard has now been enhanced to gnu++17, supplanting the
+  previously used c++14.
 
 CUDA Support
 

diff  --git a/clang/include/clang/Basic/LangStandards.def 
b/clang/include/clang/Basic/LangStandards.def
index 911b626e4c9661..5c28bdd28ef257 100644
--- a/clang/include/clang/Basic/LangStandards.def
+++ b/clang/include/clang/Basic/LangStandards.def
@@ -214,14 +214,6 @@ LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++")
 LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++1.0")
 LANGSTANDARD_ALIAS_DEPR(openclcpp2021, "CLC++2021")
 
-// CUDA
-LANGSTANDARD(cuda, "cuda", CUDA, "NVIDIA CUDA(tm)",
- LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | Digraphs)
-
-// HIP
-LANGSTANDARD(hip, "hip", HIP, "HIP",
- LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | Digraphs)
-
 // HLSL
 LANGSTANDARD(hlsl, "hlsl",
  HLSL, "High Level Shader Language",

diff  --git a/clang/lib/Basic/LangStandards.cpp 
b/clang/lib/Basic/LangStandards.cpp
index c6a1a0acc2cb7e..033c0efe8d4f5d 100644
--- a/clang/lib/Basic/LangStandards.cpp
+++ b/clang/lib/Basic/LangStandards.cpp
@@ -54,8 +54,6 @@ LangStandard::Kind 
clang::getDefaultLanguageStandard(clang::Language Lang,
 return LangStandard::lang_opencl12;
   case Language::OpenCLCXX:
 return LangStandard::lang_openclcpp10;
-  case Language::CUDA:
-return LangStandard::lang_cuda;
   case Language::Asm:
   case Language::C:
 // The PS4 uses C99 as the default C standard.
@@ -66,13 +64,13 @@ LangStandard::Kind 
clang::getDefaultLanguageStandard(clang::Language Lang,
 return LangStandard::lang_gnu11;
   case Language::CXX:
   case Language::ObjCXX:
+  case Language::CUDA:
+  case Language::HIP:
 if (T.isPS())
   return LangStandard::lang_gnucxx14;
 return LangStandard::lang_gnucxx17;
   case Language::RenderScript:
 return LangStandard::lang_c99;
-  case Language::HIP:
-return LangStandard::lang_hip;
   case Language::HLSL:
 return LangStandard::lang_hlsl2021;
   }

diff  --git a/clang/test/CodeGenCUDA/long-double.cu 
b/clang/test/CodeGenCUDA/long-double.cu
index 454a93ce5f6b6a..d52de972ea3da4 100644
--- a/clang/test/CodeGenCUDA/long-double.cu
+++ b/clang/test/CodeGenCUDA/long-double.cu
@@ -6,7 +6,7 @@
 // RUN:   -aux-triple x86_64-unknown-gnu-linux -fcuda-is-device \
 // RUN:   -emit-llvm -o - %s 2>&1 | FileCheck %s
 
-// CHECK: @_ZN15infinity_helperIeE5valueE = {{.*}} double 0x47EFD586B834, 
align 8
+// CHECK: @_ZN15infinity_helperIeE5valueE = {{.*}} double 
0x47EFD586B834,{{.*}} align 8
 // CHECK: @size = {{.*}} i32 8
 
 #include "Inputs/cuda.h"

diff  --git a/clang/test/Driver/unknown-std.cpp 
b/clang/test/Driver/unknown-std.cpp
index e918c087095ef0..5c58042a0a2c71 100644
--- a/clang/test/Driver/unknown-std.cpp
+++ b/clang/test/Driver/unknown-std.cpp
@@ -4,7 +4,10 @@
 
 // RUN: not %clang %s -std=foobar -c 2>&1 | FileCheck --match-full-lines %s
 // RUN: not %clang -x objective-c++ %s -std=foobar -c 2>&1 | FileCheck 
--match-full-lines %s
-// RUN: not %clang -x cuda -nocudainc -nocudalib 
--cuda-path=%S/Inputs/CUDA/usr/local/cuda %s -std=foobar -c 2>&1 | FileCheck 
--match-full-lines --check-prefix=CHECK --check-prefix=CUDA %s
+// RUN: not %clang -x cuda -nocudainc -nocudalib 
--cuda-path=%S/Inputs/CUDA/usr/local/cuda \
+// RUN:   %s -std=foobar -c 2>&1 | FileCheck --match-full-lines %s
+// RUN: not %clang -x hip -nocudainc -nocudalib %s -std=foobar -c 2>&1 \
+// RUN:   | FileCheck --match-full-lines %s
 
 // CHECK: error: invalid value 'foobar' in '-std=foobar'
 // CHECK-NEXT: note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' 
standard
@@ -21,7 +24,6 @@
 // CHECK-NEXT: note: use 'gnu++23' for 'ISO C++ 2023 DIS with GNU extensions' 
stan

[Lldb-commits] [lldb] bbffda6 - [lldb] Skip unsupported CTF types

2023-07-20 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-07-20T10:21:33-07:00
New Revision: bbffda645a1cdb5d3426b1d7eca31b0f9a312959

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

LOG: [lldb] Skip unsupported CTF types

This ensures we we don't crash when parsing a type that references an
unsupported type.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index 783584f5fec71d..88926baa7a6e7f 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -377,6 +377,11 @@ llvm::Expected
 SymbolFileCTF::ParseModifierType(lldb::offset_t &offset, lldb::user_id_t uid,
  uint32_t kind, uint32_t type) {
   TypeSP ref_type = GetTypeForUID(type);
+  if (!ref_type)
+return llvm::make_error(
+llvm::formatv("Could not find modified type: {0}", type),
+llvm::inconvertibleErrorCode());
+
   CompilerType compiler_type;
 
   switch (kind) {
@@ -410,6 +415,11 @@ llvm::Expected 
SymbolFileCTF::ParseTypedef(lldb::offset_t &offset,
  llvm::StringRef name,
  uint32_t type) {
   TypeSP underlying_type = GetTypeForUID(type);
+  if (!underlying_type)
+return llvm::make_error(
+llvm::formatv("Could not find typedef underlying type: {0}", type),
+llvm::inconvertibleErrorCode());
+
   CompilerType target_ast_type = underlying_type->GetFullCompilerType();
   clang::DeclContext *decl_ctx = m_ast->GetTranslationUnitDecl();
   CompilerType ast_typedef = target_ast_type.CreateTypedef(
@@ -430,6 +440,12 @@ llvm::Expected 
SymbolFileCTF::ParseArray(lldb::offset_t &offset,
   ctf_array.nelems = m_data.GetU32(&offset);
 
   TypeSP element_type = GetTypeForUID(ctf_array.contents);
+  if (!element_type)
+return llvm::make_error(
+llvm::formatv("Could not find array element type: {0}",
+  ctf_array.contents),
+llvm::inconvertibleErrorCode());
+
   std::optional element_size = element_type->GetByteSize(nullptr);
   if (!element_size)
 return llvm::make_error(
@@ -495,8 +511,8 @@ SymbolFileCTF::ParseFunction(lldb::offset_t &offset, 
lldb::user_id_t uid,
   break;
 }
 
-TypeSP arg_type = GetTypeForUID(arg_uid);
-arg_types.push_back(arg_type->GetFullCompilerType());
+if (TypeSP arg_type = GetTypeForUID(arg_uid))
+  arg_types.push_back(arg_type->GetFullCompilerType());
   }
 
   // If the number of arguments is odd, a single uint32_t of padding is 
inserted
@@ -505,6 +521,11 @@ SymbolFileCTF::ParseFunction(lldb::offset_t &offset, 
lldb::user_id_t uid,
 m_data.GetU32(&offset);
 
   TypeSP ret_type = GetTypeForUID(type);
+  if (!ret_type)
+return llvm::make_error(
+llvm::formatv("Could not find function return type: {0}", type),
+llvm::inconvertibleErrorCode());
+
   CompilerType func_type = m_ast->CreateFunctionType(
   ret_type->GetFullCompilerType(), arg_types.data(), arg_types.size(),
   is_variadic, 0, clang::CallingConv::CC_C);
@@ -537,11 +558,13 @@ SymbolFileCTF::ParseRecord(lldb::offset_t &offset, 
lldb::user_id_t uid,
 llvm::StringRef member_name = ReadString(ctf_member.name);
 const uint32_t member_type_uid = ctf_member.type;
 
-TypeSP member_type = GetTypeForUID(member_type_uid);
-const uint32_t member_size = member_type->GetByteSize(nullptr).value_or(0);
-TypeSystemClang::AddFieldToRecordType(union_type, member_name,
-  member_type->GetFullCompilerType(),
-  eAccessPublic, member_size);
+if (TypeSP member_type = GetTypeForUID(member_type_uid)) {
+  const uint32_t member_size =
+  member_type->GetByteSize(nullptr).value_or(0);
+  TypeSystemClang::AddFieldToRecordType(union_type, member_name,
+member_type->GetFullCompilerType(),
+eAccessPublic, member_size);
+}
   }
   m_ast->CompleteTagDeclarationDefinition(union_type);
 
@@ -620,7 +643,8 @@ size_t SymbolFileCTF::ParseTypes(CompileUnit &cu) {
 type_offset, type_uid, name, kind, variable_length, type, size);
 if (!type_or_error) {
   LLDB_LOG_ERROR(log, type_or_error.takeError(),
- "Failed to parse type at offset {1}: {0}", type_offset);
+ "Failed to parse type {1} at offset {2}: {0}", type_uid,
+ type_offset);
 } else {
   type_sp = *type_or_error;
   if (log) {
@@ -634,7 +658,15 @@

[Lldb-commits] [PATCH] D149213: [lldb] Add basic support for Rust enums in TypeSystemClang

2023-07-20 Thread Tom Tromey via Phabricator via lldb-commits
tom.tromey added a comment.

> Apart from just implementing type system itself (which is much bigger scope 
> than this change) there are other non-trivial issues:
>
> 1. There is no "compiler-as-a-service" in Rust so getting expressions to work 
> is non-trivial. An interpreter of some sort needs to be built with subset of 
> Rust support

My work also included a parser for some Rust expressions.


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

https://reviews.llvm.org/D149213

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


[Lldb-commits] [PATCH] D155256: [lldb][x86_64] Add fs_base/gs_base support for Linux

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155256

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


[Lldb-commits] [PATCH] D155768: [lldb] [NFC] Remove some dead code from Watchpoint class, and a method that makes no sense

2023-07-20 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

Thanks David, yeah I came to the same conclusion about that method.  I made 
hacked up lldb that behaved like the MIPS case to confirm that the hit count is 
incremented before we decide it's a fake stop & decrement it again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155768

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


[Lldb-commits] [lldb] 259e3f2 - Remove IncrementFalseAlarmsAndReviseHitCount, unused ivars

2023-07-20 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2023-07-20T15:16:02-07:00
New Revision: 259e3f2a4fef5ff2cdc0086f432bbfd2493653f5

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

LOG: Remove IncrementFalseAlarmsAndReviseHitCount, unused ivars

Reading through the Watchpoint class, I found this method
that wasn't being used properly, and a couple of ivars that
weren't used at all.  Cleanup.

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

Added: 


Modified: 
lldb/include/lldb/Breakpoint/Watchpoint.h
lldb/source/Breakpoint/Watchpoint.cpp
lldb/source/Target/StopInfo.cpp

Removed: 




diff  --git a/lldb/include/lldb/Breakpoint/Watchpoint.h 
b/lldb/include/lldb/Breakpoint/Watchpoint.h
index 3ee75516debe8d..8fde3b563a3f06 100644
--- a/lldb/include/lldb/Breakpoint/Watchpoint.h
+++ b/lldb/include/lldb/Breakpoint/Watchpoint.h
@@ -63,8 +63,6 @@ class Watchpoint : public 
std::enable_shared_from_this,
 
   ~Watchpoint() override;
 
-  void IncrementFalseAlarmsAndReviseHitCount();
-
   bool IsEnabled() const;
 
   // This doesn't really enable/disable the watchpoint.   It is currently just
@@ -214,12 +212,8 @@ class Watchpoint : public 
std::enable_shared_from_this,
   // again, we check the count, if it is more than 1, it means the user-
   // supplied actions actually want the watchpoint to be disabled!
   uint32_t m_watch_read : 1, // 1 if we stop when the watched data is read from
-  m_watch_write : 1, // 1 if we stop when the watched data is written 
to
-  m_watch_was_read : 1, // Set to 1 when watchpoint is hit for a read 
access
-  m_watch_was_written : 1;  // Set to 1 when watchpoint is hit for a write
-// access
+  m_watch_write : 1; // 1 if we stop when the watched data is written 
to
   uint32_t m_ignore_count;  // Number of times to ignore this watchpoint
-  uint32_t m_false_alarms;  // Number of false alarms.
   std::string m_decl_str;   // Declaration information, if any.
   std::string m_watch_spec_str; // Spec for the watchpoint.
   lldb::ValueObjectSP m_old_value_sp;

diff  --git a/lldb/source/Breakpoint/Watchpoint.cpp 
b/lldb/source/Breakpoint/Watchpoint.cpp
index b6e6d4a5a32d5e..a20a4ad98c5a84 100644
--- a/lldb/source/Breakpoint/Watchpoint.cpp
+++ b/lldb/source/Breakpoint/Watchpoint.cpp
@@ -29,8 +29,7 @@ Watchpoint::Watchpoint(Target &target, lldb::addr_t addr, 
uint32_t size,
 : StoppointSite(0, addr, size, hardware), m_target(target),
   m_enabled(false), m_is_hardware(hardware), m_is_watch_variable(false),
   m_is_ephemeral(false), m_disabled_count(0), m_watch_read(0),
-  m_watch_write(0), m_watch_was_read(0), m_watch_was_written(0),
-  m_ignore_count(0), m_false_alarms(0), m_being_created(true) {
+  m_watch_write(0), m_ignore_count(0), m_being_created(true) {
 
   if (type && type->IsValid())
 m_type = *type;
@@ -212,19 +211,6 @@ bool Watchpoint::CaptureWatchedValue(const 
ExecutionContext &exe_ctx) {
   return (m_new_value_sp && m_new_value_sp->GetError().Success());
 }
 
-void Watchpoint::IncrementFalseAlarmsAndReviseHitCount() {
-  ++m_false_alarms;
-  if (m_false_alarms) {
-if (m_hit_counter.GetValue() >= m_false_alarms) {
-  m_hit_counter.Decrement(m_false_alarms);
-  m_false_alarms = 0;
-} else {
-  m_false_alarms -= m_hit_counter.GetValue();
-  m_hit_counter.Reset();
-}
-  }
-}
-
 // RETURNS - true if we should stop at this breakpoint, false if we
 // should continue.
 

diff  --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp
index 8bcb16c391e031..efc8fd269ac29f 100644
--- a/lldb/source/Target/StopInfo.cpp
+++ b/lldb/source/Target/StopInfo.cpp
@@ -894,7 +894,7 @@ class StopInfoWatchpoint : public StopInfo {
 
 if (m_silently_skip_wp) {
   m_should_stop = false;
-  wp_sp->IncrementFalseAlarmsAndReviseHitCount();
+  wp_sp->UndoHitCount();
 }
 
 if (wp_sp->GetHitCount() <= wp_sp->GetIgnoreCount()) {



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


[Lldb-commits] [PATCH] D155768: [lldb] [NFC] Remove some dead code from Watchpoint class, and a method that makes no sense

2023-07-20 Thread Jason Molenda via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG259e3f2a4fef: Remove IncrementFalseAlarmsAndReviseHitCount, 
unused ivars (authored by jasonmolenda).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155768

Files:
  lldb/include/lldb/Breakpoint/Watchpoint.h
  lldb/source/Breakpoint/Watchpoint.cpp
  lldb/source/Target/StopInfo.cpp


Index: lldb/source/Target/StopInfo.cpp
===
--- lldb/source/Target/StopInfo.cpp
+++ lldb/source/Target/StopInfo.cpp
@@ -894,7 +894,7 @@
 
 if (m_silently_skip_wp) {
   m_should_stop = false;
-  wp_sp->IncrementFalseAlarmsAndReviseHitCount();
+  wp_sp->UndoHitCount();
 }
 
 if (wp_sp->GetHitCount() <= wp_sp->GetIgnoreCount()) {
Index: lldb/source/Breakpoint/Watchpoint.cpp
===
--- lldb/source/Breakpoint/Watchpoint.cpp
+++ lldb/source/Breakpoint/Watchpoint.cpp
@@ -29,8 +29,7 @@
 : StoppointSite(0, addr, size, hardware), m_target(target),
   m_enabled(false), m_is_hardware(hardware), m_is_watch_variable(false),
   m_is_ephemeral(false), m_disabled_count(0), m_watch_read(0),
-  m_watch_write(0), m_watch_was_read(0), m_watch_was_written(0),
-  m_ignore_count(0), m_false_alarms(0), m_being_created(true) {
+  m_watch_write(0), m_ignore_count(0), m_being_created(true) {
 
   if (type && type->IsValid())
 m_type = *type;
@@ -212,19 +211,6 @@
   return (m_new_value_sp && m_new_value_sp->GetError().Success());
 }
 
-void Watchpoint::IncrementFalseAlarmsAndReviseHitCount() {
-  ++m_false_alarms;
-  if (m_false_alarms) {
-if (m_hit_counter.GetValue() >= m_false_alarms) {
-  m_hit_counter.Decrement(m_false_alarms);
-  m_false_alarms = 0;
-} else {
-  m_false_alarms -= m_hit_counter.GetValue();
-  m_hit_counter.Reset();
-}
-  }
-}
-
 // RETURNS - true if we should stop at this breakpoint, false if we
 // should continue.
 
Index: lldb/include/lldb/Breakpoint/Watchpoint.h
===
--- lldb/include/lldb/Breakpoint/Watchpoint.h
+++ lldb/include/lldb/Breakpoint/Watchpoint.h
@@ -63,8 +63,6 @@
 
   ~Watchpoint() override;
 
-  void IncrementFalseAlarmsAndReviseHitCount();
-
   bool IsEnabled() const;
 
   // This doesn't really enable/disable the watchpoint.   It is currently just
@@ -214,12 +212,8 @@
   // again, we check the count, if it is more than 1, it means the user-
   // supplied actions actually want the watchpoint to be disabled!
   uint32_t m_watch_read : 1, // 1 if we stop when the watched data is read from
-  m_watch_write : 1, // 1 if we stop when the watched data is written 
to
-  m_watch_was_read : 1, // Set to 1 when watchpoint is hit for a read 
access
-  m_watch_was_written : 1;  // Set to 1 when watchpoint is hit for a write
-// access
+  m_watch_write : 1; // 1 if we stop when the watched data is written 
to
   uint32_t m_ignore_count;  // Number of times to ignore this watchpoint
-  uint32_t m_false_alarms;  // Number of false alarms.
   std::string m_decl_str;   // Declaration information, if any.
   std::string m_watch_spec_str; // Spec for the watchpoint.
   lldb::ValueObjectSP m_old_value_sp;


Index: lldb/source/Target/StopInfo.cpp
===
--- lldb/source/Target/StopInfo.cpp
+++ lldb/source/Target/StopInfo.cpp
@@ -894,7 +894,7 @@
 
 if (m_silently_skip_wp) {
   m_should_stop = false;
-  wp_sp->IncrementFalseAlarmsAndReviseHitCount();
+  wp_sp->UndoHitCount();
 }
 
 if (wp_sp->GetHitCount() <= wp_sp->GetIgnoreCount()) {
Index: lldb/source/Breakpoint/Watchpoint.cpp
===
--- lldb/source/Breakpoint/Watchpoint.cpp
+++ lldb/source/Breakpoint/Watchpoint.cpp
@@ -29,8 +29,7 @@
 : StoppointSite(0, addr, size, hardware), m_target(target),
   m_enabled(false), m_is_hardware(hardware), m_is_watch_variable(false),
   m_is_ephemeral(false), m_disabled_count(0), m_watch_read(0),
-  m_watch_write(0), m_watch_was_read(0), m_watch_was_written(0),
-  m_ignore_count(0), m_false_alarms(0), m_being_created(true) {
+  m_watch_write(0), m_ignore_count(0), m_being_created(true) {
 
   if (type && type->IsValid())
 m_type = *type;
@@ -212,19 +211,6 @@
   return (m_new_value_sp && m_new_value_sp->GetError().Success());
 }
 
-void Watchpoint::IncrementFalseAlarmsAndReviseHitCount() {
-  ++m_false_alarms;
-  if (m_false_alarms) {
-if (m_hit_counter.GetValue() >= m_false_alarms) {
-  m_hit_counter.Decrement(m_false_alarms);
-  m_false_alarms = 0;
-} else {
-  

[Lldb-commits] [PATCH] D155198: [lldb] Consider OP_addrx in DWARFExpression::Update_DW_OP_addr

2023-07-20 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

As far as I'm concerned, this doesn't look too controversial to me and it is 
unblocking one of the bots. I think it would be okay to tentatively land this, 
but be on the lookout and promptly react to any post-commit feedback from 
@clayborg.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155198

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


[Lldb-commits] [lldb] 49b3c33 - [lldb][x86_64] Support fs_base/gs_base register in Linux

2023-07-20 Thread Jeffrey Tan via lldb-commits

Author: Jeffrey Tan
Date: 2023-07-20T16:32:47-07:00
New Revision: 49b3c3355f9c36a023e04bba509ac89d15da6ff9

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

LOG: [lldb][x86_64] Support fs_base/gs_base register in Linux

Summary:
[lldb][x86_64] This patch adds fs_base/gs_base support for Linux x86_64.

Originally, I plan to split the diff into two parts, one to refactoring 
lldb_xxx_x86_64 => x86_64::lldb_xxx across code base and the other one for 
adding fs_base/gs_base, but it turns out to be a non-trivial effort to split 
and very error prone so I decided to keep a single diff to get feedback.

GDB supports fs_base/gs_base registers while LLDB does not. Since both linux 
coredump note section and ptrace
supports them it is a missing feature.

For context, this is a required feature to support getting pthread pointer on 
linux from both live and dump debugging.
See thread below for details:
https://discourse.llvm.org/t/how-to-get-pthread-pointer-from-lldb/70542/2?u=jeffreytan81

Implementation wise, we have initially tried `#ifdef` approach to reuse the 
code but it is introducing very tricky bugs and proves
hard to maintain. Instead the diff completely separates the registers between 
x86_64 and x86_64_with_base so that non-linux related
implementations can use x86_64 registers while linux uses x86_64_with_base.
Here are the list of changes done in the patch:
* Registers in lldb-x86-register-enums.h are separated into two: x86_64 and 
x86_64_with_base
* fs_base/gs_base are added into x86_64_with_base
* All linux files are change to use x86_64::lldb_xxx => 
x86_64_with_base::lldb_xxx
* Support linux elf-core:
* A new RegisterContextLinuxCore_x86_64 class is added for ThreadElfCore
* RegisterContextLinuxCore_x86_64 overrides and uses its own register 
set supports fs_base/gs_base
* RegisterInfos_x86_64_with_base/RegisterInfos_x86_64_with_base_shared 
ared added to provide g_contained_XXX/g_invalidate_XXX and RegInfo related code 
sharing.
* `RegisterContextPOSIX_x86 ::m_gpr_x86_64` seems to be unused so I removed it.
* `NativeRegisterContextDBReg_x86::GetDR()` is overridden in 
`NativeRegisterContextLinux_x86_64` to make watchpoint work.

Reviewers:clayborg,labath,jingham,jdoerfert,JDevlieghere,kusmour,GeorgeHuyubo

Subscribers:

Tasks:

Tags:

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

Added: 
lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base.h

lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.cpp
lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.h
lldb/source/Plugins/Process/elf-core/RegisterContextLinuxCore_x86_64.cpp
lldb/source/Plugins/Process/elf-core/RegisterContextLinuxCore_x86_64.h

Modified: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
lldb/source/Plugins/Process/Utility/CMakeLists.txt
lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h
lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
lldb/source/Plugins/Process/Utility/RegisterContext_x86.h
lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h
lldb/source/Plugins/Process/elf-core/CMakeLists.txt
lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
lldb/test/API/commands/register/register/register_command/TestRegisters.py

lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
index e81ef3301f1f13..f0e295b5900867 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
@@ -100,96 +100,97 @@ static_assert((sizeof(g_mpx_regnums_i386) / 
sizeof(g_mpx_regnums_i386[0])) -
 
 // x86 64-bit general purpose registers.
 static const uint32_t g_gpr_regnums_x86_64[] = {
-lldb_rax_x86_64,lldb_rbx_x86_64,lldb_rcx_x86_64, lldb_rdx_x86_64,
-lldb_rdi_x86_64,lldb_rsi_x86_64,lldb_rbp_x86_64, lldb_rsp_x86_64,
-lldb_r8_x86_64, lldb_r9_x86_64, lldb_r10_x86_64, lldb_r11_x86_64,
-lldb_r12_x86_64,lldb_r13_x86_64,lldb_r14_x86_64, lldb_r15_x86_64,
-lldb_rip_x86_64,lldb_rflags_x86_64, lldb_cs_x86_64,  lldb_fs_x86_64,
-lldb_gs_x86_64, lldb_ss_x86_64, lldb_ds_x86_64,  lldb_es_x86_64,
-lldb_eax_x86_64,lldb_ebx_x86_64,lldb_ecx_x86

[Lldb-commits] [PATCH] D155256: [lldb][x86_64] Add fs_base/gs_base support for Linux

2023-07-20 Thread jeffrey tan via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG49b3c3355f9c: [lldb][x86_64] Support fs_base/gs_base 
register in Linux (authored by yinghuitan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155256

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
  lldb/source/Plugins/Process/Utility/CMakeLists.txt
  lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h
  lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
  lldb/source/Plugins/Process/Utility/RegisterContext_x86.h
  lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base.h
  lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.h
  lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h
  lldb/source/Plugins/Process/elf-core/CMakeLists.txt
  lldb/source/Plugins/Process/elf-core/RegisterContextLinuxCore_x86_64.cpp
  lldb/source/Plugins/Process/elf-core/RegisterContextLinuxCore_x86_64.h
  lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
  lldb/test/API/commands/register/register/register_command/TestRegisters.py
  
lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py

Index: lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
===
--- lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
+++ lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
@@ -31,6 +31,41 @@
 """Test that lldb can read the process information from an x86_64 linux core file."""
 self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_tid)
 
+@skipIf(oslist=["windows"])
+@skipIf(triple="^mips")
+def test_fs_gs_base(self):
+"""Tests fs_base/gs_base registers can be read from linux coredump."""
+target = self.dbg.CreateTarget(None)
+process = target.LoadCore("linux-x86_64.core")
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# The fs_base/gs_base registers in linux-x86_64.core are parsed by
+# using "eu-readelf -n linux-x86_64.core" to verify.
+fs_base_values = [0x7fc295017700, 0x7fc294fff740, 0x7fc29501f700]
+gs_base_values = [0, 0, 0]
+
+for i in range(process.GetNumThreads()):
+thread = process.GetThreadAtIndex(i)
+self.assertTrue(thread.IsValid(), "current thread is valid")
+
+current_frame = thread.GetFrameAtIndex(0)
+self.assertTrue(current_frame.IsValid(), "current frame is valid")
+
+reg_fs_base = current_frame.FindRegister("fs_base")
+reg_gs_base = current_frame.FindRegister("gs_base")
+self.assertTrue(reg_fs_base.IsValid(), "fs_base is not available")
+self.assertTrue(reg_gs_base.IsValid(), "gs_base is not available")
+
+self.assertEqual(
+reg_fs_base.GetValueAsSigned(-1), fs_base_values[i], f"fs_base read is different from expected"
+)
+
+self.assertEqual(
+reg_gs_base.GetValueAsSigned(-1), gs_base_values[i], f"gs_base read is different from expected"
+)
+self.dbg.DeleteTarget(target)
+
+
 def do_test(self, filename, pid, tid):
 target = self.dbg.CreateTarget("")
 process = target.LoadCore(filename + ".core")
Index: lldb/test/API/commands/register/register/register_command/TestRegisters.py
===
--- lldb/test/API/commands/register/register/register_command/TestRegisters.py
+++ lldb/test/API/commands/register/register/register_command/TestRegisters.py
@@ -606,3 +606,47 @@
 
 # This has an alternative name according to the ABI.
 self.expect("register info x30", substrs=["Name: lr (x30)"])
+
+@skipUnlessPlatform(["linux"])
+@skipIf(archs=no_match(["x86_64"]))
+def test_fs_gs_base(self):
+"""
+Tests fs_base register can be read and equals to pthread_self() return value
+and gs_base register equals zero.
+"""
+self.build()
+target = self.createTestTarget()
+# Launch the process and stop.
+self.expect("run", PROCESS_STOPPED, substrs=["stopped"])
+
+process = target.GetProcess()
+
+thread = process.GetThreadAtIndex(0)
+self.assertTrue(thread.IsValid(), "current thread is valid")
+
+current_frame = thread.GetFrameAtIndex(0)
+  

[Lldb-commits] [PATCH] D155905: lldb RFC: Exposing set/get address masks, Fix*Address methods in SBProcess

2023-07-20 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda created this revision.
jasonmolenda added reviewers: DavidSpickett, jingham, clayborg.
jasonmolenda added a project: LLDB.
Herald added subscribers: JDevlieghere, kristof.beyls.
Herald added a project: All.
jasonmolenda requested review of this revision.
Herald added a subscriber: lldb-commits.

We've had a few people doing SB API scripting who have asked for access to the 
Process settings of address masks, and API to fix address+metadata down to just 
addressable memory.

We're mostly focused on AArch64 these days at Apple so the number of addressing 
bits is what everyone is really asking for, but given that Linux's native 
representation is an address mask which can express things number-of-bits 
cannot, the SB API needs to represent that way, I think.

I'm also including the "Highmem" variants here, which makes for a not great 
looking SB API additions, but I know someone is going to need it.  I'm open to 
suggestions or rejections of including this.  There is an environment I need to 
support where they have items in both high and low memory (in the same 
execution level) with different page table settings for both so they have 
different numbers of addressing bits for low and high memory.  This is quite 
uncommon I think -- if you have code running in high and low memory 
simultaneously, it's usually a kernel in high memory at EL1 and userland in low 
memory at EL0 and on Darwin they run with the same page table setups.

For the internal Process API, I didn't mind having these separate Highmem 
accessors which only differed from the base ones when we're in this situation 
of low & high memory on AArch64 having different page table setups.  The only 
user of this is the Apple AArch64 ABI plugin when fixing addresses, so it 
wasn't something most people needed to consider.  But putting it in SBProcess, 
it locks the API down more.

Adding Fix*Address is obvious.

No tests written yet, I didn't want to get ahead of myself.  Given that I can 
get / set the address masks with these API, it will be easy enough to mutate 
it, run some uint64_t's through the Fix*Address API and confirm they're 
modified.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155905

Files:
  lldb/include/lldb/API/SBProcess.h
  lldb/source/API/SBProcess.cpp

Index: lldb/source/API/SBProcess.cpp
===
--- lldb/source/API/SBProcess.cpp
+++ lldb/source/API/SBProcess.cpp
@@ -1243,6 +1243,83 @@
   return sb_proc_info;
 }
 
+addr_t SBProcess::GetCodeAddressMask() {
+  LLDB_INSTRUMENT_VA(this);
+  addr_t default_mask = 0;
+  if (ProcessSP process_sp = GetSP())
+return process_sp->GetCodeAddressMask();
+  return default_mask;
+}
+
+addr_t SBProcess::GetDataAddressMask() {
+  LLDB_INSTRUMENT_VA(this);
+  addr_t default_mask = 0;
+  if (ProcessSP process_sp = GetSP())
+return process_sp->GetDataAddressMask();
+  return default_mask;
+}
+
+addr_t SBProcess::GetHighmemCodeAddressMask() {
+  LLDB_INSTRUMENT_VA(this);
+  addr_t default_mask = 0;
+  if (ProcessSP process_sp = GetSP())
+return process_sp->GetHighmemCodeAddressMask();
+  return default_mask;
+}
+
+addr_t SBProcess::GetHighmemDataAddressMask() {
+  LLDB_INSTRUMENT_VA(this);
+  addr_t default_mask = 0;
+  if (ProcessSP process_sp = GetSP())
+return process_sp->GetHighmemDataAddressMask();
+  return default_mask;
+}
+
+void SBProcess::SetCodeAddressMask(addr_t mask) {
+  LLDB_INSTRUMENT_VA(this, mask);
+  if (ProcessSP process_sp = GetSP())
+process_sp->SetCodeAddressMask(mask);
+}
+
+void SBProcess::SetDataAddressMask(addr_t mask) {
+  LLDB_INSTRUMENT_VA(this, mask);
+  if (ProcessSP process_sp = GetSP())
+process_sp->SetDataAddressMask(mask);
+}
+
+void SBProcess::SetHighmemCodeAddressMask(addr_t mask) {
+  LLDB_INSTRUMENT_VA(this, mask);
+  if (ProcessSP process_sp = GetSP())
+process_sp->SetHighmemCodeAddressMask(mask);
+}
+
+void SBProcess::SetHighmemDataAddressMask(addr_t mask) {
+  LLDB_INSTRUMENT_VA(this, mask);
+  if (ProcessSP process_sp = GetSP())
+process_sp->SetHighmemDataAddressMask(mask);
+}
+
+addr_t SBProcess::FixCodeAddress(addr_t addr) {
+  LLDB_INSTRUMENT_VA(this, addr);
+  if (ProcessSP process_sp = GetSP())
+return process_sp->FixCodeAddress(addr);
+  return addr;
+}
+
+addr_t SBProcess::FixDataAddress(addr_t addr) {
+  LLDB_INSTRUMENT_VA(this, addr);
+  if (ProcessSP process_sp = GetSP())
+return process_sp->FixDataAddress(addr);
+  return addr;
+}
+
+addr_t SBProcess::FixAnyAddress(addr_t addr) {
+  LLDB_INSTRUMENT_VA(this, addr);
+  if (ProcessSP process_sp = GetSP())
+return process_sp->FixAnyAddress(addr);
+  return addr;
+}
+
 lldb::addr_t SBProcess::AllocateMemory(size_t size, uint32_t permissions,
lldb::SBError &sb_error) {
   LLDB_INSTRUMENT_VA(this, size, permissions, sb_error);
Index: lldb/include/lldb/API/SBProcess.h

[Lldb-commits] [PATCH] D151683: [clang] Enable C++11-style attributes in all language modes

2023-07-20 Thread Nikolas Klauser via Phabricator via lldb-commits
philnik updated this revision to Diff 542743.
philnik added a comment.

- Address comments
- Try to fix CI
- Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151683

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/Features.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Parse/Parser.h
  clang/lib/Basic/Attributes.cpp
  clang/lib/Lex/Lexer.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/AST/ast-dump-attr.m
  clang/test/AST/ast-dump-c-attr.c
  clang/test/AST/attr-annotate-type.c
  clang/test/CodeGen/attr-btf_type_tag-func.c
  clang/test/CodeGen/attr-btf_type_tag-var.c
  clang/test/Frontend/noderef.c
  clang/test/OpenMP/assumes_messages_attr.c
  clang/test/OpenMP/openmp_attribute_compat.cpp
  clang/test/Parser/asm.c
  clang/test/Parser/c2x-attributes.c
  clang/test/Parser/c2x-attributes.m
  clang/test/Parser/cxx-decl.cpp
  clang/test/Parser/objc-attr.m
  clang/test/ParserHLSL/group_shared.hlsl
  clang/test/Preprocessor/has_c_attribute.c
  clang/test/Sema/annotate-type.c
  clang/test/Sema/annotate.c
  clang/test/Sema/attr-availability-square-brackets.c
  clang/test/Sema/attr-external-source-symbol-cxx.cpp
  clang/test/Sema/attr-external-source-symbol.c
  clang/test/Sema/attr-likelihood.c
  clang/test/Sema/attr-objc-bridge-related.m
  clang/test/Sema/attr-regparm.c
  clang/test/Sema/attr-type-safety.c
  clang/test/Sema/c2x-attr.c
  clang/test/Sema/c2x-noreturn.c
  clang/test/Sema/internal_linkage.c
  clang/test/Sema/matrix-type-builtins.c
  clang/test/Sema/neon-vector-types.c
  clang/test/Sema/overload-arm-mve.c
  clang/test/Sema/overloadable.c
  clang/test/Sema/vector-gcc-compat.c
  clang/test/SemaCXX/attr-cxx-disabled.cpp
  clang/test/SemaCXX/cxx98-compat.cpp
  clang/test/SemaCXX/warn-c++11-extensions.cpp
  clang/test/SemaObjC/attr-objc-gc.m
  clang/unittests/AST/AttrTest.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -575,7 +575,6 @@
 // FIXME: We should ask the driver for the appropriate default flags.
 lang_opts.GNUMode = true;
 lang_opts.GNUKeywords = true;
-lang_opts.DoubleSquareBracketAttributes = true;
 lang_opts.CPlusPlus11 = true;
 
 // The Darwin libc expects this macro to be set.
Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3394,14 +3394,10 @@
   // If this is the C++11 variety, also add in the LangOpts test.
   if (Variety == "CXX11")
 Test += " && LangOpts.CPlusPlus11";
-  else if (Variety == "C2x")
-Test += " && LangOpts.DoubleSquareBracketAttributes";
 } else if (Variety == "CXX11")
   // C++11 mode should be checked against LangOpts, which is presumed to be
   // present in the caller.
   Test = "LangOpts.CPlusPlus11";
-else if (Variety == "C2x")
-  Test = "LangOpts.DoubleSquareBracketAttributes";
 
 std::string TestStr = !Test.empty()
   ? Test + " ? " + llvm::itostr(Version) + " : 0"
Index: clang/unittests/AST/AttrTest.cpp
===
--- clang/unittests/AST/AttrTest.cpp
+++ clang/unittests/AST/AttrTest.cpp
@@ -157,7 +157,7 @@
   AST = buildASTFromCodeWithArgs(R"c(
 __auto_type [[clang::annotate_type("auto")]] auto_var = 1;
   )c",
- {"-fdouble-square-bracket-attributes"},
+ {},
  "input.c");
 
   {
Index: clang/test/SemaObjC/attr-objc-gc.m
===
--- clang/test/SemaObjC/attr-objc-gc.m
+++ clang/test/SemaObjC/attr-objc-gc.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
 static id __attribute((objc_gc(weak))) a;
 static id __attribute((objc_gc(strong))) b;
 
Index: clang/test/SemaCXX/warn-c++11-extensions.cpp
===
--- clang/test/SemaCXX/warn-c++11-extensions.cpp
+++ clang/test/SemaCXX/warn-c++11-extensions.cpp
@@ -7,3 +7,5 @@
 
 enum struct E1 { A, B }; // expected-warning {{scoped enumerations are a C++11 extension}}
 enum class E2 { C, D }; // expected-warning {{scoped enumerations are a C++11 extension}}
+
+[[]] void 

[Lldb-commits] [lldb] e19339f - [lldb] Identify Swift-implemented ObjC classes

2023-07-20 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2023-07-20T19:32:12-07:00
New Revision: e19339f5f8c15d4307aaed14309e38e3c87121ac

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

LOG: [lldb] Identify Swift-implemented ObjC classes

Classes implemented in Swift can be exposed to ObjC. For those classes, the ObjC
metadata is incomplete. Specifically, the encoded types of the ivars are 
incomplete. As
one might expect, the Swift metadata _is_ complete. In such cases, the Swift 
runtime
should be consulted when determining the dynamic type of a value.

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

Added: 


Modified: 
lldb/include/lldb/Target/LanguageRuntime.h
lldb/source/Core/ValueObjectDynamicValue.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h

Removed: 




diff  --git a/lldb/include/lldb/Target/LanguageRuntime.h 
b/lldb/include/lldb/Target/LanguageRuntime.h
index 9cc79dc976c4d8..eff79a0bf0d062 100644
--- a/lldb/include/lldb/Target/LanguageRuntime.h
+++ b/lldb/include/lldb/Target/LanguageRuntime.h
@@ -67,6 +67,12 @@ class LanguageRuntime : public Runtime, public 
PluginInterface {
 
   virtual lldb::LanguageType GetLanguageType() const = 0;
 
+  /// Return the preferred language runtime instance, which in most cases will
+  /// be the current instance.
+  virtual LanguageRuntime *GetPreferredLanguageRuntime(ValueObject &in_value) {
+return nullptr;
+  }
+
   virtual bool GetObjectDescription(Stream &str, ValueObject &object) = 0;
 
   virtual bool GetObjectDescription(Stream &str, Value &value,

diff  --git a/lldb/source/Core/ValueObjectDynamicValue.cpp 
b/lldb/source/Core/ValueObjectDynamicValue.cpp
index 9db50aeeec9eaa..e6e30dce9d1e4a 100644
--- a/lldb/source/Core/ValueObjectDynamicValue.cpp
+++ b/lldb/source/Core/ValueObjectDynamicValue.cpp
@@ -149,7 +149,18 @@ bool ValueObjectDynamicValue::UpdateValue() {
   if (known_type != lldb::eLanguageTypeUnknown &&
   known_type != lldb::eLanguageTypeC) {
 runtime = process->GetLanguageRuntime(known_type);
-if (runtime)
+if (auto *preferred_runtime =
+runtime->GetPreferredLanguageRuntime(*m_parent)) {
+  // Try the preferred runtime first.
+  found_dynamic_type = preferred_runtime->GetDynamicTypeAndAddress(
+  *m_parent, m_use_dynamic, class_type_or_name, dynamic_address,
+  value_type);
+  if (found_dynamic_type)
+// Set the operative `runtime` for later use in this function.
+runtime = preferred_runtime;
+}
+if (!found_dynamic_type)
+  // Fallback to the runtime for `known_type`.
   found_dynamic_type = runtime->GetDynamicTypeAndAddress(
   *m_parent, m_use_dynamic, class_type_or_name, dynamic_address,
   value_type);

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
index 80ba352228c543..39969520b74556 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
@@ -10,8 +10,10 @@
 
 #include "lldb/Expression/FunctionCaller.h"
 #include "lldb/Target/ABI.h"
+#include "lldb/Target/Language.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
+#include "lldb/lldb-enumerations.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -668,6 +670,19 @@ uint64_t ClassDescriptorV2::GetInstanceSize() {
   return 0;
 }
 
+// From the ObjC runtime.
+static uint8_t IS_SWIFT_STABLE = 1U << 1;
+
+LanguageType ClassDescriptorV2::GetImplementationLanguage() const {
+  std::unique_ptr objc_class;
+  if (auto *process = m_runtime.GetProcess())
+if (Read_objc_class(process, objc_class))
+  if (objc_class->m_flags & IS_SWIFT_STABLE)
+return lldb::eLanguageTypeSwift;
+
+  return lldb::eLanguageTypeObjC;
+}
+
 ClassDescriptorV2::iVarsStorage::iVarsStorage() : m_ivars(), m_mutex() {}
 
 size_t ClassDescriptorV2::iVarsStorage::size() { return m_ivars.size(); }

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
index 09e5383d7fb95a..d298af92ba5e62 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCCl

[Lldb-commits] [PATCH] D152837: [lldb] Identify Swift-implemented ObjC classes

2023-07-20 Thread Dave Lee via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe19339f5f8c1: [lldb] Identify Swift-implemented ObjC classes 
(authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152837

Files:
  lldb/include/lldb/Target/LanguageRuntime.h
  lldb/source/Core/ValueObjectDynamicValue.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
  lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h

Index: lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
@@ -24,6 +24,7 @@
 #include "lldb/Target/LanguageRuntime.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/ThreadSafeDenseMap.h"
+#include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-private.h"
 
 class CommandObjectObjC_ClassTable_Dump;
@@ -86,6 +87,11 @@
   return (m_is_cf == eLazyBoolYes);
 }
 
+/// Determine whether this class is implemented in Swift.
+virtual lldb::LanguageType GetImplementationLanguage() const {
+  return lldb::eLanguageTypeObjC;
+}
+
 virtual bool IsValid() = 0;
 
 /// There are two routines in the ObjC runtime that tagged pointer clients
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
@@ -38,6 +38,8 @@
 
   static llvm::StringRef GetPluginNameStatic() { return "apple-objc-v2"; }
 
+  LanguageRuntime *GetPreferredLanguageRuntime(ValueObject &in_value) override;
+
   static char ID;
 
   bool isA(const void *ClassID) const override {
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -33,6 +33,7 @@
 #include "lldb/Target/ABI.h"
 #include "lldb/Target/DynamicLoader.h"
 #include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/LanguageRuntime.h"
 #include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
@@ -753,6 +754,19 @@
   RegisterObjCExceptionRecognizer(process);
 }
 
+LanguageRuntime *
+AppleObjCRuntimeV2::GetPreferredLanguageRuntime(ValueObject &in_value) {
+  if (auto process_sp = in_value.GetProcessSP()) {
+assert(process_sp.get() == m_process);
+if (auto descriptor_sp = GetNonKVOClassDescriptor(in_value)) {
+  LanguageType impl_lang = descriptor_sp->GetImplementationLanguage();
+  if (impl_lang != eLanguageTypeUnknown)
+return process_sp->GetLanguageRuntime(impl_lang);
+}
+  }
+  return nullptr;
+}
+
 bool AppleObjCRuntimeV2::GetDynamicTypeAndAddress(
 ValueObject &in_value, lldb::DynamicValueType use_dynamic,
 TypeAndOrName &class_type_or_name, Address &address,
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
@@ -12,6 +12,7 @@
 #include 
 
 #include "AppleObjCRuntimeV2.h"
+#include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-private.h"
 
 #include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
@@ -34,6 +35,8 @@
 return true; // any Objective-C v2 runtime class descriptor we vend is valid
   }
 
+  lldb::LanguageType GetImplementationLanguage() const override;
+
   // a custom descriptor is used for tagged pointers
   bool GetTaggedPointerInfo(uint64_t *info_bits = nullptr,
 uint64_t *value_bits = nullptr,
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
@@ -10,8 +10,10 @@
 
 #include "lldb/Expression/FunctionCaller.h"
 #incl

[Lldb-commits] [lldb] a6ff60e - [lldb] Delete unused LibcxxOptionalSummaryProvider (NFC)

2023-07-20 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2023-07-20T19:32:58-07:00
New Revision: a6ff60ecdd061cc21383108ac092ae4a700f9143

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

LOG: [lldb] Delete unused LibcxxOptionalSummaryProvider (NFC)

No longer needed following refactoring in D115178.

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.h

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index cb601603a3c43d..cae17ef992b215 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -76,27 +76,6 @@ 
lldb_private::formatters::GetSecondValueOfLibCXXCompressedPair(
   return value;
 }
 
-bool lldb_private::formatters::LibcxxOptionalSummaryProvider(
-ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
-  ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
-  if (!valobj_sp)
-return false;
-
-  // An optional either contains a value or not, the member __engaged_ is
-  // a bool flag, it is true if the optional has a value and false otherwise.
-  ValueObjectSP engaged_sp(valobj_sp->GetChildMemberWithName("__engaged_"));
-
-  if (!engaged_sp)
-return false;
-
-  llvm::StringRef engaged_as_cstring(
-  engaged_sp->GetValueAsUnsigned(0) == 1 ? "true" : "false");
-
-  stream.Printf(" Has Value=%s ", engaged_as_cstring.data());
-
-  return true;
-}
-
 bool lldb_private::formatters::LibcxxFunctionSummaryProvider(
 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
 

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
index 2dae71b24419d6..f65801e2cb1b9c 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
@@ -59,10 +59,6 @@ bool LibcxxWStringViewSummaryProvider(
 ValueObject &valobj, Stream &stream,
 const TypeSummaryOptions &options); // libc++ std::wstring_view
 
-bool LibcxxOptionalSummaryProvider(
-ValueObject &valobj, Stream &stream,
-const TypeSummaryOptions &options); // libc++ std::optional<>
-
 bool LibcxxSmartPointerSummaryProvider(
 ValueObject &valobj, Stream &stream,
 const TypeSummaryOptions



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


[Lldb-commits] [lldb] 8a45a54 - [lldb] Fix -Wreturn-type in RegisterInfos_x86_64_with_base_shared.cpp (NFC)

2023-07-20 Thread Jie Fu via lldb-commits

Author: Jie Fu
Date: 2023-07-21T11:42:42+08:00
New Revision: 8a45a54d59fcd29f559f4f260e2c447bef498e1e

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

LOG: [lldb] Fix -Wreturn-type in RegisterInfos_x86_64_with_base_shared.cpp (NFC)

/data/llvm-project/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.cpp:319:1:
 error: non-void function does
not return a value in all control paths [-Werror,-Wreturn-type]
}
^
1 error generated.

Added: 


Modified: 

lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.cpp
index a894dfe6143c41..7b2d64de230f33 100644
--- 
a/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.cpp
+++ 
b/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.cpp
@@ -238,7 +238,7 @@ uint32_t 
RegisterInfos_x86_64_with_base_shared::g_invalidate_st7_64[] = {
 RegInfo &GetRegInfoShared(llvm::Triple::ArchType arch_type, bool with_base) {
   static std::once_flag once_flag_x86, once_flag_x86_64,
   once_flag_x86_64_with_base;
-  static RegInfo reg_info_x86, reg_info_x86_64, reg_info_x86_64_with_base;
+  static RegInfo reg_info_x86, reg_info_x86_64, reg_info_x86_64_with_base, 
reg_info_invalid;
 
   switch (arch_type) {
   case llvm::Triple::x86:
@@ -314,7 +314,7 @@ RegInfo &GetRegInfoShared(llvm::Triple::ArchType arch_type, 
bool with_base) {
 }
   default:
 assert(false && "Unhandled target architecture.");
-break;
+return reg_info_invalid;
   }
 }
 



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


[Lldb-commits] [PATCH] D155117: Platform qemu-user: Build path to qemu automatically if not specified

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

In D155117#4510512 , @ted wrote:

> In D155117#4505538 , @labath wrote:
>
>> I am wondering if we actually need the second step (the architecture 
>> setting) here. The main reason it exists is the usage in 
>> `GetSupportedArchitectures` (which is called before a target is created) it 
>> seems like the value derived from the target should always be more correct. 
>> WDYT? What are the values you get in steps 2 and 3 for your use case?
>
> I don't think we need to specify the architecture, because I think we can 
> always get it from the triple. There might be a case where someone is using a 
> qemu that isn't named the same as the Triple ArchName, but that case could be 
> covered by emulator-path.

Yeah, that's my thinking as well. Given this, I think we should drop the 
setting part and just go with the target value directly.

In D155117#4511968 , @ted wrote:

> As for the GetSupportedArchitectures case, downstream I left in the code that 
> checks the property, but changed the return {}; to
>
>   return {ArchSpec(llvm::Triple("riscv32-unknown-linux")),
>   ArchSpec(llvm::Triple("riscv64-unknown-linux"))};
>
> I don't think we want that upstream, but downstream the only time we're 
> targetting riscv linux is when using qemu.
>
> That lets me run lldb, load a riscv file, then run, without setting any 
> properties.

FWIW, the way we do that is by putting something along the lines of:

  settings set platform.plugin.qemu-user.architecture aarch64
  ...
  platform select qemu-user
  platform select host

into our global lldbinit file. This causes lldb's platform selection logic to 
pick qemu-user (instead of remote-linux) when encountering an aarch64 
executable, without needing to change the source code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155117

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