[Lldb-commits] [lldb] [lldb] Fix incorrect logical operator in 'if' condition check (NFC) (PR #94779)

2024-07-06 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/94779

>From b8a387d82ed90c98f6bc9c0c7f9bc9da0d8e4d18 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Fri, 7 Jun 2024 23:21:15 +0530
Subject: [PATCH 1/3] [LLDB][NFC] Fix a cppcheck warning in
 Python/Interfaces/ScriptedPythonInterface.h

Fix #89195
---
 .../Python/Interfaces/ScriptedPythonInterface.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index 163659234466d..30811639c9a95 100644
--- 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -85,7 +85,7 @@ class ScriptedPythonInterface : virtual public 
ScriptedInterface {
 bool has_class_name = !class_name.empty();
 bool has_interpreter_dict =
 !(llvm::StringRef(m_interpreter.GetDictionaryName()).empty());
-if (!has_class_name && !has_interpreter_dict && !script_obj) {
+if (!has_class_name || !has_interpreter_dict || !script_obj) {
   if (!has_class_name)
 return create_error("Missing script class name.");
   else if (!has_interpreter_dict)

>From 7a53eeb7c42c79f7637a8900a02e782f385d494f Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 19 Jun 2024 13:46:57 +0530
Subject: [PATCH 2/3] simplify condition

---
 .../Interfaces/ScriptedPythonInterface.h   | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index 30811639c9a95..3d7c640a686ae 100644
--- 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -85,13 +85,17 @@ class ScriptedPythonInterface : virtual public 
ScriptedInterface {
 bool has_class_name = !class_name.empty();
 bool has_interpreter_dict =
 !(llvm::StringRef(m_interpreter.GetDictionaryName()).empty());
-if (!has_class_name || !has_interpreter_dict || !script_obj) {
-  if (!has_class_name)
-return create_error("Missing script class name.");
-  else if (!has_interpreter_dict)
-return create_error("Invalid script interpreter dictionary.");
-  else
-return create_error("Missing scripting object.");
+
+if (!has_class_name) {
+  return create_error("Missing script class name.");
+}
+
+if (!has_interpreter_dict) {
+  return create_error("Invalid script interpreter dictionary.");
+}
+
+if (!script_obj) {
+  return create_error("Missing scripting object.");
 }
 
 Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,

>From 93a6edb2e5cfeca2eccbc6b70ad8a06476c99210 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 6 Jul 2024 09:21:30 +0200
Subject: [PATCH 3/3] address review comment

---
 .../Python/Interfaces/ScriptedPythonInterface.h  | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index 3d7c640a686ae..9e859ec4b3653 100644
--- 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -86,17 +86,14 @@ class ScriptedPythonInterface : virtual public 
ScriptedInterface {
 bool has_interpreter_dict =
 !(llvm::StringRef(m_interpreter.GetDictionaryName()).empty());
 
-if (!has_class_name) {
+if (!has_class_name)
   return create_error("Missing script class name.");
-}
 
-if (!has_interpreter_dict) {
+if (!has_interpreter_dict)
   return create_error("Invalid script interpreter dictionary.");
-}
 
-if (!script_obj) {
+if (!script_obj)
   return create_error("Missing scripting object.");
-}
 
 Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
Locker::FreeLock);

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


[Lldb-commits] [lldb] [lldb] Fix incorrect logical operator in 'if' condition check (NFC) (PR #94779)

2024-07-06 Thread Shivam Gupta via lldb-commits


@@ -85,13 +85,17 @@ class ScriptedPythonInterface : virtual public 
ScriptedInterface {
 bool has_class_name = !class_name.empty();
 bool has_interpreter_dict =
 !(llvm::StringRef(m_interpreter.GetDictionaryName()).empty());
-if (!has_class_name && !has_interpreter_dict && !script_obj) {
-  if (!has_class_name)
-return create_error("Missing script class name.");
-  else if (!has_interpreter_dict)
-return create_error("Invalid script interpreter dictionary.");
-  else
-return create_error("Missing scripting object.");
+
+if (!has_class_name) {
+  return create_error("Missing script class name.");
+}

xgupta wrote:

Sure, thanks.

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


[Lldb-commits] [lldb] [lldb] Correct format specifier for sscanf to prevent buffer overflow (NFC) (PR #94783)

2024-07-06 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/94783

>From 17d39d89ee723881063ecbea19caaa6806e4e095 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 15 Jun 2024 23:57:03 +0530
Subject: [PATCH 1/2] Resolved merge conflict

---
 lldb/source/Host/linux/Host.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index 5545f9ef4d70e6..8a38947d4b665f 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -100,7 +100,7 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
&ProcessInfo,
   StatFields stat_fields;
   if (sscanf(
   Rest.data(),
-  "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld",
+  "%d %15s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld 
%ld",
   &stat_fields.pid, stat_fields.comm, &stat_fields.state,
   &stat_fields.ppid, &stat_fields.pgrp, &stat_fields.session,
   &stat_fields.tty_nr, &stat_fields.tpgid, &stat_fields.flags,

>From d84106a138040dc4e680ec82306969f8ff7ec01d Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 6 Jul 2024 10:57:08 +0200
Subject: [PATCH 2/2] run clang-format

---
 lldb/source/Host/linux/Host.cpp | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index 8a38947d4b665f..b5fa266da1d3bf 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -98,16 +98,16 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
&ProcessInfo,
   if (Rest.empty())
 return false;
   StatFields stat_fields;
-  if (sscanf(
-  Rest.data(),
-  "%d %15s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld 
%ld",
-  &stat_fields.pid, stat_fields.comm, &stat_fields.state,
-  &stat_fields.ppid, &stat_fields.pgrp, &stat_fields.session,
-  &stat_fields.tty_nr, &stat_fields.tpgid, &stat_fields.flags,
-  &stat_fields.minflt, &stat_fields.cminflt, &stat_fields.majflt,
-  &stat_fields.cmajflt, &stat_fields.utime, &stat_fields.stime,
-  &stat_fields.cutime, &stat_fields.cstime,
-  &stat_fields.realtime_priority, &stat_fields.priority) < 0) {
+  if (sscanf(Rest.data(),
+ "%d %15s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld 
"
+ "%ld",
+ &stat_fields.pid, stat_fields.comm, &stat_fields.state,
+ &stat_fields.ppid, &stat_fields.pgrp, &stat_fields.session,
+ &stat_fields.tty_nr, &stat_fields.tpgid, &stat_fields.flags,
+ &stat_fields.minflt, &stat_fields.cminflt, &stat_fields.majflt,
+ &stat_fields.cmajflt, &stat_fields.utime, &stat_fields.stime,
+ &stat_fields.cutime, &stat_fields.cstime,
+ &stat_fields.realtime_priority, &stat_fields.priority) < 0) {
 return false;
   }
 

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


[Lldb-commits] [lldb] [lldb] Fix string truncation method when substring is the prefix of string (NFC) (PR #94785)

2024-07-06 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/94785

>From 6ec5b1a005b7551f2857b30e2461d297e7febfa3 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Fri, 7 Jun 2024 23:44:49 +0530
Subject: [PATCH 1/2] [LLDB][NFC] Fix a cppcheck warning in
 Platform/Android/PlatformAndroid.cpp

Fix #91211
---
 lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp 
b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
index e177c134fea20e..6367763dd8b4ac 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec 
&src_file_spec,
   static constexpr llvm::StringLiteral k_zip_separator("!/");
   size_t pos = source_file.find(k_zip_separator);
   if (pos != std::string::npos)
-source_file = source_file.substr(0, pos);
+source_file = source_file.resize(0, pos);
 
   Status error;
   AdbClientUP adb(GetAdbClient(error));

>From c05f1a9812b8ef6cfc4f1f4c2d7525371d65a95b Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 6 Jul 2024 11:00:16 +0200
Subject: [PATCH 2/2] address review comment

---
 lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp 
b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
index 6367763dd8b4ac..ff63af68aec9db 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec 
&src_file_spec,
   static constexpr llvm::StringLiteral k_zip_separator("!/");
   size_t pos = source_file.find(k_zip_separator);
   if (pos != std::string::npos)
-source_file = source_file.resize(0, pos);
+source_file = source_file.resize(pos);
 
   Status error;
   AdbClientUP adb(GetAdbClient(error));

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


[Lldb-commits] [lldb] [lldb] Fix string truncation method when substring is the prefix of string (NFC) (PR #94785)

2024-07-09 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/94785

>From 6ec5b1a005b7551f2857b30e2461d297e7febfa3 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Fri, 7 Jun 2024 23:44:49 +0530
Subject: [PATCH 1/3] [LLDB][NFC] Fix a cppcheck warning in
 Platform/Android/PlatformAndroid.cpp

Fix #91211
---
 lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp 
b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
index e177c134fea20..6367763dd8b4a 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec 
&src_file_spec,
   static constexpr llvm::StringLiteral k_zip_separator("!/");
   size_t pos = source_file.find(k_zip_separator);
   if (pos != std::string::npos)
-source_file = source_file.substr(0, pos);
+source_file = source_file.resize(0, pos);
 
   Status error;
   AdbClientUP adb(GetAdbClient(error));

>From c05f1a9812b8ef6cfc4f1f4c2d7525371d65a95b Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 6 Jul 2024 11:00:16 +0200
Subject: [PATCH 2/3] address review comment

---
 lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp 
b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
index 6367763dd8b4a..ff63af68aec9d 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec 
&src_file_spec,
   static constexpr llvm::StringLiteral k_zip_separator("!/");
   size_t pos = source_file.find(k_zip_separator);
   if (pos != std::string::npos)
-source_file = source_file.resize(0, pos);
+source_file = source_file.resize(pos);
 
   Status error;
   AdbClientUP adb(GetAdbClient(error));

>From 1cd2f9c11070bcbee2efad2e5b84433eef31438c Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Tue, 9 Jul 2024 12:31:01 +0200
Subject: [PATCH 3/3] address review comment

---
 lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp 
b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
index ff63af68aec9d..50b6a5c29a657 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec 
&src_file_spec,
   static constexpr llvm::StringLiteral k_zip_separator("!/");
   size_t pos = source_file.find(k_zip_separator);
   if (pos != std::string::npos)
-source_file = source_file.resize(pos);
+source_file.resize(pos);
 
   Status error;
   AdbClientUP adb(GetAdbClient(error));

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


[Lldb-commits] [lldb] [lldb] Fix string truncation method when substring is the prefix of string (NFC) (PR #94785)

2024-07-09 Thread Shivam Gupta via lldb-commits


@@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec 
&src_file_spec,
   static constexpr llvm::StringLiteral k_zip_separator("!/");
   size_t pos = source_file.find(k_zip_separator);
   if (pos != std::string::npos)
-source_file = source_file.substr(0, pos);
+source_file = source_file.resize(0, pos);

xgupta wrote:

Thanks, got it.

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


[Lldb-commits] [lldb] [lldb] Fix string truncation method when substring is the prefix of string (NFC) (PR #94785)

2024-07-11 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Correct format specifier for sscanf to prevent buffer overflow (NFC) (PR #94783)

2024-07-11 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/94783

>From 17d39d89ee723881063ecbea19caaa6806e4e095 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 15 Jun 2024 23:57:03 +0530
Subject: [PATCH 1/2] Resolved merge conflict

---
 lldb/source/Host/linux/Host.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index 5545f9ef4d70e..8a38947d4b665 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -100,7 +100,7 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
&ProcessInfo,
   StatFields stat_fields;
   if (sscanf(
   Rest.data(),
-  "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld",
+  "%d %15s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld 
%ld",
   &stat_fields.pid, stat_fields.comm, &stat_fields.state,
   &stat_fields.ppid, &stat_fields.pgrp, &stat_fields.session,
   &stat_fields.tty_nr, &stat_fields.tpgid, &stat_fields.flags,

>From d84106a138040dc4e680ec82306969f8ff7ec01d Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 6 Jul 2024 10:57:08 +0200
Subject: [PATCH 2/2] run clang-format

---
 lldb/source/Host/linux/Host.cpp | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index 8a38947d4b665..b5fa266da1d3b 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -98,16 +98,16 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
&ProcessInfo,
   if (Rest.empty())
 return false;
   StatFields stat_fields;
-  if (sscanf(
-  Rest.data(),
-  "%d %15s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld 
%ld",
-  &stat_fields.pid, stat_fields.comm, &stat_fields.state,
-  &stat_fields.ppid, &stat_fields.pgrp, &stat_fields.session,
-  &stat_fields.tty_nr, &stat_fields.tpgid, &stat_fields.flags,
-  &stat_fields.minflt, &stat_fields.cminflt, &stat_fields.majflt,
-  &stat_fields.cmajflt, &stat_fields.utime, &stat_fields.stime,
-  &stat_fields.cutime, &stat_fields.cstime,
-  &stat_fields.realtime_priority, &stat_fields.priority) < 0) {
+  if (sscanf(Rest.data(),
+ "%d %15s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld 
"
+ "%ld",
+ &stat_fields.pid, stat_fields.comm, &stat_fields.state,
+ &stat_fields.ppid, &stat_fields.pgrp, &stat_fields.session,
+ &stat_fields.tty_nr, &stat_fields.tpgid, &stat_fields.flags,
+ &stat_fields.minflt, &stat_fields.cminflt, &stat_fields.majflt,
+ &stat_fields.cmajflt, &stat_fields.utime, &stat_fields.stime,
+ &stat_fields.cutime, &stat_fields.cstime,
+ &stat_fields.realtime_priority, &stat_fields.priority) < 0) {
 return false;
   }
 

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


[Lldb-commits] [lldb] [LLDB] Add an assert to verify sign_bit_pos is within the valid range (NFC) (PR #95678)

2024-07-24 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/95678

>From ef5b9cefb408ca3a721c95d8f6702abba77a602b Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 00:21:51 +0530
Subject: [PATCH 1/3] [LLDB] Add an assert to verify sign_bit_pos is within the
 valid range

---
 lldb/source/Utility/Scalar.cpp | 31 +++
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index c680101aa9efa..6e2f1ca4c1613 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -745,26 +745,25 @@ Status Scalar::SetValueFromData(const DataExtractor &data,
 
 bool Scalar::SignExtend(uint32_t sign_bit_pos) {
   const uint32_t max_bit_pos = GetByteSize() * 8;
+  assert(sign_bit_pos < max_bit_pos);
 
-  if (sign_bit_pos < max_bit_pos) {
-switch (m_type) {
-case Scalar::e_void:
-case Scalar::e_float:
-  return false;
+  switch (m_type) {
+  case Scalar::e_void:
+  case Scalar::e_float:
+return false;
 
-case Scalar::e_int:
-  if (sign_bit_pos < (max_bit_pos - 1)) {
-llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
-llvm::APInt bitwize_and = m_integer & sign_bit;
-if (bitwize_and.getBoolValue()) {
-  llvm::APInt mask =
-  ~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
-  m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
-}
-return true;
+  case Scalar::e_int:
+if (sign_bit_pos < (max_bit_pos - 1)) {
+  llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
+  llvm::APInt bitwize_and = m_integer & sign_bit;
+  if (bitwize_and.getBoolValue()) {
+llvm::APInt mask =
+~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
+m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
   }
-  break;
+  return true;
 }
+break;
   }
   return false;
 }

>From 98a183742e3dc6393aa55000fff1931263ff165a Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 19 Jun 2024 13:57:55 +0530
Subject: [PATCH 2/3] address review suggestion

---
 lldb/source/Utility/Scalar.cpp | 24 
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 6e2f1ca4c1613..496f402a74114 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -747,25 +747,17 @@ bool Scalar::SignExtend(uint32_t sign_bit_pos) {
   const uint32_t max_bit_pos = GetByteSize() * 8;
   assert(sign_bit_pos < max_bit_pos);
 
-  switch (m_type) {
-  case Scalar::e_void:
-  case Scalar::e_float:
+  if (m_type != Scalar::e_int || sign_bit_pos >= (max_bit_pos - 1)) {
 return false;
+  }
 
-  case Scalar::e_int:
-if (sign_bit_pos < (max_bit_pos - 1)) {
-  llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
-  llvm::APInt bitwize_and = m_integer & sign_bit;
-  if (bitwize_and.getBoolValue()) {
-llvm::APInt mask =
-~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
-m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
-  }
-  return true;
-}
-break;
+  llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
+  llvm::APInt bitwize_and = m_integer & sign_bit;
+  if (bitwize_and.getBoolValue()) {
+llvm::APInt mask = ~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
+m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
   }
-  return false;
+  return true;
 }
 
 size_t Scalar::GetAsMemoryData(void *dst, size_t dst_len,

>From 5fbf491d0781c1dcce6bdc727844e75c527f6473 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 24 Jul 2024 14:36:15 +0200
Subject: [PATCH 3/3] adjust assert to fix
 SymbolFile/DWARF/debug-types-expressions.test

---
 lldb/source/Utility/Scalar.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 496f402a74114..42247f658da13 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -745,8 +745,8 @@ Status Scalar::SetValueFromData(const DataExtractor &data,
 
 bool Scalar::SignExtend(uint32_t sign_bit_pos) {
   const uint32_t max_bit_pos = GetByteSize() * 8;
-  assert(sign_bit_pos < max_bit_pos);
 
+  assert(sign_bit_pos <= max_bit_pos);
   if (m_type != Scalar::e_int || sign_bit_pos >= (max_bit_pos - 1)) {
 return false;
   }

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


[Lldb-commits] [lldb] [lldb] Fix incorrect logical operator in 'if' condition check (NFC) (PR #94779)

2024-07-25 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix incorrect logical operator in 'if' condition check (NFC) (PR #94779)

2024-07-25 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Adjust the for loop condition to prevent unintended increments in ExpandRLE (NFC) (PR #94844)

2024-07-25 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/94844

>From 5fe77213524d05581eca70b8a0d25e03fe8df793 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 8 Jun 2024 11:52:08 +0530
Subject: [PATCH 1/2] [lldb] Adjust the for loop condition to prevent
 unintended increments in ExpandRLE (NFC)

Address the issue reported by static analyser cppcheck regarding missing bounds 
check for extra iterator increment in a loop.
This could lead to accessing out-of-bounds memory. To fix this we have adjusted 
the loop conditions to not incrementing iterator c there..

Caught by cppcheck -
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp:1300:75: 
warning: Missing bounds check for extra iterator increment in loop. 
[StlMissingComparison]

Fix #91225
---
 .../Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 8a47eed3d7cbe..81644d6248a83 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1297,7 +1297,7 @@ std::string GDBRemoteCommunication::ExpandRLE(std::string 
packet) {
   // Reserve enough byte for the most common case (no RLE used).
   std::string decoded;
   decoded.reserve(packet.size());
-  for (std::string::const_iterator c = packet.begin(); c != packet.end(); ++c) 
{
+  for (std::string::const_iterator c = packet.begin(); c != packet.end();) {
 if (*c == '*') {
   // '*' indicates RLE. Next character will give us the repeat count and
   // previous character is what is to be repeated.
@@ -1316,6 +1316,7 @@ std::string GDBRemoteCommunication::ExpandRLE(std::string 
packet) {
 } else {
   decoded.push_back(*c);
 }
+c++;
   }
   return decoded;
 }

>From b655f644e4744c98087ab0c8aee8bc38b3502c70 Mon Sep 17 00:00:00 2001
From: xgupta 
Date: Thu, 25 Jul 2024 15:59:17 +0200
Subject: [PATCH 2/2] address review comment

---
 .../Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 81644d6248a83..926310fa22328 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1298,7 +1298,7 @@ std::string GDBRemoteCommunication::ExpandRLE(std::string 
packet) {
   std::string decoded;
   decoded.reserve(packet.size());
   for (std::string::const_iterator c = packet.begin(); c != packet.end();) {
-if (*c == '*') {
+if (*c == '*' && std::next(c) != packet.end()) {
   // '*' indicates RLE. Next character will give us the repeat count and
   // previous character is what is to be repeated.
   char char_to_repeat = decoded.back();

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


[Lldb-commits] [lldb] [LLDB] Add an assert to verify sign_bit_pos is within the valid range (NFC) (PR #95678)

2024-07-26 Thread Shivam Gupta via lldb-commits


@@ -746,27 +746,18 @@ Status Scalar::SetValueFromData(const DataExtractor &data,
 bool Scalar::SignExtend(uint32_t sign_bit_pos) {
   const uint32_t max_bit_pos = GetByteSize() * 8;
 
-  if (sign_bit_pos < max_bit_pos) {
-switch (m_type) {
-case Scalar::e_void:
-case Scalar::e_float:
-  return false;
+  assert(sign_bit_pos <= max_bit_pos);

xgupta wrote:

Yes, I have realized this now, asserts are discoursed in the LLDB debugger and 
it mentions in docs - 
https://lldb.llvm.org/resources/contributing.html#error-handling-and-use-of-assertions-in-lldb.

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


[Lldb-commits] [lldb] [LLDB] Add an assert to verify sign_bit_pos is within the valid range (NFC) (PR #95678)

2024-07-26 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/95678

>From ef5b9cefb408ca3a721c95d8f6702abba77a602b Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 00:21:51 +0530
Subject: [PATCH 1/4] [LLDB] Add an assert to verify sign_bit_pos is within the
 valid range

---
 lldb/source/Utility/Scalar.cpp | 31 +++
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index c680101aa9efa..6e2f1ca4c1613 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -745,26 +745,25 @@ Status Scalar::SetValueFromData(const DataExtractor &data,
 
 bool Scalar::SignExtend(uint32_t sign_bit_pos) {
   const uint32_t max_bit_pos = GetByteSize() * 8;
+  assert(sign_bit_pos < max_bit_pos);
 
-  if (sign_bit_pos < max_bit_pos) {
-switch (m_type) {
-case Scalar::e_void:
-case Scalar::e_float:
-  return false;
+  switch (m_type) {
+  case Scalar::e_void:
+  case Scalar::e_float:
+return false;
 
-case Scalar::e_int:
-  if (sign_bit_pos < (max_bit_pos - 1)) {
-llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
-llvm::APInt bitwize_and = m_integer & sign_bit;
-if (bitwize_and.getBoolValue()) {
-  llvm::APInt mask =
-  ~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
-  m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
-}
-return true;
+  case Scalar::e_int:
+if (sign_bit_pos < (max_bit_pos - 1)) {
+  llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
+  llvm::APInt bitwize_and = m_integer & sign_bit;
+  if (bitwize_and.getBoolValue()) {
+llvm::APInt mask =
+~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
+m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
   }
-  break;
+  return true;
 }
+break;
   }
   return false;
 }

>From 98a183742e3dc6393aa55000fff1931263ff165a Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 19 Jun 2024 13:57:55 +0530
Subject: [PATCH 2/4] address review suggestion

---
 lldb/source/Utility/Scalar.cpp | 24 
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 6e2f1ca4c1613..496f402a74114 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -747,25 +747,17 @@ bool Scalar::SignExtend(uint32_t sign_bit_pos) {
   const uint32_t max_bit_pos = GetByteSize() * 8;
   assert(sign_bit_pos < max_bit_pos);
 
-  switch (m_type) {
-  case Scalar::e_void:
-  case Scalar::e_float:
+  if (m_type != Scalar::e_int || sign_bit_pos >= (max_bit_pos - 1)) {
 return false;
+  }
 
-  case Scalar::e_int:
-if (sign_bit_pos < (max_bit_pos - 1)) {
-  llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
-  llvm::APInt bitwize_and = m_integer & sign_bit;
-  if (bitwize_and.getBoolValue()) {
-llvm::APInt mask =
-~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
-m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
-  }
-  return true;
-}
-break;
+  llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
+  llvm::APInt bitwize_and = m_integer & sign_bit;
+  if (bitwize_and.getBoolValue()) {
+llvm::APInt mask = ~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
+m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
   }
-  return false;
+  return true;
 }
 
 size_t Scalar::GetAsMemoryData(void *dst, size_t dst_len,

>From 5fbf491d0781c1dcce6bdc727844e75c527f6473 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 24 Jul 2024 14:36:15 +0200
Subject: [PATCH 3/4] adjust assert to fix
 SymbolFile/DWARF/debug-types-expressions.test

---
 lldb/source/Utility/Scalar.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 496f402a74114..42247f658da13 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -745,8 +745,8 @@ Status Scalar::SetValueFromData(const DataExtractor &data,
 
 bool Scalar::SignExtend(uint32_t sign_bit_pos) {
   const uint32_t max_bit_pos = GetByteSize() * 8;
-  assert(sign_bit_pos < max_bit_pos);
 
+  assert(sign_bit_pos <= max_bit_pos);
   if (m_type != Scalar::e_int || sign_bit_pos >= (max_bit_pos - 1)) {
 return false;
   }

>From 2a7cbea5c38b57ed412c1415254b2308b2bd1e16 Mon Sep 17 00:00:00 2001
From: xgupta 
Date: Fri, 26 Jul 2024 11:03:32 +0200
Subject: [PATCH 4/4] address review comment

---
 lldb/source/Utility/Scalar.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 42247f658da13..facb3e5a6a1a9 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source

[Lldb-commits] [lldb] [LLDB] Remove the redundent increment of 'properties' variable (PR #95675)

2024-07-26 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Adjust the for loop condition to prevent unintended increments in ExpandRLE (NFC) (PR #94844)

2024-07-26 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] [NFC] Fix a cppcheck warning in lldb/source/Utility/Scalar.cpp (PR #94775)

2024-06-07 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/94775

Fixes #85985

lldb/source/Utility/Scalar.cpp:756:23: warning: Opposite inner 'if' condition 
leads to a dead code block. [oppositeInnerCondition]

>From da77334ac60233e688812e39480f58bbe1a251eb Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Fri, 7 Jun 2024 23:05:13 +0530
Subject: [PATCH] [LLDB] [NFC] Fix a cppcheck warning in
 lldb/source/Utility/Scalar.cpp

Fixes #85985
---
 lldb/source/Utility/Scalar.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index c70c5e1079918..c680101aa9efa 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -753,9 +753,7 @@ bool Scalar::SignExtend(uint32_t sign_bit_pos) {
   return false;
 
 case Scalar::e_int:
-  if (max_bit_pos == sign_bit_pos)
-return true;
-  else if (sign_bit_pos < (max_bit_pos - 1)) {
+  if (sign_bit_pos < (max_bit_pos - 1)) {
 llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
 llvm::APInt bitwize_and = m_integer & sign_bit;
 if (bitwize_and.getBoolValue()) {

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


[Lldb-commits] [lldb] [LLDB][NFC] Fix a cppcheck warning in Python/Interfaces/ScriptedPythonInterface.h (PR #94779)

2024-06-07 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/94779

Source code analyser cppcheck says:
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h:89:11:
 warning: Identical inner 'if' condition is always true. 
[identicalInnerCondition]
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h:91:16:
 warning: Identical inner 'if' condition is always true. 
[identicalInnerCondition]

Fix #89195

>From b8a387d82ed90c98f6bc9c0c7f9bc9da0d8e4d18 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Fri, 7 Jun 2024 23:21:15 +0530
Subject: [PATCH] [LLDB][NFC] Fix a cppcheck warning in
 Python/Interfaces/ScriptedPythonInterface.h

Fix #89195
---
 .../Python/Interfaces/ScriptedPythonInterface.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index 163659234466d..30811639c9a95 100644
--- 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -85,7 +85,7 @@ class ScriptedPythonInterface : virtual public 
ScriptedInterface {
 bool has_class_name = !class_name.empty();
 bool has_interpreter_dict =
 !(llvm::StringRef(m_interpreter.GetDictionaryName()).empty());
-if (!has_class_name && !has_interpreter_dict && !script_obj) {
+if (!has_class_name || !has_interpreter_dict || !script_obj) {
   if (!has_class_name)
 return create_error("Missing script class name.");
   else if (!has_interpreter_dict)

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


[Lldb-commits] [lldb] [LLDB][NFC] Fix a cppcheck warning in lldb/source/Host/linux/Host.cpp (PR #94783)

2024-06-07 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/94783

Fix #89710

>From 3fe606e8e9a9eb8df336ac48995eaa52b659aad1 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Fri, 7 Jun 2024 23:37:08 +0530
Subject: [PATCH] [LLDB][NFC] Fix a cppcheck warning in
 lldb/source/Host/linux/Host.cpp

Fix #89710
---
 lldb/source/Host/linux/Host.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index c6490f2fc9e2f..8a65c46a52ea8 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -92,7 +92,7 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
&ProcessInfo,
 return false;
   StatFields stat_fields;
   if (sscanf(Rest.data(),
- "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld",
+ "%d %15s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld",
  &stat_fields.pid, stat_fields.comm, &stat_fields.state,
  &stat_fields.ppid, &stat_fields.pgrp, &stat_fields.session,
  &stat_fields.tty_nr, &stat_fields.tpgid, &stat_fields.flags,

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


[Lldb-commits] [lldb] [LLDB][NFC] Fix a cppcheck warning in Platform/Android/PlatformAndroid.cpp (PR #94785)

2024-06-07 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/94785



Fix #91211

>From 6ec5b1a005b7551f2857b30e2461d297e7febfa3 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Fri, 7 Jun 2024 23:44:49 +0530
Subject: [PATCH] [LLDB][NFC] Fix a cppcheck warning in
 Platform/Android/PlatformAndroid.cpp

Fix #91211
---
 lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp 
b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
index e177c134fea20..6367763dd8b4a 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec 
&src_file_spec,
   static constexpr llvm::StringLiteral k_zip_separator("!/");
   size_t pos = source_file.find(k_zip_separator);
   if (pos != std::string::npos)
-source_file = source_file.substr(0, pos);
+source_file = source_file.resize(0, pos);
 
   Status error;
   AdbClientUP adb(GetAdbClient(error));

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


[Lldb-commits] [lldb] [LLDB][NFC] Fix a cppcheck warning in Platform/Android/PlatformAndroid.cpp (PR #94785)

2024-06-07 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] [NFC] Fix a cppcheck warning in lldb/source/Utility/Scalar.cpp (PR #94775)

2024-06-07 Thread Shivam Gupta via lldb-commits

xgupta wrote:

> The change LGTM, but I have a few suggestions regarding the title and 
> description:
> 
> * Retitle the PR to something like "[lldb] Remove dead code block (NFC)" 
> or something that conveys the intent/outcome. The modified file and line 
> number are already part of the commit and are just redundant. You could 
> mention it was found by `cppcheck` if you think that's useful.
> 
> * Update the description to explain why this code block is dead. 
> Something along the lines of "The check that `max_bit_pos == sign_bit_pos` 
> conflicts with the check that `sign_bit_pos < max_bit_pos` in the block 
> surrounding it" or something like that. Definitely mention the issue but 
> don't just repeat the warning without enough context to make sense of it.

Thanks, will update other PR also as your suggested.

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


[Lldb-commits] [lldb] [lldb] Remove dead code block (NFC) (PR #94775)

2024-06-07 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Remove dead code block (NFC) (PR #94775)

2024-06-07 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix incorrect logical operator in 'if' condition check (NFC) (PR #94779)

2024-06-07 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix incorrect logical operator in 'if' condition check (NFC) (PR #94779)

2024-06-07 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Correct format specifier for sscanf to prevent buffer overflow (NFC) (PR #94783)

2024-06-07 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Correct format specifier for sscanf to prevent buffer overflow (NFC) (PR #94783)

2024-06-07 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix string truncation method when substring is the prefix of string (NFC) (PR #94785)

2024-06-07 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix string truncation method when substring is the prefix of string (NFC) (PR #94785)

2024-06-07 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Remove redundant c_str() calls in stream output (NFC) (PR #94839)

2024-06-07 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/94839

Passing the result of c_str() to a stream is slow and redundant. This change 
removes unnecessary c_str() calls and uses the string object directly.

Caught by cppcheck -
lldb/tools/debugserver/source/JSON.cpp:398:19: performance: Passing the result 
of c_str() to a stream is slow and redundant. [stlcstrStream] 
lldb/tools/debugserver/source/JSON.cpp:408:64: performance: Passing the result 
of c_str() to a stream is slow and redundant. [stlcstrStream] 
lldb/tools/debugserver/source/JSON.cpp:420:54: performance: Passing the result 
of c_str() to a stream is slow and redundant. [stlcstrStream] 
lldb/tools/debugserver/source/JSON.cpp:46:13: performance: Passing the result 
of c_str() to a stream is slow and redundant. [stlcstrStream]

Fix #91212

>From 530ef9052731a97cec38d5833a3b8c064c70d3da Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 8 Jun 2024 10:31:44 +0530
Subject: [PATCH] [lldb] Remove redundant c_str() calls in stream output (NFC)

Passing the result of c_str() to a stream is slow and redundant.
This change removes unnecessary c_str() calls and uses the string object 
directly.

Caught by cppcheck -
lldb/tools/debugserver/source/JSON.cpp:398:19: performance: Passing the result 
of c_str() to a stream is slow and redundant. [stlcstrStream]
lldb/tools/debugserver/source/JSON.cpp:408:64: performance: Passing the result 
of c_str() to a stream is slow and redundant. [stlcstrStream]
lldb/tools/debugserver/source/JSON.cpp:420:54: performance: Passing the result 
of c_str() to a stream is slow and redundant. [stlcstrStream]
lldb/tools/debugserver/source/JSON.cpp:46:13: performance: Passing the result 
of c_str() to a stream is slow and redundant. [stlcstrStream]

Fix #91212
---
 lldb/tools/debugserver/source/JSON.cpp | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/lldb/tools/debugserver/source/JSON.cpp 
b/lldb/tools/debugserver/source/JSON.cpp
index 315c52aafc932..5453d857cb214 100644
--- a/lldb/tools/debugserver/source/JSON.cpp
+++ b/lldb/tools/debugserver/source/JSON.cpp
@@ -43,7 +43,7 @@ JSONString::JSONString(const std::string &s)
 : JSONValue(JSONValue::Kind::String), m_data(s) {}
 
 void JSONString::Write(std::ostream &s) {
-  s << "\"" << json_string_quote_metachars(m_data).c_str() << "\"";
+  s << "\"" << json_string_quote_metachars(m_data) << "\"";
 }
 
 uint64_t JSONNumber::GetAsUnsigned() const {
@@ -395,7 +395,7 @@ JSONParser::Token JSONParser::GetToken(std::string &value) {
   } else {
 error << "error: got exponent character but no exponent digits at "
  "offset in float value \""
-  << value.c_str() << "\"";
+  << value << "\"";
 value = error.str();
 return Token::Status;
   }
@@ -405,8 +405,7 @@ JSONParser::Token JSONParser::GetToken(std::string &value) {
   if (got_frac_digits) {
 return Token::Float;
   } else {
-error << "error: no digits after decimal point \"" << value.c_str()
-  << "\"";
+error << "error: no digits after decimal point \"" << value << 
"\"";
 value = error.str();
 return Token::Status;
   }
@@ -417,7 +416,7 @@ JSONParser::Token JSONParser::GetToken(std::string &value) {
   // We need at least some integer digits to make an integer
   return Token::Integer;
 } else {
-  error << "error: no digits negate sign \"" << value.c_str() << "\"";
+  error << "error: no digits negate sign \"" << value << "\"";
   value = error.str();
   return Token::Status;
 }

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


[Lldb-commits] [lldb] [lldb] Use const reference for range variables to improve performance (NFC) (PR #94840)

2024-06-07 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/94840

Cppcheck recommends using a const reference for range variables in a for-each 
loop. This avoids unnecessary copying of elements, improving performance.

Caught by cppcheck -
lldb/source/API/SBBreakpoint.cpp:717:22: performance: Range variable 'name' 
should be declared as const reference. [iterateByValue]

Fix #91213

>From 2206c6ec4f540b191b0dbf827a58836e35d19174 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 8 Jun 2024 10:43:01 +0530
Subject: [PATCH] [lldb] Use const reference for range variables to improve
 performance (NFC)

Cppcheck recommends using a const reference for range variables in a for-each 
loop.
This avoids unnecessary copying of elements, improving performance.

Caught by cppcheck -
lldb/source/API/SBBreakpoint.cpp:717:22: performance: Range variable 'name' 
should be declared as const reference. [iterateByValue]

Fix #91213
---
 lldb/source/API/SBBreakpoint.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index f1fb6f904f5f0..3d908047f9455 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -714,7 +714,7 @@ void SBBreakpoint::GetNames(SBStringList &names) {
 bkpt_sp->GetTarget().GetAPIMutex());
 std::vector names_vec;
 bkpt_sp->GetNames(names_vec);
-for (std::string name : names_vec) {
+for (const std::string &name : names_vec) {
   names.AppendString(name.c_str());
 }
   }

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


[Lldb-commits] [lldb] [lldb] Use const reference for range variables to improve performance (NFC) (PR #94840)

2024-06-07 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/94840

>From 25fb87d4bb4af55e642ec386f104412b39065a83 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 8 Jun 2024 10:43:01 +0530
Subject: [PATCH] [lldb] Use const reference for range variables to improve
 performance (NFC)

Cppcheck recommends using a const reference for range variables in a for-each 
loop.
This avoids unnecessary copying of elements, improving performance.

Caught by cppcheck -
lldb/source/API/SBBreakpoint.cpp:717:22: performance: Range variable 'name' 
should be declared as const reference. [iterateByValue]
lldb/source/API/SBTarget.cpp:1150:15: performance: Range variable 'name' should 
be declared as const reference. [iterateByValue]
lldb/source/Breakpoint/Breakpoint.cpp:888:26: performance: Range variable 
'name' should be declared as const reference. [iterateByValue]

Fix #91213
Fix #91217
Fix #91219
---
 lldb/source/API/SBBreakpoint.cpp  | 2 +-
 lldb/source/API/SBTarget.cpp  | 2 +-
 lldb/source/Breakpoint/Breakpoint.cpp | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index f1fb6f904f5f0..3d908047f9455 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -714,7 +714,7 @@ void SBBreakpoint::GetNames(SBStringList &names) {
 bkpt_sp->GetTarget().GetAPIMutex());
 std::vector names_vec;
 bkpt_sp->GetNames(names_vec);
-for (std::string name : names_vec) {
+for (const std::string &name : names_vec) {
   names.AppendString(name.c_str());
 }
   }
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 962ce9ba83cc7..adb9e645610ba 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -1147,7 +1147,7 @@ void SBTarget::GetBreakpointNames(SBStringList &names) {
 
 std::vector name_vec;
 target_sp->GetBreakpointNames(name_vec);
-for (auto name : name_vec)
+for (const auto &name : name_vec)
   names.AppendString(name.c_str());
   }
 }
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index ae845e92762b9..dc80d435ad444 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -885,7 +885,7 @@ void Breakpoint::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
 s->Printf("Names:");
 s->EOL();
 s->IndentMore();
-for (std::string name : m_name_list) {
+for (const std::string &name : m_name_list) {
   s->Indent();
   s->Printf("%s\n", name.c_str());
 }

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


[Lldb-commits] [lldb] [lldb] Use const reference for range variables to improve performance (NFC) (PR #94840)

2024-06-07 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Use const reference for range variables to improve performance (NFC) (PR #94840)

2024-06-07 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/94840

>From ebfb9d81ccc9d54a03e33b73143753a6d0f008bb Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 8 Jun 2024 10:43:01 +0530
Subject: [PATCH] [lldb] Use const reference for range variables to improve
 performance (NFC)

Cppcheck recommends using a const reference for range variables in a for-each 
loop.
This avoids unnecessary copying of elements, improving performance.

Caught by cppcheck -
lldb/source/API/SBBreakpoint.cpp:717:22: performance: Range variable 'name' 
should be declared as const reference. [iterateByValue]
lldb/source/API/SBTarget.cpp:1150:15: performance: Range variable 'name' should 
be declared as const reference. [iterateByValue]
lldb/source/Breakpoint/Breakpoint.cpp:888:26: performance: Range variable 
'name' should be declared as const reference. [iterateByValue]
lldb/source/Breakpoint/BreakpointIDList.cpp:262:26: performance: Range variable 
'name' should be declared as const reference. [iterateByValue]

Fix #91213
Fix #91217
Fix #91219
Fix #91220
---
 lldb/source/API/SBBreakpoint.cpp| 2 +-
 lldb/source/API/SBTarget.cpp| 2 +-
 lldb/source/Breakpoint/Breakpoint.cpp   | 2 +-
 lldb/source/Breakpoint/BreakpointIDList.cpp | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index f1fb6f904f5f0..3d908047f9455 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -714,7 +714,7 @@ void SBBreakpoint::GetNames(SBStringList &names) {
 bkpt_sp->GetTarget().GetAPIMutex());
 std::vector names_vec;
 bkpt_sp->GetNames(names_vec);
-for (std::string name : names_vec) {
+for (const std::string &name : names_vec) {
   names.AppendString(name.c_str());
 }
   }
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 962ce9ba83cc7..adb9e645610ba 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -1147,7 +1147,7 @@ void SBTarget::GetBreakpointNames(SBStringList &names) {
 
 std::vector name_vec;
 target_sp->GetBreakpointNames(name_vec);
-for (auto name : name_vec)
+for (const auto &name : name_vec)
   names.AppendString(name.c_str());
   }
 }
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index ae845e92762b9..dc80d435ad444 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -885,7 +885,7 @@ void Breakpoint::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
 s->Printf("Names:");
 s->EOL();
 s->IndentMore();
-for (std::string name : m_name_list) {
+for (const std::string &name : m_name_list) {
   s->Indent();
   s->Printf("%s\n", name.c_str());
 }
diff --git a/lldb/source/Breakpoint/BreakpointIDList.cpp 
b/lldb/source/Breakpoint/BreakpointIDList.cpp
index 97af1d40eb7a5..5fc9f95a75db1 100644
--- a/lldb/source/Breakpoint/BreakpointIDList.cpp
+++ b/lldb/source/Breakpoint/BreakpointIDList.cpp
@@ -259,7 +259,7 @@ llvm::Error BreakpointIDList::FindAndReplaceIDRanges(
 
 if (!names_found.empty()) {
   for (BreakpointSP bkpt_sp : target->GetBreakpointList().Breakpoints()) {
-for (std::string name : names_found) {
+for (const std::string &name : names_found) {
   if (bkpt_sp->MatchesName(name.c_str())) {
 StreamString canonical_id_str;
 BreakpointID::GetCanonicalReference(

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


[Lldb-commits] [lldb] [lldb] Use const reference for range variables to improve performance (NFC) (PR #94840)

2024-06-07 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix redundant condition in compression type check (NFC) (PR #94841)

2024-06-07 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/94841

The `else if` condition for checking `m_compression_type` is redundant as it 
matches with a previous `if` condition, making the expression always false. 
Reported by cppcheck as a possible cut-and-paste error.

Caught by cppcheck -
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp:543:35: 
style: Expression is always false because 'else if' condition matches previous 
condition at line 535. [multiCondition]

Fix #91222

>From 5451d769f36528e9640e665d4124103a6c34bf20 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 8 Jun 2024 11:14:06 +0530
Subject: [PATCH] [lldb] Fix redundant condition in compression type check
 (NFC)

The `else if` condition for checking `m_compression_type` is redundant as it 
matches with a previous `if` condition, making the expression always false.
Reported by cppcheck as a possible cut-and-paste error.

Caught by cppcheck -
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp:543:35: 
style: Expression is always false because 'else if' condition matches previous 
condition at line 535. [multiCondition]

Fix #91222
---
 .../Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp   | 2 --
 1 file changed, 2 deletions(-)

diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 8a47eed3d7cbe..52bf8533bbd8a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -540,8 +540,6 @@ bool GDBRemoteCommunication::DecompressPacket() {
 scratchbuf_size = compression_decode_scratch_buffer_size 
(COMPRESSION_ZLIB);
   else if (m_compression_type == CompressionType::LZMA)
 scratchbuf_size = compression_decode_scratch_buffer_size 
(COMPRESSION_LZMA);
-  else if (m_compression_type == CompressionType::LZFSE)
-scratchbuf_size = compression_decode_scratch_buffer_size 
(COMPRESSION_LZFSE);
   if (scratchbuf_size > 0) {
 m_decompression_scratch = (void*) malloc (scratchbuf_size);
 m_decompression_scratch_type = m_compression_type;

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


[Lldb-commits] [lldb] [lldb] Remove redundant condition in watch mask check (NFC) (PR #94842)

2024-06-07 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/94842

This issue is reported by cppcheck as a pointless test in the watch mask check. 
The `else if` condition is opposite to the previous `if` condition, making the 
expression always true.

Caught by cppcheck -
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp:509:25: 
style: Expression is always true because 'else if' condition is opposite to 
previous condition at line 505. [multiCondition]

Fix #91223

>From 12821eca107f3b1b29c5e6d65919322579f8dba8 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 8 Jun 2024 11:19:45 +0530
Subject: [PATCH] [lldb] Remove redundant condition in watch mask check (NFC)

This issue is reported by cppcheck as a pointless test in the watch mask check.
The `else if` condition is opposite to the previous `if` condition, making the 
expression always true.

Caught by cppcheck -
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp:509:25: 
style: Expression is always true because 'else if' condition is opposite to 
previous condition at line 505. [multiCondition]

Fix #91223
---
 .../Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
index 5ad2f7a8e9455..4668c25eab083 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
@@ -506,7 +506,7 @@ uint32_t 
NativeRegisterContextLinux_arm::SetHardwareWatchpoint(
   return LLDB_INVALID_INDEX32;
 else if (watch_mask <= 0x02)
   size = 2;
-else if (watch_mask <= 0x04)
+else
   size = 4;
 
 addr = addr & (~0x03);

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


[Lldb-commits] [lldb] [lldb] Fix redundant condition in compression type check (NFC) (PR #94841)

2024-06-07 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/94841

>From 5451d769f36528e9640e665d4124103a6c34bf20 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 8 Jun 2024 11:14:06 +0530
Subject: [PATCH 1/2] [lldb] Fix redundant condition in compression type check
 (NFC)

The `else if` condition for checking `m_compression_type` is redundant as it 
matches with a previous `if` condition, making the expression always false.
Reported by cppcheck as a possible cut-and-paste error.

Caught by cppcheck -
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp:543:35: 
style: Expression is always false because 'else if' condition matches previous 
condition at line 535. [multiCondition]

Fix #91222
---
 .../Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp   | 2 --
 1 file changed, 2 deletions(-)

diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 8a47eed3d7cbe..52bf8533bbd8a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -540,8 +540,6 @@ bool GDBRemoteCommunication::DecompressPacket() {
 scratchbuf_size = compression_decode_scratch_buffer_size 
(COMPRESSION_ZLIB);
   else if (m_compression_type == CompressionType::LZMA)
 scratchbuf_size = compression_decode_scratch_buffer_size 
(COMPRESSION_LZMA);
-  else if (m_compression_type == CompressionType::LZFSE)
-scratchbuf_size = compression_decode_scratch_buffer_size 
(COMPRESSION_LZFSE);
   if (scratchbuf_size > 0) {
 m_decompression_scratch = (void*) malloc (scratchbuf_size);
 m_decompression_scratch_type = m_compression_type;

>From dd6b3b57a509088565cb7df178fd3e9d55c7e55e Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 8 Jun 2024 11:24:58 +0530
Subject: [PATCH 2/2] clang format

---
 .../Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 52bf8533bbd8a..187370eb36cae 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -539,7 +539,8 @@ bool GDBRemoteCommunication::DecompressPacket() {
   else if (m_compression_type == CompressionType::ZlibDeflate)
 scratchbuf_size = compression_decode_scratch_buffer_size 
(COMPRESSION_ZLIB);
   else if (m_compression_type == CompressionType::LZMA)
-scratchbuf_size = compression_decode_scratch_buffer_size 
(COMPRESSION_LZMA);
+scratchbuf_size =
+compression_decode_scratch_buffer_size(COMPRESSION_LZMA);
   if (scratchbuf_size > 0) {
 m_decompression_scratch = (void*) malloc (scratchbuf_size);
 m_decompression_scratch_type = m_compression_type;

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


[Lldb-commits] [lldb] [lldb] Adjust the for loop condition to prevent unintended increments in ExpandRLE (NFC) (PR #94844)

2024-06-07 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/94844

This PR address the issue reported by static analyser cppcheck regarding 
missing bounds check for extra iterator increment in a loop. This could lead to 
accessing out-of-bounds memory. 
To fix this we have adjusted the loop conditions to not incrementing iterator c 
there.

Caught by cppcheck -
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp:1300:75: 
warning: Missing bounds check for extra iterator increment in loop. 
[StlMissingComparison]

Fix #91225

>From 5fe77213524d05581eca70b8a0d25e03fe8df793 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 8 Jun 2024 11:52:08 +0530
Subject: [PATCH] [lldb] Adjust the for loop condition to prevent unintended
 increments in ExpandRLE (NFC)

Address the issue reported by static analyser cppcheck regarding missing bounds 
check for extra iterator increment in a loop.
This could lead to accessing out-of-bounds memory. To fix this we have adjusted 
the loop conditions to not incrementing iterator c there..

Caught by cppcheck -
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp:1300:75: 
warning: Missing bounds check for extra iterator increment in loop. 
[StlMissingComparison]

Fix #91225
---
 .../Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 8a47eed3d7cbe..81644d6248a83 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1297,7 +1297,7 @@ std::string GDBRemoteCommunication::ExpandRLE(std::string 
packet) {
   // Reserve enough byte for the most common case (no RLE used).
   std::string decoded;
   decoded.reserve(packet.size());
-  for (std::string::const_iterator c = packet.begin(); c != packet.end(); ++c) 
{
+  for (std::string::const_iterator c = packet.begin(); c != packet.end();) {
 if (*c == '*') {
   // '*' indicates RLE. Next character will give us the repeat count and
   // previous character is what is to be repeated.
@@ -1316,6 +1316,7 @@ std::string GDBRemoteCommunication::ExpandRLE(std::string 
packet) {
 } else {
   decoded.push_back(*c);
 }
+c++;
   }
   return decoded;
 }

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


[Lldb-commits] [lldb] [lldb] Remove redundant c_str() calls in stream output (NFC) (PR #94839)

2024-06-07 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Remove redundant c_str() calls in stream output (NFC) (PR #94839)

2024-06-07 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add a test for lea_rsp_pattern_p to x86 unwinder (NFC) (PR #94852)

2024-06-08 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/94852

This commit adds a test for lea_rsp_pattern_p which was previously due as FIXME.

>From 1ca5f7e7edefedd12de0745de5afe720f41456b1 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 8 Jun 2024 17:43:55 +0530
Subject: [PATCH] [lldb] Add a test for lea_rsp_pattern_p to x86 unwinder (NFC)

This commit adds a test for lea_rsp_pattern_p which was previously due as FIXME.
---
 .../x86/Testx86AssemblyInspectionEngine.cpp   | 24 ++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git 
a/lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp 
b/lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
index 277cc14ce50c9..597e5b2e40d5e 100644
--- a/lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
+++ b/lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
@@ -1731,7 +1731,29 @@ TEST_F(Testx86AssemblyInspectionEngine, TestAddESP) {
   EXPECT_EQ(4 - 16, row_sp->GetCFAValue().GetOffset());
 }
 
-// FIXME add test for lea_rsp_pattern_p
+TEST_F(Testx86AssemblyInspectionEngine, TestLEA_RSP_Pattern) {
+  UnwindPlan::Row::RegisterLocation regloc;
+  UnwindPlan::RowSP row_sp;
+  AddressRange sample_range;
+  UnwindPlan unwind_plan(eRegisterKindLLDB);
+  std::unique_ptr engine = Getx86_64Inspector();
+
+  uint8_t data[] = {
+  0x8d, 0x64, 0x24, 0x10, // lea rsp, [rsp + 0x10]
+  0x90// nop
+  };
+
+  sample_range = AddressRange(0x1000, sizeof(data));
+
+  EXPECT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(
+  data, sizeof(data), sample_range, unwind_plan));
+
+  row_sp = unwind_plan.GetRowForFunctionOffset(0);
+  EXPECT_EQ(0ull, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rsp);
+  EXPECT_TRUE(row_sp->GetCFAValue().IsRegisterPlusOffset() == true);
+  EXPECT_EQ(8, row_sp->GetCFAValue().GetOffset());
+}
 
 TEST_F(Testx86AssemblyInspectionEngine, TestPopRBX) {
   UnwindPlan::Row::RegisterLocation regloc;

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


[Lldb-commits] [lldb] [lldb] Use const reference for range variables to improve performance (NFC) (PR #94840)

2024-06-08 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix redundant condition in compression type check (NFC) (PR #94841)

2024-06-10 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Remove redundant condition in watch mask check (NFC) (PR #94842)

2024-06-10 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add a test for lea_rsp_pattern_p to x86 unwinder (NFC) (PR #94852)

2024-06-11 Thread Shivam Gupta via lldb-commits

xgupta wrote:

Thanks @jasonmolenda for the review. I do have commit access to merge it.

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


[Lldb-commits] [lldb] [lldb] Add a test for lea_rsp_pattern_p to x86 unwinder (NFC) (PR #94852)

2024-06-11 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Remove the redundent increment of 'properties' variable (PR #95675)

2024-06-15 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/95675

This is described in (N3) https://pvs-studio.com/en/blog/posts/cpp/1126/ so 
caught by the PVS Studio analyzer. Warning message -
V547 Expression 'properties ++ > 0' is always false. CommandObjectTarget.cpp:100

I could not understand it properly but the properties++ operation is performed 
twice when the target architecture is valid.
First increment seems unnecessary since it is always false '0>0'.

>From a305b3958b3bf5551fda2d17af8eb11b9d122125 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 15 Jun 2024 23:12:19 +0530
Subject: [PATCH] [LLDB] Remove the redundent increment of 'properties'
 variable

This is described in (N3) https://pvs-studio.com/en/blog/posts/cpp/1126/ so 
caught by the PVS Studio analyzer.
Warning message -
V547 Expression 'properties ++ > 0' is always false. CommandObjectTarget.cpp:100

I could not understand it properly but the properties++ operation is performed
twice when the target architecture is valid.
First increment seems unnecessary since it is always false '0>0'.
---
 lldb/source/Commands/CommandObjectTarget.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index ae6c6d5479a19..c3d4307267a1b 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -97,7 +97,7 @@ static void DumpTargetInfo(uint32_t target_idx, Target 
*target,
 
   uint32_t properties = 0;
   if (target_arch.IsValid()) {
-strm.Printf("%sarch=", properties++ > 0 ? ", " : " ( ");
+strm.Printf("%sarch=", properties > 0 ? ", " : " ( ");
 target_arch.DumpTriple(strm.AsRawOstream());
 properties++;
   }

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


[Lldb-commits] [lldb] [lldb] Remove dead code block (NFC) (PR #94775)

2024-06-15 Thread Shivam Gupta via lldb-commits

xgupta wrote:

Gentile ping!

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


[Lldb-commits] [lldb] [lldb] Fix incorrect logical operator in 'if' condition check (NFC) (PR #94779)

2024-06-15 Thread Shivam Gupta via lldb-commits

xgupta wrote:

Gentile ping!

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


[Lldb-commits] [lldb] [lldb] Remove dead code block (NFC) (PR #94775)

2024-06-15 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Correct format specifier for sscanf to prevent buffer overflow (NFC) (PR #94783)

2024-06-15 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/94783

>From 17d39d89ee723881063ecbea19caaa6806e4e095 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 15 Jun 2024 23:57:03 +0530
Subject: [PATCH] Resolved merge conflict

---
 lldb/source/Host/linux/Host.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index 5545f9ef4d70e..8a38947d4b665 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -100,7 +100,7 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
&ProcessInfo,
   StatFields stat_fields;
   if (sscanf(
   Rest.data(),
-  "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld",
+  "%d %15s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld 
%ld",
   &stat_fields.pid, stat_fields.comm, &stat_fields.state,
   &stat_fields.ppid, &stat_fields.pgrp, &stat_fields.session,
   &stat_fields.tty_nr, &stat_fields.tpgid, &stat_fields.flags,

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


[Lldb-commits] [lldb] [LLDB] Add an assert to verify sign_bit_pos is within the valid range (NFC) (PR #95678)

2024-06-15 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/95678

None

>From 74efb6ae3187fe1e67e61cdca1f99b9de8146db4 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 00:21:51 +0530
Subject: [PATCH] [LLDB] Add an assert to verify sign_bit_pos is within the
 valid range

---
 lldb/source/Utility/Scalar.cpp | 31 +++
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index c680101aa9efa..6e2f1ca4c1613 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -745,26 +745,25 @@ Status Scalar::SetValueFromData(const DataExtractor &data,
 
 bool Scalar::SignExtend(uint32_t sign_bit_pos) {
   const uint32_t max_bit_pos = GetByteSize() * 8;
+  assert(sign_bit_pos < max_bit_pos);
 
-  if (sign_bit_pos < max_bit_pos) {
-switch (m_type) {
-case Scalar::e_void:
-case Scalar::e_float:
-  return false;
+  switch (m_type) {
+  case Scalar::e_void:
+  case Scalar::e_float:
+return false;
 
-case Scalar::e_int:
-  if (sign_bit_pos < (max_bit_pos - 1)) {
-llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
-llvm::APInt bitwize_and = m_integer & sign_bit;
-if (bitwize_and.getBoolValue()) {
-  llvm::APInt mask =
-  ~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
-  m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
-}
-return true;
+  case Scalar::e_int:
+if (sign_bit_pos < (max_bit_pos - 1)) {
+  llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
+  llvm::APInt bitwize_and = m_integer & sign_bit;
+  if (bitwize_and.getBoolValue()) {
+llvm::APInt mask =
+~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
+m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
   }
-  break;
+  return true;
 }
+break;
   }
   return false;
 }

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


[Lldb-commits] [lldb] [LLDB] Remove dead code (NFC) (PR #95713)

2024-06-16 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/95713

The dead code is caught by PVS studio analyzer -
https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N12.

Warning message -
V523 The 'then' statement is equivalent to the 'else' statement. Options.cpp 
1212

>From 76b5728a9b938f2b0d689cd20d6ba43c2f0a3bfd Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 22:29:45 +0530
Subject: [PATCH] [LLDB] Remove dead code (NFC)

The dead code is caught by PVS studio analyzer -
https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N12.

Warning message -
V523 The 'then' statement is equivalent to the 'else' statement. Options.cpp 
1212
---
 lldb/source/Interpreter/Options.cpp | 21 ++---
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/lldb/source/Interpreter/Options.cpp 
b/lldb/source/Interpreter/Options.cpp
index 4e7d074ace1b8..c5e75e0b9dced 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -1197,21 +1197,12 @@ OptionElementVector Options::ParseForCompletion(const 
Args &args,
 }
 break;
   case OptionParser::eOptionalArgument:
-if (OptionParser::GetOptionArgument() != nullptr) {
-  option_element_vector.push_back(OptionArgElement(
-  opt_defs_index,
-  FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 2],
-args),
-  FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 1],
-args)));
-} else {
-  option_element_vector.push_back(OptionArgElement(
-  opt_defs_index,
-  FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 2],
-args),
-  FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 1],
-args)));
-}
+option_element_vector.push_back(OptionArgElement(
+opt_defs_index,
+FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 2],
+  args),
+FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 1],
+  args)));
 break;
   default:
 // The options table is messed up.  Here we'll just continue

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


[Lldb-commits] [lldb] [LLDB] Remove dead code (NFC) (PR #95713)

2024-06-16 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix incorrect logical operator in 'if' condition check (NFC) (PR #94779)

2024-06-19 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/94779

>From b8a387d82ed90c98f6bc9c0c7f9bc9da0d8e4d18 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Fri, 7 Jun 2024 23:21:15 +0530
Subject: [PATCH 1/2] [LLDB][NFC] Fix a cppcheck warning in
 Python/Interfaces/ScriptedPythonInterface.h

Fix #89195
---
 .../Python/Interfaces/ScriptedPythonInterface.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index 163659234466d..30811639c9a95 100644
--- 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -85,7 +85,7 @@ class ScriptedPythonInterface : virtual public 
ScriptedInterface {
 bool has_class_name = !class_name.empty();
 bool has_interpreter_dict =
 !(llvm::StringRef(m_interpreter.GetDictionaryName()).empty());
-if (!has_class_name && !has_interpreter_dict && !script_obj) {
+if (!has_class_name || !has_interpreter_dict || !script_obj) {
   if (!has_class_name)
 return create_error("Missing script class name.");
   else if (!has_interpreter_dict)

>From 7a53eeb7c42c79f7637a8900a02e782f385d494f Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 19 Jun 2024 13:46:57 +0530
Subject: [PATCH 2/2] simplify condition

---
 .../Interfaces/ScriptedPythonInterface.h   | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index 30811639c9a95..3d7c640a686ae 100644
--- 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -85,13 +85,17 @@ class ScriptedPythonInterface : virtual public 
ScriptedInterface {
 bool has_class_name = !class_name.empty();
 bool has_interpreter_dict =
 !(llvm::StringRef(m_interpreter.GetDictionaryName()).empty());
-if (!has_class_name || !has_interpreter_dict || !script_obj) {
-  if (!has_class_name)
-return create_error("Missing script class name.");
-  else if (!has_interpreter_dict)
-return create_error("Invalid script interpreter dictionary.");
-  else
-return create_error("Missing scripting object.");
+
+if (!has_class_name) {
+  return create_error("Missing script class name.");
+}
+
+if (!has_interpreter_dict) {
+  return create_error("Invalid script interpreter dictionary.");
+}
+
+if (!script_obj) {
+  return create_error("Missing scripting object.");
 }
 
 Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,

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


[Lldb-commits] [lldb] [LLDB] Add an assert to verify sign_bit_pos is within the valid range (NFC) (PR #95678)

2024-06-19 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/95678

>From 74efb6ae3187fe1e67e61cdca1f99b9de8146db4 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 00:21:51 +0530
Subject: [PATCH 1/2] [LLDB] Add an assert to verify sign_bit_pos is within the
 valid range

---
 lldb/source/Utility/Scalar.cpp | 31 +++
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index c680101aa9efa..6e2f1ca4c1613 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -745,26 +745,25 @@ Status Scalar::SetValueFromData(const DataExtractor &data,
 
 bool Scalar::SignExtend(uint32_t sign_bit_pos) {
   const uint32_t max_bit_pos = GetByteSize() * 8;
+  assert(sign_bit_pos < max_bit_pos);
 
-  if (sign_bit_pos < max_bit_pos) {
-switch (m_type) {
-case Scalar::e_void:
-case Scalar::e_float:
-  return false;
+  switch (m_type) {
+  case Scalar::e_void:
+  case Scalar::e_float:
+return false;
 
-case Scalar::e_int:
-  if (sign_bit_pos < (max_bit_pos - 1)) {
-llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
-llvm::APInt bitwize_and = m_integer & sign_bit;
-if (bitwize_and.getBoolValue()) {
-  llvm::APInt mask =
-  ~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
-  m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
-}
-return true;
+  case Scalar::e_int:
+if (sign_bit_pos < (max_bit_pos - 1)) {
+  llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
+  llvm::APInt bitwize_and = m_integer & sign_bit;
+  if (bitwize_and.getBoolValue()) {
+llvm::APInt mask =
+~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
+m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
   }
-  break;
+  return true;
 }
+break;
   }
   return false;
 }

>From 2cc4f83d71229542bdabcba5ffe32b09c8529d57 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 19 Jun 2024 13:57:55 +0530
Subject: [PATCH 2/2] address review suggestion

---
 lldb/source/Utility/Scalar.cpp | 24 
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 6e2f1ca4c1613..496f402a74114 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -747,25 +747,17 @@ bool Scalar::SignExtend(uint32_t sign_bit_pos) {
   const uint32_t max_bit_pos = GetByteSize() * 8;
   assert(sign_bit_pos < max_bit_pos);
 
-  switch (m_type) {
-  case Scalar::e_void:
-  case Scalar::e_float:
+  if (m_type != Scalar::e_int || sign_bit_pos >= (max_bit_pos - 1)) {
 return false;
+  }
 
-  case Scalar::e_int:
-if (sign_bit_pos < (max_bit_pos - 1)) {
-  llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
-  llvm::APInt bitwize_and = m_integer & sign_bit;
-  if (bitwize_and.getBoolValue()) {
-llvm::APInt mask =
-~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
-m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
-  }
-  return true;
-}
-break;
+  llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
+  llvm::APInt bitwize_and = m_integer & sign_bit;
+  if (bitwize_and.getBoolValue()) {
+llvm::APInt mask = ~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
+m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
   }
-  return false;
+  return true;
 }
 
 size_t Scalar::GetAsMemoryData(void *dst, size_t dst_len,

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


[Lldb-commits] [lldb] [LLDB] Remove the redundent increment of 'properties' variable (PR #95675)

2024-06-19 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Add an assert to verify sign_bit_pos is within the valid range (NFC) (PR #95678)

2024-06-21 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/95678

>From c02fa111c62f98a20055745d5d8b75aea8fd748a Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 00:21:51 +0530
Subject: [PATCH 1/2] [LLDB] Add an assert to verify sign_bit_pos is within the
 valid range

---
 lldb/source/Utility/Scalar.cpp | 31 +++
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index c680101aa9efa..6e2f1ca4c1613 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -745,26 +745,25 @@ Status Scalar::SetValueFromData(const DataExtractor &data,
 
 bool Scalar::SignExtend(uint32_t sign_bit_pos) {
   const uint32_t max_bit_pos = GetByteSize() * 8;
+  assert(sign_bit_pos < max_bit_pos);
 
-  if (sign_bit_pos < max_bit_pos) {
-switch (m_type) {
-case Scalar::e_void:
-case Scalar::e_float:
-  return false;
+  switch (m_type) {
+  case Scalar::e_void:
+  case Scalar::e_float:
+return false;
 
-case Scalar::e_int:
-  if (sign_bit_pos < (max_bit_pos - 1)) {
-llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
-llvm::APInt bitwize_and = m_integer & sign_bit;
-if (bitwize_and.getBoolValue()) {
-  llvm::APInt mask =
-  ~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
-  m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
-}
-return true;
+  case Scalar::e_int:
+if (sign_bit_pos < (max_bit_pos - 1)) {
+  llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
+  llvm::APInt bitwize_and = m_integer & sign_bit;
+  if (bitwize_and.getBoolValue()) {
+llvm::APInt mask =
+~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
+m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
   }
-  break;
+  return true;
 }
+break;
   }
   return false;
 }

>From fc09409c733a4f5c92fdbb30cb6e23858bf1e49a Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 19 Jun 2024 13:57:55 +0530
Subject: [PATCH 2/2] address review suggestion

---
 lldb/source/Utility/Scalar.cpp | 24 
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 6e2f1ca4c1613..496f402a74114 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -747,25 +747,17 @@ bool Scalar::SignExtend(uint32_t sign_bit_pos) {
   const uint32_t max_bit_pos = GetByteSize() * 8;
   assert(sign_bit_pos < max_bit_pos);
 
-  switch (m_type) {
-  case Scalar::e_void:
-  case Scalar::e_float:
+  if (m_type != Scalar::e_int || sign_bit_pos >= (max_bit_pos - 1)) {
 return false;
+  }
 
-  case Scalar::e_int:
-if (sign_bit_pos < (max_bit_pos - 1)) {
-  llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
-  llvm::APInt bitwize_and = m_integer & sign_bit;
-  if (bitwize_and.getBoolValue()) {
-llvm::APInt mask =
-~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
-m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
-  }
-  return true;
-}
-break;
+  llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
+  llvm::APInt bitwize_and = m_integer & sign_bit;
+  if (bitwize_and.getBoolValue()) {
+llvm::APInt mask = ~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1);
+m_integer |= APSInt(std::move(mask), m_integer.isUnsigned());
   }
-  return false;
+  return true;
 }
 
 size_t Scalar::GetAsMemoryData(void *dst, size_t dst_len,

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


[Lldb-commits] [lldb] [LLDB] Add an assert to verify sign_bit_pos is within the valid range (NFC) (PR #95678)

2024-08-18 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Add an assert to verify sign_bit_pos is within the valid range (NFC) (PR #95678)

2024-08-18 Thread Shivam Gupta via lldb-commits

xgupta wrote:

I think it would be fine not to merge this PR. Asserts are recommended in the 
LLDB source code. I will close the PR.

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


[Lldb-commits] [lldb] [lldb] Adjust the for loop condition to prevent unintended increments in ExpandRLE (NFC) (PR #94844)

2024-08-18 Thread Shivam Gupta via lldb-commits

xgupta wrote:

ping!

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


[Lldb-commits] [lldb] 0b8eff1 - [LLDB][NFC] Fix a incorrect use of shared_ptr in RenderScriptRuntime.cpp

2023-02-06 Thread Shivam Gupta via lldb-commits

Author: Shivam Gupta
Date: 2023-02-06T22:07:43+05:30
New Revision: 0b8eff1f8724c6d8e890227597060109cb55e1ca

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

LOG: [LLDB][NFC] Fix a incorrect use of shared_ptr in RenderScriptRuntime.cpp

Incorrect use of shared_ptr.

found by PVS-Studio https://pvs-studio.com/en/blog/posts/cpp/1003/, N8 & N9.

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

Added: 


Modified: 

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 
b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
index e168241fb2c97..cc43ecb901038 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -2346,7 +2346,7 @@ void RenderScriptRuntime::SetElementSize(Element &elem) {
 // Given an allocation, this function copies the allocation contents from
 // device into a buffer on the heap. Returning a shared pointer to the buffer
 // containing the data.
-std::shared_ptr
+std::shared_ptr
 RenderScriptRuntime::GetAllocationData(AllocationDetails *alloc,
StackFrame *frame_ptr) {
   Log *log = GetLog(LLDBLog::Language);
@@ -2368,7 +2368,7 @@ RenderScriptRuntime::GetAllocationData(AllocationDetails 
*alloc,
 
   // Allocate a buffer to copy data into
   const uint32_t size = *alloc->size.get();
-  std::shared_ptr buffer(new uint8_t[size]);
+  std::shared_ptr buffer(new uint8_t[size]);
   if (!buffer) {
 LLDB_LOGF(log, "%s - couldn't allocate a %" PRIu32 " byte buffer",
   __FUNCTION__, size);
@@ -2557,7 +2557,7 @@ bool RenderScriptRuntime::LoadAllocation(Stream &strm, 
const uint32_t alloc_id,
 // saved to the file as the ElementHeader struct followed by offsets to the
 // structs of all the element's children.
 size_t RenderScriptRuntime::PopulateElementHeaders(
-const std::shared_ptr header_buffer, size_t offset,
+const std::shared_ptr header_buffer, size_t offset,
 const Element &elem) {
   // File struct for an element header with all the relevant details copied
   // from elem. We assume members are valid already.
@@ -2661,7 +2661,7 @@ bool RenderScriptRuntime::SaveAllocation(Stream &strm, 
const uint32_t alloc_id,
   }
 
   // Read allocation into buffer of heap memory
-  const std::shared_ptr buffer = GetAllocationData(alloc, frame_ptr);
+  const std::shared_ptr buffer = GetAllocationData(alloc, 
frame_ptr);
   if (!buffer) {
 strm.Printf("Error: Couldn't read allocation data into buffer");
 strm.EOL();
@@ -2695,7 +2695,7 @@ bool RenderScriptRuntime::SaveAllocation(Stream &strm, 
const uint32_t alloc_id,
   }
 
   // Create the headers describing the element type of the allocation.
-  std::shared_ptr element_header_buffer(
+  std::shared_ptr element_header_buffer(
   new uint8_t[element_header_size]);
   if (element_header_buffer == nullptr) {
 strm.Printf("Internal Error: Couldn't allocate %" PRIu64
@@ -3214,7 +3214,7 @@ bool RenderScriptRuntime::DumpAllocation(Stream &strm, 
StackFrame *frame_ptr,
 __FUNCTION__, data_size);
 
   // Allocate a buffer to copy data into
-  std::shared_ptr buffer = GetAllocationData(alloc, frame_ptr);
+  std::shared_ptr buffer = GetAllocationData(alloc, frame_ptr);
   if (!buffer) {
 strm.Printf("Error: Couldn't read allocation data");
 strm.EOL();

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
 
b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
index bc460706fd295..336058ede9b96 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ 
b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -528,7 +528,7 @@ class RenderScriptRuntime : public 
lldb_private::CPPLanguageRuntime {
 
   AllocationDetails *FindAllocByID(Stream &strm, const uint32_t alloc_id);
 
-  std::shared_ptr GetAllocationData(AllocationDetails *alloc,
+  std::shared_ptr GetAllocationData(AllocationDetails *alloc,
  StackFrame *frame_ptr);
 
   void SetElementSize(Element &elem);
@@ -538,7 +538,7 @@ class RenderScriptRuntime : public 
lldb_private::CPPLanguageRuntime {
 
   void FindStructTypeName(Element &elem, StackFrame *frame_ptr);
 
-  size_t PopulateElementHeaders(const std::sh

[Lldb-commits] [lldb] d531e5c - [LLDB] [NFC] Typo fix in usage text for "type filter" command

2021-10-20 Thread Shivam Gupta via lldb-commits

Author: Daniel Jalkut
Date: 2021-10-21T12:22:52+05:30
New Revision: d531e5cf58413e34dc006a580d2c109863bddaa1

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

LOG: [LLDB] [NFC] Typo fix in usage text for "type filter" command

When you invoke "help type filter" the resulting help shows:

Syntax: type synthetic []

This patch fixes the help so it says "type filter" instead of "type synthetic".

patch by: "Daniel Jalkut "

Reviewed By: teemperor

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

Added: 


Modified: 
lldb/source/Commands/CommandObjectType.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectType.cpp 
b/lldb/source/Commands/CommandObjectType.cpp
index 90e224867e2a4..3bff844786f4e 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -2978,7 +2978,7 @@ class CommandObjectTypeFilter : public 
CommandObjectMultiword {
   CommandObjectTypeFilter(CommandInterpreter &interpreter)
   : CommandObjectMultiword(interpreter, "type filter",
"Commands for operating on type filters.",
-   "type synthetic [] ") {
+   "type filter [] ") {
 LoadSubCommand(
 "add", CommandObjectSP(new CommandObjectTypeFilterAdd(interpreter)));
 LoadSubCommand("clear", CommandObjectSP(



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


[Lldb-commits] [lldb] 3af9847 - [LLDB][Docs] Convert some .txt files to .rst

2021-08-30 Thread Shivam Gupta via lldb-commits

Author: Shivam Gupta
Date: 2021-08-31T11:45:24+05:30
New Revision: 3af9847a9581fca3c81c7f8669f6f617e35ba9e5

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

LOG: [LLDB][Docs] Convert some .txt files to .rst

Upadate some .txt files to .rst for consistency as most
of the documentation is written in reStructuredText format.

Signed-off-by: Shivam Gupta 

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

Added: 
lldb/docs/use/links.rst

Modified: 


Removed: 
lldb/docs/use/links.md



diff  --git a/lldb/docs/use/links.md b/lldb/docs/use/links.md
deleted file mode 100644
index 8c125a26cb46a..0
--- a/lldb/docs/use/links.md
+++ /dev/null
@@ -1,56 +0,0 @@
-Links
-=
-
-This page contains links to external resources on how to use LLDB. Being listed
-on this page is not an endorsement.
-
-## Blog Posts
-
-### [Dancing in the Debugger — A Waltz with LLDB (2014) 
](https://www.objc.io/issues/19-debugging/lldb-debugging/)
-
-A high level overview of LLDB with a focus on debugging Objective-C code.
-
-## Videos
-
-### [LLDB: Beyond "po" 
(2019)](https://developer.apple.com/videos/play/wwdc2019/429/)
-
-LLDB is a powerful tool for exploring and debugging your app at runtime.
-Discover the various ways to display values in your app, how to format custom
-data types, and how to extend LLDB using your own Python 3 scripts.
-
-### [Advanced Debugging with Xcode and LLDB 
(2018)](https://developer.apple.com/videos/play/wwdc2018/412/)
-
-Discover advanced techniques, and tips and tricks for enhancing your Xcode
-debugging workflows. Learn how to take advantage of LLDB and custom breakpoints
-for more powerful debugging. Get the most out of Xcode's view debugging tools
-to solve UI issues in your app more efficiently.
-
-### [Debugging with LLDB 
(2012)](https://developer.apple.com/videos/play/wwdc2012/415/)
-
-LLDB is the next-generation debugger for macOS and iOS. Get an introduction to
-using LLDB via the console interface and within Xcode's graphical debugger. The
-team that created LLDB will demonstrate the latest features and improvements,
-helping you track down bugs more efficiently than ever before.
-
-### [Migrating from GDB to LLDB 
(2011)](https://developer.apple.com/videos/play/wwdc2011/321/)
-
-LLDB is the next-generation debugger for macOS and iOS. Discover why you'll
-want to start using LLDB in your own development, get expert tips from the team
-that created LLDB, and see how it will help you track down bugs more
-efficiently than ever before.
-
-## Books
-
-### [Advanced Apple Debugging & Reverse Engineering 
(2018)](https://www.raywenderlich.com/books/advanced-apple-debugging-reverse-engineering/)
-
-A book about using LLDB on Apple platforms.
-
-## Extensions
-
-### [facebook/chisel](https://github.com/facebook/chisel)
-
-Chisel is a collection of LLDB commands to assist in the debugging of iOS apps.
-
-### [DerekSelander/LLDB](https://github.com/DerekSelander/LLDB)
-
-A collection of LLDB aliases/regexes and Python scripts.

diff  --git a/lldb/docs/use/links.rst b/lldb/docs/use/links.rst
new file mode 100644
index 0..595a78c8db804
--- /dev/null
+++ b/lldb/docs/use/links.rst
@@ -0,0 +1,82 @@
+Links
+=
+
+This page contains links to external resources on how to use LLDB. Being
+listed on this page is not an endorsement.
+
+Blog Posts
+--
+
+`Dancing in the Debugger — A Waltz with LLDB (2014)`_
+~
+
+A high level overview of LLDB with a focus on debugging Objective-C
+code.
+
+Videos
+--
+
+`LLDB: Beyond “po” (2019)`_
+~~~
+
+LLDB is a powerful tool for exploring and debugging your app at runtime.
+Discover the various ways to display values in your app, how to format
+custom data types, and how to extend LLDB using your own Python 3
+scripts.
+
+`Advanced Debugging with Xcode and LLDB (2018)`_
+
+
+Discover advanced techniques, and tips and tricks for enhancing your
+Xcode debugging workflows. Learn how to take advantage of LLDB and
+custom breakpoints for more powerful debugging. Get the most out of
+Xcode’s view debugging tools to solve UI issues in your app more
+efficiently.
+
+`Debugging with LLDB (2012)`_
+~
+
+LLDB is the next-generation debugger for macOS and iOS. Get an
+introduction to using LLDB via the console interface and within Xcode’s
+graphical debugger. The team that created LLDB will demonstrate the
+latest features and improvements, helping you track down bugs more
+efficiently than ever before.
+
+`Migrating from GDB to LLDB (2011)`_
+
+
+LLDB is the next-generation debugger for macOS and iOS. Discover why
+you’ll want to s

[Lldb-commits] [lldb] 654e8d6 - [LLDB][Docs] Move best-practices.txt contain to resources/test.rst

2021-08-30 Thread Shivam Gupta via lldb-commits

Author: Shivam Gupta
Date: 2021-08-31T11:45:24+05:30
New Revision: 654e8d6c318a0c4eb9bfd74a9ace6d1a1bda5100

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

LOG: [LLDB][Docs] Move best-practices.txt contain to resources/test.rst

This file contain some old reference to files those are now either renamed or 
replaced.
Also this .txt file didn't generate to html during the sphnix documentation 
build so I send its contents to resources/test.rst file.

Signed-off-by: Shivam Gupta 

Reviewed By: teemperor, mgorny, JDevlieghere

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

Added: 


Modified: 
lldb/docs/resources/test.rst

Removed: 
lldb/docs/testsuite/best-practices.txt



diff  --git a/lldb/docs/resources/test.rst b/lldb/docs/resources/test.rst
index d2830bc53c1f0..1f876ff4513d6 100644
--- a/lldb/docs/resources/test.rst
+++ b/lldb/docs/resources/test.rst
@@ -319,6 +319,71 @@ A better way to write the test above would be using LLDB's 
testing function
 # Good. Will print expected_string and the contents of list_of_results.
 self.assertIn(expected_string, list_of_results)
 
+**Do not use hard-coded line numbers in your test case.**
+
+Instead, try to tag the line with some distinguishing pattern, and use the 
function line_number() defined in lldbtest.py which takes 
+filename and string_to_match as arguments and returns the line number.
+
+As an example, take a look at 
test/API/functionalities/breakpoint/breakpoint_conditions/main.c which has these
+two lines:
+
+.. code-block:: c
+
+return c(val); // Find the line number of c's parent call here.
+
+and
+
+.. code-block:: c
+
+return val + 3; // Find the line number of function "c" here.
+
+The Python test case TestBreakpointConditions.py uses the comment strings to 
find the line numbers during setUp(self) and use them
+later on to verify that the correct breakpoint is being stopped on and that 
its parent frame also has the correct line number as
+intended through the breakpoint condition.
+
+**Take advantage of the unittest framework's decorator features.**
+
+These features can be use to properly mark your test class or method for 
platform-specific tests, compiler specific, version specific.
+
+As an example, take a look at 
test/API/lang/c/forward/TestForwardDeclaration.py which has these lines:
+
+.. code-block:: python
+
+@no_debug_info_test
+@skipIfDarwin
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "8.0"])
+@expectedFailureAll(oslist=["windows"])
+def test_debug_names(self):
+"""Test that we are able to find complete types when using DWARF v5
+accelerator tables"""
+self.do_test(dict(CFLAGS_EXTRAS="-gdwarf-5 -gpubnames"))
+
+This tells the test harness that unless we are running "linux" and clang 
version equal & above 8.0, the test should be skipped.
+
+**Class-wise cleanup after yourself.**
+
+TestBase.tearDownClass(cls) provides a mechanism to invoke the 
platform-specific cleanup after finishing with a test class. A test
+class can have more than one test methods, so the tearDownClass(cls) method 
gets run after all the test methods have been executed by
+the test harness.
+
+The default cleanup action performed by the 
packages/Python/lldbsuite/test/lldbtest.py module invokes the "make clean" os 
command.
+
+If this default cleanup is not enough, individual class can provide an extra 
cleanup hook with a class method named classCleanup , 
+for example, in test/API/terminal/TestSTTYBeforeAndAfter.py:
+
+.. code-block:: python
+
+@classmethod
+def classCleanup(cls):
+"""Cleanup the test byproducts."""
+cls.RemoveTempFile("child_send1.txt")
+
+
+The 'child_send1.txt' file gets generated during the test run, so it makes 
sense to explicitly spell out the action in the same 
+TestSTTYBeforeAndAfter.py file to do the cleanup instead of artificially 
adding it as part of the default cleanup action which serves to
+cleanup those intermediate and a.out files.
+
 Running The Tests
 -
 

diff  --git a/lldb/docs/testsuite/best-practices.txt 
b/lldb/docs/testsuite/best-practices.txt
deleted file mode 100644
index b5a9156fd521c..0
--- a/lldb/docs/testsuite/best-practices.txt
+++ /dev/null
@@ -1,93 +0,0 @@
-This document attempts to point out some best practices that prove to be 
helpful
-when building new test cases in the tot/test directory.  Everyone is welcomed 
to
-add/modify contents into this file.
-
-o Do not use hard-coded line numbers in your test case.  Instead, try to tag 
the
-  line with some distinguishing pattern, and use the function line_number()
-  defined in lldbtest.py which takes filename and string_to_match as arguments
-  and returns the line number.
-

[Lldb-commits] [lldb] 59c954f - [LLDB][Docs] Indicate `PS1` variable by $

2021-09-04 Thread Shivam Gupta via lldb-commits

Author: Shivam Gupta
Date: 2021-09-04T20:57:59+05:30
New Revision: 59c954f76a66c6fc715610e85be71e9c050f2302

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

LOG: [LLDB][Docs] Indicate `PS1` variable by $

Added: 


Modified: 
lldb/docs/design/reproducers.rst
lldb/docs/design/sbapi.rst
lldb/docs/index.rst
lldb/docs/resources/build.rst
lldb/docs/use/python-reference.rst
lldb/docs/use/python.rst
lldb/docs/use/troubleshooting.rst

Removed: 




diff  --git a/lldb/docs/design/reproducers.rst 
b/lldb/docs/design/reproducers.rst
index 99e34d812deed..cac8721196d3e 100644
--- a/lldb/docs/design/reproducers.rst
+++ b/lldb/docs/design/reproducers.rst
@@ -33,7 +33,7 @@ late to capture initialization of the debugger.
 
 .. code-block:: bash
 
-  > lldb --capture
+  $ lldb --capture
 
 In capture mode, LLDB will keep track of all the information it needs to replay
 the current debug session. Most data is captured lazily to limit the impact on
@@ -70,7 +70,7 @@ were passed to LLDB during capture are already part of the 
reproducer.
 
 .. code-block:: bash
 
- > lldb --replay /path/to/reproducer
+  $ lldb --replay /path/to/reproducer
 
 
 During replay LLDB will behave similar to batch mode. The session should be

diff  --git a/lldb/docs/design/sbapi.rst b/lldb/docs/design/sbapi.rst
index 676509bbd99e5..f4a7ca271be63 100644
--- a/lldb/docs/design/sbapi.rst
+++ b/lldb/docs/design/sbapi.rst
@@ -68,7 +68,7 @@ Like other clang-based tools it requires a compilation 
database
 
 ::
 
-./bin/lldb-instr /path/to/lldb/source/API/SBDebugger.cpp
+   $ ./bin/lldb-instr /path/to/lldb/source/API/SBDebugger.cpp
 
 
 The tool will automatically insert ``LLDB_RECORD`` macros inline, however you

diff  --git a/lldb/docs/index.rst b/lldb/docs/index.rst
index 1fdf674863e7c..0ca444f31ed14 100644
--- a/lldb/docs/index.rst
+++ b/lldb/docs/index.rst
@@ -90,7 +90,7 @@ subdirectory:
 
 ::
 
-  > git clone https://github.com/llvm/llvm-project.git
+  $ git clone https://github.com/llvm/llvm-project.git
 
 Note that LLDB generally builds from top-of-trunk using CMake and Ninja.
 Additionally it builds:

diff  --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index 6e2afcae0e262..13e5dcd3f09c8 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -70,11 +70,11 @@ commands below.
 
 ::
 
-  > yum install libedit-devel libxml2-devel ncurses-devel python-devel swig
-  > sudo apt-get install build-essential swig python3-dev libedit-dev 
libncurses5-dev
-  > pkg install swig python
-  > pkgin install swig python36 cmake ninja-build
-  > brew install swig cmake ninja
+  $ yum install libedit-devel libxml2-devel ncurses-devel python-devel swig
+  $ sudo apt-get install build-essential swig python3-dev libedit-dev 
libncurses5-dev
+  $ pkg install swig python
+  $ pkgin install swig python36 cmake ninja-build
+  $ brew install swig cmake ninja
 
 Note that there's an `incompatibility
 `_ between Python version 3.7 and 
later
@@ -82,6 +82,7 @@ and swig versions older than 4.0.0 which makes builds of LLDB 
using debug
 versions of python unusable. This primarily affects Windows, as debug builds of
 LLDB must use debug python as well.
 
+
 Windows
 ***
 
@@ -139,7 +140,7 @@ source-tree with git:
 
 ::
 
-  > git clone https://github.com/llvm/llvm-project.git
+  $ git clone https://github.com/llvm/llvm-project.git
 
 CMake is a cross-platform build-generator tool. CMake does not build the
 project, it generates the files needed by your build tool. The recommended
@@ -155,7 +156,7 @@ to the ``llvm`` directory in the source-tree:
 
 ::
 
-  > cmake -G Ninja -DLLVM_ENABLE_PROJECTS="clang;lldb" [] 
path/to/llvm-project/llvm
+  $ cmake -G Ninja -DLLVM_ENABLE_PROJECTS="clang;lldb" [] 
path/to/llvm-project/llvm
 
 We used the ``LLVM_ENABLE_PROJECTS`` option here to tell the build-system which
 subprojects to build in addition to LLVM (for more options see
@@ -166,7 +167,7 @@ it only builds what is necessary to run the lldb driver:
 
 ::
 
-  > ninja lldb
+  $ ninja lldb
 
 Standalone builds
 *
@@ -185,10 +186,10 @@ Clang. Then we build the ``ALL`` target with ninja:
 
 ::
 
-  > cmake -B /path/to/llvm-build -G Ninja \
+  $ cmake -B /path/to/llvm-build -G Ninja \
   -DLLVM_ENABLE_PROJECTS=clang \
   [] /path/to/llvm-project/llvm
-  > ninja
+  $ ninja
 
 Now run CMake a second time with ``-B`` pointing to a new directory for the
 main build-tree and the positional argument pointing to the ``lldb`` directory
@@ -199,10 +200,10 @@ build directory for Clang, remember to pass its module 
path via ``Clang_DIR``
 
 ::
 
-  > cmake -B /path/to/lldb-build -G Ninja \
+  $ cmake -B /path/to/lldb-build

[Lldb-commits] [lldb] [lldb] Adjust the for loop condition to prevent unintended increments in ExpandRLE (NFC) (PR #94844)

2025-02-10 Thread Shivam Gupta via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Adjust the for loop condition to prevent unintended increments in ExpandRLE (NFC) (PR #94844)

2025-02-10 Thread Shivam Gupta via lldb-commits

xgupta wrote:

Could not understand the right fix. Better it to leave it.

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