[Lldb-commits] [lldb] [lldb] Add constant value mode for RegisterLocation in UnwindPlans (PR #100624)
@@ -153,6 +155,9 @@ void UnwindPlan::Row::RegisterLocation::Dump(Stream &s, if (m_type == atDWARFExpression) s.PutChar(']'); } break; + case isConstant: +s.Printf("=%x", m_location.offset); felipepiovezan wrote: Ohh oops, you're totally right! Fixed! https://github.com/llvm/llvm-project/pull/100624 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add constant value mode for RegisterLocation in UnwindPlans (PR #100624)
https://github.com/felipepiovezan updated https://github.com/llvm/llvm-project/pull/100624 >From 223075d6f036537a7edec10b370f6d922135cb79 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Tue, 23 Jul 2024 13:30:40 -0700 Subject: [PATCH 1/2] [lldb] Add constant value mode for RegisterLocation in UnwindPlans This is useful for language runtimes that compute register values by inspecting the state of the currently running process. Currently, there are no mechanisms enabling these runtimes to set register values to arbitrary values. The alternative considered would involve creating a dwarf expression that produces an arbitrary integer (e.g. using OP_constu). However, the current data structure for Rows is such that they do not own any memory associated with dwarf expressions, which implies any such expression would need to have static storage and therefore could not contain a runtime value. Adding a new rule for constants leads to a simpler implementation. It's also worth noting that this does not make the "Location" union any bigger, since it already contains a pointer+size pair. --- lldb/include/lldb/Symbol/UnwindPlan.h| 17 - lldb/source/Symbol/UnwindPlan.cpp| 17 + lldb/source/Target/RegisterContextUnwind.cpp | 9 + 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h b/lldb/include/lldb/Symbol/UnwindPlan.h index ebb0ec421da72..a9e8406608ff3 100644 --- a/lldb/include/lldb/Symbol/UnwindPlan.h +++ b/lldb/include/lldb/Symbol/UnwindPlan.h @@ -68,7 +68,8 @@ class UnwindPlan { isAFAPlusOffset, // reg = AFA + offset inOtherRegister, // reg = other reg atDWARFExpression, // reg = deref(eval(dwarf_expr)) -isDWARFExpression // reg = eval(dwarf_expr) +isDWARFExpression, // reg = eval(dwarf_expr) +isConstant // reg = constant }; RegisterLocation() : m_location() {} @@ -105,6 +106,15 @@ class UnwindPlan { bool IsDWARFExpression() const { return m_type == isDWARFExpression; } + bool IsConstant() const { return m_type == isConstant; } + + void SetIsConstant(uint64_t value) { +m_type = isConstant; +m_location.constant_value = value; + } + + uint64_t GetConstant() const { return m_location.constant_value; } + void SetAtCFAPlusOffset(int32_t offset) { m_type = atCFAPlusOffset; m_location.offset = offset; @@ -192,6 +202,8 @@ class UnwindPlan { const uint8_t *opcodes; uint16_t length; } expr; +// For m_type == isConstant +uint64_t constant_value; } m_location; }; @@ -358,6 +370,9 @@ class UnwindPlan { bool SetRegisterLocationToSame(uint32_t reg_num, bool must_replace); +bool SetRegisterLocationToIsConstant(uint32_t reg_num, uint64_t constant, + bool can_replace); + // When this UnspecifiedRegistersAreUndefined mode is // set, any register that is not specified by this Row will // be described as Undefined. diff --git a/lldb/source/Symbol/UnwindPlan.cpp b/lldb/source/Symbol/UnwindPlan.cpp index e258a4e3d82f2..fcd3154a01d82 100644 --- a/lldb/source/Symbol/UnwindPlan.cpp +++ b/lldb/source/Symbol/UnwindPlan.cpp @@ -46,6 +46,8 @@ operator==(const UnwindPlan::Row::RegisterLocation &rhs) const { return !memcmp(m_location.expr.opcodes, rhs.m_location.expr.opcodes, m_location.expr.length); break; +case isConstant: + return m_location.constant_value == rhs.m_location.constant_value; } } return false; @@ -153,6 +155,9 @@ void UnwindPlan::Row::RegisterLocation::Dump(Stream &s, if (m_type == atDWARFExpression) s.PutChar(']'); } break; + case isConstant: +s.Printf("=%x", m_location.offset); +break; } } @@ -351,6 +356,18 @@ bool UnwindPlan::Row::SetRegisterLocationToSame(uint32_t reg_num, return true; } +bool UnwindPlan::Row::SetRegisterLocationToIsConstant(uint32_t reg_num, + uint64_t constant, + bool can_replace) { + if (!can_replace && + m_register_locations.find(reg_num) != m_register_locations.end()) +return false; + RegisterLocation reg_loc; + reg_loc.SetIsConstant(constant); + m_register_locations[reg_num] = reg_loc; + return true; +} + bool UnwindPlan::Row::operator==(const UnwindPlan::Row &rhs) const { return m_offset == rhs.m_offset && m_cfa_value == rhs.m_cfa_value && m_afa_value == rhs.m_afa_value && diff --git a/lldb/source/Target/RegisterContextUnwind.cpp b/lldb/source/Target/RegisterContextUnwind.cpp index 95e8abd763d53..f74f1dc0e1b80 100644 --- a/lldb/source/Target/RegisterContextUnwind.cpp +++ b/lldb/source/Target/RegisterContextUnwind.cpp @@ -1694,6 +1694,15 @@ RegisterContextUnwind::Sav
[Lldb-commits] [lldb] [lldb][test] Fix TestMultipleDebuggers test on non-x86, other small issues (PR #101169)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/101169 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Fix ProcessMinidump::GetMemoryRegions to include 64b regions when /proc/pid maps are missing. (PR #101086)
Jlalond wrote: > Sounds good. Could you split off the lldb parts to a separate review though? @labath I think we need both, in order to fix `SBProcess` to return all memory regions we need the LLDB change, which enables us to test if the yaml2obj generates correctly https://github.com/llvm/llvm-project/pull/101086 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Fix ProcessMinidump::GetMemoryRegions to include 64b regions when /proc/pid maps are missing. (PR #101086)
@@ -154,3 +155,17 @@ MinidumpFile::create(MemoryBufferRef Source) { return std::unique_ptr( new MinidumpFile(Source, Hdr, *ExpectedStreams, std::move(StreamMap))); } + +Expected> MinidumpFile::getMemory64List() const { + Expected MemoryList64 = getMemoryList64Header(); + if (!MemoryList64) +return MemoryList64.takeError(); + + std::optional> Stream = + getRawStream(StreamType::Memory64List); + if (!Stream) +return createError("No such stream"); + + return getDataSliceAs( Jlalond wrote: I was a bit flippant, but I think the only confusion for me is that the pointers are always being converted to an ArrayRef, `getDataSliceAsArrayOf<>` could work but is particularly verbose https://github.com/llvm/llvm-project/pull/101086 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Fix ProcessMinidump::GetMemoryRegions to include 64b regions when /proc/pid maps are missing. (PR #101086)
https://github.com/Jlalond edited https://github.com/llvm/llvm-project/pull/101086 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][win][x86_64] Fix XFAIL and XPASS on LLDB API tests (PR #100477)
@@ -12,6 +12,7 @@ class MultipleSlidesTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True +@expectedFailureAll(oslist=["windows"], archs=["x86_64"]) dzhidzhoev wrote: Here's the execution log on my setup https://gist.github.com/dzhidzhoev/c6af2c83c6175eb1ba83c306b0ad9a15. Build commands are ``` F:/Users/vdzhidzhoev/temp/build-lldb-native/bin/clang.exe -O0 -m64 -c F:\Users\vdzhidzhoev\temp\llvm-project\lldb\test\API\functionalities\multiple-slides/main.c -o main.o F:/Users/vdzhidzhoev/temp/build-lldb-native/bin/clang.exe main.o -gdwarf -O0 -m64 -IF:\Users\vdzhidzhoev\temp\llvm-project\lldb\packages\Python\lldbsuite\test\make/../../../../..//include -IF:/Users/vdzhidzhoev/temp/build-lldb-native/tools/lldb/include -IF:\Users\vdzhidzhoev\temp\llvm-project\lldb\test\API\functionalities\multiple-slides -IF:\Users\vdzhidzhoev\temp\llvm-project\lldb\packages\Python\lldbsuite\test\make -include F:\Users\vdzhidzhoev\temp\llvm-project\lldb\packages\Python\lldbsuite\test\make/test_common.h -fno-limit-debug-info -fuse-ld=lld --driver-mode=g++ -o "a.out" ``` It seems that -gdwarf is added on this line https://github.com/llvm/llvm-project/blob/8f7910a4fc08818462e0e836db74b20290cd36c7/lldb/packages/Python/lldbsuite/test/make/Makefile.rules#L270. Here's objdump for main.o: ``` $ bin/llvm-objdump -t /f/Users/vdzhidzhoev/temp/build-lldb-native/lldb-test-build.noindex/functionalities/multiple-slides/TestMultipleSlides.test_mulitple_slides/main.o | less F:/Users/vdzhidzhoev/temp/build-lldb-native/lldb-test-build.noindex/functionalities/multiple-slides/TestMultipleSlides.test_mulitple_slides/main.o: file format coff-x86-64 SYMBOL TABLE: [ 0](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x .text AUX scnlen 0x17 nreloc 2 nlnno 0 checksum 0xdb640681 assoc 1 comdat 0 [ 2](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x .data AUX scnlen 0x4000 nreloc 0 nlnno 0 checksum 0x8ff2bf4e assoc 2 comdat 0 [ 4](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x .bss AUX scnlen 0x0 nreloc 0 nlnno 0 checksum 0x0 assoc 3 comdat 0 [ 6](sec 4)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x .xdata AUX scnlen 0x8 nreloc 0 nlnno 0 checksum 0x1ab96b84 assoc 4 comdat 0 [ 8](sec 5)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x .pdata AUX scnlen 0xc nreloc 3 nlnno 0 checksum 0x767e3832 assoc 5 comdat 0 [10](sec 6)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x .llvm_addrsig AUX scnlen 0x2 nreloc 0 nlnno 0 checksum 0xe3c301f assoc 6 comdat 0 [12](sec -1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x @feat.00 [13](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x main [14](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x first [15](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x2000 second [16](sec -2)(fl 0x00)(ty 0)(scl 67) (nx 1) 0x .file ``` Here's "image dump symtab" from lldb.exe for a.out https://gist.github.com/dzhidzhoev/ee3bd2566f3a95b018f40c45e34d9078. https://github.com/llvm/llvm-project/pull/100477 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][win][x86_64] Fix XFAIL and XPASS on LLDB API tests (PR #100477)
@@ -12,6 +12,7 @@ class MultipleSlidesTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True +@expectedFailureAll(oslist=["windows"], archs=["x86_64"]) dzhidzhoev wrote: "first" is preset in both dumps https://github.com/llvm/llvm-project/pull/100477 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][win][x86_64] XFAIL already failing Shell tests (PR #100476)
@@ -1,3 +1,4 @@ +# XFAIL: target=x86_64-{{.*}}-windows{{.*}} dzhidzhoev wrote: > @dzhidzhoev would you be able to share the CMake configuration your Windows > native CI is using? I'm having trouble spotting what's wrong with my local > build. For sure! Sorry, I needed some time to sort it out, because I hadn't reproduced it on my local machine before, only had it in CI. ``` cmake -DLLVM_LIT_ARGS="-v -vv --threads=8 --xunit-xml-output=xunit-report.xml" ^ -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ^ -DCMAKE_INSTALL_PREFIX=native -DCMAKE_BUILD_TYPE=Release ^ -DLLVM_ENABLE_PROJECTS=lldb;llvm;clang;lld -DLLVM_ENABLE_ASSERTIONS=ON ^ -DMake_EXECUTABLE=c:/bin/make-wfix.exe ^ -DLLDB_TEST_USER_ARGS=--skip-category=watchpoint ^ -DLLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON ^ c:/lldb-test-scripts/llvm ``` https://github.com/llvm/llvm-project/pull/100476 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Fix ProcessMinidump::GetMemoryRegions to include 64b regions when /proc/pid maps are missing. (PR #101086)
labath wrote: > > Sounds good. Could you split off the lldb parts to a separate review though? > > @labath I think we need both, in order to fix `SBProcess` to return all > memory regions we need the LLDB change, which enables us to test if the > yaml2obj generates correctly I can believe you need the llvm changes for the lldb test. That's fine and expected. You can make those changes on a separate PR. However, there shouldn't code in llvm which is only tested from lldb. That's why I pointed you to all the existing tests for yaml2minidump functionality in llvm. You can test the llvm functionality through those. https://github.com/llvm/llvm-project/pull/101086 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Support remote run of Shell tests (PR #95986)
https://github.com/dzhidzhoev updated https://github.com/llvm/llvm-project/pull/95986 >From d21c76b25e20e45b20f0f95bd7b4324fb5a19a81 Mon Sep 17 00:00:00 2001 From: Vladislav Dzhidzhoev Date: Fri, 31 May 2024 21:39:56 + Subject: [PATCH] [lldb][test] Support remote run of Shell tests 1. This commit adds LLDB_TEST_PLATFORM_URL, LLDB_TEST_SYSROOT, LLDB_TEST_PLATFORM_WORKING_DIR, LLDB_SHELL_TESTS_DISABLE_REMOTE cmake flags to pass arguments for cross-compilation and remote running of both Shell&API tests. 2. To run Shell tests remotely, it adds 'platform select' and 'platform connect' commands to %lldb substitution. 3. 'remote-linux' feature added to lit to disable tests failing with remote execution. 4. A separate working directory is assigned to each test to avoid conflicts during parallel test execution. 5. Remote Shell testing is run only when LLDB_TEST_SYSROOT is set for building test sources. Recommended compiler for that is Clang. --- lldb/docs/resources/test.rst | 20 +++--- lldb/test/API/lit.cfg.py | 7 ++ lldb/test/API/lit.site.cfg.py.in | 3 + lldb/test/CMakeLists.txt | 1 + .../test/Shell/Settings/TestEchoCommands.test | 2 + lldb/test/Shell/Target/target-label.test | 20 +++--- lldb/test/Shell/helper/toolchain.py | 67 ++- lldb/test/Shell/lit.cfg.py| 9 ++- lldb/test/Shell/lit.site.cfg.py.in| 7 +- 9 files changed, 112 insertions(+), 24 deletions(-) diff --git a/lldb/docs/resources/test.rst b/lldb/docs/resources/test.rst index 382e42bf22b10..23b6ab03559d4 100644 --- a/lldb/docs/resources/test.rst +++ b/lldb/docs/resources/test.rst @@ -592,15 +592,17 @@ test suite, but there are two things to have in mind: multiple connections. For more information on how to setup remote debugging see the Remote debugging page. 2. You must tell the test-suite how to connect to the remote system. This is - achieved using the ``--platform-name``, ``--platform-url`` and - ``--platform-working-dir`` parameters to ``dotest.py``. These parameters - correspond to the platform select and platform connect LLDB commands. You - will usually also need to specify the compiler and architecture for the - remote system. - -Currently, running the remote test suite is supported only with ``dotest.py`` (or -dosep.py with a single thread), but we expect this issue to be addressed in the -near future. + achieved using the ``LLDB_TEST_PLATFORM_URL``, ``LLDB_TEST_PLATFORM_WORKING_DIR`` + flags to cmake, and ``--platform-name`` parameter to ``dotest.py``. + These parameters correspond to the platform select and platform connect + LLDB commands. You will usually also need to specify the compiler and + architecture for the remote system. +3. Remote Shell tests execution is currently supported only for Linux target + platform. It's triggered when ``LLDB_TEST_SYSROOT`` is provided for building + test sources. It can be disabled by setting ``LLDB_SHELL_TESTS_DISABLE_REMOTE=On``. + Shell tests are not guaranteed to pass against remote target if the compiler + being used is other than Clang. + Running tests in QEMU System Emulation Environment `` diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py index 96520c7c82624..6a0a1b0a76675 100644 --- a/lldb/test/API/lit.cfg.py +++ b/lldb/test/API/lit.cfg.py @@ -303,6 +303,13 @@ def delete_module_cache(path): # In particular, (1) is visited at the top of the file, since the script # derives other information from it. +if is_configured("lldb_platform_url"): +dotest_cmd += ["--platform-url", config.lldb_platform_url] +if is_configured("lldb_platform_working_dir"): +dotest_cmd += ["--platform-working-dir", config.lldb_platform_working_dir] +if is_configured("cmake_sysroot"): +dotest_cmd += ["--sysroot", config.cmake_sysroot] + if is_configured("dotest_user_args_str"): dotest_cmd.extend(config.dotest_user_args_str.split(";")) diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in index 8b2d09ae41cd2..db3cd2971f347 100644 --- a/lldb/test/API/lit.site.cfg.py.in +++ b/lldb/test/API/lit.site.cfg.py.in @@ -24,6 +24,9 @@ config.lua_executable = "@Lua_EXECUTABLE@" config.lua_test_entry = "TestLuaAPI.py" config.dotest_common_args_str = lit_config.substitute("@LLDB_TEST_COMMON_ARGS@") config.dotest_user_args_str = lit_config.substitute("@LLDB_TEST_USER_ARGS@") +config.lldb_platform_url = lit_config.substitute("@LLDB_TEST_PLATFORM_URL@") +config.lldb_platform_working_dir = lit_config.substitute("@LLDB_TEST_PLATFORM_WORKING_DIR@") +config.cmake_sysroot = lit_config.substitute("@LLDB_TEST_SYSROOT@" or "@DEFAULT_SYSROOT@") config.lldb_enable_python = @LLDB_ENABLE_PYTHON@ config.dotest_lit_args_str = None config.enabled_plugins = [] diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.
[Lldb-commits] [lldb] [lldb][test] Support remote run of Shell tests (PR #95986)
https://github.com/dzhidzhoev updated https://github.com/llvm/llvm-project/pull/95986 >From b747d2cf8d648e0dadda4adaaf2e0ef41d4ebd34 Mon Sep 17 00:00:00 2001 From: Vladislav Dzhidzhoev Date: Fri, 31 May 2024 21:39:56 + Subject: [PATCH] [lldb][test] Support remote run of Shell tests 1. This commit adds LLDB_TEST_PLATFORM_URL, LLDB_TEST_SYSROOT, LLDB_TEST_PLATFORM_WORKING_DIR, LLDB_SHELL_TESTS_DISABLE_REMOTE cmake flags to pass arguments for cross-compilation and remote running of both Shell&API tests. 2. To run Shell tests remotely, it adds 'platform select' and 'platform connect' commands to %lldb substitution. 3. 'remote-linux' feature added to lit to disable tests failing with remote execution. 4. A separate working directory is assigned to each test to avoid conflicts during parallel test execution. 5. Remote Shell testing is run only when LLDB_TEST_SYSROOT is set for building test sources. Recommended compiler for that is Clang. --- lldb/docs/resources/test.rst | 20 +++--- lldb/test/API/lit.cfg.py | 7 ++ lldb/test/API/lit.site.cfg.py.in | 3 + lldb/test/CMakeLists.txt | 1 + .../test/Shell/Settings/TestEchoCommands.test | 2 + lldb/test/Shell/Target/target-label.test | 20 +++--- lldb/test/Shell/helper/toolchain.py | 67 ++- lldb/test/Shell/lit.cfg.py| 9 ++- lldb/test/Shell/lit.site.cfg.py.in| 7 +- 9 files changed, 112 insertions(+), 24 deletions(-) diff --git a/lldb/docs/resources/test.rst b/lldb/docs/resources/test.rst index 382e42bf22b10..23b6ab03559d4 100644 --- a/lldb/docs/resources/test.rst +++ b/lldb/docs/resources/test.rst @@ -592,15 +592,17 @@ test suite, but there are two things to have in mind: multiple connections. For more information on how to setup remote debugging see the Remote debugging page. 2. You must tell the test-suite how to connect to the remote system. This is - achieved using the ``--platform-name``, ``--platform-url`` and - ``--platform-working-dir`` parameters to ``dotest.py``. These parameters - correspond to the platform select and platform connect LLDB commands. You - will usually also need to specify the compiler and architecture for the - remote system. - -Currently, running the remote test suite is supported only with ``dotest.py`` (or -dosep.py with a single thread), but we expect this issue to be addressed in the -near future. + achieved using the ``LLDB_TEST_PLATFORM_URL``, ``LLDB_TEST_PLATFORM_WORKING_DIR`` + flags to cmake, and ``--platform-name`` parameter to ``dotest.py``. + These parameters correspond to the platform select and platform connect + LLDB commands. You will usually also need to specify the compiler and + architecture for the remote system. +3. Remote Shell tests execution is currently supported only for Linux target + platform. It's triggered when ``LLDB_TEST_SYSROOT`` is provided for building + test sources. It can be disabled by setting ``LLDB_SHELL_TESTS_DISABLE_REMOTE=On``. + Shell tests are not guaranteed to pass against remote target if the compiler + being used is other than Clang. + Running tests in QEMU System Emulation Environment `` diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py index 96520c7c82624..6a0a1b0a76675 100644 --- a/lldb/test/API/lit.cfg.py +++ b/lldb/test/API/lit.cfg.py @@ -303,6 +303,13 @@ def delete_module_cache(path): # In particular, (1) is visited at the top of the file, since the script # derives other information from it. +if is_configured("lldb_platform_url"): +dotest_cmd += ["--platform-url", config.lldb_platform_url] +if is_configured("lldb_platform_working_dir"): +dotest_cmd += ["--platform-working-dir", config.lldb_platform_working_dir] +if is_configured("cmake_sysroot"): +dotest_cmd += ["--sysroot", config.cmake_sysroot] + if is_configured("dotest_user_args_str"): dotest_cmd.extend(config.dotest_user_args_str.split(";")) diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in index 8b2d09ae41cd2..db3cd2971f347 100644 --- a/lldb/test/API/lit.site.cfg.py.in +++ b/lldb/test/API/lit.site.cfg.py.in @@ -24,6 +24,9 @@ config.lua_executable = "@Lua_EXECUTABLE@" config.lua_test_entry = "TestLuaAPI.py" config.dotest_common_args_str = lit_config.substitute("@LLDB_TEST_COMMON_ARGS@") config.dotest_user_args_str = lit_config.substitute("@LLDB_TEST_USER_ARGS@") +config.lldb_platform_url = lit_config.substitute("@LLDB_TEST_PLATFORM_URL@") +config.lldb_platform_working_dir = lit_config.substitute("@LLDB_TEST_PLATFORM_WORKING_DIR@") +config.cmake_sysroot = lit_config.substitute("@LLDB_TEST_SYSROOT@" or "@DEFAULT_SYSROOT@") config.lldb_enable_python = @LLDB_ENABLE_PYTHON@ config.dotest_lit_args_str = None config.enabled_plugins = [] diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.
[Lldb-commits] [lldb] [lldb][test] Support remote run of Shell tests (PR #95986)
dzhidzhoev wrote: Update: fixed condition for remote execution. Now this PR is ready for review. https://github.com/llvm/llvm-project/pull/95986 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][RISCV] function calls support in lldb expressions (PR #99336)
tedwoodward wrote: BTW, if you call SetCanInterpretFunctionCalls(true); somewhere, you can use the IR interpreter to call functions. PrepareTrivialCall below the implementation you do here, for JIT, handles that. https://github.com/llvm/llvm-project/pull/99336 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/101208 Currently, CommandObjects are obtaining a target in a variety of ways. Often the command incorrectly operates on the selected target. As an example, when a breakpoint command is running, the current target is passed into the command but the target that hit the breakpoint is not the selected target. In other places we use the CommandObject's execution context, which is frozen during the execution of the command, which comes with its own limitations. And of course there's all the places where we need to use, or to fallback on the dummy target Instead of having to guess how to get the target, this patch introduces one helper function in CommandObject to get the most relevant target. In order of priority, that's the target from the command object's execution context, from the interpreter's execution context, the selected target or the dummy target. This function always return the dummy target if explicitly requested. rdar://110846511 >From 515525357026eb49508b1322b3b9ee40840f7b5e Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 29 Jul 2024 16:32:45 -0700 Subject: [PATCH] [lldb] Unify the way we get the Target in CommandObject Currently, CommandObjects are obtaining a target in a variety of ways. Often the command incorrectly operates on the selected target. As an example, when a breakpoint command is running, the current target is passed into the command but the target that hit the breakpoint is not the selected target. In other places we use the CommandObject's execution context, which is frozen during the execution of the command, which comes with its own limitations. And of course there's all the places where we need to use, or to fallback on the dummy target Instead of having to guess how to get the target, this patch introduces one helper function in CommandObject to get the most relevant target. In order of priority, that's the target from the command object's execution context, from the interpreter's execution context, the selected target or the dummy target. This function always return the dummy target if explicitly requested. rdar://110846511 --- lldb/include/lldb/Interpreter/CommandObject.h | 12 ++--- .../Commands/CommandObjectBreakpoint.cpp | 31 ++-- .../CommandObjectBreakpointCommand.cpp| 6 +-- .../Commands/CommandObjectDWIMPrint.cpp | 2 +- .../Commands/CommandObjectDisassemble.cpp | 10 ++-- .../Commands/CommandObjectExpression.cpp | 8 +-- lldb/source/Commands/CommandObjectFrame.cpp | 28 --- lldb/source/Commands/CommandObjectProcess.cpp | 4 +- lldb/source/Commands/CommandObjectTarget.cpp | 50 +-- lldb/source/Commands/CommandObjectThread.cpp | 2 +- .../Commands/CommandObjectWatchpoint.cpp | 16 +++--- .../CommandObjectWatchpointCommand.cpp| 6 +-- lldb/source/Interpreter/CommandObject.cpp | 34 +++-- .../DarwinLog/StructuredDataDarwinLog.cpp | 4 +- 14 files changed, 105 insertions(+), 108 deletions(-) diff --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h index d48dbcdd5a5da..16d89f1e5db87 100644 --- a/lldb/include/lldb/Interpreter/CommandObject.h +++ b/lldb/include/lldb/Interpreter/CommandObject.h @@ -369,12 +369,12 @@ class CommandObject : public std::enable_shared_from_this { "currently stopped."; } - // This is for use in the command interpreter, when you either want the - // selected target, or if no target is present you want to prime the dummy - // target with entities that will be copied over to new targets. - Target &GetSelectedOrDummyTarget(bool prefer_dummy = false); - Target &GetSelectedTarget(); - Target &GetDummyTarget(); + // This is for use in the command interpreter and returns the most relevant + // target. In order of priority, that's the target from the command object's + // execution context, from the interpreter's execution context, the selected + // target or the dummy target. This function always return the dummy target if + // explicitly requested. + Target &GetTarget(bool dummy = false); // If a command needs to use the "current" thread, use this call. Command // objects will have an ExecutionContext to use, and that may or may not have diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 773f8ed2fa8af..40be0cf02cd35 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -539,7 +539,7 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { protected: void DoExecute(Args &command, CommandReturnObject &result) override { -Target &target = GetSelectedOrDummyTarget(m_dummy_options.m_use_dummy); +Target &target = GetTarget(m_dummy_options.m_use_dummy); // The following are the various types of brea
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes Currently, CommandObjects are obtaining a target in a variety of ways. Often the command incorrectly operates on the selected target. As an example, when a breakpoint command is running, the current target is passed into the command but the target that hit the breakpoint is not the selected target. In other places we use the CommandObject's execution context, which is frozen during the execution of the command, which comes with its own limitations. And of course there's all the places where we need to use, or to fallback on the dummy target Instead of having to guess how to get the target, this patch introduces one helper function in CommandObject to get the most relevant target. In order of priority, that's the target from the command object's execution context, from the interpreter's execution context, the selected target or the dummy target. This function always return the dummy target if explicitly requested. rdar://110846511 --- Patch is 36.00 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/101208.diff 14 Files Affected: - (modified) lldb/include/lldb/Interpreter/CommandObject.h (+6-6) - (modified) lldb/source/Commands/CommandObjectBreakpoint.cpp (+14-17) - (modified) lldb/source/Commands/CommandObjectBreakpointCommand.cpp (+3-3) - (modified) lldb/source/Commands/CommandObjectDWIMPrint.cpp (+1-1) - (modified) lldb/source/Commands/CommandObjectDisassemble.cpp (+5-5) - (modified) lldb/source/Commands/CommandObjectExpression.cpp (+4-4) - (modified) lldb/source/Commands/CommandObjectFrame.cpp (+11-17) - (modified) lldb/source/Commands/CommandObjectProcess.cpp (+2-2) - (modified) lldb/source/Commands/CommandObjectTarget.cpp (+25-25) - (modified) lldb/source/Commands/CommandObjectThread.cpp (+1-1) - (modified) lldb/source/Commands/CommandObjectWatchpoint.cpp (+8-8) - (modified) lldb/source/Commands/CommandObjectWatchpointCommand.cpp (+3-3) - (modified) lldb/source/Interpreter/CommandObject.cpp (+20-14) - (modified) lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp (+2-2) ``diff diff --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h index d48dbcdd5a5da..16d89f1e5db87 100644 --- a/lldb/include/lldb/Interpreter/CommandObject.h +++ b/lldb/include/lldb/Interpreter/CommandObject.h @@ -369,12 +369,12 @@ class CommandObject : public std::enable_shared_from_this { "currently stopped."; } - // This is for use in the command interpreter, when you either want the - // selected target, or if no target is present you want to prime the dummy - // target with entities that will be copied over to new targets. - Target &GetSelectedOrDummyTarget(bool prefer_dummy = false); - Target &GetSelectedTarget(); - Target &GetDummyTarget(); + // This is for use in the command interpreter and returns the most relevant + // target. In order of priority, that's the target from the command object's + // execution context, from the interpreter's execution context, the selected + // target or the dummy target. This function always return the dummy target if + // explicitly requested. + Target &GetTarget(bool dummy = false); // If a command needs to use the "current" thread, use this call. Command // objects will have an ExecutionContext to use, and that may or may not have diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 773f8ed2fa8af..40be0cf02cd35 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -539,7 +539,7 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { protected: void DoExecute(Args &command, CommandReturnObject &result) override { -Target &target = GetSelectedOrDummyTarget(m_dummy_options.m_use_dummy); +Target &target = GetTarget(m_dummy_options.m_use_dummy); // The following are the various types of breakpoints that could be set: // 1). -f -l -p [-s -g] (setting breakpoint by source location) @@ -747,7 +747,7 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { const bool show_locations = false; bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial, show_locations); - if (&target == &GetDummyTarget()) + if (&target == &GetTarget(/*dummy=*/true)) output_stream.Printf("Breakpoint set in dummy target, will get copied " "into future targets.\n"); else { @@ -839,7 +839,7 @@ class CommandObjectBreakpointModify : public CommandObjectParsed { protected: void DoExecute(Args &command, CommandReturnObject &result) override { -Target &target = GetSelectedOrDummyTarget(m_dummy_opts.m_use_dummy); +Target &target = GetTarg
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
@@ -369,12 +369,12 @@ class CommandObject : public std::enable_shared_from_this { "currently stopped."; } - // This is for use in the command interpreter, when you either want the - // selected target, or if no target is present you want to prime the dummy - // target with entities that will be copied over to new targets. - Target &GetSelectedOrDummyTarget(bool prefer_dummy = false); - Target &GetSelectedTarget(); - Target &GetDummyTarget(); + // This is for use in the command interpreter and returns the most relevant + // target. In order of priority, that's the target from the command object's + // execution context, from the interpreter's execution context, the selected + // target or the dummy target. This function always return the dummy target if bulbazord wrote: nit: Oxford comma? 😄 https://github.com/llvm/llvm-project/pull/101208 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
@@ -754,23 +754,29 @@ const char *CommandObject::GetArgumentDescriptionAsCString( return g_argument_table[arg_type].help_text; } -Target &CommandObject::GetDummyTarget() { +Target &CommandObject::GetTarget(bool dummy) { + // Always return the dummy target if explicitly requested. + if (dummy) +return m_interpreter.GetDebugger().GetDummyTarget(); + + // Prefer the frozen execution context in the command object. + if (Target *target = m_exe_ctx.GetTargetPtr()) +return *target; + + // Fallback to the command interpreter's execution context in case we get + // called after DoExecute has finished. For example, when doing multi-line + // expression that uses an input reader or breakpoint callbacks. + if (Target *target = m_interpreter.GetExecutionContext().GetTargetPtr()) +return *target; + + // Finally, if we have no other target, get the selected target. + if (TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget()) +return *target_sp; + + // We only have the dummy target. return m_interpreter.GetDebugger().GetDummyTarget(); } -Target &CommandObject::GetSelectedOrDummyTarget(bool prefer_dummy) { - return m_interpreter.GetDebugger().GetSelectedOrDummyTarget(prefer_dummy); -} - -Target &CommandObject::GetSelectedTarget() { - assert(m_flags.AnySet(eCommandRequiresTarget | eCommandProcessMustBePaused | bulbazord wrote: Do you think this assertion would still be useful to have? https://github.com/llvm/llvm-project/pull/101208 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][win][x86_64] Fix XFAIL and XPASS on LLDB API tests (PR #100477)
@@ -12,6 +12,7 @@ class MultipleSlidesTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True +@expectedFailureAll(oslist=["windows"], archs=["x86_64"]) kendalharland wrote: I see. Our command lines look identical. Can you also please share the linker command that your clang invocation is generating? I am also curious to know how you built lld. Perhaps I'm missing an earlier step. My clang output with `-v` specified is: ``` "C:\workspace\llvm-project\build\bin\clang.exe" -O0 -m64-c C:\workspace\llvm-project\lldb\test\API\functionalities\multiple-slides/main.c -o main.o "C:\workspace\llvm-project\build\bin\clang.exe" main.o -gdwarf -O0 -m64 -IC:\workspace\llvm-project\lldb\packages\Python\lldbsuite\test\make/../../../../../include -IC:/workspace/llvm-project/build/tools/lldb/include -IC:\workspace\llvm-project\lldb\test\API\functionalities\multiple-slides -IC:\workspace\llvm-project\lldb\packages\Python\lldbsuite\test\make -include C:\workspace\llvm-project\lldb\packages\Python\lldbsuite\test\make/test_common.h -fno-limit-debug-info -v -fuse-ld=lld --driver-mode=g++ -o "a.out" clang version 20.0.0git (https://github.com/kendalharland/llvm-project bf6f1f2f5f23857eb18e08fbef29c5ca2e553bea) Target: x86_64-unknown-windows-msvc Thread model: posix InstalledDir: C:\workspace\llvm-project\build\bin "C:\\workspace\\llvm-project\\build\\bin\\lld-link" -out:a.out -defaultlib:libcmt -defaultlib:oldnames -nologo -debug main.o ``` https://github.com/llvm/llvm-project/pull/100477 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
@@ -369,12 +369,12 @@ class CommandObject : public std::enable_shared_from_this { "currently stopped."; } - // This is for use in the command interpreter, when you either want the - // selected target, or if no target is present you want to prime the dummy - // target with entities that will be copied over to new targets. - Target &GetSelectedOrDummyTarget(bool prefer_dummy = false); - Target &GetSelectedTarget(); - Target &GetDummyTarget(); + // This is for use in the command interpreter and returns the most relevant + // target. In order of priority, that's the target from the command object's + // execution context, from the interpreter's execution context, the selected + // target or the dummy target. This function always return the dummy target if jimingham wrote: always returns not always return https://github.com/llvm/llvm-project/pull/101208 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][win][x86_64] Fix XFAIL and XPASS on LLDB API tests (PR #100477)
@@ -12,6 +12,7 @@ class MultipleSlidesTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True +@expectedFailureAll(oslist=["windows"], archs=["x86_64"]) kendalharland wrote: For comparison, my objdump output shows no symbol table: ``` PS C:\workspace\llvm-project> C:\workspace\llvm-project\build\bin\llvm-objdump -t C:\workspace\llvm-project\build\lldb-test-build.noindex\functionalities\multiple-slides\TestMultipleSlides.test_mulitple_slides\a.out C:\workspace\llvm-project\build\lldb-test-build.noindex\functionalities\multiple-slides\TestMultipleSlides.test_mulitple_slides\a.out: file format coff-x86-64 SYMBOL TABLE: ``` https://github.com/llvm/llvm-project/pull/100477 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
@@ -754,23 +754,29 @@ const char *CommandObject::GetArgumentDescriptionAsCString( return g_argument_table[arg_type].help_text; } -Target &CommandObject::GetDummyTarget() { +Target &CommandObject::GetTarget(bool dummy) { + // Always return the dummy target if explicitly requested. + if (dummy) +return m_interpreter.GetDebugger().GetDummyTarget(); + + // Prefer the frozen execution context in the command object. + if (Target *target = m_exe_ctx.GetTargetPtr()) +return *target; + + // Fallback to the command interpreter's execution context in case we get + // called after DoExecute has finished. For example, when doing multi-line + // expression that uses an input reader or breakpoint callbacks. + if (Target *target = m_interpreter.GetExecutionContext().GetTargetPtr()) +return *target; + + // Finally, if we have no other target, get the selected target. + if (TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget()) +return *target_sp; + + // We only have the dummy target. jimingham wrote: I don't think it's worth using an optional here, but passing out a reference here means that if you called this with dummy == false, and there was only the dummy target, we would still return the Dummy target. That seems unexpected - but maybe just worth a comment? https://github.com/llvm/llvm-project/pull/101208 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
@@ -754,23 +754,29 @@ const char *CommandObject::GetArgumentDescriptionAsCString( return g_argument_table[arg_type].help_text; } -Target &CommandObject::GetDummyTarget() { +Target &CommandObject::GetTarget(bool dummy) { + // Always return the dummy target if explicitly requested. + if (dummy) +return m_interpreter.GetDebugger().GetDummyTarget(); + + // Prefer the frozen execution context in the command object. + if (Target *target = m_exe_ctx.GetTargetPtr()) +return *target; + + // Fallback to the command interpreter's execution context in case we get + // called after DoExecute has finished. For example, when doing multi-line + // expression that uses an input reader or breakpoint callbacks. + if (Target *target = m_interpreter.GetExecutionContext().GetTargetPtr()) +return *target; + + // Finally, if we have no other target, get the selected target. + if (TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget()) +return *target_sp; + + // We only have the dummy target. return m_interpreter.GetDebugger().GetDummyTarget(); } -Target &CommandObject::GetSelectedOrDummyTarget(bool prefer_dummy) { - return m_interpreter.GetDebugger().GetSelectedOrDummyTarget(prefer_dummy); -} - -Target &CommandObject::GetSelectedTarget() { - assert(m_flags.AnySet(eCommandRequiresTarget | eCommandProcessMustBePaused | JDevlieghere wrote: Not really, since we now fall back to the dummy target. The only place to put it would be in the last if-clause but at that point we know the target already exists so there's nothing to assert anymore. https://github.com/llvm/llvm-project/pull/101208 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
@@ -754,23 +754,29 @@ const char *CommandObject::GetArgumentDescriptionAsCString( return g_argument_table[arg_type].help_text; } -Target &CommandObject::GetDummyTarget() { +Target &CommandObject::GetTarget(bool dummy) { + // Always return the dummy target if explicitly requested. + if (dummy) +return m_interpreter.GetDebugger().GetDummyTarget(); + + // Prefer the frozen execution context in the command object. + if (Target *target = m_exe_ctx.GetTargetPtr()) +return *target; + + // Fallback to the command interpreter's execution context in case we get + // called after DoExecute has finished. For example, when doing multi-line + // expression that uses an input reader or breakpoint callbacks. + if (Target *target = m_interpreter.GetExecutionContext().GetTargetPtr()) +return *target; + + // Finally, if we have no other target, get the selected target. + if (TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget()) +return *target_sp; + + // We only have the dummy target. JDevlieghere wrote: The `dummy` argument is meant to indicate that we always want the dummy target. Would it be clearer if I called it `force_dummy` or `dummy_only` or something? https://github.com/llvm/llvm-project/pull/101208 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
@@ -754,23 +754,29 @@ const char *CommandObject::GetArgumentDescriptionAsCString( return g_argument_table[arg_type].help_text; } -Target &CommandObject::GetDummyTarget() { +Target &CommandObject::GetTarget(bool dummy) { + // Always return the dummy target if explicitly requested. + if (dummy) +return m_interpreter.GetDebugger().GetDummyTarget(); + + // Prefer the frozen execution context in the command object. + if (Target *target = m_exe_ctx.GetTargetPtr()) +return *target; + + // Fallback to the command interpreter's execution context in case we get + // called after DoExecute has finished. For example, when doing multi-line + // expression that uses an input reader or breakpoint callbacks. + if (Target *target = m_interpreter.GetExecutionContext().GetTargetPtr()) +return *target; + + // Finally, if we have no other target, get the selected target. + if (TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget()) +return *target_sp; + + // We only have the dummy target. JDevlieghere wrote: Or `prefer_dummy` like the original signature? I shortened it to facilitate the inline comments, but I can change it back. https://github.com/llvm/llvm-project/pull/101208 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
@@ -754,23 +754,29 @@ const char *CommandObject::GetArgumentDescriptionAsCString( return g_argument_table[arg_type].help_text; } -Target &CommandObject::GetDummyTarget() { +Target &CommandObject::GetTarget(bool dummy) { + // Always return the dummy target if explicitly requested. + if (dummy) +return m_interpreter.GetDebugger().GetDummyTarget(); + + // Prefer the frozen execution context in the command object. + if (Target *target = m_exe_ctx.GetTargetPtr()) +return *target; + + // Fallback to the command interpreter's execution context in case we get + // called after DoExecute has finished. For example, when doing multi-line + // expression that uses an input reader or breakpoint callbacks. + if (Target *target = m_interpreter.GetExecutionContext().GetTargetPtr()) +return *target; + + // Finally, if we have no other target, get the selected target. + if (TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget()) +return *target_sp; + + // We only have the dummy target. jimingham wrote: Is it worth having that flag, since if you wanted ONLY the dummy target, you could still call GetDummyTarget. https://github.com/llvm/llvm-project/pull/101208 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
@@ -754,23 +754,29 @@ const char *CommandObject::GetArgumentDescriptionAsCString( return g_argument_table[arg_type].help_text; } -Target &CommandObject::GetDummyTarget() { +Target &CommandObject::GetTarget(bool dummy) { + // Always return the dummy target if explicitly requested. + if (dummy) +return m_interpreter.GetDebugger().GetDummyTarget(); + + // Prefer the frozen execution context in the command object. + if (Target *target = m_exe_ctx.GetTargetPtr()) +return *target; + + // Fallback to the command interpreter's execution context in case we get + // called after DoExecute has finished. For example, when doing multi-line + // expression that uses an input reader or breakpoint callbacks. + if (Target *target = m_interpreter.GetExecutionContext().GetTargetPtr()) +return *target; + + // Finally, if we have no other target, get the selected target. + if (TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget()) +return *target_sp; + + // We only have the dummy target. jimingham wrote: I kind of like that better, you shouldn't be dialing up the dummy target directly unless you really mean it, so making that stand out a bit more in the code might be good. https://github.com/llvm/llvm-project/pull/101208 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
@@ -754,23 +754,29 @@ const char *CommandObject::GetArgumentDescriptionAsCString( return g_argument_table[arg_type].help_text; } -Target &CommandObject::GetDummyTarget() { +Target &CommandObject::GetTarget(bool dummy) { + // Always return the dummy target if explicitly requested. + if (dummy) +return m_interpreter.GetDebugger().GetDummyTarget(); + + // Prefer the frozen execution context in the command object. + if (Target *target = m_exe_ctx.GetTargetPtr()) +return *target; + + // Fallback to the command interpreter's execution context in case we get + // called after DoExecute has finished. For example, when doing multi-line + // expression that uses an input reader or breakpoint callbacks. + if (Target *target = m_interpreter.GetExecutionContext().GetTargetPtr()) +return *target; + + // Finally, if we have no other target, get the selected target. + if (TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget()) +return *target_sp; + + // We only have the dummy target. jimingham wrote: I don't like `prefer_dummy`, "prefer" makes it sound like not returning the dummy is an option here, which it isn't... https://github.com/llvm/llvm-project/pull/101208 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/101208 >From 515525357026eb49508b1322b3b9ee40840f7b5e Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 29 Jul 2024 16:32:45 -0700 Subject: [PATCH 1/2] [lldb] Unify the way we get the Target in CommandObject Currently, CommandObjects are obtaining a target in a variety of ways. Often the command incorrectly operates on the selected target. As an example, when a breakpoint command is running, the current target is passed into the command but the target that hit the breakpoint is not the selected target. In other places we use the CommandObject's execution context, which is frozen during the execution of the command, which comes with its own limitations. And of course there's all the places where we need to use, or to fallback on the dummy target Instead of having to guess how to get the target, this patch introduces one helper function in CommandObject to get the most relevant target. In order of priority, that's the target from the command object's execution context, from the interpreter's execution context, the selected target or the dummy target. This function always return the dummy target if explicitly requested. rdar://110846511 --- lldb/include/lldb/Interpreter/CommandObject.h | 12 ++--- .../Commands/CommandObjectBreakpoint.cpp | 31 ++-- .../CommandObjectBreakpointCommand.cpp| 6 +-- .../Commands/CommandObjectDWIMPrint.cpp | 2 +- .../Commands/CommandObjectDisassemble.cpp | 10 ++-- .../Commands/CommandObjectExpression.cpp | 8 +-- lldb/source/Commands/CommandObjectFrame.cpp | 28 --- lldb/source/Commands/CommandObjectProcess.cpp | 4 +- lldb/source/Commands/CommandObjectTarget.cpp | 50 +-- lldb/source/Commands/CommandObjectThread.cpp | 2 +- .../Commands/CommandObjectWatchpoint.cpp | 16 +++--- .../CommandObjectWatchpointCommand.cpp| 6 +-- lldb/source/Interpreter/CommandObject.cpp | 34 +++-- .../DarwinLog/StructuredDataDarwinLog.cpp | 4 +- 14 files changed, 105 insertions(+), 108 deletions(-) diff --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h index d48dbcdd5a5da..16d89f1e5db87 100644 --- a/lldb/include/lldb/Interpreter/CommandObject.h +++ b/lldb/include/lldb/Interpreter/CommandObject.h @@ -369,12 +369,12 @@ class CommandObject : public std::enable_shared_from_this { "currently stopped."; } - // This is for use in the command interpreter, when you either want the - // selected target, or if no target is present you want to prime the dummy - // target with entities that will be copied over to new targets. - Target &GetSelectedOrDummyTarget(bool prefer_dummy = false); - Target &GetSelectedTarget(); - Target &GetDummyTarget(); + // This is for use in the command interpreter and returns the most relevant + // target. In order of priority, that's the target from the command object's + // execution context, from the interpreter's execution context, the selected + // target or the dummy target. This function always return the dummy target if + // explicitly requested. + Target &GetTarget(bool dummy = false); // If a command needs to use the "current" thread, use this call. Command // objects will have an ExecutionContext to use, and that may or may not have diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 773f8ed2fa8af..40be0cf02cd35 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -539,7 +539,7 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { protected: void DoExecute(Args &command, CommandReturnObject &result) override { -Target &target = GetSelectedOrDummyTarget(m_dummy_options.m_use_dummy); +Target &target = GetTarget(m_dummy_options.m_use_dummy); // The following are the various types of breakpoints that could be set: // 1). -f -l -p [-s -g] (setting breakpoint by source location) @@ -747,7 +747,7 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { const bool show_locations = false; bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial, show_locations); - if (&target == &GetDummyTarget()) + if (&target == &GetTarget(/*dummy=*/true)) output_stream.Printf("Breakpoint set in dummy target, will get copied " "into future targets.\n"); else { @@ -839,7 +839,7 @@ class CommandObjectBreakpointModify : public CommandObjectParsed { protected: void DoExecute(Args &command, CommandReturnObject &result) override { -Target &target = GetSelectedOrDummyTarget(m_dummy_opts.m_use_dummy); +Target &target = GetTarget(m_dummy_opts.m_use_dummy); std::unique_lock lock; target.GetBreak
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
@@ -754,23 +754,29 @@ const char *CommandObject::GetArgumentDescriptionAsCString( return g_argument_table[arg_type].help_text; } -Target &CommandObject::GetDummyTarget() { +Target &CommandObject::GetTarget(bool dummy) { + // Always return the dummy target if explicitly requested. + if (dummy) +return m_interpreter.GetDebugger().GetDummyTarget(); + + // Prefer the frozen execution context in the command object. + if (Target *target = m_exe_ctx.GetTargetPtr()) +return *target; + + // Fallback to the command interpreter's execution context in case we get + // called after DoExecute has finished. For example, when doing multi-line + // expression that uses an input reader or breakpoint callbacks. + if (Target *target = m_interpreter.GetExecutionContext().GetTargetPtr()) +return *target; + + // Finally, if we have no other target, get the selected target. + if (TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget()) +return *target_sp; + + // We only have the dummy target. JDevlieghere wrote: Alright, I removed the argument from `GetTarget` and added `GetDummyTarget` again. https://github.com/llvm/llvm-project/pull/101208 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
@@ -754,23 +754,29 @@ const char *CommandObject::GetArgumentDescriptionAsCString( return g_argument_table[arg_type].help_text; } -Target &CommandObject::GetDummyTarget() { +Target &CommandObject::GetTarget(bool dummy) { + // Always return the dummy target if explicitly requested. + if (dummy) +return m_interpreter.GetDebugger().GetDummyTarget(); + + // Prefer the frozen execution context in the command object. + if (Target *target = m_exe_ctx.GetTargetPtr()) +return *target; + + // Fallback to the command interpreter's execution context in case we get + // called after DoExecute has finished. For example, when doing multi-line + // expression that uses an input reader or breakpoint callbacks. + if (Target *target = m_interpreter.GetExecutionContext().GetTargetPtr()) +return *target; + + // Finally, if we have no other target, get the selected target. + if (TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget()) +return *target_sp; + + // We only have the dummy target. jimingham wrote: Yeah, that makes the case where people are dialing it up from an option slightly more verbose, but much clearer what's going on. https://github.com/llvm/llvm-project/pull/101208 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
https://github.com/jimingham approved this pull request. This is a great cleanup, thanks for doing it! https://github.com/llvm/llvm-project/pull/101208 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change Module to have a concrete UnwindTable, update (PR #101130)
@@ -64,7 +64,7 @@ class UnwindTable { private: void Dump(Stream &s); - void Initialize(); + void Initialize(bool force = false); jimingham wrote: This needs a comment explaining what you are forcing. https://github.com/llvm/llvm-project/pull/101130 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
https://github.com/bulbazord approved this pull request. https://github.com/llvm/llvm-project/pull/101208 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/101208 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][win][x86_64] Fix XFAIL and XPASS on LLDB API tests (PR #100477)
@@ -12,6 +12,7 @@ class MultipleSlidesTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True +@expectedFailureAll(oslist=["windows"], archs=["x86_64"]) dzhidzhoev wrote: ``` $ F:/Users/vdzhidzhoev/temp/build-lldb-native/bin/clang.exe main.o -gdwarf -O0 -m64 -IF:\Users\vdzhidzhoev\temp\llvm-project\lldb\packages\Python\lldbsuite\test\make/../../../../..//include -IF:/Users/vdzhidzhoev/temp/build-lldb-native/tools/lldb/include -IF:\Users\vdzhidzhoev\temp\llvm-project\lldb\test\API\functionalities\multiple-slides -IF:\Users\vdzhidzhoev\temp\llvm-project\lldb\packages\Python\lldbsuite\test\make -include F:\Users\vdzhidzhoev\temp\llvm-project\lldb\packages\Python\lldbsuite\test\make/test_common.h -fno-limit-debug-info -fuse-ld=lld --driver-mode=g++ -o "a.out" -v clang version 20.0.0git (g...@gitlab.ninolab.accesssoftek.com:accesssoftek/lldb-test-scripts.git 8d8d23fec72ad6ff77e15e7627ab8cc26ac36d4c) Target: x86_64-pc-windows-msvc Thread model: posix InstalledDir: F:\Users\vdzhidzhoev\temp\build-lldb-native\bin Build config: +assertions "F:\\Users\\vdzhidzhoev\\temp\\build-lldb-native\\bin\\lld-link" -out:a.out -defaultlib:libcmt -defaultlib:oldnames -nologo -debug main.o ``` https://github.com/llvm/llvm-project/pull/100477 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][win][x86_64] Fix XFAIL and XPASS on LLDB API tests (PR #100477)
https://github.com/dzhidzhoev edited https://github.com/llvm/llvm-project/pull/100477 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][win][x86_64] Fix XFAIL and XPASS on LLDB API tests (PR #100477)
@@ -12,6 +12,7 @@ class MultipleSlidesTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True +@expectedFailureAll(oslist=["windows"], archs=["x86_64"]) dzhidzhoev wrote: > For comparison, my objdump output shows no symbol table: > > ``` > PS C:\workspace\llvm-project> > C:\workspace\llvm-project\build\bin\llvm-objdump -t > C:\workspace\llvm-project\build\lldb-test-build.noindex\functionalities\multiple-slides\TestMultipleSlides.test_mulitple_slides\a.out > > C:\workspace\llvm-project\build\lldb-test-build.noindex\functionalities\multiple-slides\TestMultipleSlides.test_mulitple_slides\a.out: > file format coff-x86-64 > > SYMBOL TABLE: > ``` I have the same for a.out. The dump I provided (with "first") was launched for main.o. Try launching bin/lldb, "file a.out", "image dump symtab a.out", and there should be "first" symbol. Beware that will probably show A LOT of entries. https://github.com/llvm/llvm-project/pull/100477 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][win][x86_64] Fix XFAIL and XPASS on LLDB API tests (PR #100477)
https://github.com/dzhidzhoev edited https://github.com/llvm/llvm-project/pull/100477 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][win][x86_64] Fix XFAIL and XPASS on LLDB API tests (PR #100477)
https://github.com/dzhidzhoev edited https://github.com/llvm/llvm-project/pull/100477 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Impove ObjectFileELF's .dynamic parsing and usage. (PR #101237)
https://github.com/clayborg created https://github.com/llvm/llvm-project/pull/101237 This patch improves the ability of a ObjectFileELF instance to read the .dynamic section. It adds the ability to read the .dynamic section from a ELF file that is read from memory, cleans up the usage of the .dynamic entries so that ObjectFileELF::ParseDynamicSymbols() is the only code that parses .dynamic entries, teaches that function the read and store the string values for each .dynamic entry, and dumps the .dynamic entries in the output of "image dump objfile". It also cleans up the code that gets the dynamic string table and the .dynamic data from the ELF file. >From 6ef64acd518afe8bdc42c5042f35c857be96e3b4 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Tue, 30 Jul 2024 13:37:44 -0700 Subject: [PATCH] Impove ObjectFileELF's .dynamic parsing and usage. This patch improves the ability of a ObjectFileELF instance to read the .dynamic section. It adds the ability to read the .dynamic section from a ELF file that is read from memory, cleans up the usage of the .dynamic entries so that ObjectFileELF::ParseDynamicSymbols() is the only code that parses .dynamic entries, teaches that function the read and store the string values for each .dynamic entry, and dumps the .dynamic entries in the output of "image dump objfile". It also cleans up the code that gets the dynamic string table and the .dynamic data from the ELF file. --- lldb/include/lldb/Target/Process.h| 2 +- .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 356 +- .../Plugins/ObjectFile/ELF/ObjectFileELF.h| 38 +- lldb/source/Target/Process.cpp| 15 + .../ObjectFile/ELF/Inputs/memory-elf.cpp | 6 + .../test/Shell/ObjectFile/ELF/elf-memory.test | 58 +++ 6 files changed, 378 insertions(+), 97 deletions(-) create mode 100644 lldb/test/Shell/ObjectFile/ELF/Inputs/memory-elf.cpp create mode 100644 lldb/test/Shell/ObjectFile/ELF/elf-memory.test diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index c8475db8ae160..17e18261b4752 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1952,7 +1952,7 @@ class Process : public std::enable_shared_from_this, lldb::ModuleSP ReadModuleFromMemory(const FileSpec &file_spec, lldb::addr_t header_addr, - size_t size_to_read = 512); + size_t size_to_read = 0); /// Attempt to get the attributes for a region of memory in the process. /// diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 890db5c274814..becee73f96205 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -873,33 +873,29 @@ Address ObjectFileELF::GetImageInfoAddress(Target *target) { if (!section_list) return Address(); - // Find the SHT_DYNAMIC (.dynamic) section. - SectionSP dynsym_section_sp( - section_list->FindSectionByType(eSectionTypeELFDynamicLinkInfo, true)); - if (!dynsym_section_sp) -return Address(); - assert(dynsym_section_sp->GetObjectFile() == this); - - user_id_t dynsym_id = dynsym_section_sp->GetID(); - const ELFSectionHeaderInfo *dynsym_hdr = GetSectionHeaderByIndex(dynsym_id); - if (!dynsym_hdr) -return Address(); - for (size_t i = 0; i < m_dynamic_symbols.size(); ++i) { -ELFDynamic &symbol = m_dynamic_symbols[i]; +const ELFDynamic &symbol = m_dynamic_symbols[i].symbol; if (symbol.d_tag == DT_DEBUG) { // Compute the offset as the number of previous entries plus the size of // d_tag. - addr_t offset = i * dynsym_hdr->sh_entsize + GetAddressByteSize(); - return Address(dynsym_section_sp, offset); + addr_t offset = (i * 2 + 1) * GetAddressByteSize(); + addr_t file_addr = m_dynamic_base_addr + offset; + Address addr; + if (addr.ResolveAddressUsingFileSections(file_addr, GetSectionList())) +return addr; } // MIPS executables uses DT_MIPS_RLD_MAP_REL to support PIE. DT_MIPS_RLD_MAP // exists in non-PIE. else if ((symbol.d_tag == DT_MIPS_RLD_MAP || symbol.d_tag == DT_MIPS_RLD_MAP_REL) && target) { - addr_t offset = i * dynsym_hdr->sh_entsize + GetAddressByteSize(); + SectionSP dynsym_section_sp(section_list->FindSectionByType( + eSectionTypeELFDynamicLinkInfo, true)); + if (!dynsym_section_sp) +return Address(); + + addr_t offset = (i * 2 + 1) * GetAddressByteSize(); addr_t dyn_base = dynsym_section_sp->GetLoadBaseAddress(target); if (dyn_base == LLDB_INVALID_ADDRESS) return Address(); @@ -970,62 +966,23 @@ Address ObjectFileELF::GetBaseAddress() { return LLDB_INVALID_ADDRESS; } -// ParseDependentModules size_t ObjectF
[Lldb-commits] [lldb] Impove ObjectFileELF's .dynamic parsing and usage. (PR #101237)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Greg Clayton (clayborg) Changes This patch improves the ability of a ObjectFileELF instance to read the .dynamic section. It adds the ability to read the .dynamic section from a ELF file that is read from memory, cleans up the usage of the .dynamic entries so that ObjectFileELF::ParseDynamicSymbols() is the only code that parses .dynamic entries, teaches that function the read and store the string values for each .dynamic entry, and dumps the .dynamic entries in the output of "image dump objfile". It also cleans up the code that gets the dynamic string table and the .dynamic data from the ELF file. --- Patch is 22.51 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/101237.diff 6 Files Affected: - (modified) lldb/include/lldb/Target/Process.h (+1-1) - (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (+261-95) - (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h (+37-1) - (modified) lldb/source/Target/Process.cpp (+15) - (added) lldb/test/Shell/ObjectFile/ELF/Inputs/memory-elf.cpp (+6) - (added) lldb/test/Shell/ObjectFile/ELF/elf-memory.test (+58) ``diff diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index c8475db8ae160..17e18261b4752 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1952,7 +1952,7 @@ class Process : public std::enable_shared_from_this, lldb::ModuleSP ReadModuleFromMemory(const FileSpec &file_spec, lldb::addr_t header_addr, - size_t size_to_read = 512); + size_t size_to_read = 0); /// Attempt to get the attributes for a region of memory in the process. /// diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 890db5c274814..becee73f96205 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -873,33 +873,29 @@ Address ObjectFileELF::GetImageInfoAddress(Target *target) { if (!section_list) return Address(); - // Find the SHT_DYNAMIC (.dynamic) section. - SectionSP dynsym_section_sp( - section_list->FindSectionByType(eSectionTypeELFDynamicLinkInfo, true)); - if (!dynsym_section_sp) -return Address(); - assert(dynsym_section_sp->GetObjectFile() == this); - - user_id_t dynsym_id = dynsym_section_sp->GetID(); - const ELFSectionHeaderInfo *dynsym_hdr = GetSectionHeaderByIndex(dynsym_id); - if (!dynsym_hdr) -return Address(); - for (size_t i = 0; i < m_dynamic_symbols.size(); ++i) { -ELFDynamic &symbol = m_dynamic_symbols[i]; +const ELFDynamic &symbol = m_dynamic_symbols[i].symbol; if (symbol.d_tag == DT_DEBUG) { // Compute the offset as the number of previous entries plus the size of // d_tag. - addr_t offset = i * dynsym_hdr->sh_entsize + GetAddressByteSize(); - return Address(dynsym_section_sp, offset); + addr_t offset = (i * 2 + 1) * GetAddressByteSize(); + addr_t file_addr = m_dynamic_base_addr + offset; + Address addr; + if (addr.ResolveAddressUsingFileSections(file_addr, GetSectionList())) +return addr; } // MIPS executables uses DT_MIPS_RLD_MAP_REL to support PIE. DT_MIPS_RLD_MAP // exists in non-PIE. else if ((symbol.d_tag == DT_MIPS_RLD_MAP || symbol.d_tag == DT_MIPS_RLD_MAP_REL) && target) { - addr_t offset = i * dynsym_hdr->sh_entsize + GetAddressByteSize(); + SectionSP dynsym_section_sp(section_list->FindSectionByType( + eSectionTypeELFDynamicLinkInfo, true)); + if (!dynsym_section_sp) +return Address(); + + addr_t offset = (i * 2 + 1) * GetAddressByteSize(); addr_t dyn_base = dynsym_section_sp->GetLoadBaseAddress(target); if (dyn_base == LLDB_INVALID_ADDRESS) return Address(); @@ -970,62 +966,23 @@ Address ObjectFileELF::GetBaseAddress() { return LLDB_INVALID_ADDRESS; } -// ParseDependentModules size_t ObjectFileELF::ParseDependentModules() { if (m_filespec_up) return m_filespec_up->GetSize(); m_filespec_up = std::make_unique(); - if (!ParseSectionHeaders()) -return 0; - - SectionList *section_list = GetSectionList(); - if (!section_list) -return 0; - - // Find the SHT_DYNAMIC section. - Section *dynsym = - section_list->FindSectionByType(eSectionTypeELFDynamicLinkInfo, true) - .get(); - if (!dynsym) -return 0; - assert(dynsym->GetObjectFile() == this); - - const ELFSectionHeaderInfo *header = GetSectionHeaderByIndex(dynsym->GetID()); - if (!header) -return 0; - // sh_link: section header index of string table used by entries in the - // section. - Section *dynstr = section_list->FindSectionByID(header->sh_link).
[Lldb-commits] [lldb] [LLDB] Improve ObjectFileELF files ability to load from memory. (PR #100900)
https://github.com/clayborg closed https://github.com/llvm/llvm-project/pull/100900 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Improve ObjectFileELF files ability to load from memory. (PR #100900)
clayborg wrote: I am going to split this up. New PR with just .dynamic changes is here: https://github.com/llvm/llvm-project/pull/101237 https://github.com/llvm/llvm-project/pull/100900 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Impove ObjectFileELF's .dynamic parsing and usage. (PR #101237)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff bee2654300a8f524e05dd4cad41411d597246ac0 6ef64acd518afe8bdc42c5042f35c857be96e3b4 --extensions cpp,h -- lldb/test/Shell/ObjectFile/ELF/Inputs/memory-elf.cpp lldb/include/lldb/Target/Process.h lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h lldb/source/Target/Process.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index becee73f96..ee891a5182 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -3208,7 +3208,7 @@ void ObjectFileELF::Dump(Stream *s) { DumpDependentModules(s); s->EOL(); DumpELFDynamic(s); - s->EOL(); + s->EOL(); } // DumpELFHeader @@ -3797,8 +3797,8 @@ std::optional ObjectFileELF::GetDynstrData() { if (section_list) { // Find the SHT_DYNAMIC section. Section *dynamic = - section_list->FindSectionByType(eSectionTypeELFDynamicLinkInfo, true) - .get(); +section_list->FindSectionByType(eSectionTypeELFDynamicLinkInfo, true) +.get(); if (dynamic) { assert(dynamic->GetObjectFile() == this); const ELFSectionHeaderInfo *header = diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h index cb38830197..ae2025ba2c 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h @@ -436,8 +436,6 @@ private: /// \return The bytes that represent the string table data or \c std::nullopt /// if an error occured. std::optional GetDynstrData(); - - }; #endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_ELF_OBJECTFILEELF_H diff --git a/lldb/test/Shell/ObjectFile/ELF/Inputs/memory-elf.cpp b/lldb/test/Shell/ObjectFile/ELF/Inputs/memory-elf.cpp index f4162a4a1d..9cae6c99c9 100644 --- a/lldb/test/Shell/ObjectFile/ELF/Inputs/memory-elf.cpp +++ b/lldb/test/Shell/ObjectFile/ELF/Inputs/memory-elf.cpp @@ -3,4 +3,3 @@ int main() { printf("Hello World\n"); // Use something from libc.so return 0; } - `` https://github.com/llvm/llvm-project/pull/101237 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Impove ObjectFileELF's .dynamic parsing and usage. (PR #101237)
https://github.com/tschuett edited https://github.com/llvm/llvm-project/pull/101237 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change Module to have a concrete UnwindTable, update (PR #101130)
jimingham wrote: So the strategy here is the UnwindTable class calls its `Initialize()` any time a client wants to use an UnwindTable so that it can be lazily filled. Then Module calls `UnwindTable::Update()` any time something gets added to the module that might change the unwind table. That seems pretty clear. It is a little odd that the laziness of the UnwindTable itself gets defeated by Update, which forces the Initialize even if the unwind table isn't currently being requested. Not sure if that matters? If it does, Update could just tell the UnwindTable that next time it gets asked a question it has to reread the unwind information. Maybe it could even just set m_initialized back to `false` and then let the lazy initialization redo the work when requested? https://github.com/llvm/llvm-project/pull/101130 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change Module to have a concrete UnwindTable, update (PR #101130)
@@ -64,7 +64,7 @@ class UnwindTable { private: void Dump(Stream &s); - void Initialize(); + void Initialize(bool force = false); jasonmolenda wrote: Yeah I'm not thrilled with the terminology I used. But I had `Initialize` which assumed no unwind sources had been discovered, and `Update` called after a SymbolFileVendor is added to the Module which looks for any un-set unwind sources and checks to see if they can now be found. That duplication didn't thrill me. https://github.com/llvm/llvm-project/pull/101130 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change Module to have a concrete UnwindTable, update (PR #101130)
jasonmolenda wrote: > It is a little odd that the laziness of the UnwindTable itself gets defeated > by Update, which forces the Initialize even if the unwind table isn't > currently being requested. I could add an ivar `m_module_has_updated` which is set when a new ObjectFile/SymbolFileVendor is added to the Module. And all the getter methods in UnwindTable call `Initialize()` which currently checks that it has been initialized or not, and add that in. > Not sure if that matters? If it does, Update could just tell the UnwindTable > that next time it gets asked a question it has to reread the unwind > information. Maybe it could even just set m_initialized back to `false` and > then let the lazy initialization redo the work when requested? Hah, I didn't read your full comment. Yes, same idea, and just as good. I'll do that. https://github.com/llvm/llvm-project/pull/101130 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix TestMultipleDebuggers test on non-x86, other small issues (PR #101169)
https://github.com/jasonmolenda approved this pull request. Thanks for the good cleanup. https://github.com/llvm/llvm-project/pull/101169 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ObjectFileJSON and Section changes to support section.address field i… (PR #101062)
JDevlieghere wrote: > I was hoping to fix everything in one Pull Request so that it at least > becomes usable once this merges. The LLVM project generally [prefers](https://llvm.org/docs/CodeReview.html#code-reviews-speed-and-reciprocity) smaller patches as they're easier to review. We'll definitely want to fix the end-to-end issue and have a test, but the deserialization issue can stand on its own and deserves its own PR. https://github.com/llvm/llvm-project/pull/101062 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Impove ObjectFileELF's .dynamic parsing and usage. (PR #101237)
https://github.com/clayborg updated https://github.com/llvm/llvm-project/pull/101237 >From 6ef64acd518afe8bdc42c5042f35c857be96e3b4 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Tue, 30 Jul 2024 13:37:44 -0700 Subject: [PATCH 1/2] Impove ObjectFileELF's .dynamic parsing and usage. This patch improves the ability of a ObjectFileELF instance to read the .dynamic section. It adds the ability to read the .dynamic section from a ELF file that is read from memory, cleans up the usage of the .dynamic entries so that ObjectFileELF::ParseDynamicSymbols() is the only code that parses .dynamic entries, teaches that function the read and store the string values for each .dynamic entry, and dumps the .dynamic entries in the output of "image dump objfile". It also cleans up the code that gets the dynamic string table and the .dynamic data from the ELF file. --- lldb/include/lldb/Target/Process.h| 2 +- .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 356 +- .../Plugins/ObjectFile/ELF/ObjectFileELF.h| 38 +- lldb/source/Target/Process.cpp| 15 + .../ObjectFile/ELF/Inputs/memory-elf.cpp | 6 + .../test/Shell/ObjectFile/ELF/elf-memory.test | 58 +++ 6 files changed, 378 insertions(+), 97 deletions(-) create mode 100644 lldb/test/Shell/ObjectFile/ELF/Inputs/memory-elf.cpp create mode 100644 lldb/test/Shell/ObjectFile/ELF/elf-memory.test diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index c8475db8ae160..17e18261b4752 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1952,7 +1952,7 @@ class Process : public std::enable_shared_from_this, lldb::ModuleSP ReadModuleFromMemory(const FileSpec &file_spec, lldb::addr_t header_addr, - size_t size_to_read = 512); + size_t size_to_read = 0); /// Attempt to get the attributes for a region of memory in the process. /// diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 890db5c274814..becee73f96205 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -873,33 +873,29 @@ Address ObjectFileELF::GetImageInfoAddress(Target *target) { if (!section_list) return Address(); - // Find the SHT_DYNAMIC (.dynamic) section. - SectionSP dynsym_section_sp( - section_list->FindSectionByType(eSectionTypeELFDynamicLinkInfo, true)); - if (!dynsym_section_sp) -return Address(); - assert(dynsym_section_sp->GetObjectFile() == this); - - user_id_t dynsym_id = dynsym_section_sp->GetID(); - const ELFSectionHeaderInfo *dynsym_hdr = GetSectionHeaderByIndex(dynsym_id); - if (!dynsym_hdr) -return Address(); - for (size_t i = 0; i < m_dynamic_symbols.size(); ++i) { -ELFDynamic &symbol = m_dynamic_symbols[i]; +const ELFDynamic &symbol = m_dynamic_symbols[i].symbol; if (symbol.d_tag == DT_DEBUG) { // Compute the offset as the number of previous entries plus the size of // d_tag. - addr_t offset = i * dynsym_hdr->sh_entsize + GetAddressByteSize(); - return Address(dynsym_section_sp, offset); + addr_t offset = (i * 2 + 1) * GetAddressByteSize(); + addr_t file_addr = m_dynamic_base_addr + offset; + Address addr; + if (addr.ResolveAddressUsingFileSections(file_addr, GetSectionList())) +return addr; } // MIPS executables uses DT_MIPS_RLD_MAP_REL to support PIE. DT_MIPS_RLD_MAP // exists in non-PIE. else if ((symbol.d_tag == DT_MIPS_RLD_MAP || symbol.d_tag == DT_MIPS_RLD_MAP_REL) && target) { - addr_t offset = i * dynsym_hdr->sh_entsize + GetAddressByteSize(); + SectionSP dynsym_section_sp(section_list->FindSectionByType( + eSectionTypeELFDynamicLinkInfo, true)); + if (!dynsym_section_sp) +return Address(); + + addr_t offset = (i * 2 + 1) * GetAddressByteSize(); addr_t dyn_base = dynsym_section_sp->GetLoadBaseAddress(target); if (dyn_base == LLDB_INVALID_ADDRESS) return Address(); @@ -970,62 +966,23 @@ Address ObjectFileELF::GetBaseAddress() { return LLDB_INVALID_ADDRESS; } -// ParseDependentModules size_t ObjectFileELF::ParseDependentModules() { if (m_filespec_up) return m_filespec_up->GetSize(); m_filespec_up = std::make_unique(); - if (!ParseSectionHeaders()) -return 0; - - SectionList *section_list = GetSectionList(); - if (!section_list) -return 0; - - // Find the SHT_DYNAMIC section. - Section *dynsym = - section_list->FindSectionByType(eSectionTypeELFDynamicLinkInfo, true) - .get(); - if (!dynsym) -return 0; - assert(dynsym->GetObjectFile() == this); - - const ELFSectionHeaderInfo *header = GetSectionHeaderByIndex(dynsym->Ge
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/101243 >From 61371af08b82e1229c34b43f56772813c2f74b1c Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 13:56:21 -0700 Subject: [PATCH 1/5] [cmake][llvm] Limit the number of Xcode schemes created by default CMake -GXcode would otherwise offer to create one scheme for each target, which ends up being a lot. For t push --forcenow, limit the default to the `check-*` LIT targets, plus `ALL_BUILD` and `install`. --- cmake/Modules/Xcode.cmake| 24 llvm/CMakeLists.txt | 4 llvm/cmake/modules/AddLLVM.cmake | 1 + 3 files changed, 29 insertions(+) create mode 100644 cmake/Modules/Xcode.cmake diff --git a/cmake/Modules/Xcode.cmake b/cmake/Modules/Xcode.cmake new file mode 100644 index 0..466cf79eb8b00 --- /dev/null +++ b/cmake/Modules/Xcode.cmake @@ -0,0 +1,24 @@ +# When this is enabled, CMake will generate schemes for every target, but not +# all of them make sense to surface in the Xcode UI by default. +set(CMAKE_XCODE_GENERATE_SCHEME YES) + +# Enumerate all the targets in a directory. +macro(get_all_targets targets dir) + get_property(sub_dirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) + foreach(subdir ${sub_dirs}) +get_all_targets(${targets} ${subdir}) + endforeach() + get_property(local_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) + list(APPEND ${targets} ${local_targets}) +endmacro() + +get_all_targets(all_targets ${PROJECT_SOURCE_DIR}) + +# Turn off scheme generation by default for targets that do not have +# XCODE_GENERATE_SCHEME set. +foreach(target ${all_targets}) + get_target_property(value ${target} XCODE_GENERATE_SCHEME) + if("${value}" STREQUAL "value-NOTFOUND") +set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME NO) + endif() +endforeach() diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 12618966c4adf..501b9ea288053 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1423,3 +1423,7 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() + +if (XCODE) + include(Xcode) +endif() diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 03f4e1f190fd9..f4f71b35ffa70 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -2043,6 +2043,7 @@ function(add_lit_target target comment) # Tests should be excluded from "Build Solution". set_target_properties(${target} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON) + set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME ON) endfunction() # Convert a target name like check-clang to a variable name like CLANG. >From 9b294dcb88c5aeb377454338773fabbaf58e41d6 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 14:36:56 -0700 Subject: [PATCH 2/5] take Jonas' suggestion --- cmake/Modules/Xcode.cmake | 24 llvm/CMakeLists.txt | 4 2 files changed, 28 deletions(-) delete mode 100644 cmake/Modules/Xcode.cmake diff --git a/cmake/Modules/Xcode.cmake b/cmake/Modules/Xcode.cmake deleted file mode 100644 index 466cf79eb8b00..0 --- a/cmake/Modules/Xcode.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# When this is enabled, CMake will generate schemes for every target, but not -# all of them make sense to surface in the Xcode UI by default. -set(CMAKE_XCODE_GENERATE_SCHEME YES) - -# Enumerate all the targets in a directory. -macro(get_all_targets targets dir) - get_property(sub_dirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) - foreach(subdir ${sub_dirs}) -get_all_targets(${targets} ${subdir}) - endforeach() - get_property(local_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) - list(APPEND ${targets} ${local_targets}) -endmacro() - -get_all_targets(all_targets ${PROJECT_SOURCE_DIR}) - -# Turn off scheme generation by default for targets that do not have -# XCODE_GENERATE_SCHEME set. -foreach(target ${all_targets}) - get_target_property(value ${target} XCODE_GENERATE_SCHEME) - if("${value}" STREQUAL "value-NOTFOUND") -set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME NO) - endif() -endforeach() diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 501b9ea288053..12618966c4adf 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1423,7 +1423,3 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() - -if (XCODE) - include(Xcode) -endif() >From 834f4b1d7d7a062d6de08a3c285890c580097406 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 14:44:27 -0700 Subject: [PATCH 3/5] generate schemes for llvm_add_tool tools, too --- llvm/cmake/modules/AddLLVM.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index f4f71b35ffa70..ac47e884ac229 100644 --- a/llvm/cmake/modules/AddLLVM.cm
[Lldb-commits] [lldb] [lldb] Change Module to have a concrete UnwindTable, update (PR #101130)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/101130 >From 55b1ac1fbad89ebc50038738c1e09045e9884be8 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 29 Jul 2024 22:37:43 -0700 Subject: [PATCH 1/3] [lldb] Change Module to have a concrete UnwindTable, update Currently a Module has a std::optional which is created when the UnwindTable is requested from outside the Module. The idea is to delay its creation until the Module has an ObjectFile initialized, which will have been done by the time we're doing an unwind. However, Module::GetUnwindTable wasn't doing any locking, so it was possible for two threads to ask for the UnwindTable for the first time, one would be created and returned while another thread would create one, destroy the first in the process of emplacing it. It was an uncommon crash, but it was possible. Grabbing the Module's mutex would be one way to address it, but when loading ELF binaries, we start creating the SymbolTable on one thread (ObjectFileELF) grabbing the Module's mutex, and then spin up worker threads to parse the individual DWARF compilation units, which then try to also get the UnwindTable and deadlock if they try to get the Module's mutex. This changes Module to have a concrete UnwindTable as an ivar, and when it adds an ObjectFile or SymbolFileVendor, it will call the Update method on it, which will re-evaluate which sections exist in the ObjectFile/SymbolFile. UnwindTable used to have an Initialize method which set all the sections, and an Update method which would set some of them if they weren't set. I unified these with the Initialize method taking a `force` option to re-initialize the section pointers even if they had been done already before. This is addressing a rare crash report we've received, and also a failure Adrian spotted on the -fsanitize=address CI bot last week, it's still uncommon with ASAN but it can happen with the standard testsuite. rdar://132514736 --- lldb/include/lldb/Core/Module.h| 6 +-- lldb/include/lldb/Symbol/UnwindTable.h | 2 +- lldb/source/Core/Module.cpp| 26 +++-- lldb/source/Symbol/UnwindTable.cpp | 51 ++ 4 files changed, 23 insertions(+), 62 deletions(-) diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 0188057247a68..5589c1c9a350d 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -1021,9 +1021,9 @@ class Module : public std::enable_shared_from_this, lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file /// parser for this module as it may or may /// not be shared with the SymbolFile - std::optional m_unwind_table; ///< Table of FuncUnwinders - /// objects created for this - /// Module's functions + UnwindTable m_unwind_table; ///< Table of FuncUnwinders + /// objects created for this + /// Module's functions lldb::SymbolVendorUP m_symfile_up; ///< A pointer to the symbol vendor for this module. std::vector diff --git a/lldb/include/lldb/Symbol/UnwindTable.h b/lldb/include/lldb/Symbol/UnwindTable.h index 26826e5d1b497..0e7d76b1b896c 100644 --- a/lldb/include/lldb/Symbol/UnwindTable.h +++ b/lldb/include/lldb/Symbol/UnwindTable.h @@ -64,7 +64,7 @@ class UnwindTable { private: void Dump(Stream &s); - void Initialize(); + void Initialize(bool force = false); std::optional GetAddressRange(const Address &addr, const SymbolContext &sc); diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 9c105b3f0e57a..acc17ecad015b 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -131,7 +131,8 @@ Module *Module::GetAllocatedModuleAtIndex(size_t idx) { } Module::Module(const ModuleSpec &module_spec) -: m_file_has_changed(false), m_first_file_changed_log(false) { +: m_unwind_table(*this), m_file_has_changed(false), + m_first_file_changed_log(false) { // Scope for locker below... { std::lock_guard guard( @@ -238,7 +239,8 @@ Module::Module(const FileSpec &file_spec, const ArchSpec &arch, : m_mod_time(FileSystem::Instance().GetModificationTime(file_spec)), m_arch(arch), m_file(file_spec), m_object_name(object_name), m_object_offset(object_offset), m_object_mod_time(object_mod_time), - m_file_has_changed(false), m_first_file_changed_log(false) { + m_unwind_table(*this), m_file_has_changed(false), + m_first_file_changed_log(false) { // Scope for locker below... { std::lock_guard guard( @@ -254,7 +256,9 @@ Module::Module(const FileSpec &file_spec, const ArchSpec &arch, m_object_name.AsCString(""), m_object_name.IsEmpty()
[Lldb-commits] [lldb] [lldb] Change Module to have a concrete UnwindTable, update (PR #101130)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jason Molenda (jasonmolenda) Changes Currently a Module has a std::optionalwhich is created when the UnwindTable is requested from outside the Module. The idea is to delay its creation until the Module has an ObjectFile initialized, which will have been done by the time we're doing an unwind. However, Module::GetUnwindTable wasn't doing any locking, so it was possible for two threads to ask for the UnwindTable for the first time, one would be created and returned while another thread would create one, destroy the first in the process of emplacing it. It was an uncommon crash, but it was possible. Grabbing the Module's mutex would be one way to address it, but when loading ELF binaries, we start creating the SymbolTable on one thread (ObjectFileELF) grabbing the Module's mutex, and then spin up worker threads to parse the individual DWARF compilation units, which then try to also get the UnwindTable and deadlock if they try to get the Module's mutex. This changes Module to have a concrete UnwindTable as an ivar, and when it adds an ObjectFile or SymbolFileVendor, it will call the Update method on it, which will re-evaluate which sections exist in the ObjectFile/SymbolFile. UnwindTable used to have an Initialize method which set all the sections, and an Update method which would set some of them if they weren't set. I unified these with the Initialize method taking a `force` option to re-initialize the section pointers even if they had been done already before. This is addressing a rare crash report we've received, and also a failure Adrian spotted on the -fsanitize=address CI bot last week, it's still uncommon with ASAN but it can happen with the standard testsuite. rdar://128876433 --- Full diff: https://github.com/llvm/llvm-project/pull/101130.diff 4 Files Affected: - (modified) lldb/include/lldb/Core/Module.h (+3-3) - (modified) lldb/include/lldb/Symbol/UnwindTable.h (+3-3) - (modified) lldb/source/Core/Module.cpp (+15-11) - (modified) lldb/source/Symbol/UnwindTable.cpp (+10-51) ``diff diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 0188057247a68..5589c1c9a350d 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -1021,9 +1021,9 @@ class Module : public std::enable_shared_from_this, lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file /// parser for this module as it may or may /// not be shared with the SymbolFile - std::optional m_unwind_table; ///< Table of FuncUnwinders - /// objects created for this - /// Module's functions + UnwindTable m_unwind_table; ///< Table of FuncUnwinders + /// objects created for this + /// Module's functions lldb::SymbolVendorUP m_symfile_up; ///< A pointer to the symbol vendor for this module. std::vector diff --git a/lldb/include/lldb/Symbol/UnwindTable.h b/lldb/include/lldb/Symbol/UnwindTable.h index 26826e5d1b497..bfcf1c3c072d6 100644 --- a/lldb/include/lldb/Symbol/UnwindTable.h +++ b/lldb/include/lldb/Symbol/UnwindTable.h @@ -57,9 +57,9 @@ class UnwindTable { ArchSpec GetArchitecture(); - /// Called after a SymbolFile has been added to a Module to add any new - /// unwind sections that may now be available. - void Update(); + /// Called after an ObjectFile/SymbolFile has been added to a Module to add + /// any new unwind sections that may now be available. + void ModuleWasUpdated(); private: void Dump(Stream &s); diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 9c105b3f0e57a..f9d7832254f46 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -131,7 +131,8 @@ Module *Module::GetAllocatedModuleAtIndex(size_t idx) { } Module::Module(const ModuleSpec &module_spec) -: m_file_has_changed(false), m_first_file_changed_log(false) { +: m_unwind_table(*this), m_file_has_changed(false), + m_first_file_changed_log(false) { // Scope for locker below... { std::lock_guard guard( @@ -238,7 +239,8 @@ Module::Module(const FileSpec &file_spec, const ArchSpec &arch, : m_mod_time(FileSystem::Instance().GetModificationTime(file_spec)), m_arch(arch), m_file(file_spec), m_object_name(object_name), m_object_offset(object_offset), m_object_mod_time(object_mod_time), - m_file_has_changed(false), m_first_file_changed_log(false) { + m_unwind_table(*this), m_file_has_changed(false), + m_first_file_changed_log(false) { // Scope for locker below... { std::lock_guard guard( @@ -254,7 +256,9 @@ Module::Module(const FileSpec &file_spec, const ArchSpec &arch, m_object_name.AsCString(""), m_obje
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
clayborg wrote: Can we add a cmake settings that allows users to add custom target names that will be added? I would love to use this for my common projects like: ``` -DCMAKE_LLVM_XCODE_TARGETS=lldb;llvm-dwarfdump;llvm-gsymutil;lld ``` And it would add those top level targets? https://github.com/llvm/llvm-project/pull/101243 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
jroelofs wrote: neat idea. that's doable. https://github.com/llvm/llvm-project/pull/101243 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/101243 >From 61371af08b82e1229c34b43f56772813c2f74b1c Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 13:56:21 -0700 Subject: [PATCH 1/6] [cmake][llvm] Limit the number of Xcode schemes created by default CMake -GXcode would otherwise offer to create one scheme for each target, which ends up being a lot. For t push --forcenow, limit the default to the `check-*` LIT targets, plus `ALL_BUILD` and `install`. --- cmake/Modules/Xcode.cmake| 24 llvm/CMakeLists.txt | 4 llvm/cmake/modules/AddLLVM.cmake | 1 + 3 files changed, 29 insertions(+) create mode 100644 cmake/Modules/Xcode.cmake diff --git a/cmake/Modules/Xcode.cmake b/cmake/Modules/Xcode.cmake new file mode 100644 index 0..466cf79eb8b00 --- /dev/null +++ b/cmake/Modules/Xcode.cmake @@ -0,0 +1,24 @@ +# When this is enabled, CMake will generate schemes for every target, but not +# all of them make sense to surface in the Xcode UI by default. +set(CMAKE_XCODE_GENERATE_SCHEME YES) + +# Enumerate all the targets in a directory. +macro(get_all_targets targets dir) + get_property(sub_dirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) + foreach(subdir ${sub_dirs}) +get_all_targets(${targets} ${subdir}) + endforeach() + get_property(local_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) + list(APPEND ${targets} ${local_targets}) +endmacro() + +get_all_targets(all_targets ${PROJECT_SOURCE_DIR}) + +# Turn off scheme generation by default for targets that do not have +# XCODE_GENERATE_SCHEME set. +foreach(target ${all_targets}) + get_target_property(value ${target} XCODE_GENERATE_SCHEME) + if("${value}" STREQUAL "value-NOTFOUND") +set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME NO) + endif() +endforeach() diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 12618966c4adf..501b9ea288053 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1423,3 +1423,7 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() + +if (XCODE) + include(Xcode) +endif() diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 03f4e1f190fd9..f4f71b35ffa70 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -2043,6 +2043,7 @@ function(add_lit_target target comment) # Tests should be excluded from "Build Solution". set_target_properties(${target} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON) + set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME ON) endfunction() # Convert a target name like check-clang to a variable name like CLANG. >From 9b294dcb88c5aeb377454338773fabbaf58e41d6 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 14:36:56 -0700 Subject: [PATCH 2/6] take Jonas' suggestion --- cmake/Modules/Xcode.cmake | 24 llvm/CMakeLists.txt | 4 2 files changed, 28 deletions(-) delete mode 100644 cmake/Modules/Xcode.cmake diff --git a/cmake/Modules/Xcode.cmake b/cmake/Modules/Xcode.cmake deleted file mode 100644 index 466cf79eb8b00..0 --- a/cmake/Modules/Xcode.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# When this is enabled, CMake will generate schemes for every target, but not -# all of them make sense to surface in the Xcode UI by default. -set(CMAKE_XCODE_GENERATE_SCHEME YES) - -# Enumerate all the targets in a directory. -macro(get_all_targets targets dir) - get_property(sub_dirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) - foreach(subdir ${sub_dirs}) -get_all_targets(${targets} ${subdir}) - endforeach() - get_property(local_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) - list(APPEND ${targets} ${local_targets}) -endmacro() - -get_all_targets(all_targets ${PROJECT_SOURCE_DIR}) - -# Turn off scheme generation by default for targets that do not have -# XCODE_GENERATE_SCHEME set. -foreach(target ${all_targets}) - get_target_property(value ${target} XCODE_GENERATE_SCHEME) - if("${value}" STREQUAL "value-NOTFOUND") -set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME NO) - endif() -endforeach() diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 501b9ea288053..12618966c4adf 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1423,7 +1423,3 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() - -if (XCODE) - include(Xcode) -endif() >From 834f4b1d7d7a062d6de08a3c285890c580097406 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 14:44:27 -0700 Subject: [PATCH 3/6] generate schemes for llvm_add_tool tools, too --- llvm/cmake/modules/AddLLVM.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index f4f71b35ffa70..ac47e884ac229 100644 --- a/llvm/cmake/modules/AddLLVM.cm
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
https://github.com/jroelofs edited https://github.com/llvm/llvm-project/pull/101243 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
https://github.com/JDevlieghere approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/101243 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
clayborg wrote: Great! That will be very useful. https://github.com/llvm/llvm-project/pull/101243 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
@@ -1423,3 +1423,11 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() + +if (XCODE) + set(LLVM_XCODE_EXTRA_TARGET_SCHEMES "" CACHE STRING "Specifies an extra list of targets to turn into schemes") clayborg wrote: Do we want to say "an extra list of semi colon separated target names"? Do you specify this multiple times, or just once with semi colon separated target names? https://github.com/llvm/llvm-project/pull/101243 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
@@ -1423,3 +1423,11 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() + +if (XCODE) + set(LLVM_XCODE_EXTRA_TARGET_SCHEMES "" CACHE STRING "Specifies an extra list of targets to turn into schemes") jroelofs wrote: Lists in CMake are semicolon-separated. I'll add an example in a comment. https://github.com/llvm/llvm-project/pull/101243 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/101243 >From 61371af08b82e1229c34b43f56772813c2f74b1c Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 13:56:21 -0700 Subject: [PATCH 1/7] [cmake][llvm] Limit the number of Xcode schemes created by default CMake -GXcode would otherwise offer to create one scheme for each target, which ends up being a lot. For t push --forcenow, limit the default to the `check-*` LIT targets, plus `ALL_BUILD` and `install`. --- cmake/Modules/Xcode.cmake| 24 llvm/CMakeLists.txt | 4 llvm/cmake/modules/AddLLVM.cmake | 1 + 3 files changed, 29 insertions(+) create mode 100644 cmake/Modules/Xcode.cmake diff --git a/cmake/Modules/Xcode.cmake b/cmake/Modules/Xcode.cmake new file mode 100644 index 0..466cf79eb8b00 --- /dev/null +++ b/cmake/Modules/Xcode.cmake @@ -0,0 +1,24 @@ +# When this is enabled, CMake will generate schemes for every target, but not +# all of them make sense to surface in the Xcode UI by default. +set(CMAKE_XCODE_GENERATE_SCHEME YES) + +# Enumerate all the targets in a directory. +macro(get_all_targets targets dir) + get_property(sub_dirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) + foreach(subdir ${sub_dirs}) +get_all_targets(${targets} ${subdir}) + endforeach() + get_property(local_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) + list(APPEND ${targets} ${local_targets}) +endmacro() + +get_all_targets(all_targets ${PROJECT_SOURCE_DIR}) + +# Turn off scheme generation by default for targets that do not have +# XCODE_GENERATE_SCHEME set. +foreach(target ${all_targets}) + get_target_property(value ${target} XCODE_GENERATE_SCHEME) + if("${value}" STREQUAL "value-NOTFOUND") +set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME NO) + endif() +endforeach() diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 12618966c4adf..501b9ea288053 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1423,3 +1423,7 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() + +if (XCODE) + include(Xcode) +endif() diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 03f4e1f190fd9..f4f71b35ffa70 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -2043,6 +2043,7 @@ function(add_lit_target target comment) # Tests should be excluded from "Build Solution". set_target_properties(${target} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON) + set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME ON) endfunction() # Convert a target name like check-clang to a variable name like CLANG. >From 9b294dcb88c5aeb377454338773fabbaf58e41d6 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 14:36:56 -0700 Subject: [PATCH 2/7] take Jonas' suggestion --- cmake/Modules/Xcode.cmake | 24 llvm/CMakeLists.txt | 4 2 files changed, 28 deletions(-) delete mode 100644 cmake/Modules/Xcode.cmake diff --git a/cmake/Modules/Xcode.cmake b/cmake/Modules/Xcode.cmake deleted file mode 100644 index 466cf79eb8b00..0 --- a/cmake/Modules/Xcode.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# When this is enabled, CMake will generate schemes for every target, but not -# all of them make sense to surface in the Xcode UI by default. -set(CMAKE_XCODE_GENERATE_SCHEME YES) - -# Enumerate all the targets in a directory. -macro(get_all_targets targets dir) - get_property(sub_dirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) - foreach(subdir ${sub_dirs}) -get_all_targets(${targets} ${subdir}) - endforeach() - get_property(local_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) - list(APPEND ${targets} ${local_targets}) -endmacro() - -get_all_targets(all_targets ${PROJECT_SOURCE_DIR}) - -# Turn off scheme generation by default for targets that do not have -# XCODE_GENERATE_SCHEME set. -foreach(target ${all_targets}) - get_target_property(value ${target} XCODE_GENERATE_SCHEME) - if("${value}" STREQUAL "value-NOTFOUND") -set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME NO) - endif() -endforeach() diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 501b9ea288053..12618966c4adf 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1423,7 +1423,3 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() - -if (XCODE) - include(Xcode) -endif() >From 834f4b1d7d7a062d6de08a3c285890c580097406 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Tue, 30 Jul 2024 14:44:27 -0700 Subject: [PATCH 3/7] generate schemes for llvm_add_tool tools, too --- llvm/cmake/modules/AddLLVM.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index f4f71b35ffa70..ac47e884ac229 100644 --- a/llvm/cmake/modules/AddLLVM.cm
[Lldb-commits] [lldb] [lldb][test][win][x86_64] Fix XFAIL and XPASS on LLDB API tests (PR #100477)
@@ -52,6 +52,7 @@ def test_negative_indexing(self): self.build() self.validate_negative_indexing() +@expectedFailureAll(oslist=["windows"], archs=["x86_64"]) dzhidzhoev wrote: I see the same function name/signature. Btw, I'd recommend adding `--env;LLDB_USE_LLDB_SERVER=1` to `LLDB_TEST_USER_ARGS` cmake argument. Without it, lldb can't even stop on a breakpoint on my machine. It may be helpful if you haven't set it yet. https://github.com/llvm/llvm-project/pull/100477 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change Module to have a concrete UnwindTable, update (PR #101130)
jasonmolenda wrote: Thanks for the suggestion @jimingham , I pushed an update to implement that idea. https://github.com/llvm/llvm-project/pull/101130 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a982cab - [cmake][llvm] Limit the number of Xcode schemes created by default (#101243)
Author: Jon Roelofs Date: 2024-07-30T17:17:04-07:00 New Revision: a982cabea3cfbf456a01ed85499fa7dfc7ec18c7 URL: https://github.com/llvm/llvm-project/commit/a982cabea3cfbf456a01ed85499fa7dfc7ec18c7 DIFF: https://github.com/llvm/llvm-project/commit/a982cabea3cfbf456a01ed85499fa7dfc7ec18c7.diff LOG: [cmake][llvm] Limit the number of Xcode schemes created by default (#101243) CMake -GXcode would otherwise offer to create one scheme for each target, which ends up being a lot. For now, limit the default to the `check-*` LIT targets, plus `ALL_BUILD` and `install`. For targets that aren't in the default list, we now have a configuration variable to promote an extra list of targets into schemes, for example `-DLLVM_XCODE_EXTRA_TARGET_SCHEMES="TargetParserTests;SupportTests"` to add schemes for `TargetParserTests` and `SupportTests` respectively. Added: Modified: clang/cmake/modules/AddClang.cmake lldb/cmake/modules/AddLLDB.cmake llvm/CMakeLists.txt llvm/cmake/modules/AddLLVM.cmake Removed: diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake index 9d09be1936847..5327b5d2f0892 100644 --- a/clang/cmake/modules/AddClang.cmake +++ b/clang/cmake/modules/AddClang.cmake @@ -147,6 +147,7 @@ endmacro(add_clang_library) macro(add_clang_executable name) add_llvm_executable( ${name} ${ARGN} ) set_clang_windows_version_resource_properties(${name}) + set_target_properties(${name} PROPERTIES XCODE_GENERATE_SCHEME ON) endmacro(add_clang_executable) macro(add_clang_tool name) @@ -181,6 +182,7 @@ macro(add_clang_tool name) set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name}) endif() endif() + set_target_properties(${name} PROPERTIES XCODE_GENERATE_SCHEME ON) endmacro() macro(add_clang_symlink name dest) diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index 538029037dd46..0a81ec5092185 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -258,6 +258,7 @@ function(add_lldb_tool name) endif() add_lldb_executable(${name} GENERATE_INSTALL ${ARG_UNPARSED_ARGUMENTS}) + set_target_properties(${name} PROPERTIES XCODE_GENERATE_SCHEME ON) endfunction() # The test suite relies on finding LLDB.framework binary resources in the diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 12618966c4adf..699de1ccd870c 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1423,3 +1423,16 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() + +if (XCODE) + # For additional targets that you would like to add schemes, specify e.g: + # + # -DLLVM_XCODE_EXTRA_TARGET_SCHEMES="TargetParserTests;SupportTests" + # + # at CMake configure time. + set(LLVM_XCODE_EXTRA_TARGET_SCHEMES "" CACHE STRING "Specifies an extra list of targets to turn into schemes") + + foreach(target ${LLVM_XCODE_EXTRA_TARGET_SCHEMES}) +set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME ON) + endforeach() +endif() diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 03f4e1f190fd9..ac47e884ac229 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -1452,6 +1452,7 @@ macro(llvm_add_tool project name) endif() get_subproject_title(subproject_title) set_target_properties(${name} PROPERTIES FOLDER "${subproject_title}/Tools") + set_target_properties(${name} PROPERTIES XCODE_GENERATE_SCHEME ON) endmacro(llvm_add_tool project name) macro(add_llvm_tool name) @@ -2043,6 +2044,7 @@ function(add_lit_target target comment) # Tests should be excluded from "Build Solution". set_target_properties(${target} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON) + set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME ON) endfunction() # Convert a target name like check-clang to a variable name like CLANG. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
https://github.com/jroelofs closed https://github.com/llvm/llvm-project/pull/101243 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [Obj2Yaml] Add support for minidump generation with 64b memory ranges. (PR #101272)
https://github.com/Jlalond created https://github.com/llvm/llvm-project/pull/101272 This PR adds support for `obj2yaml` and `yaml2obj` to generate minidumps that have a Memory64List stream. This is a prerequisite to #101086. Worth noting - const dropped on minidumps so we could cache a MemoryDescriptor_64 to it's actual offset, preventing the need to loop multiple times - doesn't reuse the existing `ListStream` code in some places, because the Memory64List has a different width size field (unsigned 64), and a larger header than all the other streams. I determined refactoring the existing code to support Mem64 would be worse than supporting the special case. >From 78ab13e3da15832117a7e2f8f85090a63482ca41 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde Date: Tue, 30 Jul 2024 11:04:45 -0700 Subject: [PATCH 1/2] Squash 64b-memory-regions-minidump and take only llvm-changes --- llvm/include/llvm/BinaryFormat/Minidump.h | 12 llvm/include/llvm/Object/Minidump.h | 16 -- llvm/include/llvm/ObjectYAML/MinidumpYAML.h | 28 + llvm/lib/Object/Minidump.cpp| 19 ++-- llvm/lib/ObjectYAML/MinidumpEmitter.cpp | 11 +++ llvm/lib/ObjectYAML/MinidumpYAML.cpp| 34 + 6 files changed, 115 insertions(+), 5 deletions(-) diff --git a/llvm/include/llvm/BinaryFormat/Minidump.h b/llvm/include/llvm/BinaryFormat/Minidump.h index 9669303252615..8054e81322a92 100644 --- a/llvm/include/llvm/BinaryFormat/Minidump.h +++ b/llvm/include/llvm/BinaryFormat/Minidump.h @@ -74,6 +74,18 @@ struct MemoryDescriptor_64 { support::ulittle64_t StartOfMemoryRange; support::ulittle64_t DataSize; }; +static_assert(sizeof(MemoryDescriptor_64) == 16); + +struct MemoryListHeader { + support::ulittle32_t NumberOfMemoryRanges; +}; +static_assert(sizeof(MemoryListHeader) == 4); + +struct Memory64ListHeader { + support::ulittle64_t NumberOfMemoryRanges; + support::ulittle64_t BaseRVA; +}; +static_assert(sizeof(Memory64ListHeader) == 16); struct MemoryInfoListHeader { support::ulittle32_t SizeOfHeader; diff --git a/llvm/include/llvm/Object/Minidump.h b/llvm/include/llvm/Object/Minidump.h index e45d4de0090de..6ca9eb2afe150 100644 --- a/llvm/include/llvm/Object/Minidump.h +++ b/llvm/include/llvm/Object/Minidump.h @@ -103,6 +103,15 @@ class MinidumpFile : public Binary { minidump::StreamType::MemoryList); } + /// Returns the header to the memory 64 list stream. An error is returned if + /// the file does not contain this stream. + Expected getMemoryList64Header() const { +return getStream( +minidump::StreamType::Memory64List); + } + + Expected> getMemory64List() const; + class MemoryInfoIterator : public iterator_facade_base> getDataSlice(ArrayRef Data, - size_t Offset, size_t Size); + static Expected> + getDataSlice(ArrayRef Data, uint64_t Offset, uint64_t Size); /// Return the slice of the given data array as an array of objects of the /// given type. The function checks that the input array is large enough to /// contain the correct number of objects of the given type. template static Expected> getDataSliceAs(ArrayRef Data, - size_t Offset, size_t Count); + uint64_t Offset, uint64_t Count); MinidumpFile(MemoryBufferRef Source, const minidump::Header &Header, ArrayRef Streams, @@ -208,6 +217,7 @@ Expected> MinidumpFile::getDataSliceAs(ArrayRef Data, getDataSlice(Data, Offset, sizeof(T) * Count); if (!Slice) return Slice.takeError(); + return ArrayRef(reinterpret_cast(Slice->data()), Count); } diff --git a/llvm/include/llvm/ObjectYAML/MinidumpYAML.h b/llvm/include/llvm/ObjectYAML/MinidumpYAML.h index b0cee541cef20..2cccf7fba5853 100644 --- a/llvm/include/llvm/ObjectYAML/MinidumpYAML.h +++ b/llvm/include/llvm/ObjectYAML/MinidumpYAML.h @@ -29,6 +29,7 @@ struct Stream { Exception, MemoryInfoList, MemoryList, +Memory64List, ModuleList, RawContent, SystemInfo, @@ -104,6 +105,25 @@ using ModuleListStream = detail::ListStream; using ThreadListStream = detail::ListStream; using MemoryListStream = detail::ListStream; +/// Memory64ListStream minidump stream. +struct Memory64ListStream : public Stream { + minidump::Memory64ListHeader Header; + std::vector Entries; + yaml::BinaryRef Content; + + Memory64ListStream() + : Stream(StreamKind::Memory64List, minidump::StreamType::Memory64List) {} + + explicit Memory64ListStream( + std::vector Entries) + : Stream(StreamKind::Memory64List, minidump::StreamType::Memory64List), +Entries(Entries) {} + + static bool classof(const Stream *S) { +return S->Kind == StreamKind::Memory64List; + } +}; + /// ExceptionStream minidump stream. struct ExceptionStream : public Stream { minidump::ExceptionSt
[Lldb-commits] [lldb] [llvm] [Obj2Yaml] Add support for minidump generation with 64b memory ranges. (PR #101272)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jacob Lalonde (Jlalond) Changes This PR adds support for `obj2yaml` and `yaml2obj` to generate minidumps that have a Memory64List stream. This is a prerequisite to #101086. Worth noting - const dropped on minidumps so we could cache a MemoryDescriptor_64 to it's actual offset, preventing the need to loop multiple times - doesn't reuse the existing `ListStream` code in some places, because the Memory64List has a different width size field (unsigned 64), and a larger header than all the other streams. I determined refactoring the existing code to support Mem64 would be worse than supporting the special case. --- Patch is 21.68 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/101272.diff 11 Files Affected: - (modified) lldb/test/Shell/Minidump/Inputs/linux-x86_64.yaml (+3-3) - (modified) llvm/include/llvm/BinaryFormat/Minidump.h (+12) - (modified) llvm/include/llvm/Object/Minidump.h (+21-3) - (modified) llvm/include/llvm/ObjectYAML/MinidumpYAML.h (+30-3) - (modified) llvm/lib/Object/Minidump.cpp (+47-2) - (modified) llvm/lib/ObjectYAML/MinidumpEmitter.cpp (+19) - (modified) llvm/lib/ObjectYAML/MinidumpYAML.cpp (+41-3) - (modified) llvm/test/tools/obj2yaml/Minidump/basic.yaml (+10-2) - (modified) llvm/tools/obj2yaml/minidump2yaml.cpp (+1-1) - (modified) llvm/tools/obj2yaml/obj2yaml.h (+1-1) - (modified) llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp (+48) ``diff diff --git a/lldb/test/Shell/Minidump/Inputs/linux-x86_64.yaml b/lldb/test/Shell/Minidump/Inputs/linux-x86_64.yaml index d2ae6543141e8..157903f368a08 100644 --- a/lldb/test/Shell/Minidump/Inputs/linux-x86_64.yaml +++ b/lldb/test/Shell/Minidump/Inputs/linux-x86_64.yaml @@ -1,7 +1,7 @@ --- !minidump -Streams: +Streams: - Type:ModuleList -Modules: +Modules: - Base of Image: 0x0040 Size of Image: 0x1000 Module Name: '/tmp/test/linux-x86_64' @@ -13,7 +13,7 @@ Streams: Number of Processors: 40 Platform ID: Linux CSD Version: 'Linux 3.13.0-91-generic #138-Ubuntu SMP Fri Jun 24 17:00:34 UTC 2016 x86_64' -CPU: +CPU: Vendor ID: GenuineIntel Version Info:0x Feature Info:0x diff --git a/llvm/include/llvm/BinaryFormat/Minidump.h b/llvm/include/llvm/BinaryFormat/Minidump.h index 9669303252615..8054e81322a92 100644 --- a/llvm/include/llvm/BinaryFormat/Minidump.h +++ b/llvm/include/llvm/BinaryFormat/Minidump.h @@ -74,6 +74,18 @@ struct MemoryDescriptor_64 { support::ulittle64_t StartOfMemoryRange; support::ulittle64_t DataSize; }; +static_assert(sizeof(MemoryDescriptor_64) == 16); + +struct MemoryListHeader { + support::ulittle32_t NumberOfMemoryRanges; +}; +static_assert(sizeof(MemoryListHeader) == 4); + +struct Memory64ListHeader { + support::ulittle64_t NumberOfMemoryRanges; + support::ulittle64_t BaseRVA; +}; +static_assert(sizeof(Memory64ListHeader) == 16); struct MemoryInfoListHeader { support::ulittle32_t SizeOfHeader; diff --git a/llvm/include/llvm/Object/Minidump.h b/llvm/include/llvm/Object/Minidump.h index e45d4de0090de..eedebc10b3fe7 100644 --- a/llvm/include/llvm/Object/Minidump.h +++ b/llvm/include/llvm/Object/Minidump.h @@ -15,6 +15,7 @@ #include "llvm/BinaryFormat/Minidump.h" #include "llvm/Object/Binary.h" #include "llvm/Support/Error.h" +#include namespace llvm { namespace object { @@ -52,6 +53,9 @@ class MinidumpFile : public Binary { return getDataSlice(getData(), Desc.RVA, Desc.DataSize); } + Expected> + getRawData(minidump::MemoryDescriptor_64 Desc) const; + /// Returns the minidump string at the given offset. An error is returned if /// we fail to parse the string, or the string is invalid UTF16. Expected getString(size_t Offset) const; @@ -103,6 +107,15 @@ class MinidumpFile : public Binary { minidump::StreamType::MemoryList); } + /// Returns the header to the memory 64 list stream. An error is returned if + /// the file does not contain this stream. + Expected getMemoryList64Header() const { +return getStream( +minidump::StreamType::Memory64List); + } + + Expected> getMemory64List(); + class MemoryInfoIterator : public iterator_facade_base> getDataSlice(ArrayRef Data, - size_t Offset, size_t Size); + static Expected> + getDataSlice(ArrayRef Data, uint64_t Offset, uint64_t Size); /// Return the slice of the given data array as an array of objects of the /// given type. The function checks that the input array is large enough to /// contain the correct number of objects of the given type. template static Expected> getDataSliceAs(ArrayRef Data, - size_t Offset, size_t Count); + uint64_t Of
[Lldb-commits] [lldb] [llvm] [Obj2Yaml] Add support for minidump generation with 64b memory ranges. (PR #101272)
@@ -356,6 +370,13 @@ void yaml::MappingContextTraits::mapping( IO.mapRequired("Content", Content); } +void yaml::MappingContextTraits::mapping( +IO &IO, MemoryDescriptor_64 &Memory, BinaryRef &Content) { + mapRequiredHex(IO, "Start of Memory Range", Memory.StartOfMemoryRange); + mapRequiredHex(IO, "Data Size", Memory.DataSize); Jlalond wrote: Would like feedback from reviewers, should we require DataSize here or should we just take the content size? https://github.com/llvm/llvm-project/pull/101272 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [Obj2Yaml] Add support for minidump generation with 64b memory ranges. (PR #101272)
@@ -550,7 +588,7 @@ Stream::create(const Directory &StreamDesc, const object::MinidumpFile &File) { llvm_unreachable("Unhandled stream kind!"); } -Expected Object::create(const object::MinidumpFile &File) { +Expected Object::create(object::MinidumpFile &File) { Jlalond wrote: @labath I had to drop the const modifier here in order to cache the MemoryDescriptor_64 offsets. I thought this would be appropriate given repetitive linear search in the `Stream::create` for Memory64. I'm not sure if removing the const modifier is the correct decision and would appreciate your input. https://github.com/llvm/llvm-project/pull/101272 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [Obj2Yaml] Add support for minidump generation with 64b memory ranges. (PR #101272)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 0891ccc0c68c35e17562c752955788f08054bcdb 9be9a32f57c5bd516eb5e64282ed71292a78c27a --extensions h,cpp -- llvm/include/llvm/BinaryFormat/Minidump.h llvm/include/llvm/Object/Minidump.h llvm/include/llvm/ObjectYAML/MinidumpYAML.h llvm/lib/Object/Minidump.cpp llvm/lib/ObjectYAML/MinidumpEmitter.cpp llvm/lib/ObjectYAML/MinidumpYAML.cpp llvm/tools/obj2yaml/minidump2yaml.cpp llvm/tools/obj2yaml/obj2yaml.h llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp `` View the diff from clang-format here. ``diff diff --git a/llvm/include/llvm/ObjectYAML/MinidumpYAML.h b/llvm/include/llvm/ObjectYAML/MinidumpYAML.h index 7f7924b920..8867c2ce3b 100644 --- a/llvm/include/llvm/ObjectYAML/MinidumpYAML.h +++ b/llvm/include/llvm/ObjectYAML/MinidumpYAML.h @@ -119,7 +119,7 @@ struct Memory64ListStream explicit Memory64ListStream( std::vector Entries = {}) - : ListStream(Entries){}; + : ListStream(Entries) {}; }; /// ExceptionStream minidump stream. `` https://github.com/llvm/llvm-project/pull/101272 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] c35c4c7 - [lldb] Reland 2402b3213c2f with `-H` to debug the windows build issue
Author: Med Ismail Bennani Date: 2024-07-30T18:26:04-07:00 New Revision: c35c4c72e4977258fc1da940e0470e8d0671bf07 URL: https://github.com/llvm/llvm-project/commit/c35c4c72e4977258fc1da940e0470e8d0671bf07 DIFF: https://github.com/llvm/llvm-project/commit/c35c4c72e4977258fc1da940e0470e8d0671bf07.diff LOG: [lldb] Reland 2402b3213c2f with `-H` to debug the windows build issue This patch relands 2402b3213c2f to investigate the ambigious typedef issue happening on the windows bots: https://lab.llvm.org/buildbot/#/builders/141/builds/1175/ However this patch adds the `-H` compiler flag when building the ScriptedProcessPythonInterface library to be able to investigate the include order issue. This patch will be revert after 1 failing run on the windows bot. Signed-off-by: Med Ismail Bennani Added: lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/CMakeLists.txt lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.h Modified: lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Removed: lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt index 8c7e92bead32c..2d7f0791902f3 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt @@ -21,7 +21,6 @@ endif() add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces ScriptedPythonInterface.cpp - ScriptedProcessPythonInterface.cpp ScriptedThreadPythonInterface.cpp LINK_LIBS @@ -38,5 +37,9 @@ add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces add_subdirectory(OperatingSystemPythonInterface) add_subdirectory(ScriptedPlatformPythonInterface) +set(ORIGINAL_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +set(CMAKE_CXX_FLAGS "${ORIGINAL_CMAKE_CXX_FLAGS} -H") +add_subdirectory(ScriptedProcessPythonInterface) +set(CMAKE_CXX_FLAGS "${ORIGINAL_CMAKE_CXX_FLAGS}") add_subdirectory(ScriptedThreadPlanPythonInterface) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/CMakeLists.txt new file mode 100644 index 0..66ed041853f67 --- /dev/null +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/CMakeLists.txt @@ -0,0 +1,16 @@ +add_lldb_library(lldbPluginScriptInterpreterPythonScriptedProcessPythonInterface PLUGIN + + ScriptedProcessPythonInterface.cpp + + LINK_LIBS +lldbCore +lldbHost +lldbInterpreter +lldbTarget +lldbPluginScriptInterpreterPython +${Python3_LIBRARIES} +${LLDB_LIBEDIT_LIBS} + + LINK_COMPONENTS +Support + ) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.cpp similarity index 85% rename from lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp rename to lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.cpp index 313c597ce48f3..f4fba0848fe27 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.cpp @@ -6,11 +6,8 @@ // //===--===// +#include "lldb/Core/PluginManager.h" #include "lldb/Host/Config.h" -#if LLDB_ENABLE_PYTHON -// LLDB Python header must be included first -#include "../lldb-python.h" -#endif #include "lldb/Target/Process.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" @@ -18,10 +15,16 @@ #if LLDB_ENABLE_PYTHON -#include "../SWIGPythonBridge.h" -#include "../ScriptInterpreterPythonImpl.h" +// clang-format off +// LLDB Python header must be included first +#include "../../lldb-python.h" +//clang-format on + +#include "../../SWIGPythonBridge.h" +#include "../../ScriptInterpreterPythonImpl.h" +#include "../ScriptedThreadPythonInterface.h" #include "ScriptedProcessPythonInterface.h" -#include "ScriptedThreadPythonInterface
[Lldb-commits] [lldb] [lldb][TypeSystemClang] Create VLAs of explicitly 0-size as ConstantArrayType (PR #100710)
medismailben wrote: @Michael137 This broke the windows bot: https://lab.llvm.org/buildbot/#/builders/141/builds/1214 Should we skip it on that platform or do you see an easy fix ? https://github.com/llvm/llvm-project/pull/100710 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f65fa54 - Revert "[lldb] Reland 2402b3213c2f with `-H` to debug the windows build issue"
Author: Med Ismail Bennani Date: 2024-07-30T19:46:19-07:00 New Revision: f65fa5461dcbaf554babf10ca67ae8fea5b4da7e URL: https://github.com/llvm/llvm-project/commit/f65fa5461dcbaf554babf10ca67ae8fea5b4da7e DIFF: https://github.com/llvm/llvm-project/commit/f65fa5461dcbaf554babf10ca67ae8fea5b4da7e.diff LOG: Revert "[lldb] Reland 2402b3213c2f with `-H` to debug the windows build issue" This reverts commit c35c4c72e4977258fc1da940e0470e8d0671bf07. Added: lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h Modified: lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Removed: lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/CMakeLists.txt lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.h diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt index 2d7f0791902f3..8c7e92bead32c 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt @@ -21,6 +21,7 @@ endif() add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces ScriptedPythonInterface.cpp + ScriptedProcessPythonInterface.cpp ScriptedThreadPythonInterface.cpp LINK_LIBS @@ -37,9 +38,5 @@ add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces add_subdirectory(OperatingSystemPythonInterface) add_subdirectory(ScriptedPlatformPythonInterface) -set(ORIGINAL_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") -set(CMAKE_CXX_FLAGS "${ORIGINAL_CMAKE_CXX_FLAGS} -H") -add_subdirectory(ScriptedProcessPythonInterface) -set(CMAKE_CXX_FLAGS "${ORIGINAL_CMAKE_CXX_FLAGS}") add_subdirectory(ScriptedThreadPlanPythonInterface) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp similarity index 85% rename from lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.cpp rename to lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp index f4fba0848fe27..313c597ce48f3 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp @@ -6,8 +6,11 @@ // //===--===// -#include "lldb/Core/PluginManager.h" #include "lldb/Host/Config.h" +#if LLDB_ENABLE_PYTHON +// LLDB Python header must be included first +#include "../lldb-python.h" +#endif #include "lldb/Target/Process.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" @@ -15,16 +18,10 @@ #if LLDB_ENABLE_PYTHON -// clang-format off -// LLDB Python header must be included first -#include "../../lldb-python.h" -//clang-format on - -#include "../../SWIGPythonBridge.h" -#include "../../ScriptInterpreterPythonImpl.h" -#include "../ScriptedThreadPythonInterface.h" +#include "../SWIGPythonBridge.h" +#include "../ScriptInterpreterPythonImpl.h" #include "ScriptedProcessPythonInterface.h" - +#include "ScriptedThreadPythonInterface.h" #include using namespace lldb; @@ -32,8 +29,6 @@ using namespace lldb_private; using namespace lldb_private::python; using Locker = ScriptInterpreterPythonImpl::Locker; -LLDB_PLUGIN_DEFINE_ADV(ScriptedProcessPythonInterface, ScriptInterpreterPythonScriptedProcessPythonInterface) - ScriptedProcessPythonInterface::ScriptedProcessPythonInterface( ScriptInterpreterPythonImpl &interpreter) : ScriptedProcessInterface(), ScriptedPythonInterface(interpreter) {} @@ -213,24 +208,4 @@ StructuredData::DictionarySP ScriptedProcessPythonInterface::GetMetadata() { return dict; } -void ScriptedProcessPythonInterface::Initialize() { - const std::vector ci_usages = { - "process attach -C [-k key -v value ...]", - "process launch -C [-k key -v value ...]"}; - const std::vector api_usages = { - "SBAttachInfo.SetScriptedProcessClassName", - "SBAttachInfo.SetScriptedProcessDictionary", - "SBTarget.Attach", - "SBLaunchInfo.SetScriptedProcessClassName", - "SBLaunchInfo.SetScriptedProcessDictionary", - "SBTarget.Launch"}; - PluginManager::Reg
[Lldb-commits] [lldb] e72cdae - [lldb] Reland 2402b3213c2f with `/H` to debug the windows build issue
Author: Med Ismail Bennani Date: 2024-07-30T19:54:11-07:00 New Revision: e72cdae47b4e263ea97b2bdd75cf44c1510cf3be URL: https://github.com/llvm/llvm-project/commit/e72cdae47b4e263ea97b2bdd75cf44c1510cf3be DIFF: https://github.com/llvm/llvm-project/commit/e72cdae47b4e263ea97b2bdd75cf44c1510cf3be.diff LOG: [lldb] Reland 2402b3213c2f with `/H` to debug the windows build issue This patch relands 2402b3213c2f to investigate the ambigious typedef issue happening on the windows bots: https://lab.llvm.org/buildbot/#/builders/141/builds/1175/ However this patch adds the `/H` compiler flag when building the ScriptedProcessPythonInterface library to be able to investigate the include order issue. This patch will be revert after 1 failing run on the windows bot. Signed-off-by: Med Ismail Bennani Added: lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/CMakeLists.txt lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.h Modified: lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Removed: lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt index 8c7e92bead32c..9efb97286ce97 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt @@ -21,7 +21,6 @@ endif() add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces ScriptedPythonInterface.cpp - ScriptedProcessPythonInterface.cpp ScriptedThreadPythonInterface.cpp LINK_LIBS @@ -38,5 +37,13 @@ add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces add_subdirectory(OperatingSystemPythonInterface) add_subdirectory(ScriptedPlatformPythonInterface) +if (WIN32) + set(ORIGINAL_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "${ORIGINAL_CMAKE_CXX_FLAGS} /H") +endif() +add_subdirectory(ScriptedProcessPythonInterface) +if (WIN32) + set(CMAKE_CXX_FLAGS "${ORIGINAL_CMAKE_CXX_FLAGS}") +endif() add_subdirectory(ScriptedThreadPlanPythonInterface) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/CMakeLists.txt new file mode 100644 index 0..66ed041853f67 --- /dev/null +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/CMakeLists.txt @@ -0,0 +1,16 @@ +add_lldb_library(lldbPluginScriptInterpreterPythonScriptedProcessPythonInterface PLUGIN + + ScriptedProcessPythonInterface.cpp + + LINK_LIBS +lldbCore +lldbHost +lldbInterpreter +lldbTarget +lldbPluginScriptInterpreterPython +${Python3_LIBRARIES} +${LLDB_LIBEDIT_LIBS} + + LINK_COMPONENTS +Support + ) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.cpp similarity index 85% rename from lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp rename to lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.cpp index 313c597ce48f3..f4fba0848fe27 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.cpp @@ -6,11 +6,8 @@ // //===--===// +#include "lldb/Core/PluginManager.h" #include "lldb/Host/Config.h" -#if LLDB_ENABLE_PYTHON -// LLDB Python header must be included first -#include "../lldb-python.h" -#endif #include "lldb/Target/Process.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" @@ -18,10 +15,16 @@ #if LLDB_ENABLE_PYTHON -#include "../SWIGPythonBridge.h" -#include "../ScriptInterpreterPythonImpl.h" +// clang-format off +// LLDB Python header must be included first +#include "../../lldb-python.h" +//clang-format on + +#include "../../SWIGPythonBridge.h" +#include "../../ScriptInterpreterPythonImpl.h" +#include "../ScriptedThreadPythonInterface.h" #include "ScriptedProcessPythonInte
[Lldb-commits] [lldb] [lldb] Updated lldb-server to spawn the child process and share socket on Windows (PR #101283)
https://github.com/slydiman created https://github.com/llvm/llvm-project/pull/101283 `lldb-server --server` works on Windows now w/o multithreading. The rest functionality remains unchanged. Added also PipeWindows::WriteWithTimeout(), fixed PipeWindows::ReadWithTimeout() and missing initialization of m_read_overlapped.hEvent in the constructor PipeWindows(lldb::pipe_t read, lldb::pipe_t write). Fixes #90923, fixes #56346. This is the part 1 of the replacement of #100670. In the part 2 I plan to switch `lldb-server gdbserver` to use `--fd` and listen a common gdb port for all gdbserver connections. Then we can remove gdb port mapping to fix #97537. >From 28ee2d294000852cc8b0a40db55b0619e9d257c9 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Wed, 31 Jul 2024 05:41:21 +0400 Subject: [PATCH] [lldb] Updated lldb-server to spawn the child process and share socket on Windows `lldb-server --server` works on Windows now w/o multithreading. The rest functionality remains unchanged. Added also PipeWindows::WriteWithTimeout(), fixed PipeWindows::ReadWithTimeout() and missing initialization of m_read_overlapped.hEvent in the constructor PipeWindows(lldb::pipe_t read, lldb::pipe_t write). Fixes #90923, fixes #56346. This is the part 1 of the replacement of #100670. In the part 2 I plan to switch `lldb-server gdbserver` to use --fd and listen a common gdb port for all gdbserver connections. Then we can remove gdb port mapping to fix #97537. --- lldb/include/lldb/Host/windows/PipeWindows.h | 3 + lldb/source/Host/windows/PipeWindows.cpp | 128 --- .../GDBRemoteCommunicationServerPlatform.cpp | 34 ++ .../GDBRemoteCommunicationServerPlatform.h| 2 +- .../tools/lldb-server/LLDBServerUtilities.cpp | 2 + lldb/tools/lldb-server/lldb-platform.cpp | 316 +++--- 6 files changed, 404 insertions(+), 81 deletions(-) diff --git a/lldb/include/lldb/Host/windows/PipeWindows.h b/lldb/include/lldb/Host/windows/PipeWindows.h index 4b5be28d7ae6c..c99cf52be46c1 100644 --- a/lldb/include/lldb/Host/windows/PipeWindows.h +++ b/lldb/include/lldb/Host/windows/PipeWindows.h @@ -61,6 +61,9 @@ class PipeWindows : public PipeBase { Status Delete(llvm::StringRef name) override; Status Write(const void *buf, size_t size, size_t &bytes_written) override; + Status WriteWithTimeout(const void *buf, size_t size, + const std::chrono::microseconds &timeout, + size_t &bytes_written); Status ReadWithTimeout(void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read) override; diff --git a/lldb/source/Host/windows/PipeWindows.cpp b/lldb/source/Host/windows/PipeWindows.cpp index c82c919607b5b..318d5abbed74d 100644 --- a/lldb/source/Host/windows/PipeWindows.cpp +++ b/lldb/source/Host/windows/PipeWindows.cpp @@ -58,7 +58,10 @@ PipeWindows::PipeWindows(pipe_t read, pipe_t write) } ZeroMemory(&m_read_overlapped, sizeof(m_read_overlapped)); + m_read_overlapped.hEvent = ::CreateEventA(nullptr, TRUE, FALSE, nullptr); + ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); + m_write_overlapped.hEvent = ::CreateEventA(nullptr, TRUE, FALSE, nullptr); } PipeWindows::~PipeWindows() { Close(); } @@ -77,6 +80,7 @@ Status PipeWindows::CreateNew(bool child_process_inherit) { m_write_fd = _open_osfhandle((intptr_t)m_write, _O_WRONLY); ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); + m_write_overlapped.hEvent = ::CreateEventA(nullptr, TRUE, FALSE, nullptr); return Status(); } @@ -202,6 +206,7 @@ Status PipeWindows::OpenNamedPipe(llvm::StringRef name, m_write_fd = _open_osfhandle((intptr_t)m_write, _O_WRONLY); ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); +m_write_overlapped.hEvent = ::CreateEventA(nullptr, TRUE, FALSE, nullptr); } return Status(); @@ -228,6 +233,8 @@ int PipeWindows::ReleaseWriteFileDescriptor() { return PipeWindows::kInvalidDescriptor; int result = m_write_fd; m_write_fd = PipeWindows::kInvalidDescriptor; + if (m_write_overlapped.hEvent) +::CloseHandle(m_write_overlapped.hEvent); m_write = INVALID_HANDLE_VALUE; ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); return result; @@ -250,6 +257,9 @@ void PipeWindows::CloseWriteFileDescriptor() { if (!CanWrite()) return; + if (m_write_overlapped.hEvent) +::CloseHandle(m_write_overlapped.hEvent); + _close(m_write_fd); m_write = INVALID_HANDLE_VALUE; m_write_fd = PipeWindows::kInvalidDescriptor; @@ -283,54 +293,94 @@ Status PipeWindows::ReadWithTimeout(void *buf, size_t size, DWORD sys_bytes_read = size; BOOL result = ::ReadFile(m_read, buf, sys_bytes_read, &sys_bytes_read, &m_read_overlapped); - if (!result && GetLastError() != ERROR_IO_PENDING) -return Status(::GetLastError(), eErrorTypeWin32); - - DWORD timeout
[Lldb-commits] [lldb] [lldb] Updated lldb-server to spawn the child process and share socket on Windows (PR #101283)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Dmitry Vasilyev (slydiman) Changes `lldb-server --server` works on Windows now w/o multithreading. The rest functionality remains unchanged. Added also PipeWindows::WriteWithTimeout(), fixed PipeWindows::ReadWithTimeout() and missing initialization of m_read_overlapped.hEvent in the constructor PipeWindows(lldb::pipe_t read, lldb::pipe_t write). Fixes #90923, fixes #56346. This is the part 1 of the replacement of #100670. In the part 2 I plan to switch `lldb-server gdbserver` to use `--fd` and listen a common gdb port for all gdbserver connections. Then we can remove gdb port mapping to fix #97537. --- Patch is 26.45 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/101283.diff 6 Files Affected: - (modified) lldb/include/lldb/Host/windows/PipeWindows.h (+3) - (modified) lldb/source/Host/windows/PipeWindows.cpp (+89-39) - (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp (+34) - (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h (+1-1) - (modified) lldb/tools/lldb-server/LLDBServerUtilities.cpp (+2) - (modified) lldb/tools/lldb-server/lldb-platform.cpp (+275-41) ``diff diff --git a/lldb/include/lldb/Host/windows/PipeWindows.h b/lldb/include/lldb/Host/windows/PipeWindows.h index 4b5be28d7ae6c..c99cf52be46c1 100644 --- a/lldb/include/lldb/Host/windows/PipeWindows.h +++ b/lldb/include/lldb/Host/windows/PipeWindows.h @@ -61,6 +61,9 @@ class PipeWindows : public PipeBase { Status Delete(llvm::StringRef name) override; Status Write(const void *buf, size_t size, size_t &bytes_written) override; + Status WriteWithTimeout(const void *buf, size_t size, + const std::chrono::microseconds &timeout, + size_t &bytes_written); Status ReadWithTimeout(void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read) override; diff --git a/lldb/source/Host/windows/PipeWindows.cpp b/lldb/source/Host/windows/PipeWindows.cpp index c82c919607b5b..318d5abbed74d 100644 --- a/lldb/source/Host/windows/PipeWindows.cpp +++ b/lldb/source/Host/windows/PipeWindows.cpp @@ -58,7 +58,10 @@ PipeWindows::PipeWindows(pipe_t read, pipe_t write) } ZeroMemory(&m_read_overlapped, sizeof(m_read_overlapped)); + m_read_overlapped.hEvent = ::CreateEventA(nullptr, TRUE, FALSE, nullptr); + ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); + m_write_overlapped.hEvent = ::CreateEventA(nullptr, TRUE, FALSE, nullptr); } PipeWindows::~PipeWindows() { Close(); } @@ -77,6 +80,7 @@ Status PipeWindows::CreateNew(bool child_process_inherit) { m_write_fd = _open_osfhandle((intptr_t)m_write, _O_WRONLY); ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); + m_write_overlapped.hEvent = ::CreateEventA(nullptr, TRUE, FALSE, nullptr); return Status(); } @@ -202,6 +206,7 @@ Status PipeWindows::OpenNamedPipe(llvm::StringRef name, m_write_fd = _open_osfhandle((intptr_t)m_write, _O_WRONLY); ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); +m_write_overlapped.hEvent = ::CreateEventA(nullptr, TRUE, FALSE, nullptr); } return Status(); @@ -228,6 +233,8 @@ int PipeWindows::ReleaseWriteFileDescriptor() { return PipeWindows::kInvalidDescriptor; int result = m_write_fd; m_write_fd = PipeWindows::kInvalidDescriptor; + if (m_write_overlapped.hEvent) +::CloseHandle(m_write_overlapped.hEvent); m_write = INVALID_HANDLE_VALUE; ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); return result; @@ -250,6 +257,9 @@ void PipeWindows::CloseWriteFileDescriptor() { if (!CanWrite()) return; + if (m_write_overlapped.hEvent) +::CloseHandle(m_write_overlapped.hEvent); + _close(m_write_fd); m_write = INVALID_HANDLE_VALUE; m_write_fd = PipeWindows::kInvalidDescriptor; @@ -283,54 +293,94 @@ Status PipeWindows::ReadWithTimeout(void *buf, size_t size, DWORD sys_bytes_read = size; BOOL result = ::ReadFile(m_read, buf, sys_bytes_read, &sys_bytes_read, &m_read_overlapped); - if (!result && GetLastError() != ERROR_IO_PENDING) -return Status(::GetLastError(), eErrorTypeWin32); - - DWORD timeout = (duration == std::chrono::microseconds::zero()) - ? INFINITE - : duration.count() * 1000; - DWORD wait_result = ::WaitForSingleObject(m_read_overlapped.hEvent, timeout); - if (wait_result != WAIT_OBJECT_0) { -// The operation probably failed. However, if it timed out, we need to -// cancel the I/O. Between the time we returned from WaitForSingleObject -// and the time we call CancelIoEx, the operation may complete. If that -// hapens, CancelIoEx will fail and return ERROR_NOT_FOUND. If that -// happens, the original operatio
[Lldb-commits] [lldb] [lldb] Updated lldb-server to spawn the child process and share socket on Windows (PR #101283)
https://github.com/slydiman updated https://github.com/llvm/llvm-project/pull/101283 >From 396b9a0595c04a8ec2e01c06788ddf9498ee3c4c Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Wed, 31 Jul 2024 05:41:21 +0400 Subject: [PATCH] [lldb] Updated lldb-server to spawn the child process and share socket on Windows `lldb-server --server` works on Windows now w/o multithreading. The rest functionality remains unchanged. Added also PipeWindows::WriteWithTimeout(), fixed PipeWindows::ReadWithTimeout() and missing initialization of m_read_overlapped.hEvent in the constructor PipeWindows(lldb::pipe_t read, lldb::pipe_t write). Fixes #90923, fixes #56346. This is the part 1 of the replacement of #100670. In the part 2 I plan to switch `lldb-server gdbserver` to use --fd and listen a common gdb port for all gdbserver connections. Then we can remove gdb port mapping to fix #97537. --- lldb/include/lldb/Host/windows/PipeWindows.h | 3 + lldb/source/Host/windows/PipeWindows.cpp | 128 --- .../GDBRemoteCommunicationServerPlatform.cpp | 34 ++ .../GDBRemoteCommunicationServerPlatform.h| 2 +- .../tools/lldb-server/LLDBServerUtilities.cpp | 2 + lldb/tools/lldb-server/lldb-platform.cpp | 316 +++--- 6 files changed, 404 insertions(+), 81 deletions(-) diff --git a/lldb/include/lldb/Host/windows/PipeWindows.h b/lldb/include/lldb/Host/windows/PipeWindows.h index 4b5be28d7ae6c..c99cf52be46c1 100644 --- a/lldb/include/lldb/Host/windows/PipeWindows.h +++ b/lldb/include/lldb/Host/windows/PipeWindows.h @@ -61,6 +61,9 @@ class PipeWindows : public PipeBase { Status Delete(llvm::StringRef name) override; Status Write(const void *buf, size_t size, size_t &bytes_written) override; + Status WriteWithTimeout(const void *buf, size_t size, + const std::chrono::microseconds &timeout, + size_t &bytes_written); Status ReadWithTimeout(void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read) override; diff --git a/lldb/source/Host/windows/PipeWindows.cpp b/lldb/source/Host/windows/PipeWindows.cpp index c82c919607b5b..318d5abbed74d 100644 --- a/lldb/source/Host/windows/PipeWindows.cpp +++ b/lldb/source/Host/windows/PipeWindows.cpp @@ -58,7 +58,10 @@ PipeWindows::PipeWindows(pipe_t read, pipe_t write) } ZeroMemory(&m_read_overlapped, sizeof(m_read_overlapped)); + m_read_overlapped.hEvent = ::CreateEventA(nullptr, TRUE, FALSE, nullptr); + ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); + m_write_overlapped.hEvent = ::CreateEventA(nullptr, TRUE, FALSE, nullptr); } PipeWindows::~PipeWindows() { Close(); } @@ -77,6 +80,7 @@ Status PipeWindows::CreateNew(bool child_process_inherit) { m_write_fd = _open_osfhandle((intptr_t)m_write, _O_WRONLY); ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); + m_write_overlapped.hEvent = ::CreateEventA(nullptr, TRUE, FALSE, nullptr); return Status(); } @@ -202,6 +206,7 @@ Status PipeWindows::OpenNamedPipe(llvm::StringRef name, m_write_fd = _open_osfhandle((intptr_t)m_write, _O_WRONLY); ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); +m_write_overlapped.hEvent = ::CreateEventA(nullptr, TRUE, FALSE, nullptr); } return Status(); @@ -228,6 +233,8 @@ int PipeWindows::ReleaseWriteFileDescriptor() { return PipeWindows::kInvalidDescriptor; int result = m_write_fd; m_write_fd = PipeWindows::kInvalidDescriptor; + if (m_write_overlapped.hEvent) +::CloseHandle(m_write_overlapped.hEvent); m_write = INVALID_HANDLE_VALUE; ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); return result; @@ -250,6 +257,9 @@ void PipeWindows::CloseWriteFileDescriptor() { if (!CanWrite()) return; + if (m_write_overlapped.hEvent) +::CloseHandle(m_write_overlapped.hEvent); + _close(m_write_fd); m_write = INVALID_HANDLE_VALUE; m_write_fd = PipeWindows::kInvalidDescriptor; @@ -283,54 +293,94 @@ Status PipeWindows::ReadWithTimeout(void *buf, size_t size, DWORD sys_bytes_read = size; BOOL result = ::ReadFile(m_read, buf, sys_bytes_read, &sys_bytes_read, &m_read_overlapped); - if (!result && GetLastError() != ERROR_IO_PENDING) -return Status(::GetLastError(), eErrorTypeWin32); - - DWORD timeout = (duration == std::chrono::microseconds::zero()) - ? INFINITE - : duration.count() * 1000; - DWORD wait_result = ::WaitForSingleObject(m_read_overlapped.hEvent, timeout); - if (wait_result != WAIT_OBJECT_0) { -// The operation probably failed. However, if it timed out, we need to -// cancel the I/O. Between the time we returned from WaitForSingleObject -// and the time we call CancelIoEx, the operation may complete. If that -// hapens, CancelIoEx will fail and return ERROR_NOT_FOUND. If that -// happens, the or
[Lldb-commits] [lldb] [llvm] [Obj2Yaml] Add support for minidump generation with 64b memory ranges. (PR #101272)
@@ -136,6 +136,22 @@ static size_t layout(BlobAllocator &File, MinidumpYAML::ExceptionStream &S) { return DataEnd; } +static size_t layout(BlobAllocator &File, MinidumpYAML::Memory64ListStream &S) { + size_t BaseRVA = File.tell() + sizeof(minidump::Memory64ListHeader); clayborg wrote: Don't use `size_t`, it is 32 bits on 32 bit architectures. Shouldn't the BaseRVA be: ``` uint64_t BaseRVA = File.tell() + sizeof(minidump::Memory64ListHeader) + S.Entries.size() * sizeof(minidump:: MemoryDescriptor_64); if (BaseRVA > UINT32_MAX) Error! ``` This RVA puts the BaseRVA right after the header and would explain your test suite issues. https://github.com/llvm/llvm-project/pull/101272 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [Obj2Yaml] Add support for minidump generation with 64b memory ranges. (PR #101272)
@@ -336,3 +336,51 @@ TEST(MinidumpYAML, ExceptionStream_ExtraParameter) { 0xab, 0xad, 0xca, 0xfe}), *ExpectedContext); } + +TEST(MinidumpYAML, MemoryRegion_64bit) { + SmallString<0> Storage; + auto ExpectedFile = toBinary(Storage, R"( +--- !minidump +Streams: + - Type:Memory64List +Memory Ranges: + - Start of Memory Range: 0x7FCF0818283 +Data Size: 8 +Content: '68656c6c6f' + - Start of Memory Range: 0x7FFF0818283 +Data Size: 8 +Content: '776f726c64' +)"); + + ASSERT_THAT_EXPECTED(ExpectedFile, Succeeded()); + object::MinidumpFile &File = **ExpectedFile; + + ASSERT_EQ(1u, File.streams().size()); + + Expected> ExpectedMemoryList = + File.getMemory64List(); + + ASSERT_THAT_EXPECTED(ExpectedMemoryList, Succeeded()); + + ArrayRef MemoryList = *ExpectedMemoryList; + ASSERT_EQ(2u, MemoryList.size()); + + const minidump::MemoryDescriptor_64 &DescOne = MemoryList[0]; + ASSERT_EQ(0x7FCF0818283u, DescOne.StartOfMemoryRange); + ASSERT_EQ(8u, DescOne.DataSize); + + const minidump::MemoryDescriptor_64 &DescTwo = MemoryList[1]; + ASSERT_EQ(0x7FFF0818283u, DescTwo.StartOfMemoryRange); + ASSERT_EQ(8u, DescTwo.DataSize); + + const std::optional> ExpectedContent = + File.getRawStream(StreamType::Memory64List); + ASSERT_TRUE(ExpectedContent); + const ArrayRef Content = *ExpectedContent; + const size_t offset = + sizeof(Memory64ListHeader) + (sizeof(MemoryDescriptor_64) * 2); + const uint64_t *Array = + reinterpret_cast(Content.slice(offset, 16).data(), 16); + ASSERT_EQ(0x70002Au, Array[0]); + ASSERT_EQ(0x7000AAu, Array[1]); clayborg wrote: What is this trying to test? You need to verify the data, which starts at the `BaseRVA` is "hello" and "world" right? Not sure what this is trying to test. https://github.com/llvm/llvm-project/pull/101272 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [Obj2Yaml] Add support for minidump generation with 64b memory ranges. (PR #101272)
@@ -336,3 +336,51 @@ TEST(MinidumpYAML, ExceptionStream_ExtraParameter) { 0xab, 0xad, 0xca, 0xfe}), *ExpectedContext); } + +TEST(MinidumpYAML, MemoryRegion_64bit) { + SmallString<0> Storage; + auto ExpectedFile = toBinary(Storage, R"( +--- !minidump +Streams: + - Type:Memory64List +Memory Ranges: + - Start of Memory Range: 0x7FCF0818283 +Data Size: 8 +Content: '68656c6c6f' + - Start of Memory Range: 0x7FFF0818283 +Data Size: 8 +Content: '776f726c64' +)"); + + ASSERT_THAT_EXPECTED(ExpectedFile, Succeeded()); + object::MinidumpFile &File = **ExpectedFile; + + ASSERT_EQ(1u, File.streams().size()); + + Expected> ExpectedMemoryList = + File.getMemory64List(); + + ASSERT_THAT_EXPECTED(ExpectedMemoryList, Succeeded()); + + ArrayRef MemoryList = *ExpectedMemoryList; + ASSERT_EQ(2u, MemoryList.size()); + + const minidump::MemoryDescriptor_64 &DescOne = MemoryList[0]; + ASSERT_EQ(0x7FCF0818283u, DescOne.StartOfMemoryRange); + ASSERT_EQ(8u, DescOne.DataSize); + + const minidump::MemoryDescriptor_64 &DescTwo = MemoryList[1]; + ASSERT_EQ(0x7FFF0818283u, DescTwo.StartOfMemoryRange); + ASSERT_EQ(8u, DescTwo.DataSize); + + const std::optional> ExpectedContent = + File.getRawStream(StreamType::Memory64List); + ASSERT_TRUE(ExpectedContent); + const ArrayRef Content = *ExpectedContent; + const size_t offset = + sizeof(Memory64ListHeader) + (sizeof(MemoryDescriptor_64) * 2); + const uint64_t *Array = + reinterpret_cast(Content.slice(offset, 16).data(), 16); + ASSERT_EQ(0x70002Au, Array[0]); + ASSERT_EQ(0x7000AAu, Array[1]); clayborg wrote: Line 382 asserts for me: ``` Assertion failed: (N+M <= size() && "Invalid specifier"), function slice, file ArrayRef.h, line 196. (lldb) v --raw Content (llvm::ArrayRef) Content = { Data = 0x000138e0625c Length = 48 } offset = 48 ``` https://github.com/llvm/llvm-project/pull/101272 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [Obj2Yaml] Add support for minidump generation with 64b memory ranges. (PR #101272)
@@ -152,15 +165,15 @@ class MinidumpFile : public Binary { } /// Return a slice of the given data array, with bounds checking. - static Expected> getDataSlice(ArrayRef Data, - size_t Offset, size_t Size); + static Expected> + getDataSlice(ArrayRef Data, uint64_t Offset, uint64_t Size); /// Return the slice of the given data array as an array of objects of the /// given type. The function checks that the input array is large enough to /// contain the correct number of objects of the given type. template static Expected> getDataSliceAs(ArrayRef Data, - size_t Offset, size_t Count); + uint64_t Offset, uint64_t Count); clayborg wrote: I had to fix the function for getSlizeAs to use `uint64_t` for both params that you changed here or it woudn't compile for me. https://github.com/llvm/llvm-project/pull/101272 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [Obj2Yaml] Add support for minidump generation with 64b memory ranges. (PR #101272)
clayborg wrote: Does look like this is working correctly: ``` $ minidump.py /tmp/md.dmp MINIDUMP_HEADER: Signature = 0x504d444d Version= 0xa793 NumberOfStreams= 0x0001 StreamDirectoryRva = 0x0020 CheckSum = 0x TimeDateStamp = 0x Flags = 0x MINIDUMP_DIRECTORY[1]: StreamType DataSize RVA -- -- 0x0009 Memory64ListStream0x0030 0x002c MINIDUMP_MEMORY64_LIST: NumberOfMemoryRanges = 0x0002 BaseRva = 0x005c MemoryRanges[0] = [0x07fcf0818283 - 0x07fcf081828b) MemoryRanges[1] = [0x07fff0818283 - 0x07fff081828b) $ hexdump -C /tmp/md.dmp 4d 44 4d 50 93 a7 00 00 01 00 00 00 20 00 00 00 |MDMP ...| 0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 || 0020 09 00 00 00 30 00 00 00 2c 00 00 00 02 00 00 00 |0...,...| 0030 00 00 00 00 5c 00 00 00 00 00 00 00 83 82 81 f0 |\...| 0040 fc ff ff 07 08 00 00 00 00 00 00 00 83 82 81 f0 || 0050 ff ff ff 07 08 00 00 00 00 00 00 00 68 65 6c 6c |hell| 0060 6f 77 6f 72 6c 64 |oworld| 0066 https://github.com/llvm/llvm-project/pull/101272 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Updated lldb-server to spawn the child process and share socket on Windows (PR #101283)
slydiman wrote: Note GDBRemoteCommunicationServerPlatform::DebugserverProcessReaped() may cause a crash if this callback will be called from the child monitor thread after destroing the instance of GDBRemoteCommunicationServerPlatform. It is impossible to control this thread anyway. Hope I will fix it in the part 2 removing m_port_map. m_spawned_pids may be static since we have one GDBRemoteCommunicationServerPlatform instance per process. https://github.com/llvm/llvm-project/pull/101283 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Updated lldb-server to spawn the child process and share socket on Windows (PR #101283)
https://github.com/slydiman edited https://github.com/llvm/llvm-project/pull/101283 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [Obj2Yaml] Add support for minidump generation with 64b memory ranges. (PR #101272)
clayborg wrote: ``` 0x07fcf081828b - 0x07fcf0818283 = 8 (from MemoryRanges[0]) and there are only 5 bytes in the file's hexdump ``` So the data for MemoryRanges[1] will be off since it will think it starts at: ``` BaseRva + 8 = 0x5c + 8 = 0x0064 ``` And that points to the last 2 bytes of the file. https://github.com/llvm/llvm-project/pull/101272 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [Obj2Yaml] Add support for minidump generation with 64b memory ranges. (PR #101272)
clayborg wrote: So the BaseRVA does look good, the memory range is being set to 8 bytes instead of 5 for each data. https://github.com/llvm/llvm-project/pull/101272 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [Obj2Yaml] Add support for minidump generation with 64b memory ranges. (PR #101272)
https://github.com/Jlalond updated https://github.com/llvm/llvm-project/pull/101272 >From 78ab13e3da15832117a7e2f8f85090a63482ca41 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde Date: Tue, 30 Jul 2024 11:04:45 -0700 Subject: [PATCH 1/3] Squash 64b-memory-regions-minidump and take only llvm-changes --- llvm/include/llvm/BinaryFormat/Minidump.h | 12 llvm/include/llvm/Object/Minidump.h | 16 -- llvm/include/llvm/ObjectYAML/MinidumpYAML.h | 28 + llvm/lib/Object/Minidump.cpp| 19 ++-- llvm/lib/ObjectYAML/MinidumpEmitter.cpp | 11 +++ llvm/lib/ObjectYAML/MinidumpYAML.cpp| 34 + 6 files changed, 115 insertions(+), 5 deletions(-) diff --git a/llvm/include/llvm/BinaryFormat/Minidump.h b/llvm/include/llvm/BinaryFormat/Minidump.h index 9669303252615..8054e81322a92 100644 --- a/llvm/include/llvm/BinaryFormat/Minidump.h +++ b/llvm/include/llvm/BinaryFormat/Minidump.h @@ -74,6 +74,18 @@ struct MemoryDescriptor_64 { support::ulittle64_t StartOfMemoryRange; support::ulittle64_t DataSize; }; +static_assert(sizeof(MemoryDescriptor_64) == 16); + +struct MemoryListHeader { + support::ulittle32_t NumberOfMemoryRanges; +}; +static_assert(sizeof(MemoryListHeader) == 4); + +struct Memory64ListHeader { + support::ulittle64_t NumberOfMemoryRanges; + support::ulittle64_t BaseRVA; +}; +static_assert(sizeof(Memory64ListHeader) == 16); struct MemoryInfoListHeader { support::ulittle32_t SizeOfHeader; diff --git a/llvm/include/llvm/Object/Minidump.h b/llvm/include/llvm/Object/Minidump.h index e45d4de0090de..6ca9eb2afe150 100644 --- a/llvm/include/llvm/Object/Minidump.h +++ b/llvm/include/llvm/Object/Minidump.h @@ -103,6 +103,15 @@ class MinidumpFile : public Binary { minidump::StreamType::MemoryList); } + /// Returns the header to the memory 64 list stream. An error is returned if + /// the file does not contain this stream. + Expected getMemoryList64Header() const { +return getStream( +minidump::StreamType::Memory64List); + } + + Expected> getMemory64List() const; + class MemoryInfoIterator : public iterator_facade_base> getDataSlice(ArrayRef Data, - size_t Offset, size_t Size); + static Expected> + getDataSlice(ArrayRef Data, uint64_t Offset, uint64_t Size); /// Return the slice of the given data array as an array of objects of the /// given type. The function checks that the input array is large enough to /// contain the correct number of objects of the given type. template static Expected> getDataSliceAs(ArrayRef Data, - size_t Offset, size_t Count); + uint64_t Offset, uint64_t Count); MinidumpFile(MemoryBufferRef Source, const minidump::Header &Header, ArrayRef Streams, @@ -208,6 +217,7 @@ Expected> MinidumpFile::getDataSliceAs(ArrayRef Data, getDataSlice(Data, Offset, sizeof(T) * Count); if (!Slice) return Slice.takeError(); + return ArrayRef(reinterpret_cast(Slice->data()), Count); } diff --git a/llvm/include/llvm/ObjectYAML/MinidumpYAML.h b/llvm/include/llvm/ObjectYAML/MinidumpYAML.h index b0cee541cef20..2cccf7fba5853 100644 --- a/llvm/include/llvm/ObjectYAML/MinidumpYAML.h +++ b/llvm/include/llvm/ObjectYAML/MinidumpYAML.h @@ -29,6 +29,7 @@ struct Stream { Exception, MemoryInfoList, MemoryList, +Memory64List, ModuleList, RawContent, SystemInfo, @@ -104,6 +105,25 @@ using ModuleListStream = detail::ListStream; using ThreadListStream = detail::ListStream; using MemoryListStream = detail::ListStream; +/// Memory64ListStream minidump stream. +struct Memory64ListStream : public Stream { + minidump::Memory64ListHeader Header; + std::vector Entries; + yaml::BinaryRef Content; + + Memory64ListStream() + : Stream(StreamKind::Memory64List, minidump::StreamType::Memory64List) {} + + explicit Memory64ListStream( + std::vector Entries) + : Stream(StreamKind::Memory64List, minidump::StreamType::Memory64List), +Entries(Entries) {} + + static bool classof(const Stream *S) { +return S->Kind == StreamKind::Memory64List; + } +}; + /// ExceptionStream minidump stream. struct ExceptionStream : public Stream { minidump::ExceptionStream MDExceptionStream; @@ -244,6 +264,12 @@ template <> struct MappingContextTraits { BinaryRef &Content); }; +template <> +struct MappingContextTraits { + static void mapping(IO &IO, minidump::MemoryDescriptor_64 &Memory, + BinaryRef &Content); +}; + } // namespace yaml } // namespace llvm @@ -262,6 +288,7 @@ LLVM_YAML_DECLARE_MAPPING_TRAITS(llvm::minidump::CPUInfo::X86Info) LLVM_YAML_DECLARE_MAPPING_TRAITS(llvm::minidump::Exception) LLVM_YAML_DECLARE_MAPPING_TRAITS(llvm::minidump::MemoryInfo) LLVM_YAML_DECLARE_MAPPING_TRAIT