[Lldb-commits] [PATCH] D150954: [lldb][cmake] Allow specifying custom libcxx for tests in standalone builds

2023-05-19 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added reviewers: aprantl, bulbazord, JDevlieghere.
Herald added a subscriber: ekilmer.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Standalone builds currently do not set the `LLDB_HAS_LIBCXX`,
`LIBCXX_LIBRARY_DIR`, `LIBCXX_GENERATED_INCLUDE_DIR`.
These are necessary for API tests with `USE_LIBCPP` to run against
a custom built libcxx. Thus on all buildbots using standalone builds
(most notably the public swift-ci), the API tests always run against
the libcxx headers in the system SDK.

This patch introduces a new cmake variable `LLDB_TEST_LIBCXX_ROOT_DIR`
that allows us to point the tests in standalone builds to a custom
libcxx directory.

Since the user can control the libcxx location we can hard error if
no such custom libcxx build exists.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150954

Files:
  lldb/test/CMakeLists.txt


Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -139,6 +139,9 @@
   )
 endif()
 
+set(LLDB_TEST_LIBCXX_ROOT_DIR "${LLVM_BINARY_DIR}" CACHE PATH
+"The build root for libcxx. Used in standalone builds to point the API 
tests to a custom build of libcxx.")
+
 # Add dependencies if we test with the in-tree clang.
 # This works with standalone builds as they import the clang target.
 if(TARGET clang)
@@ -169,9 +172,18 @@
 # FIXME: Standalone builds should import the cxx target as well.
 if(LLDB_BUILT_STANDALONE)
   # For now check that the include directory exists.
-  set(cxx_dir "${LLVM_BINARY_DIR}/include/c++")
-  if(NOT EXISTS ${cxx_dir})
-message(WARNING "LLDB test suite requires libc++ in 
llvm/projects/libcxx or an existing build symlinked to ${cxx_dir}")
+  set(cxx_dir "${LLDB_TEST_LIBCXX_ROOT_DIR}/include/c++")
+  if(EXISTS ${cxx_dir})
+# These variables make sure the API tests can run against a custom
+# build of libcxx even for standalone builds.
+set(LLDB_HAS_LIBCXX ON)
+set(LIBCXX_LIBRARY_DIR 
"${LLDB_TEST_LIBCXX_ROOT_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}")
+set(LIBCXX_GENERATED_INCLUDE_DIR 
"${LLDB_TEST_LIBCXX_ROOT_DIR}/include/c++/v1")
+  else()
+message(FATAL_ERROR
+"Couldn't find libcxx build in '${LLDB_TEST_LIBCXX_ROOT_DIR}'. To 
run the "
+"test-suite for a standalone LLDB build please build libcxx and 
point "
+"LLDB_TEST_LIBCXX_ROOT_DIR to it.")
   endif()
 else()
   # We require libcxx for the test suite, so if we aren't building it,


Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -139,6 +139,9 @@
   )
 endif()
 
+set(LLDB_TEST_LIBCXX_ROOT_DIR "${LLVM_BINARY_DIR}" CACHE PATH
+"The build root for libcxx. Used in standalone builds to point the API tests to a custom build of libcxx.")
+
 # Add dependencies if we test with the in-tree clang.
 # This works with standalone builds as they import the clang target.
 if(TARGET clang)
@@ -169,9 +172,18 @@
 # FIXME: Standalone builds should import the cxx target as well.
 if(LLDB_BUILT_STANDALONE)
   # For now check that the include directory exists.
-  set(cxx_dir "${LLVM_BINARY_DIR}/include/c++")
-  if(NOT EXISTS ${cxx_dir})
-message(WARNING "LLDB test suite requires libc++ in llvm/projects/libcxx or an existing build symlinked to ${cxx_dir}")
+  set(cxx_dir "${LLDB_TEST_LIBCXX_ROOT_DIR}/include/c++")
+  if(EXISTS ${cxx_dir})
+# These variables make sure the API tests can run against a custom
+# build of libcxx even for standalone builds.
+set(LLDB_HAS_LIBCXX ON)
+set(LIBCXX_LIBRARY_DIR "${LLDB_TEST_LIBCXX_ROOT_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}")
+set(LIBCXX_GENERATED_INCLUDE_DIR "${LLDB_TEST_LIBCXX_ROOT_DIR}/include/c++/v1")
+  else()
+message(FATAL_ERROR
+"Couldn't find libcxx build in '${LLDB_TEST_LIBCXX_ROOT_DIR}'. To run the "
+"test-suite for a standalone LLDB build please build libcxx and point "
+"LLDB_TEST_LIBCXX_ROOT_DIR to it.")
   endif()
 else()
   # We require libcxx for the test suite, so if we aren't building it,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D150954: [lldb][cmake] Allow specifying custom libcxx for tests in standalone builds

2023-05-19 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

Outstanding question would be whether we want to mirror this change in 
`utils/lldb-dotest/CMakeLists.txt`. If so, we should probably extract all this 
libcxx logic into a common helper between the two.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150954

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


[Lldb-commits] [PATCH] D144509: [CMake] Bumps minimum version to 3.20.0.

2023-05-19 Thread Hans Wennborg via Phabricator via lldb-commits
hans added a comment.

In D144509#4350052 , @Mordante wrote:

> In D144509#4349921 , @thakis wrote:
>
>> Reverted this and follow-ups in d763c6e5e2d0a6b34097aa7dabca31e9aff9b0b6 
>>  for 
>> now.
>>
>> Sorry this is such a pain to land :(
>>
>> (See also discussion over in D150688 )
>
> I'm not happy that the patch needs to be reverted again.
>
> It has taken me a lot of time to contact all buildbots maintainers to get all 
> buildbots updated to the minimal CMake requirement.

I sympathize with this, but I still believe reverting in these situations is 
the right thing to do. It reduces disruption for everyone who needs their 
builds to keep working, while allowing the failures to be investigated without 
the pressure of knowing that head is currently broken. That this patch has been 
hard to land is in the nature of the change itself.

> Now that they are updated it turned out that one of the two last updated bots 
> has an issue with this patch and that has been fixed. But now it seems to 
> break Chromium. I don't have access to Windows so I don't know how I can test 
> patches.

I'm happy to test patches on my Windows machine.

> Do you have a suggestion how we can move this patch forward?

IIRC, D150688  + the diff in 
https://github.com/llvm/llvm-project/issues/62719#issuecomment-1552903385 + 
upgrading the pre-merge linux bot should take care of all known issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144509

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


[Lldb-commits] [PATCH] D150954: [lldb][cmake] Allow specifying custom libcxx for tests in standalone builds

2023-05-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/test/CMakeLists.txt:142-143
 
+set(LLDB_TEST_LIBCXX_ROOT_DIR "${LLVM_BINARY_DIR}" CACHE PATH
+"The build root for libcxx. Used in standalone builds to point the API 
tests to a custom build of libcxx.")
+

If this is only necessary for the standalone build, then this should go in 
`cmake/modules/LLDBStandalone.cmake`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150954

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


[Lldb-commits] [PATCH] D150805: Proof of concept for reducing progress-reporting frequency.

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

In D150805#4351277 , @saugustine 
wrote:

> This update switches to a time-based approach as suggested by Jordan. 
> However, the timing is about the same as the original. I believe because 
> calling getCurrentTime every iteration is comparably slow as printing the 
> progress report itself.
>
> It probably is still a win over very slow connections, where printing is even 
> slower and time would remain the same.
>
> What would be ideal is a timing thread that wakes up every X seconds and 
> prints the results, but there isn't a good mechanism for that, and doing that 
> portably is way out of scope for this.

As I said in my previous comment, if we want to do anything timeout based it 
should be done in the the broadcaster/listener machinery so that other types of 
events can benefit from it too. I think the issue you're describing can be 
solved at that level, for example by blocking for a the desired time and 
flushing all but the last event received until that point.

> Shall we just switch to a percentage? Printing it every percent update?
>
> That has the issues Jordan described, where things appear to progress 
> quickly, and then may grind to a halt due to some big DIE.
>
> But I think the perfect shouldn't be the enemy of the good here.

Yes, that's definitely a shortcoming of this approach. What makes this somewhat 
less bad in my mind is that the inaccuracy is bounded by the granularity: e.g. 
something if you report every percentage, the error can never be more than a 
percentage. It would be nice if the consumer could set this property though, 
but I don't think there's a straightforward way to do that.

Adding support for a generic, user-specified, rate limit to the listeners would 
be my preferred solution, but I don't know how much work that would be.


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] D150954: [lldb][cmake] Allow specifying custom libcxx for tests in standalone builds

2023-05-19 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 523804.
Michael137 added a comment.

- Move variable into `LLDBStandalone.cmake`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150954

Files:
  lldb/cmake/modules/LLDBStandalone.cmake
  lldb/test/CMakeLists.txt


Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -169,9 +169,18 @@
 # FIXME: Standalone builds should import the cxx target as well.
 if(LLDB_BUILT_STANDALONE)
   # For now check that the include directory exists.
-  set(cxx_dir "${LLVM_BINARY_DIR}/include/c++")
-  if(NOT EXISTS ${cxx_dir})
-message(WARNING "LLDB test suite requires libc++ in 
llvm/projects/libcxx or an existing build symlinked to ${cxx_dir}")
+  set(cxx_dir "${LLDB_TEST_LIBCXX_ROOT_DIR}/include/c++")
+  if(EXISTS ${cxx_dir})
+# These variables make sure the API tests can run against a custom
+# build of libcxx even for standalone builds.
+set(LLDB_HAS_LIBCXX ON)
+set(LIBCXX_LIBRARY_DIR 
"${LLDB_TEST_LIBCXX_ROOT_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}")
+set(LIBCXX_GENERATED_INCLUDE_DIR 
"${LLDB_TEST_LIBCXX_ROOT_DIR}/include/c++/v1")
+  else()
+message(FATAL_ERROR
+"Couldn't find libcxx build in '${LLDB_TEST_LIBCXX_ROOT_DIR}'. To 
run the "
+"test-suite for a standalone LLDB build please build libcxx and 
point "
+"LLDB_TEST_LIBCXX_ROOT_DIR to it.")
   endif()
 else()
   # We require libcxx for the test suite, so if we aren't building it,
Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -16,6 +16,9 @@
 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_INCLUDE_DIR} CACHE PATH "Path to 
llvm/include")
 set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR} CACHE PATH "Path to LLVM build tree")
 
+set(LLDB_TEST_LIBCXX_ROOT_DIR "${LLVM_BINARY_DIR}" CACHE PATH
+"The build root for libcxx. Used in standalone builds to point the API 
tests to a custom build of libcxx.")
+
 set(LLVM_LIT_ARGS "-sv" CACHE STRING "Default options for lit")
 
 set(lit_file_name "llvm-lit")


Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -169,9 +169,18 @@
 # FIXME: Standalone builds should import the cxx target as well.
 if(LLDB_BUILT_STANDALONE)
   # For now check that the include directory exists.
-  set(cxx_dir "${LLVM_BINARY_DIR}/include/c++")
-  if(NOT EXISTS ${cxx_dir})
-message(WARNING "LLDB test suite requires libc++ in llvm/projects/libcxx or an existing build symlinked to ${cxx_dir}")
+  set(cxx_dir "${LLDB_TEST_LIBCXX_ROOT_DIR}/include/c++")
+  if(EXISTS ${cxx_dir})
+# These variables make sure the API tests can run against a custom
+# build of libcxx even for standalone builds.
+set(LLDB_HAS_LIBCXX ON)
+set(LIBCXX_LIBRARY_DIR "${LLDB_TEST_LIBCXX_ROOT_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}")
+set(LIBCXX_GENERATED_INCLUDE_DIR "${LLDB_TEST_LIBCXX_ROOT_DIR}/include/c++/v1")
+  else()
+message(FATAL_ERROR
+"Couldn't find libcxx build in '${LLDB_TEST_LIBCXX_ROOT_DIR}'. To run the "
+"test-suite for a standalone LLDB build please build libcxx and point "
+"LLDB_TEST_LIBCXX_ROOT_DIR to it.")
   endif()
 else()
   # We require libcxx for the test suite, so if we aren't building it,
Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -16,6 +16,9 @@
 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
 set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR} CACHE PATH "Path to LLVM build tree")
 
+set(LLDB_TEST_LIBCXX_ROOT_DIR "${LLVM_BINARY_DIR}" CACHE PATH
+"The build root for libcxx. Used in standalone builds to point the API tests to a custom build of libcxx.")
+
 set(LLVM_LIT_ARGS "-sv" CACHE STRING "Default options for lit")
 
 set(lit_file_name "llvm-lit")
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D144509: [CMake] Bumps minimum version to 3.20.0.

2023-05-19 Thread Mark de Wever via Phabricator via lldb-commits
Mordante added a comment.

In D144509#4356160 , @hans wrote:

> In D144509#4350052 , @Mordante 
> wrote:
>
>> In D144509#4349921 , @thakis wrote:
>>
>>> Reverted this and follow-ups in d763c6e5e2d0a6b34097aa7dabca31e9aff9b0b6 
>>>  for 
>>> now.
>>>
>>> Sorry this is such a pain to land :(
>>>
>>> (See also discussion over in D150688 )
>>
>> I'm not happy that the patch needs to be reverted again.
>>
>> It has taken me a lot of time to contact all buildbots maintainers to get 
>> all buildbots updated to the minimal CMake requirement.
>
> I sympathize with this, but I still believe reverting in these situations is 
> the right thing to do. It reduces disruption for everyone who needs their 
> builds to keep working, while allowing the failures to be investigated 
> without the pressure of knowing that head is currently broken. That this 
> patch has been hard to land is in the nature of the change itself.

I'm caught quite off-guard that it seems the LLVM buildbots don't cover our 
Windows support that well. It would also be great to know how we can improve 
the process to update dependency versions. The current way does not really 
encourage me to propose LLVM wide updates again.

>> Now that they are updated it turned out that one of the two last updated 
>> bots has an issue with this patch and that has been fixed. But now it seems 
>> to break Chromium. I don't have access to Windows so I don't know how I can 
>> test patches.
>
> I'm happy to test patches on my Windows machine.

Thanks!

>> Do you have a suggestion how we can move this patch forward?
>
> IIRC, D150688  + the diff in 
> https://github.com/llvm/llvm-project/issues/62719#issuecomment-1552903385 + 
> upgrading the pre-merge linux bot should take care of all known issues.

Would it make sense to put all these patches in one new review and then test 
that on Chromium and ask @glandium to test that too. Then we know whether it 
solves the issues. Do you want me to make a patch or do you want to do it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144509

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


[Lldb-commits] [lldb] aa2c2c8 - Work around a modularization issue in the Python headers.

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

Author: Adrian Prantl
Date: 2023-05-19T10:22:51-07:00
New Revision: aa2c2c8e3c3fe74f2b374b3fdc703ca7b05f80a0

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

LOG: Work around a modularization issue in the Python headers.

Added: 


Modified: 
lldb/source/API/CMakeLists.txt
lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
lldb/unittests/ScriptInterpreter/Python/CMakeLists.txt

Removed: 




diff  --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 3e189f387f1ca..238372bdcab19 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -6,6 +6,11 @@ if(LLDB_BUILD_FRAMEWORK)
 endif()
 
 if(LLDB_ENABLE_PYTHON)
+  if (APPLE AND LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY)
+# Work around an issue with the Python headers, which have a modular 
include
+# inside an extern "C" block.
+remove_module_flags()
+  endif()
   get_target_property(python_bindings_dir swig_wrapper_python BINARY_DIR)
   set(lldb_python_wrapper ${python_bindings_dir}/LLDBWrapPython.cpp)
 endif()

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt 
b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
index d59b7bbf65a28..7236116696424 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
@@ -1,3 +1,9 @@
+if (APPLE AND LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY)
+  # Work around an issue with the Python headers, which have a modular include
+  # inside an extern "C" block.
+  remove_module_flags()
+endif()
+
 if(NOT LLDB_PYTHON_RELATIVE_PATH)
   message(FATAL_ERROR "LLDB_PYTHON_RELATIVE_PATH is not set.")
 endif()

diff  --git a/lldb/unittests/ScriptInterpreter/Python/CMakeLists.txt 
b/lldb/unittests/ScriptInterpreter/Python/CMakeLists.txt
index 90a53bf175105..daaf40dceff1d 100644
--- a/lldb/unittests/ScriptInterpreter/Python/CMakeLists.txt
+++ b/lldb/unittests/ScriptInterpreter/Python/CMakeLists.txt
@@ -1,3 +1,9 @@
+if (APPLE AND LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY)
+  # Work around an issue with the Python headers, which have a modular include
+  # inside an extern "C" block.
+  remove_module_flags()
+endif()
+
 add_lldb_unittest(ScriptInterpreterPythonTests
   PythonDataObjectsTests.cpp
   PythonTestSuite.cpp



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


[Lldb-commits] [PATCH] D150954: [lldb][cmake] Allow specifying custom libcxx for tests in standalone builds

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150954

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


[Lldb-commits] [lldb] 85cb7fb - Relax test

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

Author: Adrian Prantl
Date: 2023-05-19T10:52:00-07:00
New Revision: 85cb7fbc07e3a974e5c2580e650f61177c941a76

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

LOG: Relax test

Added: 


Modified: 
lldb/test/Shell/BuildScript/toolchain-clang.test

Removed: 




diff  --git a/lldb/test/Shell/BuildScript/toolchain-clang.test 
b/lldb/test/Shell/BuildScript/toolchain-clang.test
index 1eaf7064065d6..3b2c8b0660bb7 100644
--- a/lldb/test/Shell/BuildScript/toolchain-clang.test
+++ b/lldb/test/Shell/BuildScript/toolchain-clang.test
@@ -7,8 +7,8 @@ RUN:| FileCheck --check-prefix=CHECK 
--check-prefix=CHECK-64 %s
 CHECK: Cleaning {{.*}}toolchain-clang.test.tmp{{.}}foo.exe-foobar.o
 CHECK: Cleaning {{.*}}toolchain-clang.test.tmp{{.}}foo.exe
 CHECK: compiling foobar.c -> foo.exe-foobar.o
-CHECK-32: {{.*}}clang++{{(\.EXE)?}} -m32 -g -O0 -c -o {{.*}}foo.exe-foobar.o 
{{.*}}foobar.c
-CHECK-64: {{.*}}clang++{{(\.EXE)?}} -m64 -g -O0 -c -o {{.*}}foo.exe-foobar.o 
{{.*}}foobar.c
+CHECK-32: {{.*}}clang++{{(\.EXE)?}} -m32 -g -O0 -c {{.*}}-o 
{{.*}}foo.exe-foobar.o {{.*}}foobar.c
+CHECK-64: {{.*}}clang++{{(\.EXE)?}} -m64 -g -O0 -c {{.*}}-o 
{{.*}}foo.exe-foobar.o {{.*}}foobar.c
 CHECK: linking foo.exe-foobar.o -> foo.exe
 CHECK-32: {{.*}}clang++{{(\.EXE)?}} -m32 {{(-L.* )?(-Wl,-rpath,.* )?}}-o 
{{.*}}foo.exe {{.*}}foo.exe-foobar.o
 CHECK-64: {{.*}}clang++{{(\.EXE)?}} -m64 {{(-L.* )?(-Wl,-rpath,.* )?}}-o 
{{.*}}foo.exe {{.*}}foo.exe-foobar.o



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


[Lldb-commits] [lldb] 3c4f16b - [lldb][NFCI] Consolidate segment names in ObjectFileMachO

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

Author: Alex Langford
Date: 2023-05-19T13:06:40-07:00
New Revision: 3c4f16b6cab2964702d70a4834ea631bed7daaca

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

LOG: [lldb][NFCI] Consolidate segment names in ObjectFileMachO

We have static functions for each one, we should use them where it makes
sense.

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 150dde8304cb8..dfd5ae728cefb 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1362,9 +1362,11 @@ void ObjectFileMachO::SanitizeSegmentCommand(
 // shared cache file, and not the specific image we are
 // examining. Let's fix this up so that it looks like a normal
 // image.
-if (strncmp(seg_cmd.segname, "__TEXT", sizeof(seg_cmd.segname)) == 0)
+if (strncmp(seg_cmd.segname, GetSegmentNameTEXT().GetCString(),
+sizeof(seg_cmd.segname)) == 0)
   m_text_address = seg_cmd.vmaddr;
-if (strncmp(seg_cmd.segname, "__LINKEDIT", sizeof(seg_cmd.segname)) == 0)
+if (strncmp(seg_cmd.segname, GetSegmentNameLINKEDIT().GetCString(),
+sizeof(seg_cmd.segname)) == 0)
   m_linkedit_original_offset = seg_cmd.fileoff;
 
 seg_cmd.fileoff = seg_cmd.vmaddr - m_text_address;
@@ -2606,9 +2608,8 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   std::set resolver_addresses;
 
   if (dyld_trie_data.GetByteSize() > 0) {
-ConstString text_segment_name("__TEXT");
 SectionSP text_segment_sp =
-GetSectionList()->FindSectionByName(text_segment_name);
+GetSectionList()->FindSectionByName(GetSegmentNameTEXT());
 lldb::addr_t text_segment_file_addr = LLDB_INVALID_ADDRESS;
 if (text_segment_sp)
   text_segment_file_addr = text_segment_sp->GetFileAddress();
@@ -5270,10 +5271,9 @@ lldb_private::Address 
ObjectFileMachO::GetEntryPointAddress() {
 }
   } break;
   case LC_MAIN: {
-ConstString text_segment_name("__TEXT");
 uint64_t entryoffset = m_data.GetU64(&offset);
 SectionSP text_segment_sp =
-GetSectionList()->FindSectionByName(text_segment_name);
+GetSectionList()->FindSectionByName(GetSegmentNameTEXT());
 if (text_segment_sp) {
   done = true;
   start_address = text_segment_sp->GetFileAddress() + entryoffset;



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


[Lldb-commits] [PATCH] D150996: LLVM_FALLTHROUGH => [[fallthrough]]. NFC

2023-05-19 Thread Craig Topper via Phabricator via lldb-commits
craig.topper created this revision.
craig.topper added a reviewer: MaskRay.
Herald added subscribers: ThomasRaoux, kbarton, hiraditya, nemanjai.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a reviewer: zuban32.
Herald added subscribers: lldb-commits, cfe-commits, pcwang-thead.
Herald added a reviewer: mpaszkowski.
Herald added projects: clang, LLDB, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150996

Files:
  clang/lib/AST/TemplateBase.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Sema/SemaChecking.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  llvm/lib/Analysis/MemoryLocation.cpp
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
  llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCRegisterInfo.h
  llvm/lib/Target/SPIRV/SPIRVISelLowering.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8487,7 +8487,7 @@
   Ops[1] = SafeRHS;
   return new VPWidenRecipe(*I, make_range(Ops.begin(), Ops.end()));
 }
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   }
   case Instruction::Add:
   case Instruction::And:
Index: llvm/lib/Target/SPIRV/SPIRVISelLowering.cpp
===
--- llvm/lib/Target/SPIRV/SPIRVISelLowering.cpp
+++ llvm/lib/Target/SPIRV/SPIRVISelLowering.cpp
@@ -55,7 +55,7 @@
   switch (Intrinsic) {
   case Intrinsic::spv_load:
 AlignIdx = 2;
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case Intrinsic::spv_store: {
 if (I.getNumOperands() >= AlignIdx + 1) {
   auto *AlignOp = cast(I.getOperand(AlignIdx));
Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.h
===
--- llvm/lib/Target/PowerPC/PPCRegisterInfo.h
+++ llvm/lib/Target/PowerPC/PPCRegisterInfo.h
@@ -183,7 +183,7 @@
   case 'f':
 if (RegName[1] == 'p')
   return RegName + 2;
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case 'r':
   case 'v':
 if (RegName[1] == 's') {
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -10686,7 +10686,7 @@
   RetOps.push_back(Extract);
   return DAG.getMergeValues(RetOps, dl);
 }
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   }
   case Intrinsic::ppc_vsx_disassemble_pair: {
 int NumVecs = 2;
Index: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
+++ llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
@@ -3994,7 +3994,7 @@
   if (SRLConst && SRLConst->getSExtValue() == 16)
 return false;
 }
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case ISD::ROTL:
   case ISD::SHL:
   case ISD::AND:
Index: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
===
--- llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -2523,7 +2523,7 @@
   return 2 * LT.first;
 if (!Ty->getScalarType()->isFP128Ty())
   return LT.first;
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case ISD::FMUL:
   case ISD::FDIV:
 // These nodes are marked as 'custom' just to lower them to SVE.
Index: llvm/lib/ProfileData/InstrProf.cpp
===
--- llvm/lib/ProfileData/InstrProf.cpp
+++ llvm/lib/ProfileData/InstrProf.cpp
@@ -1385,7 +1385,7 @@
   case 10ull:
 H.TemporalProfTracesOffset =
 read(Buffer, offsetOf(&Header::TemporalProfTracesOffset));
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case 9ull:
 H.BinaryIdOffset = read(Buffer, offsetOf(&Header::BinaryIdOffset));
 [[fallthrough]];
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -2420,7 +2420,7 @@
   case OMPScheduleType::BaseRuntimeSimd:
 assert(!ChunkSize &&
"schedule type does not support user-defined chunk sizes");
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case OMPScheduleType::BaseDynamicChunked:
   case OMPScheduleType::BaseGuidedChunked:
   case OMPScheduleType::BaseGuidedIterativeChunked:
Index: llvm/lib/DebugInfo/LogicalView/

[Lldb-commits] [PATCH] D146765: [lldb/crashlog] Load inlined symbol into interactive crashlog

2023-05-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 523948.
mib added a comment.

Address feedbacks:

- Simplify and Improve regex
- Add test


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

https://reviews.llvm.org/D146765

Files:
  lldb/examples/python/crashlog.py
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_json.test
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
@@ -0,0 +1,43 @@
+# REQUIRES: python, native && target-aarch64 && system-darwin
+
+# RUN: mkdir -p %t.dir
+# RUN: yaml2obj %S/Inputs/interactive_crashlog/multithread-test.yaml > %t.dir/multithread-test
+# RUN: %lldb -o 'command script import lldb.macosx.crashlog' \
+# RUN: -o 'crashlog -a -i -t %t.dir/multithread-test %S/Inputs/interactive_crashlog/multithread-test.crash' \
+# RUN: -o "thread list" -o "bt all" 2>&1 | FileCheck %s
+
+# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
+
+# CHECK: (lldb) process status
+# CHECK-NEXT: Process 22511 stopped
+# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
+# CHECK-NEXT: frame #0: 0x000100ec58f4 multithread-test`bar
+
+# CHECK: (lldb) thread backtrace
+# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
+# CHECK-NEXT:   * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} [artificial]
+# CHECK-NEXT: frame #1: 0x000100ec591b multithread-test`foo{{.*}} [artificial]
+# CHECK-NEXT: frame #2: 0x000100ec5a87 multithread-test`compute_pow{{.*}} [artificial]
+
+# CHECK: (lldb) thread list
+# CHECK-NEXT: Process 22511 stopped
+# CHECK-NEXT:   thread #1: tid = 0x, 0x00019cc40b84{{.*}}
+# CHECK-NEXT:   thread #2: tid = 0x0001, 0x00019cc42c9c{{.*}}
+# CHECK-NEXT: * thread #3: tid = 0x0002, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
+
+# CHECK: (lldb) bt all
+# CHECK:  thread #1
+# CHECK:frame #{{[0-9]+}}: 0x00019cc40b84{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x000100ec5b3b multithread-test`main{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x0002230f8da7{{.*}} [artificial]
+# CHECK-NEXT:  thread #2
+# CHECK-NEXT:frame #0: 0x00019cc42c9c{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x000100ec5957 multithread-test`call_and_wait{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc7e06b{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc78e2b{{.*}} [artificial]
+# CHECK-NEXT:* thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
+# CHECK-NEXT:  * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} [artificial]
+# CHECK-NEXT:frame #1: 0x000100ec591b multithread-test`foo{{.*}} [artificial]
+# CHECK-NEXT:frame #2: 0x000100ec5a87 multithread-test`compute_pow{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc7e06b{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc78e2b{{.*}} [artificial]
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash
@@ -0,0 +1,140 @@
+Process:   multithread-test [22511]
+Path:  /Users/USER/*/multithread-test
+Identifier:multithread-test
+Version:   ???
+Code Type: ARM-64 (Native)
+Parent Process:zsh [59146]
+Responsible:   Terminal [1640]
+User ID:   501
+
+Date/Time: 2022-07-28 11:10:19.4194 -0700
+OS Version:macOS 13.0 ()
+Report Version:12
+Anonymous UUID:CDC11418-EDBF-2A49-0D83-8B441A5004B0
+
+Sleep/Wake UUID:   7B2A0D73-8966-4B8D-98E9-CC6EC1B44967
+
+Time Awake Since Boot: 11 seconds
+Time Since Wake:   214 seconds
+
+System Integrity Protection: disabled
+
+Crashed Thread:2
+
+Exception Type:EXC_BAD_ACCESS (SIGSEGV)
+Exception Codes:   KERN_INVALID_ADDRESS at 0x
+Exception Codes:   0x0001, 0x
+
+Termination Reason:Namespace SIGNAL, Code 11 Segmentation fault: 11
+Terminating Process:   exc handler [22511]
+
+VM Region Info: 0 is not in any region.  Bytes before following region: 4310450176
+  REGION TYPESTART - END [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
+  UNUSED SPACE AT STAR

[Lldb-commits] [PATCH] D151002: [lldb] Fix process pid parsing issue

2023-05-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: JDevlieghere, bulbazord.
mib added a project: LLDB.
Herald added a project: All.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch should fix an issue when parsing the process pid and setting
it in the scripted process.

It can happen that the `crashlog.process_id` attribute is sometimes
parsed as a string. That would cause the scripted process to pick the
default value (0).

To address that, this patch makes sure that the parsed attributed is
converted to the integer type before passing it to the scripted process.

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151002

Files:
  lldb/examples/python/scripted_process/crashlog_scripted_process.py


Index: lldb/examples/python/scripted_process/crashlog_scripted_process.py
===
--- lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -11,7 +11,13 @@
 class CrashLogScriptedProcess(ScriptedProcess):
 def set_crashlog(self, crashlog):
 self.crashlog = crashlog
-self.pid = self.crashlog.process_id
+if self.crashlog.process_id:
+if type(self.crashlog.process_id) is int:
+self.pid = self.crashlog.process_id
+elif type(self.crashlog.process_id) is str:
+self.pid = int(self.crashlog.process_id, 0)
+else:
+self.pid = super().get_process_id()
 self.addr_mask = self.crashlog.addr_mask
 self.crashed_thread_idx = self.crashlog.crashed_thread_idx
 self.loaded_images = []


Index: lldb/examples/python/scripted_process/crashlog_scripted_process.py
===
--- lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -11,7 +11,13 @@
 class CrashLogScriptedProcess(ScriptedProcess):
 def set_crashlog(self, crashlog):
 self.crashlog = crashlog
-self.pid = self.crashlog.process_id
+if self.crashlog.process_id:
+if type(self.crashlog.process_id) is int:
+self.pid = self.crashlog.process_id
+elif type(self.crashlog.process_id) is str:
+self.pid = int(self.crashlog.process_id, 0)
+else:
+self.pid = super().get_process_id()
 self.addr_mask = self.crashlog.addr_mask
 self.crashed_thread_idx = self.crashlog.crashed_thread_idx
 self.loaded_images = []
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D150805: Proof of concept for reducing progress-reporting frequency.

2023-05-19 Thread Sterling Augustine via Phabricator via lldb-commits
saugustine updated this revision to Diff 523951.
saugustine added a comment.

Moved the rate-limiting to Debugger.[cpp|h]

Also wrote a custom getCurrentTime function, which doesn't do the
much of the extra work the Timer.h version does.

With this change, the timing is much better:

On my local machine, for a 93k DIE application, I get the following
timings:

  

1 second rate limit
(lldb) log timers dump
580.971832328 sec (total: 580.972s; child: 0.000s; count: 93007) for void 
DWARFUnit::ExtractDIEsRWLocked()

  

0 second rate limit, but with this change in place
663.114765369 sec (total: 663.115s; child: 0.000s; count: 93007) for void 
DWARFUnit::ExtractDIEsRWLocked()

  

Without this change in place
651.826884735 sec (total: 651.827s; child: 0.000s; count: 93007) for void 
DWARFUnit::ExtractDIEsRWLocked()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150805

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/Debugger.cpp

Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -66,6 +66,7 @@
 #include "llvm/Support/Process.h"
 #include "llvm/Support/ThreadPool.h"
 #include "llvm/Support/Threading.h"
+#include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
 
 #include 
@@ -403,6 +404,17 @@
   return SetPropertyAtIndex(idx, show_progress);
 }
 
+uint64_t Debugger::GetRateLimitProgress() const {
+  const uint32_t idx = ePropertyRateLimitProgress;
+  return GetPropertyAtIndexAs(
+  idx, g_debugger_properties[idx].default_uint_value != 0);
+}
+
+bool Debugger::SetRateLimitProgress(uint64_t rate_limit) {
+  const uint32_t idx = ePropertyShowProgress;
+  return SetPropertyAtIndex(idx, rate_limit);
+}
+
 llvm::StringRef Debugger::GetShowProgressAnsiPrefix() const {
   const uint32_t idx = ePropertyShowProgressAnsiPrefix;
   return GetPropertyAtIndexAs(
@@ -1934,6 +1946,16 @@
   return {};
 }
 
+// Rate-limit calculations should be fast. TimePoints collect memory and
+// instruction counts, which is slow.
+static double getCurrentTime() {
+  using Seconds = std::chrono::duration>;
+  llvm::sys::TimePoint<> now;
+  std::chrono::nanoseconds user, sys;
+  llvm::sys::Process::GetTimeUsage(now, user, sys);
+  return Seconds(now.time_since_epoch()).count();
+}
+
 void Debugger::HandleProgressEvent(const lldb::EventSP &event_sp) {
   auto *data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
   if (!data)
@@ -1976,6 +1998,13 @@
 
   StreamSP output = GetAsyncOutputStream();
 
+  // Rate limit progress messages, but always show the last event.
+  double current_time = getCurrentTime();
+  if (current_time < m_next_report_time &&
+  data->GetCompleted() != data->GetTotal())
+return;
+  m_next_report_time = current_time + GetRateLimitProgress();
+
   // Print over previous line, if any.
   output->Printf("\r");
 
@@ -1983,6 +2012,9 @@
 // Clear the current line.
 output->Printf("\x1B[2K");
 output->Flush();
+// This set of progress reports is complete. Reset to show the first
+// progress report of the next set.
+m_next_report_time = 0.0;
 return;
   }
 
Index: lldb/source/Core/CoreProperties.td
===
--- lldb/source/Core/CoreProperties.td
+++ lldb/source/Core/CoreProperties.td
@@ -147,6 +147,10 @@
 Global,
 DefaultTrue,
 Desc<"Whether to show progress or not if the debugger's output is an interactive color-enabled terminal.">;
+  def RateLimitProgress: Property<"rate-limit-progress", "UInt64">,
+Global,
+DefaultUnsignedValue<1>,
+Desc<"Seconds to wait between progress reports.">;
   def ShowProgressAnsiPrefix: Property<"show-progress-ansi-prefix", "String">,
 Global,
 DefaultStringValue<"${ansi.faint}">,
Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -307,6 +307,10 @@
 
   bool SetShowProgress(bool show_progress);
 
+  uint64_t GetRateLimitProgress() const;
+
+  bool SetRateLimitProgress(uint64_t rate_limit);
+
   llvm::StringRef GetShowProgressAnsiPrefix() const;
 
   llvm::StringRef GetShowProgressAnsiSuffix() const;
@@ -668,6 +672,9 @@
 eBroadcastBitEventThreadIsListening = (1 << 0),
   };
 
+  // Used to rate-limit progress reports;
+  double m_next_report_time = 0.0;
+
 private:
   // Use Debugger::CreateInstance() to get a shared pointer to a new debugger
   // object
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D151003: [Damangle] convert dlangDemangle to use std::string_view

2023-05-19 Thread Nick Desaulniers via Phabricator via lldb-commits
nickdesaulniers created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
nickdesaulniers requested review of this revision.
Herald added projects: LLDB, LLVM.
Herald added subscribers: llvm-commits, lldb-commits.

I was doing this API conversion to use std::string_view top-down in
D149104 , but this exposed issues in 
individual demanglers that needed to
get fixed first. There's no issue with the conversion for the D language
demangler, so convert it.

I have a more aggressive refactoring of the entire D language demangler
to use std::string_view more extensively, but the interface with
llvm::nonMicrosoftDemangle is the more interesting one.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151003

Files:
  lldb/source/Core/Mangled.cpp
  llvm/include/llvm/Demangle/Demangle.h
  llvm/lib/Demangle/DLangDemangle.cpp
  llvm/lib/Demangle/Demangle.cpp
  llvm/tools/llvm-dlang-demangle-fuzzer/llvm-dlang-demangle-fuzzer.cpp
  llvm/unittests/Demangle/DLangDemangleTest.cpp

Index: llvm/unittests/Demangle/DLangDemangleTest.cpp
===
--- llvm/unittests/Demangle/DLangDemangleTest.cpp
+++ llvm/unittests/Demangle/DLangDemangleTest.cpp
@@ -11,10 +11,11 @@
 #include "gtest/gtest.h"
 
 #include 
+#include 
 #include 
 
 struct DLangDemangleTestFixture
-: public testing::TestWithParam> {
+: public testing::TestWithParam> {
   char *Demangled;
 
   void SetUp() override { Demangled = llvm::dlangDemangle(GetParam().first); }
@@ -29,9 +30,8 @@
 INSTANTIATE_TEST_SUITE_P(
 DLangDemangleTest, DLangDemangleTestFixture,
 testing::Values(
-std::make_pair("_Dmain", "D main"), std::make_pair(nullptr, nullptr),
-std::make_pair("_Z", nullptr), std::make_pair("_DDD", nullptr),
-std::make_pair("_D88", nullptr),
+std::make_pair("_Dmain", "D main"), std::make_pair("_Z", nullptr),
+std::make_pair("_DDD", nullptr), std::make_pair("_D88", nullptr),
 std::make_pair("_D8demangleZ", "demangle"),
 std::make_pair("_D8demangle4testZ", "demangle.test"),
 std::make_pair("_D8demangle4test5test2Z", "demangle.test.test2"),
Index: llvm/tools/llvm-dlang-demangle-fuzzer/llvm-dlang-demangle-fuzzer.cpp
===
--- llvm/tools/llvm-dlang-demangle-fuzzer/llvm-dlang-demangle-fuzzer.cpp
+++ llvm/tools/llvm-dlang-demangle-fuzzer/llvm-dlang-demangle-fuzzer.cpp
@@ -13,7 +13,7 @@
 
 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   std::string NullTerminatedString((const char *)Data, Size);
-  char *Demangled = llvm::dlangDemangle(NullTerminatedString.c_str());
+  char *Demangled = llvm::dlangDemangle(NullTerminatedString);
   std::free(Demangled);
   return 0;
 }
Index: llvm/lib/Demangle/Demangle.cpp
===
--- llvm/lib/Demangle/Demangle.cpp
+++ llvm/lib/Demangle/Demangle.cpp
@@ -46,6 +46,9 @@
 }
 
 bool llvm::nonMicrosoftDemangle(const char *MangledName, std::string &Result) {
+  if (!MangledName)
+return false;
+
   char *Demangled = nullptr;
   if (isItaniumEncoding(MangledName))
 Demangled = itaniumDemangle(MangledName);
Index: llvm/lib/Demangle/DLangDemangle.cpp
===
--- llvm/lib/Demangle/DLangDemangle.cpp
+++ llvm/lib/Demangle/DLangDemangle.cpp
@@ -14,6 +14,7 @@
 //===--===//
 
 #include "llvm/Demangle/Demangle.h"
+#include "llvm/Demangle/StringViewExtras.h"
 #include "llvm/Demangle/Utility.h"
 
 #include 
@@ -22,6 +23,7 @@
 
 using namespace llvm;
 using llvm::itanium_demangle::OutputBuffer;
+using llvm::itanium_demangle::starts_with;
 
 namespace {
 
@@ -541,20 +543,20 @@
   return parseMangle(Demangled, this->Str);
 }
 
-char *llvm::dlangDemangle(const char *MangledName) {
-  if (MangledName == nullptr || strncmp(MangledName, "_D", 2) != 0)
+char *llvm::dlangDemangle(std::string_view MangledName) {
+  if (MangledName.empty() || !starts_with(MangledName, "_D"))
 return nullptr;
 
   OutputBuffer Demangled;
-  if (strcmp(MangledName, "_Dmain") == 0) {
+  if (MangledName == "_Dmain") {
 Demangled << "D main";
   } else {
 
-Demangler D = Demangler(MangledName);
-MangledName = D.parseMangle(&Demangled);
+Demangler D(MangledName.data());
+const char *M = D.parseMangle(&Demangled);
 
 // Check that the entire symbol was successfully demangled.
-if (MangledName == nullptr || *MangledName != '\0') {
+if (M == nullptr || *M != '\0') {
   std::free(Demangled.getBuffer());
   return nullptr;
 }
Index: llvm/include/llvm/Demangle/Demangle.h
===
--- llvm/include/llvm/Demangle/Demangle.h
+++ llvm/include/llvm/Demangle/Demangle.h
@@ -58,7 +58,7 @@
 char *rustDeman

[Lldb-commits] [PATCH] D146765: [lldb/crashlog] Load inlined symbol into interactive crashlog

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

Looks good! A few minor comments.




Comment at: lldb/examples/python/crashlog.py:628-629
+description = ""
+# Since images are parsed after threads, we need to build a
+# map for every image with a list of all the symbols and addresses
+if frame_img_name and frame_addr and frame_symbol:

I think this comment better describes `parse_thread` rather than 
`parse_asi_backtrace` no?



Comment at: lldb/examples/python/crashlog.py:634-635
+description += " + " + frame_offset
+for image in self.images:
+if image.identifier == frame_img_name:
+image.symbols[frame_symbol] = {

Does it make sense for `self.images` to be a dictionary instead of a list? 
Something that maps `image_name -> image_info`. That way you could do something 
like `self.images[frame_img_name].symbols[frame_symbol] = { ... }` instead of 
iterating over every image (with appropriate error checking in the event that 
frame_img_name isn't in self.images yet).



Comment at: lldb/examples/python/crashlog.py:639
+"type": "code",
+"address": int(frame_addr, 0) - int(frame_offset)
+}

if `frame_offset` is `None`, you're doing `int(None)` which will give you a 
`TypeError`. Above you can do something like `frame_offset_value = 0` and in 
the `if frame_offset:` block you can do `frame_offset_value = 
int(frame_offset)`.



Comment at: lldb/examples/python/crashlog.py:708
+r'))(?: '# capture group garbage
+r'\('# source infor capture group
+r'([^\:]+)'  # file name

typo: `infor` -> `info`



Comment at: lldb/examples/python/crashlog.py:711
+r'\:(\d+)'   # line number
+r'(?:\:' # capture group garbage
+r'(\d+)' # column number

What does `garbage` mean in this case? I assume it's boilerplate of some kind.



Comment at: lldb/examples/python/crashlog.py:936
+description += " + " + frame_offset
+if not frame_img_name in self.symbols:
+self.symbols[frame_img_name] = list()





Comment at: lldb/examples/python/crashlog.py:940
+"name": frame_symbol,
+"address": int(frame_addr, 0) - int(frame_offset)
+})

Same situation here as above, `frame_offset` might be `None` and then you'll 
crash with a `TypeError`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146765

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


[Lldb-commits] [PATCH] D151002: [lldb] Fix process pid parsing issue

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

You probably encountered this somewhere, is there a simple test we could add 
here? The change looks fine to me nonetheless.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151002

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


[Lldb-commits] [PATCH] D151002: [lldb] Fix process pid parsing issue

2023-05-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

In D151002#4357886 , @bulbazord wrote:

> You probably encountered this somewhere, is there a simple test we could add 
> here? The change looks fine to me nonetheless.

This is specific to interactive scripted process and the only test requires 
Apple Silicon: 
https://github.com/llvm/llvm-project/blob/main/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test#L1
 so Green Dragon didn't caught this issue.

You should be able to repro by running `ninja check-lldb-shell` on Apple 
Silicon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151002

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


[Lldb-commits] [PATCH] D146765: [lldb/crashlog] Load inlined symbol into interactive crashlog

2023-05-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib marked 7 inline comments as done.
mib added inline comments.



Comment at: lldb/examples/python/crashlog.py:628-629
+description = ""
+# Since images are parsed after threads, we need to build a
+# map for every image with a list of all the symbols and addresses
+if frame_img_name and frame_addr and frame_symbol:

bulbazord wrote:
> I think this comment better describes `parse_thread` rather than 
> `parse_asi_backtrace` no?
+1, that's an oversight.



Comment at: lldb/examples/python/crashlog.py:634-635
+description += " + " + frame_offset
+for image in self.images:
+if image.identifier == frame_img_name:
+image.symbols[frame_symbol] = {

bulbazord wrote:
> Does it make sense for `self.images` to be a dictionary instead of a list? 
> Something that maps `image_name -> image_info`. That way you could do 
> something like `self.images[frame_img_name].symbols[frame_symbol] = { ... }` 
> instead of iterating over every image (with appropriate error checking in the 
> event that frame_img_name isn't in self.images yet).
I thought about that but the problem is that `JSONCrashLogParser` uses image 
index and `TextCrashLogParser` uses image name as dictionary keys. It would be 
pretty convoluted to make the dictionary that is the same for both parser so 
I'd rather keep a list here.



Comment at: lldb/examples/python/crashlog.py:639
+"type": "code",
+"address": int(frame_addr, 0) - int(frame_offset)
+}

bulbazord wrote:
> if `frame_offset` is `None`, you're doing `int(None)` which will give you a 
> `TypeError`. Above you can do something like `frame_offset_value = 0` and in 
> the `if frame_offset:` block you can do `frame_offset_value = 
> int(frame_offset)`.
Good point!



Comment at: lldb/examples/python/crashlog.py:711
+r'\:(\d+)'   # line number
+r'(?:\:' # capture group garbage
+r'(\d+)' # column number

bulbazord wrote:
> What does `garbage` mean in this case? I assume it's boilerplate of some kind.
When I broke down the regex, I really to isolate the capture groups that we 
cared the most about.
By "garbage" I mean text that are required to parse the whole thing but that 
isn't captured.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146765

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


[Lldb-commits] [PATCH] D146765: [lldb/crashlog] Load inlined symbol into interactive crashlog

2023-05-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 523961.
mib marked 4 inline comments as done.
mib added a comment.

Address @bulbazord comments


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

https://reviews.llvm.org/D146765

Files:
  lldb/examples/python/crashlog.py
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_json.test
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
@@ -0,0 +1,43 @@
+# REQUIRES: python, native && target-aarch64 && system-darwin
+
+# RUN: mkdir -p %t.dir
+# RUN: yaml2obj %S/Inputs/interactive_crashlog/multithread-test.yaml > %t.dir/multithread-test
+# RUN: %lldb -o 'command script import lldb.macosx.crashlog' \
+# RUN: -o 'crashlog -a -i -t %t.dir/multithread-test %S/Inputs/interactive_crashlog/multithread-test.crash' \
+# RUN: -o "thread list" -o "bt all" 2>&1 | FileCheck %s
+
+# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
+
+# CHECK: (lldb) process status
+# CHECK-NEXT: Process 22511 stopped
+# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
+# CHECK-NEXT: frame #0: 0x000100ec58f4 multithread-test`bar
+
+# CHECK: (lldb) thread backtrace
+# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
+# CHECK-NEXT:   * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} [artificial]
+# CHECK-NEXT: frame #1: 0x000100ec591b multithread-test`foo{{.*}} [artificial]
+# CHECK-NEXT: frame #2: 0x000100ec5a87 multithread-test`compute_pow{{.*}} [artificial]
+
+# CHECK: (lldb) thread list
+# CHECK-NEXT: Process 22511 stopped
+# CHECK-NEXT:   thread #1: tid = 0x, 0x00019cc40b84{{.*}}
+# CHECK-NEXT:   thread #2: tid = 0x0001, 0x00019cc42c9c{{.*}}
+# CHECK-NEXT: * thread #3: tid = 0x0002, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
+
+# CHECK: (lldb) bt all
+# CHECK:  thread #1
+# CHECK:frame #{{[0-9]+}}: 0x00019cc40b84{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x000100ec5b3b multithread-test`main{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x0002230f8da7{{.*}} [artificial]
+# CHECK-NEXT:  thread #2
+# CHECK-NEXT:frame #0: 0x00019cc42c9c{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x000100ec5957 multithread-test`call_and_wait{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc7e06b{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc78e2b{{.*}} [artificial]
+# CHECK-NEXT:* thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
+# CHECK-NEXT:  * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} [artificial]
+# CHECK-NEXT:frame #1: 0x000100ec591b multithread-test`foo{{.*}} [artificial]
+# CHECK-NEXT:frame #2: 0x000100ec5a87 multithread-test`compute_pow{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc7e06b{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc78e2b{{.*}} [artificial]
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash
@@ -0,0 +1,140 @@
+Process:   multithread-test [22511]
+Path:  /Users/USER/*/multithread-test
+Identifier:multithread-test
+Version:   ???
+Code Type: ARM-64 (Native)
+Parent Process:zsh [59146]
+Responsible:   Terminal [1640]
+User ID:   501
+
+Date/Time: 2022-07-28 11:10:19.4194 -0700
+OS Version:macOS 13.0 ()
+Report Version:12
+Anonymous UUID:CDC11418-EDBF-2A49-0D83-8B441A5004B0
+
+Sleep/Wake UUID:   7B2A0D73-8966-4B8D-98E9-CC6EC1B44967
+
+Time Awake Since Boot: 11 seconds
+Time Since Wake:   214 seconds
+
+System Integrity Protection: disabled
+
+Crashed Thread:2
+
+Exception Type:EXC_BAD_ACCESS (SIGSEGV)
+Exception Codes:   KERN_INVALID_ADDRESS at 0x
+Exception Codes:   0x0001, 0x
+
+Termination Reason:Namespace SIGNAL, Code 11 Segmentation fault: 11
+Terminating Process:   exc handler [22511]
+
+VM Region Info: 0 is not in any region.  Bytes before following region: 4310450176
+  REGION TYPESTART - END [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
+  UNUSED SPACE A

[Lldb-commits] [PATCH] D146765: [lldb/crashlog] Load inlined symbol into interactive crashlog

2023-05-19 Thread Alex Langford via Phabricator via lldb-commits
bulbazord accepted this revision.
bulbazord added a comment.
This revision is now accepted and ready to land.

Ok, looks good to me now. Thanks!


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

https://reviews.llvm.org/D146765

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


[Lldb-commits] [PATCH] D146765: [lldb/crashlog] Load inlined symbol into interactive crashlog

2023-05-19 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/examples/python/crashlog.py:703
+symbol   = (
+r'(?: +(?:'  # spaces and + sign
+r'(.+)'  # symbol name

this is just "spaces", not "spaces and + sign"



Comment at: lldb/examples/python/crashlog.py:705
+r'(.+)'  # symbol name
+r'(?: \+ '   # spaces and + sign
+r'(\d+)' # symbol offset

this is "space and + sign" not "spaces"



Comment at: lldb/examples/python/crashlog.py:710
+r'([^\:]+)'  # file name
+r'\:(\d+)'   # line number
+r'(?:\:' # capture group garbage

`:` does not need to be escaped


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

https://reviews.llvm.org/D146765

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


[Lldb-commits] [PATCH] D146765: [lldb/crashlog] Load inlined symbol into interactive crashlog

2023-05-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 523980.
mib marked 3 inline comments as done.
mib added a comment.

Address @kastiglione comments and reformat.


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

https://reviews.llvm.org/D146765

Files:
  lldb/examples/python/crashlog.py
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_json.test
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
@@ -0,0 +1,43 @@
+# REQUIRES: python, native && target-aarch64 && system-darwin
+
+# RUN: mkdir -p %t.dir
+# RUN: yaml2obj %S/Inputs/interactive_crashlog/multithread-test.yaml > %t.dir/multithread-test
+# RUN: %lldb -o 'command script import lldb.macosx.crashlog' \
+# RUN: -o 'crashlog -a -i -t %t.dir/multithread-test %S/Inputs/interactive_crashlog/multithread-test.crash' \
+# RUN: -o "thread list" -o "bt all" 2>&1 | FileCheck %s
+
+# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
+
+# CHECK: (lldb) process status
+# CHECK-NEXT: Process 22511 stopped
+# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
+# CHECK-NEXT: frame #0: 0x000100ec58f4 multithread-test`bar
+
+# CHECK: (lldb) thread backtrace
+# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
+# CHECK-NEXT:   * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} [artificial]
+# CHECK-NEXT: frame #1: 0x000100ec591b multithread-test`foo{{.*}} [artificial]
+# CHECK-NEXT: frame #2: 0x000100ec5a87 multithread-test`compute_pow{{.*}} [artificial]
+
+# CHECK: (lldb) thread list
+# CHECK-NEXT: Process 22511 stopped
+# CHECK-NEXT:   thread #1: tid = 0x, 0x00019cc40b84{{.*}}
+# CHECK-NEXT:   thread #2: tid = 0x0001, 0x00019cc42c9c{{.*}}
+# CHECK-NEXT: * thread #3: tid = 0x0002, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
+
+# CHECK: (lldb) bt all
+# CHECK:  thread #1
+# CHECK:frame #{{[0-9]+}}: 0x00019cc40b84{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x000100ec5b3b multithread-test`main{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x0002230f8da7{{.*}} [artificial]
+# CHECK-NEXT:  thread #2
+# CHECK-NEXT:frame #0: 0x00019cc42c9c{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x000100ec5957 multithread-test`call_and_wait{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc7e06b{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc78e2b{{.*}} [artificial]
+# CHECK-NEXT:* thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
+# CHECK-NEXT:  * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} [artificial]
+# CHECK-NEXT:frame #1: 0x000100ec591b multithread-test`foo{{.*}} [artificial]
+# CHECK-NEXT:frame #2: 0x000100ec5a87 multithread-test`compute_pow{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc7e06b{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc78e2b{{.*}} [artificial]
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash
@@ -0,0 +1,140 @@
+Process:   multithread-test [22511]
+Path:  /Users/USER/*/multithread-test
+Identifier:multithread-test
+Version:   ???
+Code Type: ARM-64 (Native)
+Parent Process:zsh [59146]
+Responsible:   Terminal [1640]
+User ID:   501
+
+Date/Time: 2022-07-28 11:10:19.4194 -0700
+OS Version:macOS 13.0 ()
+Report Version:12
+Anonymous UUID:CDC11418-EDBF-2A49-0D83-8B441A5004B0
+
+Sleep/Wake UUID:   7B2A0D73-8966-4B8D-98E9-CC6EC1B44967
+
+Time Awake Since Boot: 11 seconds
+Time Since Wake:   214 seconds
+
+System Integrity Protection: disabled
+
+Crashed Thread:2
+
+Exception Type:EXC_BAD_ACCESS (SIGSEGV)
+Exception Codes:   KERN_INVALID_ADDRESS at 0x
+Exception Codes:   0x0001, 0x
+
+Termination Reason:Namespace SIGNAL, Code 11 Segmentation fault: 11
+Terminating Process:   exc handler [22511]
+
+VM Region Info: 0 is not in any region.  Bytes before following region: 4310450176
+  REGION TYPESTART - END [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
+

[Lldb-commits] [lldb] aefa8f4 - [lldb] Fix process pid parsing issue

2023-05-19 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-05-19T20:08:18-07:00
New Revision: aefa8f4460d12503d577c085069d632115e22ed4

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

LOG: [lldb] Fix process pid parsing issue

This patch should fix an issue when parsing the process pid and setting
it in the scripted process.

It can happen that the `crashlog.process_id` attribute is sometimes
parsed as a string. That would cause the scripted process to pick the
default value (0).

To address that, this patch makes sure that the parsed attributed is
converted to the integer type before passing it to the scripted process.

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/python/scripted_process/crashlog_scripted_process.py

Removed: 




diff  --git 
a/lldb/examples/python/scripted_process/crashlog_scripted_process.py 
b/lldb/examples/python/scripted_process/crashlog_scripted_process.py
index c913c86af11aa..46b2816032a59 100644
--- a/lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ b/lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -11,7 +11,13 @@
 class CrashLogScriptedProcess(ScriptedProcess):
 def set_crashlog(self, crashlog):
 self.crashlog = crashlog
-self.pid = self.crashlog.process_id
+if self.crashlog.process_id:
+if type(self.crashlog.process_id) is int:
+self.pid = self.crashlog.process_id
+elif type(self.crashlog.process_id) is str:
+self.pid = int(self.crashlog.process_id, 0)
+else:
+self.pid = super().get_process_id()
 self.addr_mask = self.crashlog.addr_mask
 self.crashed_thread_idx = self.crashlog.crashed_thread_idx
 self.loaded_images = []



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


[Lldb-commits] [lldb] dfdd898 - [lldb/crashlog] Load inlined symbol into interactive crashlog

2023-05-19 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-05-19T20:08:18-07:00
New Revision: dfdd8988621bcdce0364e0c3ab2d6ba52e875f32

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

LOG: [lldb/crashlog] Load inlined symbol into interactive crashlog

Sometimes, crash reports come with inlined symbols. These provide the
exact stacktrace from the user binary.

However, when investigating a crash, it's very likely that the images related
to the crashed thread are not available on the debugging user system or
that the versions don't match. This causes interactive crashlog to show
a degraded backtrace in lldb.

This patch aims to address that issue, by parsing the inlined symbols
from the crash report and load them into lldb's target.

This patch is a follow-up to 27f27d1, focusing on inlined symbols
loading from legacy (non-json) crash reports.

To do so, it updates the stack frame regular expression to make the
capture groups more granular, to be able to extract the symbol name, the
offset and the source location if available, while making it more
maintainable.

So now, when parsing the crash report, we build a data structure
containing all the symbol information for each stackframe. Then, after
launching the scripted process for interactive mode, we write a JSON
symbol file for each module, only containing the symbols that it contains.

Finally, we load the json symbol file into lldb, before showing the user
the process status and backtrace.

rdar://97345586

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

Signed-off-by: Med Ismail Bennani 

Added: 

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_json.test

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test

Modified: 
lldb/examples/python/crashlog.py

Removed: 

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test



diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index dadab3cd8b7f4..d207af10f36f2 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -432,6 +432,8 @@ def __init__(self, debugger, path, verbose):
 self.path = os.path.expanduser(path)
 self.verbose = verbose
 self.crashlog = CrashLog(debugger, self.path, self.verbose)
+# List of DarwinImages sorted by their index.
+self.images = list()
 
 @abc.abstractmethod
 def parse(self):
@@ -459,8 +461,6 @@ def parse_json(buffer):
 
 def __init__(self, debugger, path, verbose):
 super().__init__(debugger, path, verbose)
-# List of DarwinImages sorted by their index.
-self.images = list()
 
 def parse(self):
 try:
@@ -603,14 +603,45 @@ def parse_asi_backtrace(self, thread, bt):
 print("error: can't parse application specific backtrace.")
 return False
 
-(frame_id, frame_img_name, frame_addr,
-frame_ofs) = frame_match.groups()
+frame_id = frame_img_name = frame_addr = frame_symbol = 
frame_offset = frame_file = frame_line = frame_column = None
+
+if len(frame_match.groups()) == 3:
+# Get the image UUID from the frame image name.
+(frame_id, frame_img_name, frame_addr) = frame_match.groups()
+elif len(frame_match.groups()) == 5:
+(frame_id, frame_img_name, frame_addr,
+frame_symbol, frame_offset) = frame_match.groups()
+elif len(frame_match.groups()) == 7:
+(frame_id, frame_img_name, frame_addr,
+frame_symbol, frame_offset,
+frame_file, frame_line) = frame_match.groups()
+elif len(frame_match.groups()) == 8:
+(frame_id, frame_img_name, frame_addr,
+frame_symbol, frame_offset,
+frame_file, frame_line, frame_column) = 
frame_match.groups()
 
 thread.add_ident(frame_img_name)
 if frame_img_name not in self.crashlog.idents:
 self.crashlog.idents.append(frame_img_name)
-thread.frames.append(self.crashlog.Frame(int(frame_id), int(
-frame_addr, 0), frame_ofs))
+
+description = ""
+if frame_img_name and frame_addr and frame_symbol:
+description = frame_symbol
+frame_offset_value = 0
+if frame_offset:
+description += " + " + frame_offset
+frame_offset_value = int(frame_offset, 0)
+for image in self.images:
+if image.identifier ==

[Lldb-commits] [PATCH] D146765: [lldb/crashlog] Load inlined symbol into interactive crashlog

2023-05-19 Thread Med Ismail Bennani 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 rGdfdd8988621b: [lldb/crashlog] Load inlined symbol into 
interactive crashlog (authored by mib).

Changed prior to commit:
  https://reviews.llvm.org/D146765?vs=523980&id=523981#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146765

Files:
  lldb/examples/python/crashlog.py
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_json.test
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
@@ -3,7 +3,7 @@
 # RUN: mkdir -p %t.dir
 # RUN: yaml2obj %S/Inputs/interactive_crashlog/multithread-test.yaml > %t.dir/multithread-test
 # RUN: %lldb -o 'command script import lldb.macosx.crashlog' \
-# RUN: -o 'crashlog -a -i -t %t.dir/multithread-test %S/Inputs/interactive_crashlog/multithread-test.ips' \
+# RUN: -o 'crashlog -a -i -t %t.dir/multithread-test %S/Inputs/interactive_crashlog/multithread-test.crash' \
 # RUN: -o "thread list" -o "bt all" 2>&1 | FileCheck %s
 
 # CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
@@ -21,12 +21,12 @@
 
 # CHECK: (lldb) thread list
 # CHECK-NEXT: Process 22511 stopped
-# CHECK-NEXT:   thread #1: tid = 0x23c7fe, 0x00019cc40b84{{.*}}, queue = 'com.apple.main-thread'
-# CHECK-NEXT:   thread #2: tid = 0x23c800, 0x00019cc42c9c{{.*}}
-# CHECK-NEXT: * thread #3: tid = 0x23c801, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
+# CHECK-NEXT:   thread #1: tid = 0x, 0x00019cc40b84{{.*}}
+# CHECK-NEXT:   thread #2: tid = 0x0001, 0x00019cc42c9c{{.*}}
+# CHECK-NEXT: * thread #3: tid = 0x0002, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 
 # CHECK: (lldb) bt all
-# CHECK:  thread #1, queue = 'com.apple.main-thread'
+# CHECK:  thread #1
 # CHECK:frame #{{[0-9]+}}: 0x00019cc40b84{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x000100ec5b3b multithread-test`main{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x0002230f8da7{{.*}} [artificial]
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash
@@ -0,0 +1,140 @@
+Process:   multithread-test [22511]
+Path:  /Users/USER/*/multithread-test
+Identifier:multithread-test
+Version:   ???
+Code Type: ARM-64 (Native)
+Parent Process:zsh [59146]
+Responsible:   Terminal [1640]
+User ID:   501
+
+Date/Time: 2022-07-28 11:10:19.4194 -0700
+OS Version:macOS 13.0 ()
+Report Version:12
+Anonymous UUID:CDC11418-EDBF-2A49-0D83-8B441A5004B0
+
+Sleep/Wake UUID:   7B2A0D73-8966-4B8D-98E9-CC6EC1B44967
+
+Time Awake Since Boot: 11 seconds
+Time Since Wake:   214 seconds
+
+System Integrity Protection: disabled
+
+Crashed Thread:2
+
+Exception Type:EXC_BAD_ACCESS (SIGSEGV)
+Exception Codes:   KERN_INVALID_ADDRESS at 0x
+Exception Codes:   0x0001, 0x
+
+Termination Reason:Namespace SIGNAL, Code 11 Segmentation fault: 11
+Terminating Process:   exc handler [22511]
+
+VM Region Info: 0 is not in any region.  Bytes before following region: 4310450176
+  REGION TYPESTART - END [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
+  UNUSED SPACE AT START
+--->  
+  __TEXT  100ec4000-100ec8000[   16K] r-x/r-x SM=COW  ...tithread-test
+
+Thread 0::  Dispatch queue: com.apple.main-thread
+0   libsystem_kernel.dylib	   0x19cc40b84 __ulock_wait + 8
+1   libsystem_pthread.dylib   	   0x19cc80394 _pthread_join + 444
+2   libc++.1.dylib	   0x19cbd8274 std::__1::thread::join() + 36
+3   multithread-test  	   0x100ec5b3c main + 160 (multithread-test.cpp:31)
+4   dyld  	   0x2230f8da8 start + 2376
+
+Thread 1:
+0   libsystem_kernel.dylib	   0x19cc42c9c __write_nocancel + 8
+1   libsystem_c.dylib 

[Lldb-commits] [PATCH] D151002: [lldb] Fix process pid parsing issue

2023-05-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaefa8f4460d1: [lldb] Fix process pid parsing issue (authored 
by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151002

Files:
  lldb/examples/python/scripted_process/crashlog_scripted_process.py


Index: lldb/examples/python/scripted_process/crashlog_scripted_process.py
===
--- lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -11,7 +11,13 @@
 class CrashLogScriptedProcess(ScriptedProcess):
 def set_crashlog(self, crashlog):
 self.crashlog = crashlog
-self.pid = self.crashlog.process_id
+if self.crashlog.process_id:
+if type(self.crashlog.process_id) is int:
+self.pid = self.crashlog.process_id
+elif type(self.crashlog.process_id) is str:
+self.pid = int(self.crashlog.process_id, 0)
+else:
+self.pid = super().get_process_id()
 self.addr_mask = self.crashlog.addr_mask
 self.crashed_thread_idx = self.crashlog.crashed_thread_idx
 self.loaded_images = []


Index: lldb/examples/python/scripted_process/crashlog_scripted_process.py
===
--- lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -11,7 +11,13 @@
 class CrashLogScriptedProcess(ScriptedProcess):
 def set_crashlog(self, crashlog):
 self.crashlog = crashlog
-self.pid = self.crashlog.process_id
+if self.crashlog.process_id:
+if type(self.crashlog.process_id) is int:
+self.pid = self.crashlog.process_id
+elif type(self.crashlog.process_id) is str:
+self.pid = int(self.crashlog.process_id, 0)
+else:
+self.pid = super().get_process_id()
 self.addr_mask = self.crashlog.addr_mask
 self.crashed_thread_idx = self.crashlog.crashed_thread_idx
 self.loaded_images = []
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits