[Lldb-commits] [PATCH] D140630: [lldb-vscode] Add data breakpoint support

2023-05-26 Thread Callum Macmillan via Phabricator via lldb-commits
cimacmillan added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140630

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


[Lldb-commits] [PATCH] D151366: [lldb] Disable variable watchpoints when going out of scope

2023-05-26 Thread antoine moynault via Phabricator via lldb-commits
antmo added a comment.

Hi @mib,
I think this broke lldb-arm-ubuntu bot (LocalVariableWatchpointDisabler.test 
failure): https://lab.llvm.org/buildbot/#/builders/17/builds/38136
Also visible on lldb-aarch64-windows here (TestVarPath.py issue is something 
else): https://lab.llvm.org/buildbot/#/builders/219/builds/3048
Could you please take a look ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151366

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


[Lldb-commits] [lldb] d01917c - [LLDB] Explicitly declare constructor in `PersistentExpressionState`

2023-05-26 Thread Laszlo Kindrat via lldb-commits

Author: Laszlo Kindrat
Date: 2023-05-26T09:25:44-04:00
New Revision: d01917c507a3b195109001d1b9a91c4fbdbb5a71

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

LOG: [LLDB] Explicitly declare constructor in `PersistentExpressionState`

It seems that when trying to link the lldb library explicitly, the inlined 
default constructor cannot find the vtable for the class. This patch fixes this 
by explicitly declaring a default constructor in `PersistentExpressionState`, 
and providing the definition in the source file.

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

Added: 


Modified: 
lldb/include/lldb/Expression/ExpressionVariable.h
lldb/source/Expression/ExpressionVariable.cpp

Removed: 




diff  --git a/lldb/include/lldb/Expression/ExpressionVariable.h 
b/lldb/include/lldb/Expression/ExpressionVariable.h
index ad85a21df5115..277b00a916686 100644
--- a/lldb/include/lldb/Expression/ExpressionVariable.h
+++ b/lldb/include/lldb/Expression/ExpressionVariable.h
@@ -207,6 +207,8 @@ class PersistentExpressionState
   /// LLVM RTTI support
   static char ID;
 
+  PersistentExpressionState();
+
   virtual ~PersistentExpressionState();
 
   virtual lldb::ExpressionVariableSP

diff  --git a/lldb/source/Expression/ExpressionVariable.cpp 
b/lldb/source/Expression/ExpressionVariable.cpp
index 44ab1c2d0b436..f0a28988822fa 100644
--- a/lldb/source/Expression/ExpressionVariable.cpp
+++ b/lldb/source/Expression/ExpressionVariable.cpp
@@ -34,6 +34,8 @@ uint8_t *ExpressionVariable::GetValueBytes() {
 
 char PersistentExpressionState::ID;
 
+PersistentExpressionState::PersistentExpressionState() = default;
+
 PersistentExpressionState::~PersistentExpressionState() = default;
 
 lldb::addr_t PersistentExpressionState::LookupSymbol(ConstString name) {



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


[Lldb-commits] [PATCH] D151501: [LLDB] Explicitly declare constructor in `PersistentExpressionState`

2023-05-26 Thread Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd01917c507a3: [LLDB] Explicitly declare constructor in 
`PersistentExpressionState` (authored by Laszlo Kindrat 
).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151501

Files:
  lldb/include/lldb/Expression/ExpressionVariable.h
  lldb/source/Expression/ExpressionVariable.cpp


Index: lldb/source/Expression/ExpressionVariable.cpp
===
--- lldb/source/Expression/ExpressionVariable.cpp
+++ lldb/source/Expression/ExpressionVariable.cpp
@@ -34,6 +34,8 @@
 
 char PersistentExpressionState::ID;
 
+PersistentExpressionState::PersistentExpressionState() = default;
+
 PersistentExpressionState::~PersistentExpressionState() = default;
 
 lldb::addr_t PersistentExpressionState::LookupSymbol(ConstString name) {
Index: lldb/include/lldb/Expression/ExpressionVariable.h
===
--- lldb/include/lldb/Expression/ExpressionVariable.h
+++ lldb/include/lldb/Expression/ExpressionVariable.h
@@ -207,6 +207,8 @@
   /// LLVM RTTI support
   static char ID;
 
+  PersistentExpressionState();
+
   virtual ~PersistentExpressionState();
 
   virtual lldb::ExpressionVariableSP


Index: lldb/source/Expression/ExpressionVariable.cpp
===
--- lldb/source/Expression/ExpressionVariable.cpp
+++ lldb/source/Expression/ExpressionVariable.cpp
@@ -34,6 +34,8 @@
 
 char PersistentExpressionState::ID;
 
+PersistentExpressionState::PersistentExpressionState() = default;
+
 PersistentExpressionState::~PersistentExpressionState() = default;
 
 lldb::addr_t PersistentExpressionState::LookupSymbol(ConstString name) {
Index: lldb/include/lldb/Expression/ExpressionVariable.h
===
--- lldb/include/lldb/Expression/ExpressionVariable.h
+++ lldb/include/lldb/Expression/ExpressionVariable.h
@@ -207,6 +207,8 @@
   /// LLVM RTTI support
   static char ID;
 
+  PersistentExpressionState();
+
   virtual ~PersistentExpressionState();
 
   virtual lldb::ExpressionVariableSP
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D140630: [lldb-vscode] Add data breakpoint support

2023-05-26 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.

This seems reasonable to me and I'm accepting it to unblock this feature. When 
Greg gets back he should be able to provide some additional comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140630

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


[Lldb-commits] [PATCH] D151524: [lldb][NFCI] Change type of SBDebugger::m_instance_name

2023-05-26 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151524

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


[Lldb-commits] [lldb] e31f994 - [lldb] Improve error message when evaluating expression when not stopped

2023-05-26 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-05-26T08:49:58-07:00
New Revision: e31f99464216ef4d04ffa821e174522b699780ee

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

LOG: [lldb] Improve error message when evaluating expression when not stopped

When trying to run an expression after a process has existed, you
currently are shown the following error message:

  (lldb) p strlen("")
  error: Can't make a function caller while the process is running

This error is wrong and pretty uninformative. After this patch, the
following error message is shown:

  (lldb) p strlen("")
  error: unable to evaluate expression while the process is exited: the
  process must be stopped because the expression might require
  allocating memory.

rdar://109731325

Differential revision: https://reviews.llvm.org/D151497

Added: 
lldb/test/Shell/Expr/TestExited.test

Modified: 
lldb/source/Expression/UserExpression.cpp
lldb/source/Expression/UtilityFunction.cpp

Removed: 




diff  --git a/lldb/source/Expression/UserExpression.cpp 
b/lldb/source/Expression/UserExpression.cpp
index 0c2d159d144a1..b250177db9979 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -39,6 +39,7 @@
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/State.h"
 #include "lldb/Utility/StreamString.h"
 
 using namespace lldb_private;
@@ -202,15 +203,18 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
 
 return execution_results;
   }
-  // Since we might need to call allocate memory and maybe call code to make
-  // the caller, we need to be stopped.
+
+  // Since we might need to allocate memory, we need to be stopped to run
+  // an expression.
   if (process != nullptr && process->GetState() != lldb::eStateStopped) {
-error.SetErrorString("Can't make a function caller while the process is " 
-  "running");
+error.SetErrorStringWithFormatv(
+"unable to evaluate expression while the process is {0}: the process "
+"must be stopped because the expression might require allocating "
+"memory.",
+StateAsCString(process->GetState()));
 return execution_results;
   }
 
-
   // Explicitly force the IR interpreter to evaluate the expression when the
   // there is no process that supports running the expression for us. Don't
   // change the execution policy if we have the special top-level policy that

diff  --git a/lldb/source/Expression/UtilityFunction.cpp 
b/lldb/source/Expression/UtilityFunction.cpp
index 5d55d9a5c2c1d..d317c1cd6c154 100644
--- a/lldb/source/Expression/UtilityFunction.cpp
+++ b/lldb/source/Expression/UtilityFunction.cpp
@@ -21,6 +21,7 @@
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/State.h"
 #include "lldb/Utility/Stream.h"
 
 using namespace lldb_private;
@@ -64,11 +65,13 @@ FunctionCaller *UtilityFunction::MakeFunctionCaller(
 error.SetErrorString("Can't make a function caller without a process.");
 return nullptr;
   }
-  // Since we might need to call allocate memory and maybe call code to make
+  // Since we might need to allocate memory and maybe call code to make
   // the caller, we need to be stopped.
   if (process_sp->GetState() != lldb::eStateStopped) {
-error.SetErrorString("Can't make a function caller while the process is " 
- "running");
+error.SetErrorStringWithFormatv(
+"Can't make a function caller while the process is {0}: the process "
+"must be stopped to allocate memory.",
+StateAsCString(process_sp->GetState()));
 return nullptr;
   }
 

diff  --git a/lldb/test/Shell/Expr/TestExited.test 
b/lldb/test/Shell/Expr/TestExited.test
new file mode 100644
index 0..ca83db06ff739
--- /dev/null
+++ b/lldb/test/Shell/Expr/TestExited.test
@@ -0,0 +1,3 @@
+# RUN: %clangxx_host %p/Inputs/call-function.cpp -g -o %t
+# RUN: %lldb %t -o 'r' -o 'expr strlen("")' 2>&1 | FileCheck %s
+# CHECK: error: unable to evaluate expression while the process is exited: the 
process must be stopped because the expression might require allocating memory.



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


[Lldb-commits] [PATCH] D151497: [lldb] Improve function caller error message

2023-05-26 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe31f99464216: [lldb] Improve error message when evaluating 
expression when not stopped (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D151497?vs=525861&id=526082#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151497

Files:
  lldb/source/Expression/UserExpression.cpp
  lldb/source/Expression/UtilityFunction.cpp
  lldb/test/Shell/Expr/TestExited.test


Index: lldb/test/Shell/Expr/TestExited.test
===
--- /dev/null
+++ lldb/test/Shell/Expr/TestExited.test
@@ -0,0 +1,3 @@
+# RUN: %clangxx_host %p/Inputs/call-function.cpp -g -o %t
+# RUN: %lldb %t -o 'r' -o 'expr strlen("")' 2>&1 | FileCheck %s
+# CHECK: error: unable to evaluate expression while the process is exited: the 
process must be stopped because the expression might require allocating memory.
Index: lldb/source/Expression/UtilityFunction.cpp
===
--- lldb/source/Expression/UtilityFunction.cpp
+++ lldb/source/Expression/UtilityFunction.cpp
@@ -21,6 +21,7 @@
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/State.h"
 #include "lldb/Utility/Stream.h"
 
 using namespace lldb_private;
@@ -64,11 +65,13 @@
 error.SetErrorString("Can't make a function caller without a process.");
 return nullptr;
   }
-  // Since we might need to call allocate memory and maybe call code to make
+  // Since we might need to allocate memory and maybe call code to make
   // the caller, we need to be stopped.
   if (process_sp->GetState() != lldb::eStateStopped) {
-error.SetErrorString("Can't make a function caller while the process is " 
- "running");
+error.SetErrorStringWithFormatv(
+"Can't make a function caller while the process is {0}: the process "
+"must be stopped to allocate memory.",
+StateAsCString(process_sp->GetState()));
 return nullptr;
   }
 
Index: lldb/source/Expression/UserExpression.cpp
===
--- lldb/source/Expression/UserExpression.cpp
+++ lldb/source/Expression/UserExpression.cpp
@@ -39,6 +39,7 @@
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/State.h"
 #include "lldb/Utility/StreamString.h"
 
 using namespace lldb_private;
@@ -202,15 +203,18 @@
 
 return execution_results;
   }
-  // Since we might need to call allocate memory and maybe call code to make
-  // the caller, we need to be stopped.
+
+  // Since we might need to allocate memory, we need to be stopped to run
+  // an expression.
   if (process != nullptr && process->GetState() != lldb::eStateStopped) {
-error.SetErrorString("Can't make a function caller while the process is " 
-  "running");
+error.SetErrorStringWithFormatv(
+"unable to evaluate expression while the process is {0}: the process "
+"must be stopped because the expression might require allocating "
+"memory.",
+StateAsCString(process->GetState()));
 return execution_results;
   }
 
-
   // Explicitly force the IR interpreter to evaluate the expression when the
   // there is no process that supports running the expression for us. Don't
   // change the execution policy if we have the special top-level policy that


Index: lldb/test/Shell/Expr/TestExited.test
===
--- /dev/null
+++ lldb/test/Shell/Expr/TestExited.test
@@ -0,0 +1,3 @@
+# RUN: %clangxx_host %p/Inputs/call-function.cpp -g -o %t
+# RUN: %lldb %t -o 'r' -o 'expr strlen("")' 2>&1 | FileCheck %s
+# CHECK: error: unable to evaluate expression while the process is exited: the process must be stopped because the expression might require allocating memory.
Index: lldb/source/Expression/UtilityFunction.cpp
===
--- lldb/source/Expression/UtilityFunction.cpp
+++ lldb/source/Expression/UtilityFunction.cpp
@@ -21,6 +21,7 @@
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/State.h"
 #include "lldb/Utility/Stream.h"
 
 using namespace lldb_private;
@@ -64,11 +65,13 @@
 error.SetErrorString("Can't make a function caller without a process.");
 return nullptr;
   }
-  // Since we might need to call allocate memory and maybe call code to make
+  // Since we might need to allocate memory and maybe call code to make
   // the caller, we need to be stopped.
   if (process_sp->GetState() != lldb::eStateStopped) {
-error.SetErrorString("Can't make a funct

[Lldb-commits] [PATCH] D151516: [lldb][NFCI] Remove use of ConstString from UnixSignals::SignalCode

2023-05-26 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151516

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


[Lldb-commits] [PATCH] D150805: Rate limit progress reporting

2023-05-26 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

My suggestion was to add rate limiting support to the listener so that all 
events could benefit from this. The current patch seems unnecessary ad-hoc: 
it's limited to (1) progress events and (2) the default event handler. I 
expects that lldb-vscode plugin users suffer from this as well for example.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150805

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


[Lldb-commits] [PATCH] D151269: [lldb] Pass CMAKE_SYSROOT through to LLDB shell tests

2023-05-26 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM. I suspect you'll run into the same problem when you get the API tests 
working, but we can deal with that when the time comes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151269

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


[Lldb-commits] [PATCH] D150772: Add code snippet line numbers to TestExprDiagnostics output

2023-05-26 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

I think this test could benefit from switching to string literals (`'''`) and 
doing a single `self.assertIn` rather than scanning the whole output for every 
line. Also please use `black` (version 23) to format the test.


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

https://reviews.llvm.org/D150772

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


[Lldb-commits] [PATCH] D150805: Rate limit progress reporting

2023-05-26 Thread Sterling Augustine via Phabricator via lldb-commits
saugustine abandoned this revision.
saugustine added a comment.

I'll let someone with a better understanding of the proper implementation take 
it from here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150805

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


[Lldb-commits] [lldb] a731c5f - [lldb] Remove reproducer test suite (NFC)

2023-05-26 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-05-26T09:33:40-07:00
New Revision: a731c5f01d5a7cd6bc150c11498fe46fbd5bab94

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

LOG: [lldb] Remove reproducer test suite (NFC)

The reproducer feature as well as the ability to capture or replay tests
with reproducers was removed. This removes the corresponding CMake
target.

Added: 


Modified: 
lldb/test/CMakeLists.txt

Removed: 




diff  --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 4cf796c94652..f215704db12c 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -260,27 +260,6 @@ add_lit_testsuite(check-lldb "Running lldb lit test suite"
 lldb-unit-test-deps)
 set_target_properties(check-lldb PROPERTIES FOLDER "lldb tests")
 
-# Add a lit test suite that runs the API & shell test while capturing a
-# reproducer.
-add_lit_testsuite(check-lldb-reproducers-capture
-  "Running lldb test suite with reproducer capture"
-  ${CMAKE_CURRENT_BINARY_DIR}/API
-  ${CMAKE_CURRENT_BINARY_DIR}/Shell
-  PARAMS "lldb-run-with-repro=capture"
-  EXCLUDE_FROM_CHECK_ALL
-  DEPENDS lldb-test-depends)
-
-# Add a lit test suite that runs the API & shell test by replaying a
-# reproducer.
-add_lit_testsuite(check-lldb-reproducers
-  "Running lldb test suite with reproducer replay"
-  ${CMAKE_CURRENT_BINARY_DIR}/API
-  ${CMAKE_CURRENT_BINARY_DIR}/Shell
-  PARAMS "lldb-run-with-repro=replay"
-  EXCLUDE_FROM_CHECK_ALL
-  DEPENDS lldb-test-depends)
-add_dependencies(check-lldb-reproducers check-lldb-reproducers-capture)
-
 if(LLDB_BUILT_STANDALONE)
   # This has to happen *AFTER* add_lit_testsuite.
   if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit)



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


[Lldb-commits] [PATCH] D151570: Fix Build error on Mac M1 : error: use of undeclared identifier 'getopt_long_only'; did you mean 'getopt_long'?

2023-05-26 Thread Nicklas Boman via Phabricator via lldb-commits
smurfd created this revision.
smurfd added a reviewer: LLDB.
Herald added a subscriber: krytarowski.
Herald added a project: All.
smurfd requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

I got build error on ma m1
`lldb/source/Host/common/OptionParser.cpp:46:10: error: use of undeclared 
identifier 'getopt_long_only'; did you mean 'getopt_long'?`

this patch fixes that, two includes needed and also check if `__APPLE__`. after 
that building works.

Please set reviewers correct if its not correct, first patch


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151570

Files:
  lldb/include/lldb/Host/common/GetOptInc.h
  lldb/source/Host/common/OptionParser.cpp
  lldb/tools/lldb-server/lldb-platform.cpp


Index: lldb/tools/lldb-server/lldb-platform.cpp
===
--- lldb/tools/lldb-server/lldb-platform.cpp
+++ lldb/tools/lldb-server/lldb-platform.cpp
@@ -36,6 +36,7 @@
 #include "lldb/Host/common/TCPSocket.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
+#include "lldb/Host/common/GetOptInc.h"
 
 using namespace lldb;
 using namespace lldb_private;
Index: lldb/source/Host/common/OptionParser.cpp
===
--- lldb/source/Host/common/OptionParser.cpp
+++ lldb/source/Host/common/OptionParser.cpp
@@ -10,7 +10,7 @@
 #include "lldb/Host/HostGetOpt.h"
 #include "lldb/Utility/OptionDefinition.h"
 #include "lldb/lldb-private-types.h"
-
+#include "lldb/Host/common/GetOptInc.h"
 #include 
 
 using namespace lldb_private;
Index: lldb/include/lldb/Host/common/GetOptInc.h
===
--- lldb/include/lldb/Host/common/GetOptInc.h
+++ lldb/include/lldb/Host/common/GetOptInc.h
@@ -15,7 +15,7 @@
 #define REPLACE_GETOPT
 #define REPLACE_GETOPT_LONG
 #endif
-#if defined(_MSC_VER) || defined(__NetBSD__)
+#if defined(_MSC_VER) || defined(__NetBSD__) || defined(__APPLE__)
 #define REPLACE_GETOPT_LONG_ONLY
 #endif
 


Index: lldb/tools/lldb-server/lldb-platform.cpp
===
--- lldb/tools/lldb-server/lldb-platform.cpp
+++ lldb/tools/lldb-server/lldb-platform.cpp
@@ -36,6 +36,7 @@
 #include "lldb/Host/common/TCPSocket.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
+#include "lldb/Host/common/GetOptInc.h"
 
 using namespace lldb;
 using namespace lldb_private;
Index: lldb/source/Host/common/OptionParser.cpp
===
--- lldb/source/Host/common/OptionParser.cpp
+++ lldb/source/Host/common/OptionParser.cpp
@@ -10,7 +10,7 @@
 #include "lldb/Host/HostGetOpt.h"
 #include "lldb/Utility/OptionDefinition.h"
 #include "lldb/lldb-private-types.h"
-
+#include "lldb/Host/common/GetOptInc.h"
 #include 
 
 using namespace lldb_private;
Index: lldb/include/lldb/Host/common/GetOptInc.h
===
--- lldb/include/lldb/Host/common/GetOptInc.h
+++ lldb/include/lldb/Host/common/GetOptInc.h
@@ -15,7 +15,7 @@
 #define REPLACE_GETOPT
 #define REPLACE_GETOPT_LONG
 #endif
-#if defined(_MSC_VER) || defined(__NetBSD__)
+#if defined(_MSC_VER) || defined(__NetBSD__) || defined(__APPLE__)
 #define REPLACE_GETOPT_LONG_ONLY
 #endif
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 877ddac - [lldb][NFCI] Include in SBDefines for FILE * definition

2023-05-26 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2023-05-26T10:56:17-07:00
New Revision: 877ddac051c4fc6b32e3e45b02dc628b018b381b

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

LOG: [lldb][NFCI] Include  in SBDefines for FILE * definition

There are a few API headers that use FILE * but do not include the
correct header for their definition. Instead of including  in each
of the headers manually, it seems easiest to include it in SBDefines to
get them all at once.

rdar://109579348

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

Added: 


Modified: 
lldb/include/lldb/API/SBDefines.h

Removed: 




diff  --git a/lldb/include/lldb/API/SBDefines.h 
b/lldb/include/lldb/API/SBDefines.h
index 15f808b29fa8d..15b25d08530b8 100644
--- a/lldb/include/lldb/API/SBDefines.h
+++ b/lldb/include/lldb/API/SBDefines.h
@@ -15,6 +15,8 @@
 #include "lldb/lldb-types.h"
 #include "lldb/lldb-versioning.h"
 
+#include  // For FILE *
+
 #ifndef LLDB_API
 #if defined(_WIN32)
 #if defined(LLDB_IN_LIBLLDB)



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


[Lldb-commits] [PATCH] D151381: [lldb][NFCI] Include in SBDefines for FILE * definition

2023-05-26 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG877ddac051c4: [lldb][NFCI] Include  in 
SBDefines for FILE * definition (authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151381

Files:
  lldb/include/lldb/API/SBDefines.h


Index: lldb/include/lldb/API/SBDefines.h
===
--- lldb/include/lldb/API/SBDefines.h
+++ lldb/include/lldb/API/SBDefines.h
@@ -15,6 +15,8 @@
 #include "lldb/lldb-types.h"
 #include "lldb/lldb-versioning.h"
 
+#include  // For FILE *
+
 #ifndef LLDB_API
 #if defined(_WIN32)
 #if defined(LLDB_IN_LIBLLDB)


Index: lldb/include/lldb/API/SBDefines.h
===
--- lldb/include/lldb/API/SBDefines.h
+++ lldb/include/lldb/API/SBDefines.h
@@ -15,6 +15,8 @@
 #include "lldb/lldb-types.h"
 #include "lldb/lldb-versioning.h"
 
+#include  // For FILE *
+
 #ifndef LLDB_API
 #if defined(_WIN32)
 #if defined(LLDB_IN_LIBLLDB)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D151269: [lldb] Pass CMAKE_SYSROOT through to LLDB shell tests

2023-05-26 Thread Daniel Thornburgh via Phabricator via lldb-commits
mysterymath updated this revision to Diff 526140.
mysterymath added a comment.

Apply black formatting to resolve merge conflict.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151269

Files:
  lldb/test/Shell/helper/build.py
  lldb/test/Shell/helper/toolchain.py
  lldb/test/Shell/lit.site.cfg.py.in


Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -13,6 +13,7 @@
 # Since it comes from the command line, it may have backslashes which
 # should not need to be escaped.
 config.lldb_lit_tools_dir = lit_config.substitute(r"@LLDB_LIT_TOOLS_DIR@")
+config.cmake_sysroot = lit_config.substitute("@CMAKE_SYSROOT@")
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
Index: lldb/test/Shell/helper/toolchain.py
===
--- lldb/test/Shell/helper/toolchain.py
+++ lldb/test/Shell/helper/toolchain.py
@@ -47,6 +47,8 @@
 build_script_args.append(
 '--objc-gnustep-dir="{0}"'.format(config.objc_gnustep_dir)
 )
+if config.cmake_sysroot:
+build_script_args.append("--sysroot={0}".format(config.cmake_sysroot))
 
 lldb_init = _get_lldb_init_path(config)
 
@@ -160,6 +162,9 @@
 # The clang module cache is used for building inferiors.
 host_flags += ["-fmodules-cache-path={}".format(config.clang_module_cache)]
 
+if config.cmake_sysroot:
+host_flags += ["--sysroot={}".format(config.cmake_sysroot)]
+
 host_flags = " ".join(host_flags)
 config.substitutions.append(("%clang_host", "%clang " + host_flags))
 config.substitutions.append(("%clangxx_host", "%clangxx " + host_flags))
Index: lldb/test/Shell/helper/build.py
===
--- lldb/test/Shell/helper/build.py
+++ lldb/test/Shell/helper/build.py
@@ -73,6 +73,14 @@
 help="Include and link GNUstep libobjc2 (Windows and Linux only)",
 )
 
+parser.add_argument(
+"--sysroot",
+metavar="directory",
+dest="sysroot",
+required=False,
+help="If specified, a sysroot to be passed via --sysroot",
+)
+
 if sys.platform == "darwin":
 parser.add_argument(
 "--apple-sdk",
@@ -305,6 +313,7 @@
 if args.objc_gnustep_dir
 else None
 )
+self.sysroot = args.sysroot
 
 def _exe_file_name(self):
 assert self.mode != "compile"
@@ -761,6 +770,8 @@
 args.extend(
 ["-Xclang", "-gcodeview", "-Xclang", 
"--dependent-lib=msvcrtd"]
 )
+elif self.sysroot:
+args.extend(["--sysroot", self.sysroot])
 
 if self.std:
 args.append("-std={0}".format(self.std))
@@ -797,6 +808,8 @@
 args.extend(
 ["-fuse-ld=lld-link", "-g", "-Xclang", 
"--dependent-lib=msvcrtd"]
 )
+elif self.sysroot:
+args.extend(["--sysroot", self.sysroot])
 
 return ("linking", self._obj_file_names(), self._exe_file_name(), 
None, args)
 


Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -13,6 +13,7 @@
 # Since it comes from the command line, it may have backslashes which
 # should not need to be escaped.
 config.lldb_lit_tools_dir = lit_config.substitute(r"@LLDB_LIT_TOOLS_DIR@")
+config.cmake_sysroot = lit_config.substitute("@CMAKE_SYSROOT@")
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
Index: lldb/test/Shell/helper/toolchain.py
===
--- lldb/test/Shell/helper/toolchain.py
+++ lldb/test/Shell/helper/toolchain.py
@@ -47,6 +47,8 @@
 build_script_args.append(
 '--objc-gnustep-dir="{0}"'.format(config.objc_gnustep_dir)
 )
+if config.cmake_sysroot:
+build_script_args.append("--sysroot={0}".format(config.cmake_sysroot))
 
 lldb_init = _get_lldb_init_path(config)
 
@@ -160,6 +162,9 @@
 # The clang module cache is used for building inferiors.
 host_flags += ["-fmodules-cache-path={}".format(config.clang_module_cache)]
 
+if config.cmake_sysroot:
+host_flags += ["--sysroot={}".format(config.cmake_sysroot)]
+
 host_flags = " ".join(host_flags)
 config.substitutions.append(("%clang_host", "%clang " + host_flags))
 config.substitutions.append(("%clangxx_host", "%clangxx " + host_flags))
Index: lldb/test/Shell/helper/build.py
===
--- lldb/test/Shell/helper/build.py
+++ lldb/

[Lldb-commits] [PATCH] D151269: [lldb] Pass CMAKE_SYSROOT through to LLDB shell tests

2023-05-26 Thread Daniel Thornburgh via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb22965df1304: [lldb] Pass CMAKE_SYSROOT through to LLDB 
shell tests (authored by mysterymath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151269

Files:
  lldb/test/Shell/helper/build.py
  lldb/test/Shell/helper/toolchain.py
  lldb/test/Shell/lit.site.cfg.py.in


Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -13,6 +13,7 @@
 # Since it comes from the command line, it may have backslashes which
 # should not need to be escaped.
 config.lldb_lit_tools_dir = lit_config.substitute(r"@LLDB_LIT_TOOLS_DIR@")
+config.cmake_sysroot = lit_config.substitute("@CMAKE_SYSROOT@")
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
Index: lldb/test/Shell/helper/toolchain.py
===
--- lldb/test/Shell/helper/toolchain.py
+++ lldb/test/Shell/helper/toolchain.py
@@ -47,6 +47,8 @@
 build_script_args.append(
 '--objc-gnustep-dir="{0}"'.format(config.objc_gnustep_dir)
 )
+if config.cmake_sysroot:
+build_script_args.append("--sysroot={0}".format(config.cmake_sysroot))
 
 lldb_init = _get_lldb_init_path(config)
 
@@ -160,6 +162,9 @@
 # The clang module cache is used for building inferiors.
 host_flags += ["-fmodules-cache-path={}".format(config.clang_module_cache)]
 
+if config.cmake_sysroot:
+host_flags += ["--sysroot={}".format(config.cmake_sysroot)]
+
 host_flags = " ".join(host_flags)
 config.substitutions.append(("%clang_host", "%clang " + host_flags))
 config.substitutions.append(("%clangxx_host", "%clangxx " + host_flags))
Index: lldb/test/Shell/helper/build.py
===
--- lldb/test/Shell/helper/build.py
+++ lldb/test/Shell/helper/build.py
@@ -73,6 +73,14 @@
 help="Include and link GNUstep libobjc2 (Windows and Linux only)",
 )
 
+parser.add_argument(
+"--sysroot",
+metavar="directory",
+dest="sysroot",
+required=False,
+help="If specified, a sysroot to be passed via --sysroot",
+)
+
 if sys.platform == "darwin":
 parser.add_argument(
 "--apple-sdk",
@@ -305,6 +313,7 @@
 if args.objc_gnustep_dir
 else None
 )
+self.sysroot = args.sysroot
 
 def _exe_file_name(self):
 assert self.mode != "compile"
@@ -761,6 +770,8 @@
 args.extend(
 ["-Xclang", "-gcodeview", "-Xclang", 
"--dependent-lib=msvcrtd"]
 )
+elif self.sysroot:
+args.extend(["--sysroot", self.sysroot])
 
 if self.std:
 args.append("-std={0}".format(self.std))
@@ -797,6 +808,8 @@
 args.extend(
 ["-fuse-ld=lld-link", "-g", "-Xclang", 
"--dependent-lib=msvcrtd"]
 )
+elif self.sysroot:
+args.extend(["--sysroot", self.sysroot])
 
 return ("linking", self._obj_file_names(), self._exe_file_name(), 
None, args)
 


Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -13,6 +13,7 @@
 # Since it comes from the command line, it may have backslashes which
 # should not need to be escaped.
 config.lldb_lit_tools_dir = lit_config.substitute(r"@LLDB_LIT_TOOLS_DIR@")
+config.cmake_sysroot = lit_config.substitute("@CMAKE_SYSROOT@")
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
Index: lldb/test/Shell/helper/toolchain.py
===
--- lldb/test/Shell/helper/toolchain.py
+++ lldb/test/Shell/helper/toolchain.py
@@ -47,6 +47,8 @@
 build_script_args.append(
 '--objc-gnustep-dir="{0}"'.format(config.objc_gnustep_dir)
 )
+if config.cmake_sysroot:
+build_script_args.append("--sysroot={0}".format(config.cmake_sysroot))
 
 lldb_init = _get_lldb_init_path(config)
 
@@ -160,6 +162,9 @@
 # The clang module cache is used for building inferiors.
 host_flags += ["-fmodules-cache-path={}".format(config.clang_module_cache)]
 
+if config.cmake_sysroot:
+host_flags += ["--sysroot={}".format(config.cmake_sysroot)]
+
 host_flags = " ".join(host_flags)
 config.substitutions.append(("%clang_host", "%clang " + host_flags))
 config.substitutions.append(("%clangxx_host", "%clangxx " + host_flags))
Index: lldb/test/Shell/helper/build.py

[Lldb-commits] [lldb] b22965d - [lldb] Pass CMAKE_SYSROOT through to LLDB shell tests

2023-05-26 Thread Daniel Thornburgh via lldb-commits

Author: Daniel Thornburgh
Date: 2023-05-26T11:30:33-07:00
New Revision: b22965df1304a752af2724f7c2c3c58347532e71

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

LOG: [lldb] Pass CMAKE_SYSROOT through to LLDB shell tests

This allows the LLDB Shell tests to succeed in (e.g. CI) environments where
system libraries are provided hermetically as a sysroot.

Reviewed By: JDevlieghere

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

Added: 


Modified: 
lldb/test/Shell/helper/build.py
lldb/test/Shell/helper/toolchain.py
lldb/test/Shell/lit.site.cfg.py.in

Removed: 




diff  --git a/lldb/test/Shell/helper/build.py b/lldb/test/Shell/helper/build.py
index 21e5d2f22316c..2a04967c89bc3 100755
--- a/lldb/test/Shell/helper/build.py
+++ b/lldb/test/Shell/helper/build.py
@@ -73,6 +73,14 @@
 help="Include and link GNUstep libobjc2 (Windows and Linux only)",
 )
 
+parser.add_argument(
+"--sysroot",
+metavar="directory",
+dest="sysroot",
+required=False,
+help="If specified, a sysroot to be passed via --sysroot",
+)
+
 if sys.platform == "darwin":
 parser.add_argument(
 "--apple-sdk",
@@ -305,6 +313,7 @@ def __init__(self, toolchain_type, args, obj_ext):
 if args.objc_gnustep_dir
 else None
 )
+self.sysroot = args.sysroot
 
 def _exe_file_name(self):
 assert self.mode != "compile"
@@ -761,6 +770,8 @@ def _get_compilation_command(self, source, obj):
 args.extend(
 ["-Xclang", "-gcodeview", "-Xclang", 
"--dependent-lib=msvcrtd"]
 )
+elif self.sysroot:
+args.extend(["--sysroot", self.sysroot])
 
 if self.std:
 args.append("-std={0}".format(self.std))
@@ -797,6 +808,8 @@ def _get_link_command(self):
 args.extend(
 ["-fuse-ld=lld-link", "-g", "-Xclang", 
"--dependent-lib=msvcrtd"]
 )
+elif self.sysroot:
+args.extend(["--sysroot", self.sysroot])
 
 return ("linking", self._obj_file_names(), self._exe_file_name(), 
None, args)
 

diff  --git a/lldb/test/Shell/helper/toolchain.py 
b/lldb/test/Shell/helper/toolchain.py
index 31d3f1295fb4e..8b56c659b13bf 100644
--- a/lldb/test/Shell/helper/toolchain.py
+++ b/lldb/test/Shell/helper/toolchain.py
@@ -47,6 +47,8 @@ def use_lldb_substitutions(config):
 build_script_args.append(
 '--objc-gnustep-dir="{0}"'.format(config.objc_gnustep_dir)
 )
+if config.cmake_sysroot:
+build_script_args.append("--sysroot={0}".format(config.cmake_sysroot))
 
 lldb_init = _get_lldb_init_path(config)
 
@@ -160,6 +162,9 @@ def use_support_substitutions(config):
 # The clang module cache is used for building inferiors.
 host_flags += ["-fmodules-cache-path={}".format(config.clang_module_cache)]
 
+if config.cmake_sysroot:
+host_flags += ["--sysroot={}".format(config.cmake_sysroot)]
+
 host_flags = " ".join(host_flags)
 config.substitutions.append(("%clang_host", "%clang " + host_flags))
 config.substitutions.append(("%clangxx_host", "%clangxx " + host_flags))

diff  --git a/lldb/test/Shell/lit.site.cfg.py.in 
b/lldb/test/Shell/lit.site.cfg.py.in
index f84cb60ff9404..736dfc335732b 100644
--- a/lldb/test/Shell/lit.site.cfg.py.in
+++ b/lldb/test/Shell/lit.site.cfg.py.in
@@ -13,6 +13,7 @@ config.lldb_tools_dir = 
lit_config.substitute("@LLDB_TOOLS_DIR@")
 # Since it comes from the command line, it may have backslashes which
 # should not need to be escaped.
 config.lldb_lit_tools_dir = lit_config.substitute(r"@LLDB_LIT_TOOLS_DIR@")
+config.cmake_sysroot = lit_config.substitute("@CMAKE_SYSROOT@")
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@



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


[Lldb-commits] [lldb] cefd280 - Make function static (NFC)

2023-05-26 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2023-05-26T13:12:12-07:00
New Revision: cefd2802aa49274942da87edf5019b5a23315f01

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

LOG: Make function static (NFC)

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 22298da9bf62..121a397b1c15 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -436,7 +436,7 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   return output.str();
 };
 
-llvm::Expected GetXcodeSDK(XcodeSDK sdk) {
+static llvm::Expected GetXcodeSDK(XcodeSDK sdk) {
   XcodeSDK::Info info = sdk.Parse();
   std::string sdk_name = XcodeSDK::GetCanonicalName(info);
   if (sdk_name.empty())



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


[Lldb-commits] [lldb] c45a649 - Revert "Make function static (NFC)"

2023-05-26 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2023-05-26T13:51:46-07:00
New Revision: c45a649a9697ed25834feae946db3b962395a62a

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

LOG: Revert "Make function static (NFC)"

This reverts commit cefd2802aa49274942da87edf5019b5a23315f01.

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 121a397b1c15..22298da9bf62 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -436,7 +436,7 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   return output.str();
 };
 
-static llvm::Expected GetXcodeSDK(XcodeSDK sdk) {
+llvm::Expected GetXcodeSDK(XcodeSDK sdk) {
   XcodeSDK::Info info = sdk.Parse();
   std::string sdk_name = XcodeSDK::GetCanonicalName(info);
   if (sdk_name.empty())



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


[Lldb-commits] [lldb] d9c898a - Revert "Factor out xcrun into a function (NFC)"

2023-05-26 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2023-05-26T13:51:46-07:00
New Revision: d9c898ab60b0b9291b23d66530961fe436a03a8a

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

LOG: Revert "Factor out xcrun into a function (NFC)"

This reverts commit 97ca34996dbe5a61e79d7c559af7b15dc39c08a5.

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 22298da9bf62e..5a39ed370747a 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -373,69 +373,6 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   return g_developer_directory;
 }
 
-static llvm::Expected
-xcrun(const std::string &sdk, llvm::ArrayRef arguments,
-  llvm::StringRef developer_dir = "") {
-  Args args;
-  if (!developer_dir.empty()) {
-args.AppendArgument("/usr/bin/env");
-args.AppendArgument("DEVELOPER_DIR=" + developer_dir.str());
-  }
-  args.AppendArgument("/usr/bin/xcrun");
-  args.AppendArgument("--sdk");
-  args.AppendArgument(sdk);
-  for (auto arg: arguments)
-args.AppendArguent(arg);
-
-  Log *log = GetLog(LLDBLog::Host);
-  if (log) {
-std::string cmdstr;
-args.GetCommandString(cmdstr);
-log->Printf("GetXcodeSDK() running shell cmd '%s'", cmdstr.c_str());
-  }
-
-  int status = 0;
-  int signo = 0;
-  std::string output_str;
-  // The first time after Xcode was updated or freshly installed,
-  // xcrun can take surprisingly long to build up its database.
-  auto timeout = std::chrono::seconds(60);
-  bool run_in_shell = false;
-  lldb_private::Status error = Host::RunShellCommand(
-  args, FileSpec(), &status, &signo, &output_str, timeout, run_in_shell);
-
-  // Check that xcrun returned something useful.
-  if (error.Fail()) {
-// Catastrophic error.
-LLDB_LOG(log, "xcrun failed to execute: %s", error.AsCString());
-return error.ToError();
-  }
-  if (status != 0) {
-// xcrun didn't find a matching SDK. Not an error, we'll try
-// 
diff erent spellings.
-LLDB_LOG(log, "xcrun returned exit code %d", status);
-return "";
-  }
-  if (output_str.empty()) {
-LLDB_LOG(log, "xcrun returned no results");
-return "";
-  }
-
-  // Convert to a StringRef so we can manipulate the string without modifying
-  // the underlying data.
-  llvm::StringRef output(output_str);
-
-  // Remove any trailing newline characters.
-  output = output.rtrim();
-
-  // Strip any leading newline characters and everything before them.
-  const size_t last_newline = output.rfind('\n');
-  if (last_newline != llvm::StringRef::npos)
-output = output.substr(last_newline + 1);
-
-  return output.str();
-};
-
 llvm::Expected GetXcodeSDK(XcodeSDK sdk) {
   XcodeSDK::Info info = sdk.Parse();
   std::string sdk_name = XcodeSDK::GetCanonicalName(info);
@@ -445,13 +382,75 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
 
   Log *log = GetLog(LLDBLog::Host);
 
+  auto xcrun = [](const std::string &sdk,
+  llvm::StringRef developer_dir =
+  "") -> llvm::Expected {
+Args args;
+if (!developer_dir.empty()) {
+  args.AppendArgument("/usr/bin/env");
+  args.AppendArgument("DEVELOPER_DIR=" + developer_dir.str());
+}
+args.AppendArgument("/usr/bin/xcrun");
+args.AppendArgument("--show-sdk-path");
+args.AppendArgument("--sdk");
+args.AppendArgument(sdk);
+
+Log *log = GetLog(LLDBLog::Host);
+if (log) {
+  std::string cmdstr;
+  args.GetCommandString(cmdstr);
+  log->Printf("GetXcodeSDK() running shell cmd '%s'", cmdstr.c_str());
+}
+
+int status = 0;
+int signo = 0;
+std::string output_str;
+// The first time after Xcode was updated or freshly installed,
+// xcrun can take surprisingly long to build up its database.
+auto timeout = std::chrono::seconds(60);
+bool run_in_shell = false;
+lldb_private::Status error = Host::RunShellCommand(
+args, FileSpec(), &status, &signo, &output_str, timeout, run_in_shell);
+
+// Check that xcrun returned something useful.
+if (error.Fail()) {
+  // Catastrophic error.
+  LLDB_LOG(log, "xcrun failed to execute: %s", error.AsCString());
+  return error.ToError();
+}
+if (status != 0) {
+  // xcrun didn't find a matching SDK. Not an error, we'll try
+  // 
diff erent spellings.
+  LLDB_LOG(log, "xcrun returned exit code %d", status);
+  return "";
+}
+if (output_str.empty()) {
+  LLDB_LOG(log, "xcrun returned no results");
+  return "";
+}
+
+// Convert to a StringRef so we can manipulate the string witho

[Lldb-commits] [PATCH] D151588: Factor out xcrun (NFC)

2023-05-26 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: JDevlieghere, bulbazord.
Herald added a project: All.
aprantl requested review of this revision.

https://reviews.llvm.org/D151588

Files:
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -373,84 +373,86 @@
   return g_developer_directory;
 }
 
-llvm::Expected GetXcodeSDK(XcodeSDK sdk) {
-  XcodeSDK::Info info = sdk.Parse();
-  std::string sdk_name = XcodeSDK::GetCanonicalName(info);
-  if (sdk_name.empty())
-return llvm::createStringError(llvm::inconvertibleErrorCode(),
-   "Unrecognized SDK type: " + sdk.GetString());
+static llvm::Expected
+xcrun(const std::string &sdk, llvm::ArrayRef arguments,
+  llvm::StringRef developer_dir = "") {
+  Args args;
+  if (!developer_dir.empty()) {
+args.AppendArgument("/usr/bin/env");
+args.AppendArgument("DEVELOPER_DIR=" + developer_dir.str());
+  }
+  args.AppendArgument("/usr/bin/xcrun");
+  args.AppendArgument("--sdk");
+  args.AppendArgument(sdk);
+  for (auto arg: arguments)
+args.AppendArgument(arg);
 
   Log *log = GetLog(LLDBLog::Host);
+  if (log) {
+std::string cmdstr;
+args.GetCommandString(cmdstr);
+log->Printf("GetXcodeSDK() running shell cmd '%s'", cmdstr.c_str());
+  }
 
-  auto xcrun = [](const std::string &sdk,
-  llvm::StringRef developer_dir =
-  "") -> llvm::Expected {
-Args args;
-if (!developer_dir.empty()) {
-  args.AppendArgument("/usr/bin/env");
-  args.AppendArgument("DEVELOPER_DIR=" + developer_dir.str());
-}
-args.AppendArgument("/usr/bin/xcrun");
-args.AppendArgument("--show-sdk-path");
-args.AppendArgument("--sdk");
-args.AppendArgument(sdk);
-
-Log *log = GetLog(LLDBLog::Host);
-if (log) {
-  std::string cmdstr;
-  args.GetCommandString(cmdstr);
-  log->Printf("GetXcodeSDK() running shell cmd '%s'", cmdstr.c_str());
-}
+  int status = 0;
+  int signo = 0;
+  std::string output_str;
+  // The first time after Xcode was updated or freshly installed,
+  // xcrun can take surprisingly long to build up its database.
+  auto timeout = std::chrono::seconds(60);
+  bool run_in_shell = false;
+  lldb_private::Status error = Host::RunShellCommand(
+  args, FileSpec(), &status, &signo, &output_str, timeout, run_in_shell);
+
+  // Check that xcrun returned something useful.
+  if (error.Fail()) {
+// Catastrophic error.
+LLDB_LOG(log, "xcrun failed to execute: %s", error.AsCString());
+return error.ToError();
+  }
+  if (status != 0) {
+// xcrun didn't find a matching SDK. Not an error, we'll try
+// different spellings.
+LLDB_LOG(log, "xcrun returned exit code %d", status);
+return "";
+  }
+  if (output_str.empty()) {
+LLDB_LOG(log, "xcrun returned no results");
+return "";
+  }
 
-int status = 0;
-int signo = 0;
-std::string output_str;
-// The first time after Xcode was updated or freshly installed,
-// xcrun can take surprisingly long to build up its database.
-auto timeout = std::chrono::seconds(60);
-bool run_in_shell = false;
-lldb_private::Status error = Host::RunShellCommand(
-args, FileSpec(), &status, &signo, &output_str, timeout, run_in_shell);
-
-// Check that xcrun returned something useful.
-if (error.Fail()) {
-  // Catastrophic error.
-  LLDB_LOG(log, "xcrun failed to execute: %s", error.AsCString());
-  return error.ToError();
-}
-if (status != 0) {
-  // xcrun didn't find a matching SDK. Not an error, we'll try
-  // different spellings.
-  LLDB_LOG(log, "xcrun returned exit code %d", status);
-  return "";
-}
-if (output_str.empty()) {
-  LLDB_LOG(log, "xcrun returned no results");
-  return "";
-}
+  // Convert to a StringRef so we can manipulate the string without modifying
+  // the underlying data.
+  llvm::StringRef output(output_str);
 
-// Convert to a StringRef so we can manipulate the string without modifying
-// the underlying data.
-llvm::StringRef output(output_str);
+  // Remove any trailing newline characters.
+  output = output.rtrim();
 
-// Remove any trailing newline characters.
-output = output.rtrim();
+  // Strip any leading newline characters and everything before them.
+  const size_t last_newline = output.rfind('\n');
+  if (last_newline != llvm::StringRef::npos)
+output = output.substr(last_newline + 1);
 
-// Strip any leading newline characters and everything before them.
-const size_t last_newline = output.rfind('\n');
-if (last_newline != llvm::StringRef::npos)
-  output = output.substr(last_newline + 1);
+  return output.str();
+}
 
-return output.str();
-  };
+static llv

[Lldb-commits] [PATCH] D151588: Factor out xcrun (NFC)

2023-05-26 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added a comment.

What is the motivation behind this change?

Also, why did you factor out `--show-sdk-path` into an argument? I assume you 
want to use `xcrun` for other purposes?


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

https://reviews.llvm.org/D151588

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


[Lldb-commits] [PATCH] D151588: Factor out xcrun (NFC)

2023-05-26 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 526194.

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

https://reviews.llvm.org/D151588

Files:
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -373,84 +373,86 @@
   return g_developer_directory;
 }
 
-llvm::Expected GetXcodeSDK(XcodeSDK sdk) {
-  XcodeSDK::Info info = sdk.Parse();
-  std::string sdk_name = XcodeSDK::GetCanonicalName(info);
-  if (sdk_name.empty())
-return llvm::createStringError(llvm::inconvertibleErrorCode(),
-   "Unrecognized SDK type: " + sdk.GetString());
+static llvm::Expected
+xcrun(const std::string &sdk, llvm::ArrayRef arguments,
+  llvm::StringRef developer_dir = "") {
+  Args args;
+  if (!developer_dir.empty()) {
+args.AppendArgument("/usr/bin/env");
+args.AppendArgument("DEVELOPER_DIR=" + developer_dir.str());
+  }
+  args.AppendArgument("/usr/bin/xcrun");
+  args.AppendArgument("--sdk");
+  args.AppendArgument(sdk);
+  for (auto arg: arguments)
+args.AppendArgument(arg);
 
   Log *log = GetLog(LLDBLog::Host);
+  if (log) {
+std::string cmdstr;
+args.GetCommandString(cmdstr);
+log->Printf("GetXcodeSDK() running shell cmd '%s'", cmdstr.c_str());
+  }
 
-  auto xcrun = [](const std::string &sdk,
-  llvm::StringRef developer_dir =
-  "") -> llvm::Expected {
-Args args;
-if (!developer_dir.empty()) {
-  args.AppendArgument("/usr/bin/env");
-  args.AppendArgument("DEVELOPER_DIR=" + developer_dir.str());
-}
-args.AppendArgument("/usr/bin/xcrun");
-args.AppendArgument("--show-sdk-path");
-args.AppendArgument("--sdk");
-args.AppendArgument(sdk);
-
-Log *log = GetLog(LLDBLog::Host);
-if (log) {
-  std::string cmdstr;
-  args.GetCommandString(cmdstr);
-  log->Printf("GetXcodeSDK() running shell cmd '%s'", cmdstr.c_str());
-}
+  int status = 0;
+  int signo = 0;
+  std::string output_str;
+  // The first time after Xcode was updated or freshly installed,
+  // xcrun can take surprisingly long to build up its database.
+  auto timeout = std::chrono::seconds(60);
+  bool run_in_shell = false;
+  lldb_private::Status error = Host::RunShellCommand(
+  args, FileSpec(), &status, &signo, &output_str, timeout, run_in_shell);
+
+  // Check that xcrun returned something useful.
+  if (error.Fail()) {
+// Catastrophic error.
+LLDB_LOG(log, "xcrun failed to execute: %s", error.AsCString());
+return error.ToError();
+  }
+  if (status != 0) {
+// xcrun didn't find a matching SDK. Not an error, we'll try
+// different spellings.
+LLDB_LOG(log, "xcrun returned exit code %d", status);
+return "";
+  }
+  if (output_str.empty()) {
+LLDB_LOG(log, "xcrun returned no results");
+return "";
+  }
 
-int status = 0;
-int signo = 0;
-std::string output_str;
-// The first time after Xcode was updated or freshly installed,
-// xcrun can take surprisingly long to build up its database.
-auto timeout = std::chrono::seconds(60);
-bool run_in_shell = false;
-lldb_private::Status error = Host::RunShellCommand(
-args, FileSpec(), &status, &signo, &output_str, timeout, run_in_shell);
-
-// Check that xcrun returned something useful.
-if (error.Fail()) {
-  // Catastrophic error.
-  LLDB_LOG(log, "xcrun failed to execute: %s", error.AsCString());
-  return error.ToError();
-}
-if (status != 0) {
-  // xcrun didn't find a matching SDK. Not an error, we'll try
-  // different spellings.
-  LLDB_LOG(log, "xcrun returned exit code %d", status);
-  return "";
-}
-if (output_str.empty()) {
-  LLDB_LOG(log, "xcrun returned no results");
-  return "";
-}
+  // Convert to a StringRef so we can manipulate the string without modifying
+  // the underlying data.
+  llvm::StringRef output(output_str);
 
-// Convert to a StringRef so we can manipulate the string without modifying
-// the underlying data.
-llvm::StringRef output(output_str);
+  // Remove any trailing newline characters.
+  output = output.rtrim();
 
-// Remove any trailing newline characters.
-output = output.rtrim();
+  // Strip any leading newline characters and everything before them.
+  const size_t last_newline = output.rfind('\n');
+  if (last_newline != llvm::StringRef::npos)
+output = output.substr(last_newline + 1);
 
-// Strip any leading newline characters and everything before them.
-const size_t last_newline = output.rfind('\n');
-if (last_newline != llvm::StringRef::npos)
-  output = output.substr(last_newline + 1);
+  return output.str();
+}
 
-return output.str();
-  };
+static llvm::Expected GetXcodeSDK(XcodeSDK sdk) {

[Lldb-commits] [PATCH] D151570: Fix Build error on Mac M1 : error: use of undeclared identifier 'getopt_long_only'; did you mean 'getopt_long'?

2023-05-26 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

What host compiler are you using when you see this error? `getopt_long_only` is 
available on macOS. Does this compile for you?

  #include 
  
  int main(int argc, char** argv)
  {
struct option longopts[] = {
  { "foo", required_argument, 0, 'f' },
};
int i;
return getopt_long_only(argc, argv, "l::m:r:d",
longopts, &i);
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151570

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


[Lldb-commits] [PATCH] D151591: HostInfoMacOS: Add a utility function for finding an SDK-specific tool

2023-05-26 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: bulbazord, JDevlieghere.
Herald added a project: All.
aprantl requested review of this revision.

This is an API needed by swift-lldb.


https://reviews.llvm.org/D151591

Files:
  lldb/include/lldb/Host/HostInfoBase.h
  lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
  lldb/unittests/Host/HostInfoTest.cpp

Index: lldb/unittests/Host/HostInfoTest.cpp
===
--- lldb/unittests/Host/HostInfoTest.cpp
+++ lldb/unittests/Host/HostInfoTest.cpp
@@ -72,6 +72,23 @@
   // This is expected to fail.
   EXPECT_TRUE(get_sdk("CeciNestPasUnOS.sdk", true).empty());
 }
+
+TEST_F(HostInfoTest, FindSDKTool) {
+  auto find_tool = [](std::string sdk, llvm::StringRef tool,
+  bool error = false) -> llvm::StringRef {
+auto sdk_path_or_err =
+HostInfo::FindSDKTool(XcodeSDK(std::move(sdk)), tool);
+if (!error) {
+  EXPECT_TRUE((bool)sdk_path_or_err);
+  return *sdk_path_or_err;
+}
+EXPECT_FALSE((bool)sdk_path_or_err);
+llvm::consumeError(sdk_path_or_err.takeError());
+return {};
+  };
+  EXPECT_FALSE(find_tool("MacOSX.sdk", "clang").empty());
+  EXPECT_TRUE(find_tool("MacOSX.sdk", "CeciNestPasUnOutil").empty());
+}
 #endif
 
 TEST(HostInfoTestInitialization, InitTwice) {
Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -522,36 +522,65 @@
   return path;
 }
 
-llvm::Expected HostInfoMacOSX::GetXcodeSDKPath(XcodeSDK sdk) {
-  struct ErrorOrPath {
-std::string str;
-bool is_error;
-  };
-  static llvm::StringMap g_sdk_path;
-  static std::mutex g_sdk_path_mutex;
+namespace {
+struct ErrorOrPath {
+  std::string str;
+  bool is_error;
+};
+} // namespace
 
-  std::lock_guard guard(g_sdk_path_mutex);
+static llvm::Expected
+find_cached_path(llvm::StringMap &cache, std::mutex &mutex,
+ llvm::StringRef key,
+ std::function(void)> compute) {
+  std::lock_guard guard(mutex);
   LLDB_SCOPED_TIMER();
 
-  auto key = sdk.GetString();
-  auto it = g_sdk_path.find(key);
-  if (it != g_sdk_path.end()) {
+  auto it = cache.find(key);
+  if (it != cache.end()) {
 if (it->second.is_error)
   return llvm::createStringError(llvm::inconvertibleErrorCode(),
  it->second.str);
-else
-  return it->second.str;
+return it->second.str;
   }
-  auto path_or_err = GetXcodeSDK(sdk);
+  auto path_or_err = compute();
   if (!path_or_err) {
 std::string error = toString(path_or_err.takeError());
-g_sdk_path.insert({key, {error, true}});
+cache.insert({key, {error, true}});
 return llvm::createStringError(llvm::inconvertibleErrorCode(), error);
   }
-  auto it_new = g_sdk_path.insert({key, {*path_or_err, false}});
+  auto it_new = cache.insert({key, {*path_or_err, false}});
   return it_new.first->second.str;
 }
 
+llvm::Expected HostInfoMacOSX::GetXcodeSDKPath(XcodeSDK sdk) {
+  static llvm::StringMap g_sdk_path;
+  static std::mutex g_sdk_path_mutex;
+  auto key = sdk.GetString();
+  return find_cached_path(g_sdk_path, g_sdk_path_mutex, key, [&](){
+return GetXcodeSDK(sdk);
+  });
+}
+
+llvm::Expected
+HostInfoMacOSX::FindSDKTool(XcodeSDK sdk, llvm::StringRef tool) {
+  static llvm::StringMap g_tool_path;
+  static std::mutex g_tool_path_mutex;
+  std::string key;
+  llvm::raw_string_ostream(key) << sdk.GetString() << ":" << tool;
+  return find_cached_path(
+  g_tool_path, g_tool_path_mutex, key,
+  [&]() -> llvm::Expected {
+std::string sdk_name = XcodeSDK::GetCanonicalName(sdk.Parse());
+if (sdk_name.empty())
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Unrecognized SDK type: " +
+ sdk.GetString());
+llvm::SmallVector find = {"-find", tool};
+return xcrun(sdk_name, find);
+  });
+}
+
 namespace {
 struct dyld_shared_cache_dylib_text_info {
   uint64_t version; // current version 1
Index: lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
===
--- lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
+++ lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
@@ -12,6 +12,7 @@
 #include "lldb/Host/posix/HostInfoPosix.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/XcodeSDK.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/VersionTuple.h"
 #include 
 
@@ -30,8 +31,9 @@
   static FileSpec GetXcodeContentsDirectory();
   static FileSpec GetXcodeDeveloperDirectory();
 
-  /// Query xcrun to find an Xcode SDK directory.
   static llvm::Expected GetXcodeSDKPath(XcodeSDK sdk);
+  static llvm::Expected FindSDKTool(XcodeSDK sdk,
+

[Lldb-commits] [PATCH] D151588: Factor out xcrun (NFC)

2023-05-26 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

In D151588#4377128 , @bulbazord wrote:

> What is the motivation behind this change?
>
> Also, why did you factor out `--show-sdk-path` into an argument? I assume you 
> want to use `xcrun` for other purposes?

This is in preparation for https://reviews.llvm.org/D151588


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

https://reviews.llvm.org/D151588

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


[Lldb-commits] [PATCH] D151591: HostInfoMacOS: Add a utility function for finding an SDK-specific tool

2023-05-26 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: lldb/unittests/Host/HostInfoTest.cpp:90
+  EXPECT_FALSE(find_tool("MacOSX.sdk", "clang").empty());
+  EXPECT_TRUE(find_tool("MacOSX.sdk", "CeciNestPasUnOutil").empty());
+}

LOL


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

https://reviews.llvm.org/D151591

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


[Lldb-commits] [PATCH] D151588: Factor out xcrun (NFC)

2023-05-26 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D151588

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


[Lldb-commits] [PATCH] D151588: Factor out xcrun (NFC)

2023-05-26 Thread Alex Langford via Phabricator via lldb-commits
bulbazord accepted this revision.
bulbazord added a comment.

Sounds good


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

https://reviews.llvm.org/D151588

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


[Lldb-commits] [lldb] f32d24d - Revert "[lldb] Disable variable watchpoints when going out of scope"

2023-05-26 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2023-05-26T15:32:10-07:00
New Revision: f32d24d57742054cd1131dfa5c21f363139bf59b

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

LOG: Revert "[lldb] Disable variable watchpoints when going out of scope"

Reverting https://reviews.llvm.org/D151366 until Ismail has a chance
to look at the ubuntu CI test failures and can reland.

This reverts commit 7c847ac4bd1bd8a89c7fbb4581328fa8cb0498f1.

Added: 


Modified: 
lldb/include/lldb/Breakpoint/Watchpoint.h
lldb/source/Breakpoint/Watchpoint.cpp
lldb/source/Commands/CommandObjectWatchpoint.cpp
lldb/test/Shell/ScriptInterpreter/Lua/watchpoint_callback.test

Removed: 
lldb/test/Shell/Watchpoint/Inputs/val.c
lldb/test/Shell/Watchpoint/Inputs/watchpoint.in
lldb/test/Shell/Watchpoint/LocalVariableWatchpointDisabler.test



diff  --git a/lldb/include/lldb/Breakpoint/Watchpoint.h 
b/lldb/include/lldb/Breakpoint/Watchpoint.h
index 3ee75516debe8..037be4539066c 100644
--- a/lldb/include/lldb/Breakpoint/Watchpoint.h
+++ b/lldb/include/lldb/Breakpoint/Watchpoint.h
@@ -90,40 +90,6 @@ class Watchpoint : public 
std::enable_shared_from_this,
   void SetWatchVariable(bool val);
   bool CaptureWatchedValue(const ExecutionContext &exe_ctx);
 
-  /// \struct WatchpointVariableContext
-  /// \brief Represents the context of a watchpoint variable.
-  ///
-  /// This struct encapsulates the information related to a watchpoint 
variable,
-  /// including the watch ID and the execution context in which it is being
-  /// used. This struct is passed as a Baton to the \b
-  /// VariableWatchpointDisabler breakpoint callback.
-  struct WatchpointVariableContext {
-/// \brief Constructor for WatchpointVariableContext.
-/// \param watch_id The ID of the watchpoint.
-/// \param exe_ctx The execution context associated with the watchpoint.
-WatchpointVariableContext(lldb::watch_id_t watch_id,
-  ExecutionContext exe_ctx)
-: watch_id(watch_id), exe_ctx(exe_ctx) {}
-
-lldb::watch_id_t watch_id; ///< The ID of the watchpoint.
-ExecutionContext
-exe_ctx; ///< The execution context associated with the watchpoint.
-  };
-
-  class WatchpointVariableBaton : public TypedBaton 
{
-  public:
-WatchpointVariableBaton(std::unique_ptr Data)
-: TypedBaton(std::move(Data)) {}
-  };
-
-  bool SetupVariableWatchpointDisabler(lldb::StackFrameSP frame_sp) const;
-
-  /// Callback routine to disable the watchpoint set on a local variable when
-  ///  it goes out of scope.
-  static bool VariableWatchpointDisabler(
-  void *baton, lldb_private::StoppointCallbackContext *context,
-  lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
-
   void GetDescription(Stream *s, lldb::DescriptionLevel level);
   void Dump(Stream *s) const override;
   void DumpSnapshots(Stream *s, const char *prefix = nullptr) const;

diff  --git a/lldb/source/Breakpoint/Watchpoint.cpp 
b/lldb/source/Breakpoint/Watchpoint.cpp
index fa95d6db6cc5e..d8b8bd505db95 100644
--- a/lldb/source/Breakpoint/Watchpoint.cpp
+++ b/lldb/source/Breakpoint/Watchpoint.cpp
@@ -83,94 +83,6 @@ void Watchpoint::SetCallback(WatchpointHitCallback callback,
   SendWatchpointChangedEvent(eWatchpointEventTypeCommandChanged);
 }
 
-bool Watchpoint::SetupVariableWatchpointDisabler(StackFrameSP frame_sp) const {
-  if (!frame_sp)
-return false;
-
-  ThreadSP thread_sp = frame_sp->GetThread();
-  if (!thread_sp)
-return false;
-
-  uint32_t return_frame_index =
-  thread_sp->GetSelectedFrameIndex(DoNoSelectMostRelevantFrame) + 1;
-  if (return_frame_index >= LLDB_INVALID_FRAME_ID)
-return false;
-
-  StackFrameSP return_frame_sp(
-  thread_sp->GetStackFrameAtIndex(return_frame_index));
-  if (!return_frame_sp)
-return false;
-
-  ExecutionContext exe_ctx(return_frame_sp);
-  TargetSP target_sp = exe_ctx.GetTargetSP();
-  if (!target_sp)
-return false;
-
-  Address return_address(return_frame_sp->GetFrameCodeAddress());
-  lldb::addr_t return_addr = return_address.GetLoadAddress(target_sp.get());
-  if (return_addr == LLDB_INVALID_ADDRESS)
-return false;
-
-  BreakpointSP bp_sp = target_sp->CreateBreakpoint(
-  return_addr, /*internal=*/true, /*request_hardware=*/false);
-  if (!bp_sp || !bp_sp->HasResolvedLocations())
-return false;
-
-  auto wvc_up = std::make_unique(GetID(), exe_ctx);
-  auto baton_sp = std::make_shared(std::move(wvc_up));
-  bp_sp->SetCallback(VariableWatchpointDisabler, baton_sp);
-  bp_sp->SetOneShot(true);
-  bp_sp->SetBreakpointKind("variable watchpoint disabler");
-  return true;
-}
-
-bool Watchpoint::VariableWatchpointDisabler(void *baton,
-StoppointCallbackContext *context,
-

[Lldb-commits] [PATCH] D151366: [lldb] Disable variable watchpoints when going out of scope

2023-05-26 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

In D151366#4375959 , @antmo wrote:

> Hi @mib,
> I think this broke lldb-arm-ubuntu bot (LocalVariableWatchpointDisabler.test 
> failure): https://lab.llvm.org/buildbot/#/builders/17/builds/38136
> Also visible on lldb-aarch64-windows here (TestVarPath.py issue is something 
> else): https://lab.llvm.org/buildbot/#/builders/219/builds/3048
> Could you please take a look ?

Thanks for pointing out the bot failures, I hadn't noticed them yet.  I've 
reverted Ismail's change until he can look into it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151366

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


[Lldb-commits] [PATCH] D151597: [lldb][NFCI] Remove use of ConstString from IOHandler

2023-05-26 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, jingham, mib, jasonmolenda.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

None of these need to be in the ConstString StringPool. For the most
part they are constant strings and do not require fast comparisons.

I did change IOHandlerDelegateMultiline slightly -- specifically, the
`m_end_line` member always has a `\n` at the end of it now. This was so
that `IOHandlerGetControlSequence` can always return a StringRef. This
did require a slight change to `IOHandlerIsInputComplete` where we must
drop the newline before comparing it against the input parameter.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151597

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Core/IOHandler.h
  lldb/include/lldb/Expression/REPL.h
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Expression/REPL.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -434,10 +434,11 @@
 
   ~IOHandlerPythonInterpreter() override = default;
 
-  ConstString GetControlSequence(char ch) override {
+  llvm::StringRef GetControlSequence(char ch) override {
+static constexpr llvm::StringLiteral control_sequence("quit()\n");
 if (ch == 'd')
-  return ConstString("quit()\n");
-return ConstString();
+  return control_sequence;
+return llvm::StringRef();
   }
 
   void Run() override {
Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -117,10 +117,11 @@
   return (m_enable_auto_indent ? GetAutoIndentCharacters() : nullptr);
 }
 
-ConstString REPL::IOHandlerGetControlSequence(char ch) {
+llvm::StringRef REPL::IOHandlerGetControlSequence(char ch) {
+  static constexpr llvm::StringLiteral control_sequence(":quit\n");
   if (ch == 'd')
-return ConstString(":quit\n");
-  return ConstString();
+return control_sequence;
+  return llvm::StringRef();
 }
 
 const char *REPL::IOHandlerGetCommandPrefix() { return ":"; }
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -1126,7 +1126,7 @@
   }
 }
 
-ConstString Debugger::GetTopIOHandlerControlSequence(char ch) {
+llvm::StringRef Debugger::GetTopIOHandlerControlSequence(char ch) {
   return m_io_handler_stack.GetTopIOHandlerControlSequence(ch);
 }
 
Index: lldb/source/API/SBCommandInterpreter.cpp
===
--- lldb/source/API/SBCommandInterpreter.cpp
+++ lldb/source/API/SBCommandInterpreter.cpp
@@ -155,11 +155,12 @@
 const char *SBCommandInterpreter::GetIOHandlerControlSequence(char ch) {
   LLDB_INSTRUMENT_VA(this, ch);
 
-  return (IsValid()
-  ? m_opaque_ptr->GetDebugger()
-.GetTopIOHandlerControlSequence(ch)
-.GetCString()
-  : nullptr);
+  if (!IsValid())
+return nullptr;
+
+  return ConstString(
+ m_opaque_ptr->GetDebugger().GetTopIOHandlerControlSequence(ch))
+  .GetCString();
 }
 
 lldb::ReturnStatus
Index: lldb/include/lldb/Interpreter/CommandInterpreter.h
===
--- lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -652,10 +652,11 @@
   void IOHandlerInputComplete(IOHandler &io_handler,
   std::string &line) override;
 
-  ConstString IOHandlerGetControlSequence(char ch) override {
+  llvm::StringRef IOHandlerGetControlSequence(char ch) override {
+static constexpr llvm::StringLiteral control_sequence("quit\n");
 if (ch == 'd')
-  return ConstString("quit\n");
-return ConstString();
+  return control_sequence;
+return llvm::StringRef();
   }
 
   void GetProcessOutput();
Index: lldb/include/lldb/Expression/REPL.h
===
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -88,7 +88,7 @@
 
   const char *IOHandlerGetFixIndentationCharacters() override;
 
-  ConstString IOHandlerGetControlSequence(char ch) override;
+  llvm::StringRef IOHandlerGetControlSequence(char ch) override;
 
   const char *IOHandlerGetCommandPrefix() override;
 
Index: lldb/include/lldb/Core/IOHandler.h
===

[Lldb-commits] [PATCH] D151570: Fix Build error on Mac M1 : error: use of undeclared identifier 'getopt_long_only'; did you mean 'getopt_long'?

2023-05-26 Thread Nicklas Boman via Phabricator via lldb-commits
smurfd added a comment.

Hey, yeah that compiles.
Im using the standard macos clang ,for Ventura 13.4, xcode 14.3

  $ gcc -v
  Apple clang version 14.0.3 (clang-1403.0.22.14.1)
  Target: arm64-apple-darwin22.5.0
  Thread model: posix
  InstalledDir: 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

this is the way i built llvm from git main from 
`https://github.com/llvm/llvm-project`

  $ rm -rf build && mkdir build && cd build
  $ cmake 
-DLLVM_ENABLE_PROJECTS="bolt;clang;clang-tools-extra;compiler-rt;lld;lldb;mlir;openmp;polly;flang"
 -DCMAKE_BUILD_TYPE=Release 
-DCMAKE_CXX_FLAGS="-D_GLIBCXX_HAVE_ENOTRECOVERABLE=1 -DENOTRECOVERABLE=98" -G 
"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$HOME/code/.build/llvm-dev -Bbuild 
-DLLVM_ENABLE_RUNTIMES="libunwind;libcxxabi;pstl;libcxx" ../llvm
  $ make -j8 -Cbuild

after the error i apply this patch and the build finishes.

im using this checkout : dd16cd731dfb4746a351380edc848199cf9631e8 
 (have 
also now tried main at the time of writing : 
a419ec4f256d279c91746a3962dd6dd2da45c304 
) with the 
same error

  [ 65%] Built target llvm-tapi-diff
  [ 65%] Building CXX object 
lib/DebugInfo/PDB/CMakeFiles/LLVMDebugInfoPDB.dir/PDB.cpp.o
  
/Users/hellbeard/code/_misc/llvm-project/lldb/source/Host/common/OptionParser.cpp:46:10:
 error: use of undeclared identifier 'getopt_long_only'; did you mean 
'getopt_long'?
return getopt_long_only(argv.size() - 1, argv.data(), opt_cstr.c_str(),
   ^~~~
   getopt_long
  /opt/pkg/include/getopt.h:62:5: note: 'getopt_long' declared here
  int getopt_long(int, char * const *, const char *,
  ^
  1 error generated.
  make[2]: *** 
[tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/OptionParser.cpp.o] 
Error 1
  make[2]: *** Waiting for unfinished jobs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151570

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


[Lldb-commits] [PATCH] D151599: [lldb][NFCI] Remove use of ConstString from StructuredDataDarwinLog static functions

2023-05-26 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, jingham, mib, jasonmolenda.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The strings "DarwinLog" and "log" probably do not need to be in the
ConstString StringPool. We still create ConstStrings from them in some
places (for now) but that's because we don't have an implicit
constructor to convert a StringRef to a ConstString.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151599

Files:
  lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp

Index: lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
===
--- lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
+++ lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
@@ -162,13 +162,13 @@
 // used to format message text
 };
 
-static ConstString GetDarwinLogTypeName() {
-  static const ConstString s_key_name("DarwinLog");
+static llvm::StringRef GetDarwinLogTypeName() {
+  static constexpr llvm::StringLiteral s_key_name("DarwinLog");
   return s_key_name;
 }
 
-static ConstString GetLogEventType() {
-  static const ConstString s_event_type("log");
+static llvm::StringRef GetLogEventType() {
+  static constexpr llvm::StringLiteral s_event_type("log");
   return s_event_type;
 }
 
@@ -799,8 +799,8 @@
 }
 
 // Get the plugin for the process.
-auto plugin_sp =
-process_sp->GetStructuredDataPlugin(GetDarwinLogTypeName());
+auto plugin_sp = process_sp->GetStructuredDataPlugin(
+ConstString(GetDarwinLogTypeName()));
 if (!plugin_sp || (plugin_sp->GetPluginName() !=
StructuredDataDarwinLog::GetStaticPluginName())) {
   result.AppendError("failed to get StructuredDataPlugin for "
@@ -822,8 +822,8 @@
 // Send configuration to the feature by way of the process. Construct the
 // options we will use.
 auto config_sp = m_options_sp->BuildConfigurationData(m_enable);
-const Status error =
-process_sp->ConfigureStructuredData(GetDarwinLogTypeName(), config_sp);
+const Status error = process_sp->ConfigureStructuredData(
+ConstString(GetDarwinLogTypeName()), config_sp);
 
 // Report results.
 if (!error.Success()) {
@@ -871,8 +871,8 @@
   stream.PutCString("Enabled: not applicable "
 "(requires process)\n");
 } else {
-  auto plugin_sp =
-  process_sp->GetStructuredDataPlugin(GetDarwinLogTypeName());
+  auto plugin_sp = process_sp->GetStructuredDataPlugin(
+  ConstString(GetDarwinLogTypeName()));
   stream.Printf("Availability: %s\n",
 plugin_sp ? "available" : "unavailable");
   llvm::StringRef plugin_name = StructuredDataDarwinLog::GetStaticPluginName();
@@ -1089,7 +1089,7 @@
 LLDB_LOGF(log,
   "StructuredDataDarwinLog::%s() StructuredData type "
   "expected to be %s but was %s, ignoring",
-  __FUNCTION__, GetDarwinLogTypeName().AsCString(),
+  __FUNCTION__, GetDarwinLogTypeName().str().c_str(),
   type_name.AsCString());
 return;
   }
@@ -1142,7 +1142,7 @@
   }
 
   // Validate this is really a message for our plugin.
-  ConstString type_name;
+  llvm::StringRef type_name;
   if (!dictionary->GetValueForKeyAsString("type", type_name)) {
 SetErrorWithJSON(error, "Structured data doesn't contain mandatory "
 "type field",
@@ -1490,12 +1490,13 @@
   LLDB_LOGF(log, "StructuredDataDarwinLog::%s() call is for process uid %d",
 __FUNCTION__, process_sp->GetUniqueID());
 
-  auto plugin_sp = process_sp->GetStructuredDataPlugin(GetDarwinLogTypeName());
+  auto plugin_sp =
+  process_sp->GetStructuredDataPlugin(ConstString(GetDarwinLogTypeName()));
   if (!plugin_sp) {
 LLDB_LOGF(log,
   "StructuredDataDarwinLog::%s() warning: no plugin for "
   "feature %s in process uid %u",
-  __FUNCTION__, GetDarwinLogTypeName().AsCString(),
+  __FUNCTION__, GetDarwinLogTypeName().str().c_str(),
   process_sp->GetUniqueID());
 return false;
   }
@@ -1736,7 +1737,7 @@
 size_t StructuredDataDarwinLog::HandleDisplayOfEvent(
 const StructuredData::Dictionary &event, Stream &stream) {
   // Check the type of the event.
-  ConstString event_type;
+  llvm::StringRef event_type;
   if (!event.GetValueForKeyAsString("type", event_type)) {
 // Hmm, we expected to get events that describe what they are.  Continue
 // anyway.
@@ -1836,8 +1837,8 @@
 
   // We can run it directly.
   // Send configuration to the feature by way of the process.
-  const Status error =
-  process_sp->ConfigureStructuredData(GetDarwinLogTypeName(), config_sp);
+  const Status error = process_sp->ConfigureSt

[Lldb-commits] [PATCH] D151603: [lldb][NFCI] Refactor Language::GetFormatterPrefixSuffix

2023-05-26 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, jingham, mib, aprantl, Michael137, 
kastiglione.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

- Remove unused parameter `valobj` (I checked downstream, not even swift is 
using it).
- Return a std::pair insted of having 2 out parameter 
strings.
- Remove the use of ConstStrings.

This change was primarily mechanical except in
`ObjCLanguage::GetFormatterPrefixSuffix`. To keep this fast, we
construct an llvm::StringMap> so that we
can look things up quickly. There is some amount of cost to setting up
the map the first time it is called, but subsequent lookups should be
as fast as a hash + string comparison (the cost of looking up something
in an llvm::StringMap).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151603

Files:
  lldb/include/lldb/Target/Language.h
  lldb/source/Plugins/Language/ObjC/CF.cpp
  lldb/source/Plugins/Language/ObjC/Cocoa.cpp
  lldb/source/Plugins/Language/ObjC/NSArray.cpp
  lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
  lldb/source/Plugins/Language/ObjC/NSSet.cpp
  lldb/source/Plugins/Language/ObjC/NSString.cpp
  lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
  lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
  lldb/source/Target/Language.cpp

Index: lldb/source/Target/Language.cpp
===
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -452,11 +452,9 @@
   return result;
 }
 
-bool Language::GetFormatterPrefixSuffix(ValueObject &valobj,
-ConstString type_hint,
-std::string &prefix,
-std::string &suffix) {
-  return false;
+std::pair
+Language::GetFormatterPrefixSuffix(llvm::StringRef type_hint) {
+  return std::pair();
 }
 
 bool Language::DemangledNameContainsPath(llvm::StringRef path, 
Index: lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
===
--- lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
+++ lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -150,9 +150,8 @@
 
   std::unique_ptr GetTypeScavenger() override;
 
-  bool GetFormatterPrefixSuffix(ValueObject &valobj, ConstString type_hint,
-std::string &prefix,
-std::string &suffix) override;
+  std::pair
+  GetFormatterPrefixSuffix(llvm::StringRef type_hint) override;
 
   bool IsNilReference(ValueObject &valobj) override;
 
Index: lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
===
--- lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -998,78 +998,41 @@
 ObjCDebugInfoScavenger>());
 }
 
-bool ObjCLanguage::GetFormatterPrefixSuffix(ValueObject &valobj,
-ConstString type_hint,
-std::string &prefix,
-std::string &suffix) {
-  static ConstString g_CFBag("CFBag");
-  static ConstString g_CFBinaryHeap("CFBinaryHeap");
-
-  static ConstString g_NSNumberChar("NSNumber:char");
-  static ConstString g_NSNumberShort("NSNumber:short");
-  static ConstString g_NSNumberInt("NSNumber:int");
-  static ConstString g_NSNumberLong("NSNumber:long");
-  static ConstString g_NSNumberInt128("NSNumber:int128_t");
-  static ConstString g_NSNumberFloat("NSNumber:float");
-  static ConstString g_NSNumberDouble("NSNumber:double");
-
-  static ConstString g_NSData("NSData");
-  static ConstString g_NSArray("NSArray");
-  static ConstString g_NSString("NSString");
-  static ConstString g_NSStringStar("NSString*");
-
-  if (type_hint.IsEmpty())
-return false;
-
-  prefix.clear();
-  suffix.clear();
-
-  if (type_hint == g_CFBag || type_hint == g_CFBinaryHeap) {
-prefix = "@";
-return true;
-  }
-
-  if (type_hint == g_NSNumberChar) {
-prefix = "(char)";
-return true;
-  }
-  if (type_hint == g_NSNumberShort) {
-prefix = "(short)";
-return true;
-  }
-  if (type_hint == g_NSNumberInt) {
-prefix = "(int)";
-return true;
-  }
-  if (type_hint == g_NSNumberLong) {
-prefix = "(long)";
-return true;
-  }
-  if (type_hint == g_NSNumberInt128) {
-prefix = "(int128_t)";
-return true;
-  }
-  if (type_hint == g_NSNumberFloat) {
-prefix = "(float)";
-return true;
-  }
-  if (type_hint == g_NSNumberDouble) {
-prefix = "(double)";
-return true;
-  }
-
-  if (type_hint == g_NSData || type_hint == g_NSArray) {
-prefix = "@\"";
-suffix = "\"";
-return true;
-  }
-
-  if (type_hint == g_NSString || type_hint == g_NSStringStar) {
-prefix = "@";
-return true;
-  }
+