[Lldb-commits] [lldb] 51e7257 - [lldb] Fix nondeterminism in DWARFIndexCachingTest
Author: Pavel Labath Date: 2022-05-03T10:28:47+02:00 New Revision: 51e72570d7e163d03ff211b7127899a1efd08174 URL: https://github.com/llvm/llvm-project/commit/51e72570d7e163d03ff211b7127899a1efd08174 DIFF: https://github.com/llvm/llvm-project/commit/51e72570d7e163d03ff211b7127899a1efd08174.diff LOG: [lldb] Fix nondeterminism in DWARFIndexCachingTest The entries in the input map need to be sorted as well, as there's no guarantee that the entries (ConstStrings) will be inserted in the proper order. Added: Modified: lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp Removed: diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp b/lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp index 0fb7f46068be7..361e529e71645 100644 --- a/lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp +++ b/lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp @@ -67,7 +67,7 @@ static void EncodeDecode(const NameToDIE &object, ByteOrder byte_order) { NameToDIE decoded_object; offset_t data_offset = 0; decoded_object.Decode(data, &data_offset, strtab_reader); - EXPECT_TRUE(object == decoded_object); + EXPECT_EQ(object, decoded_object); } static void EncodeDecode(const NameToDIE &object) { @@ -83,6 +83,7 @@ TEST(DWARFIndexCachingTest, NameToDIEEncodeDecode) { DIERef(llvm::None, DIERef::Section::DebugInfo, 0x11223344)); map.Insert(ConstString("workd"), DIERef(100, DIERef::Section::DebugInfo, 0x11223344)); + map.Finalize(); // Make sure a valid NameToDIE map encodes and decodes correctly. EncodeDecode(map); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124760: [lldb] Fix ppc64 detection in lldb
serge-sans-paille updated this revision to Diff 426620. serge-sans-paille added a comment. Fix nits CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124760/new/ https://reviews.llvm.org/D124760 Files: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/source/Utility/ArchSpec.cpp lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py lldb/test/API/functionalities/postmortem/elf-core/linux-ppc64.core lldb/test/API/functionalities/postmortem/elf-core/linux-ppc64.out Index: lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py === --- lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -24,12 +24,14 @@ _i386_pid = 32306 _x86_64_pid = 32259 _s390x_pid = 1045 +_ppc64_pid = 28146 _ppc64le_pid = 28147 _aarch64_regions = 4 _i386_regions = 4 _x86_64_regions = 5 _s390x_regions = 2 +_ppc64_regions = 2 _ppc64le_regions = 2 @skipIfLLVMTargetMissing("AArch64") @@ -49,6 +51,12 @@ self.do_test("linux-ppc64le", self._ppc64le_pid, self._ppc64le_regions, "linux-ppc64le.ou") +@skipIfLLVMTargetMissing("PowerPC") +def test_ppc64(self): +"""Test that lldb can read the process information from an ppc64 linux core file.""" +self.do_test("linux-ppc64", self._ppc64_pid, self._ppc64_regions, + "linux-ppc64.ou") + @skipIfLLVMTargetMissing("X86") def test_x86_64(self): """Test that lldb can read the process information from an x86_64 linux core file.""" Index: lldb/source/Utility/ArchSpec.cpp === --- lldb/source/Utility/ArchSpec.cpp +++ lldb/source/Utility/ArchSpec.cpp @@ -358,10 +358,10 @@ 0xu, 0xu}, // Intel MCU // FIXME: is this correct? {ArchSpec::eCore_ppc_generic, llvm::ELF::EM_PPC, LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // PowerPC -{ArchSpec::eCore_ppc64le_generic, llvm::ELF::EM_PPC64, LLDB_INVALID_CPUTYPE, - 0xu, 0xu}, // PowerPC64le -{ArchSpec::eCore_ppc64_generic, llvm::ELF::EM_PPC64, LLDB_INVALID_CPUTYPE, - 0xu, 0xu}, // PowerPC64 +{ArchSpec::eCore_ppc64le_generic, llvm::ELF::EM_PPC64, + ArchSpec::eCore_ppc64le_generic, 0xu, 0xu}, // PowerPC64le +{ArchSpec::eCore_ppc64_generic, llvm::ELF::EM_PPC64, + ArchSpec::eCore_ppc64_generic, 0xu, 0xu}, // PowerPC64 {ArchSpec::eCore_arm_generic, llvm::ELF::EM_ARM, LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // ARM {ArchSpec::eCore_arm_aarch64, llvm::ELF::EM_AARCH64, LLDB_INVALID_CPUTYPE, @@ -400,8 +400,8 @@ LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // HEXAGON {ArchSpec::eCore_arc, llvm::ELF::EM_ARC_COMPACT2, LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // ARC -{ArchSpec::eCore_avr, llvm::ELF::EM_AVR, LLDB_INVALID_CPUTYPE, - 0xu, 0xu}, // AVR +{ArchSpec::eCore_avr, llvm::ELF::EM_AVR, LLDB_INVALID_CPUTYPE, 0xu, + 0xu}, // AVR {ArchSpec::eCore_riscv32, llvm::ELF::EM_RISCV, ArchSpec::eRISCVSubType_riscv32, 0xu, 0xu}, // riscv32 {ArchSpec::eCore_riscv64, llvm::ELF::EM_RISCV, Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp === --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -310,9 +310,19 @@ } } +static uint32_t ppc64VariantFromElfFlags(const elf::ELFHeader &header) { + uint32_t endian = header.e_ident[EI_DATA]; + if (endian == ELFDATA2LSB) +return ArchSpec::eCore_ppc64le_generic; + else +return ArchSpec::eCore_ppc64_generic; +} + static uint32_t subTypeFromElfHeader(const elf::ELFHeader &header) { if (header.e_machine == llvm::ELF::EM_MIPS) return mipsVariantFromElfFlags(header); + else if (header.e_machine == llvm::ELF::EM_PPC64) +return ppc64VariantFromElfFlags(header); else if (header.e_machine == llvm::ELF::EM_RISCV) return riscvVariantFromElfFlags(header); Index: lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py === --- lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -24,12 +24,14 @@ _i386_pid = 32306 _x86_64_pid = 32259 _s390x_pid = 1045 +_ppc64_pid = 28146 _ppc64le_pid = 28147 _aarch64_regions = 4 _i386_regions = 4 _x86_64_regions = 5 _s390x_regions = 2 +_ppc64_regions = 2 _ppc64le_regions = 2 @skipIfLLVMTargetMissing("AArch64") @@ -49,6 +51,12 @@ self.do_test("linux-ppc64le
[Lldb-commits] [lldb] f114f00 - [lldb] Fix ppc64 detection in lldb
Author: serge-sans-paille Date: 2022-05-03T12:17:23+02:00 New Revision: f114f009486816ed4b3bf984f0fbbb8fc80914f6 URL: https://github.com/llvm/llvm-project/commit/f114f009486816ed4b3bf984f0fbbb8fc80914f6 DIFF: https://github.com/llvm/llvm-project/commit/f114f009486816ed4b3bf984f0fbbb8fc80914f6.diff LOG: [lldb] Fix ppc64 detection in lldb Currently, ppc64le and ppc64 (defaulting to big endian) have the same descriptor, thus the linear scan always return ppc64le. Handle that through subtype. Differential Revision: https://reviews.llvm.org/D124760 Added: lldb/test/API/functionalities/postmortem/elf-core/linux-ppc64.core lldb/test/API/functionalities/postmortem/elf-core/linux-ppc64.out Modified: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/source/Utility/ArchSpec.cpp lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py Removed: diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 684d070c54d26..28ccfbe3d6e64 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -310,9 +310,19 @@ static uint32_t riscvVariantFromElfFlags(const elf::ELFHeader &header) { } } +static uint32_t ppc64VariantFromElfFlags(const elf::ELFHeader &header) { + uint32_t endian = header.e_ident[EI_DATA]; + if (endian == ELFDATA2LSB) +return ArchSpec::eCore_ppc64le_generic; + else +return ArchSpec::eCore_ppc64_generic; +} + static uint32_t subTypeFromElfHeader(const elf::ELFHeader &header) { if (header.e_machine == llvm::ELF::EM_MIPS) return mipsVariantFromElfFlags(header); + else if (header.e_machine == llvm::ELF::EM_PPC64) +return ppc64VariantFromElfFlags(header); else if (header.e_machine == llvm::ELF::EM_RISCV) return riscvVariantFromElfFlags(header); diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp index 963005b5cdfa7..c6feacfc7c1e6 100644 --- a/lldb/source/Utility/ArchSpec.cpp +++ b/lldb/source/Utility/ArchSpec.cpp @@ -358,10 +358,10 @@ static const ArchDefinitionEntry g_elf_arch_entries[] = { 0xu, 0xu}, // Intel MCU // FIXME: is this correct? {ArchSpec::eCore_ppc_generic, llvm::ELF::EM_PPC, LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // PowerPC -{ArchSpec::eCore_ppc64le_generic, llvm::ELF::EM_PPC64, LLDB_INVALID_CPUTYPE, - 0xu, 0xu}, // PowerPC64le -{ArchSpec::eCore_ppc64_generic, llvm::ELF::EM_PPC64, LLDB_INVALID_CPUTYPE, - 0xu, 0xu}, // PowerPC64 +{ArchSpec::eCore_ppc64le_generic, llvm::ELF::EM_PPC64, + ArchSpec::eCore_ppc64le_generic, 0xu, 0xu}, // PowerPC64le +{ArchSpec::eCore_ppc64_generic, llvm::ELF::EM_PPC64, + ArchSpec::eCore_ppc64_generic, 0xu, 0xu}, // PowerPC64 {ArchSpec::eCore_arm_generic, llvm::ELF::EM_ARM, LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // ARM {ArchSpec::eCore_arm_aarch64, llvm::ELF::EM_AARCH64, LLDB_INVALID_CPUTYPE, @@ -400,8 +400,8 @@ static const ArchDefinitionEntry g_elf_arch_entries[] = { LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // HEXAGON {ArchSpec::eCore_arc, llvm::ELF::EM_ARC_COMPACT2, LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // ARC -{ArchSpec::eCore_avr, llvm::ELF::EM_AVR, LLDB_INVALID_CPUTYPE, - 0xu, 0xu}, // AVR +{ArchSpec::eCore_avr, llvm::ELF::EM_AVR, LLDB_INVALID_CPUTYPE, 0xu, + 0xu}, // AVR {ArchSpec::eCore_riscv32, llvm::ELF::EM_RISCV, ArchSpec::eRISCVSubType_riscv32, 0xu, 0xu}, // riscv32 {ArchSpec::eCore_riscv64, llvm::ELF::EM_RISCV, diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py index d1948b6752753..14da7f6051e62 100644 --- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -24,12 +24,14 @@ class LinuxCoreTestCase(TestBase): _i386_pid = 32306 _x86_64_pid = 32259 _s390x_pid = 1045 +_ppc64_pid = 28146 _ppc64le_pid = 28147 _aarch64_regions = 4 _i386_regions = 4 _x86_64_regions = 5 _s390x_regions = 2 +_ppc64_regions = 2 _ppc64le_regions = 2 @skipIfLLVMTargetMissing("AArch64") @@ -49,6 +51,12 @@ def test_ppc64le(self): self.do_test("linux-ppc64le", self._ppc64le_pid, self._ppc64le_regions, "linux-ppc64le.ou") +@skipIfLLVMTargetMissing("PowerPC") +def test_ppc64(self): +"""Test that lldb can read the process information from an ppc64 linux core file.""" +self.do_test("linux-ppc64", self._ppc64_pid, self._ppc64_regions, + "linux-ppc64.
[Lldb-commits] [PATCH] D124760: [lldb] Fix ppc64 detection in lldb
This revision was automatically updated to reflect the committed changes. Closed by commit rGf114f0094868: [lldb] Fix ppc64 detection in lldb (authored by serge-sans-paille). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124760/new/ https://reviews.llvm.org/D124760 Files: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/source/Utility/ArchSpec.cpp lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py lldb/test/API/functionalities/postmortem/elf-core/linux-ppc64.core lldb/test/API/functionalities/postmortem/elf-core/linux-ppc64.out Index: lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py === --- lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -24,12 +24,14 @@ _i386_pid = 32306 _x86_64_pid = 32259 _s390x_pid = 1045 +_ppc64_pid = 28146 _ppc64le_pid = 28147 _aarch64_regions = 4 _i386_regions = 4 _x86_64_regions = 5 _s390x_regions = 2 +_ppc64_regions = 2 _ppc64le_regions = 2 @skipIfLLVMTargetMissing("AArch64") @@ -49,6 +51,12 @@ self.do_test("linux-ppc64le", self._ppc64le_pid, self._ppc64le_regions, "linux-ppc64le.ou") +@skipIfLLVMTargetMissing("PowerPC") +def test_ppc64(self): +"""Test that lldb can read the process information from an ppc64 linux core file.""" +self.do_test("linux-ppc64", self._ppc64_pid, self._ppc64_regions, + "linux-ppc64.ou") + @skipIfLLVMTargetMissing("X86") def test_x86_64(self): """Test that lldb can read the process information from an x86_64 linux core file.""" Index: lldb/source/Utility/ArchSpec.cpp === --- lldb/source/Utility/ArchSpec.cpp +++ lldb/source/Utility/ArchSpec.cpp @@ -358,10 +358,10 @@ 0xu, 0xu}, // Intel MCU // FIXME: is this correct? {ArchSpec::eCore_ppc_generic, llvm::ELF::EM_PPC, LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // PowerPC -{ArchSpec::eCore_ppc64le_generic, llvm::ELF::EM_PPC64, LLDB_INVALID_CPUTYPE, - 0xu, 0xu}, // PowerPC64le -{ArchSpec::eCore_ppc64_generic, llvm::ELF::EM_PPC64, LLDB_INVALID_CPUTYPE, - 0xu, 0xu}, // PowerPC64 +{ArchSpec::eCore_ppc64le_generic, llvm::ELF::EM_PPC64, + ArchSpec::eCore_ppc64le_generic, 0xu, 0xu}, // PowerPC64le +{ArchSpec::eCore_ppc64_generic, llvm::ELF::EM_PPC64, + ArchSpec::eCore_ppc64_generic, 0xu, 0xu}, // PowerPC64 {ArchSpec::eCore_arm_generic, llvm::ELF::EM_ARM, LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // ARM {ArchSpec::eCore_arm_aarch64, llvm::ELF::EM_AARCH64, LLDB_INVALID_CPUTYPE, @@ -400,8 +400,8 @@ LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // HEXAGON {ArchSpec::eCore_arc, llvm::ELF::EM_ARC_COMPACT2, LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // ARC -{ArchSpec::eCore_avr, llvm::ELF::EM_AVR, LLDB_INVALID_CPUTYPE, - 0xu, 0xu}, // AVR +{ArchSpec::eCore_avr, llvm::ELF::EM_AVR, LLDB_INVALID_CPUTYPE, 0xu, + 0xu}, // AVR {ArchSpec::eCore_riscv32, llvm::ELF::EM_RISCV, ArchSpec::eRISCVSubType_riscv32, 0xu, 0xu}, // riscv32 {ArchSpec::eCore_riscv64, llvm::ELF::EM_RISCV, Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp === --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -310,9 +310,19 @@ } } +static uint32_t ppc64VariantFromElfFlags(const elf::ELFHeader &header) { + uint32_t endian = header.e_ident[EI_DATA]; + if (endian == ELFDATA2LSB) +return ArchSpec::eCore_ppc64le_generic; + else +return ArchSpec::eCore_ppc64_generic; +} + static uint32_t subTypeFromElfHeader(const elf::ELFHeader &header) { if (header.e_machine == llvm::ELF::EM_MIPS) return mipsVariantFromElfFlags(header); + else if (header.e_machine == llvm::ELF::EM_PPC64) +return ppc64VariantFromElfFlags(header); else if (header.e_machine == llvm::ELF::EM_RISCV) return riscvVariantFromElfFlags(header); Index: lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py === --- lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -24,12 +24,14 @@ _i386_pid = 32306 _x86_64_pid = 32259 _s390x_pid = 1045 +_ppc64_pid = 28146 _ppc64le_pid = 28147 _aarch64_regions = 4 _i386_regions = 4 _x86_64_regions = 5 _s390x_regions = 2 +_ppc64_regions = 2 _ppc64
[Lldb-commits] [PATCH] D124673: [llvm][lldb] use FindLibEdit.cmake everywhere
upsj updated this revision to Diff 426628. upsj added a comment. fix standalone builds Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124673/new/ https://reviews.llvm.org/D124673 Files: cmake/Modules/FindLibEdit.cmake lldb/CMakeLists.txt lldb/cmake/modules/FindLibEdit.cmake lldb/source/Core/CMakeLists.txt lldb/source/Host/CMakeLists.txt lldb/source/Interpreter/CMakeLists.txt lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt llvm/cmake/config-ix.cmake llvm/lib/LineEditor/CMakeLists.txt llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn Index: llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn === --- llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn +++ llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn @@ -142,7 +142,7 @@ # list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS}) # endif() # if (LLDB_ENABLE_LIBEDIT) - # list(APPEND EXTRA_LIBS ${LibEdit_LIBRARIES}) + # list(APPEND EXTRA_LIBS LibEdit::LibEdit) # endif() # if (LLDB_ENABLE_LZMA) # list(APPEND EXTRA_LIBS ${LIBLZMA_LIBRARIES}) Index: llvm/lib/LineEditor/CMakeLists.txt === --- llvm/lib/LineEditor/CMakeLists.txt +++ llvm/lib/LineEditor/CMakeLists.txt @@ -1,5 +1,5 @@ if(HAVE_LIBEDIT) - set(link_libs edit) + set(link_libs LibEdit::LibEdit) endif() add_llvm_component_library(LLVMLineEditor Index: llvm/cmake/config-ix.cmake === --- llvm/cmake/config-ix.cmake +++ llvm/cmake/config-ix.cmake @@ -64,7 +64,6 @@ check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT) check_include_file(mach/mach.h HAVE_MACH_MACH_H) -check_include_file(histedit.h HAVE_HISTEDIT_H) check_include_file(CrashReporterClient.h HAVE_CRASHREPORTERCLIENT_H) if(APPLE) include(CheckCSourceCompiles) @@ -184,8 +183,9 @@ # Don't look for these libraries on Windows. if (NOT PURE_WINDOWS) # Skip libedit if using ASan as it contains memory leaks. -if (LLVM_ENABLE_LIBEDIT AND HAVE_HISTEDIT_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*") - check_library_exists(edit el_init "" HAVE_LIBEDIT) +if (LLVM_ENABLE_LIBEDIT AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*") + find_package(LibEdit) + set(HAVE_LIBEDIT ${LibEdit_FOUND}) else() set(HAVE_LIBEDIT 0) endif() Index: lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt === --- lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt +++ lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt @@ -10,7 +10,7 @@ if (LLDB_ENABLE_LIBEDIT) - list(APPEND LLDB_LIBEDIT_LIBS ${LibEdit_LIBRARIES}) + list(APPEND LLDB_LIBEDIT_LIBS LibEdit::LibEdit) endif() add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN @@ -35,9 +35,3 @@ LINK_COMPONENTS Support ) - -if (LLDB_ENABLE_LIBEDIT) - target_include_directories(lldbPluginScriptInterpreterPython PUBLIC -${LibEdit_INCLUDE_DIRS} - ) -endif() Index: lldb/source/Interpreter/CMakeLists.txt === --- lldb/source/Interpreter/CMakeLists.txt +++ lldb/source/Interpreter/CMakeLists.txt @@ -68,6 +68,3 @@ LLDBInterpreterPropertiesGen LLDBInterpreterPropertiesEnumGen) -if (LLDB_ENABLE_LIBEDIT) - target_include_directories(lldbInterpreter PRIVATE ${LibEdit_INCLUDE_DIRS}) -endif() Index: lldb/source/Host/CMakeLists.txt === --- lldb/source/Host/CMakeLists.txt +++ lldb/source/Host/CMakeLists.txt @@ -141,7 +141,7 @@ list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS}) endif() if (LLDB_ENABLE_LIBEDIT) - list(APPEND EXTRA_LIBS ${LibEdit_LIBRARIES}) + list(APPEND EXTRA_LIBS LibEdit::LibEdit) endif() if (LLDB_ENABLE_LZMA) list(APPEND EXTRA_LIBS ${LIBLZMA_LIBRARIES}) @@ -151,7 +151,7 @@ endif() if (LLDB_ENABLE_LIBEDIT) - list(APPEND LLDB_LIBEDIT_LIBS ${LibEdit_LIBRARIES}) + list(APPEND LLDB_LIBEDIT_LIBS LibEdit::LibEdit) if (LLVM_BUILD_STATIC) list(APPEND LLDB_SYSTEM_LIBS gpm) endif() @@ -171,6 +171,3 @@ Support ) -if (LLDB_ENABLE_LIBEDIT) - target_include_directories(lldbHost PUBLIC ${LibEdit_INCLUDE_DIRS}) -endif() Index: lldb/source/Core/CMakeLists.txt === --- lldb/source/Core/CMakeLists.txt +++ lldb/source/Core/CMakeLists.txt @@ -103,10 +103,6 @@ # TODO: Remove once we have better layering set_target_properties(lldbCore PROPERTIES LINK_INTERFACE_MULTIPLICITY 5) -if (LLDB_ENABLE_LIBEDIT) - target_include_directories(lldbCore PRIVATE ${LibEdit_INCLUDE_DIRS}) -endif() - if (LLDB_ENABLE_CURSES) target_include_directories(lldbCore PRIVATE ${CURSES_INCLUDE_DIRS}) endif() Index: lldb/CMakeLists.txt =
[Lldb-commits] [lldb] 7667d80 - Revert "[lldb] Fix ppc64 detection in lldb"
Author: David Spickett Date: 2022-05-03T13:24:10Z New Revision: 7667d805948e8049420b01c92f84c56528b42567 URL: https://github.com/llvm/llvm-project/commit/7667d805948e8049420b01c92f84c56528b42567 DIFF: https://github.com/llvm/llvm-project/commit/7667d805948e8049420b01c92f84c56528b42567.diff LOG: Revert "[lldb] Fix ppc64 detection in lldb" This reverts commit f114f009486816ed4b3bf984f0fbbb8fc80914f6. Due to hitting an assert on our lldb bots: https://lab.llvm.org/buildbot/#/builders/96/builds/22715 ../llvm-project/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp:170: virtual lldb::RegisterContextSP ThreadElfCore::CreateRegisterContextForFrame( lldb_private::StackFrame *): Assertion `false && "Architecture or OS not supported"' failed. Added: Modified: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/source/Utility/ArchSpec.cpp lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py Removed: lldb/test/API/functionalities/postmortem/elf-core/linux-ppc64.core lldb/test/API/functionalities/postmortem/elf-core/linux-ppc64.out diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 28ccfbe3d6e64..684d070c54d26 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -310,19 +310,9 @@ static uint32_t riscvVariantFromElfFlags(const elf::ELFHeader &header) { } } -static uint32_t ppc64VariantFromElfFlags(const elf::ELFHeader &header) { - uint32_t endian = header.e_ident[EI_DATA]; - if (endian == ELFDATA2LSB) -return ArchSpec::eCore_ppc64le_generic; - else -return ArchSpec::eCore_ppc64_generic; -} - static uint32_t subTypeFromElfHeader(const elf::ELFHeader &header) { if (header.e_machine == llvm::ELF::EM_MIPS) return mipsVariantFromElfFlags(header); - else if (header.e_machine == llvm::ELF::EM_PPC64) -return ppc64VariantFromElfFlags(header); else if (header.e_machine == llvm::ELF::EM_RISCV) return riscvVariantFromElfFlags(header); diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp index c6feacfc7c1e6..963005b5cdfa7 100644 --- a/lldb/source/Utility/ArchSpec.cpp +++ b/lldb/source/Utility/ArchSpec.cpp @@ -358,10 +358,10 @@ static const ArchDefinitionEntry g_elf_arch_entries[] = { 0xu, 0xu}, // Intel MCU // FIXME: is this correct? {ArchSpec::eCore_ppc_generic, llvm::ELF::EM_PPC, LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // PowerPC -{ArchSpec::eCore_ppc64le_generic, llvm::ELF::EM_PPC64, - ArchSpec::eCore_ppc64le_generic, 0xu, 0xu}, // PowerPC64le -{ArchSpec::eCore_ppc64_generic, llvm::ELF::EM_PPC64, - ArchSpec::eCore_ppc64_generic, 0xu, 0xu}, // PowerPC64 +{ArchSpec::eCore_ppc64le_generic, llvm::ELF::EM_PPC64, LLDB_INVALID_CPUTYPE, + 0xu, 0xu}, // PowerPC64le +{ArchSpec::eCore_ppc64_generic, llvm::ELF::EM_PPC64, LLDB_INVALID_CPUTYPE, + 0xu, 0xu}, // PowerPC64 {ArchSpec::eCore_arm_generic, llvm::ELF::EM_ARM, LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // ARM {ArchSpec::eCore_arm_aarch64, llvm::ELF::EM_AARCH64, LLDB_INVALID_CPUTYPE, @@ -400,8 +400,8 @@ static const ArchDefinitionEntry g_elf_arch_entries[] = { LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // HEXAGON {ArchSpec::eCore_arc, llvm::ELF::EM_ARC_COMPACT2, LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // ARC -{ArchSpec::eCore_avr, llvm::ELF::EM_AVR, LLDB_INVALID_CPUTYPE, 0xu, - 0xu}, // AVR +{ArchSpec::eCore_avr, llvm::ELF::EM_AVR, LLDB_INVALID_CPUTYPE, + 0xu, 0xu}, // AVR {ArchSpec::eCore_riscv32, llvm::ELF::EM_RISCV, ArchSpec::eRISCVSubType_riscv32, 0xu, 0xu}, // riscv32 {ArchSpec::eCore_riscv64, llvm::ELF::EM_RISCV, diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py index 14da7f6051e62..d1948b6752753 100644 --- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -24,14 +24,12 @@ class LinuxCoreTestCase(TestBase): _i386_pid = 32306 _x86_64_pid = 32259 _s390x_pid = 1045 -_ppc64_pid = 28146 _ppc64le_pid = 28147 _aarch64_regions = 4 _i386_regions = 4 _x86_64_regions = 5 _s390x_regions = 2 -_ppc64_regions = 2 _ppc64le_regions = 2 @skipIfLLVMTargetMissing("AArch64") @@ -51,12 +49,6 @@ def test_ppc64le(self): self.do_test("linux-ppc64le", self._ppc64le_pid, self._ppc64le_regions, "linux-ppc64le.ou") -@skipIfLLVMTargetMissing("PowerPC") -def test_ppc64(self): -
[Lldb-commits] [PATCH] D124760: [lldb] Fix ppc64 detection in lldb
DavidSpickett added a comment. I reverted this due to an assert: https://lab.llvm.org/buildbot/#/builders/96/builds/22715/steps/6/logs/stdio (set cmake `LLVM_ENABLE_ASSERTIONS` to `ON`) I think you could just add PowerPC to the `if (!reg_interface` there but first time looking at the code I'm not sure of the consequences of that. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124760/new/ https://reviews.llvm.org/D124760 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ca0b416 - [lldb][NFC] Add more tests for GenerateOptionsUsage
Author: David Spickett Date: 2022-05-03T13:40:14Z New Revision: ca0b41665978d5efd8482188a0541342cb298031 URL: https://github.com/llvm/llvm-project/commit/ca0b41665978d5efd8482188a0541342cb298031 DIFF: https://github.com/llvm/llvm-project/commit/ca0b41665978d5efd8482188a0541342cb298031.diff LOG: [lldb][NFC] Add more tests for GenerateOptionsUsage This adds a few targeted tests to make sure that when refactoring this function later I don't break these properties. Some are tested in passing elsewhere but this makes it more obvious what went wrong when it fails. This doesn't cover everything the function does, I couldn't find any examples that would exercise some of the code. Reviewed By: jingham Differential Revision: https://reviews.llvm.org/D123500 Added: Modified: lldb/test/API/commands/help/TestHelp.py Removed: diff --git a/lldb/test/API/commands/help/TestHelp.py b/lldb/test/API/commands/help/TestHelp.py index 5bd85ddcf7062..49f83411413a9 100644 --- a/lldb/test/API/commands/help/TestHelp.py +++ b/lldb/test/API/commands/help/TestHelp.py @@ -243,3 +243,63 @@ def test_help_option_group_format_options_usage(self): "-f ( --format )", "The format to use for each of the value to be written.", "-s ( --size )", "The size in bytes to write from input file or each value."]) +@no_debug_info_test +def test_help_shows_optional_short_options(self): +"""Test that optional short options are printed and that they are in + alphabetical order with upper case options first.""" +self.expect("help memory read", +substrs=["memory read [-br]", "memory read [-AFLORTr]"]) +self.expect("help target modules lookup", +substrs=["target modules lookup [-Airv]"]) + +@no_debug_info_test +def test_help_shows_command_options_usage(self): +"""Test that we start the usage section with a specific line.""" +self.expect("help memory read", substrs=["Command Options Usage:\n memory read"]) + +@no_debug_info_test +def test_help_detailed_information_spacing(self): +"""Test that we put a break between the usage and the options help lines, + and between the options themselves.""" +self.expect("help memory read", substrs=[ +"[]\n\n --show-tags", +# Starts with the end of the show-tags line +"output).\n\n -A"]) + +@no_debug_info_test +def test_help_detailed_information_ordering(self): +"""Test that we order options alphabetically, upper case first.""" +# You could test this with a simple regex like: +# .*.*.* +# Except that that could pass sometimes even with shuffled output. +# This makes sure that doesn't happen. + +self.runCmd("help memory read") +got = self.res.GetOutput() +_, options_lines = got.split("Command Options Usage:") +options_lines = options_lines.lstrip().splitlines() + +# Skip over "memory read [-xyz] lines. +while("memory read" in options_lines[0]): +options_lines.pop(0) +# Plus the newline after that. +options_lines.pop(0) + +short_options = [] +for line in options_lines: +# Ignore line breaks and descriptions. +# (not stripping the line here in case some line of the descriptions +# happens to start with "-") +if not line or not line.startswith(" -"): +continue +# This apears at the end after the options. +if "This command takes options and free form arguments." in line: +break +line = line.strip() +# The order of -- only options is not enforced so ignore their position. +if not line.startswith("--"): +# Save its short char name. +short_options.append(line[1]) + +self.assertEqual(sorted(short_options), short_options, + "Short option help displayed in an incorrect order!") ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D123500: [lldb][NFC] Add more tests for GenerateOptionsUsage
This revision was automatically updated to reflect the committed changes. Closed by commit rGca0b41665978: [lldb][NFC] Add more tests for GenerateOptionsUsage (authored by DavidSpickett). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D123500/new/ https://reviews.llvm.org/D123500 Files: lldb/test/API/commands/help/TestHelp.py Index: lldb/test/API/commands/help/TestHelp.py === --- lldb/test/API/commands/help/TestHelp.py +++ lldb/test/API/commands/help/TestHelp.py @@ -243,3 +243,63 @@ "-f ( --format )", "The format to use for each of the value to be written.", "-s ( --size )", "The size in bytes to write from input file or each value."]) +@no_debug_info_test +def test_help_shows_optional_short_options(self): +"""Test that optional short options are printed and that they are in + alphabetical order with upper case options first.""" +self.expect("help memory read", +substrs=["memory read [-br]", "memory read [-AFLORTr]"]) +self.expect("help target modules lookup", +substrs=["target modules lookup [-Airv]"]) + +@no_debug_info_test +def test_help_shows_command_options_usage(self): +"""Test that we start the usage section with a specific line.""" +self.expect("help memory read", substrs=["Command Options Usage:\n memory read"]) + +@no_debug_info_test +def test_help_detailed_information_spacing(self): +"""Test that we put a break between the usage and the options help lines, + and between the options themselves.""" +self.expect("help memory read", substrs=[ +"[]\n\n --show-tags", +# Starts with the end of the show-tags line +"output).\n\n -A"]) + +@no_debug_info_test +def test_help_detailed_information_ordering(self): +"""Test that we order options alphabetically, upper case first.""" +# You could test this with a simple regex like: +# .*.*.* +# Except that that could pass sometimes even with shuffled output. +# This makes sure that doesn't happen. + +self.runCmd("help memory read") +got = self.res.GetOutput() +_, options_lines = got.split("Command Options Usage:") +options_lines = options_lines.lstrip().splitlines() + +# Skip over "memory read [-xyz] lines. +while("memory read" in options_lines[0]): +options_lines.pop(0) +# Plus the newline after that. +options_lines.pop(0) + +short_options = [] +for line in options_lines: +# Ignore line breaks and descriptions. +# (not stripping the line here in case some line of the descriptions +# happens to start with "-") +if not line or not line.startswith(" -"): +continue +# This apears at the end after the options. +if "This command takes options and free form arguments." in line: +break +line = line.strip() +# The order of -- only options is not enforced so ignore their position. +if not line.startswith("--"): +# Save its short char name. +short_options.append(line[1]) + +self.assertEqual(sorted(short_options), short_options, + "Short option help displayed in an incorrect order!") Index: lldb/test/API/commands/help/TestHelp.py === --- lldb/test/API/commands/help/TestHelp.py +++ lldb/test/API/commands/help/TestHelp.py @@ -243,3 +243,63 @@ "-f ( --format )", "The format to use for each of the value to be written.", "-s ( --size )", "The size in bytes to write from input file or each value."]) +@no_debug_info_test +def test_help_shows_optional_short_options(self): +"""Test that optional short options are printed and that they are in + alphabetical order with upper case options first.""" +self.expect("help memory read", +substrs=["memory read [-br]", "memory read [-AFLORTr]"]) +self.expect("help target modules lookup", +substrs=["target modules lookup [-Airv]"]) + +@no_debug_info_test +def test_help_shows_command_options_usage(self): +"""Test that we start the usage section with a specific line.""" +self.expect("help memory read", substrs=["Command Options Usage:\n memory read"]) + +@no_debug_info_test +def test_help_detailed_information_spacing(self): +"""Test that we put a break between the usage and the options help lines, + and between the options themselves.""" +self.expect("help memory read", substrs=[ +
[Lldb-commits] [PATCH] D123502: [lldb][NFC] Refactor printing of short options in help
DavidSpickett added a comment. > Were there any tests for the help output? If not, maybe we should add one. For these bits no, in fact I broke them without realising at first. Hence the tests in the other review as you saw, they'll be landed before this. Thanks for the reviews! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D123502/new/ https://reviews.llvm.org/D123502 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D123501: [lldb][NFC] Simplify part of Options::GenerateOptionUsage
This revision was automatically updated to reflect the committed changes. Closed by commit rG61f2d3074699: [lldb][NFC] Simplify part of Options::GenerateOptionUsage (authored by DavidSpickett). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D123501/new/ https://reviews.llvm.org/D123501 Files: lldb/source/Interpreter/Options.cpp Index: lldb/source/Interpreter/Options.cpp === --- lldb/source/Interpreter/Options.cpp +++ lldb/source/Interpreter/Options.cpp @@ -20,6 +20,7 @@ #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Target.h" #include "lldb/Utility/StreamString.h" +#include "llvm/ADT/STLExtras.h" using namespace lldb; using namespace lldb_private; @@ -540,63 +541,49 @@ // -short ( --long_name ) // help text -// This variable is used to keep track of which options' info we've printed -// out, because some options can be in more than one usage level, but we -// only want to print the long form of its information once. - -std::multimap options_seen; strm.IndentMore(5); -// Put the unique command options in a vector & sort it, so we can output -// them alphabetically (by short_option) when writing out detailed help for -// each option. - -i = 0; -for (auto &def : opt_defs) - options_seen.insert(std::make_pair(def.short_option, i++)); +// Put the command options in a sorted container, so we can output +// them alphabetically by short_option. +std::multimap options_ordered; +for (auto def : llvm::enumerate(opt_defs)) + options_ordered.insert( + std::make_pair(def.value().short_option, def.index())); -// Go through the unique'd and alphabetically sorted vector of options, -// find the table entry for each option and write out the detailed help -// information for that option. +// Go through each option, find the table entry and write out the detailed +// help information for that option. bool first_option_printed = false; -for (auto pos : options_seen) { - i = pos.second; - // Print out the help information for this option. - +for (auto pos : options_ordered) { // Put a newline separation between arguments if (first_option_printed) strm.EOL(); else first_option_printed = true; - CommandArgumentType arg_type = opt_defs[i].argument_type; - - StreamString arg_name_str; - arg_name_str.Printf("<%s>", CommandObject::GetArgumentName(arg_type)); + OptionDefinition opt_def = opt_defs[pos.second]; strm.Indent(); - if (opt_defs[i].short_option && opt_defs[i].HasShortOption()) { -PrintOption(opt_defs[i], eDisplayShortOption, nullptr, nullptr, false, + if (opt_def.short_option && opt_def.HasShortOption()) { +PrintOption(opt_def, eDisplayShortOption, nullptr, nullptr, false, strm); -PrintOption(opt_defs[i], eDisplayLongOption, " ( ", " )", false, strm); +PrintOption(opt_def, eDisplayLongOption, " ( ", " )", false, strm); } else { // Short option is not printable, just print long option -PrintOption(opt_defs[i], eDisplayLongOption, nullptr, nullptr, false, -strm); +PrintOption(opt_def, eDisplayLongOption, nullptr, nullptr, false, strm); } strm.EOL(); strm.IndentMore(5); - if (opt_defs[i].usage_text) -OutputFormattedUsageText(strm, opt_defs[i], screen_width); - if (!opt_defs[i].enum_values.empty()) { + if (opt_def.usage_text) +OutputFormattedUsageText(strm, opt_def, screen_width); + if (!opt_def.enum_values.empty()) { strm.Indent(); strm.Printf("Values: "); bool is_first = true; -for (const auto &enum_value : opt_defs[i].enum_values) { +for (const auto &enum_value : opt_def.enum_values) { if (is_first) { strm.Printf("%s", enum_value.string_value); is_first = false; Index: lldb/source/Interpreter/Options.cpp === --- lldb/source/Interpreter/Options.cpp +++ lldb/source/Interpreter/Options.cpp @@ -20,6 +20,7 @@ #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Target.h" #include "lldb/Utility/StreamString.h" +#include "llvm/ADT/STLExtras.h" using namespace lldb; using namespace lldb_private; @@ -540,63 +541,49 @@ // -short ( --long_name ) // help text -// This variable is used to keep track of which options' info we've printed -// out, because some options can be in more than one usage level, but we -// only want to print the long form of its information once. - -std::multimap options_seen; strm.IndentMore(5); -// Put the unique command options in a vector & sort it, so we can output -
[Lldb-commits] [lldb] 61f2d30 - [lldb][NFC] Simplify part of Options::GenerateOptionUsage
Author: David Spickett Date: 2022-05-03T14:32:26Z New Revision: 61f2d307469981d5563187d646c44f8731ecf367 URL: https://github.com/llvm/llvm-project/commit/61f2d307469981d5563187d646c44f8731ecf367 DIFF: https://github.com/llvm/llvm-project/commit/61f2d307469981d5563187d646c44f8731ecf367.diff LOG: [lldb][NFC] Simplify part of Options::GenerateOptionUsage Use llvm::enumerate, remove an unused arg name stream and replace repeated uses of indexing to get the option def. We could use map instead of multimap but I'm not 100% that would be NFC. All short options should be unique in theory. Depends on D123500 Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D123501 Added: Modified: lldb/source/Interpreter/Options.cpp Removed: diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp index feebe338bc9aa..d42a86e3b856c 100644 --- a/lldb/source/Interpreter/Options.cpp +++ b/lldb/source/Interpreter/Options.cpp @@ -20,6 +20,7 @@ #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Target.h" #include "lldb/Utility/StreamString.h" +#include "llvm/ADT/STLExtras.h" using namespace lldb; using namespace lldb_private; @@ -540,63 +541,49 @@ void Options::GenerateOptionUsage(Stream &strm, CommandObject *cmd, // -short ( --long_name ) // help text -// This variable is used to keep track of which options' info we've printed -// out, because some options can be in more than one usage level, but we -// only want to print the long form of its information once. - -std::multimap options_seen; strm.IndentMore(5); -// Put the unique command options in a vector & sort it, so we can output -// them alphabetically (by short_option) when writing out detailed help for -// each option. - -i = 0; -for (auto &def : opt_defs) - options_seen.insert(std::make_pair(def.short_option, i++)); +// Put the command options in a sorted container, so we can output +// them alphabetically by short_option. +std::multimap options_ordered; +for (auto def : llvm::enumerate(opt_defs)) + options_ordered.insert( + std::make_pair(def.value().short_option, def.index())); -// Go through the unique'd and alphabetically sorted vector of options, -// find the table entry for each option and write out the detailed help -// information for that option. +// Go through each option, find the table entry and write out the detailed +// help information for that option. bool first_option_printed = false; -for (auto pos : options_seen) { - i = pos.second; - // Print out the help information for this option. - +for (auto pos : options_ordered) { // Put a newline separation between arguments if (first_option_printed) strm.EOL(); else first_option_printed = true; - CommandArgumentType arg_type = opt_defs[i].argument_type; - - StreamString arg_name_str; - arg_name_str.Printf("<%s>", CommandObject::GetArgumentName(arg_type)); + OptionDefinition opt_def = opt_defs[pos.second]; strm.Indent(); - if (opt_defs[i].short_option && opt_defs[i].HasShortOption()) { -PrintOption(opt_defs[i], eDisplayShortOption, nullptr, nullptr, false, + if (opt_def.short_option && opt_def.HasShortOption()) { +PrintOption(opt_def, eDisplayShortOption, nullptr, nullptr, false, strm); -PrintOption(opt_defs[i], eDisplayLongOption, " ( ", " )", false, strm); +PrintOption(opt_def, eDisplayLongOption, " ( ", " )", false, strm); } else { // Short option is not printable, just print long option -PrintOption(opt_defs[i], eDisplayLongOption, nullptr, nullptr, false, -strm); +PrintOption(opt_def, eDisplayLongOption, nullptr, nullptr, false, strm); } strm.EOL(); strm.IndentMore(5); - if (opt_defs[i].usage_text) -OutputFormattedUsageText(strm, opt_defs[i], screen_width); - if (!opt_defs[i].enum_values.empty()) { + if (opt_def.usage_text) +OutputFormattedUsageText(strm, opt_def, screen_width); + if (!opt_def.enum_values.empty()) { strm.Indent(); strm.Printf("Values: "); bool is_first = true; -for (const auto &enum_value : opt_defs[i].enum_values) { +for (const auto &enum_value : opt_def.enum_values) { if (is_first) { strm.Printf("%s", enum_value.string_value); is_first = false; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D123502: [lldb][NFC] Refactor printing of short options in help
This revision was automatically updated to reflect the committed changes. Closed by commit rGcf05de7168b0: [lldb][NFC] Refactor printing of short options in help (authored by DavidSpickett). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D123502/new/ https://reviews.llvm.org/D123502 Files: lldb/source/Interpreter/Options.cpp Index: lldb/source/Interpreter/Options.cpp === --- lldb/source/Interpreter/Options.cpp +++ lldb/source/Interpreter/Options.cpp @@ -421,8 +421,6 @@ uint32_t num_option_sets = GetRequiredOptions().size(); - uint32_t i; - if (!only_print_args) { for (uint32_t opt_set = 0; opt_set < num_option_sets; ++opt_set) { uint32_t opt_set_mask; @@ -441,77 +439,46 @@ // single string. If a command has "-a" "-b" and "-c", this will show up // as [-abc] - std::set options; - std::set::const_iterator options_pos, options_end; - for (auto &def : opt_defs) { -if (def.usage_mask & opt_set_mask && def.HasShortOption()) { - // Add current option to the end of out_stream. + // We use a set here so that they will be sorted. + std::set required_options; + std::set optional_options; - if (def.required && def.option_has_arg == OptionParser::eNoArgument) { -options.insert(def.short_option); + for (auto &def : opt_defs) { +if (def.usage_mask & opt_set_mask && def.HasShortOption() && +def.option_has_arg == OptionParser::eNoArgument) { + if (def.required) { +required_options.insert(def.short_option); + } else { +optional_options.insert(def.short_option); } } } - if (!options.empty()) { -// We have some required options with no arguments + if (!required_options.empty()) { strm.PutCString(" -"); -for (i = 0; i < 2; ++i) - for (options_pos = options.begin(), options_end = options.end(); - options_pos != options_end; ++options_pos) { -if (i == 0 && ::islower(*options_pos)) - continue; -if (i == 1 && ::isupper(*options_pos)) - continue; -strm << (char)*options_pos; - } - } - - options.clear(); - for (auto &def : opt_defs) { -if (def.usage_mask & opt_set_mask && def.HasShortOption()) { - // Add current option to the end of out_stream. - - if (!def.required && - def.option_has_arg == OptionParser::eNoArgument) { -options.insert(def.short_option); - } -} +for (int short_option : required_options) + strm.PutChar(short_option); } - if (!options.empty()) { -// We have some required options with no arguments + if (!optional_options.empty()) { strm.PutCString(" [-"); -for (i = 0; i < 2; ++i) - for (options_pos = options.begin(), options_end = options.end(); - options_pos != options_end; ++options_pos) { -if (i == 0 && ::islower(*options_pos)) - continue; -if (i == 1 && ::isupper(*options_pos)) - continue; -strm << (char)*options_pos; - } +for (int short_option : optional_options) + strm.PutChar(short_option); strm.PutChar(']'); } // First go through and print the required options (list them up front). - for (auto &def : opt_defs) { -if (def.usage_mask & opt_set_mask && def.HasShortOption()) { - if (def.required && def.option_has_arg != OptionParser::eNoArgument) -PrintOption(def, eDisplayBestOption, " ", nullptr, true, strm); -} +if (def.usage_mask & opt_set_mask && def.HasShortOption() && +def.required && def.option_has_arg != OptionParser::eNoArgument) + PrintOption(def, eDisplayBestOption, " ", nullptr, true, strm); } // Now go through again, and this time only print the optional options. - for (auto &def : opt_defs) { -if (def.usage_mask & opt_set_mask) { - // Add current option to the end of out_stream. - - if (!def.required && def.option_has_arg != OptionParser::eNoArgument) -PrintOption(def, eDisplayBestOption, " ", nullptr, true, strm); -} +if (def.usage_mask & opt_set_mask && !def.required && +def.option_has_arg != OptionParser::eNoArgument) + PrintOption(def, eDisplayBestOption, " ", nullptr, true, strm); } if (args_str.GetSize() > 0) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] cf05de7 - [lldb][NFC] Refactor printing of short options in help
Author: David Spickett Date: 2022-05-03T15:18:39Z New Revision: cf05de7168b0ae2eaffdd6ab5a7c982bfa6da5c6 URL: https://github.com/llvm/llvm-project/commit/cf05de7168b0ae2eaffdd6ab5a7c982bfa6da5c6 DIFF: https://github.com/llvm/llvm-project/commit/cf05de7168b0ae2eaffdd6ab5a7c982bfa6da5c6.diff LOG: [lldb][NFC] Refactor printing of short options in help Instead of building a set twice for optional and required, build a set for each while walking the options once. Then take advantage of set being sorted meaning we don't have to enforce the upper/lower order ourselves. Just cleaned up the formatting on the later loops. Combined the if conditions and used a single line if. Depends on D123501 Reviewed By: jingham Differential Revision: https://reviews.llvm.org/D123502 Added: Modified: lldb/source/Interpreter/Options.cpp Removed: diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp index d42a86e3b856c..7d1f7667fb635 100644 --- a/lldb/source/Interpreter/Options.cpp +++ b/lldb/source/Interpreter/Options.cpp @@ -421,8 +421,6 @@ void Options::GenerateOptionUsage(Stream &strm, CommandObject *cmd, uint32_t num_option_sets = GetRequiredOptions().size(); - uint32_t i; - if (!only_print_args) { for (uint32_t opt_set = 0; opt_set < num_option_sets; ++opt_set) { uint32_t opt_set_mask; @@ -441,77 +439,46 @@ void Options::GenerateOptionUsage(Stream &strm, CommandObject *cmd, // single string. If a command has "-a" "-b" and "-c", this will show up // as [-abc] - std::set options; - std::set::const_iterator options_pos, options_end; - for (auto &def : opt_defs) { -if (def.usage_mask & opt_set_mask && def.HasShortOption()) { - // Add current option to the end of out_stream. + // We use a set here so that they will be sorted. + std::set required_options; + std::set optional_options; - if (def.required && def.option_has_arg == OptionParser::eNoArgument) { -options.insert(def.short_option); + for (auto &def : opt_defs) { +if (def.usage_mask & opt_set_mask && def.HasShortOption() && +def.option_has_arg == OptionParser::eNoArgument) { + if (def.required) { +required_options.insert(def.short_option); + } else { +optional_options.insert(def.short_option); } } } - if (!options.empty()) { -// We have some required options with no arguments + if (!required_options.empty()) { strm.PutCString(" -"); -for (i = 0; i < 2; ++i) - for (options_pos = options.begin(), options_end = options.end(); - options_pos != options_end; ++options_pos) { -if (i == 0 && ::islower(*options_pos)) - continue; -if (i == 1 && ::isupper(*options_pos)) - continue; -strm << (char)*options_pos; - } - } - - options.clear(); - for (auto &def : opt_defs) { -if (def.usage_mask & opt_set_mask && def.HasShortOption()) { - // Add current option to the end of out_stream. - - if (!def.required && - def.option_has_arg == OptionParser::eNoArgument) { -options.insert(def.short_option); - } -} +for (int short_option : required_options) + strm.PutChar(short_option); } - if (!options.empty()) { -// We have some required options with no arguments + if (!optional_options.empty()) { strm.PutCString(" [-"); -for (i = 0; i < 2; ++i) - for (options_pos = options.begin(), options_end = options.end(); - options_pos != options_end; ++options_pos) { -if (i == 0 && ::islower(*options_pos)) - continue; -if (i == 1 && ::isupper(*options_pos)) - continue; -strm << (char)*options_pos; - } +for (int short_option : optional_options) + strm.PutChar(short_option); strm.PutChar(']'); } // First go through and print the required options (list them up front). - for (auto &def : opt_defs) { -if (def.usage_mask & opt_set_mask && def.HasShortOption()) { - if (def.required && def.option_has_arg != OptionParser::eNoArgument) -PrintOption(def, eDisplayBestOption, " ", nullptr, true, strm); -} +if (def.usage_mask & opt_set_mask && def.HasShortOption() && +def.required && def.option_has_arg != OptionParser::eNoArgument) + PrintOption(def, eDisplayBestOption, " ", nullptr, true, strm); } // Now go through again, and this time only print the optional options. - for (auto &def : opt_defs) { -if (def.usage_mask & opt_set_mask) { - // Add current option to t
[Lldb-commits] [PATCH] D124858: [trace][intelpt] Support system-wide tracing [4] - Support per core tracing on lldb-server
wallace created this revision. Herald added a subscriber: mgorny. Herald added a project: All. wallace requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. This diffs implements per-core tracing on lldb-server. It also includes tests that ensure that tracing can be initiated from the client and that the jLLDBGetState ppacket returns the list of trace buffers per core. This doesn't include any decoder changes. Finally, this makes some little changes here and there improving the existing code. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D124858 Files: lldb/docs/lldb-gdb-remote.txt lldb/include/lldb/Utility/TraceGDBRemotePackets.h lldb/include/lldb/Utility/TraceIntelPTGDBRemotePackets.h lldb/include/lldb/lldb-types.h lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py lldb/source/Plugins/Process/Linux/CMakeLists.txt lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp lldb/source/Plugins/Process/Linux/IntelPTCollector.h lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.h lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.h lldb/source/Plugins/Process/Linux/Perf.cpp lldb/source/Plugins/Process/Linux/Perf.h lldb/source/Plugins/Process/Linux/Procfs.cpp lldb/source/Plugins/Process/Linux/Procfs.h lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp lldb/source/Plugins/Trace/intel-pt/TraceIntelPTOptions.td lldb/source/Target/Trace.cpp lldb/source/Utility/TraceGDBRemotePackets.cpp lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py Index: lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py === --- lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py +++ lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py @@ -30,6 +30,8 @@ self.expect("continue") self.expect("thread trace dump instructions", substrs=['main.cpp:4']) +self.traceStopProcess() + @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) @testSBAPIAndCommands def testStartMultipleLiveThreadsWithStops(self): @@ -65,6 +67,8 @@ self.expect("thread trace dump instructions 2", substrs=['not traced']) +self.traceStopProcess() + @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) @testSBAPIAndCommands def testStartMultipleLiveThreadsWithStops(self): @@ -100,6 +104,8 @@ self.expect("thread trace dump instructions 1", substrs=['not traced']) self.expect("thread trace dump instructions 2", substrs=['not traced']) +self.traceStopProcess() + @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) def testStartMultipleLiveThreadsWithThreadStartAll(self): self.build() @@ -156,6 +162,8 @@ @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) @testSBAPIAndCommands def testStartPerCoreSession(self): +self.skipIfPerCoreTracingIsNotSupported() + self.build() exe = self.getBuildArtifact("a.out") self.dbg.CreateTarget(exe) @@ -163,6 +171,28 @@ self.expect("b main") self.expect("r") -self.traceStartProcess( -error=True, perCoreTracing=True, -substrs=["Per-core tracing is not supported"]) +# We should fail if we hit the total buffer limit. Useful if the number +# of cores is huge. +self.traceStartProcess(error="True", processBufferSizeLimit=100, +perCoreTracing=True, +substrs=["The process can't be traced because the process trace size " +"limit has been reached. Consider retracing with a higher limit."]) + +self.traceStartProcess(perCoreTracing=True) +self.traceStopProcess() + +self.traceStartProcess(perCoreTracing=True) +# We can't support multiple per-core tracing sessions. +self.traceStartProcess(error=True, perCoreTracing=True, +substrs=["Process currently traced. Stop process tracing first"]) + +# We can't support tracing per thread is per core is enabled. +self.traceStartThread( +error="True", +substrs=["Process currently traced with per-core tracing. Stop process tracing first"]) + +# The GetState packet should return trace buffers per core +self.expect("""process plugin packet send 'jLLDBTraceGetState:{"type":"intel-pt"}]'""", +substrs=['''[{"kind":"traceBuffer","size":4096}],"coreId":''']) + +self.traceStopProcess() Index: lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp =
[Lldb-commits] [PATCH] D123954: [lldb] Add setting for max depth of value object printing (NFC)
kastiglione added inline comments. Comment at: lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h:50 uint32_t max_depth; + bool max_depth_is_default; uint32_t ptr_depth; aprantl wrote: > Should this be with the other bools on line 45? It wasn't there because of `std::tie` can't bind to a bit field value. I've moved this bool into the bitfield and got rid of the `std::tie`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D123954/new/ https://reviews.llvm.org/D123954 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124858: [trace][intelpt] Support system-wide tracing [4] - Support per core tracing on lldb-server
wallace updated this revision to Diff 426737. wallace added a comment. nits Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124858/new/ https://reviews.llvm.org/D124858 Files: lldb/docs/lldb-gdb-remote.txt lldb/include/lldb/Utility/TraceGDBRemotePackets.h lldb/include/lldb/Utility/TraceIntelPTGDBRemotePackets.h lldb/include/lldb/lldb-types.h lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py lldb/source/Plugins/Process/Linux/CMakeLists.txt lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp lldb/source/Plugins/Process/Linux/IntelPTCollector.h lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.h lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.h lldb/source/Plugins/Process/Linux/Perf.cpp lldb/source/Plugins/Process/Linux/Perf.h lldb/source/Plugins/Process/Linux/Procfs.cpp lldb/source/Plugins/Process/Linux/Procfs.h lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp lldb/source/Plugins/Trace/intel-pt/TraceIntelPTOptions.td lldb/source/Target/Trace.cpp lldb/source/Utility/TraceGDBRemotePackets.cpp lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py Index: lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py === --- lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py +++ lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py @@ -30,6 +30,8 @@ self.expect("continue") self.expect("thread trace dump instructions", substrs=['main.cpp:4']) +self.traceStopProcess() + @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) @testSBAPIAndCommands def testStartMultipleLiveThreadsWithStops(self): @@ -65,6 +67,8 @@ self.expect("thread trace dump instructions 2", substrs=['not traced']) +self.traceStopProcess() + @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) @testSBAPIAndCommands def testStartMultipleLiveThreadsWithStops(self): @@ -100,6 +104,8 @@ self.expect("thread trace dump instructions 1", substrs=['not traced']) self.expect("thread trace dump instructions 2", substrs=['not traced']) +self.traceStopProcess() + @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) def testStartMultipleLiveThreadsWithThreadStartAll(self): self.build() @@ -156,6 +162,8 @@ @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) @testSBAPIAndCommands def testStartPerCoreSession(self): +self.skipIfPerCoreTracingIsNotSupported() + self.build() exe = self.getBuildArtifact("a.out") self.dbg.CreateTarget(exe) @@ -163,6 +171,28 @@ self.expect("b main") self.expect("r") -self.traceStartProcess( -error=True, perCoreTracing=True, -substrs=["Per-core tracing is not supported"]) +# We should fail if we hit the total buffer limit. Useful if the number +# of cores is huge. +self.traceStartProcess(error="True", processBufferSizeLimit=100, +perCoreTracing=True, +substrs=["The process can't be traced because the process trace size " +"limit has been reached. Consider retracing with a higher limit."]) + +self.traceStartProcess(perCoreTracing=True) +self.traceStopProcess() + +self.traceStartProcess(perCoreTracing=True) +# We can't support multiple per-core tracing sessions. +self.traceStartProcess(error=True, perCoreTracing=True, +substrs=["Process currently traced. Stop process tracing first"]) + +# We can't support tracing per thread is per core is enabled. +self.traceStartThread( +error="True", +substrs=["Process currently traced with per-core tracing. Stop process tracing first"]) + +# The GetState packet should return trace buffers per core +self.expect("""process plugin packet send 'jLLDBTraceGetState:{"type":"intel-pt"}]'""", +substrs=['''[{"kind":"traceBuffer","size":4096}],"coreId":''']) + +self.traceStopProcess() Index: lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp === --- lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp +++ lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp @@ -16,6 +16,10 @@ const char *IntelPTDataKinds::kProcFsCpuInfo = "procfsCpuInfo"; const char *IntelPTDataKinds::kTraceBuffer = "traceBuffer"; +bool TraceIntelPTStartRequest::IsPerCoreTracing() const { + return per_core_tracing.ge
[Lldb-commits] [PATCH] D124858: [trace][intelpt] Support system-wide tracing [4] - Support per core tracing on lldb-server
wallace updated this revision to Diff 426742. wallace added a comment. add one test Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124858/new/ https://reviews.llvm.org/D124858 Files: lldb/docs/lldb-gdb-remote.txt lldb/include/lldb/Utility/TraceGDBRemotePackets.h lldb/include/lldb/Utility/TraceIntelPTGDBRemotePackets.h lldb/include/lldb/lldb-types.h lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py lldb/source/Plugins/Process/Linux/CMakeLists.txt lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp lldb/source/Plugins/Process/Linux/IntelPTCollector.h lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.h lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.h lldb/source/Plugins/Process/Linux/Perf.cpp lldb/source/Plugins/Process/Linux/Perf.h lldb/source/Plugins/Process/Linux/Procfs.cpp lldb/source/Plugins/Process/Linux/Procfs.h lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp lldb/source/Plugins/Trace/intel-pt/TraceIntelPTOptions.td lldb/source/Target/Trace.cpp lldb/source/Utility/TraceGDBRemotePackets.cpp lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py Index: lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py === --- lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py +++ lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py @@ -30,6 +30,8 @@ self.expect("continue") self.expect("thread trace dump instructions", substrs=['main.cpp:4']) +self.traceStopProcess() + @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) @testSBAPIAndCommands def testStartMultipleLiveThreadsWithStops(self): @@ -65,6 +67,8 @@ self.expect("thread trace dump instructions 2", substrs=['not traced']) +self.traceStopProcess() + @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) @testSBAPIAndCommands def testStartMultipleLiveThreadsWithStops(self): @@ -100,6 +104,8 @@ self.expect("thread trace dump instructions 1", substrs=['not traced']) self.expect("thread trace dump instructions 2", substrs=['not traced']) +self.traceStopProcess() + @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) def testStartMultipleLiveThreadsWithThreadStartAll(self): self.build() @@ -156,6 +162,8 @@ @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) @testSBAPIAndCommands def testStartPerCoreSession(self): +self.skipIfPerCoreTracingIsNotSupported() + self.build() exe = self.getBuildArtifact("a.out") self.dbg.CreateTarget(exe) @@ -163,6 +171,32 @@ self.expect("b main") self.expect("r") -self.traceStartProcess( -error=True, perCoreTracing=True, -substrs=["Per-core tracing is not supported"]) +# We should fail if we hit the total buffer limit. Useful if the number +# of cores is huge. +self.traceStartProcess(error="True", processBufferSizeLimit=100, +perCoreTracing=True, +substrs=["The process can't be traced because the process trace size " +"limit has been reached. Consider retracing with a higher limit."]) + +self.traceStartProcess(perCoreTracing=True) +self.traceStopProcess() + +self.traceStartProcess(perCoreTracing=True) +# We can't support multiple per-core tracing sessions. +self.traceStartProcess(error=True, perCoreTracing=True, +substrs=["Process currently traced. Stop process tracing first"]) + +# We can't support tracing per thread is per core is enabled. +self.traceStartThread( +error="True", +substrs=["Process currently traced with per-core tracing. Stop process tracing first"]) + +# We can't stop individual thread when per core is enabled. +self.traceStopThread(error="True", +substrs=["Can't stop tracing an individual thread when per-core process tracing is enabled"]) + +# The GetState packet should return trace buffers per core +self.expect("""process plugin packet send 'jLLDBTraceGetState:{"type":"intel-pt"}]'""", +substrs=['''[{"kind":"traceBuffer","size":4096}],"coreId":''']) + +self.traceStopProcess() Index: lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp === --- lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp +++ lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp @@ -1
[Lldb-commits] [PATCH] D124858: [trace][intelpt] Support system-wide tracing [4] - Support per core tracing on lldb-server
wallace updated this revision to Diff 426745. wallace edited the summary of this revision. wallace added a comment. improve error message Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124858/new/ https://reviews.llvm.org/D124858 Files: lldb/docs/lldb-gdb-remote.txt lldb/include/lldb/Utility/TraceGDBRemotePackets.h lldb/include/lldb/Utility/TraceIntelPTGDBRemotePackets.h lldb/include/lldb/lldb-types.h lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py lldb/source/Plugins/Process/Linux/CMakeLists.txt lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp lldb/source/Plugins/Process/Linux/IntelPTCollector.h lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.h lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.h lldb/source/Plugins/Process/Linux/Perf.cpp lldb/source/Plugins/Process/Linux/Perf.h lldb/source/Plugins/Process/Linux/Procfs.cpp lldb/source/Plugins/Process/Linux/Procfs.h lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp lldb/source/Plugins/Trace/intel-pt/TraceIntelPTOptions.td lldb/source/Target/Trace.cpp lldb/source/Utility/TraceGDBRemotePackets.cpp lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py Index: lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py === --- lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py +++ lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py @@ -30,6 +30,8 @@ self.expect("continue") self.expect("thread trace dump instructions", substrs=['main.cpp:4']) +self.traceStopProcess() + @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) @testSBAPIAndCommands def testStartMultipleLiveThreadsWithStops(self): @@ -65,6 +67,8 @@ self.expect("thread trace dump instructions 2", substrs=['not traced']) +self.traceStopProcess() + @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) @testSBAPIAndCommands def testStartMultipleLiveThreadsWithStops(self): @@ -100,6 +104,8 @@ self.expect("thread trace dump instructions 1", substrs=['not traced']) self.expect("thread trace dump instructions 2", substrs=['not traced']) +self.traceStopProcess() + @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) def testStartMultipleLiveThreadsWithThreadStartAll(self): self.build() @@ -156,6 +162,8 @@ @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) @testSBAPIAndCommands def testStartPerCoreSession(self): +self.skipIfPerCoreTracingIsNotSupported() + self.build() exe = self.getBuildArtifact("a.out") self.dbg.CreateTarget(exe) @@ -163,6 +171,32 @@ self.expect("b main") self.expect("r") -self.traceStartProcess( -error=True, perCoreTracing=True, -substrs=["Per-core tracing is not supported"]) +# We should fail if we hit the total buffer limit. Useful if the number +# of cores is huge. +self.traceStartProcess(error="True", processBufferSizeLimit=100, +perCoreTracing=True, +substrs=["The process can't be traced because the process trace size " +"limit has been reached. Consider retracing with a higher limit."]) + +self.traceStartProcess(perCoreTracing=True) +self.traceStopProcess() + +self.traceStartProcess(perCoreTracing=True) +# We can't support multiple per-core tracing sessions. +self.traceStartProcess(error=True, perCoreTracing=True, +substrs=["Process currently traced. Stop process tracing first"]) + +# We can't support tracing per thread is per core is enabled. +self.traceStartThread( +error="True", +substrs=["Process currently traced with per-core tracing. Stop process tracing first"]) + +# We can't stop individual thread when per core is enabled. +self.traceStopThread(error="True", +substrs=["Can't stop tracing an individual thread when per-core process tracing is enabled"]) + +# The GetState packet should return trace buffers per core +self.expect("""process plugin packet send 'jLLDBTraceGetState:{"type":"intel-pt"}]'""", +substrs=['''[{"kind":"traceBuffer","size":4096}],"coreId":''']) + +self.traceStopProcess() Index: lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp === --- lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp +++ lldb
[Lldb-commits] [PATCH] D123954: [lldb] Add setting for max depth of value object printing (NFC)
kastiglione updated this revision to Diff 426755. kastiglione added a comment. Addresses Adrian's feedback. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D123954/new/ https://reviews.llvm.org/D123954 Files: lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h lldb/include/lldb/DataFormatters/ValueObjectPrinter.h lldb/include/lldb/Interpreter/CommandInterpreter.h lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h lldb/include/lldb/Interpreter/OptionValueProperties.h lldb/include/lldb/Target/Target.h lldb/source/Commands/CommandObjectFrame.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/DataFormatters/DumpValueObjectOptions.cpp lldb/source/DataFormatters/ValueObjectPrinter.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp lldb/source/Interpreter/OptionValueProperties.cpp lldb/source/Target/Target.cpp lldb/source/Target/TargetProperties.td Index: lldb/source/Target/TargetProperties.td === --- lldb/source/Target/TargetProperties.td +++ lldb/source/Target/TargetProperties.td @@ -72,6 +72,9 @@ def MaxChildrenCount: Property<"max-children-count", "SInt64">, DefaultUnsignedValue<256>, Desc<"Maximum number of children to expand in any level of depth.">; + def MaxChildrenDepth: Property<"max-children-depth", "UInt64">, +DefaultUnsignedValue<0x>, +Desc<"Maximum depth to expand children.">; def MaxSummaryLength: Property<"max-string-summary-length", "SInt64">, DefaultUnsignedValue<1024>, Desc<"Maximum number of characters to show when using %s in summary strings.">; Index: lldb/source/Target/Target.cpp === --- lldb/source/Target/Target.cpp +++ lldb/source/Target/Target.cpp @@ -4236,6 +4236,15 @@ nullptr, idx, g_target_properties[idx].default_uint_value); } +std::pair +TargetProperties::GetMaximumDepthOfChildrenToDisplay() const { + const uint32_t idx = ePropertyMaxChildrenDepth; + auto *option_value = + m_collection_sp->GetPropertyAtIndexAsOptionValueUInt64(nullptr, idx); + bool is_default = !option_value->OptionWasSet(); + return {option_value->GetCurrentValue(), is_default}; +} + uint32_t TargetProperties::GetMaximumSizeOfStringSummary() const { const uint32_t idx = ePropertyMaxSummaryLength; return m_collection_sp->GetPropertyAtIndexAsSInt64( Index: lldb/source/Interpreter/OptionValueProperties.cpp === --- lldb/source/Interpreter/OptionValueProperties.cpp +++ lldb/source/Interpreter/OptionValueProperties.cpp @@ -412,6 +412,17 @@ return nullptr; } +OptionValueUInt64 *OptionValueProperties::GetPropertyAtIndexAsOptionValueUInt64( +const ExecutionContext *exe_ctx, uint32_t idx) const { + const Property *property = GetPropertyAtIndex(exe_ctx, false, idx); + if (property) { +OptionValue *value = property->GetValue().get(); +if (value) + return value->GetAsUInt64(); + } + return nullptr; +} + int64_t OptionValueProperties::GetPropertyAtIndexAsSInt64( const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const { const Property *property = GetPropertyAtIndex(exe_ctx, false, idx); Index: lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp === --- lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp +++ lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp @@ -104,6 +104,8 @@ max_depth = UINT32_MAX; error.SetErrorStringWithFormat("invalid max depth '%s'", option_arg.str().c_str()); +} else { + max_depth_is_default = false; } break; @@ -163,6 +165,7 @@ flat_output = false; use_objc = false; max_depth = UINT32_MAX; + max_depth_is_default = true; ptr_depth = 0; elem_count = 0; use_synth = true; @@ -172,9 +175,12 @@ TargetSP target_sp = execution_context ? execution_context->GetTargetSP() : TargetSP(); - if (target_sp) + if (target_sp) { use_dynamic = target_sp->GetPreferDynamicValue(); - else { +auto max_depth_config = target_sp->GetMaximumDepthOfChildrenToDisplay(); +max_depth = std::get(max_depth_config); +max_depth_is_default = std::get(max_depth_config); + } else { // If we don't have any targets, then dynamic values won't do us much good. use_dynamic = lldb::eNoDynamicValues; } @@ -190,7 +196,7 @@ options.SetShowSummary(false); else options.SetOmitSummaryDepth(no_summary_depth); - options.SetMaximumDepth(max_depth) + options.SetMaximumDepth(max_depth, max_depth_is_default) .SetShowTypes(show_types) .SetShowLocation(show_location) .SetUseObjectiveC(use_objc) Index: lldb/source/Interpreter/CommandInterprete
[Lldb-commits] [PATCH] D123954: [lldb] Add setting for max depth of value object printing (NFC)
kastiglione updated this revision to Diff 426761. kastiglione added a comment. Fixed/improved docstring Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D123954/new/ https://reviews.llvm.org/D123954 Files: lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h lldb/include/lldb/DataFormatters/ValueObjectPrinter.h lldb/include/lldb/Interpreter/CommandInterpreter.h lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h lldb/include/lldb/Interpreter/OptionValueProperties.h lldb/include/lldb/Target/Target.h lldb/source/Commands/CommandObjectFrame.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/DataFormatters/DumpValueObjectOptions.cpp lldb/source/DataFormatters/ValueObjectPrinter.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp lldb/source/Interpreter/OptionValueProperties.cpp lldb/source/Target/Target.cpp lldb/source/Target/TargetProperties.td Index: lldb/source/Target/TargetProperties.td === --- lldb/source/Target/TargetProperties.td +++ lldb/source/Target/TargetProperties.td @@ -72,6 +72,9 @@ def MaxChildrenCount: Property<"max-children-count", "SInt64">, DefaultUnsignedValue<256>, Desc<"Maximum number of children to expand in any level of depth.">; + def MaxChildrenDepth: Property<"max-children-depth", "UInt64">, +DefaultUnsignedValue<0x>, +Desc<"Maximum depth to expand children.">; def MaxSummaryLength: Property<"max-string-summary-length", "SInt64">, DefaultUnsignedValue<1024>, Desc<"Maximum number of characters to show when using %s in summary strings.">; Index: lldb/source/Target/Target.cpp === --- lldb/source/Target/Target.cpp +++ lldb/source/Target/Target.cpp @@ -4236,6 +4236,15 @@ nullptr, idx, g_target_properties[idx].default_uint_value); } +std::pair +TargetProperties::GetMaximumDepthOfChildrenToDisplay() const { + const uint32_t idx = ePropertyMaxChildrenDepth; + auto *option_value = + m_collection_sp->GetPropertyAtIndexAsOptionValueUInt64(nullptr, idx); + bool is_default = !option_value->OptionWasSet(); + return {option_value->GetCurrentValue(), is_default}; +} + uint32_t TargetProperties::GetMaximumSizeOfStringSummary() const { const uint32_t idx = ePropertyMaxSummaryLength; return m_collection_sp->GetPropertyAtIndexAsSInt64( Index: lldb/source/Interpreter/OptionValueProperties.cpp === --- lldb/source/Interpreter/OptionValueProperties.cpp +++ lldb/source/Interpreter/OptionValueProperties.cpp @@ -412,6 +412,17 @@ return nullptr; } +OptionValueUInt64 *OptionValueProperties::GetPropertyAtIndexAsOptionValueUInt64( +const ExecutionContext *exe_ctx, uint32_t idx) const { + const Property *property = GetPropertyAtIndex(exe_ctx, false, idx); + if (property) { +OptionValue *value = property->GetValue().get(); +if (value) + return value->GetAsUInt64(); + } + return nullptr; +} + int64_t OptionValueProperties::GetPropertyAtIndexAsSInt64( const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const { const Property *property = GetPropertyAtIndex(exe_ctx, false, idx); Index: lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp === --- lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp +++ lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp @@ -104,6 +104,8 @@ max_depth = UINT32_MAX; error.SetErrorStringWithFormat("invalid max depth '%s'", option_arg.str().c_str()); +} else { + max_depth_is_default = false; } break; @@ -163,6 +165,7 @@ flat_output = false; use_objc = false; max_depth = UINT32_MAX; + max_depth_is_default = true; ptr_depth = 0; elem_count = 0; use_synth = true; @@ -172,9 +175,12 @@ TargetSP target_sp = execution_context ? execution_context->GetTargetSP() : TargetSP(); - if (target_sp) + if (target_sp) { use_dynamic = target_sp->GetPreferDynamicValue(); - else { +auto max_depth_config = target_sp->GetMaximumDepthOfChildrenToDisplay(); +max_depth = std::get(max_depth_config); +max_depth_is_default = std::get(max_depth_config); + } else { // If we don't have any targets, then dynamic values won't do us much good. use_dynamic = lldb::eNoDynamicValues; } @@ -190,7 +196,7 @@ options.SetShowSummary(false); else options.SetOmitSummaryDepth(no_summary_depth); - options.SetMaximumDepth(max_depth) + options.SetMaximumDepth(max_depth, max_depth_is_default) .SetShowTypes(show_types) .SetShowLocation(show_location) .SetUseObjectiveC(use_objc) Index: lldb/source/Interpreter/CommandInterpreter.cp
[Lldb-commits] [lldb] 2f9fc57 - [lldb] Add setting for max depth of value object printing (NFC)
Author: Dave Lee Date: 2022-05-03T10:39:42-07:00 New Revision: 2f9fc576be206bd5c4fddfec5f89fceb3554a8d6 URL: https://github.com/llvm/llvm-project/commit/2f9fc576be206bd5c4fddfec5f89fceb3554a8d6 DIFF: https://github.com/llvm/llvm-project/commit/2f9fc576be206bd5c4fddfec5f89fceb3554a8d6.diff LOG: [lldb] Add setting for max depth of value object printing (NFC) This adds a setting (`target.max-children-depth`) that will provide a default value for the `--depth` flag used by `expression` and `frame variable`. The new setting uses the same default that's currently fixed in source: `UINT32_MAX`. This provides two purposes: 1. Allowing downstream forks to provide a customized default. 2. Allowing users to set their own default. Following `target.max-children-count`, a warning is emitted when the max depth is reached. The warning lets users know which flags or settings they can customize. This warning is shown only when the limit is the default value. rdar://87466495 Differential Revision: https://reviews.llvm.org/D123954 Added: Modified: lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h lldb/include/lldb/DataFormatters/ValueObjectPrinter.h lldb/include/lldb/Interpreter/CommandInterpreter.h lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h lldb/include/lldb/Interpreter/OptionValueProperties.h lldb/include/lldb/Target/Target.h lldb/source/Commands/CommandObjectFrame.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/DataFormatters/DumpValueObjectOptions.cpp lldb/source/DataFormatters/ValueObjectPrinter.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp lldb/source/Interpreter/OptionValueProperties.cpp lldb/source/Target/Target.cpp lldb/source/Target/TargetProperties.td Removed: diff --git a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h index cef43f45b8e41..c6306c7dab60b 100644 --- a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h +++ b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h @@ -66,7 +66,7 @@ class DumpValueObjectOptions { DumpValueObjectOptions & SetMaximumPointerDepth(PointerDepth depth = {PointerDepth::Mode::Never, 0}); - DumpValueObjectOptions &SetMaximumDepth(uint32_t depth = 0); + DumpValueObjectOptions &SetMaximumDepth(uint32_t depth, bool is_default); DumpValueObjectOptions &SetDeclPrintingHelper(DeclPrintingHelper helper); @@ -125,6 +125,7 @@ class DumpValueObjectOptions { SetPointerAsArray(const PointerAsArraySettings &ptr_array); uint32_t m_max_depth = UINT32_MAX; + bool m_max_depth_is_default = true; lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues; uint32_t m_omit_summary_depth = 0; lldb::Format m_format = lldb::eFormatDefault; diff --git a/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h b/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h index 833cd5eea356c..90e54021a71f7 100644 --- a/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h +++ b/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h @@ -117,6 +117,8 @@ class ValueObjectPrinter { bool PrintChildrenOneLiner(bool hide_names); + bool HasReachedMaximumDepth(); + private: ValueObject *m_orig_valobj; ValueObject *m_valobj; diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index f1f715c891a5c..55971136b63b3 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -223,11 +223,11 @@ class CommandInterpreter : public Broadcaster, eBroadcastBitAsynchronousErrorData = (1 << 4) }; - enum ChildrenTruncatedWarningStatus // tristate boolean to manage children - // truncation warning - { eNoTruncation = 0,// never truncated -eUnwarnedTruncation = 1, // truncated but did not notify -eWarnedTruncation = 2 // truncated and notified + /// Tristate boolean to manage children omission warnings. + enum ChildrenOmissionWarningStatus { +eNoOmission = 0, ///< No children were omitted. +eUnwarnedOmission = 1, ///< Children omitted, and not yet notified. +eWarnedOmission = 2///< Children omitted and notified. }; enum CommandTypes { @@ -496,21 +496,33 @@ class CommandInterpreter : public Broadcaster, } void ChildrenTruncated() { -if (m_truncation_warning == eNoTruncation) - m_truncation_warning = eUnwarnedTruncation; +if (m_truncation_warning == eNoOmission) + m_truncation_warning = eUnwarnedOmission; } - bool TruncationWarningNecessary() { -return (m_truncation_warning == eUnwarnedTruncation); + void SetReachedMaximumDepth() { +if (m_max
[Lldb-commits] [PATCH] D123954: [lldb] Add setting for max depth of value object printing (NFC)
This revision was automatically updated to reflect the committed changes. Closed by commit rG2f9fc576be20: [lldb] Add setting for max depth of value object printing (NFC) (authored by kastiglione). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D123954/new/ https://reviews.llvm.org/D123954 Files: lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h lldb/include/lldb/DataFormatters/ValueObjectPrinter.h lldb/include/lldb/Interpreter/CommandInterpreter.h lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h lldb/include/lldb/Interpreter/OptionValueProperties.h lldb/include/lldb/Target/Target.h lldb/source/Commands/CommandObjectFrame.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/DataFormatters/DumpValueObjectOptions.cpp lldb/source/DataFormatters/ValueObjectPrinter.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp lldb/source/Interpreter/OptionValueProperties.cpp lldb/source/Target/Target.cpp lldb/source/Target/TargetProperties.td Index: lldb/source/Target/TargetProperties.td === --- lldb/source/Target/TargetProperties.td +++ lldb/source/Target/TargetProperties.td @@ -72,6 +72,9 @@ def MaxChildrenCount: Property<"max-children-count", "SInt64">, DefaultUnsignedValue<256>, Desc<"Maximum number of children to expand in any level of depth.">; + def MaxChildrenDepth: Property<"max-children-depth", "UInt64">, +DefaultUnsignedValue<0x>, +Desc<"Maximum depth to expand children.">; def MaxSummaryLength: Property<"max-string-summary-length", "SInt64">, DefaultUnsignedValue<1024>, Desc<"Maximum number of characters to show when using %s in summary strings.">; Index: lldb/source/Target/Target.cpp === --- lldb/source/Target/Target.cpp +++ lldb/source/Target/Target.cpp @@ -4236,6 +4236,15 @@ nullptr, idx, g_target_properties[idx].default_uint_value); } +std::pair +TargetProperties::GetMaximumDepthOfChildrenToDisplay() const { + const uint32_t idx = ePropertyMaxChildrenDepth; + auto *option_value = + m_collection_sp->GetPropertyAtIndexAsOptionValueUInt64(nullptr, idx); + bool is_default = !option_value->OptionWasSet(); + return {option_value->GetCurrentValue(), is_default}; +} + uint32_t TargetProperties::GetMaximumSizeOfStringSummary() const { const uint32_t idx = ePropertyMaxSummaryLength; return m_collection_sp->GetPropertyAtIndexAsSInt64( Index: lldb/source/Interpreter/OptionValueProperties.cpp === --- lldb/source/Interpreter/OptionValueProperties.cpp +++ lldb/source/Interpreter/OptionValueProperties.cpp @@ -412,6 +412,17 @@ return nullptr; } +OptionValueUInt64 *OptionValueProperties::GetPropertyAtIndexAsOptionValueUInt64( +const ExecutionContext *exe_ctx, uint32_t idx) const { + const Property *property = GetPropertyAtIndex(exe_ctx, false, idx); + if (property) { +OptionValue *value = property->GetValue().get(); +if (value) + return value->GetAsUInt64(); + } + return nullptr; +} + int64_t OptionValueProperties::GetPropertyAtIndexAsSInt64( const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const { const Property *property = GetPropertyAtIndex(exe_ctx, false, idx); Index: lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp === --- lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp +++ lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp @@ -104,6 +104,8 @@ max_depth = UINT32_MAX; error.SetErrorStringWithFormat("invalid max depth '%s'", option_arg.str().c_str()); +} else { + max_depth_is_default = false; } break; @@ -163,6 +165,7 @@ flat_output = false; use_objc = false; max_depth = UINT32_MAX; + max_depth_is_default = true; ptr_depth = 0; elem_count = 0; use_synth = true; @@ -172,9 +175,12 @@ TargetSP target_sp = execution_context ? execution_context->GetTargetSP() : TargetSP(); - if (target_sp) + if (target_sp) { use_dynamic = target_sp->GetPreferDynamicValue(); - else { +auto max_depth_config = target_sp->GetMaximumDepthOfChildrenToDisplay(); +max_depth = std::get(max_depth_config); +max_depth_is_default = std::get(max_depth_config); + } else { // If we don't have any targets, then dynamic values won't do us much good. use_dynamic = lldb::eNoDynamicValues; } @@ -190,7 +196,7 @@ options.SetShowSummary(false); else options.SetOmitSummaryDepth(no_summary_depth); - options.SetMaximumDepth(max_depth) + options.SetMaximumDepth(max_depth, max_depth_is_default) .SetShowTypes(show_types) .SetShowLocation(show_loca
[Lldb-commits] [PATCH] D124858: [trace][intelpt] Support system-wide tracing [4] - Support per core tracing on lldb-server
wallace added inline comments. Comment at: lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py:47 +self.skipTest("Per core tracing is not supported. You need " +"/proc/sys/kernel/perf_event_paranoid to be 0 or -1.") + or use sudo Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124858/new/ https://reviews.llvm.org/D124858 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124673: [llvm][lldb] use FindLibEdit.cmake everywhere
JDevlieghere added inline comments. Comment at: lldb/CMakeLists.txt:3-5 +if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) + set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) +endif() Can this go in `lldb/cmake/modules/LLDBStandalone.cmake`? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124673/new/ https://reviews.llvm.org/D124673 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124872: [lldb] Add a function to check if lldb is running in an interactive session
JDevlieghere created this revision. JDevlieghere added a reviewer: aprantl. Herald added a project: All. JDevlieghere requested review of this revision. This patch adds a function to check if lldb is running in an interactive debug session. Currently this API only works on macOS. It's expected to be used in combination with `Host::OpenFileInExternalEditor`. https://reviews.llvm.org/D124872 Files: lldb/include/lldb/Host/Host.h lldb/source/Host/common/Host.cpp lldb/source/Host/macosx/objcxx/Host.mm Index: lldb/source/Host/macosx/objcxx/Host.mm === --- lldb/source/Host/macosx/objcxx/Host.mm +++ lldb/source/Host/macosx/objcxx/Host.mm @@ -32,6 +32,8 @@ #define LauncherXPCServiceErrorTypeKey "errorType" #define LauncherXPCServiceCodeTypeKey "errorCode" +#include +#include #endif #include "llvm/Support/Host.h" @@ -406,6 +408,16 @@ #endif // TARGET_OS_OSX } +bool Host::IsInteractiveSession() { +#if !TARGET_OS_OSX + return false; +#else + auditinfo_addr_t info; + getaudit_addr(&info, sizeof(info)); + return info.ai_flags & AU_SESSION_FLAG_HAS_GRAPHIC_ACCESS; +#endif +} + Environment Host::GetEnvironment() { return Environment(*_NSGetEnviron()); } static bool GetMacOSXProcessCPUType(ProcessInstanceInfo &process_info) { Index: lldb/source/Host/common/Host.cpp === --- lldb/source/Host/common/Host.cpp +++ lldb/source/Host/common/Host.cpp @@ -575,6 +575,7 @@ return false; } +bool Host::IsInteractiveSession() { return false; } #endif std::unique_ptr Host::CreateDefaultConnection(llvm::StringRef url) { Index: lldb/include/lldb/Host/Host.h === --- lldb/include/lldb/Host/Host.h +++ lldb/include/lldb/Host/Host.h @@ -242,6 +242,8 @@ static bool OpenFileInExternalEditor(const FileSpec &file_spec, uint32_t line_no); + static bool IsInteractiveSession(); + static Environment GetEnvironment(); static std::unique_ptr Index: lldb/source/Host/macosx/objcxx/Host.mm === --- lldb/source/Host/macosx/objcxx/Host.mm +++ lldb/source/Host/macosx/objcxx/Host.mm @@ -32,6 +32,8 @@ #define LauncherXPCServiceErrorTypeKey "errorType" #define LauncherXPCServiceCodeTypeKey "errorCode" +#include +#include #endif #include "llvm/Support/Host.h" @@ -406,6 +408,16 @@ #endif // TARGET_OS_OSX } +bool Host::IsInteractiveSession() { +#if !TARGET_OS_OSX + return false; +#else + auditinfo_addr_t info; + getaudit_addr(&info, sizeof(info)); + return info.ai_flags & AU_SESSION_FLAG_HAS_GRAPHIC_ACCESS; +#endif +} + Environment Host::GetEnvironment() { return Environment(*_NSGetEnviron()); } static bool GetMacOSXProcessCPUType(ProcessInstanceInfo &process_info) { Index: lldb/source/Host/common/Host.cpp === --- lldb/source/Host/common/Host.cpp +++ lldb/source/Host/common/Host.cpp @@ -575,6 +575,7 @@ return false; } +bool Host::IsInteractiveSession() { return false; } #endif std::unique_ptr Host::CreateDefaultConnection(llvm::StringRef url) { Index: lldb/include/lldb/Host/Host.h === --- lldb/include/lldb/Host/Host.h +++ lldb/include/lldb/Host/Host.h @@ -242,6 +242,8 @@ static bool OpenFileInExternalEditor(const FileSpec &file_spec, uint32_t line_no); + static bool IsInteractiveSession(); + static Environment GetEnvironment(); static std::unique_ptr ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124814: Fix debugserver translation check
jasonmolenda accepted this revision. jasonmolenda added a comment. This revision is now accepted and ready to land. LGTM. I see how your workflow is set up. Yeah, you return an error if someone tries to run debugserver in translation (and the inferior isn't x86_64) - that's what we need to do, a translated debugserver won't be able to debug arm64 processes. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124814/new/ https://reviews.llvm.org/D124814 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124872: [lldb] Add a function to check if lldb is running in an interactive session
aprantl accepted this revision. aprantl added a comment. This revision is now accepted and ready to land. Thank you! This is equally useful and untestable :-) CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124872/new/ https://reviews.llvm.org/D124872 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124873: [lldb] Session transcript should use the async debugger streams
JDevlieghere created this revision. JDevlieghere added a reviewer: mib. Herald added a project: All. JDevlieghere requested review of this revision. When writing out the session transcript, output should be printed to the async debugger streams. https://reviews.llvm.org/D124873 Files: lldb/source/Core/Debugger.cpp Index: lldb/source/Core/Debugger.cpp === --- lldb/source/Core/Debugger.cpp +++ lldb/source/Core/Debugger.cpp @@ -669,9 +669,9 @@ CommandReturnObject result(debugger_sp->GetUseColor()); cmd_interpreter.SaveTranscript(result); if (result.Succeeded()) - debugger_sp->GetOutputStream() << result.GetOutputData() << '\n'; + (*debugger_sp->GetAsyncOutputStream()) << result.GetOutputData() << '\n'; else - debugger_sp->GetErrorStream() << result.GetErrorData() << '\n'; + (*debugger_sp->GetAsyncOutputStream()) << result.GetErrorData() << '\n'; } debugger_sp->Clear(); Index: lldb/source/Core/Debugger.cpp === --- lldb/source/Core/Debugger.cpp +++ lldb/source/Core/Debugger.cpp @@ -669,9 +669,9 @@ CommandReturnObject result(debugger_sp->GetUseColor()); cmd_interpreter.SaveTranscript(result); if (result.Succeeded()) - debugger_sp->GetOutputStream() << result.GetOutputData() << '\n'; + (*debugger_sp->GetAsyncOutputStream()) << result.GetOutputData() << '\n'; else - debugger_sp->GetErrorStream() << result.GetErrorData() << '\n'; + (*debugger_sp->GetAsyncOutputStream()) << result.GetErrorData() << '\n'; } debugger_sp->Clear(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124873: [lldb] Session transcript should use the async debugger streams
mib accepted this revision. mib added a comment. This revision is now accepted and ready to land. LGTM! Thanks! CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124873/new/ https://reviews.llvm.org/D124873 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124873: [lldb] Session transcript should use the async debugger streams
JDevlieghere updated this revision to Diff 426821. JDevlieghere added a comment. Typo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124873/new/ https://reviews.llvm.org/D124873 Files: lldb/source/Core/Debugger.cpp Index: lldb/source/Core/Debugger.cpp === --- lldb/source/Core/Debugger.cpp +++ lldb/source/Core/Debugger.cpp @@ -669,9 +669,9 @@ CommandReturnObject result(debugger_sp->GetUseColor()); cmd_interpreter.SaveTranscript(result); if (result.Succeeded()) - debugger_sp->GetOutputStream() << result.GetOutputData() << '\n'; + (*debugger_sp->GetAsyncOutputStream()) << result.GetOutputData() << '\n'; else - debugger_sp->GetErrorStream() << result.GetErrorData() << '\n'; + (*debugger_sp->GetAsyncErrorStream()) << result.GetErrorData() << '\n'; } debugger_sp->Clear(); Index: lldb/source/Core/Debugger.cpp === --- lldb/source/Core/Debugger.cpp +++ lldb/source/Core/Debugger.cpp @@ -669,9 +669,9 @@ CommandReturnObject result(debugger_sp->GetUseColor()); cmd_interpreter.SaveTranscript(result); if (result.Succeeded()) - debugger_sp->GetOutputStream() << result.GetOutputData() << '\n'; + (*debugger_sp->GetAsyncOutputStream()) << result.GetOutputData() << '\n'; else - debugger_sp->GetErrorStream() << result.GetErrorData() << '\n'; + (*debugger_sp->GetAsyncErrorStream()) << result.GetErrorData() << '\n'; } debugger_sp->Clear(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124872: [lldb] Add a function to check if lldb is running in an interactive session
aprantl added inline comments. Comment at: lldb/source/Host/macosx/objcxx/Host.mm:411 +bool Host::IsInteractiveSession() { +#if !TARGET_OS_OSX Wait. I think this is a misnomer. An lldb session over SSH is interactive, but not graphical. Should this be called IsInteractiveDesktopSession/IsInteractiveGraphicSession/IsInteractiveGUISession? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124872/new/ https://reviews.llvm.org/D124872 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124872: [lldb] Add a function to check if lldb is running in an interactive session
JDevlieghere updated this revision to Diff 426822. JDevlieghere added a comment. IsInteractiveSession -> IsInteractiveGraphicSession CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124872/new/ https://reviews.llvm.org/D124872 Files: lldb/include/lldb/Host/Host.h lldb/source/Host/common/Host.cpp lldb/source/Host/macosx/objcxx/Host.mm Index: lldb/source/Host/macosx/objcxx/Host.mm === --- lldb/source/Host/macosx/objcxx/Host.mm +++ lldb/source/Host/macosx/objcxx/Host.mm @@ -32,6 +32,8 @@ #define LauncherXPCServiceErrorTypeKey "errorType" #define LauncherXPCServiceCodeTypeKey "errorCode" +#include +#include #endif #include "llvm/Support/Host.h" @@ -406,6 +408,16 @@ #endif // TARGET_OS_OSX } +bool Host::IsInteractiveGraphicSession() { +#if !TARGET_OS_OSX + return false; +#else + auditinfo_addr_t info; + getaudit_addr(&info, sizeof(info)); + return info.ai_flags & AU_SESSION_FLAG_HAS_GRAPHIC_ACCESS; +#endif +} + Environment Host::GetEnvironment() { return Environment(*_NSGetEnviron()); } static bool GetMacOSXProcessCPUType(ProcessInstanceInfo &process_info) { Index: lldb/source/Host/common/Host.cpp === --- lldb/source/Host/common/Host.cpp +++ lldb/source/Host/common/Host.cpp @@ -575,6 +575,7 @@ return false; } +bool Host::IsInteractiveGraphicSession() { return false; } #endif std::unique_ptr Host::CreateDefaultConnection(llvm::StringRef url) { Index: lldb/include/lldb/Host/Host.h === --- lldb/include/lldb/Host/Host.h +++ lldb/include/lldb/Host/Host.h @@ -242,6 +242,8 @@ static bool OpenFileInExternalEditor(const FileSpec &file_spec, uint32_t line_no); + static bool IsInteractiveGraphicSession(); + static Environment GetEnvironment(); static std::unique_ptr Index: lldb/source/Host/macosx/objcxx/Host.mm === --- lldb/source/Host/macosx/objcxx/Host.mm +++ lldb/source/Host/macosx/objcxx/Host.mm @@ -32,6 +32,8 @@ #define LauncherXPCServiceErrorTypeKey "errorType" #define LauncherXPCServiceCodeTypeKey "errorCode" +#include +#include #endif #include "llvm/Support/Host.h" @@ -406,6 +408,16 @@ #endif // TARGET_OS_OSX } +bool Host::IsInteractiveGraphicSession() { +#if !TARGET_OS_OSX + return false; +#else + auditinfo_addr_t info; + getaudit_addr(&info, sizeof(info)); + return info.ai_flags & AU_SESSION_FLAG_HAS_GRAPHIC_ACCESS; +#endif +} + Environment Host::GetEnvironment() { return Environment(*_NSGetEnviron()); } static bool GetMacOSXProcessCPUType(ProcessInstanceInfo &process_info) { Index: lldb/source/Host/common/Host.cpp === --- lldb/source/Host/common/Host.cpp +++ lldb/source/Host/common/Host.cpp @@ -575,6 +575,7 @@ return false; } +bool Host::IsInteractiveGraphicSession() { return false; } #endif std::unique_ptr Host::CreateDefaultConnection(llvm::StringRef url) { Index: lldb/include/lldb/Host/Host.h === --- lldb/include/lldb/Host/Host.h +++ lldb/include/lldb/Host/Host.h @@ -242,6 +242,8 @@ static bool OpenFileInExternalEditor(const FileSpec &file_spec, uint32_t line_no); + static bool IsInteractiveGraphicSession(); + static Environment GetEnvironment(); static std::unique_ptr ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124872: [lldb] Add a function to check if lldb is running in an interactive session
aprantl accepted this revision. aprantl added a comment. This revision is now accepted and ready to land. One last request: Could you add a Doxygen comment? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124872/new/ https://reviews.llvm.org/D124872 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124872: [lldb] Add a function to check if lldb is running in an interactive session
mib added inline comments. Comment at: lldb/source/Host/macosx/objcxx/Host.mm:411 +bool Host::IsInteractiveSession() { +#if !TARGET_OS_OSX aprantl wrote: > Wait. I think this is a misnomer. An lldb session over SSH is interactive, > but not graphical. Should this be called > IsInteractiveDesktopSession/IsInteractiveGraphicSession/IsInteractiveGUISession? FWIW, if you `open` a file on macOS over SSH, it would still open it in the default app. I'd expect the same behaviour here. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124872/new/ https://reviews.llvm.org/D124872 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124872: [lldb] Add a function to check if lldb is running in an interactive session
mib added inline comments. Comment at: lldb/source/Host/macosx/objcxx/Host.mm:411 +bool Host::IsInteractiveSession() { +#if !TARGET_OS_OSX mib wrote: > aprantl wrote: > > Wait. I think this is a misnomer. An lldb session over SSH is interactive, > > but not graphical. Should this be called > > IsInteractiveDesktopSession/IsInteractiveGraphicSession/IsInteractiveGUISession? > FWIW, if you `open` a file on macOS over SSH, it would still open it in the > default app. I'd expect the same behaviour here. > FWIW, if you `open` a file on macOS over SSH, it would still open it in the > default app. I'd expect the same behaviour here. ... Even if you're not in front of the screen. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124872/new/ https://reviews.llvm.org/D124872 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124872: [lldb] Add a function to check if lldb is running in an interactive session
aprantl added inline comments. Comment at: lldb/source/Host/macosx/objcxx/Host.mm:411 +bool Host::IsInteractiveSession() { +#if !TARGET_OS_OSX mib wrote: > mib wrote: > > aprantl wrote: > > > Wait. I think this is a misnomer. An lldb session over SSH is > > > interactive, but not graphical. Should this be called > > > IsInteractiveDesktopSession/IsInteractiveGraphicSession/IsInteractiveGUISession? > > FWIW, if you `open` a file on macOS over SSH, it would still open it in the > > default app. I'd expect the same behaviour here. > > FWIW, if you `open` a file on macOS over SSH, it would still open it in the > > default app. I'd expect the same behaviour here. > > ... Even if you're not in front of the screen. Right, that's why we don't want to open files in the external editor if we are connected over SSH. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124872/new/ https://reviews.llvm.org/D124872 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124873: [lldb] Session transcript should use the async debugger streams
This revision was automatically updated to reflect the committed changes. Closed by commit rG3d08c778c01e: [lldb] Session transcript should use the async debugger streams (authored by JDevlieghere). Herald added a project: LLDB. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124873/new/ https://reviews.llvm.org/D124873 Files: lldb/source/Core/Debugger.cpp Index: lldb/source/Core/Debugger.cpp === --- lldb/source/Core/Debugger.cpp +++ lldb/source/Core/Debugger.cpp @@ -669,9 +669,9 @@ CommandReturnObject result(debugger_sp->GetUseColor()); cmd_interpreter.SaveTranscript(result); if (result.Succeeded()) - debugger_sp->GetOutputStream() << result.GetOutputData() << '\n'; + (*debugger_sp->GetAsyncOutputStream()) << result.GetOutputData() << '\n'; else - debugger_sp->GetErrorStream() << result.GetErrorData() << '\n'; + (*debugger_sp->GetAsyncErrorStream()) << result.GetErrorData() << '\n'; } debugger_sp->Clear(); Index: lldb/source/Core/Debugger.cpp === --- lldb/source/Core/Debugger.cpp +++ lldb/source/Core/Debugger.cpp @@ -669,9 +669,9 @@ CommandReturnObject result(debugger_sp->GetUseColor()); cmd_interpreter.SaveTranscript(result); if (result.Succeeded()) - debugger_sp->GetOutputStream() << result.GetOutputData() << '\n'; + (*debugger_sp->GetAsyncOutputStream()) << result.GetOutputData() << '\n'; else - debugger_sp->GetErrorStream() << result.GetErrorData() << '\n'; + (*debugger_sp->GetAsyncErrorStream()) << result.GetErrorData() << '\n'; } debugger_sp->Clear(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3d08c77 - [lldb] Session transcript should use the async debugger streams
Author: Jonas Devlieghere Date: 2022-05-03T15:11:57-07:00 New Revision: 3d08c778c01e1577752762da8c980db32b4e6d55 URL: https://github.com/llvm/llvm-project/commit/3d08c778c01e1577752762da8c980db32b4e6d55 DIFF: https://github.com/llvm/llvm-project/commit/3d08c778c01e1577752762da8c980db32b4e6d55.diff LOG: [lldb] Session transcript should use the async debugger streams When writing out the session transcript, print output to the asynchronous debugger stream to prevent it from potentially interleaving with other output. Differential revision: https://reviews.llvm.org/D124873 Added: Modified: lldb/source/Core/Debugger.cpp Removed: diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index e7d3d6bd8b9ac..a0785549e77ec 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -669,9 +669,9 @@ void Debugger::Destroy(DebuggerSP &debugger_sp) { CommandReturnObject result(debugger_sp->GetUseColor()); cmd_interpreter.SaveTranscript(result); if (result.Succeeded()) - debugger_sp->GetOutputStream() << result.GetOutputData() << '\n'; + (*debugger_sp->GetAsyncOutputStream()) << result.GetOutputData() << '\n'; else - debugger_sp->GetErrorStream() << result.GetErrorData() << '\n'; + (*debugger_sp->GetAsyncErrorStream()) << result.GetErrorData() << '\n'; } debugger_sp->Clear(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b945b62 - [lldb] Add a function to check if lldb is running in an interactive session
Author: Jonas Devlieghere Date: 2022-05-03T15:11:57-07:00 New Revision: b945b62cf35e1b45ffb9233958756743b2b5fd46 URL: https://github.com/llvm/llvm-project/commit/b945b62cf35e1b45ffb9233958756743b2b5fd46 DIFF: https://github.com/llvm/llvm-project/commit/b945b62cf35e1b45ffb9233958756743b2b5fd46.diff LOG: [lldb] Add a function to check if lldb is running in an interactive session This patch adds a function to check if lldb is running in an interactive debug session. Currently this API only works on macOS. It's expected to be used in combination with Host::OpenFileInExternalEditor. Differential revision: https://reviews.llvm.org/D124872 Added: Modified: lldb/include/lldb/Host/Host.h lldb/source/Host/common/Host.cpp lldb/source/Host/macosx/objcxx/Host.mm Removed: diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h index b78988721b507..3b49b5e393507 100644 --- a/lldb/include/lldb/Host/Host.h +++ b/lldb/include/lldb/Host/Host.h @@ -242,6 +242,13 @@ class Host { static bool OpenFileInExternalEditor(const FileSpec &file_spec, uint32_t line_no); + /// Check if we're running in an interactive graphical session. + /// + /// \return + /// True if we're running in an interactive graphical session. False if + /// we're not or don't know. + static bool IsInteractiveGraphicSession(); + static Environment GetEnvironment(); static std::unique_ptr diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index 28232eadd350b..e8c5ece9a4f6c 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -575,6 +575,7 @@ bool Host::OpenFileInExternalEditor(const FileSpec &file_spec, return false; } +bool Host::IsInteractiveGraphicSession() { return false; } #endif std::unique_ptr Host::CreateDefaultConnection(llvm::StringRef url) { diff --git a/lldb/source/Host/macosx/objcxx/Host.mm b/lldb/source/Host/macosx/objcxx/Host.mm index ca6a408642ae8..7c490f922128d 100644 --- a/lldb/source/Host/macosx/objcxx/Host.mm +++ b/lldb/source/Host/macosx/objcxx/Host.mm @@ -32,6 +32,8 @@ #define LauncherXPCServiceErrorTypeKey "errorType" #define LauncherXPCServiceCodeTypeKey "errorCode" +#include +#include #endif #include "llvm/Support/Host.h" @@ -406,6 +408,16 @@ repeat with the_window in (get windows)\n\ #endif // TARGET_OS_OSX } +bool Host::IsInteractiveGraphicSession() { +#if !TARGET_OS_OSX + return false; +#else + auditinfo_addr_t info; + getaudit_addr(&info, sizeof(info)); + return info.ai_flags & AU_SESSION_FLAG_HAS_GRAPHIC_ACCESS; +#endif +} + Environment Host::GetEnvironment() { return Environment(*_NSGetEnviron()); } static bool GetMacOSXProcessCPUType(ProcessInstanceInfo &process_info) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D124872: [lldb] Add a function to check if lldb is running in an interactive session
This revision was automatically updated to reflect the committed changes. Closed by commit rGb945b62cf35e: [lldb] Add a function to check if lldb is running in an interactive session (authored by JDevlieghere). Herald added a project: LLDB. Changed prior to commit: https://reviews.llvm.org/D124872?vs=426822&id=426857#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124872/new/ https://reviews.llvm.org/D124872 Files: lldb/include/lldb/Host/Host.h lldb/source/Host/common/Host.cpp lldb/source/Host/macosx/objcxx/Host.mm Index: lldb/source/Host/macosx/objcxx/Host.mm === --- lldb/source/Host/macosx/objcxx/Host.mm +++ lldb/source/Host/macosx/objcxx/Host.mm @@ -32,6 +32,8 @@ #define LauncherXPCServiceErrorTypeKey "errorType" #define LauncherXPCServiceCodeTypeKey "errorCode" +#include +#include #endif #include "llvm/Support/Host.h" @@ -406,6 +408,16 @@ #endif // TARGET_OS_OSX } +bool Host::IsInteractiveGraphicSession() { +#if !TARGET_OS_OSX + return false; +#else + auditinfo_addr_t info; + getaudit_addr(&info, sizeof(info)); + return info.ai_flags & AU_SESSION_FLAG_HAS_GRAPHIC_ACCESS; +#endif +} + Environment Host::GetEnvironment() { return Environment(*_NSGetEnviron()); } static bool GetMacOSXProcessCPUType(ProcessInstanceInfo &process_info) { Index: lldb/source/Host/common/Host.cpp === --- lldb/source/Host/common/Host.cpp +++ lldb/source/Host/common/Host.cpp @@ -575,6 +575,7 @@ return false; } +bool Host::IsInteractiveGraphicSession() { return false; } #endif std::unique_ptr Host::CreateDefaultConnection(llvm::StringRef url) { Index: lldb/include/lldb/Host/Host.h === --- lldb/include/lldb/Host/Host.h +++ lldb/include/lldb/Host/Host.h @@ -242,6 +242,13 @@ static bool OpenFileInExternalEditor(const FileSpec &file_spec, uint32_t line_no); + /// Check if we're running in an interactive graphical session. + /// + /// \return + /// True if we're running in an interactive graphical session. False if + /// we're not or don't know. + static bool IsInteractiveGraphicSession(); + static Environment GetEnvironment(); static std::unique_ptr Index: lldb/source/Host/macosx/objcxx/Host.mm === --- lldb/source/Host/macosx/objcxx/Host.mm +++ lldb/source/Host/macosx/objcxx/Host.mm @@ -32,6 +32,8 @@ #define LauncherXPCServiceErrorTypeKey "errorType" #define LauncherXPCServiceCodeTypeKey "errorCode" +#include +#include #endif #include "llvm/Support/Host.h" @@ -406,6 +408,16 @@ #endif // TARGET_OS_OSX } +bool Host::IsInteractiveGraphicSession() { +#if !TARGET_OS_OSX + return false; +#else + auditinfo_addr_t info; + getaudit_addr(&info, sizeof(info)); + return info.ai_flags & AU_SESSION_FLAG_HAS_GRAPHIC_ACCESS; +#endif +} + Environment Host::GetEnvironment() { return Environment(*_NSGetEnviron()); } static bool GetMacOSXProcessCPUType(ProcessInstanceInfo &process_info) { Index: lldb/source/Host/common/Host.cpp === --- lldb/source/Host/common/Host.cpp +++ lldb/source/Host/common/Host.cpp @@ -575,6 +575,7 @@ return false; } +bool Host::IsInteractiveGraphicSession() { return false; } #endif std::unique_ptr Host::CreateDefaultConnection(llvm::StringRef url) { Index: lldb/include/lldb/Host/Host.h === --- lldb/include/lldb/Host/Host.h +++ lldb/include/lldb/Host/Host.h @@ -242,6 +242,13 @@ static bool OpenFileInExternalEditor(const FileSpec &file_spec, uint32_t line_no); + /// Check if we're running in an interactive graphical session. + /// + /// \return + /// True if we're running in an interactive graphical session. False if + /// we're not or don't know. + static bool IsInteractiveGraphicSession(); + static Environment GetEnvironment(); static std::unique_ptr ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3dd0046 - [trace][intelpt] Fix out-of-bounds access.
Author: Weverything Date: 2022-05-03T16:07:58-07:00 New Revision: 3dd00461f9cb91a6582653500603882ed1475e51 URL: https://github.com/llvm/llvm-project/commit/3dd00461f9cb91a6582653500603882ed1475e51 DIFF: https://github.com/llvm/llvm-project/commit/3dd00461f9cb91a6582653500603882ed1475e51.diff LOG: [trace][intelpt] Fix out-of-bounds access. The StringRef single argument constructor expects a null-terminated string. Explicitly pass the size to prevent reading pass the end of the array. Added: Modified: lldb/source/Plugins/Process/Linux/Procfs.cpp Removed: diff --git a/lldb/source/Plugins/Process/Linux/Procfs.cpp b/lldb/source/Plugins/Process/Linux/Procfs.cpp index 1ff7c568d891f..756749e0a7e32 100644 --- a/lldb/source/Plugins/Process/Linux/Procfs.cpp +++ b/lldb/source/Plugins/Process/Linux/Procfs.cpp @@ -60,8 +60,8 @@ lldb_private::process_linux::GetAvailableLogicalCoreIDs() { if (!cpuinfo) return cpuinfo.takeError(); -Expected> core_ids = GetAvailableLogicalCoreIDs( -StringRef(reinterpret_cast(cpuinfo->data(; +Expected> core_ids = GetAvailableLogicalCoreIDs(StringRef( +reinterpret_cast(cpuinfo->data()), cpuinfo->size())); if (!core_ids) return core_ids.takeError(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 20048f3 - [lldb] use one shared ThreadPool and task groups
Author: Luboš Luňák Date: 2022-05-04T06:18:20+02:00 New Revision: 20048f3150cf6c603c8f5a20912561048a868484 URL: https://github.com/llvm/llvm-project/commit/20048f3150cf6c603c8f5a20912561048a868484 DIFF: https://github.com/llvm/llvm-project/commit/20048f3150cf6c603c8f5a20912561048a868484.diff LOG: [lldb] use one shared ThreadPool and task groups As a preparation for parallelizing loading of symbols (D122975), it is necessary to use just one thread pool to avoid using a thread pool from inside a task of another thread pool. Differential Revision: https://reviews.llvm.org/D123226 Added: Modified: lldb/include/lldb/Core/Debugger.h lldb/source/Core/Debugger.cpp lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp Removed: diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 354230b7a88a3..8005e03071b24 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -49,6 +49,7 @@ namespace llvm { class raw_ostream; +class ThreadPool; } namespace lldb_private { @@ -379,6 +380,9 @@ class Debugger : public std::enable_shared_from_this, return m_broadcaster_manager_sp; } + /// Shared thread poll. Use only with ThreadPoolTaskGroup. + static llvm::ThreadPool &GetThreadPool(); + /// Report warning events. /// /// Progress events will be delivered to any debuggers that have listeners diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index a0785549e77ec..ff158dd1cfdfe 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -66,6 +66,7 @@ #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Process.h" +#include "llvm/Support/ThreadPool.h" #include "llvm/Support/Threading.h" #include "llvm/Support/raw_ostream.h" @@ -1970,3 +1971,13 @@ Status Debugger::RunREPL(LanguageType language, const char *repl_options) { return err; } + +llvm::ThreadPool &Debugger::GetThreadPool() { + // NOTE: intentional leak to avoid issues with C++ destructor chain + static llvm::ThreadPool *g_thread_pool = nullptr; + static llvm::once_flag g_once_flag; + llvm::call_once(g_once_flag, []() { +g_thread_pool = new llvm::ThreadPool(llvm::optimal_concurrency()); + }); + return *g_thread_pool; +} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp index d0d5aead2c2b3..b743c84c10e01 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -13,6 +13,7 @@ #include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h" #include "lldb/Core/DataFileCache.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/Progress.h" #include "lldb/Symbol/ObjectFile.h" @@ -94,7 +95,7 @@ void ManualDWARFIndex::Index() { // Share one thread pool across operations to avoid the overhead of // recreating the threads. - llvm::ThreadPool pool(llvm::optimal_concurrency(units_to_index.size())); + llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool()); // Create a task runner that extracts dies for each DWARF unit in a // separate thread. @@ -105,14 +106,14 @@ void ManualDWARFIndex::Index() { // to wait until all units have been indexed in case a DIE in one // unit refers to another and the indexes accesses those DIEs. for (size_t i = 0; i < units_to_index.size(); ++i) -pool.async(extract_fn, i); - pool.wait(); +task_group.async(extract_fn, i); + task_group.wait(); // Now create a task runner that can index each DWARF unit in a // separate thread so we can index quickly. for (size_t i = 0; i < units_to_index.size(); ++i) -pool.async(parser_fn, i); - pool.wait(); +task_group.async(parser_fn, i); + task_group.wait(); auto finalize_fn = [this, &sets, &progress](NameToDIE(IndexSet::*index)) { NameToDIE &result = m_set.*index; @@ -122,15 +123,15 @@ void ManualDWARFIndex::Index() { progress.Increment(); }; - pool.async(finalize_fn, &IndexSet::function_basenames); - pool.async(finalize_fn, &IndexSet::function_fullnames); - pool.async(finalize_fn, &IndexSet::function_methods); - pool.async(finalize_fn, &IndexSet::function_selectors); - pool.async(finalize_fn, &IndexSet::objc_class_selectors); - pool.async(finalize_fn, &IndexSet::globals); - pool.async(finalize_fn, &IndexSet::types); - pool.async(finalize_fn, &IndexSet::namespaces); - pool.wait(); + task_group.async(finalize_fn, &IndexSet::function_basenames); + task_group.async(finalize_fn, &IndexSet::function_fullnames); + task_group.async(finalize_fn, &IndexSet::function_methods); + task_group.async(finalize_fn, &IndexSet::function_selectors); + task_group.async
[Lldb-commits] [PATCH] D123226: [lldb] use one shared ThreadPool and task groups
This revision was automatically updated to reflect the committed changes. Closed by commit rG20048f3150cf: [lldb] use one shared ThreadPool and task groups (authored by llunak). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D123226/new/ https://reviews.llvm.org/D123226 Files: lldb/include/lldb/Core/Debugger.h lldb/source/Core/Debugger.cpp lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp === --- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -13,6 +13,7 @@ #include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h" #include "lldb/Core/DataFileCache.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/Progress.h" #include "lldb/Symbol/ObjectFile.h" @@ -94,7 +95,7 @@ // Share one thread pool across operations to avoid the overhead of // recreating the threads. - llvm::ThreadPool pool(llvm::optimal_concurrency(units_to_index.size())); + llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool()); // Create a task runner that extracts dies for each DWARF unit in a // separate thread. @@ -105,14 +106,14 @@ // to wait until all units have been indexed in case a DIE in one // unit refers to another and the indexes accesses those DIEs. for (size_t i = 0; i < units_to_index.size(); ++i) -pool.async(extract_fn, i); - pool.wait(); +task_group.async(extract_fn, i); + task_group.wait(); // Now create a task runner that can index each DWARF unit in a // separate thread so we can index quickly. for (size_t i = 0; i < units_to_index.size(); ++i) -pool.async(parser_fn, i); - pool.wait(); +task_group.async(parser_fn, i); + task_group.wait(); auto finalize_fn = [this, &sets, &progress](NameToDIE(IndexSet::*index)) { NameToDIE &result = m_set.*index; @@ -122,15 +123,15 @@ progress.Increment(); }; - pool.async(finalize_fn, &IndexSet::function_basenames); - pool.async(finalize_fn, &IndexSet::function_fullnames); - pool.async(finalize_fn, &IndexSet::function_methods); - pool.async(finalize_fn, &IndexSet::function_selectors); - pool.async(finalize_fn, &IndexSet::objc_class_selectors); - pool.async(finalize_fn, &IndexSet::globals); - pool.async(finalize_fn, &IndexSet::types); - pool.async(finalize_fn, &IndexSet::namespaces); - pool.wait(); + task_group.async(finalize_fn, &IndexSet::function_basenames); + task_group.async(finalize_fn, &IndexSet::function_fullnames); + task_group.async(finalize_fn, &IndexSet::function_methods); + task_group.async(finalize_fn, &IndexSet::function_selectors); + task_group.async(finalize_fn, &IndexSet::objc_class_selectors); + task_group.async(finalize_fn, &IndexSet::globals); + task_group.async(finalize_fn, &IndexSet::types); + task_group.async(finalize_fn, &IndexSet::namespaces); + task_group.wait(); SaveToCache(); } Index: lldb/source/Core/Debugger.cpp === --- lldb/source/Core/Debugger.cpp +++ lldb/source/Core/Debugger.cpp @@ -66,6 +66,7 @@ #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Process.h" +#include "llvm/Support/ThreadPool.h" #include "llvm/Support/Threading.h" #include "llvm/Support/raw_ostream.h" @@ -1970,3 +1971,13 @@ return err; } + +llvm::ThreadPool &Debugger::GetThreadPool() { + // NOTE: intentional leak to avoid issues with C++ destructor chain + static llvm::ThreadPool *g_thread_pool = nullptr; + static llvm::once_flag g_once_flag; + llvm::call_once(g_once_flag, []() { +g_thread_pool = new llvm::ThreadPool(llvm::optimal_concurrency()); + }); + return *g_thread_pool; +} Index: lldb/include/lldb/Core/Debugger.h === --- lldb/include/lldb/Core/Debugger.h +++ lldb/include/lldb/Core/Debugger.h @@ -49,6 +49,7 @@ namespace llvm { class raw_ostream; +class ThreadPool; } namespace lldb_private { @@ -379,6 +380,9 @@ return m_broadcaster_manager_sp; } + /// Shared thread poll. Use only with ThreadPoolTaskGroup. + static llvm::ThreadPool &GetThreadPool(); + /// Report warning events. /// /// Progress events will be delivered to any debuggers that have listeners ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D122975: parallelize calling of Module::PreloadSymbols()
llunak added a comment. The prerequisities fo this change have been pushed, so this one is ready. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D122975/new/ https://reviews.llvm.org/D122975 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits