[Lldb-commits] [lldb] [lldb][AArch64] Do not crash if NT_ARM_TLS is missing (PR #106478)
@@ -0,0 +1,34 @@ +# REQUIRES: aarch64 DavidSpickett wrote: Is this requiring the host to be aarch64 or that the aarch64 llvm target is enabled, we should only need the latter for this. https://github.com/llvm/llvm-project/pull/106478 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AArch64] Do not crash if NT_ARM_TLS is missing (PR #106478)
@@ -254,9 +254,10 @@ RegisterInfoPOSIX_arm64::RegisterInfoPOSIX_arm64( if (m_opt_regsets.AllSet(eRegsetMaskMTE)) AddRegSetMTE(); - // The TLS set always contains tpidr but only has tpidr2 when SME is - // present. - AddRegSetTLS(m_opt_regsets.AllSet(eRegsetMaskSSVE)); + if (m_opt_regsets.AllSet(eRegsetMaskTLS)) DavidSpickett wrote: Add braces here {} as the body is now >1 line. https://github.com/llvm/llvm-project/pull/106478 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AArch64] Do not crash if NT_ARM_TLS is missing (PR #106478)
DavidSpickett wrote: Interested in how you ended up with a file without it, perhaps there was some era of kernels that produces that result. But given we do a check whether to set the regset bit, we should use the result of that later anyway, so this looks ok to me. https://github.com/llvm/llvm-project/pull/106478 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AArch64] Do not crash if NT_ARM_TLS is missing (PR #106478)
DavidSpickett wrote: And "don't crash on invalid input" is a good enough reason to fix this regardless of how the core file was generated, even if the core file is corrupted. https://github.com/llvm/llvm-project/pull/106478 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] c954306 - [lldb][lldb-dap][test] Enable more tests on Windows
Author: David Spickett Date: 2024-08-29T07:37:02Z New Revision: c954306ef763eb25f06432324889bde98735963d URL: https://github.com/llvm/llvm-project/commit/c954306ef763eb25f06432324889bde98735963d DIFF: https://github.com/llvm/llvm-project/commit/c954306ef763eb25f06432324889bde98735963d.diff LOG: [lldb][lldb-dap][test] Enable more tests on Windows These tests "just work" on our Windows On Arm machine. Added: Modified: lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py lldb/test/API/tools/lldb-dap/console/TestDAP_console.py Removed: diff --git a/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py index 78ceb7971112e5..33e7dcbe1b3b2f 100644 --- a/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py +++ b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py @@ -19,7 +19,6 @@ def setUp(self): self.main_basename = "main-copy.cpp" self.main_path = os.path.realpath(self.getBuildArtifact(self.main_basename)) -@skipIfWindows def test_logmessage_basic(self): """Tests breakpoint logmessage basic functionality.""" before_loop_line = line_number("main.cpp", "// before loop") diff --git a/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py b/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py index 9e64dfe1daf0e3..8bbab8d0991dee 100644 --- a/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py +++ b/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py @@ -37,7 +37,6 @@ def check_lldb_command( ), ) -@skipIfWindows def test_scopes_variables_setVariable_evaluate(self): """ Tests that the "scopes" request causes the currently selected @@ -80,7 +79,6 @@ def test_scopes_variables_setVariable_evaluate(self): self.check_lldb_command("frame select", "frame #1", "frame 1 is selected") -@skipIfWindows def test_custom_escape_prefix(self): program = self.getBuildArtifact("a.out") self.build_and_launch(program, commandEscapePrefix="::") @@ -96,7 +94,6 @@ def test_custom_escape_prefix(self): command_escape_prefix="::", ) -@skipIfWindows def test_empty_escape_prefix(self): program = self.getBuildArtifact("a.out") self.build_and_launch(program, commandEscapePrefix="") @@ -151,7 +148,6 @@ def test_exit_status_message_sigterm(self): "Exit status does not contain message 'exited with status'", ) -@skipIfWindows def test_exit_status_message_ok(self): program = self.getBuildArtifact("a.out") self.build_and_launch(program, commandEscapePrefix="") ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [compiler-rt] [libcxx] [lldb] [llvm] Rename Sanitizer Coverage => Coverage Sanitizer (PR #106505)
https://github.com/cor3ntin created https://github.com/llvm/llvm-project/pull/106505 This is so that we are consistent with other sanitizers. Importantly, this makes the docs clearer. Driver flags are left unchanged (We are not proposing to rename `sancov` either). The good thing is that flags were already consistent with other sanitizers so there would not be any motivation to change them, even if we were feeling disruptive. >From adb4a0eb00972811343ff05eac6977512f01970a Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Thu, 29 Aug 2024 09:43:56 +0200 Subject: [PATCH] Rename Sanitizer Coverage => Coverage Sanitizer This is so that we are consistent with other sanitizers. Importantly, this makes the docs clearer. Driver flags are left unchanged. The good thing is that flags were already consistent with other sanitizers so there would not be any motivation to change them, even if we were feeling disruptive. --- ...izerCoverage.rst => CoverageSanitizer.rst} | 16 ++-- clang/docs/SourceBasedCodeCoverage.rst| 2 +- clang/docs/UsersManual.rst| 2 +- clang/docs/index.rst | 2 +- clang/docs/tools/clang-formatted-files.txt| 2 +- clang/include/clang/Basic/AttrDocs.td | 4 +- clang/include/clang/Basic/CodeGenOptions.def | 18 ++-- clang/include/clang/Basic/CodeGenOptions.h| 2 +- .../clang/Basic/DiagnosticDriverKinds.td | 8 +- clang/include/clang/Driver/Options.td | 26 +++--- clang/lib/CodeGen/BackendUtil.cpp | 10 +-- clang/lib/Driver/SanitizerArgs.cpp| 4 +- clang/test/CodeGen/Inputs/memprof.exe | Bin 1394680 -> 1394680 bytes clang/test/CodeGen/sancov-new-pm.c| 2 +- clang/test/Driver/sancov.c| 2 +- .../include/sanitizer/common_interface_defs.h | 2 +- .../include/sanitizer/coverage_interface.h| 2 +- compiler-rt/lib/fuzzer/dataflow/DataFlow.cpp | 4 +- .../lib/sanitizer_common/CMakeLists.txt | 18 ++-- ...sia.cpp => coverage_sanitizer_fuchsia.cpp} | 6 +- ...e.inc => coverage_sanitizer_interface.inc} | 4 +- ...cpp => coverage_sanitizer_libcdep_new.cpp} | 8 +- ...p => coverage_sanitizer_win_dll_thunk.cpp} | 6 +- ...e_sanitizer_win_dynamic_runtime_thunk.cpp} | 8 +- ...pp => coverage_sanitizer_win_sections.cpp} | 4 +- ...erage_sanitizer_win_weak_interception.cpp} | 6 +- .../lib/sanitizer_common/sancov_flags.cpp | 2 +- .../lib/sanitizer_common/sancov_flags.h | 2 +- .../lib/sanitizer_common/sancov_flags.inc | 2 +- .../Darwin/interface_symbols_darwin.cpp | 2 +- .../Linux/interface_symbols_linux.cpp | 2 +- .../asan/TestCases/Posix/coverage-reset.cpp | 14 +-- .../test/asan/TestCases/coverage-and-lsan.cpp | 2 +- ...verage_sanitizer_allowlist_ignorelist.cpp} | 0 ...pp => coverage_sanitizer_control_flow.cpp} | 0 ...coverage_sanitizer_inline8bit_counter.cpp} | 0 ...tizer_inline8bit_counter_default_impl.cpp} | 0 ...> coverage_sanitizer_inline_bool_flag.cpp} | 0 ...ne.cpp => coverage_sanitizer_no_prune.cpp} | 0 ...cpp => coverage_sanitizer_stack_depth.cpp} | 0 ...e.cpp => coverage_sanitizer_symbolize.cpp} | 2 +- ...coverage_sanitizer_trace_loads_stores.cpp} | 0 ...coverage_sanitizer_trace_pc_guard-dso.cpp} | 10 +-- ...overage_sanitizer_trace_pc_guard-init.cpp} | 0 ... => coverage_sanitizer_trace_pc_guard.cpp} | 8 +- libcxx/docs/VendorDocumentation.rst | 2 +- lldb/docs/resources/fuzzing.rst | 4 +- llvm/docs/FuzzingLLVM.rst | 2 +- llvm/docs/LangRef.rst | 2 +- llvm/docs/LibFuzzer.rst | 12 +-- llvm/docs/SymbolizerMarkupFormat.rst | 2 +- .../include/llvm/Transforms/Instrumentation.h | 6 +- ...anitizerCoverage.h => CoverageSanitizer.h} | 14 +-- llvm/lib/Passes/PassBuilder.cpp | 2 +- llvm/lib/Passes/PassRegistry.def | 2 +- .../Transforms/Instrumentation/CMakeLists.txt | 2 +- ...izerCoverage.cpp => CoverageSanitizer.cpp} | 82 +- .../SanitizerCoverage/crit-edge-sancov.ll | 4 +- .../Transforms/PGOProfile/Inputs/memprof.exe | Bin 1606400 -> 1606400 bytes .../PGOProfile/Inputs/memprof.nocolinfo.exe | Bin 1606168 -> 1606168 bytes .../Inputs/memprof_internal_linkage.exe | Bin 1605160 -> 1605160 bytes .../PGOProfile/Inputs/memprof_loop_unroll.exe | Bin 1605960 -> 1605960 bytes .../Inputs/memprof_missing_leaf.exe | Bin 1605072 -> 1605072 bytes .../Inputs/basic-histogram.memprofexe | Bin 1611256 -> 1611256 bytes .../llvm-profdata/Inputs/basic.memprofexe | Bin 1604896 -> 1604896 bytes .../llvm-profdata/Inputs/basic_v3.memprofexe | Bin 1379856 -> 1379856 bytes .../llvm-profdata/Inputs/buildid.memprofexe | Bin 1604904 -> 1604904 bytes .../llvm-profdata/Inputs/inline.memprofexe| Bin 1605480 -> 1605480 bytes .../l
[Lldb-commits] [clang] [compiler-rt] [libcxx] [lldb] [llvm] Rename Sanitizer Coverage => Coverage Sanitizer (PR #106505)
llvmbot wrote: @llvm/pr-subscribers-lldb @llvm/pr-subscribers-libcxx Author: cor3ntin (cor3ntin) Changes This is so that we are consistent with other sanitizers. Importantly, this makes the docs clearer. Driver flags are left unchanged (We are not proposing to rename `sancov` either). The good thing is that flags were already consistent with other sanitizers so there would not be any motivation to change them, even if we were feeling disruptive. --- Patch is 84.39 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/106505.diff 79 Files Affected: - (renamed) clang/docs/CoverageSanitizer.rst (+8-8) - (modified) clang/docs/SourceBasedCodeCoverage.rst (+1-1) - (modified) clang/docs/UsersManual.rst (+1-1) - (modified) clang/docs/index.rst (+1-1) - (modified) clang/docs/tools/clang-formatted-files.txt (+1-1) - (modified) clang/include/clang/Basic/AttrDocs.td (+2-2) - (modified) clang/include/clang/Basic/CodeGenOptions.def (+9-9) - (modified) clang/include/clang/Basic/CodeGenOptions.h (+1-1) - (modified) clang/include/clang/Basic/DiagnosticDriverKinds.td (+4-4) - (modified) clang/include/clang/Driver/Options.td (+13-13) - (modified) clang/lib/CodeGen/BackendUtil.cpp (+5-5) - (modified) clang/lib/Driver/SanitizerArgs.cpp (+2-2) - (modified) clang/test/CodeGen/Inputs/memprof.exe () - (modified) clang/test/CodeGen/sancov-new-pm.c (+1-1) - (modified) clang/test/Driver/sancov.c (+1-1) - (modified) compiler-rt/include/sanitizer/common_interface_defs.h (+1-1) - (modified) compiler-rt/include/sanitizer/coverage_interface.h (+1-1) - (modified) compiler-rt/lib/fuzzer/dataflow/DataFlow.cpp (+2-2) - (modified) compiler-rt/lib/sanitizer_common/CMakeLists.txt (+9-9) - (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_fuchsia.cpp (+3-3) - (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_interface.inc (+2-2) - (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_libcdep_new.cpp (+4-4) - (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_dll_thunk.cpp (+3-3) - (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_dynamic_runtime_thunk.cpp (+4-4) - (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_sections.cpp (+2-2) - (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_weak_interception.cpp (+3-3) - (modified) compiler-rt/lib/sanitizer_common/sancov_flags.cpp (+1-1) - (modified) compiler-rt/lib/sanitizer_common/sancov_flags.h (+1-1) - (modified) compiler-rt/lib/sanitizer_common/sancov_flags.inc (+1-1) - (modified) compiler-rt/test/asan/TestCases/Darwin/interface_symbols_darwin.cpp (+1-1) - (modified) compiler-rt/test/asan/TestCases/Linux/interface_symbols_linux.cpp (+1-1) - (modified) compiler-rt/test/asan/TestCases/Posix/coverage-reset.cpp (+7-7) - (modified) compiler-rt/test/asan/TestCases/coverage-and-lsan.cpp (+1-1) - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_allowlist_ignorelist.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_control_flow.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline8bit_counter.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline8bit_counter_default_impl.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline_bool_flag.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_no_prune.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_stack_depth.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_symbolize.cpp (+1-1) - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_loads_stores.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard-dso.cpp (+5-5) - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard-init.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard.cpp (+4-4) - (modified) libcxx/docs/VendorDocumentation.rst (+1-1) - (modified) lldb/docs/resources/fuzzing.rst (+2-2) - (modified) llvm/docs/FuzzingLLVM.rst (+1-1) - (modified) llvm/docs/LangRef.rst (+1-1) - (modified) llvm/docs/LibFuzzer.rst (+6-6) - (modified) llvm/docs/SymbolizerMarkupFormat.rst (+1-1) - (modified) llvm/include/llvm/Transforms/Instrumentation.h (+3-3) - (renamed) llvm/include/llvm/Transforms/Instrumentation/CoverageSanitizer.h (+7-7) - (modified) llvm/lib/Passes/PassBuilder.cpp (+1-1) - (modified) llvm/lib/Passes/PassRegistry.def (+1-1) - (modified) llvm/lib/Transforms/Instrumentation/CMakeLists.txt (+1-1) - (renamed) llvm/lib/Transforms/Instrumentation/CoverageSanitizer.cpp (+41-41) - (modified) llvm/test/Instrumentation/SanitizerCoverage/crit-edge-sancov.ll (+2-2) - (modified) llvm/t
[Lldb-commits] [clang] [compiler-rt] [libcxx] [lldb] [llvm] Rename Sanitizer Coverage => Coverage Sanitizer (PR #106505)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen Author: cor3ntin (cor3ntin) Changes This is so that we are consistent with other sanitizers. Importantly, this makes the docs clearer. Driver flags are left unchanged (We are not proposing to rename `sancov` either). The good thing is that flags were already consistent with other sanitizers so there would not be any motivation to change them, even if we were feeling disruptive. --- Patch is 84.39 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/106505.diff 79 Files Affected: - (renamed) clang/docs/CoverageSanitizer.rst (+8-8) - (modified) clang/docs/SourceBasedCodeCoverage.rst (+1-1) - (modified) clang/docs/UsersManual.rst (+1-1) - (modified) clang/docs/index.rst (+1-1) - (modified) clang/docs/tools/clang-formatted-files.txt (+1-1) - (modified) clang/include/clang/Basic/AttrDocs.td (+2-2) - (modified) clang/include/clang/Basic/CodeGenOptions.def (+9-9) - (modified) clang/include/clang/Basic/CodeGenOptions.h (+1-1) - (modified) clang/include/clang/Basic/DiagnosticDriverKinds.td (+4-4) - (modified) clang/include/clang/Driver/Options.td (+13-13) - (modified) clang/lib/CodeGen/BackendUtil.cpp (+5-5) - (modified) clang/lib/Driver/SanitizerArgs.cpp (+2-2) - (modified) clang/test/CodeGen/Inputs/memprof.exe () - (modified) clang/test/CodeGen/sancov-new-pm.c (+1-1) - (modified) clang/test/Driver/sancov.c (+1-1) - (modified) compiler-rt/include/sanitizer/common_interface_defs.h (+1-1) - (modified) compiler-rt/include/sanitizer/coverage_interface.h (+1-1) - (modified) compiler-rt/lib/fuzzer/dataflow/DataFlow.cpp (+2-2) - (modified) compiler-rt/lib/sanitizer_common/CMakeLists.txt (+9-9) - (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_fuchsia.cpp (+3-3) - (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_interface.inc (+2-2) - (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_libcdep_new.cpp (+4-4) - (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_dll_thunk.cpp (+3-3) - (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_dynamic_runtime_thunk.cpp (+4-4) - (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_sections.cpp (+2-2) - (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_weak_interception.cpp (+3-3) - (modified) compiler-rt/lib/sanitizer_common/sancov_flags.cpp (+1-1) - (modified) compiler-rt/lib/sanitizer_common/sancov_flags.h (+1-1) - (modified) compiler-rt/lib/sanitizer_common/sancov_flags.inc (+1-1) - (modified) compiler-rt/test/asan/TestCases/Darwin/interface_symbols_darwin.cpp (+1-1) - (modified) compiler-rt/test/asan/TestCases/Linux/interface_symbols_linux.cpp (+1-1) - (modified) compiler-rt/test/asan/TestCases/Posix/coverage-reset.cpp (+7-7) - (modified) compiler-rt/test/asan/TestCases/coverage-and-lsan.cpp (+1-1) - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_allowlist_ignorelist.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_control_flow.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline8bit_counter.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline8bit_counter_default_impl.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline_bool_flag.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_no_prune.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_stack_depth.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_symbolize.cpp (+1-1) - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_loads_stores.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard-dso.cpp (+5-5) - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard-init.cpp () - (renamed) compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard.cpp (+4-4) - (modified) libcxx/docs/VendorDocumentation.rst (+1-1) - (modified) lldb/docs/resources/fuzzing.rst (+2-2) - (modified) llvm/docs/FuzzingLLVM.rst (+1-1) - (modified) llvm/docs/LangRef.rst (+1-1) - (modified) llvm/docs/LibFuzzer.rst (+6-6) - (modified) llvm/docs/SymbolizerMarkupFormat.rst (+1-1) - (modified) llvm/include/llvm/Transforms/Instrumentation.h (+3-3) - (renamed) llvm/include/llvm/Transforms/Instrumentation/CoverageSanitizer.h (+7-7) - (modified) llvm/lib/Passes/PassBuilder.cpp (+1-1) - (modified) llvm/lib/Passes/PassRegistry.def (+1-1) - (modified) llvm/lib/Transforms/Instrumentation/CMakeLists.txt (+1-1) - (renamed) llvm/lib/Transforms/Instrumentation/CoverageSanitizer.cpp (+41-41) - (modified) llvm/test/Instrumentation/SanitizerCoverage/crit-edge-sancov.ll (+2-2) - (modified) llvm/test/Transforms/PGOP
[Lldb-commits] [clang] [compiler-rt] [libcxx] [lldb] [llvm] Rename Sanitizer Coverage => Coverage Sanitizer (PR #106505)
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 ec9f36a624fa9f8fea6e40384ce513b6da8c08e4 adb4a0eb00972811343ff05eac6977512f01970a --extensions c,h,inc,cpp -- clang/include/clang/Basic/CodeGenOptions.h clang/lib/CodeGen/BackendUtil.cpp clang/lib/Driver/SanitizerArgs.cpp clang/test/CodeGen/sancov-new-pm.c clang/test/Driver/sancov.c compiler-rt/include/sanitizer/common_interface_defs.h compiler-rt/include/sanitizer/coverage_interface.h compiler-rt/lib/fuzzer/dataflow/DataFlow.cpp compiler-rt/lib/sanitizer_common/sancov_flags.cpp compiler-rt/lib/sanitizer_common/sancov_flags.h compiler-rt/lib/sanitizer_common/sancov_flags.inc compiler-rt/test/asan/TestCases/Darwin/interface_symbols_darwin.cpp compiler-rt/test/asan/TestCases/Linux/interface_symbols_linux.cpp compiler-rt/test/asan/TestCases/Posix/coverage-reset.cpp compiler-rt/test/asan/TestCases/coverage-and-lsan.cpp llvm/include/llvm/Transforms/Instrumentation.h llvm/lib/Passes/PassBuilder.cpp llvm/tools/sancov/sancov.cpp compiler-rt/lib/sanitizer_common/coverage_sanitizer_fuchsia.cpp compiler-rt/lib/sanitizer_common/coverage_sanitizer_interface.inc compiler-rt/lib/sanitizer_common/coverage_sanitizer_libcdep_new.cpp compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_dll_thunk.cpp compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_dynamic_runtime_thunk.cpp compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_sections.cpp compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_weak_interception.cpp compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_allowlist_ignorelist.cpp compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_control_flow.cpp compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline8bit_counter.cpp compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline8bit_counter_default_impl.cpp compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline_bool_flag.cpp compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_no_prune.cpp compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_stack_depth.cpp compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_symbolize.cpp compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_loads_stores.cpp compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard-dso.cpp compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard-init.cpp compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard.cpp llvm/include/llvm/Transforms/Instrumentation/CoverageSanitizer.h llvm/lib/Transforms/Instrumentation/CoverageSanitizer.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 3301a0f9b5..382cee4527 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -68,6 +68,7 @@ #include "llvm/Transforms/Instrumentation/AddressSanitizer.h" #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h" #include "llvm/Transforms/Instrumentation/BoundsChecking.h" +#include "llvm/Transforms/Instrumentation/CoverageSanitizer.h" #include "llvm/Transforms/Instrumentation/DataFlowSanitizer.h" #include "llvm/Transforms/Instrumentation/GCOVProfiler.h" #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h" @@ -80,7 +81,6 @@ #include "llvm/Transforms/Instrumentation/PGOInstrumentation.h" #include "llvm/Transforms/Instrumentation/RealtimeSanitizer.h" #include "llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h" -#include "llvm/Transforms/Instrumentation/CoverageSanitizer.h" #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h" #include "llvm/Transforms/ObjCARC.h" #include "llvm/Transforms/Scalar/EarlyCSE.h" diff --git a/compiler-rt/lib/sanitizer_common/coverage_sanitizer_fuchsia.cpp b/compiler-rt/lib/sanitizer_common/coverage_sanitizer_fuchsia.cpp index 9343079f78..026b669a1c 100644 --- a/compiler-rt/lib/sanitizer_common/coverage_sanitizer_fuchsia.cpp +++ b/compiler-rt/lib/sanitizer_common/coverage_sanitizer_fuchsia.cpp @@ -27,14 +27,14 @@ #include "sanitizer_platform.h" #if SANITIZER_FUCHSIA -#include -#include -#include - -#include "sanitizer_atomic.h" -#include "sanitizer_common.h" -#include "sanitizer_interface_internal.h" -#include "sanitizer_internal_defs.h" +# include +# include +# include + +# include "sanitizer_atomic.h" +# include "sanitizer_common.h" +# include "sanitizer_interface_internal.h" +# include "sanitizer_internal_defs.h" # include "sanitizer_symbolizer_markup_constants.h" using namespace __sanitizer; diff --git a/compiler-rt/lib/sanitizer_common/coverage_sanitizer_libcdep_new.cpp b/compiler-rt/lib/sanitizer_common/coverage_sanitizer_libcdep_new.cpp index ab4
[Lldb-commits] [lldb] [lldb] Inline expression evaluator error visualization (PR #106470)
labath wrote: This seems like it could be problematic for IDEs, if they don't print the error in the same window as the expression being evaluated. The arrows could end up pointing to nowhere, or to the wrong place in the expression (if we don't get the right offset). I think this could be made simpler and more robust by just printing a reproduction of the expression as the first line of the error message. It saving that one line output worth it? Also, how will this behave for multiline expressions? Or with errors that refer to multiple source locations (e.g inside macro expansions)? ``` (lldb) expr Enter expressions, then terminate with an empty line to evaluate: 1: #define FOO(x) foo+x 2: FOO(bar) error: :2:1: use of undeclared identifier 'foo' 2 | FOO(bar) | ^ :1:16: expanded from macro 'FOO' 1 | #define FOO(x) foo+x |^ error: :2:5: use of undeclared identifier 'bar' 2 | FOO(bar) | ^ ``` https://github.com/llvm/llvm-project/pull/106470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ae34257 - [lldb][lldb-dap][test] Skip logpoint test on Windows again
Author: David Spickett Date: 2024-08-29T08:33:34Z New Revision: ae34257e9015a366ea63cd461535b35bc9837c57 URL: https://github.com/llvm/llvm-project/commit/ae34257e9015a366ea63cd461535b35bc9837c57 DIFF: https://github.com/llvm/llvm-project/commit/ae34257e9015a366ea63cd461535b35bc9837c57.diff LOG: [lldb][lldb-dap][test] Skip logpoint test on Windows again This one snuck into the previous patch. The test program needs updating if it's ever going to work on Windows. Added: Modified: lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py Removed: diff --git a/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py index 33e7dcbe1b3b2f..78ceb7971112e5 100644 --- a/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py +++ b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py @@ -19,6 +19,7 @@ def setUp(self): self.main_basename = "main-copy.cpp" self.main_path = os.path.realpath(self.getBuildArtifact(self.main_basename)) +@skipIfWindows def test_logmessage_basic(self): """Tests breakpoint logmessage basic functionality.""" before_loop_line = line_number("main.cpp", "// before loop") ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add Status::Detail to store expression evaluator diagnostics [… (PR #106442)
labath wrote: The llvm::Error class already supports this kind of metadata (and in a much better way IMO). Given that moving to llvm::Error is our long term goal, would it be possible to port enough APIs so that it's possible to pass an unmodified Error object from the producer to the place that needs to consume it? https://github.com/llvm/llvm-project/pull/106442 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Updated TCPSocket to listen multiple ports on the same single thread (PR #104797)
https://github.com/slydiman edited https://github.com/llvm/llvm-project/pull/104797 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)
https://github.com/labath commented: This looks great. I don't think anyone will object to removing old ndk support, but let's leave this PR open for a while to give people a chance to notice. https://github.com/llvm/llvm-project/pull/106443 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/106443 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)
@@ -1,81 +1,55 @@ NDK_ROOT := $(shell dirname $(CC))/../../../../.. -ifeq "$(findstring 64, $(ARCH))" "64" - # lowest 64-bit API level - API_LEVEL := 21 -else ifeq "$(ARCH)" "i386" - # clone(2) declaration is present only since this api level - API_LEVEL := 17 +ifeq "$(HOST_OS)" "Linux" + HOST_TAG := linux-x86_64 +else ifeq "$(HOST_OS)" "Darwin" + HOST_TAG := darwin-x86_64 else - # lowest supported 32-bit API level - API_LEVEL := 16 + HOST_TAG := windows-x86_64 +endif + +TOOLCHAIN_SYSROOT := $(NDK_ROOT)/toolchains/llvm/prebuilt/$(HOST_TAG)/sysroot + +ifeq "$(wildcard $(TOOLCHAIN_SYSROOT)/.)" "" +# Compiling test inferiors for Android requires an NDK with the unified +# toolchain introduced in version r19. +$(error "No unified toolchain sysroot found in $(NDK_ROOT). NDK must be r19 or later.") endif ifeq "$(ARCH)" "arm" - SYSROOT_ARCH := arm - STL_ARCH := armeabi-v7a TRIPLE := armv7-none-linux-androideabi ARCH_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm else ifeq "$(ARCH)" "aarch64" - SYSROOT_ARCH := arm64 - STL_ARCH := arm64-v8a TRIPLE := aarch64-none-linux-android else ifeq "$(ARCH)" "i386" - SYSROOT_ARCH := x86 - STL_ARCH := x86 TRIPLE := i686-none-linux-android else - SYSROOT_ARCH := $(ARCH) - STL_ARCH := $(ARCH) TRIPLE := $(ARCH)-none-linux-android endif -ifeq "$(findstring 86,$(ARCH))" "86" - TOOLCHAIN_DIR := $(STL_ARCH)-4.9 -else ifeq "$(ARCH)" "arm" - TOOLCHAIN_DIR := arm-linux-androideabi-4.9 -else - TOOLCHAIN_DIR := $(subst -none,,$(TRIPLE))-4.9 -endif +# lowest 64-bit API level +API_LEVEL := 21 ifeq "$(ARCH)" "arm" - TOOL_PREFIX := arm-linux-androideabi -else - TOOL_PREFIX := $(subst -none,,$(TRIPLE)) -endif - -ifeq "$(HOST_OS)" "Linux" - HOST_TAG := linux-x86_64 -else ifeq "$(HOST_OS)" "Darwin" - HOST_TAG := darwin-x86_64 + ARCH_DIR := arm-linux-androideabi else - HOST_TAG := windows-x86_64 -endif - -GCC_TOOLCHAIN = $(NDK_ROOT)/toolchains/$(TOOLCHAIN_DIR)/prebuilt/$(HOST_TAG) - -OBJCOPY ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-objcopy -ARCHIVER ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-ar - -ifeq "$(findstring clang,$(CC))" "clang" - ARCH_CFLAGS += -target $(TRIPLE) --gcc-toolchain=$(GCC_TOOLCHAIN) - ARCH_LDFLAGS += -target $(TRIPLE) --gcc-toolchain=$(GCC_TOOLCHAIN) + ARCH_DIR := $(subst -none,,$(TRIPLE)) endif -ARCH_CFLAGS += --sysroot=$(NDK_ROOT)/sysroot \ - -isystem $(NDK_ROOT)/sysroot/usr/include/$(TOOL_PREFIX) \ - -D__ANDROID_API__=$(API_LEVEL) \ - -isystem $(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH)/usr/include - -ARCH_LDFLAGS += --sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) -lm +ARCH_CFLAGS += \ + --target=$(TRIPLE) \ + --sysroot=$(TOOLCHAIN_SYSROOT) \ + -D __ANDROID_API__=$(API_LEVEL) \ ARCH_CXXFLAGS += \ - -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/include \ - -isystem $(NDK_ROOT)/sources/android/support/include \ - -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi/include + -isystem $(TOOLCHAIN_SYSROOT)/usr/include/c++/v1 \ ARCH_LDFLAGS += \ - -L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \ - $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++_static.a \ + --target=$(TRIPLE) \ + --sysroot=$(TOOLCHAIN_SYSROOT) \ + --prefix=$(TOOLCHAIN_SYSROOT)/usr/lib/$(ARCH_DIR)/$(API_LEVEL) \ + --library-directory=$(TOOLCHAIN_SYSROOT)/usr/lib/$(ARCH_DIR)/$(API_LEVEL) \ + $(TOOLCHAIN_SYSROOT)/usr/lib/$(ARCH_DIR)/libc++_static.a \ + -lm \ -lc++abi \ - -nostdlib++ + -nostdlib++ \ labath wrote: I get the diff benefits of this, but a backslash continuation at the end of a file looks very suspicious. I'd just remove all of the final backslashes you have here. https://github.com/llvm/llvm-project/pull/106443 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Updated TCPSocket to listen multiple ports on the same single thread (PR #104797)
https://github.com/slydiman edited https://github.com/llvm/llvm-project/pull/104797 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)
@@ -1,81 +1,55 @@ NDK_ROOT := $(shell dirname $(CC))/../../../../.. -ifeq "$(findstring 64, $(ARCH))" "64" - # lowest 64-bit API level - API_LEVEL := 21 -else ifeq "$(ARCH)" "i386" - # clone(2) declaration is present only since this api level - API_LEVEL := 17 +ifeq "$(HOST_OS)" "Linux" + HOST_TAG := linux-x86_64 +else ifeq "$(HOST_OS)" "Darwin" + HOST_TAG := darwin-x86_64 else - # lowest supported 32-bit API level - API_LEVEL := 16 + HOST_TAG := windows-x86_64 +endif + +TOOLCHAIN_SYSROOT := $(NDK_ROOT)/toolchains/llvm/prebuilt/$(HOST_TAG)/sysroot + +ifeq "$(wildcard $(TOOLCHAIN_SYSROOT)/.)" "" +# Compiling test inferiors for Android requires an NDK with the unified +# toolchain introduced in version r19. +$(error "No unified toolchain sysroot found in $(NDK_ROOT). NDK must be r19 or later.") endif ifeq "$(ARCH)" "arm" - SYSROOT_ARCH := arm - STL_ARCH := armeabi-v7a TRIPLE := armv7-none-linux-androideabi ARCH_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm else ifeq "$(ARCH)" "aarch64" - SYSROOT_ARCH := arm64 - STL_ARCH := arm64-v8a TRIPLE := aarch64-none-linux-android else ifeq "$(ARCH)" "i386" - SYSROOT_ARCH := x86 - STL_ARCH := x86 TRIPLE := i686-none-linux-android else - SYSROOT_ARCH := $(ARCH) - STL_ARCH := $(ARCH) TRIPLE := $(ARCH)-none-linux-android endif -ifeq "$(findstring 86,$(ARCH))" "86" - TOOLCHAIN_DIR := $(STL_ARCH)-4.9 -else ifeq "$(ARCH)" "arm" - TOOLCHAIN_DIR := arm-linux-androideabi-4.9 -else - TOOLCHAIN_DIR := $(subst -none,,$(TRIPLE))-4.9 -endif +# lowest 64-bit API level +API_LEVEL := 21 ifeq "$(ARCH)" "arm" - TOOL_PREFIX := arm-linux-androideabi -else - TOOL_PREFIX := $(subst -none,,$(TRIPLE)) -endif - -ifeq "$(HOST_OS)" "Linux" - HOST_TAG := linux-x86_64 -else ifeq "$(HOST_OS)" "Darwin" - HOST_TAG := darwin-x86_64 + ARCH_DIR := arm-linux-androideabi else - HOST_TAG := windows-x86_64 -endif - -GCC_TOOLCHAIN = $(NDK_ROOT)/toolchains/$(TOOLCHAIN_DIR)/prebuilt/$(HOST_TAG) - -OBJCOPY ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-objcopy -ARCHIVER ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-ar - -ifeq "$(findstring clang,$(CC))" "clang" - ARCH_CFLAGS += -target $(TRIPLE) --gcc-toolchain=$(GCC_TOOLCHAIN) - ARCH_LDFLAGS += -target $(TRIPLE) --gcc-toolchain=$(GCC_TOOLCHAIN) + ARCH_DIR := $(subst -none,,$(TRIPLE)) endif -ARCH_CFLAGS += --sysroot=$(NDK_ROOT)/sysroot \ - -isystem $(NDK_ROOT)/sysroot/usr/include/$(TOOL_PREFIX) \ - -D__ANDROID_API__=$(API_LEVEL) \ - -isystem $(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH)/usr/include - -ARCH_LDFLAGS += --sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) -lm +ARCH_CFLAGS += \ + --target=$(TRIPLE) \ + --sysroot=$(TOOLCHAIN_SYSROOT) \ + -D __ANDROID_API__=$(API_LEVEL) \ ARCH_CXXFLAGS += \ - -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/include \ - -isystem $(NDK_ROOT)/sources/android/support/include \ - -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi/include + -isystem $(TOOLCHAIN_SYSROOT)/usr/include/c++/v1 \ ARCH_LDFLAGS += \ - -L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \ - $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++_static.a \ + --target=$(TRIPLE) \ + --sysroot=$(TOOLCHAIN_SYSROOT) \ + --prefix=$(TOOLCHAIN_SYSROOT)/usr/lib/$(ARCH_DIR)/$(API_LEVEL) \ + --library-directory=$(TOOLCHAIN_SYSROOT)/usr/lib/$(ARCH_DIR)/$(API_LEVEL) \ labath wrote: ```suggestion -L$(TOOLCHAIN_SYSROOT)/usr/lib/$(ARCH_DIR)/$(API_LEVEL) \ ``` I haven't seen anyone use the long version of this option (I had to look it up to be sure of what it does), so I think it'd be better to stick to `-L`. `--prefix` is probably ok, since its short form (`-B`) is also not very common. https://github.com/llvm/llvm-project/pull/106443 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix and speedup the `memory find` command (PR #104193)
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/104193 >From 7b8b8b699902d2365ea43e5ae015546c4d20fac8 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Wed, 14 Aug 2024 19:58:27 +0200 Subject: [PATCH 1/5] [lldb] Fix and speedup the `memory find` command This patch fixes an issue where the `memory find` command would effectively stop searching after encountering a memory read error (which could happen due to unreadable memory), without giving any indication that it has done so (it would just print it could not find the pattern). To make matters worse, it would not terminate after encountering this error, but rather proceed to slowly increment the address pointer, which meant that searching a large region could take a very long time (and give the appearance that lldb is actually searching for the thing). The patch fixes this first problem (*) by detecting read errors and skipping over (using GetMemoryRegionInfo) the unreadable parts of memory and resuming the search after them. It also reads the memory in bulk (up to 1MB), which speeds up the search significantly (up to 6x for live processes, 18x for core files). (*) The fix does not work on windows yet, because the ReadMemory API does not return partial results (like it does for other systems). I'm preparing a separate patch to deal with that. --- lldb/source/Target/Process.cpp| 68 +++ .../memory/find/TestMemoryFind.py | 30 ++- .../API/functionalities/memory/find/main.cpp | 83 +-- 3 files changed, 136 insertions(+), 45 deletions(-) diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index b2a0f13b9a1549..5d066d264bd3f5 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -114,33 +114,6 @@ class ProcessOptionValueProperties } }; -class ProcessMemoryIterator { -public: - ProcessMemoryIterator(Process &process, lldb::addr_t base) - : m_process(process), m_base_addr(base) {} - - bool IsValid() { return m_is_valid; } - - uint8_t operator[](lldb::addr_t offset) { -if (!IsValid()) - return 0; - -uint8_t retval = 0; -Status error; -if (0 == m_process.ReadMemory(m_base_addr + offset, &retval, 1, error)) { - m_is_valid = false; - return 0; -} - -return retval; - } - -private: - Process &m_process; - const lldb::addr_t m_base_addr; - bool m_is_valid = true; -}; - static constexpr OptionEnumValueElement g_follow_fork_mode_values[] = { { eFollowParent, @@ -3367,21 +3340,48 @@ lldb::addr_t Process::FindInMemory(lldb::addr_t low, lldb::addr_t high, if (region_size < size) return LLDB_INVALID_ADDRESS; + // See "Boyer-Moore string search algorithm". std::vector bad_char_heuristic(256, size); - ProcessMemoryIterator iterator(*this, low); - for (size_t idx = 0; idx < size - 1; idx++) { decltype(bad_char_heuristic)::size_type bcu_idx = buf[idx]; bad_char_heuristic[bcu_idx] = size - idx - 1; } - for (size_t s = 0; s <= (region_size - size);) { + + // Memory we're currently searching through. + llvm::SmallVector mem; + // Position of the memory buffer. + addr_t mem_pos = low; + // Maximum number of bytes read (and buffered). We need to read at least + // `size` bytes for a successful match. + const size_t max_read_size = std::max(size, 0x1); + + for (addr_t s = low; s <= (high - size);) { +if (s + size > mem.size() + mem_pos) { + // We need to read more data. We don't attempt to reuse the data we've + // already read (up to `size-1` bytes from `s` to `mem_pos+mem.size()`). + // This is fine for patterns much smaller than max_read_size. For very + // long patterns we may need to do something more elaborate. + mem.resize_for_overwrite(max_read_size); + Status error; + mem.resize( + ReadMemory(s, mem.data(), std::min(mem.size(), high - s), error)); + mem_pos = s; + if (error.Fail() || size > mem.size()) { +// We didn't read enough data. Skip to the next memory region. +MemoryRegionInfo info; +error = GetMemoryRegionInfo(mem_pos + mem.size(), info); +if (error.Fail()) + break; +s = info.GetRange().GetRangeEnd(); +continue; + } +} int64_t j = size - 1; -while (j >= 0 && buf[j] == iterator[s + j]) +while (j >= 0 && buf[j] == mem[s + j - mem_pos]) j--; if (j < 0) - return low + s; -else - s += bad_char_heuristic[iterator[s + size - 1]]; + return s; // We have a match. +s += bad_char_heuristic[mem[s + size - 1 - mem_pos]]; } return LLDB_INVALID_ADDRESS; diff --git a/lldb/test/API/functionalities/memory/find/TestMemoryFind.py b/lldb/test/API/functionalities/memory/find/TestMemoryFind.py index 09611cc808777d..72acfb3d600701 100644 --- a/lldb/test/API/functionalities/memory/find/TestMemoryFind.py +++ b/lldb/test/API/functionalities/memory/fin
[Lldb-commits] [lldb] [lldb] Fix and speedup the `memory find` command (PR #104193)
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 cb9267f055156daabdbab87f4c1ca9064b0e7d7d 3fc95ce499d9e5d5691158fe0847afa8ec338106 --extensions cpp -- lldb/source/Target/Process.cpp lldb/test/API/functionalities/memory/find/main.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index d96771acdc..4206fe8591 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -3365,7 +3365,8 @@ lldb::addr_t Process::FindInMemory(lldb::addr_t low, lldb::addr_t high, mem.resize_for_overwrite(max_read_size); Status error; mem.resize(ReadMemory(cur_addr, mem.data(), -std::min(mem.size(), high - cur_addr), error)); +std::min(mem.size(), high - cur_addr), +error)); mem_pos = cur_addr; if (size > mem.size()) { // We didn't read enough data. Skip to the next memory region. `` https://github.com/llvm/llvm-project/pull/104193 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Updated TCPSocket to listen multiple ports on the same single thread (PR #104797)
labath wrote: > @labath > > > Having a single socket listen on multiple ports sounds like a bad idea to > > me. > > Note that currently the class TCPSocket already contains a list of > NativeSocket `m_listen_sockets`. I am aware of that, and I'm not entirely happy with how the class implements listening. I think it would be better to have a separate class for a listening socket, because those need a completely different APIs. But, even ignoring that, I think there's a difference between listening on two addresses with the same port (I believe the only way to reach that state is if a hostname resolves to multiple addresses, in which case one really could argue that it's the same "logical" address), and two addresses with completely unrelated ports. > We do not need 2 TCPSocket instances with 2 separated lists of native sockets > even with a common MainLoop. > > We have 2 options: > > * A) 2 threads - first one calls TCPSocket::Accept() for the platform > connection, second calls TCPSocket::Accept() for the gdb connection > > * B) 1 thread - a common TCPSocket::Accept() can accept platform and gdb > connections from both ports We have (at least) three options, the third one being what I outlined in the previous message. I'm sorry this work of yours is going to waste. I could've been more explicit about what I wanted to do on the first PR, but I was more focused on what I don't want to do. > > > I have implemented the option B. It was easy because the class TCPSocket > already contains `m_listen_sockets`. > > > Then we could create two sockets and have them listen on the same main loop > > instance. > > It is already implemented inside TCPSocket but for different addresses. That's true, but I draw a different conclusion from that. Instead of saying "this should be extended to support multiple ports", my take is that "this wasn't a good place for multiplexing to begin with". > I just added different ports. > > The changes are minimal really. Yes, but that's because you extended a stringly typed api to do that you wanted. That function is used from other places as well, and this means that other places in lldb (including user-facing code, I believe) can accept these multi-port connection strings. I don't think we want to support that. https://github.com/llvm/llvm-project/pull/104797 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/linux] Make truncated reads work (PR #106532)
https://github.com/labath created https://github.com/llvm/llvm-project/pull/106532 Previously, we were returning an error if we couldn't read the whole region. This doesn't matter most of the time, because lldb caches memory reads, and in that process it aligns them to cache line boundaries. As (LLDB) cache lines are smaller than pages, the reads are unlikely to cross page boundaries. Nonetheless, this can cause a problem for large reads (which bypass the cache), where we're unable to read anything even if just a single byte of the memory is unreadable. This patch fixes the lldb-server to do that, and also changes the linux implementation, to reuse any partial results it got from the process_vm_readv call (to avoid having to re-read everything again using ptrace, only to find that it stopped at the same place). This matches debugserver behavior. It is also consistent with the gdb remote protocol documentation, but -- notably -- not with actual gdbserver behavior (which returns errors instead of partial results). We filed a [clarification bug](https://sourceware.org/bugzilla/show_bug.cgi?id=24751) several years ago. Though we did not really reach a conclusion there, I think this is the most logical behavior. The associated test does not currently pass on windows, because the windows memory read APIs don't support partial reads (I have a WIP patch to work around that). >From 610757ced98139d3d10451dcca195692b0c2d832 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 29 Aug 2024 12:26:01 +0200 Subject: [PATCH] [lldb/linux] Make truncated reads work Previously, we were returning an error if we couldn't read the whole region. This doesn't matter most of the time, because lldb caches memory reads, and in that process it aligns them to cache line boundaries. As (LLDB) cache lines are smaller than pages, the reads are unlikely to cross page boundaries. Nonetheless, this can cause a problem for large reads (which bypass the cache), where we're unable to read anything even if just a single byte of the memory is unreadable. This patch fixes the lldb-server to do that, and also changes the linux implementation, to reuse any partial results it got from the process_vm_readv call (to avoid having to re-read everything again using ptrace, only to find that it stopped at the same place). This matches debugserver behavior. It is also consistent with the gdb remote protocol documentation, but -- notably -- not with actual gdbserver behavior (which returns errors instead of partial results). We filed a [clarification bug](https://sourceware.org/bugzilla/show_bug.cgi?id=24751) several years ago. Though we did not really reach a conclusion there, I think this is the most logical behavior. The associated test does not currently pass on windows, because the windows memory read APIs don't support partial reads (I have a WIP patch to work around that). --- .../Process/Linux/NativeProcessLinux.cpp | 41 - .../GDBRemoteCommunicationServerLLGS.cpp | 20 + .../API/functionalities/memory/holes/Makefile | 3 + .../memory/holes/TestMemoryHoles.py | 63 ++ .../API/functionalities/memory/holes/main.cpp | 87 +++ 5 files changed, 176 insertions(+), 38 deletions(-) create mode 100644 lldb/test/API/functionalities/memory/holes/Makefile create mode 100644 lldb/test/API/functionalities/memory/holes/TestMemoryHoles.py create mode 100644 lldb/test/API/functionalities/memory/holes/main.cpp diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index cb95da9fc72363..1e2e3a80b18bf6 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -1641,6 +1641,10 @@ NativeProcessLinux::GetSoftwareBreakpointTrapOpcode(size_t size_hint) { Status NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) { + Log *log = GetLog(POSIXLog::Memory); + LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size); + + bytes_read = 0; if (ProcessVmReadvSupported()) { // The process_vm_readv path is about 50 times faster than ptrace api. We // want to use this syscall if it is supported. @@ -1651,32 +1655,29 @@ Status NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size, remote_iov.iov_base = reinterpret_cast(addr); remote_iov.iov_len = size; -bytes_read = process_vm_readv(GetCurrentThreadID(), &local_iov, 1, - &remote_iov, 1, 0); -const bool success = bytes_read == size; +ssize_t read_result = process_vm_readv(GetCurrentThreadID(), &local_iov, 1, + &remote_iov, 1, 0); +int error = 0; +if (read_result < 0) + error = errno; +else + bytes_read = read_result; -Log *log = GetLog(POSIX
[Lldb-commits] [lldb] [lldb/linux] Make truncated reads work (PR #106532)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Pavel Labath (labath) Changes Previously, we were returning an error if we couldn't read the whole region. This doesn't matter most of the time, because lldb caches memory reads, and in that process it aligns them to cache line boundaries. As (LLDB) cache lines are smaller than pages, the reads are unlikely to cross page boundaries. Nonetheless, this can cause a problem for large reads (which bypass the cache), where we're unable to read anything even if just a single byte of the memory is unreadable. This patch fixes the lldb-server to do that, and also changes the linux implementation, to reuse any partial results it got from the process_vm_readv call (to avoid having to re-read everything again using ptrace, only to find that it stopped at the same place). This matches debugserver behavior. It is also consistent with the gdb remote protocol documentation, but -- notably -- not with actual gdbserver behavior (which returns errors instead of partial results). We filed a [clarification bug](https://sourceware.org/bugzilla/show_bug.cgi?id=24751) several years ago. Though we did not really reach a conclusion there, I think this is the most logical behavior. The associated test does not currently pass on windows, because the windows memory read APIs don't support partial reads (I have a WIP patch to work around that). --- Full diff: https://github.com/llvm/llvm-project/pull/106532.diff 5 Files Affected: - (modified) lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp (+19-22) - (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp (+4-16) - (added) lldb/test/API/functionalities/memory/holes/Makefile (+3) - (added) lldb/test/API/functionalities/memory/holes/TestMemoryHoles.py (+63) - (added) lldb/test/API/functionalities/memory/holes/main.cpp (+87) ``diff diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index cb95da9fc72363..1e2e3a80b18bf6 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -1641,6 +1641,10 @@ NativeProcessLinux::GetSoftwareBreakpointTrapOpcode(size_t size_hint) { Status NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) { + Log *log = GetLog(POSIXLog::Memory); + LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size); + + bytes_read = 0; if (ProcessVmReadvSupported()) { // The process_vm_readv path is about 50 times faster than ptrace api. We // want to use this syscall if it is supported. @@ -1651,32 +1655,29 @@ Status NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size, remote_iov.iov_base = reinterpret_cast(addr); remote_iov.iov_len = size; -bytes_read = process_vm_readv(GetCurrentThreadID(), &local_iov, 1, - &remote_iov, 1, 0); -const bool success = bytes_read == size; +ssize_t read_result = process_vm_readv(GetCurrentThreadID(), &local_iov, 1, + &remote_iov, 1, 0); +int error = 0; +if (read_result < 0) + error = errno; +else + bytes_read = read_result; -Log *log = GetLog(POSIXLog::Process); LLDB_LOG(log, - "using process_vm_readv to read {0} bytes from inferior " - "address {1:x}: {2}", - size, addr, success ? "Success" : llvm::sys::StrError(errno)); - -if (success) - return Status(); -// else the call failed for some reason, let's retry the read using ptrace -// api. + "process_vm_readv({0}, [iovec({1}, {2})], [iovec({3:x}, {2})], 1, " + "0) => {4} ({5})", + GetCurrentThreadID(), buf, size, addr, read_result, + error > 0 ? llvm::sys::StrError(errno) : "sucesss"); } unsigned char *dst = static_cast(buf); size_t remainder; long data; - Log *log = GetLog(POSIXLog::Memory); - LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size); - - for (bytes_read = 0; bytes_read < size; bytes_read += remainder) { + for (; bytes_read < size; bytes_read += remainder) { Status error = NativeProcessLinux::PtraceWrapper( -PTRACE_PEEKDATA, GetCurrentThreadID(), (void *)addr, nullptr, 0, &data); +PTRACE_PEEKDATA, GetCurrentThreadID(), +reinterpret_cast(addr + bytes_read), nullptr, 0, &data); if (error.Fail()) return error; @@ -1684,11 +1685,7 @@ Status NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size, remainder = remainder > k_ptrace_word_size ? k_ptrace_word_size : remainder; // Copy the data into our buffer -memcpy(dst, &data, remainder); - -LLDB_LOG(log, "[{0:x}]:{1:x}", addr, data); -addr += k_ptrace_word_size; -dst += k
[Lldb-commits] [lldb] [lldb/linux] Make truncated reads work (PR #106532)
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 fdca2c33a1f33f4886d969ea0f0219764c7b6b59 610757ced98139d3d10451dcca195692b0c2d832 --extensions cpp -- lldb/test/API/functionalities/memory/holes/main.cpp lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/test/API/functionalities/memory/holes/main.cpp b/lldb/test/API/functionalities/memory/holes/main.cpp index b641fd2ebe..3228a1bff7 100644 --- a/lldb/test/API/functionalities/memory/holes/main.cpp +++ b/lldb/test/API/functionalities/memory/holes/main.cpp @@ -27,7 +27,8 @@ int getpagesize() { char *allocate_memory_with_holes() { int pagesize = getpagesize(); - void *mem = VirtualAlloc(nullptr, num_pages * pagesize, MEM_RESERVE, PAGE_NOACCESS); + void *mem = + VirtualAlloc(nullptr, num_pages * pagesize, MEM_RESERVE, PAGE_NOACCESS); if (!mem) { std::cerr << std::system_category().message(GetLastError()) << std::endl; exit(1); `` https://github.com/llvm/llvm-project/pull/106532 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/linux] Make truncated reads work (PR #106532)
@@ -0,0 +1,63 @@ +""" +Test the memory commands operating on memory regions with holes +""" + +import lldb +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * + + +class MemoryHolesTestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def setUp(self): +super().setUp() +# Find the line number to break inside main(). +self.line = line_number("main.cpp", "// break here") + +def _prepare_inferior(self): +self.build() +exe = self.getBuildArtifact("a.out") +self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + +# Break in main() after the variables are assigned values. +lldbutil.run_break_set_by_file_and_line( +self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True +) + +self.runCmd("run", RUN_SUCCEEDED) + +# The stop reason of the thread should be breakpoint. +self.expect( +"thread list", +STOPPED_DUE_TO_BREAKPOINT, +substrs=["stopped", "stop reason = breakpoint"], +) + +# The breakpoint should have a hit count of 1. +lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1) + +# Avoid the expression evaluator, as it can allocate allocate memory +# inside the holes we've deliberately left empty. +self.memory = self.frame().FindVariable("mem_with_holes").GetValueAsUnsigned() +self.pagesize = self.frame().FindVariable("pagesize").GetValueAsUnsigned() +positions = self.frame().FindVariable("positions") +self.positions = [ +positions.GetChildAtIndex(i).GetValueAsUnsigned() +for i in range(positions.GetNumChildren()) +] +self.assertEqual(len(self.positions), 5) + +@expectedFailureWindows +def test_memory_read(self): +self._prepare_inferior() + +error = lldb.SBError() +content = self.process().ReadMemory(self.memory, 2 * self.pagesize, error) +self.assertEqual(len(content), self.pagesize) +self.assertEqual(content[0:7], b"needle\0") +self.assertTrue(error.Fail()) +self.assertEqual( +f"memory read failed for {self.memory+self.pagesize:#x}", error.GetCString() +) labath wrote: I guess this kind of error behavior can be useful in some situations (you get the memory that can be read *and* the error for the part that cannot), but I've found it very counterintuitive to use. I'd definitely be open to changing that (returning an error only if we didn't read anything). https://github.com/llvm/llvm-project/pull/106532 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/linux] Make truncated reads work (PR #106532)
@@ -2526,28 +2526,16 @@ GDBRemoteCommunicationServerLLGS::Handle_memory_read( size_t bytes_read = 0; Status error = m_current_process->ReadMemoryWithoutTrap( read_addr, &buf[0], byte_count, bytes_read); - if (error.Fail()) { -LLDB_LOGF(log, - "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64 - " mem 0x%" PRIx64 ": failed to read. Error: %s", - __FUNCTION__, m_current_process->GetID(), read_addr, - error.AsCString()); + LLDB_LOG(log, "ReadMemoryWithoutTrap({0}) read {1}/{2} bytes (error: {3})", + read_addr, byte_count, bytes_read, error); + if (bytes_read == 0) labath wrote: This was changed to not assume that an error means nothing was read. https://github.com/llvm/llvm-project/pull/106532 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/linux] Make truncated reads work (PR #106532)
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/106532 >From 610757ced98139d3d10451dcca195692b0c2d832 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 29 Aug 2024 12:26:01 +0200 Subject: [PATCH 1/2] [lldb/linux] Make truncated reads work Previously, we were returning an error if we couldn't read the whole region. This doesn't matter most of the time, because lldb caches memory reads, and in that process it aligns them to cache line boundaries. As (LLDB) cache lines are smaller than pages, the reads are unlikely to cross page boundaries. Nonetheless, this can cause a problem for large reads (which bypass the cache), where we're unable to read anything even if just a single byte of the memory is unreadable. This patch fixes the lldb-server to do that, and also changes the linux implementation, to reuse any partial results it got from the process_vm_readv call (to avoid having to re-read everything again using ptrace, only to find that it stopped at the same place). This matches debugserver behavior. It is also consistent with the gdb remote protocol documentation, but -- notably -- not with actual gdbserver behavior (which returns errors instead of partial results). We filed a [clarification bug](https://sourceware.org/bugzilla/show_bug.cgi?id=24751) several years ago. Though we did not really reach a conclusion there, I think this is the most logical behavior. The associated test does not currently pass on windows, because the windows memory read APIs don't support partial reads (I have a WIP patch to work around that). --- .../Process/Linux/NativeProcessLinux.cpp | 41 - .../GDBRemoteCommunicationServerLLGS.cpp | 20 + .../API/functionalities/memory/holes/Makefile | 3 + .../memory/holes/TestMemoryHoles.py | 63 ++ .../API/functionalities/memory/holes/main.cpp | 87 +++ 5 files changed, 176 insertions(+), 38 deletions(-) create mode 100644 lldb/test/API/functionalities/memory/holes/Makefile create mode 100644 lldb/test/API/functionalities/memory/holes/TestMemoryHoles.py create mode 100644 lldb/test/API/functionalities/memory/holes/main.cpp diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index cb95da9fc72363..1e2e3a80b18bf6 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -1641,6 +1641,10 @@ NativeProcessLinux::GetSoftwareBreakpointTrapOpcode(size_t size_hint) { Status NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) { + Log *log = GetLog(POSIXLog::Memory); + LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size); + + bytes_read = 0; if (ProcessVmReadvSupported()) { // The process_vm_readv path is about 50 times faster than ptrace api. We // want to use this syscall if it is supported. @@ -1651,32 +1655,29 @@ Status NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size, remote_iov.iov_base = reinterpret_cast(addr); remote_iov.iov_len = size; -bytes_read = process_vm_readv(GetCurrentThreadID(), &local_iov, 1, - &remote_iov, 1, 0); -const bool success = bytes_read == size; +ssize_t read_result = process_vm_readv(GetCurrentThreadID(), &local_iov, 1, + &remote_iov, 1, 0); +int error = 0; +if (read_result < 0) + error = errno; +else + bytes_read = read_result; -Log *log = GetLog(POSIXLog::Process); LLDB_LOG(log, - "using process_vm_readv to read {0} bytes from inferior " - "address {1:x}: {2}", - size, addr, success ? "Success" : llvm::sys::StrError(errno)); - -if (success) - return Status(); -// else the call failed for some reason, let's retry the read using ptrace -// api. + "process_vm_readv({0}, [iovec({1}, {2})], [iovec({3:x}, {2})], 1, " + "0) => {4} ({5})", + GetCurrentThreadID(), buf, size, addr, read_result, + error > 0 ? llvm::sys::StrError(errno) : "sucesss"); } unsigned char *dst = static_cast(buf); size_t remainder; long data; - Log *log = GetLog(POSIXLog::Memory); - LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size); - - for (bytes_read = 0; bytes_read < size; bytes_read += remainder) { + for (; bytes_read < size; bytes_read += remainder) { Status error = NativeProcessLinux::PtraceWrapper( -PTRACE_PEEKDATA, GetCurrentThreadID(), (void *)addr, nullptr, 0, &data); +PTRACE_PEEKDATA, GetCurrentThreadID(), +reinterpret_cast(addr + bytes_read), nullptr, 0, &data); if (error.Fail()) return error; @@ -1684,11 +1685,7 @@ Status NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf,
[Lldb-commits] [lldb] [lldb] Fix and speedup the `memory find` command (PR #104193)
labath wrote: The linux read fix is in #106532. https://github.com/llvm/llvm-project/pull/104193 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b2a820f - [lldb][lldb-dap][test] Enable Launch tests
Author: David Spickett Date: 2024-08-29T11:55:35Z New Revision: b2a820faea960e99123f309d6a7bccb3cd1bcc12 URL: https://github.com/llvm/llvm-project/commit/b2a820faea960e99123f309d6a7bccb3cd1bcc12 DIFF: https://github.com/llvm/llvm-project/commit/b2a820faea960e99123f309d6a7bccb3cd1bcc12.diff LOG: [lldb][lldb-dap][test] Enable Launch tests Add Windows include equivalents for includes and shell command. Added: Modified: lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py lldb/test/API/tools/lldb-dap/launch/main.c Removed: diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py index dd47a2db8709b9..a16f2da3c4df71 100644 --- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py +++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py @@ -9,10 +9,10 @@ import lldbdap_testcase import time import os +import re class TestDAP_launch(lldbdap_testcase.DAPTestCaseBase): -@skipIfWindows def test_default(self): """ Tests the default launch of a simple program. No arguments, @@ -27,7 +27,6 @@ def test_default(self): lines = output.splitlines() self.assertIn(program, lines[0], "make sure program path is in first argument") -@skipIfWindows def test_termination(self): """ Tests the correct termination of lldb-dap upon a 'disconnect' @@ -47,7 +46,6 @@ def test_termination(self): # Check the return code self.assertEqual(self.dap_server.process.poll(), 0) -@skipIfWindows def test_stopOnEntry(self): """ Tests the default launch of a simple program that stops at the @@ -66,7 +64,6 @@ def test_stopOnEntry(self): reason, "breakpoint", 'verify stop isn\'t "main" breakpoint' ) -@skipIfWindows def test_cwd(self): """ Tests the default launch of a simple program with a current working @@ -92,7 +89,6 @@ def test_cwd(self): ) self.assertTrue(found, "verified program working directory") -@skipIfWindows def test_debuggerRoot(self): """ Tests the "debuggerRoot" will change the working directory of @@ -100,7 +96,10 @@ def test_debuggerRoot(self): """ program = self.getBuildArtifact("a.out") program_parent_dir = os.path.realpath(os.path.dirname(os.path.dirname(program))) -commands = ["platform shell echo cwd = $PWD"] + +var = "%cd%" if lldbplatformutil.getHostPlatform() == "windows" else "$PWD" +commands = [f"platform shell echo cwd = {var}"] + self.build_and_launch( program, debuggerRoot=program_parent_dir, initCommands=commands ) @@ -114,14 +113,13 @@ def test_debuggerRoot(self): found = True self.assertEqual( program_parent_dir, -line[len(prefix) :], +line.strip()[len(prefix) :], "lldb-dap working dir '%s' == '%s'" -% (program_parent_dir, line[6:]), +% (program_parent_dir, line[len(prefix) :]), ) self.assertTrue(found, "verified lldb-dap working directory") self.continue_to_exit() -@skipIfWindows def test_sourcePath(self): """ Tests the "sourcePath" will set the target.source-map. @@ -146,7 +144,6 @@ def test_sourcePath(self): self.assertTrue(found, 'found "sourcePath" in console output') self.continue_to_exit() -@skipIfWindows def test_disableSTDIO(self): """ Tests the default launch of a simple program with STDIO disabled. @@ -182,7 +179,6 @@ def test_shellExpandArguments_enabled(self): quote_path, line, 'verify "%s" expanded to "%s"' % (glob, program) ) -@skipIfWindows def test_shellExpandArguments_disabled(self): """ Tests the default launch of a simple program with shell expansion @@ -204,7 +200,6 @@ def test_shellExpandArguments_disabled(self): quote_path, line, 'verify "%s" stayed to "%s"' % (glob, glob) ) -@skipIfWindows def test_args(self): """ Tests launch of a simple program with arguments @@ -229,7 +224,6 @@ def test_args(self): 'arg[%i] "%s" not in "%s"' % (i + 1, quoted_arg, lines[i]), ) -@skipIfWindows def test_environment(self): """ Tests launch of a simple program with environment variables @@ -258,7 +252,6 @@ def test_environment(self): found, '"%s" must exist in program environment (%s)' % (var, lines) ) -@skipIfWindows @skipIf( archs=["arm", "aarch64"] ) # failed run https://lab.llvm.org
[Lldb-commits] [lldb] [lldb] Better matching of types in anonymous namespaces (PR #102111)
labath wrote: Any more thoughts on this, @clayborg ? https://github.com/llvm/llvm-project/pull/102111 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add armv7a and armv8a ArchSpecs (PR #106433)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/106433 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add armv7a and armv8a ArchSpecs (PR #106433)
https://github.com/DavidSpickett approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/106433 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Updated TCPSocket to listen multiple ports on the same single thread (PR #104797)
slydiman wrote: @labath What exactly are you proposing? We need some blocking method Accept() which can wait for connections from few ports. The current implementation of TCPSocket class already contains this functionality (a list of listening sockets). It is possible to create a static method TCPSocket::Accept(MainLoop &loop, std::vector &listen_sockets) and a lot of helpers to initialise and store listen sockets using the same code from the existing TCPSocket::Listen(). It looks ugly. What is the profit from this work? It is necessary to spend months for this huge refactoring. Where will it be used except Acceptor.cpp? The class Acceptor is used only in lldb-server. Then the best approach is to implement the full functional of Listen() and Accept() in the Acceptor.cpp using native sockets and without TCPSocket at all. It will contain 90% of the existing code from TCPSocket. Is it ok? https://github.com/llvm/llvm-project/pull/104797 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Improve toolchain detection in Makefile.rules (PR #102185)
https://github.com/dzhidzhoev updated https://github.com/llvm/llvm-project/pull/102185 >From e40ca68a934d0595ebc6c07010a4f6a814fa026f Mon Sep 17 00:00:00 2001 From: Vladislav Dzhidzhoev Date: Sat, 27 Jul 2024 02:39:32 +0200 Subject: [PATCH 1/6] [lldb][test] Improve toolchain detection in Makefile.rules This fix is based on a problem with cxx_compiler and cxx_linker macros on Windows. There was an issue with compiler detection in paths containing "icc". In such case, Makefile.rules thought it was provided with icc compiler. To solve that, utilities detection has been rewritten in Python. The last element of compiler's path is separated, taking into account platform path delimiter, and compiler type is extracted, with regard of possible cross-toolchain prefix. Paths for additional tools, like OBJCOPY, are initialized with tools built with LLVM if USE_LLVM_TOOLS is on, to achieve better portability for Windows. Quotes from paths are removed in Makefile.rules, that may be added when arguments are passed from Python to make. --- .../Python/lldbsuite/test/builders/builder.py | 114 +- .../Python/lldbsuite/test/make/Makefile.rules | 103 +--- .../breakpoint/breakpoint_ids/Makefile| 2 +- .../breakpoint/breakpoint_locations/Makefile | 2 +- .../consecutive_breakpoints/Makefile | 2 +- .../functionalities/breakpoint/cpp/Makefile | 2 +- .../dummy_target_breakpoints/Makefile | 2 +- .../require_hw_breakpoints/Makefile | 2 +- .../breakpoint/step_over_breakpoint/Makefile | 2 +- .../thread_plan_user_breakpoint/Makefile | 2 +- .../ObjCDataFormatterTestCase.py | 4 +- .../TestNSDictionarySynthetic.py | 4 +- .../nssetsynth/TestNSSetSynthetic.py | 4 +- .../poarray/TestPrintObjectArray.py | 4 +- .../functionalities/inline-stepping/Makefile | 2 +- .../postmortem/minidump-new/makefile.txt | 1 + .../lang/objc/orderedset/TestOrderedSet.py| 4 +- .../TestObjCSingleEntryDictionary.py | 4 +- lldb/test/API/macosx/macCatalyst/Makefile | 1 + .../macCatalystAppMacOSFramework/Makefile | 1 + .../macosx/simulator/TestSimulatorPlatform.py | 4 +- .../API/python_api/frame/inlines/Makefile | 2 +- .../lldb-server/TestAppleSimulatorOSType.py | 4 +- 23 files changed, 168 insertions(+), 104 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py b/lldb/packages/Python/lldbsuite/test/builders/builder.py index 4ea9a86c1d5fc9..ca91684ca065d6 100644 --- a/lldb/packages/Python/lldbsuite/test/builders/builder.py +++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py @@ -1,10 +1,12 @@ import os +import pathlib import platform import subprocess import sys import itertools import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbplatformutil as lldbplatformutil import lldbsuite.test.lldbutil as lldbutil from lldbsuite.test import configuration from lldbsuite.test_event import build_exception @@ -96,16 +98,120 @@ def getArchSpec(self, architecture): """ return ["ARCH=" + architecture] if architecture else [] -def getCCSpec(self, compiler): +def getToolchainSpec(self, compiler): """ -Helper function to return the key-value string to specify the compiler +Helper function to return the key-value strings to specify the toolchain used for the make system. """ cc = compiler if compiler else None if not cc and configuration.compiler: cc = configuration.compiler + if cc: -return ['CC="%s"' % cc] +exe_ext = "" +if lldbplatformutil.getHostPlatform() == "windows": +exe_ext = ".exe" + +cc = cc.strip() +cc_path = pathlib.Path(cc) +cc = cc_path.as_posix() + +# We can get CC compiler string in the following formats: +# [] - such as 'xrun clang', 'xrun /usr/bin/clang' & etc +# +# Where could contain the following parts: +# [.] - sucn as 'clang', 'clang.exe' ('clamg-cl.exe'?) +# -[.] - such as 'armv7-linux-gnueabi-gcc' +# /[.]- such as '/usr/bin/clang', 'c:\path\to\compiler\clang,exe' +# /-[.]- such as '/usr/bin/clang', 'c:\path\to\compiler\clang,exe' + +cc_ext = cc_path.suffix +# Compiler name without extension +cc_name = cc_path.stem.split(" ")[-1] + +# A kind of compiler (canonical name): clang, gcc, cc & etc. +cc_type = cc_name +# A triple prefix of compiler name: gcc +cc_prefix = "" +if not "clang-cl" in cc_name and not "llvm-gcc" in cc_name: +cc_name_parts = cc_name.split("-") +cc_type = cc_name_parts[-1
[Lldb-commits] [lldb] [lldb][test] Improve toolchain detection in Makefile.rules (PR #102185)
@@ -213,7 +229,7 @@ endif LIMIT_DEBUG_INFO_FLAGS = NO_LIMIT_DEBUG_INFO_FLAGS = MODULE_DEBUG_INFO_FLAGS = -ifneq (,$(findstring clang,$(CC))) +ifeq ($(CCC), clang) dzhidzhoev wrote: Compiler type https://github.com/llvm/llvm-project/pull/102185 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Improve toolchain detection in Makefile.rules (PR #102185)
@@ -96,16 +98,120 @@ def getArchSpec(self, architecture): """ return ["ARCH=" + architecture] if architecture else [] -def getCCSpec(self, compiler): +def getToolchainSpec(self, compiler): """ -Helper function to return the key-value string to specify the compiler +Helper function to return the key-value strings to specify the toolchain used for the make system. """ cc = compiler if compiler else None if not cc and configuration.compiler: cc = configuration.compiler + if cc: -return ['CC="%s"' % cc] +exe_ext = "" +if lldbplatformutil.getHostPlatform() == "windows": +exe_ext = ".exe" + +cc = cc.strip() +cc_path = pathlib.Path(cc) +cc = cc_path.as_posix() + +# We can get CC compiler string in the following formats: +# [] - such as 'xrun clang', 'xrun /usr/bin/clang' & etc +# +# Where could contain the following parts: +# [.] - sucn as 'clang', 'clang.exe' ('clamg-cl.exe'?) +# -[.] - such as 'armv7-linux-gnueabi-gcc' +# /[.]- such as '/usr/bin/clang', 'c:\path\to\compiler\clang,exe' +# /-[.]- such as '/usr/bin/clang', 'c:\path\to\compiler\clang,exe' + +cc_ext = cc_path.suffix +# Compiler name without extension +cc_name = cc_path.stem.split(" ")[-1] + +# A kind of compiler (canonical name): clang, gcc, cc & etc. +cc_type = cc_name +# A triple prefix of compiler name: gcc +cc_prefix = "" +if not "clang-cl" in cc_name and not "llvm-gcc" in cc_name: +cc_name_parts = cc_name.split("-") +cc_type = cc_name_parts[-1] +if len(cc_name_parts) > 1: +cc_prefix = "-".join(cc_name_parts[:-1]) + "-" + +# A kind of C++ compiler. +cxx_types = { +"icc": "icpc", +"llvm-gcc": "llvm-g++", +"gcc": "g++", +"cc": "c++", +"clang": "clang++", +} +cxx_type = cxx_types.get(cc_type, cc_type) + +cc_dir = cc_path.parent + +def getLlvmUtil(util_name): +llvm_tools_dir = os.getenv("LLVM_TOOLS_DIR", cc_dir.as_posix()) +return llvm_tools_dir + "/" + util_name + exe_ext dzhidzhoev wrote: Fixed https://github.com/llvm/llvm-project/pull/102185 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Improve toolchain detection in Makefile.rules (PR #102185)
@@ -96,16 +98,120 @@ def getArchSpec(self, architecture): """ return ["ARCH=" + architecture] if architecture else [] -def getCCSpec(self, compiler): +def getToolchainSpec(self, compiler): """ -Helper function to return the key-value string to specify the compiler +Helper function to return the key-value strings to specify the toolchain used for the make system. """ cc = compiler if compiler else None if not cc and configuration.compiler: cc = configuration.compiler + if cc: -return ['CC="%s"' % cc] +exe_ext = "" +if lldbplatformutil.getHostPlatform() == "windows": +exe_ext = ".exe" + +cc = cc.strip() +cc_path = pathlib.Path(cc) +cc = cc_path.as_posix() dzhidzhoev wrote: The idea in Makefile.rules was to unify path separators to process them. Indeed, we don't need that here. https://github.com/llvm/llvm-project/pull/102185 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [compiler-rt] [libcxx] [lldb] [llvm] Rename Sanitizer Coverage => Coverage Sanitizer (PR #106505)
@@ -257,7 +257,7 @@ General purpose options A semicolon list of arguments to pass when running the libc++ benchmarks using the ``check-cxx-benchmarks`` rule. By default we run the benchmarks for a very short amount of time, - since the primary use of ``check-cxx-benchmarks`` is to get test and sanitizer coverage, not to + since the primary use of ``check-cxx-benchmarks`` is to get test and coverage sanitizer, not to ldionne wrote: This change is wrong. This documentation relates to "coverage for sanitizers", not a specific kind of "sanitizer for coverage". https://github.com/llvm/llvm-project/pull/106505 ___ 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)
https://github.com/dlav-sc updated https://github.com/llvm/llvm-project/pull/99336 >From b7f51237438285b1be922ae754618b8c6b0b0ea3 Mon Sep 17 00:00:00 2001 From: Daniil Avdeev Date: Thu, 11 Jul 2024 11:21:36 + Subject: [PATCH 1/6] [lldb][RISCV] add jitted function calls to ABI Function calls support in LLDB expressions for RISCV: 1 of 6 Augments corresponding functionality to RISCV ABI, which allows to jit lldb expressions and thus make function calls inside them. Only function calls with integer and void function arguments and return value are supported. --- .../Plugins/ABI/RISCV/ABISysV_riscv.cpp | 89 +-- lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.h | 3 + 2 files changed, 85 insertions(+), 7 deletions(-) diff --git a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp index 6395f5bb5bd9b0..f3edee1dd6dc14 100644 --- a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp +++ b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp @@ -10,7 +10,9 @@ #include #include +#include +#include "llvm/ADT/STLExtras.h" #include "llvm/IR/DerivedTypes.h" #include "lldb/Core/PluginManager.h" @@ -19,6 +21,7 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/RegisterValue.h" #define DEFINE_REG_NAME(reg_num) ConstString(#reg_num).GetCString() @@ -163,11 +166,83 @@ TotalArgsSizeInWords(bool is_rv64, return total_size; } +static bool UpdateRegister(RegisterContext *reg_ctx, + const lldb::RegisterKind reg_kind, + const uint32_t reg_num, const addr_t value) { + Log *log = GetLog(LLDBLog::Expressions); + + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(reg_kind, reg_num); + + LLDB_LOG(log, "Writing %s: 0x%" PRIx64, reg_info->name, + static_cast(value)); + if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, value)) { +LLDB_LOG(log, "Writing %s: failed", reg_info->name); +return false; + } + return true; +} + +static void LogInitInfo(Log *log, const Thread &thread, addr_t sp, +addr_t func_addr, addr_t return_addr, +const llvm::ArrayRef args) { + assert(log); + std::stringstream ss; + ss << "ABISysV_riscv::PrepareTrivialCall" + << " (tid = 0x%" << std::hex << thread.GetID() << ", sp = 0x%" << sp + << ", func_addr = 0x%" << func_addr << ", return_addr = 0x%" + << return_addr; + + for (auto &&[idx, arg] : enumerate(args)) +ss << ", arg" << std::dec << idx << " = 0x%" << std::hex << arg; + ss << ")"; + log->PutString(ss.str()); +} + bool ABISysV_riscv::PrepareTrivialCall(Thread &thread, addr_t sp, addr_t func_addr, addr_t return_addr, llvm::ArrayRef args) const { - // TODO: Implement - return false; + Log *log = GetLog(LLDBLog::Expressions); + if (log) +LogInitInfo(log, thread, sp, func_addr, return_addr, args); + + const auto reg_ctx_sp = thread.GetRegisterContext(); + if (!reg_ctx_sp) { +LLDB_LOG(log, "Failed to get RegisterContext"); +return false; + } + + if (args.size() > s_regs_for_args_count) { +LLDB_LOG(log, "Function has %lu arguments, but only %lu are allowed!", + args.size(), s_regs_for_args_count); +return false; + } + + // Write arguments to registers + for (auto &&[idx, arg] : enumerate(args)) { +const RegisterInfo *reg_info = reg_ctx_sp->GetRegisterInfo( +eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + idx); +LLDB_LOG(log, "About to write arg%lu (0x%" PRIx64 ") into %s", idx, arg, + reg_info->name); + +if (!reg_ctx_sp->WriteRegisterFromUnsigned(reg_info, arg)) { + LLDB_LOG(log, "Failed to write arg%lu (0x%" PRIx64 ") into %s", idx, arg, + reg_info->name); + return false; +} + } + + if (!UpdateRegister(reg_ctx_sp.get(), eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_PC, func_addr)) +return false; + if (!UpdateRegister(reg_ctx_sp.get(), eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_SP, sp)) +return false; + if (!UpdateRegister(reg_ctx_sp.get(), eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_RA, return_addr)) +return false; + + LLDB_LOG(log, "ABISysV_riscv::%s: success", __func__); + return true; } bool ABISysV_riscv::PrepareTrivialCall( @@ -221,14 +296,14 @@ bool ABISysV_riscv::PrepareTrivialCall( assert(prototype.getFunctionNumParams() == args.size()); const size_t num_args = args.size(); - const size_t regs_for_args_count = 8U; const size_t num_args_in_regs = - num_args > regs_for_args_count ? regs_for_args_count : num_args; + num_args > s_regs_for_args_count ? s_regs_for_args_count : num_args; // Number of arguments passed on stack. size_t args_size = TotalArgsSizeInW
[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)
https://github.com/andrurogerz edited https://github.com/llvm/llvm-project/pull/106443 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Improve toolchain detection in Makefile.rules (PR #102185)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/102185 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Improve toolchain detection in Makefile.rules (PR #102185)
@@ -96,16 +98,120 @@ def getArchSpec(self, architecture): """ return ["ARCH=" + architecture] if architecture else [] -def getCCSpec(self, compiler): +def getToolchainSpec(self, compiler): """ -Helper function to return the key-value string to specify the compiler +Helper function to return the key-value strings to specify the toolchain used for the make system. """ cc = compiler if compiler else None if not cc and configuration.compiler: cc = configuration.compiler + if cc: -return ['CC="%s"' % cc] +exe_ext = "" +if lldbplatformutil.getHostPlatform() == "windows": +exe_ext = ".exe" + +cc = cc.strip() +cc_path = pathlib.Path(cc) +cc = cc_path.as_posix() + +# We can get CC compiler string in the following formats: +# [] - such as 'xrun clang', 'xrun /usr/bin/clang' & etc +# +# Where could contain the following parts: +# [.] - sucn as 'clang', 'clang.exe' ('clamg-cl.exe'?) +# -[.] - such as 'armv7-linux-gnueabi-gcc' +# /[.]- such as '/usr/bin/clang', 'c:\path\to\compiler\clang,exe' +# /-[.]- such as '/usr/bin/clang', 'c:\path\to\compiler\clang,exe' + +cc_ext = cc_path.suffix +# Compiler name without extension +cc_name = cc_path.stem.split(" ")[-1] + +# A kind of compiler (canonical name): clang, gcc, cc & etc. +cc_type = cc_name +# A triple prefix of compiler name: gcc +cc_prefix = "" +if not "clang-cl" in cc_name and not "llvm-gcc" in cc_name: +cc_name_parts = cc_name.split("-") +cc_type = cc_name_parts[-1] +if len(cc_name_parts) > 1: +cc_prefix = "-".join(cc_name_parts[:-1]) + "-" + +# A kind of C++ compiler. +cxx_types = { +"icc": "icpc", +"llvm-gcc": "llvm-g++", +"gcc": "g++", +"cc": "c++", +"clang": "clang++", +} +cxx_type = cxx_types.get(cc_type, cc_type) + +cc_dir = cc_path.parent + +def getLlvmUtil(util_name): +llvm_tools_dir = os.getenv("LLVM_TOOLS_DIR", cc_dir.as_posix()) +return llvm_tools_dir + "/" + util_name + exe_ext + +def getToolchainUtil(util_name): +return (cc_dir / (cc_prefix + util_name + cc_ext)).as_posix() + +cxx = getToolchainUtil(cxx_type) + +util_names = { +"OBJCOPY": "objcopy", +"STRIP": "objcopy", +"ARCHIVER": "ar", +"DWP": "dwp", +} +utils = [] + +# Note: LLVM_AR is currently required by API TestBSDArchives.py tests. +# Assembly a full path to llvm-ar for given LLVM_TOOLS_DIR; +# otherwise assume we have llvm-ar at the same place where is CC specified. +if not os.getenv("LLVM_AR"): +llvm_ar = getLlvmUtil("llvm-ar") +utils.extend(['LLVM_AR="%s"' % llvm_ar]) + +if not lldbplatformutil.platformIsDarwin(): +if os.getenv("USE_LLVM_TOOLS"): labath wrote: I'm still puzzled by this.. https://github.com/llvm/llvm-project/pull/102185 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Improve toolchain detection in Makefile.rules (PR #102185)
@@ -96,16 +98,119 @@ def getArchSpec(self, architecture): """ return ["ARCH=" + architecture] if architecture else [] -def getCCSpec(self, compiler): +def getToolchainSpec(self, compiler): """ -Helper function to return the key-value string to specify the compiler +Helper function to return the key-value strings to specify the toolchain used for the make system. """ cc = compiler if compiler else None if not cc and configuration.compiler: cc = configuration.compiler + if cc: -return ['CC="%s"' % cc] +exe_ext = "" +if lldbplatformutil.getHostPlatform() == "windows": +exe_ext = ".exe" + +cc = cc.strip() +cc_path = pathlib.Path(cc) + +# We can get CC compiler string in the following formats: +# [] - such as 'xrun clang', 'xrun /usr/bin/clang' & etc +# +# Where could contain the following parts: +# [.] - sucn as 'clang', 'clang.exe' ('clang-cl.exe'?) +# -[.] - such as 'armv7-linux-gnueabi-gcc' +# /[.]- such as '/usr/bin/clang', 'c:\path\to\compiler\clang,exe' +# /-[.]- such as '/usr/bin/clang', 'c:\path\to\compiler\clang,exe' + +cc_ext = cc_path.suffix +# Compiler name without extension +cc_name = cc_path.stem.split(" ")[-1] + +# A kind of compiler (canonical name): clang, gcc, cc & etc. +cc_type = cc_name +# A triple prefix of compiler name: gcc +cc_prefix = "" +if not "clang-cl" in cc_name and not "llvm-gcc" in cc_name: +cc_name_parts = cc_name.split("-") +cc_type = cc_name_parts[-1] +if len(cc_name_parts) > 1: +cc_prefix = "-".join(cc_name_parts[:-1]) + "-" + +# A kind of C++ compiler. +cxx_types = { +"icc": "icpc", +"llvm-gcc": "llvm-g++", +"gcc": "g++", +"cc": "c++", +"clang": "clang++", +} +cxx_type = cxx_types.get(cc_type, cc_type) + +cc_dir = cc_path.parent + +def getLlvmUtil(util_name): +llvm_tools_dir = os.getenv("LLVM_TOOLS_DIR", cc_dir) +return os.path.join(llvm_tools_dir, util_name + exe_ext) + +def getToolchainUtil(util_name): +return cc_dir / (cc_prefix + util_name + cc_ext) + +cxx = getToolchainUtil(cxx_type) + +util_names = { +"OBJCOPY": "objcopy", +"STRIP": "objcopy", +"ARCHIVER": "ar", +"DWP": "dwp", +} +utils = [] + +# Note: LLVM_AR is currently required by API TestBSDArchives.py tests. +# Assembly a full path to llvm-ar for given LLVM_TOOLS_DIR; labath wrote: ```suggestion # Assemble a full path to llvm-ar for given LLVM_TOOLS_DIR; ``` https://github.com/llvm/llvm-project/pull/102185 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Improve toolchain detection in Makefile.rules (PR #102185)
https://github.com/labath commented: Looks pretty good now, but I still have some questions. https://github.com/llvm/llvm-project/pull/102185 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Improve toolchain detection in Makefile.rules (PR #102185)
@@ -213,7 +229,7 @@ endif LIMIT_DEBUG_INFO_FLAGS = NO_LIMIT_DEBUG_INFO_FLAGS = MODULE_DEBUG_INFO_FLAGS = -ifneq (,$(findstring clang,$(CC))) +ifeq ($(CCC), clang) labath wrote: So the last `C` stands for "type" ? :) Can we call it CC_TYPE/KIND (or similar) instead? It's not like we're using it that often... https://github.com/llvm/llvm-project/pull/102185 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Improve toolchain detection in Makefile.rules (PR #102185)
@@ -96,16 +98,119 @@ def getArchSpec(self, architecture): """ return ["ARCH=" + architecture] if architecture else [] -def getCCSpec(self, compiler): +def getToolchainSpec(self, compiler): """ -Helper function to return the key-value string to specify the compiler +Helper function to return the key-value strings to specify the toolchain used for the make system. """ cc = compiler if compiler else None if not cc and configuration.compiler: cc = configuration.compiler + if cc: labath wrote: ```suggestion if not cc: return [] ``` .. and then unindent the rest of the code https://github.com/llvm/llvm-project/pull/102185 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Improve toolchain detection in Makefile.rules (PR #102185)
@@ -96,16 +98,119 @@ def getArchSpec(self, architecture): """ return ["ARCH=" + architecture] if architecture else [] -def getCCSpec(self, compiler): +def getToolchainSpec(self, compiler): """ -Helper function to return the key-value string to specify the compiler +Helper function to return the key-value strings to specify the toolchain used for the make system. """ cc = compiler if compiler else None if not cc and configuration.compiler: cc = configuration.compiler + if cc: -return ['CC="%s"' % cc] +exe_ext = "" +if lldbplatformutil.getHostPlatform() == "windows": +exe_ext = ".exe" + +cc = cc.strip() +cc_path = pathlib.Path(cc) + +# We can get CC compiler string in the following formats: +# [] - such as 'xrun clang', 'xrun /usr/bin/clang' & etc +# +# Where could contain the following parts: +# [.] - sucn as 'clang', 'clang.exe' ('clang-cl.exe'?) +# -[.] - such as 'armv7-linux-gnueabi-gcc' +# /[.]- such as '/usr/bin/clang', 'c:\path\to\compiler\clang,exe' +# /-[.]- such as '/usr/bin/clang', 'c:\path\to\compiler\clang,exe' + +cc_ext = cc_path.suffix +# Compiler name without extension +cc_name = cc_path.stem.split(" ")[-1] + +# A kind of compiler (canonical name): clang, gcc, cc & etc. +cc_type = cc_name +# A triple prefix of compiler name: gcc +cc_prefix = "" +if not "clang-cl" in cc_name and not "llvm-gcc" in cc_name: +cc_name_parts = cc_name.split("-") +cc_type = cc_name_parts[-1] +if len(cc_name_parts) > 1: +cc_prefix = "-".join(cc_name_parts[:-1]) + "-" + +# A kind of C++ compiler. +cxx_types = { +"icc": "icpc", +"llvm-gcc": "llvm-g++", +"gcc": "g++", +"cc": "c++", +"clang": "clang++", +} +cxx_type = cxx_types.get(cc_type, cc_type) + +cc_dir = cc_path.parent + +def getLlvmUtil(util_name): +llvm_tools_dir = os.getenv("LLVM_TOOLS_DIR", cc_dir) +return os.path.join(llvm_tools_dir, util_name + exe_ext) + +def getToolchainUtil(util_name): +return cc_dir / (cc_prefix + util_name + cc_ext) + +cxx = getToolchainUtil(cxx_type) + +util_names = { +"OBJCOPY": "objcopy", +"STRIP": "objcopy", labath wrote: Can we get rid of this variable? I don't think it's very helpful. Even though `objcopy` supports (I think) all of the functionality of `strip`, their args are different, so I think this could be pretty confusing. https://github.com/llvm/llvm-project/pull/102185 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Inline expression evaluator error visualization (PR #106470)
@@ -2076,7 +2077,11 @@ bool CommandInterpreter::HandleCommand(const char *command_line, } ElapsedTime elapsed(execute_time); -cmd_obj->Execute(remainder.c_str(), result); +size_t nchar = real_original_command_string.find(remainder); +std::optional pos_in_cmd; +if (nchar != std::string::npos) + pos_in_cmd = nchar + GetDebugger().GetPrompt().size(); +cmd_obj->Execute(remainder.c_str(), pos_in_cmd, result); adrian-prantl wrote: I can (and I thought the same thing as I was making the change), but I want to make sure that's the right API design. Reducing the size of the patch isn't necessarily a priority for me. Do we think that hiding the parameter in the object is a better design? https://github.com/llvm/llvm-project/pull/106470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add Status::Detail to store expression evaluator diagnostics [… (PR #106442)
labath wrote: Not really (although this might work as well). What I meant was that, AIUI you're doing this so that you can plumb structured error information from one place (clang expression parser?) to another place (the thing which generates the expression errors -- I guess somewhere CommandObjectExpression?). That could be done by creating a (custom) llvm::Error in the first place, and consuming it in the second one *and* by making sure that all of the functions along that path don't lose this information by converting the error to a lldb_private::Status. I haven't looked at how hard much changes would that require, but I'm hoping that will be a single relatively well defined path that can be ported with reasonable effort. Even if there's e.g. a virtual function somewhere along the path, we don't necessarily have to port all implementations of that function immediately. We could just port the ones we need, and provide a shim so that the other implementations can remain unchanged... https://github.com/llvm/llvm-project/pull/106442 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)
https://github.com/andrurogerz updated https://github.com/llvm/llvm-project/pull/106443 >From 476a0109d5889a80d90ae484a553cce058a6e5ce Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Mon, 26 Aug 2024 17:42:35 -0700 Subject: [PATCH 1/4] [android] get lldb tests working against newer Android NDKs Android introduced a unified tools layout in NDK r19 (2019) and removed the old layout in r22 (2021). Running lldb tests with NDK r22 or newer fails when compiling the test inferiors. This change updates `Android.rules` to match the newer unified tools structure introduced in NDK r19, which is described in more detail at https://github.com/android/ndk/issues/780. NOTE: After this change, ONLY NDK r19c and later can be used when running the lldb tests. The pre-2019 NDK structure is no longer supported. --- .../Python/lldbsuite/test/make/Android.rules | 78 ++- 1 file changed, 23 insertions(+), 55 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/make/Android.rules b/lldb/packages/Python/lldbsuite/test/make/Android.rules index cd7d8ae74d6bf3..518a90a5ba84d7 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Android.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Android.rules @@ -1,81 +1,49 @@ NDK_ROOT := $(shell dirname $(CC))/../../../../.. -ifeq "$(findstring 64, $(ARCH))" "64" - # lowest 64-bit API level - API_LEVEL := 21 -else ifeq "$(ARCH)" "i386" - # clone(2) declaration is present only since this api level - API_LEVEL := 17 +ifeq "$(HOST_OS)" "Linux" + HOST_TAG := linux-x86_64 +else ifeq "$(HOST_OS)" "Darwin" + HOST_TAG := darwin-x86_64 else - # lowest supported 32-bit API level - API_LEVEL := 16 + HOST_TAG := windows-x86_64 endif ifeq "$(ARCH)" "arm" - SYSROOT_ARCH := arm - STL_ARCH := armeabi-v7a TRIPLE := armv7-none-linux-androideabi ARCH_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm else ifeq "$(ARCH)" "aarch64" - SYSROOT_ARCH := arm64 - STL_ARCH := arm64-v8a TRIPLE := aarch64-none-linux-android else ifeq "$(ARCH)" "i386" - SYSROOT_ARCH := x86 - STL_ARCH := x86 TRIPLE := i686-none-linux-android else - SYSROOT_ARCH := $(ARCH) - STL_ARCH := $(ARCH) TRIPLE := $(ARCH)-none-linux-android endif -ifeq "$(findstring 86,$(ARCH))" "86" - TOOLCHAIN_DIR := $(STL_ARCH)-4.9 -else ifeq "$(ARCH)" "arm" - TOOLCHAIN_DIR := arm-linux-androideabi-4.9 -else - TOOLCHAIN_DIR := $(subst -none,,$(TRIPLE))-4.9 -endif +TOOLCHAIN_SYSROOT := $(NDK_ROOT)/toolchains/llvm/prebuilt/$(HOST_TAG)/sysroot -ifeq "$(ARCH)" "arm" - TOOL_PREFIX := arm-linux-androideabi -else - TOOL_PREFIX := $(subst -none,,$(TRIPLE)) -endif +# lowest 64-bit API level +API_LEVEL := 21 -ifeq "$(HOST_OS)" "Linux" - HOST_TAG := linux-x86_64 -else ifeq "$(HOST_OS)" "Darwin" - HOST_TAG := darwin-x86_64 +ifeq "$(ARCH)" "arm" + ARCH_DIR := arm-linux-androideabi else - HOST_TAG := windows-x86_64 + ARCH_DIR := $(subst -none,,$(TRIPLE)) endif -GCC_TOOLCHAIN = $(NDK_ROOT)/toolchains/$(TOOLCHAIN_DIR)/prebuilt/$(HOST_TAG) - -OBJCOPY ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-objcopy -ARCHIVER ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-ar - -ifeq "$(findstring clang,$(CC))" "clang" - ARCH_CFLAGS += -target $(TRIPLE) --gcc-toolchain=$(GCC_TOOLCHAIN) - ARCH_LDFLAGS += -target $(TRIPLE) --gcc-toolchain=$(GCC_TOOLCHAIN) -endif - -ARCH_CFLAGS += --sysroot=$(NDK_ROOT)/sysroot \ - -isystem $(NDK_ROOT)/sysroot/usr/include/$(TOOL_PREFIX) \ - -D__ANDROID_API__=$(API_LEVEL) \ - -isystem $(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH)/usr/include - -ARCH_LDFLAGS += --sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) -lm +ARCH_CFLAGS += \ + --target=$(TRIPLE) \ + --sysroot=$(TOOLCHAIN_SYSROOT) \ + -D __ANDROID_API__=$(API_LEVEL) \ ARCH_CXXFLAGS += \ - -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/include \ - -isystem $(NDK_ROOT)/sources/android/support/include \ - -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi/include + -isystem $(TOOLCHAIN_SYSROOT)/usr/include/c++/v1 \ ARCH_LDFLAGS += \ - -L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \ - $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++_static.a \ + --target=$(TRIPLE) \ + --sysroot=$(TOOLCHAIN_SYSROOT) \ + --prefix=$(TOOLCHAIN_SYSROOT)/usr/lib/$(ARCH_DIR)/$(API_LEVEL) \ + --library-directory=$(TOOLCHAIN_SYSROOT)/usr/lib/$(ARCH_DIR)/$(API_LEVEL) \ + $(TOOLCHAIN_SYSROOT)/usr/lib/$(ARCH_DIR)/libc++_static.a \ + -lm \ -lc++abi \ - -nostdlib++ + -nostdlib++ \ >From 14064c39f8c53bcdcf3f7ace7455aa3a4b9bca28 Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Wed, 28 Aug 2024 12:08:10 -0700 Subject: [PATCH 2/4] [android] explicitly fail inferior
[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)
https://github.com/andrurogerz edited https://github.com/llvm/llvm-project/pull/106443 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add Status::Detail to store expression evaluator diagnostics [… (PR #106442)
adrian-prantl wrote: > Not really (although this might work as well). What I meant was that, AIUI > you're doing this so that you can plumb structured error information from one > place (clang expression parser?) to another place (the thing which generates > the expression errors -- I guess somewhere CommandObjectExpression?). Yes, just that it's a generalized data structure for all expression parser plugins. > That could be done by creating a (custom) llvm::Error in the first place, and > consuming it in the second one _and_ by making sure that all of the functions > along that path don't lose this information by converting the error to a > lldb_private::Status. This would only work if Status actually stored an error, like I outlined above. The conversion from structured error into text needs to happen at the UI layer. For example, because only it knows indentation and coloring. Oh.. you mean converting the entire path from the expression evaluator to CommandObject from Status to llvm::Error! Yes. That would work. Since I have a few hours today, I'm going to attempt what I outlined above and then later change the APIs from Status to Expected. https://github.com/llvm/llvm-project/pull/106442 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0a00d32 - [lldb] Add armv7a and armv8a ArchSpecs (#106433)
Author: Jordan R AW Date: 2024-08-29T10:16:17-07:00 New Revision: 0a00d32c5f88fce89006dcde6e235bc77d7b495e URL: https://github.com/llvm/llvm-project/commit/0a00d32c5f88fce89006dcde6e235bc77d7b495e DIFF: https://github.com/llvm/llvm-project/commit/0a00d32c5f88fce89006dcde6e235bc77d7b495e.diff LOG: [lldb] Add armv7a and armv8a ArchSpecs (#106433) armv7a and armv8a are common names for the application subarch for arm. These names in particular are used in ChromeOS, Android, and a few other known applications. In ChromeOS, we encountered a bug where armv7a arch was not recognised and segfaulted when starting an executable on an arm32 device. Google Issue Tracker: https://issuetracker.google.com/361414339 Added: Modified: lldb/include/lldb/Utility/ArchSpec.h lldb/source/Utility/ArchSpec.cpp Removed: diff --git a/lldb/include/lldb/Utility/ArchSpec.h b/lldb/include/lldb/Utility/ArchSpec.h index 50830b889b9115..5990f984b09e2d 100644 --- a/lldb/include/lldb/Utility/ArchSpec.h +++ b/lldb/include/lldb/Utility/ArchSpec.h @@ -123,6 +123,7 @@ class ArchSpec { eCore_arm_armv6, eCore_arm_armv6m, eCore_arm_armv7, +eCore_arm_armv7a, eCore_arm_armv7l, eCore_arm_armv7f, eCore_arm_armv7s, @@ -145,6 +146,7 @@ class ArchSpec { eCore_thumbv7em, eCore_arm_arm64, eCore_arm_armv8, +eCore_arm_armv8a, eCore_arm_armv8l, eCore_arm_arm64e, eCore_arm_arm64_32, diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp index 4fd1a800023ce3..85bb85044ec156 100644 --- a/lldb/source/Utility/ArchSpec.cpp +++ b/lldb/source/Utility/ArchSpec.cpp @@ -60,6 +60,8 @@ static const CoreDefinition g_core_definitions[] = { "armv6m"}, {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7, "armv7"}, +{eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7a, + "armv7a"}, {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7l, "armv7l"}, {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7f, @@ -102,6 +104,8 @@ static const CoreDefinition g_core_definitions[] = { ArchSpec::eCore_arm_arm64, "arm64"}, {eByteOrderLittle, 8, 4, 4, llvm::Triple::aarch64, ArchSpec::eCore_arm_armv8, "armv8"}, +{eByteOrderLittle, 8, 4, 4, llvm::Triple::aarch64, + ArchSpec::eCore_arm_armv8a, "armv8a"}, {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv8l, "armv8l"}, {eByteOrderLittle, 8, 4, 4, llvm::Triple::aarch64, ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add armv7a and armv8a ArchSpecs (PR #106433)
https://github.com/cjdb closed https://github.com/llvm/llvm-project/pull/106433 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add armv7a and armv8a ArchSpecs (PR #106433)
ajordanr-google wrote: Thanks for the review and merge! https://github.com/llvm/llvm-project/pull/106433 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Inline expression evaluator error visualization (PR #106470)
@@ -2076,7 +2077,11 @@ bool CommandInterpreter::HandleCommand(const char *command_line, } ElapsedTime elapsed(execute_time); -cmd_obj->Execute(remainder.c_str(), result); +size_t nchar = real_original_command_string.find(remainder); +std::optional pos_in_cmd; +if (nchar != std::string::npos) + pos_in_cmd = nchar + GetDebugger().GetPrompt().size(); +cmd_obj->Execute(remainder.c_str(), pos_in_cmd, result); jimingham wrote: I think expr is probably the only command that is likely to ever echo its command string into the output. That's not something most commands would do. So this doesn't seem like a feature that should have as much prominence as changing the API gives it. I don't want to have to worry about what this means when I'm writing a new command, given the answer is almost surely to be "not relevant". https://github.com/llvm/llvm-project/pull/106470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Inline expression evaluator error visualization (PR #106470)
@@ -2076,7 +2077,11 @@ bool CommandInterpreter::HandleCommand(const char *command_line, } ElapsedTime elapsed(execute_time); -cmd_obj->Execute(remainder.c_str(), result); +size_t nchar = real_original_command_string.find(remainder); +std::optional pos_in_cmd; +if (nchar != std::string::npos) + pos_in_cmd = nchar + GetDebugger().GetPrompt().size(); +cmd_obj->Execute(remainder.c_str(), pos_in_cmd, result); jimingham wrote: Also, how does this work if I run expr -i 0 -u 0 -- not a valid expression The command string here is `-i 0 -u 0 -- not a valid expression` but you probably don't ever echo that full line onto the diagnostic, so either you are fudging and only matching the args part of the command, or the docs aren't right here. https://github.com/llvm/llvm-project/pull/106470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Inline expression evaluator error visualization (PR #106470)
https://github.com/jimingham edited https://github.com/llvm/llvm-project/pull/106470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Inline expression evaluator error visualization (PR #106470)
@@ -2076,7 +2077,11 @@ bool CommandInterpreter::HandleCommand(const char *command_line, } ElapsedTime elapsed(execute_time); -cmd_obj->Execute(remainder.c_str(), result); +size_t nchar = real_original_command_string.find(remainder); +std::optional pos_in_cmd; +if (nchar != std::string::npos) + pos_in_cmd = nchar + GetDebugger().GetPrompt().size(); +cmd_obj->Execute(remainder.c_str(), pos_in_cmd, result); jimingham wrote: This seems a very expr specific function and not a generally useful for commands function. https://github.com/llvm/llvm-project/pull/106470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][DWARF] Add an option to silence unsupported DW_FORM warnings (PR #106609)
https://github.com/walter-erquinigo created https://github.com/llvm/llvm-project/pull/106609 My build of LLDB is all the time loading targets with a version of libc++ that was built with gcc that uses the DW_FORM 0x1e that is not implemented by LLVM, and I doubt it'll ever implement it. It's used for some 128 bit encoding of numbers, which is just very weird. Because of this, LLDB is showing some warnings all the time for my users, so I'm adding a flag to control the enablement of this warning. >From 6e0b743f9f6b676b6f2237fa8b5d680d10525e0d Mon Sep 17 00:00:00 2001 From: Walter Erquinigo Date: Thu, 29 Aug 2024 18:41:01 + Subject: [PATCH] [LLDB][DWARF] Add an option to silence unsupported DW_FORM warnings My build of LLDB is all the time loading targets with a version of libc++ that was built with gcc that uses the DW_FORM 0x1e that is not implemented by LLVM, and I doubt it'll ever implement it. It's used for some 128 bit encoding of numbers, which is just very weird. Because of this, LLDB is showing some warnings all the time for my users, so I'm adding a flag to control the enablement of this warning. --- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 30 --- .../DWARF/SymbolFileDWARFProperties.td| 4 +++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 7e0cf36d0de1b8..cb2625a2928701 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -87,7 +87,7 @@ #include #include -//#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN +// #define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN #ifdef ENABLE_DEBUG_PRINTF #include @@ -129,6 +129,11 @@ class PluginProperties : public Properties { bool IgnoreFileIndexes() const { return GetPropertyAtIndexAs(ePropertyIgnoreIndexes, false); } + + bool EmitUnsupportedDWFormValueWarning() const { +return GetPropertyAtIndexAs( +ePropertyEmitUnsupportedDWFormValueWarning, true); + } }; } // namespace @@ -624,12 +629,14 @@ uint32_t SymbolFileDWARF::CalculateAbilities() { llvm::DWARFDebugAbbrev *abbrev = DebugAbbrev(); std::set unsupported_forms = GetUnsupportedForms(abbrev); if (!unsupported_forms.empty()) { -StreamString error; -error.Printf("unsupported DW_FORM value%s:", - unsupported_forms.size() > 1 ? "s" : ""); -for (auto form : unsupported_forms) - error.Printf(" %#x", form); -m_objfile_sp->GetModule()->ReportWarning("{0}", error.GetString()); +if (GetGlobalPluginProperties().EmitUnsupportedDWFormValueWarning()) { + StreamString error; + error.Printf("unsupported DW_FORM value%s:", + unsupported_forms.size() > 1 ? "s" : ""); + for (auto form : unsupported_forms) +error.Printf(" %#x", form); + m_objfile_sp->GetModule()->ReportWarning("{0}", error.GetString()); +} return 0; } @@ -1770,16 +1777,17 @@ SymbolFileDWARF *SymbolFileDWARF::GetDIERefSymbolFile(const DIERef &die_ref) { return this; if (file_index) { - // We have a SymbolFileDWARFDebugMap, so let it find the right file +// We have a SymbolFileDWARFDebugMap, so let it find the right file if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile()) return debug_map->GetSymbolFileByOSOIndex(*file_index); - + // Handle the .dwp file case correctly if (*file_index == DIERef::k_file_index_mask) return GetDwpSymbolFile().get(); // DWP case // Handle the .dwo file case correctly -return DebugInfo().GetUnitAtIndex(*die_ref.file_index()) +return DebugInfo() +.GetUnitAtIndex(*die_ref.file_index()) ->GetDwoSymbolFile(); // DWO case } return this; @@ -3594,7 +3602,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc, lldb::addr_t location_DW_OP_addr = LLDB_INVALID_ADDRESS; if (!location_is_const_value_data) { bool op_error = false; - const DWARFExpression* location = location_list.GetAlwaysValidExpr(); + const DWARFExpression *location = location_list.GetAlwaysValidExpr(); if (location) location_DW_OP_addr = location->GetLocation_DW_OP_addr(location_form.GetUnit(), op_error); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td index 2f1ce88808b763..0f980a514b6720 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td @@ -5,4 +5,8 @@ let Definition = "symbolfiledwarf" in { Global, DefaultFalse, Desc<"Ignore indexes present in the object files an
[Lldb-commits] [lldb] [LLDB][DWARF] Add an option to silence unsupported DW_FORM warnings (PR #106609)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Walter Erquinigo (walter-erquinigo) Changes My build of LLDB is all the time loading targets with a version of libc++ that was built with gcc that uses the DW_FORM 0x1e that is not implemented by LLVM, and I doubt it'll ever implement it. It's used for some 128 bit encoding of numbers, which is just very weird. Because of this, LLDB is showing some warnings all the time for my users, so I'm adding a flag to control the enablement of this warning. --- Full diff: https://github.com/llvm/llvm-project/pull/106609.diff 2 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+19-11) - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td (+4) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 7e0cf36d0de1b8..cb2625a2928701 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -87,7 +87,7 @@ #include #include -//#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN +// #define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN #ifdef ENABLE_DEBUG_PRINTF #include @@ -129,6 +129,11 @@ class PluginProperties : public Properties { bool IgnoreFileIndexes() const { return GetPropertyAtIndexAs(ePropertyIgnoreIndexes, false); } + + bool EmitUnsupportedDWFormValueWarning() const { +return GetPropertyAtIndexAs( +ePropertyEmitUnsupportedDWFormValueWarning, true); + } }; } // namespace @@ -624,12 +629,14 @@ uint32_t SymbolFileDWARF::CalculateAbilities() { llvm::DWARFDebugAbbrev *abbrev = DebugAbbrev(); std::set unsupported_forms = GetUnsupportedForms(abbrev); if (!unsupported_forms.empty()) { -StreamString error; -error.Printf("unsupported DW_FORM value%s:", - unsupported_forms.size() > 1 ? "s" : ""); -for (auto form : unsupported_forms) - error.Printf(" %#x", form); -m_objfile_sp->GetModule()->ReportWarning("{0}", error.GetString()); +if (GetGlobalPluginProperties().EmitUnsupportedDWFormValueWarning()) { + StreamString error; + error.Printf("unsupported DW_FORM value%s:", + unsupported_forms.size() > 1 ? "s" : ""); + for (auto form : unsupported_forms) +error.Printf(" %#x", form); + m_objfile_sp->GetModule()->ReportWarning("{0}", error.GetString()); +} return 0; } @@ -1770,16 +1777,17 @@ SymbolFileDWARF *SymbolFileDWARF::GetDIERefSymbolFile(const DIERef &die_ref) { return this; if (file_index) { - // We have a SymbolFileDWARFDebugMap, so let it find the right file +// We have a SymbolFileDWARFDebugMap, so let it find the right file if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile()) return debug_map->GetSymbolFileByOSOIndex(*file_index); - + // Handle the .dwp file case correctly if (*file_index == DIERef::k_file_index_mask) return GetDwpSymbolFile().get(); // DWP case // Handle the .dwo file case correctly -return DebugInfo().GetUnitAtIndex(*die_ref.file_index()) +return DebugInfo() +.GetUnitAtIndex(*die_ref.file_index()) ->GetDwoSymbolFile(); // DWO case } return this; @@ -3594,7 +3602,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc, lldb::addr_t location_DW_OP_addr = LLDB_INVALID_ADDRESS; if (!location_is_const_value_data) { bool op_error = false; - const DWARFExpression* location = location_list.GetAlwaysValidExpr(); + const DWARFExpression *location = location_list.GetAlwaysValidExpr(); if (location) location_DW_OP_addr = location->GetLocation_DW_OP_addr(location_form.GetUnit(), op_error); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td index 2f1ce88808b763..0f980a514b6720 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td @@ -5,4 +5,8 @@ let Definition = "symbolfiledwarf" in { Global, DefaultFalse, Desc<"Ignore indexes present in the object files and always index DWARF manually.">; + def EmitUnsupportedDWFormValueWarning: Property<"emit-unsupported-dwform-value", "Boolean">, +Global, +DefaultTrue, +Desc<"Emit warnings about unsupported DW_Form values.">; } `` https://github.com/llvm/llvm-project/pull/106609 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Inline expression evaluator error visualization (PR #106470)
https://github.com/jimingham edited https://github.com/llvm/llvm-project/pull/106470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix dap stacktrace perf issue (PR #104874)
oltolm wrote: Can you backport it into llvm-19 branch? This bug makes lldb-dap almost impossible to use on Windows. https://github.com/llvm/llvm-project/pull/104874 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AArch64] Do not crash if NT_ARM_TLS is missing (PR #106478)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/106478 >From 6854730d45a2c119d2b8f71df6e22ead1c7ad5a8 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Wed, 28 Aug 2024 17:57:38 -0700 Subject: [PATCH 1/2] [lldb][AArch64] Do not crash if NT_ARM_TLS is missing [D156118](https://reviews.llvm.org/D156118) states that this note is always present, but it is better to check it explicitly, as otherwise `lldb` may crash when trying to read registers. --- .../Utility/RegisterInfoPOSIX_arm64.cpp | 7 ++-- .../elf-core/aarch64-no-NT_ARM_TLS.yaml | 34 +++ .../test/Shell/Process/elf-core/lit.local.cfg | 1 + 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 lldb/test/Shell/Process/elf-core/aarch64-no-NT_ARM_TLS.yaml create mode 100644 lldb/test/Shell/Process/elf-core/lit.local.cfg diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp index 054b7d9b2ec575..8ebdd214458c45 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp @@ -254,9 +254,10 @@ RegisterInfoPOSIX_arm64::RegisterInfoPOSIX_arm64( if (m_opt_regsets.AllSet(eRegsetMaskMTE)) AddRegSetMTE(); - // The TLS set always contains tpidr but only has tpidr2 when SME is - // present. - AddRegSetTLS(m_opt_regsets.AllSet(eRegsetMaskSSVE)); + if (m_opt_regsets.AllSet(eRegsetMaskTLS)) +// The TLS set always contains tpidr but only has tpidr2 when SME is +// present. +AddRegSetTLS(m_opt_regsets.AllSet(eRegsetMaskSSVE)); if (m_opt_regsets.AnySet(eRegsetMaskSSVE)) AddRegSetSME(m_opt_regsets.AnySet(eRegsetMaskZT)); diff --git a/lldb/test/Shell/Process/elf-core/aarch64-no-NT_ARM_TLS.yaml b/lldb/test/Shell/Process/elf-core/aarch64-no-NT_ARM_TLS.yaml new file mode 100644 index 00..bd8ce225c9e071 --- /dev/null +++ b/lldb/test/Shell/Process/elf-core/aarch64-no-NT_ARM_TLS.yaml @@ -0,0 +1,34 @@ +# REQUIRES: aarch64 + +## Check that lldb does not crash if a core file does not contain an NT_ARM_TLS +## note while there are notes for other dynamic register sets. + +# RUN: yaml2obj %s -o %t +# RUN: %lldb -c %t -o "re r -a" | FileCheck %s + +# CHECK: Pointer Authentication Registers: +# CHECK-NEXT: data_mask = +# CHECK-NEXT: code_mask = +# CHECK-NOT: Thread Local Storage Registers: + +--- !ELF +FileHeader: + Class:ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_CORE + Machine: EM_AARCH64 +ProgramHeaders: + - Type: PT_NOTE +FirstSec: .note +LastSec:.note +Sections: + - Name: .note +Type: SHT_NOTE +Notes: + - Name: CORE +Desc: 0b000b0038931b9338931b93e02e11915ee12f00400162e258014000200162e224014100 +Type: NT_PRSTATUS + - Name: LINUX +Desc: 7f007f00 +Type: NT_ARM_PAC_MASK +... diff --git a/lldb/test/Shell/Process/elf-core/lit.local.cfg b/lldb/test/Shell/Process/elf-core/lit.local.cfg new file mode 100644 index 00..8169b9f95e118c --- /dev/null +++ b/lldb/test/Shell/Process/elf-core/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.yaml'] >From 90366705c6bce931a279940c5f9ee43f232f00f2 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Thu, 29 Aug 2024 12:20:42 -0700 Subject: [PATCH 2/2] fixup: add braces --- .../source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp index 8ebdd214458c45..9f5872e5de7e9f 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp @@ -254,10 +254,11 @@ RegisterInfoPOSIX_arm64::RegisterInfoPOSIX_arm64( if (m_opt_regsets.AllSet(eRegsetMaskMTE)) AddRegSetMTE(); - if (m_opt_regsets.AllSet(eRegsetMaskTLS)) + if (m_opt_regsets.AllSet(eRegsetMaskTLS)) { // The TLS set always contains tpidr but only has tpidr2 when SME is
[Lldb-commits] [lldb] [lldb] Inline expression evaluator error visualization (PR #106470)
@@ -2076,7 +2077,11 @@ bool CommandInterpreter::HandleCommand(const char *command_line, } ElapsedTime elapsed(execute_time); -cmd_obj->Execute(remainder.c_str(), result); +size_t nchar = real_original_command_string.find(remainder); +std::optional pos_in_cmd; +if (nchar != std::string::npos) + pos_in_cmd = nchar + GetDebugger().GetPrompt().size(); +cmd_obj->Execute(remainder.c_str(), pos_in_cmd, result); medismailben wrote: > I think expr is probably the only command that is likely to ever echo its > command string into the output. That's not something most commands would do. > So this doesn't seem like a feature that should have as much prominence as > changing the API gives it. I don't want to have to worry about what this > means when I'm writing a new command, given the answer is almost surely to be > "not relevant". I don't have a strong option about this (as long as we don't update all the `DoExecute` implementations), but I was under the impression that in the future, some commands could make use of it to point directly to what caused an error in their invocation. But again, we can have it be part of the expression for now. https://github.com/llvm/llvm-project/pull/106470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Improve `stackTrace` and `exceptionInfo` DAP request handlers (PR #105905)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/105905 >From ebcf4842c7d6c5ac0da4976c9cffb68bc3b22807 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Fri, 23 Aug 2024 16:04:44 -0700 Subject: [PATCH 1/7] [lldb-dap] Improve `stackTrace` and `exceptionInfo` DAP request handlers. Refactoring `stackTrace` to perform frame look ups in a more on-demand fashion to improve overall performance. Additionally adding additional information to the `exceptionInfo` request to report exception stacks there instead of merging the exception stack into the stack trace. The `exceptionInfo` request is only called if a stop event occurs with `reason='exception'`, which should mitigate the performance of `SBThread::GetCurrentException` calls. Adding unit tests for exception handling and stack trace supporting. --- .../Python/lldbsuite/test/lldbplatformutil.py | 16 ++ .../test/tools/lldb-dap/dap_server.py | 11 + .../test/tools/lldb-dap/lldbdap_testcase.py | 9 +- .../API/tools/lldb-dap/exception/Makefile | 2 +- .../lldb-dap/exception/TestDAP_exception.py | 8 +- .../API/tools/lldb-dap/exception/cpp/Makefile | 3 + .../exception/cpp/TestDAP_exception_cpp.py| 26 ++ .../API/tools/lldb-dap/exception/cpp/main.cpp | 6 + .../lldb-dap/exception/{main.cpp => main.c} | 2 +- .../tools/lldb-dap/exception/objc/Makefile| 9 + .../exception/objc/TestDAP_exception_objc.py | 27 ++ .../API/tools/lldb-dap/exception/objc/main.m | 8 + .../lldb-dap/extendedStackTrace/Makefile | 5 + .../TestDAP_extendedStackTrace.py | 69 + .../tools/lldb-dap/extendedStackTrace/main.m | 28 ++ .../lldb-dap/stackTrace/TestDAP_stackTrace.py | 4 +- .../TestDAP_stackTraceMissingFunctionName.py | 5 - lldb/tools/lldb-dap/DAP.cpp | 1 - lldb/tools/lldb-dap/DAP.h | 2 +- lldb/tools/lldb-dap/JSONUtils.cpp | 40 +++ lldb/tools/lldb-dap/JSONUtils.h | 3 + lldb/tools/lldb-dap/lldb-dap.cpp | 253 +- 22 files changed, 449 insertions(+), 88 deletions(-) create mode 100644 lldb/test/API/tools/lldb-dap/exception/cpp/Makefile create mode 100644 lldb/test/API/tools/lldb-dap/exception/cpp/TestDAP_exception_cpp.py create mode 100644 lldb/test/API/tools/lldb-dap/exception/cpp/main.cpp rename lldb/test/API/tools/lldb-dap/exception/{main.cpp => main.c} (56%) create mode 100644 lldb/test/API/tools/lldb-dap/exception/objc/Makefile create mode 100644 lldb/test/API/tools/lldb-dap/exception/objc/TestDAP_exception_objc.py create mode 100644 lldb/test/API/tools/lldb-dap/exception/objc/main.m create mode 100644 lldb/test/API/tools/lldb-dap/extendedStackTrace/Makefile create mode 100644 lldb/test/API/tools/lldb-dap/extendedStackTrace/TestDAP_extendedStackTrace.py create mode 100644 lldb/test/API/tools/lldb-dap/extendedStackTrace/main.m diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py index 602e15d207e94a..3d8c713562e9bf 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py @@ -181,6 +181,22 @@ def findMainThreadCheckerDylib(): return "" +def findBacktraceRecordingDylib(): +if not platformIsDarwin(): +return "" + +if getPlatform() in lldbplatform.translate(lldbplatform.darwin_embedded): +return "/Developer/usr/lib/libBacktraceRecording.dylib" + +with os.popen("xcode-select -p") as output: +xcode_developer_path = output.read().strip() +mtc_dylib_path = "%s/usr/lib/libBacktraceRecording.dylib" % xcode_developer_path +if os.path.isfile(mtc_dylib_path): +return mtc_dylib_path + +return "" + + class _PlatformContext(object): """Value object class which contains platform-specific options.""" diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 874383a13e2bb6..167142779cf12c 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -707,6 +707,17 @@ def request_evaluate(self, expression, frameIndex=0, threadId=None, context=None } return self.send_recv(command_dict) +def request_exceptionInfo(self, threadId=None): +if threadId is None: +threadId = self.get_thread_id() +args_dict = {"threadId": threadId} +command_dict = { +"command": "exceptionInfo", +"type": "request", +"arguments": args_dict, +} +return self.send_recv(command_dict) + def request_initialize(self, sourceInitFile): command_dict = { "command": "initialize", diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.
[Lldb-commits] [lldb] [lldb-dap] Improve `stackTrace` and `exceptionInfo` DAP request handlers (PR #105905)
ashgti wrote: Reverted the removal of `enableDisplayExtendedBacktrace` and added `enableDisplayExtendedBacktrace` to the documentation and package.json description of the lldb-dap debugger. https://github.com/llvm/llvm-project/pull/105905 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] [NFC] Prefer subprocess.DEVNULL over os.devnull (PR #106500)
nicovank wrote: Thanks! I have no commit access, please click the merge button :) https://github.com/llvm/llvm-project/pull/106500 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Improve `stackTrace` and `exceptionInfo` DAP request handlers (PR #105905)
@@ -3106,80 +3235,109 @@ void request_stackTrace(const llvm::json::Object &request) { llvm::json::Array stackFrames; llvm::json::Object body; + // Threads stacks may contain runtime specific extended backtraces, when + // constructing a stack trace first report the full thread stack trace then + // perform a breadth first traversal of any extended backtrace frames. + // + // For example: + // + // Thread (id=th0) stack=[s0, s1, s2, s3] + // \ Extended backtrace "libdispatch" Thread (id=th1) stack=[s0, s1] + // \ Extended backtrace "libdispatch" Thread (id=th2) stack=[s0, s1] + // \ Extended backtrace "Application Specific Backtrace" Thread (id=th3) + // stack=[s0, s1, s2] + // + // Which will flatten into: + // + // 0. th0->s0 + // 1. th0->s1 + // 2. th0->s2 + // 3. th0->s3 + // 4. label - Enqueued from th1 + // 5. th1->s0 + // 6. th1->s1 + // 7. label - Enqueued from th2 + // 8. th2->s0 + // 9. th2->s1 + // 10. label - Application Specific Backtrace + // 11. th3->s0 + // 12. th3->s1 + // 13. th3->s2 + if (thread.IsValid()) { const auto startFrame = GetUnsigned(arguments, "startFrame", 0); const auto levels = GetUnsigned(arguments, "levels", 0); const auto endFrame = (levels == 0) ? INT64_MAX : (startFrame + levels); -auto totalFrames = thread.GetNumFrames(); - -// This will always return an invalid thread when -// libBacktraceRecording.dylib is not loaded or if there is no extended -// backtrace. -lldb::SBThread queue_backtrace_thread; -if (g_dap.enable_display_extended_backtrace) - queue_backtrace_thread = thread.GetExtendedBacktraceThread("libdispatch"); -if (queue_backtrace_thread.IsValid()) { - // One extra frame as a label to mark the enqueued thread. - totalFrames += queue_backtrace_thread.GetNumFrames() + 1; -} - -// This will always return an invalid thread when there is no exception in -// the current thread. -lldb::SBThread exception_backtrace_thread; -if (g_dap.enable_display_extended_backtrace) - exception_backtrace_thread = thread.GetCurrentExceptionBacktrace(); - -if (exception_backtrace_thread.IsValid()) { - // One extra frame as a label to mark the exception thread. - totalFrames += exception_backtrace_thread.GetNumFrames() + 1; -} - -for (uint32_t i = startFrame; i < endFrame; ++i) { - lldb::SBFrame frame; - std::string prefix; - if (i < thread.GetNumFrames()) { -frame = thread.GetFrameAtIndex(i); - } else if (queue_backtrace_thread.IsValid() && - i < (thread.GetNumFrames() + - queue_backtrace_thread.GetNumFrames() + 1)) { -if (i == thread.GetNumFrames()) { - const uint32_t thread_idx = - queue_backtrace_thread.GetExtendedBacktraceOriginatingIndexID(); - const char *queue_name = queue_backtrace_thread.GetQueueName(); - auto name = llvm::formatv("Enqueued from {0} (Thread {1})", -queue_name, thread_idx); - stackFrames.emplace_back( - llvm::json::Object{{"id", thread.GetThreadID() + 1}, - {"name", name}, - {"presentationHint", "label"}}); - continue; +bool done = false; +int64_t offset = 0; +lldb::SBProcess process = thread.GetProcess(); +llvm::SmallVector threadCluster{{thread}}; + +for (uint32_t i = startFrame; i < endFrame && !threadCluster.empty(); ++i) { + lldb::SBThread current = threadCluster.front(); + lldb::SBFrame frame = current.GetFrameAtIndex(i - offset); + + // If we don't have a valid frame, check if we have any extended frames to + // report. + // *NOTE*: Threads can be chained across mutliple backtraces, so we + // need to keep track of each backtrace we've traversed fully in the + // offset. + while (!frame.IsValid() && current.IsValid() && !threadCluster.empty()) { jeffreytan81 wrote: Nit: it may worth moving extended back trace specific code into a dedicated helper function to improve readability. https://github.com/llvm/llvm-project/pull/105905 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Improve `stackTrace` and `exceptionInfo` DAP request handlers (PR #105905)
https://github.com/jeffreytan81 approved this pull request. https://github.com/llvm/llvm-project/pull/105905 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Store SupportFiles in SourceManager::File (NFC) (PR #106639)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/106639 To support detecting MD5 checksum mismatches, store a SupportFile rather than a plain FileSpec in SourceManager::File. >From 64b6c6419722ecd5865cdf3e734b63ed51763174 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 29 Aug 2024 15:03:23 -0700 Subject: [PATCH] [lldb] Store SupportFiles in SourceManager::File (NFC) To support detecting MD5 checksum mismatches, store a SupportFile rather than a plain FileSpec in SourceManager::File. --- lldb/include/lldb/Core/SourceManager.h | 26 ++-- lldb/source/Commands/CommandObjectSource.cpp | 4 +- lldb/source/Core/IOHandlerCursesGUI.cpp | 14 +- lldb/source/Core/SourceManager.cpp | 141 +++ lldb/unittests/Core/SourceManagerTest.cpp| 12 +- 5 files changed, 114 insertions(+), 83 deletions(-) diff --git a/lldb/include/lldb/Core/SourceManager.h b/lldb/include/lldb/Core/SourceManager.h index 5239ac6f4055f5..3459a1031a10d7 100644 --- a/lldb/include/lldb/Core/SourceManager.h +++ b/lldb/include/lldb/Core/SourceManager.h @@ -37,8 +37,8 @@ class SourceManager { const SourceManager::File &rhs); public: -File(const FileSpec &file_spec, lldb::TargetSP target_sp); -File(const FileSpec &file_spec, lldb::DebuggerSP debugger_sp); +File(lldb::SupportFileSP support_file_sp, lldb::TargetSP target_sp); +File(lldb::SupportFileSP support_file_sp, lldb::DebuggerSP debugger_sp); bool ModificationTimeIsStale() const; bool PathRemappingIsStale() const; @@ -56,7 +56,10 @@ class SourceManager { bool LineIsValid(uint32_t line); -const FileSpec &GetFileSpec() { return m_file_spec; } +lldb::SupportFileSP GetSupportFile() const { + assert(m_support_file_sp && "SupportFileSP must always be valid"); + return m_support_file_sp; +} uint32_t GetSourceMapModificationID() const { return m_source_map_mod_id; } @@ -70,15 +73,17 @@ class SourceManager { protected: /// Set file and update modification time. -void SetFileSpec(FileSpec file_spec); +void SetSupportFile(lldb::SupportFileSP support_file_sp); bool CalculateLineOffsets(uint32_t line = UINT32_MAX); -FileSpec m_file_spec_orig; // The original file spec that was used (can be - // different from m_file_spec) -FileSpec m_file_spec; // The actually file spec being used (if the target - // has source mappings, this might be different from - // m_file_spec_orig) +/// The original support file that was used. +lldb::SupportFileSP m_original_support_file_sp; + +/// The actually support file being used. If the target +/// has source mappings, this might be different from +/// the original support file. +lldb::SupportFileSP m_support_file_sp; // Keep the modification time that this file data is valid for llvm::sys::TimePoint<> m_mod_time; @@ -93,7 +98,8 @@ class SourceManager { lldb::TargetWP m_target_wp; private: -void CommonInitializer(const FileSpec &file_spec, lldb::TargetSP target_sp); +void CommonInitializer(lldb::SupportFileSP support_file_sp, + lldb::TargetSP target_sp); }; typedef std::shared_ptr FileSP; diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index 5ddd46ac5fdc07..1a0629c6765d41 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -1076,8 +1076,8 @@ class CommandObjectSourceList : public CommandObjectParsed { target.GetSourceManager().GetLastFile()); if (last_file_sp) { const bool show_inlines = true; -m_breakpoint_locations.Reset(last_file_sp->GetFileSpec(), 0, - show_inlines); +m_breakpoint_locations.Reset( +last_file_sp->GetSupportFile()->GetSpecOnly(), 0, show_inlines); SearchFilterForUnconstrainedSearches target_search_filter( target.shared_from_this()); target_search_filter.Search(m_breakpoint_locations); diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp index d922d32f910583..8f44e3d0cd016b 100644 --- a/lldb/source/Core/IOHandlerCursesGUI.cpp +++ b/lldb/source/Core/IOHandlerCursesGUI.cpp @@ -6894,8 +6894,8 @@ class SourceFileWindowDelegate : public WindowDelegate { if (context_changed) m_selected_line = m_pc_line; - if (m_file_sp && - m_file_sp->GetFileSpec() == m_sc.line_entry.GetFile()) { + if (m_file_sp && m_file_sp->GetSupportFile()->GetSpecOnly() == + m_sc.line_entry.GetFile()) { // Same file, nothing to do, we should either have the lines or // not (so
[Lldb-commits] [lldb] [lldb] Store SupportFiles in SourceManager::File (NFC) (PR #106639)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes To support detecting MD5 checksum mismatches, store a SupportFile rather than a plain FileSpec in SourceManager::File. --- Full diff: https://github.com/llvm/llvm-project/pull/106639.diff 5 Files Affected: - (modified) lldb/include/lldb/Core/SourceManager.h (+16-10) - (modified) lldb/source/Commands/CommandObjectSource.cpp (+2-2) - (modified) lldb/source/Core/IOHandlerCursesGUI.cpp (+8-6) - (modified) lldb/source/Core/SourceManager.cpp (+81-60) - (modified) lldb/unittests/Core/SourceManagerTest.cpp (+7-5) ``diff diff --git a/lldb/include/lldb/Core/SourceManager.h b/lldb/include/lldb/Core/SourceManager.h index 5239ac6f4055f5..3459a1031a10d7 100644 --- a/lldb/include/lldb/Core/SourceManager.h +++ b/lldb/include/lldb/Core/SourceManager.h @@ -37,8 +37,8 @@ class SourceManager { const SourceManager::File &rhs); public: -File(const FileSpec &file_spec, lldb::TargetSP target_sp); -File(const FileSpec &file_spec, lldb::DebuggerSP debugger_sp); +File(lldb::SupportFileSP support_file_sp, lldb::TargetSP target_sp); +File(lldb::SupportFileSP support_file_sp, lldb::DebuggerSP debugger_sp); bool ModificationTimeIsStale() const; bool PathRemappingIsStale() const; @@ -56,7 +56,10 @@ class SourceManager { bool LineIsValid(uint32_t line); -const FileSpec &GetFileSpec() { return m_file_spec; } +lldb::SupportFileSP GetSupportFile() const { + assert(m_support_file_sp && "SupportFileSP must always be valid"); + return m_support_file_sp; +} uint32_t GetSourceMapModificationID() const { return m_source_map_mod_id; } @@ -70,15 +73,17 @@ class SourceManager { protected: /// Set file and update modification time. -void SetFileSpec(FileSpec file_spec); +void SetSupportFile(lldb::SupportFileSP support_file_sp); bool CalculateLineOffsets(uint32_t line = UINT32_MAX); -FileSpec m_file_spec_orig; // The original file spec that was used (can be - // different from m_file_spec) -FileSpec m_file_spec; // The actually file spec being used (if the target - // has source mappings, this might be different from - // m_file_spec_orig) +/// The original support file that was used. +lldb::SupportFileSP m_original_support_file_sp; + +/// The actually support file being used. If the target +/// has source mappings, this might be different from +/// the original support file. +lldb::SupportFileSP m_support_file_sp; // Keep the modification time that this file data is valid for llvm::sys::TimePoint<> m_mod_time; @@ -93,7 +98,8 @@ class SourceManager { lldb::TargetWP m_target_wp; private: -void CommonInitializer(const FileSpec &file_spec, lldb::TargetSP target_sp); +void CommonInitializer(lldb::SupportFileSP support_file_sp, + lldb::TargetSP target_sp); }; typedef std::shared_ptr FileSP; diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index 5ddd46ac5fdc07..1a0629c6765d41 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -1076,8 +1076,8 @@ class CommandObjectSourceList : public CommandObjectParsed { target.GetSourceManager().GetLastFile()); if (last_file_sp) { const bool show_inlines = true; -m_breakpoint_locations.Reset(last_file_sp->GetFileSpec(), 0, - show_inlines); +m_breakpoint_locations.Reset( +last_file_sp->GetSupportFile()->GetSpecOnly(), 0, show_inlines); SearchFilterForUnconstrainedSearches target_search_filter( target.shared_from_this()); target_search_filter.Search(m_breakpoint_locations); diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp index d922d32f910583..8f44e3d0cd016b 100644 --- a/lldb/source/Core/IOHandlerCursesGUI.cpp +++ b/lldb/source/Core/IOHandlerCursesGUI.cpp @@ -6894,8 +6894,8 @@ class SourceFileWindowDelegate : public WindowDelegate { if (context_changed) m_selected_line = m_pc_line; - if (m_file_sp && - m_file_sp->GetFileSpec() == m_sc.line_entry.GetFile()) { + if (m_file_sp && m_file_sp->GetSupportFile()->GetSpecOnly() == + m_sc.line_entry.GetFile()) { // Same file, nothing to do, we should either have the lines or // not (source file missing) if (m_selected_line >= static_cast(m_first_visible_line)) { @@ -7001,7 +7001,8 @@ class SourceFileWindowDelegate : public WindowDelegate { LineEntry bp_loc_line_entry; if (bp_loc_sp->GetAddress().C
[Lldb-commits] [lldb] [lldb] Store SupportFiles in SourceManager::File (NFC) (PR #106639)
https://github.com/adrian-prantl commented: I was skeptical that a SupportFile would be the right choice, but it's documented as a: > Wraps either a > [FileSpec](https://lldb.llvm.org/cpp_reference/classlldb__private_1_1FileSpec.html) > that represents a local file or a source file whose contents is known (for > example because it can be reconstructed from debug info), but that hasn't > been written to a file yet. https://github.com/llvm/llvm-project/pull/106639 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Store SupportFiles in SourceManager::File (NFC) (PR #106639)
@@ -70,15 +73,17 @@ class SourceManager { protected: /// Set file and update modification time. -void SetFileSpec(FileSpec file_spec); +void SetSupportFile(lldb::SupportFileSP support_file_sp); bool CalculateLineOffsets(uint32_t line = UINT32_MAX); -FileSpec m_file_spec_orig; // The original file spec that was used (can be - // different from m_file_spec) -FileSpec m_file_spec; // The actually file spec being used (if the target - // has source mappings, this might be different from - // m_file_spec_orig) +/// The original support file that was used. +lldb::SupportFileSP m_original_support_file_sp; adrian-prantl wrote: I suppose the SourceManager cannot own it because the SupportFile may outlive it? https://github.com/llvm/llvm-project/pull/106639 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Store SupportFiles in SourceManager::File (NFC) (PR #106639)
@@ -70,15 +73,17 @@ class SourceManager { protected: /// Set file and update modification time. -void SetFileSpec(FileSpec file_spec); +void SetSupportFile(lldb::SupportFileSP support_file_sp); bool CalculateLineOffsets(uint32_t line = UINT32_MAX); -FileSpec m_file_spec_orig; // The original file spec that was used (can be - // different from m_file_spec) -FileSpec m_file_spec; // The actually file spec being used (if the target - // has source mappings, this might be different from - // m_file_spec_orig) +/// The original support file that was used. +lldb::SupportFileSP m_original_support_file_sp; + +/// The actually support file being used. If the target +/// has source mappings, this might be different from +/// the original support file. adrian-prantl wrote: Is this yet another case where one support file may have different mappings in two targets at the same time? (Asking whether this is the right ownership again) https://github.com/llvm/llvm-project/pull/106639 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Move few static helpers to the class Socket and make them public (PR #106640)
https://github.com/slydiman created https://github.com/llvm/llvm-project/pull/106640 This is the prerequisite for #104238. >From b0dffc5aa9212432f29344eda3ad0b4914f4df35 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Fri, 30 Aug 2024 01:29:58 +0400 Subject: [PATCH] [lldb][NFC] Move few static helpers to the class Socket and make them public This is the prerequisite for #104238. --- lldb/include/lldb/Host/Socket.h | 16 +-- lldb/source/Host/common/Socket.cpp| 24 +- lldb/source/Host/common/TCPSocket.cpp | 29 +-- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h index 304a91bdf6741b..4c2f07b796d615 100644 --- a/lldb/include/lldb/Host/Socket.h +++ b/lldb/include/lldb/Host/Socket.h @@ -34,9 +34,11 @@ namespace lldb_private { #if defined(_WIN32) typedef SOCKET NativeSocket; typedef lldb::pipe_t shared_fd_t; +typedef const char *set_socket_option_arg_type; #else typedef int NativeSocket; typedef NativeSocket shared_fd_t; +typedef const void *set_socket_option_arg_type; #endif class Socket; class TCPSocket; @@ -132,12 +134,8 @@ class Socket : public IOObject { // If this Socket is connected then return the URI used to connect. virtual std::string GetRemoteConnectionURI() const { return ""; }; -protected: - Socket(SocketProtocol protocol, bool should_close, - bool m_child_process_inherit); - - virtual size_t Send(const void *buf, const size_t num_bytes); - + static int CloseSocket(NativeSocket sockfd); + static Status GetLastError(); static void SetLastError(Status &error); static NativeSocket CreateSocket(const int domain, const int type, const int protocol, @@ -146,6 +144,12 @@ class Socket : public IOObject { socklen_t *addrlen, bool child_processes_inherit, Status &error); +protected: + Socket(SocketProtocol protocol, bool should_close, + bool m_child_process_inherit); + + virtual size_t Send(const void *buf, const size_t num_bytes); + SocketProtocol m_protocol; NativeSocket m_socket; bool m_child_processes_inherit; diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp index 1a506aa95b2465..62473a79e290e8 100644 --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/source/Host/common/Socket.cpp @@ -386,11 +386,7 @@ Status Socket::Close() { LLDB_LOGF(log, "%p Socket::Close (fd = %" PRIu64 ")", static_cast(this), static_cast(m_socket)); -#if defined(_WIN32) - bool success = closesocket(m_socket) == 0; -#else - bool success = ::close(m_socket) == 0; -#endif + bool success = CloseSocket(m_socket) == 0; // A reference to a FD was passed in, set it to an invalid value m_socket = kInvalidSocketValue; if (!success) { @@ -427,6 +423,24 @@ void Socket::SetLastError(Status &error) { #endif } +Status Socket::GetLastError() { + std::error_code EC; +#ifdef _WIN32 + EC = llvm::mapWindowsError(WSAGetLastError()); +#else + EC = std::error_code(errno, std::generic_category()); +#endif + return EC; +} + +int Socket::CloseSocket(NativeSocket sockfd) { +#ifdef _WIN32 + return ::closesocket(sockfd); +#else + return ::close(sockfd); +#endif +} + NativeSocket Socket::CreateSocket(const int domain, const int type, const int protocol, bool child_processes_inherit, Status &error) { diff --git a/lldb/source/Host/common/TCPSocket.cpp b/lldb/source/Host/common/TCPSocket.cpp index ea26d8433c370a..86c6ff510e2db8 100644 --- a/lldb/source/Host/common/TCPSocket.cpp +++ b/lldb/source/Host/common/TCPSocket.cpp @@ -32,28 +32,9 @@ #include #endif -#ifdef _WIN32 -#define CLOSE_SOCKET closesocket -typedef const char *set_socket_option_arg_type; -#else -#include -#define CLOSE_SOCKET ::close -typedef const void *set_socket_option_arg_type; -#endif - using namespace lldb; using namespace lldb_private; -static Status GetLastSocketError() { - std::error_code EC; -#ifdef _WIN32 - EC = llvm::mapWindowsError(WSAGetLastError()); -#else - EC = std::error_code(errno, std::generic_category()); -#endif - return EC; -} - static const int kType = SOCK_STREAM; TCPSocket::TCPSocket(bool should_close, bool child_processes_inherit) @@ -212,7 +193,7 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) { reinterpret_cast(&option_value); if (::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p, sizeof(option_value)) == -1) { - CLOSE_SOCKET(fd); + CloseSocket(fd); continue; } @@ -228,8 +209,8 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) { err = ::listen(fd, backlog); if (err == -1) { - error = GetLastSocketError(); - CLOSE_SOCKET(fd); + error = GetLastError(); + Clos
[Lldb-commits] [lldb] [lldb][NFC] Move few static helpers to the class Socket and make them public (PR #106640)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Dmitry Vasilyev (slydiman) Changes This is the prerequisite for #104238. --- Full diff: https://github.com/llvm/llvm-project/pull/106640.diff 3 Files Affected: - (modified) lldb/include/lldb/Host/Socket.h (+10-6) - (modified) lldb/source/Host/common/Socket.cpp (+19-5) - (modified) lldb/source/Host/common/TCPSocket.cpp (+5-24) ``diff diff --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h index 304a91bdf6741b..4c2f07b796d615 100644 --- a/lldb/include/lldb/Host/Socket.h +++ b/lldb/include/lldb/Host/Socket.h @@ -34,9 +34,11 @@ namespace lldb_private { #if defined(_WIN32) typedef SOCKET NativeSocket; typedef lldb::pipe_t shared_fd_t; +typedef const char *set_socket_option_arg_type; #else typedef int NativeSocket; typedef NativeSocket shared_fd_t; +typedef const void *set_socket_option_arg_type; #endif class Socket; class TCPSocket; @@ -132,12 +134,8 @@ class Socket : public IOObject { // If this Socket is connected then return the URI used to connect. virtual std::string GetRemoteConnectionURI() const { return ""; }; -protected: - Socket(SocketProtocol protocol, bool should_close, - bool m_child_process_inherit); - - virtual size_t Send(const void *buf, const size_t num_bytes); - + static int CloseSocket(NativeSocket sockfd); + static Status GetLastError(); static void SetLastError(Status &error); static NativeSocket CreateSocket(const int domain, const int type, const int protocol, @@ -146,6 +144,12 @@ class Socket : public IOObject { socklen_t *addrlen, bool child_processes_inherit, Status &error); +protected: + Socket(SocketProtocol protocol, bool should_close, + bool m_child_process_inherit); + + virtual size_t Send(const void *buf, const size_t num_bytes); + SocketProtocol m_protocol; NativeSocket m_socket; bool m_child_processes_inherit; diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp index 1a506aa95b2465..62473a79e290e8 100644 --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/source/Host/common/Socket.cpp @@ -386,11 +386,7 @@ Status Socket::Close() { LLDB_LOGF(log, "%p Socket::Close (fd = %" PRIu64 ")", static_cast(this), static_cast(m_socket)); -#if defined(_WIN32) - bool success = closesocket(m_socket) == 0; -#else - bool success = ::close(m_socket) == 0; -#endif + bool success = CloseSocket(m_socket) == 0; // A reference to a FD was passed in, set it to an invalid value m_socket = kInvalidSocketValue; if (!success) { @@ -427,6 +423,24 @@ void Socket::SetLastError(Status &error) { #endif } +Status Socket::GetLastError() { + std::error_code EC; +#ifdef _WIN32 + EC = llvm::mapWindowsError(WSAGetLastError()); +#else + EC = std::error_code(errno, std::generic_category()); +#endif + return EC; +} + +int Socket::CloseSocket(NativeSocket sockfd) { +#ifdef _WIN32 + return ::closesocket(sockfd); +#else + return ::close(sockfd); +#endif +} + NativeSocket Socket::CreateSocket(const int domain, const int type, const int protocol, bool child_processes_inherit, Status &error) { diff --git a/lldb/source/Host/common/TCPSocket.cpp b/lldb/source/Host/common/TCPSocket.cpp index ea26d8433c370a..86c6ff510e2db8 100644 --- a/lldb/source/Host/common/TCPSocket.cpp +++ b/lldb/source/Host/common/TCPSocket.cpp @@ -32,28 +32,9 @@ #include #endif -#ifdef _WIN32 -#define CLOSE_SOCKET closesocket -typedef const char *set_socket_option_arg_type; -#else -#include -#define CLOSE_SOCKET ::close -typedef const void *set_socket_option_arg_type; -#endif - using namespace lldb; using namespace lldb_private; -static Status GetLastSocketError() { - std::error_code EC; -#ifdef _WIN32 - EC = llvm::mapWindowsError(WSAGetLastError()); -#else - EC = std::error_code(errno, std::generic_category()); -#endif - return EC; -} - static const int kType = SOCK_STREAM; TCPSocket::TCPSocket(bool should_close, bool child_processes_inherit) @@ -212,7 +193,7 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) { reinterpret_cast(&option_value); if (::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p, sizeof(option_value)) == -1) { - CLOSE_SOCKET(fd); + CloseSocket(fd); continue; } @@ -228,8 +209,8 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) { err = ::listen(fd, backlog); if (err == -1) { - error = GetLastSocketError(); - CLOSE_SOCKET(fd); + error = GetLastError(); + CloseSocket(fd); continue; } @@ -250,7 +231,7 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) { void TCPSocket::CloseListenSockets() { for (auto socket : m_listen_sockets) -CLOSE_SOCKET(socket.first); +
[Lldb-commits] [lldb] [lldb] Better matching of types in anonymous namespaces (PR #102111)
clayborg wrote: Sorry for the delay, feel free to ping sooner next time! Lets start with this and we can iterate on it! https://github.com/llvm/llvm-project/pull/102111 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Better matching of types in anonymous namespaces (PR #102111)
https://github.com/clayborg approved this pull request. https://github.com/llvm/llvm-project/pull/102111 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Removed gdbserver ports map from lldb-server (PR #104238)
https://github.com/slydiman updated https://github.com/llvm/llvm-project/pull/104238 >From 22209660e732f2101fd40d613bef7a506b402a74 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Fri, 30 Aug 2024 01:08:24 +0400 Subject: [PATCH] [lldb] Removed gdbserver ports map from lldb-server Listen to gdbserver-port, accept the connection and run lldb-server gdbserver --fd on all platforms. Refactored Acceptor to listen on 2 ports in the main thread. Parameters --min-gdbserver-port and --max-gdbserver-port are deprecated now. This is the part 2 of #101283. Fixes #97537, fixes #101475. --- lldb/docs/man/lldb-server.rst | 11 +- lldb/docs/resources/qemu-testing.rst | 19 +- lldb/include/lldb/Host/Socket.h | 16 +- lldb/source/Host/common/Socket.cpp| 24 +- lldb/source/Host/common/TCPSocket.cpp | 29 +- .../posix/ConnectionFileDescriptorPosix.cpp | 21 +- .../gdb-remote/GDBRemoteCommunication.cpp | 45 +-- .../gdb-remote/GDBRemoteCommunication.h | 8 +- .../GDBRemoteCommunicationServerPlatform.cpp | 287 ++ .../GDBRemoteCommunicationServerPlatform.h| 82 + .../Process/gdb-remote/ProcessGDBRemote.cpp | 2 +- .../TestPlatformLaunchGDBServer.py| 12 +- .../Shell/lldb-server/TestGdbserverPort.test | 4 - lldb/tools/lldb-server/Acceptor.cpp | 230 +++--- lldb/tools/lldb-server/Acceptor.h | 47 +-- lldb/tools/lldb-server/lldb-gdbserver.cpp | 23 +- lldb/tools/lldb-server/lldb-platform.cpp | 199 ++-- .../Process/gdb-remote/CMakeLists.txt | 1 - .../Process/gdb-remote/PortMapTest.cpp| 115 --- .../tools/lldb-server/tests/LLGSTest.cpp | 4 - .../tools/lldb-server/tests/TestClient.cpp| 4 - .../tools/lldb-server/tests/TestClient.h | 4 + 22 files changed, 539 insertions(+), 648 deletions(-) delete mode 100644 lldb/test/Shell/lldb-server/TestGdbserverPort.test delete mode 100644 lldb/unittests/Process/gdb-remote/PortMapTest.cpp diff --git a/lldb/docs/man/lldb-server.rst b/lldb/docs/man/lldb-server.rst index a67c00b305f6d2..31f5360df5e23e 100644 --- a/lldb/docs/man/lldb-server.rst +++ b/lldb/docs/man/lldb-server.rst @@ -147,15 +147,8 @@ GDB-SERVER CONNECTIONS .. option:: --gdbserver-port - Define a port to be used for gdb-server connections. Can be specified multiple - times to allow multiple ports. Has no effect if --min-gdbserver-port - and --max-gdbserver-port are specified. - -.. option:: --min-gdbserver-port -.. option:: --max-gdbserver-port - - Specify the range of ports that can be used for gdb-server connections. Both - options need to be specified simultaneously. Overrides --gdbserver-port. + Define a port to be used for gdb-server connections. This port is used for + multiple connections. .. option:: --port-offset diff --git a/lldb/docs/resources/qemu-testing.rst b/lldb/docs/resources/qemu-testing.rst index 51a30b11717a87..e102f84a1d31f4 100644 --- a/lldb/docs/resources/qemu-testing.rst +++ b/lldb/docs/resources/qemu-testing.rst @@ -149,7 +149,6 @@ to the host (refer to QEMU's manuals for the specific options). * At least one to connect to the intial ``lldb-server``. * One more if you want to use ``lldb-server`` in ``platform mode``, and have it start a ``gdbserver`` instance for you. -* A bunch more if you want to run tests against the ``lldb-server`` platform. If you are doing either of the latter 2 you should also restrict what ports ``lldb-server tries`` to use, otherwise it will randomly pick one that is almost @@ -157,22 +156,14 @@ certainly not forwarded. An example of this is shown below. :: - $ lldb-server plaform --server --listen 0.0.0.0:54321 \ ---min-gdbserver-port 49140 --max-gdbserver-port 49150 + $ lldb-server plaform --server --listen 0.0.0.0:54321 --gdbserver-port 49140 The result of this is that: * ``lldb-server`` platform mode listens externally on port ``54321``. -* When it is asked to start a new gdbserver mode instance, it will use a port - in the range ``49140`` to ``49150``. +* When it is asked to start a new gdbserver mode instance, it will use the port + ``49140``. -Your VM configuration should have ports ``54321``, and ``49140`` to ``49150`` -forwarded for this to work. - -.. note:: - These options are used to create a "port map" within ``lldb-server``. - Unfortunately this map is not cleaned up on Windows on connection close, - and across a few uses you may run out of valid ports. To work around this, - restart the platform every so often, especially after running a set of tests. - This is tracked here: https://github.com/llvm/llvm-project/issues/90923 +Your VM configuration should have ports ``54321`` and ``49140`` forwarded for +this to work. diff --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h index 304a91bdf6741b..4c2f07b796d615 100644 --- a/lldb/include/lldb/Host/Socket.h +++ b/
[Lldb-commits] [lldb] [lldb/linux] Make truncated reads work (PR #106532)
https://github.com/clayborg approved this pull request. https://github.com/llvm/llvm-project/pull/106532 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Removed gdbserver ports map from lldb-server (PR #104238)
slydiman wrote: I have updated the patch. Note all changes in Socket.* and TCPSocket.cpp will go away after merging #106640. The class Acceptor uses the MainLoop and contains the own list of listen sockets. Please review. Thanks. https://github.com/llvm/llvm-project/pull/104238 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Removed gdbserver ports map from lldb-server (PR #104238)
https://github.com/slydiman updated https://github.com/llvm/llvm-project/pull/104238 >From d0674017bb80a4abea9a7ad4a98ada2794e77221 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Fri, 30 Aug 2024 01:08:24 +0400 Subject: [PATCH] [lldb] Removed gdbserver ports map from lldb-server Listen to gdbserver-port, accept the connection and run lldb-server gdbserver --fd on all platforms. Refactored Acceptor to listen on 2 ports in the main thread. Parameters --min-gdbserver-port and --max-gdbserver-port are deprecated now. This is the part 2 of #101283. Fixes #97537, fixes #101475. --- lldb/docs/man/lldb-server.rst | 11 +- lldb/docs/resources/qemu-testing.rst | 19 +- lldb/include/lldb/Host/Socket.h | 16 +- lldb/source/Host/common/Socket.cpp| 24 +- lldb/source/Host/common/TCPSocket.cpp | 29 +- .../posix/ConnectionFileDescriptorPosix.cpp | 21 +- .../gdb-remote/GDBRemoteCommunication.cpp | 45 +-- .../gdb-remote/GDBRemoteCommunication.h | 8 +- .../GDBRemoteCommunicationServerPlatform.cpp | 287 ++ .../GDBRemoteCommunicationServerPlatform.h| 82 + .../Process/gdb-remote/ProcessGDBRemote.cpp | 2 +- .../TestPlatformLaunchGDBServer.py| 12 +- .../Shell/lldb-server/TestGdbserverPort.test | 4 - lldb/tools/lldb-server/Acceptor.cpp | 237 --- lldb/tools/lldb-server/Acceptor.h | 43 ++- lldb/tools/lldb-server/lldb-gdbserver.cpp | 23 +- lldb/tools/lldb-server/lldb-platform.cpp | 199 ++-- .../Process/gdb-remote/CMakeLists.txt | 1 - .../Process/gdb-remote/PortMapTest.cpp| 115 --- .../tools/lldb-server/tests/LLGSTest.cpp | 4 - .../tools/lldb-server/tests/TestClient.cpp| 4 - .../tools/lldb-server/tests/TestClient.h | 4 + 22 files changed, 554 insertions(+), 636 deletions(-) delete mode 100644 lldb/test/Shell/lldb-server/TestGdbserverPort.test delete mode 100644 lldb/unittests/Process/gdb-remote/PortMapTest.cpp diff --git a/lldb/docs/man/lldb-server.rst b/lldb/docs/man/lldb-server.rst index a67c00b305f6d2..31f5360df5e23e 100644 --- a/lldb/docs/man/lldb-server.rst +++ b/lldb/docs/man/lldb-server.rst @@ -147,15 +147,8 @@ GDB-SERVER CONNECTIONS .. option:: --gdbserver-port - Define a port to be used for gdb-server connections. Can be specified multiple - times to allow multiple ports. Has no effect if --min-gdbserver-port - and --max-gdbserver-port are specified. - -.. option:: --min-gdbserver-port -.. option:: --max-gdbserver-port - - Specify the range of ports that can be used for gdb-server connections. Both - options need to be specified simultaneously. Overrides --gdbserver-port. + Define a port to be used for gdb-server connections. This port is used for + multiple connections. .. option:: --port-offset diff --git a/lldb/docs/resources/qemu-testing.rst b/lldb/docs/resources/qemu-testing.rst index 51a30b11717a87..e102f84a1d31f4 100644 --- a/lldb/docs/resources/qemu-testing.rst +++ b/lldb/docs/resources/qemu-testing.rst @@ -149,7 +149,6 @@ to the host (refer to QEMU's manuals for the specific options). * At least one to connect to the intial ``lldb-server``. * One more if you want to use ``lldb-server`` in ``platform mode``, and have it start a ``gdbserver`` instance for you. -* A bunch more if you want to run tests against the ``lldb-server`` platform. If you are doing either of the latter 2 you should also restrict what ports ``lldb-server tries`` to use, otherwise it will randomly pick one that is almost @@ -157,22 +156,14 @@ certainly not forwarded. An example of this is shown below. :: - $ lldb-server plaform --server --listen 0.0.0.0:54321 \ ---min-gdbserver-port 49140 --max-gdbserver-port 49150 + $ lldb-server plaform --server --listen 0.0.0.0:54321 --gdbserver-port 49140 The result of this is that: * ``lldb-server`` platform mode listens externally on port ``54321``. -* When it is asked to start a new gdbserver mode instance, it will use a port - in the range ``49140`` to ``49150``. +* When it is asked to start a new gdbserver mode instance, it will use the port + ``49140``. -Your VM configuration should have ports ``54321``, and ``49140`` to ``49150`` -forwarded for this to work. - -.. note:: - These options are used to create a "port map" within ``lldb-server``. - Unfortunately this map is not cleaned up on Windows on connection close, - and across a few uses you may run out of valid ports. To work around this, - restart the platform every so often, especially after running a set of tests. - This is tracked here: https://github.com/llvm/llvm-project/issues/90923 +Your VM configuration should have ports ``54321`` and ``49140`` forwarded for +this to work. diff --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h index 304a91bdf6741b..4c2f07b796d615 100644 --- a/lldb/include/lldb/Host/Socket.h +++ b