[Lldb-commits] [PATCH] D142341: [LLDB][NFC] Fix valobj_sp null pointer checks in lldb/source/Plugins/Language/
xgupta added a comment. gentle ping for review. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D142341/new/ https://reviews.llvm.org/D142341 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D143501: [clang][DebugInfo] lldb: Use preferred name's type when emitting DW_AT_names
aprantl added a comment. > Alternatively, I suppose, the DWARF emission could just look at the preferred > name and use that as the DW_AT_type in all cases anyway? Avoids needing a new > attribute, etc, though would be a bit quirky in its own way. Am I understanding you correctly that you suggest we add a new preferred name attribute to DICompositeType and then swap out all uses of those types with references to a typedef using the preferred name and pointing to the unmodified type declaration in AsmPrinter? Why wouldn't we just implement this directly in CGDebugInfo and emit a DIDerivedType(name: "preferred", type: ) and replace all uses of there? Then we wouldn't have to modify the IR format at all? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D143501/new/ https://reviews.llvm.org/D143501 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D144027: [NFC][IR] Make Module::getGlobalList() private
vporpo created this revision. vporpo added a reviewer: aeubanks. Herald added subscribers: mattd, gchakrabarti, asavonic, snehasish, ormris, hiraditya. Herald added a project: All. vporpo requested review of this revision. Herald added subscribers: llvm-commits, lldb-commits, cfe-commits, jholewinski. Herald added projects: clang, LLDB, LLVM. This patch adds several missing GlobalList modifier functions, like removeGlobalVariable(), eraseGlobalVariable() and insertGlobalVariable(). There is no longer need to access the list directly so it also makes getGlobalList() private. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D144027 Files: clang/lib/CodeGen/CGHLSLRuntime.cpp clang/lib/CodeGen/CGObjCMac.cpp lldb/source/Expression/IRExecutionUnit.cpp llvm/docs/ProgrammersManual.rst llvm/include/llvm/IR/Module.h llvm/lib/Bitcode/Reader/BitcodeReader.cpp llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp llvm/lib/IR/Globals.cpp llvm/lib/Linker/IRMover.cpp llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp llvm/lib/Transforms/IPO/GlobalOpt.cpp llvm/lib/Transforms/IPO/SCCP.cpp llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp llvm/lib/Transforms/Utils/CtorUtils.cpp llvm/unittests/IR/ModuleTest.cpp Index: llvm/unittests/IR/ModuleTest.cpp === --- llvm/unittests/IR/ModuleTest.cpp +++ llvm/unittests/IR/ModuleTest.cpp @@ -46,8 +46,11 @@ // Sort the globals by name. EXPECT_FALSE(std::is_sorted(M.global_begin(), M.global_end(), compare)); -M.getGlobalList().sort(compare); -EXPECT_TRUE(std::is_sorted(M.global_begin(), M.global_end(), compare)); +// I removed this because it is testing whether ilist.sort() works, which is +// not Module-specific. This requires access to the full GlobalList for no +// real reason. +// M.getGlobalList().sort(compare); +// EXPECT_TRUE(std::is_sorted(M.global_begin(), M.global_end(), compare)); } } @@ -273,4 +276,43 @@ EXPECT_EQ(M->named_metadata_size(), 2u); } +TEST(ModuleTest, GlobalList) { + // This tests all Module's functions that interact with Module::GlobalList. + LLVMContext C; + SMDiagnostic Err; + LLVMContext Context; + std::unique_ptr M = parseAssemblyString(R"( +@GV = external global i32 +)", + Err, Context); + auto *GV = cast(M->getNamedValue("GV")); + EXPECT_EQ(M->global_size(), 1u); + GlobalVariable *NewGV = new GlobalVariable( + Type::getInt32Ty(C), /*isConstant=*/true, GlobalValue::InternalLinkage, + /*Initializer=*/nullptr, "NewGV"); + EXPECT_EQ(M->global_size(), 1u); + // Insert before + M->insertGlobalVariable(M->globals().begin(), NewGV); + EXPECT_EQ(M->global_size(), 2u); + EXPECT_EQ(&*M->globals().begin(), NewGV); + // Insert at end() + M->removeGlobalVariable(NewGV); + EXPECT_EQ(M->global_size(), 1u); + M->insertGlobalVariable(NewGV); + EXPECT_EQ(M->global_size(), 2u); + EXPECT_EQ(&*std::prev(M->globals().end()), NewGV); + // Check globals() + auto Range = M->globals(); + EXPECT_EQ(&*Range.begin(), GV); + EXPECT_EQ(&*std::next(Range.begin()), NewGV); + EXPECT_EQ(std::next(Range.begin(), 2), Range.end()); + // Check remove + M->removeGlobalVariable(NewGV); + EXPECT_EQ(M->global_size(), 1u); + // Check erase + M->insertGlobalVariable(NewGV); + M->eraseGlobalVariable(NewGV); + EXPECT_EQ(M->global_size(), 1u); +} + } // end namespace Index: llvm/lib/Transforms/Utils/CtorUtils.cpp === --- llvm/lib/Transforms/Utils/CtorUtils.cpp +++ llvm/lib/Transforms/Utils/CtorUtils.cpp @@ -48,7 +48,7 @@ GlobalVariable *NGV = new GlobalVariable(CA->getType(), GCL->isConstant(), GCL->getLinkage(), CA, "", GCL->getThreadLocalMode()); - GCL->getParent()->getGlobalList().insert(GCL->getIterator(), NGV); + GCL->getParent()->insertGlobalVariable(GCL->getIterator(), NGV); NGV->takeName(GCL); // Nuke the old list, replacing any uses with the new one. Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp === --- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -958,7 +958,7 @@ std::vector &Bits, DenseMap> &TypeIdMap) { DenseMap GVToBits; - Bits.reserve(M.getGlobalList().size()); + Bits.reserve(M.global_size()); SmallVector Types; for (GlobalVariable &GV : M.globals()) { Types.clear(); Index: llvm/lib/Transforms/IPO/SCCP.cpp === --- llvm/lib/Transforms/IPO/SCCP.cpp +++ llvm/lib/Transforms/IPO/SCCP.cpp @@ -370,7 +370,7 @@ SI->eraseFromParent(); MadeChanges = true; } -M.getGlobalList().erase(GV); +M.eraseGlobalVariable(GV); ++NumGlobalConst; } @@ -476,4 +476,3 @@ // createIPSCCPPass - This is the public interface to this
[Lldb-commits] [PATCH] D144027: [NFC][IR] Make Module::getGlobalList() private
aeubanks accepted this revision. aeubanks added inline comments. This revision is now accepted and ready to land. Comment at: llvm/unittests/IR/ModuleTest.cpp:49 EXPECT_FALSE(std::is_sorted(M.global_begin(), M.global_end(), compare)); -M.getGlobalList().sort(compare); -EXPECT_TRUE(std::is_sorted(M.global_begin(), M.global_end(), compare)); +// I removed this because it is testing whether ilist.sort() works, which is +// not Module-specific. This requires access to the full GlobalList for no can just delete the commented out lines and add the reasoning behind deleting this either as a phabricator comment or in the commit description Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144027/new/ https://reviews.llvm.org/D144027 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D144027: [NFC][IR] Make Module::getGlobalList() private
vporpo updated this revision to Diff 497367. vporpo marked an inline comment as done. vporpo added a comment. Removed commented out lines from ModuleTest.cpp Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144027/new/ https://reviews.llvm.org/D144027 Files: clang/lib/CodeGen/CGHLSLRuntime.cpp clang/lib/CodeGen/CGObjCMac.cpp lldb/source/Expression/IRExecutionUnit.cpp llvm/docs/ProgrammersManual.rst llvm/include/llvm/IR/Module.h llvm/lib/Bitcode/Reader/BitcodeReader.cpp llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp llvm/lib/IR/Globals.cpp llvm/lib/Linker/IRMover.cpp llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp llvm/lib/Transforms/IPO/GlobalOpt.cpp llvm/lib/Transforms/IPO/SCCP.cpp llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp llvm/lib/Transforms/Utils/CtorUtils.cpp llvm/unittests/IR/ModuleTest.cpp Index: llvm/unittests/IR/ModuleTest.cpp === --- llvm/unittests/IR/ModuleTest.cpp +++ llvm/unittests/IR/ModuleTest.cpp @@ -46,8 +46,6 @@ // Sort the globals by name. EXPECT_FALSE(std::is_sorted(M.global_begin(), M.global_end(), compare)); -M.getGlobalList().sort(compare); -EXPECT_TRUE(std::is_sorted(M.global_begin(), M.global_end(), compare)); } } @@ -273,4 +271,43 @@ EXPECT_EQ(M->named_metadata_size(), 2u); } +TEST(ModuleTest, GlobalList) { + // This tests all Module's functions that interact with Module::GlobalList. + LLVMContext C; + SMDiagnostic Err; + LLVMContext Context; + std::unique_ptr M = parseAssemblyString(R"( +@GV = external global i32 +)", + Err, Context); + auto *GV = cast(M->getNamedValue("GV")); + EXPECT_EQ(M->global_size(), 1u); + GlobalVariable *NewGV = new GlobalVariable( + Type::getInt32Ty(C), /*isConstant=*/true, GlobalValue::InternalLinkage, + /*Initializer=*/nullptr, "NewGV"); + EXPECT_EQ(M->global_size(), 1u); + // Insert before + M->insertGlobalVariable(M->globals().begin(), NewGV); + EXPECT_EQ(M->global_size(), 2u); + EXPECT_EQ(&*M->globals().begin(), NewGV); + // Insert at end() + M->removeGlobalVariable(NewGV); + EXPECT_EQ(M->global_size(), 1u); + M->insertGlobalVariable(NewGV); + EXPECT_EQ(M->global_size(), 2u); + EXPECT_EQ(&*std::prev(M->globals().end()), NewGV); + // Check globals() + auto Range = M->globals(); + EXPECT_EQ(&*Range.begin(), GV); + EXPECT_EQ(&*std::next(Range.begin()), NewGV); + EXPECT_EQ(std::next(Range.begin(), 2), Range.end()); + // Check remove + M->removeGlobalVariable(NewGV); + EXPECT_EQ(M->global_size(), 1u); + // Check erase + M->insertGlobalVariable(NewGV); + M->eraseGlobalVariable(NewGV); + EXPECT_EQ(M->global_size(), 1u); +} + } // end namespace Index: llvm/lib/Transforms/Utils/CtorUtils.cpp === --- llvm/lib/Transforms/Utils/CtorUtils.cpp +++ llvm/lib/Transforms/Utils/CtorUtils.cpp @@ -48,7 +48,7 @@ GlobalVariable *NGV = new GlobalVariable(CA->getType(), GCL->isConstant(), GCL->getLinkage(), CA, "", GCL->getThreadLocalMode()); - GCL->getParent()->getGlobalList().insert(GCL->getIterator(), NGV); + GCL->getParent()->insertGlobalVariable(GCL->getIterator(), NGV); NGV->takeName(GCL); // Nuke the old list, replacing any uses with the new one. Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp === --- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -958,7 +958,7 @@ std::vector &Bits, DenseMap> &TypeIdMap) { DenseMap GVToBits; - Bits.reserve(M.getGlobalList().size()); + Bits.reserve(M.global_size()); SmallVector Types; for (GlobalVariable &GV : M.globals()) { Types.clear(); Index: llvm/lib/Transforms/IPO/SCCP.cpp === --- llvm/lib/Transforms/IPO/SCCP.cpp +++ llvm/lib/Transforms/IPO/SCCP.cpp @@ -370,7 +370,7 @@ SI->eraseFromParent(); MadeChanges = true; } -M.getGlobalList().erase(GV); +M.eraseGlobalVariable(GV); ++NumGlobalConst; } @@ -476,4 +476,3 @@ // createIPSCCPPass - This is the public interface to this file. ModulePass *llvm::createIPSCCPPass() { return new IPSCCPLegacyPass(); } - Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp === --- llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -976,7 +976,7 @@ cast(InitBool->user_back())->eraseFromParent(); delete InitBool; } else -GV->getParent()->getGlobalList().insert(GV->getIterator(), InitBool); +GV->getParent()->insertGlobalVariable(GV->getIterator(), InitBool); // Now the GV is dead, nuke it and the allocation.. GV->eraseFromParent(); @@ -1158,7 +1158,7 @@
[Lldb-commits] [PATCH] D144027: [NFC][IR] Make Module::getGlobalList() private
vporpo added inline comments. Comment at: llvm/unittests/IR/ModuleTest.cpp:47-49 // Sort the globals by name. EXPECT_FALSE(std::is_sorted(M.global_begin(), M.global_end(), compare)); -M.getGlobalList().sort(compare); I removed this because it is testing whether ilist.sort() works, which is not Module-specific. This requires access to the full GlobalList for no real reason. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144027/new/ https://reviews.llvm.org/D144027 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] eaeb8dd - [LLDB] add arch-specific watchpoint behavior defaults to lldb
Author: Jason Molenda Date: 2023-02-14T11:35:39-08:00 New Revision: eaeb8ddd4a9d3799470479a532e721d017f22a70 URL: https://github.com/llvm/llvm-project/commit/eaeb8ddd4a9d3799470479a532e721d017f22a70 DIFF: https://github.com/llvm/llvm-project/commit/eaeb8ddd4a9d3799470479a532e721d017f22a70.diff LOG: [LLDB] add arch-specific watchpoint behavior defaults to lldb lldb was originally designed to get the watchpoint exception behavior from the gdb remote serial protocol stub -- exceptions are either received before the instruction executes, or after the instruction has executed. This behavior was reported via two lldb extensions to gdb RSP, so generic remote stubs like gdbserver or a JTAG stub, would not tell lldb which behavior was correct, and it would default to "exceptions are received after the instruction has executed". Two architectures hard coded their correct "exceptions before instruction" behavior, to work around this issue. Most architectures have a fixed behavior of watchpoint exceptions, and we can center that information in lldb. We can allow a remote stub to override the default behavior via our packet extensions if it's needed on a specific target. This patch also separates the fetching of the number of watchpoints from whether exceptions are before/after the insn. Currently if lldb couldn't fetch the number of watchpoints (not really needed), it also wouldn't get when exceptions are received, and watchpoint handling would fail. lldb doesn't actually use the number of watchpoints for anything beyond printing it to the user. Differential Revision: https://reviews.llvm.org/D143215 rdar://101426626 Added: Modified: lldb/include/lldb/Target/Process.h lldb/source/API/SBProcess.cpp lldb/source/Commands/CommandObjectWatchpoint.cpp lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/source/Target/Process.cpp lldb/source/Target/StopInfo.cpp lldb/source/Target/Target.cpp Removed: diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 9862b6e57212..3ffacb52299b 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -1817,20 +1818,35 @@ class Process : public std::enable_shared_from_this, virtual Status GetMemoryRegions(lldb_private::MemoryRegionInfos ®ion_list); - virtual Status GetWatchpointSupportInfo(uint32_t &num) { -Status error; -num = 0; -error.SetErrorString("Process::GetWatchpointSupportInfo() not supported"); -return error; + /// Get the number of watchpoints supported by this target. + /// + /// We may be able to determine the number of watchpoints available + /// on this target; retrieve this value if possible. + /// + /// This number may be less than the number of watchpoints a user + /// can specify. This is because a single user watchpoint may require + /// multiple watchpoint slots to implement. Due to the size + /// and/or alignment of objects. + /// + /// \return + /// Returns the number of watchpoints, if available. + virtual std::optional GetWatchpointSlotCount() { +return std::nullopt; } - virtual Status GetWatchpointSupportInfo(uint32_t &num, bool &after) { -Status error; -num = 0; -after = true; -error.SetErrorString("Process::GetWatchpointSupportInfo() not supported"); -return error; - } + /// Whether lldb will be notified about watchpoints after + /// the instruction has completed executing, or if the + /// instruction is rolled back and it is notified before it + /// executes. + /// The default behavior is "exceptions received after instruction + /// has executed", except for certain CPU architectures. + /// Process subclasses may override this if they have additional + /// information. + /// + /// \return + /// Returns true for targets where lldb is notified after + /// the instruction has completed executing. + bool GetWatchpointReportedAfter(); lldb::ModuleSP ReadModuleFromMemory(const FileSpec &file_spec, lldb::addr_t header_addr, @@ -2663,6 +2679,24 @@ void PruneThreadPlans(); return Status("Process::DoGetMemoryRegionInfo() not supported"); } + /// Provide an override value in the subclass for lldb's + /// CPU-based logic for whether watchpoint exceptions are + /// received before or after an instruction
[Lldb-commits] [PATCH] D143215: lldb can know architecture-dependent watchpoint behaviors, instead of depending on the remote stub
This revision was automatically updated to reflect the committed changes. Closed by commit rGeaeb8ddd4a9d: [LLDB] add arch-specific watchpoint behavior defaults to lldb (authored by jasonmolenda). Changed prior to commit: https://reviews.llvm.org/D143215?vs=495976&id=497401#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D143215/new/ https://reviews.llvm.org/D143215 Files: lldb/include/lldb/Target/Process.h lldb/source/API/SBProcess.cpp lldb/source/Commands/CommandObjectWatchpoint.cpp lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/source/Target/Process.cpp lldb/source/Target/StopInfo.cpp lldb/source/Target/Target.cpp Index: lldb/source/Target/Target.cpp === --- lldb/source/Target/Target.cpp +++ lldb/source/Target/Target.cpp @@ -790,19 +790,18 @@ } static bool CheckIfWatchpointsSupported(Target *target, Status &error) { - uint32_t num_supported_hardware_watchpoints; - Status rc = target->GetProcessSP()->GetWatchpointSupportInfo( - num_supported_hardware_watchpoints); + std::optional num_supported_hardware_watchpoints = + target->GetProcessSP()->GetWatchpointSlotCount(); // If unable to determine the # of watchpoints available, // assume they are supported. - if (rc.Fail()) + if (!num_supported_hardware_watchpoints) return true; if (num_supported_hardware_watchpoints == 0) { error.SetErrorStringWithFormat( "Target supports (%u) hardware watchpoint slots.\n", -num_supported_hardware_watchpoints); +*num_supported_hardware_watchpoints); return false; } return true; Index: lldb/source/Target/StopInfo.cpp === --- lldb/source/Target/StopInfo.cpp +++ lldb/source/Target/StopInfo.cpp @@ -823,16 +823,8 @@ // stop ProcessSP process_sp = exe_ctx.GetProcessSP(); -uint32_t num; -bool wp_triggers_after; +bool wp_triggers_after = process_sp->GetWatchpointReportedAfter(); -if (!process_sp->GetWatchpointSupportInfo(num, wp_triggers_after) -.Success()) { - m_should_stop_is_valid = true; - m_should_stop = true; - return m_should_stop; -} - if (!wp_triggers_after) { // We have to step over the watchpoint before we know what to do: StopInfoWatchpointSP me_as_siwp_sp Index: lldb/source/Target/Process.cpp === --- lldb/source/Target/Process.cpp +++ lldb/source/Target/Process.cpp @@ -2355,6 +2355,23 @@ return error; } +bool Process::GetWatchpointReportedAfter() { + if (std::optional subclass_override = DoGetWatchpointReportedAfter()) +return *subclass_override; + + bool reported_after = true; + const ArchSpec &arch = GetTarget().GetArchitecture(); + if (!arch.IsValid()) +return reported_after; + llvm::Triple triple = arch.GetTriple(); + + if (triple.isMIPS() || triple.isPPC64() || triple.isRISCV() || + triple.isAArch64() || triple.isArmMClass() || triple.isARM()) +reported_after = false; + + return reported_after; +} + ModuleSP Process::ReadModuleFromMemory(const FileSpec &file_spec, lldb::addr_t header_addr, size_t size_to_read) { Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h === --- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -159,7 +159,7 @@ Status DisableWatchpoint(Watchpoint *wp, bool notify = true) override; - Status GetWatchpointSupportInfo(uint32_t &num) override; + std::optional GetWatchpointSlotCount() override; llvm::Expected TraceSupported() override; @@ -172,7 +172,7 @@ llvm::Expected> TraceGetBinaryData(const TraceGetBinaryDataRequest &request) override; - Status GetWatchpointSupportInfo(uint32_t &num, bool &after) override; + std::optional DoGetWatchpointReportedAfter() override; bool StartNoticingNewThreads() override; Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp === --- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2818,16 +2818,12 @@ return error; } -Status ProcessGDBRemote::GetWatchpointSupportInfo(uint32
[Lldb-commits] [PATCH] D144027: [NFC][IR] Make Module::getGlobalList() private
vporpo updated this revision to Diff 497403. vporpo added a comment. Rebase Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144027/new/ https://reviews.llvm.org/D144027 Files: clang/lib/CodeGen/CGHLSLRuntime.cpp clang/lib/CodeGen/CGObjCMac.cpp lldb/source/Expression/IRExecutionUnit.cpp llvm/docs/ProgrammersManual.rst llvm/include/llvm/IR/Module.h llvm/lib/Bitcode/Reader/BitcodeReader.cpp llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp llvm/lib/IR/Globals.cpp llvm/lib/Linker/IRMover.cpp llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp llvm/lib/Transforms/IPO/GlobalOpt.cpp llvm/lib/Transforms/IPO/SCCP.cpp llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp llvm/lib/Transforms/Utils/CtorUtils.cpp llvm/unittests/IR/ModuleTest.cpp Index: llvm/unittests/IR/ModuleTest.cpp === --- llvm/unittests/IR/ModuleTest.cpp +++ llvm/unittests/IR/ModuleTest.cpp @@ -46,8 +46,6 @@ // Sort the globals by name. EXPECT_FALSE(std::is_sorted(M.global_begin(), M.global_end(), compare)); -M.getGlobalList().sort(compare); -EXPECT_TRUE(std::is_sorted(M.global_begin(), M.global_end(), compare)); } } @@ -273,4 +271,43 @@ EXPECT_EQ(M->named_metadata_size(), 2u); } +TEST(ModuleTest, GlobalList) { + // This tests all Module's functions that interact with Module::GlobalList. + LLVMContext C; + SMDiagnostic Err; + LLVMContext Context; + std::unique_ptr M = parseAssemblyString(R"( +@GV = external global i32 +)", + Err, Context); + auto *GV = cast(M->getNamedValue("GV")); + EXPECT_EQ(M->global_size(), 1u); + GlobalVariable *NewGV = new GlobalVariable( + Type::getInt32Ty(C), /*isConstant=*/true, GlobalValue::InternalLinkage, + /*Initializer=*/nullptr, "NewGV"); + EXPECT_EQ(M->global_size(), 1u); + // Insert before + M->insertGlobalVariable(M->globals().begin(), NewGV); + EXPECT_EQ(M->global_size(), 2u); + EXPECT_EQ(&*M->globals().begin(), NewGV); + // Insert at end() + M->removeGlobalVariable(NewGV); + EXPECT_EQ(M->global_size(), 1u); + M->insertGlobalVariable(NewGV); + EXPECT_EQ(M->global_size(), 2u); + EXPECT_EQ(&*std::prev(M->globals().end()), NewGV); + // Check globals() + auto Range = M->globals(); + EXPECT_EQ(&*Range.begin(), GV); + EXPECT_EQ(&*std::next(Range.begin()), NewGV); + EXPECT_EQ(std::next(Range.begin(), 2), Range.end()); + // Check remove + M->removeGlobalVariable(NewGV); + EXPECT_EQ(M->global_size(), 1u); + // Check erase + M->insertGlobalVariable(NewGV); + M->eraseGlobalVariable(NewGV); + EXPECT_EQ(M->global_size(), 1u); +} + } // end namespace Index: llvm/lib/Transforms/Utils/CtorUtils.cpp === --- llvm/lib/Transforms/Utils/CtorUtils.cpp +++ llvm/lib/Transforms/Utils/CtorUtils.cpp @@ -48,7 +48,7 @@ GlobalVariable *NGV = new GlobalVariable(CA->getType(), GCL->isConstant(), GCL->getLinkage(), CA, "", GCL->getThreadLocalMode()); - GCL->getParent()->getGlobalList().insert(GCL->getIterator(), NGV); + GCL->getParent()->insertGlobalVariable(GCL->getIterator(), NGV); NGV->takeName(GCL); // Nuke the old list, replacing any uses with the new one. Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp === --- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -958,7 +958,7 @@ std::vector &Bits, DenseMap> &TypeIdMap) { DenseMap GVToBits; - Bits.reserve(M.getGlobalList().size()); + Bits.reserve(M.global_size()); SmallVector Types; for (GlobalVariable &GV : M.globals()) { Types.clear(); Index: llvm/lib/Transforms/IPO/SCCP.cpp === --- llvm/lib/Transforms/IPO/SCCP.cpp +++ llvm/lib/Transforms/IPO/SCCP.cpp @@ -370,7 +370,7 @@ SI->eraseFromParent(); MadeChanges = true; } -M.getGlobalList().erase(GV); +M.eraseGlobalVariable(GV); ++NumGlobalConst; } @@ -476,4 +476,3 @@ // createIPSCCPPass - This is the public interface to this file. ModulePass *llvm::createIPSCCPPass() { return new IPSCCPLegacyPass(); } - Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp === --- llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -976,7 +976,7 @@ cast(InitBool->user_back())->eraseFromParent(); delete InitBool; } else -GV->getParent()->getGlobalList().insert(GV->getIterator(), InitBool); +GV->getParent()->insertGlobalVariable(GV->getIterator(), InitBool); // Now the GV is dead, nuke it and the allocation.. GV->eraseFromParent(); @@ -1158,7 +1158,7 @@ GV->getThreadLocalMode(),
[Lldb-commits] [PATCH] D142926: [lldb] Replace SB swig interfaces with API headers
mib accepted this revision. mib added a comment. This revision is now accepted and ready to land. LGTM! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D142926/new/ https://reviews.llvm.org/D142926 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D144042: [lldb] Rename SetResultIsInternal to SetSuppressPersistentResult (NFC)
kastiglione created this revision. kastiglione added reviewers: jingham, Michael137, augusto2112. Herald added a project: All. kastiglione requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Rename `SetResultIsInternal` and `GetResultIsInternal` to `SetSuppressPersistentResult` and `GetSuppressPersistentResult` respectively. Also rename `m_result_is_internal`. This matches the naming in the SB API. A separate change calls `SetSuppressPersistentResult`, where the name `SetResultIsInternal` doesn't quite fit. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D144042 Files: lldb/include/lldb/Target/Target.h lldb/source/API/SBExpressionOptions.cpp lldb/source/Breakpoint/BreakpointLocation.cpp lldb/source/Expression/UserExpression.cpp Index: lldb/source/Expression/UserExpression.cpp === --- lldb/source/Expression/UserExpression.cpp +++ lldb/source/Expression/UserExpression.cpp @@ -424,7 +424,7 @@ lldb::ExpressionResults expr_result = DoExecute( diagnostic_manager, exe_ctx, options, shared_ptr_to_me, result_var); Target *target = exe_ctx.GetTargetPtr(); - if (options.GetResultIsInternal() && result_var && target) { + if (options.GetSuppressPersistentResult() && result_var && target) { if (auto *persistent_state = target->GetPersistentExpressionStateForLanguage(m_language)) persistent_state->RemovePersistentVariable(result_var); Index: lldb/source/Breakpoint/BreakpointLocation.cpp === --- lldb/source/Breakpoint/BreakpointLocation.cpp +++ lldb/source/Breakpoint/BreakpointLocation.cpp @@ -290,7 +290,7 @@ options.SetUnwindOnError(true); options.SetIgnoreBreakpoints(true); options.SetTryAllThreads(true); - options.SetResultIsInternal( + options.SetSuppressPersistentResult( true); // Don't generate a user variable for condition expressions. Status expr_error; Index: lldb/source/API/SBExpressionOptions.cpp === --- lldb/source/API/SBExpressionOptions.cpp +++ lldb/source/API/SBExpressionOptions.cpp @@ -178,13 +178,13 @@ bool SBExpressionOptions::GetSuppressPersistentResult() { LLDB_INSTRUMENT_VA(this); - return m_opaque_up->GetResultIsInternal(); + return m_opaque_up->GetSuppressPersistentResult(); } void SBExpressionOptions::SetSuppressPersistentResult(bool b) { LLDB_INSTRUMENT_VA(this, b); - return m_opaque_up->SetResultIsInternal(b); + return m_opaque_up->SetSuppressPersistentResult(b); } const char *SBExpressionOptions::GetPrefix() const { Index: lldb/include/lldb/Target/Target.h === --- lldb/include/lldb/Target/Target.h +++ lldb/include/lldb/Target/Target.h @@ -413,9 +413,11 @@ uint32_t GetPoundLineLine() const { return m_pound_line_line; } - void SetResultIsInternal(bool b) { m_result_is_internal = b; } + void SetSuppressPersistentResult(bool b) { m_suppress_persistent_result = b; } - bool GetResultIsInternal() const { return m_result_is_internal; } + bool GetSuppressPersistentResult() const { +return m_suppress_persistent_result; + } void SetAutoApplyFixIts(bool b) { m_auto_apply_fixits = b; } @@ -446,7 +448,7 @@ bool m_repl = false; bool m_generate_debug_info = false; bool m_ansi_color_errors = false; - bool m_result_is_internal = false; + bool m_suppress_persistent_result = false; bool m_auto_apply_fixits = true; uint64_t m_retries_with_fixits = 1; /// True if the executed code should be treated as utility code that is only Index: lldb/source/Expression/UserExpression.cpp === --- lldb/source/Expression/UserExpression.cpp +++ lldb/source/Expression/UserExpression.cpp @@ -424,7 +424,7 @@ lldb::ExpressionResults expr_result = DoExecute( diagnostic_manager, exe_ctx, options, shared_ptr_to_me, result_var); Target *target = exe_ctx.GetTargetPtr(); - if (options.GetResultIsInternal() && result_var && target) { + if (options.GetSuppressPersistentResult() && result_var && target) { if (auto *persistent_state = target->GetPersistentExpressionStateForLanguage(m_language)) persistent_state->RemovePersistentVariable(result_var); Index: lldb/source/Breakpoint/BreakpointLocation.cpp === --- lldb/source/Breakpoint/BreakpointLocation.cpp +++ lldb/source/Breakpoint/BreakpointLocation.cpp @@ -290,7 +290,7 @@ options.SetUnwindOnError(true); options.SetIgnoreBreakpoints(true); options.SetTryAllThreads(true); - options.SetResultIsInternal( + options.SetSuppressPersistentResult( true); // Don't generate a user variable for condition expressions. Status expr_error; Index: lldb/sou
[Lldb-commits] [lldb] 9093f3c - Report a useful error when someone passes an incorrect python class name.
Author: Jim Ingham Date: 2023-02-14T13:47:14-08:00 New Revision: 9093f3c39b8fa8ef836c627e1db329cd7349e9bb URL: https://github.com/llvm/llvm-project/commit/9093f3c39b8fa8ef836c627e1db329cd7349e9bb DIFF: https://github.com/llvm/llvm-project/commit/9093f3c39b8fa8ef836c627e1db329cd7349e9bb.diff LOG: Report a useful error when someone passes an incorrect python class name. Added: Modified: lldb/source/Commands/CommandObjectCommands.cpp lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/test/API/commands/command/script/TestCommandScript.py Removed: diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index f06dec8328c9d..254e226772dfa 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -1600,7 +1600,8 @@ class CommandObjectCommandsScriptAdd : public CommandObjectParsed, auto cmd_obj_sp = interpreter->CreateScriptCommandObject( m_options.m_class_name.c_str()); if (!cmd_obj_sp) { -result.AppendError("cannot create helper object"); +result.AppendErrorWithFormatv("cannot create helper object for: " + "'{0}'", m_options.m_class_name); return false; } diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 3c0aa29071968..1a2307424750d 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -1949,8 +1949,11 @@ ScriptInterpreterPythonImpl::CreateScriptCommandObject(const char *class_name) { PythonObject ret_val = LLDBSwigPythonCreateCommandObject( class_name, m_dictionary_name.c_str(), debugger_sp); - return StructuredData::GenericSP( - new StructuredPythonObject(std::move(ret_val))); + if (ret_val.IsValid()) +return StructuredData::GenericSP( +new StructuredPythonObject(std::move(ret_val))); + else +return {}; } bool ScriptInterpreterPythonImpl::GenerateTypeScriptFunction( diff --git a/lldb/test/API/commands/command/script/TestCommandScript.py b/lldb/test/API/commands/command/script/TestCommandScript.py index 756cb4a3632f8..7e8206ca96a48 100644 --- a/lldb/test/API/commands/command/script/TestCommandScript.py +++ b/lldb/test/API/commands/command/script/TestCommandScript.py @@ -164,6 +164,10 @@ def cleanup(): # This should not crash. self.runCmd('bug11569', check=False) +# Make sure that a reference to a non-existent class raises an error: +bad_class_name = "LLDBNoSuchModule.LLDBNoSuchClass" +self.expect("command script add wont-work --class {0}".format(bad_class_name), error=True, substrs = [bad_class_name]) + def test_persistence(self): """ Ensure that function arguments meaningfully persist (and do not crash!) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D144044: [lldb] Suppress persistent result when running po
kastiglione created this revision. kastiglione added reviewers: jingham, Michael137, augusto2112. Herald added a project: All. kastiglione requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Remove the persistent result variable after executing `po`. Without this change, the following behavior happens: (lldb) p thing (NSObject *) $0 = 0x60008000 (lldb) po thing (lldb) p thing (NSObject *) $2 = 0x60008000 (lldb) p $1 (NSObject *) $1 = 0x60008000 Even though `po` hides the persistent result variable, it's still created - as $1 in this example. It can be accessed even though its existence is not evident. With this change, the persistent result is removed after the object description has printed. Instead, this is the behavior: (lldb) p thing (NSObject *) $0 = 0x60008000 (lldb) po thing (lldb) p thing (NSObject *) $1 = 0x60008000 The difference here is that the `po` doens't silently create a persistent result. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D144044 Files: lldb/source/Commands/CommandObjectExpression.cpp Index: lldb/source/Commands/CommandObjectExpression.cpp === --- lldb/source/Commands/CommandObjectExpression.cpp +++ lldb/source/Commands/CommandObjectExpression.cpp @@ -346,6 +346,7 @@ CommandObjectExpression::GetEvalOptions(const Target &target) { EvaluateExpressionOptions options; options.SetCoerceToId(m_varobj_options.use_objc); + options.SetSuppressPersistentResult(m_varobj_options.use_objc); options.SetUnwindOnError(m_command_options.unwind_on_error); options.SetIgnoreBreakpoints(m_command_options.ignore_breakpoints); options.SetKeepInMemory(true); Index: lldb/source/Commands/CommandObjectExpression.cpp === --- lldb/source/Commands/CommandObjectExpression.cpp +++ lldb/source/Commands/CommandObjectExpression.cpp @@ -346,6 +346,7 @@ CommandObjectExpression::GetEvalOptions(const Target &target) { EvaluateExpressionOptions options; options.SetCoerceToId(m_varobj_options.use_objc); + options.SetSuppressPersistentResult(m_varobj_options.use_objc); options.SetUnwindOnError(m_command_options.unwind_on_error); options.SetIgnoreBreakpoints(m_command_options.ignore_breakpoints); options.SetKeepInMemory(true); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D144044: [lldb] Suppress persistent result when running po
kastiglione added a comment. I'll update with a test. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144044/new/ https://reviews.llvm.org/D144044 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D139740: [lldb] Disable macro redefinition warnings in expression wrapper
teemperor updated this revision to Diff 497440. teemperor added a comment. - Address builtin redefining (Thanks Michael!) CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139740/new/ https://reviews.llvm.org/D139740 Files: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp lldb/test/API/commands/expression/macros/TestMacros.py Index: lldb/test/API/commands/expression/macros/TestMacros.py === --- lldb/test/API/commands/expression/macros/TestMacros.py +++ lldb/test/API/commands/expression/macros/TestMacros.py @@ -129,3 +129,9 @@ result = frame.EvaluateExpression("MACRO_2") self.assertTrue(result.GetError().Fail(), "Printing MACRO_2 fails in the header file") + +# Check that the macro definitions do not trigger bogus Clang +# diagnostics about macro redefinitions. +result = frame.EvaluateExpression("does_not_parse") +self.assertNotIn("macro redefined", str(result.GetError())) +self.assertNotIn("redefining builtin macro", str(result.GetError())) Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp === --- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp @@ -14,6 +14,7 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" #include "clang/Lex/Lexer.h" +#include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/StringRef.h" #include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h" @@ -141,6 +142,17 @@ if (dm == nullptr) return; + // The macros directives below can potentially redefine builtin macros of the + // Clang instance which parses the user expression. The Clang diagnostics + // caused by this are not useful for the user as the source code here is + // generated by LLDB. + stream << "#pragma clang diagnostic push\n"; + stream << "#pragma clang diagnostic ignored \"-Wmacro-redefined\"\n"; + stream << "#pragma clang diagnostic ignored \"-Wbuiltin-macro-redefined\"\n"; + auto pop_warning = llvm::make_scope_exit([&stream](){ +stream << "#pragma clang diagnostic pop\n"; + }); + for (size_t i = 0; i < dm->GetNumMacroEntries(); i++) { const DebugMacroEntry &entry = dm->GetMacroEntryAtIndex(i); uint32_t line; Index: lldb/test/API/commands/expression/macros/TestMacros.py === --- lldb/test/API/commands/expression/macros/TestMacros.py +++ lldb/test/API/commands/expression/macros/TestMacros.py @@ -129,3 +129,9 @@ result = frame.EvaluateExpression("MACRO_2") self.assertTrue(result.GetError().Fail(), "Printing MACRO_2 fails in the header file") + +# Check that the macro definitions do not trigger bogus Clang +# diagnostics about macro redefinitions. +result = frame.EvaluateExpression("does_not_parse") +self.assertNotIn("macro redefined", str(result.GetError())) +self.assertNotIn("redefining builtin macro", str(result.GetError())) Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp === --- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp @@ -14,6 +14,7 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" #include "clang/Lex/Lexer.h" +#include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/StringRef.h" #include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h" @@ -141,6 +142,17 @@ if (dm == nullptr) return; + // The macros directives below can potentially redefine builtin macros of the + // Clang instance which parses the user expression. The Clang diagnostics + // caused by this are not useful for the user as the source code here is + // generated by LLDB. + stream << "#pragma clang diagnostic push\n"; + stream << "#pragma clang diagnostic ignored \"-Wmacro-redefined\"\n"; + stream << "#pragma clang diagnostic ignored \"-Wbuiltin-macro-redefined\"\n"; + auto pop_warning = llvm::make_scope_exit([&stream](){ +stream << "#pragma clang diagnostic pop\n"; + }); + for (size_t i = 0; i < dm->GetNumMacroEntries(); i++) { const DebugMacroEntry &entry = dm->GetMacroEntryAtIndex(i); uint32_t line; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D139740: [lldb] Disable macro redefinition warnings in expression wrapper
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG9f3a3e1f3f97: [lldb] Disable macro redefinition warnings in expression wrapper (authored by teemperor). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139740/new/ https://reviews.llvm.org/D139740 Files: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp lldb/test/API/commands/expression/macros/TestMacros.py Index: lldb/test/API/commands/expression/macros/TestMacros.py === --- lldb/test/API/commands/expression/macros/TestMacros.py +++ lldb/test/API/commands/expression/macros/TestMacros.py @@ -129,3 +129,9 @@ result = frame.EvaluateExpression("MACRO_2") self.assertTrue(result.GetError().Fail(), "Printing MACRO_2 fails in the header file") + +# Check that the macro definitions do not trigger bogus Clang +# diagnostics about macro redefinitions. +result = frame.EvaluateExpression("does_not_parse") +self.assertNotIn("macro redefined", str(result.GetError())) +self.assertNotIn("redefining builtin macro", str(result.GetError())) Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp === --- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp @@ -14,6 +14,7 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" #include "clang/Lex/Lexer.h" +#include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/StringRef.h" #include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h" @@ -141,6 +142,17 @@ if (dm == nullptr) return; + // The macros directives below can potentially redefine builtin macros of the + // Clang instance which parses the user expression. The Clang diagnostics + // caused by this are not useful for the user as the source code here is + // generated by LLDB. + stream << "#pragma clang diagnostic push\n"; + stream << "#pragma clang diagnostic ignored \"-Wmacro-redefined\"\n"; + stream << "#pragma clang diagnostic ignored \"-Wbuiltin-macro-redefined\"\n"; + auto pop_warning = llvm::make_scope_exit([&stream](){ +stream << "#pragma clang diagnostic pop\n"; + }); + for (size_t i = 0; i < dm->GetNumMacroEntries(); i++) { const DebugMacroEntry &entry = dm->GetMacroEntryAtIndex(i); uint32_t line; Index: lldb/test/API/commands/expression/macros/TestMacros.py === --- lldb/test/API/commands/expression/macros/TestMacros.py +++ lldb/test/API/commands/expression/macros/TestMacros.py @@ -129,3 +129,9 @@ result = frame.EvaluateExpression("MACRO_2") self.assertTrue(result.GetError().Fail(), "Printing MACRO_2 fails in the header file") + +# Check that the macro definitions do not trigger bogus Clang +# diagnostics about macro redefinitions. +result = frame.EvaluateExpression("does_not_parse") +self.assertNotIn("macro redefined", str(result.GetError())) +self.assertNotIn("redefining builtin macro", str(result.GetError())) Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp === --- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp @@ -14,6 +14,7 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" #include "clang/Lex/Lexer.h" +#include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/StringRef.h" #include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h" @@ -141,6 +142,17 @@ if (dm == nullptr) return; + // The macros directives below can potentially redefine builtin macros of the + // Clang instance which parses the user expression. The Clang diagnostics + // caused by this are not useful for the user as the source code here is + // generated by LLDB. + stream << "#pragma clang diagnostic push\n"; + stream << "#pragma clang diagnostic ignored \"-Wmacro-redefined\"\n"; + stream << "#pragma clang diagnostic ignored \"-Wbuiltin-macro-redefined\"\n"; + auto pop_warning = llvm::make_scope_exit([&stream](){ +stream << "#pragma clang diagnostic pop\n"; + }); + for (size_t i = 0; i < dm->GetNumMacroEntries(); i++) { const DebugMacroEntry &entry = dm->GetMacroEntryAtIndex(i); uint32_t line; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 9f3a3e1 - [lldb] Disable macro redefinition warnings in expression wrapper
Author: Raphael Isemann Date: 2023-02-14T23:20:56+01:00 New Revision: 9f3a3e1f3f9767ae52c492d20d63f65e82319ed2 URL: https://github.com/llvm/llvm-project/commit/9f3a3e1f3f9767ae52c492d20d63f65e82319ed2 DIFF: https://github.com/llvm/llvm-project/commit/9f3a3e1f3f9767ae52c492d20d63f65e82319ed2.diff LOG: [lldb] Disable macro redefinition warnings in expression wrapper GCC emits macro definitions into debug info when compiling with `-g3`. LLDB is translating this information into `#define` directives which are injected into the source code of user expressions. While this mechanism itself works fine, it can lead to spurious "... macro redefined" warnings when the defined macro is also a builtin Clang macro: ``` warning: :46:9: '__VERSION__' macro redefined ^ :19:9: previous definition is here [repeated about a 100 more times for every builtin macro] ``` This patch just disables the diagnostic when parsing LLDB's generated list of macros definitions. Reviewed By: Michael137 Differential Revision: https://reviews.llvm.org/D139740 Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp lldb/test/API/commands/expression/macros/TestMacros.py Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp index 56c00b35ba11b..cc3abfdfde394 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp @@ -14,6 +14,7 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" #include "clang/Lex/Lexer.h" +#include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/StringRef.h" #include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h" @@ -141,6 +142,17 @@ static void AddMacros(const DebugMacros *dm, CompileUnit *comp_unit, if (dm == nullptr) return; + // The macros directives below can potentially redefine builtin macros of the + // Clang instance which parses the user expression. The Clang diagnostics + // caused by this are not useful for the user as the source code here is + // generated by LLDB. + stream << "#pragma clang diagnostic push\n"; + stream << "#pragma clang diagnostic ignored \"-Wmacro-redefined\"\n"; + stream << "#pragma clang diagnostic ignored \"-Wbuiltin-macro-redefined\"\n"; + auto pop_warning = llvm::make_scope_exit([&stream](){ +stream << "#pragma clang diagnostic pop\n"; + }); + for (size_t i = 0; i < dm->GetNumMacroEntries(); i++) { const DebugMacroEntry &entry = dm->GetMacroEntryAtIndex(i); uint32_t line; diff --git a/lldb/test/API/commands/expression/macros/TestMacros.py b/lldb/test/API/commands/expression/macros/TestMacros.py index 3e5d720aef77b..b39572b6e4408 100644 --- a/lldb/test/API/commands/expression/macros/TestMacros.py +++ b/lldb/test/API/commands/expression/macros/TestMacros.py @@ -129,3 +129,9 @@ def test_expr_with_macros(self): result = frame.EvaluateExpression("MACRO_2") self.assertTrue(result.GetError().Fail(), "Printing MACRO_2 fails in the header file") + +# Check that the macro definitions do not trigger bogus Clang +# diagnostics about macro redefinitions. +result = frame.EvaluateExpression("does_not_parse") +self.assertNotIn("macro redefined", str(result.GetError())) +self.assertNotIn("redefining builtin macro", str(result.GetError())) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ed3e3ee - [NFC][IR] Make Module::getGlobalList() private
Author: Vasileios Porpodas Date: 2023-02-14T14:25:10-08:00 New Revision: ed3e3ee9e30dfbffd2170a770a49b36a7f444916 URL: https://github.com/llvm/llvm-project/commit/ed3e3ee9e30dfbffd2170a770a49b36a7f444916 DIFF: https://github.com/llvm/llvm-project/commit/ed3e3ee9e30dfbffd2170a770a49b36a7f444916.diff LOG: [NFC][IR] Make Module::getGlobalList() private This patch adds several missing GlobalList modifier functions, like removeGlobalVariable(), eraseGlobalVariable() and insertGlobalVariable(). There is no longer need to access the list directly so it also makes getGlobalList() private. Differential Revision: https://reviews.llvm.org/D144027 Added: Modified: clang/lib/CodeGen/CGHLSLRuntime.cpp clang/lib/CodeGen/CGObjCMac.cpp lldb/source/Expression/IRExecutionUnit.cpp llvm/docs/ProgrammersManual.rst llvm/include/llvm/IR/Module.h llvm/lib/Bitcode/Reader/BitcodeReader.cpp llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp llvm/lib/IR/Globals.cpp llvm/lib/Linker/IRMover.cpp llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp llvm/lib/Transforms/IPO/GlobalOpt.cpp llvm/lib/Transforms/IPO/SCCP.cpp llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp llvm/lib/Transforms/Utils/CtorUtils.cpp llvm/unittests/IR/ModuleTest.cpp Removed: diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp index 5882f491d5972..e9fa273f21cc8 100644 --- a/clang/lib/CodeGen/CGHLSLRuntime.cpp +++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp @@ -175,7 +175,7 @@ void CGHLSLRuntime::finishCodeGen() { for (auto &Buf : Buffers) { layoutBuffer(Buf, DL); GlobalVariable *GV = replaceBuffer(Buf); -M.getGlobalList().push_back(GV); +M.insertGlobalVariable(GV); llvm::hlsl::ResourceClass RC = Buf.IsCBuffer ? llvm::hlsl::ResourceClass::CBuffer : llvm::hlsl::ResourceClass::SRV; diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index c739d3742f801..5f4cdc6d91f1d 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -7431,7 +7431,7 @@ CGObjCNonFragileABIMac::GetClassGlobal(StringRef Name, GV->eraseFromParent(); } GV = NewGV; -CGM.getModule().getGlobalList().push_back(GV); +CGM.getModule().insertGlobalVariable(GV); } assert(GV->getLinkage() == L); diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index 73a49e552e3d2..f3cf0f623d24f 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -406,7 +406,7 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr, } }; - for (llvm::GlobalVariable &global_var : m_module->getGlobalList()) { + for (llvm::GlobalVariable &global_var : m_module->globals()) { RegisterOneValue(global_var); } diff --git a/llvm/docs/ProgrammersManual.rst b/llvm/docs/ProgrammersManual.rst index 00d51a5a05b85..71298f4a87828 100644 --- a/llvm/docs/ProgrammersManual.rst +++ b/llvm/docs/ProgrammersManual.rst @@ -3429,17 +3429,14 @@ Important Public Members of the ``Module`` class * | ``Module::global_iterator`` - Typedef for global variable list iterator | ``Module::const_global_iterator`` - Typedef for const_iterator. + | ``Module::insertGlobalVariable()`` - Inserts a global variable to the list. + | ``Module::removeGlobalVariable()`` - Removes a global variable frome the list. + | ``Module::eraseGlobalVariable()`` - Removes a global variable frome the list and deletes it. | ``global_begin()``, ``global_end()``, ``global_size()``, ``global_empty()`` These are forwarding methods that make it easy to access the contents of a ``Module`` object's GlobalVariable_ list. -* ``Module::GlobalListType &getGlobalList()`` - - Returns the list of GlobalVariable_\ s. This is necessary to use when you - need to update the list or perform a complex action that doesn't have a - forwarding method. - * ``SymbolTable *getSymbolTable()`` diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h index dbd3eae0f134c..aacdbbf08b945 100644 --- a/llvm/include/llvm/IR/Module.h +++ b/llvm/include/llvm/IR/Module.h @@ -542,6 +542,24 @@ class LLVM_EXTERNAL_VISIBILITY Module { llvm::Error materializeMetadata(); + /// Detach global variable \p GV from the list but don't delete it. + void removeGlobalVariable(GlobalVariable *GV) { GlobalList.remove(GV); } + /// Remove global variable \p GV from the list and delete it. + void eraseGlobalVariable(GlobalVariable *GV) { GlobalList.erase(GV); } + /// Insert global variable \p GV at the end of the global variable list and + /// take ownership. + void insertGlobalVariable(GlobalVariable *GV) { +insertGlobalVariable(GlobalList.end(), GV); + }
[Lldb-commits] [PATCH] D144027: [NFC][IR] Make Module::getGlobalList() private
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGed3e3ee9e30d: [NFC][IR] Make Module::getGlobalList() private (authored by vporpo). Changed prior to commit: https://reviews.llvm.org/D144027?vs=497403&id=497445#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144027/new/ https://reviews.llvm.org/D144027 Files: clang/lib/CodeGen/CGHLSLRuntime.cpp clang/lib/CodeGen/CGObjCMac.cpp lldb/source/Expression/IRExecutionUnit.cpp llvm/docs/ProgrammersManual.rst llvm/include/llvm/IR/Module.h llvm/lib/Bitcode/Reader/BitcodeReader.cpp llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp llvm/lib/IR/Globals.cpp llvm/lib/Linker/IRMover.cpp llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp llvm/lib/Transforms/IPO/GlobalOpt.cpp llvm/lib/Transforms/IPO/SCCP.cpp llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp llvm/lib/Transforms/Utils/CtorUtils.cpp llvm/unittests/IR/ModuleTest.cpp Index: llvm/unittests/IR/ModuleTest.cpp === --- llvm/unittests/IR/ModuleTest.cpp +++ llvm/unittests/IR/ModuleTest.cpp @@ -46,8 +46,6 @@ // Sort the globals by name. EXPECT_FALSE(std::is_sorted(M.global_begin(), M.global_end(), compare)); -M.getGlobalList().sort(compare); -EXPECT_TRUE(std::is_sorted(M.global_begin(), M.global_end(), compare)); } } @@ -273,4 +271,43 @@ EXPECT_EQ(M->named_metadata_size(), 2u); } +TEST(ModuleTest, GlobalList) { + // This tests all Module's functions that interact with Module::GlobalList. + LLVMContext C; + SMDiagnostic Err; + LLVMContext Context; + std::unique_ptr M = parseAssemblyString(R"( +@GV = external global i32 +)", + Err, Context); + auto *GV = cast(M->getNamedValue("GV")); + EXPECT_EQ(M->global_size(), 1u); + GlobalVariable *NewGV = new GlobalVariable( + Type::getInt32Ty(C), /*isConstant=*/true, GlobalValue::InternalLinkage, + /*Initializer=*/nullptr, "NewGV"); + EXPECT_EQ(M->global_size(), 1u); + // Insert before + M->insertGlobalVariable(M->globals().begin(), NewGV); + EXPECT_EQ(M->global_size(), 2u); + EXPECT_EQ(&*M->globals().begin(), NewGV); + // Insert at end() + M->removeGlobalVariable(NewGV); + EXPECT_EQ(M->global_size(), 1u); + M->insertGlobalVariable(NewGV); + EXPECT_EQ(M->global_size(), 2u); + EXPECT_EQ(&*std::prev(M->globals().end()), NewGV); + // Check globals() + auto Range = M->globals(); + EXPECT_EQ(&*Range.begin(), GV); + EXPECT_EQ(&*std::next(Range.begin()), NewGV); + EXPECT_EQ(std::next(Range.begin(), 2), Range.end()); + // Check remove + M->removeGlobalVariable(NewGV); + EXPECT_EQ(M->global_size(), 1u); + // Check erase + M->insertGlobalVariable(NewGV); + M->eraseGlobalVariable(NewGV); + EXPECT_EQ(M->global_size(), 1u); +} + } // end namespace Index: llvm/lib/Transforms/Utils/CtorUtils.cpp === --- llvm/lib/Transforms/Utils/CtorUtils.cpp +++ llvm/lib/Transforms/Utils/CtorUtils.cpp @@ -48,7 +48,7 @@ GlobalVariable *NGV = new GlobalVariable(CA->getType(), GCL->isConstant(), GCL->getLinkage(), CA, "", GCL->getThreadLocalMode()); - GCL->getParent()->getGlobalList().insert(GCL->getIterator(), NGV); + GCL->getParent()->insertGlobalVariable(GCL->getIterator(), NGV); NGV->takeName(GCL); // Nuke the old list, replacing any uses with the new one. Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp === --- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -958,7 +958,7 @@ std::vector &Bits, DenseMap> &TypeIdMap) { DenseMap GVToBits; - Bits.reserve(M.getGlobalList().size()); + Bits.reserve(M.global_size()); SmallVector Types; for (GlobalVariable &GV : M.globals()) { Types.clear(); Index: llvm/lib/Transforms/IPO/SCCP.cpp === --- llvm/lib/Transforms/IPO/SCCP.cpp +++ llvm/lib/Transforms/IPO/SCCP.cpp @@ -370,7 +370,7 @@ SI->eraseFromParent(); MadeChanges = true; } -M.getGlobalList().erase(GV); +M.eraseGlobalVariable(GV); ++NumGlobalConst; } @@ -407,3 +407,72 @@ PA.preserve(); return PA; } + +namespace { + +//======// +// +/// IPSCCP Class - This class implements interprocedural Sparse Conditional +/// Constant Propagation. +/// +class IPSCCPLegacyPass : public ModulePass { +public: + static char ID; + + IPSCCPLegacyPass() : ModulePass(ID) { +initializeIPSCCPLegacyPassPass(*PassRegistry::getPassRegistry()); + } + + bool runOnModule(Module &M) override { +if (skipModule(M)) + return false; +const DataLayout &DL = M.getDataL
[Lldb-commits] [lldb] cb5f239 - Revert "[NFC][IR] Make Module::getGlobalList() private"
Author: Vasileios Porpodas Date: 2023-02-14T14:29:42-08:00 New Revision: cb5f239363a3c94db5425c105fcd45e77d2a16a9 URL: https://github.com/llvm/llvm-project/commit/cb5f239363a3c94db5425c105fcd45e77d2a16a9 DIFF: https://github.com/llvm/llvm-project/commit/cb5f239363a3c94db5425c105fcd45e77d2a16a9.diff LOG: Revert "[NFC][IR] Make Module::getGlobalList() private" This reverts commit ed3e3ee9e30dfbffd2170a770a49b36a7f444916. Added: Modified: clang/lib/CodeGen/CGHLSLRuntime.cpp clang/lib/CodeGen/CGObjCMac.cpp lldb/source/Expression/IRExecutionUnit.cpp llvm/docs/ProgrammersManual.rst llvm/include/llvm/IR/Module.h llvm/lib/Bitcode/Reader/BitcodeReader.cpp llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp llvm/lib/IR/Globals.cpp llvm/lib/Linker/IRMover.cpp llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp llvm/lib/Transforms/IPO/GlobalOpt.cpp llvm/lib/Transforms/IPO/SCCP.cpp llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp llvm/lib/Transforms/Utils/CtorUtils.cpp llvm/unittests/IR/ModuleTest.cpp Removed: diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp index e9fa273f21cc8..5882f491d5972 100644 --- a/clang/lib/CodeGen/CGHLSLRuntime.cpp +++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp @@ -175,7 +175,7 @@ void CGHLSLRuntime::finishCodeGen() { for (auto &Buf : Buffers) { layoutBuffer(Buf, DL); GlobalVariable *GV = replaceBuffer(Buf); -M.insertGlobalVariable(GV); +M.getGlobalList().push_back(GV); llvm::hlsl::ResourceClass RC = Buf.IsCBuffer ? llvm::hlsl::ResourceClass::CBuffer : llvm::hlsl::ResourceClass::SRV; diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 5f4cdc6d91f1d..c739d3742f801 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -7431,7 +7431,7 @@ CGObjCNonFragileABIMac::GetClassGlobal(StringRef Name, GV->eraseFromParent(); } GV = NewGV; -CGM.getModule().insertGlobalVariable(GV); +CGM.getModule().getGlobalList().push_back(GV); } assert(GV->getLinkage() == L); diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index f3cf0f623d24f..73a49e552e3d2 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -406,7 +406,7 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr, } }; - for (llvm::GlobalVariable &global_var : m_module->globals()) { + for (llvm::GlobalVariable &global_var : m_module->getGlobalList()) { RegisterOneValue(global_var); } diff --git a/llvm/docs/ProgrammersManual.rst b/llvm/docs/ProgrammersManual.rst index 71298f4a87828..00d51a5a05b85 100644 --- a/llvm/docs/ProgrammersManual.rst +++ b/llvm/docs/ProgrammersManual.rst @@ -3429,14 +3429,17 @@ Important Public Members of the ``Module`` class * | ``Module::global_iterator`` - Typedef for global variable list iterator | ``Module::const_global_iterator`` - Typedef for const_iterator. - | ``Module::insertGlobalVariable()`` - Inserts a global variable to the list. - | ``Module::removeGlobalVariable()`` - Removes a global variable frome the list. - | ``Module::eraseGlobalVariable()`` - Removes a global variable frome the list and deletes it. | ``global_begin()``, ``global_end()``, ``global_size()``, ``global_empty()`` These are forwarding methods that make it easy to access the contents of a ``Module`` object's GlobalVariable_ list. +* ``Module::GlobalListType &getGlobalList()`` + + Returns the list of GlobalVariable_\ s. This is necessary to use when you + need to update the list or perform a complex action that doesn't have a + forwarding method. + * ``SymbolTable *getSymbolTable()`` diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h index aacdbbf08b945..dbd3eae0f134c 100644 --- a/llvm/include/llvm/IR/Module.h +++ b/llvm/include/llvm/IR/Module.h @@ -542,24 +542,6 @@ class LLVM_EXTERNAL_VISIBILITY Module { llvm::Error materializeMetadata(); - /// Detach global variable \p GV from the list but don't delete it. - void removeGlobalVariable(GlobalVariable *GV) { GlobalList.remove(GV); } - /// Remove global variable \p GV from the list and delete it. - void eraseGlobalVariable(GlobalVariable *GV) { GlobalList.erase(GV); } - /// Insert global variable \p GV at the end of the global variable list and - /// take ownership. - void insertGlobalVariable(GlobalVariable *GV) { -insertGlobalVariable(GlobalList.end(), GV); - } - /// Insert global variable \p GV into the global variable list before \p - /// Where and take ownership. - void insertGlobalVariable(GlobalListType::iterator Where, GlobalVariable *GV) { -GlobalList.insert(Where,
[Lldb-commits] [PATCH] D144044: [lldb] Suppress persistent result when running po
kastiglione updated this revision to Diff 497453. kastiglione added a comment. Respect verbosity level Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144044/new/ https://reviews.llvm.org/D144044 Files: lldb/source/Commands/CommandObjectExpression.cpp Index: lldb/source/Commands/CommandObjectExpression.cpp === --- lldb/source/Commands/CommandObjectExpression.cpp +++ lldb/source/Commands/CommandObjectExpression.cpp @@ -21,6 +21,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" +#include "lldb/lldb-private-enumerations.h" using namespace lldb; using namespace lldb_private; @@ -346,6 +347,9 @@ CommandObjectExpression::GetEvalOptions(const Target &target) { EvaluateExpressionOptions options; options.SetCoerceToId(m_varobj_options.use_objc); + if (m_command_options.m_verbosity == + eLanguageRuntimeDescriptionDisplayVerbosityCompact) +options.SetSuppressPersistentResult(m_varobj_options.use_objc); options.SetUnwindOnError(m_command_options.unwind_on_error); options.SetIgnoreBreakpoints(m_command_options.ignore_breakpoints); options.SetKeepInMemory(true); Index: lldb/source/Commands/CommandObjectExpression.cpp === --- lldb/source/Commands/CommandObjectExpression.cpp +++ lldb/source/Commands/CommandObjectExpression.cpp @@ -21,6 +21,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" +#include "lldb/lldb-private-enumerations.h" using namespace lldb; using namespace lldb_private; @@ -346,6 +347,9 @@ CommandObjectExpression::GetEvalOptions(const Target &target) { EvaluateExpressionOptions options; options.SetCoerceToId(m_varobj_options.use_objc); + if (m_command_options.m_verbosity == + eLanguageRuntimeDescriptionDisplayVerbosityCompact) +options.SetSuppressPersistentResult(m_varobj_options.use_objc); options.SetUnwindOnError(m_command_options.unwind_on_error); options.SetIgnoreBreakpoints(m_command_options.ignore_breakpoints); options.SetKeepInMemory(true); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 823186b - Recommit: [NFC][IR] Make Module::getGlobalList() private
Author: Vasileios Porpodas Date: 2023-02-14T15:12:51-08:00 New Revision: 823186b14dc97c950a808f6f4b434d399da9a220 URL: https://github.com/llvm/llvm-project/commit/823186b14dc97c950a808f6f4b434d399da9a220 DIFF: https://github.com/llvm/llvm-project/commit/823186b14dc97c950a808f6f4b434d399da9a220.diff LOG: Recommit: [NFC][IR] Make Module::getGlobalList() private This reverts commit cb5f239363a3c94db5425c105fcd45e77d2a16a9. Added: Modified: clang/lib/CodeGen/CGHLSLRuntime.cpp clang/lib/CodeGen/CGObjCMac.cpp lldb/source/Expression/IRExecutionUnit.cpp llvm/docs/ProgrammersManual.rst llvm/include/llvm/IR/Module.h llvm/lib/Bitcode/Reader/BitcodeReader.cpp llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp llvm/lib/IR/Globals.cpp llvm/lib/Linker/IRMover.cpp llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp llvm/lib/Transforms/IPO/GlobalOpt.cpp llvm/lib/Transforms/IPO/SCCP.cpp llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp llvm/lib/Transforms/Utils/CtorUtils.cpp llvm/unittests/IR/ModuleTest.cpp Removed: diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp index 5882f491d5972..e9fa273f21cc8 100644 --- a/clang/lib/CodeGen/CGHLSLRuntime.cpp +++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp @@ -175,7 +175,7 @@ void CGHLSLRuntime::finishCodeGen() { for (auto &Buf : Buffers) { layoutBuffer(Buf, DL); GlobalVariable *GV = replaceBuffer(Buf); -M.getGlobalList().push_back(GV); +M.insertGlobalVariable(GV); llvm::hlsl::ResourceClass RC = Buf.IsCBuffer ? llvm::hlsl::ResourceClass::CBuffer : llvm::hlsl::ResourceClass::SRV; diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index c739d3742f801..5f4cdc6d91f1d 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -7431,7 +7431,7 @@ CGObjCNonFragileABIMac::GetClassGlobal(StringRef Name, GV->eraseFromParent(); } GV = NewGV; -CGM.getModule().getGlobalList().push_back(GV); +CGM.getModule().insertGlobalVariable(GV); } assert(GV->getLinkage() == L); diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index 73a49e552e3d2..f3cf0f623d24f 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -406,7 +406,7 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr, } }; - for (llvm::GlobalVariable &global_var : m_module->getGlobalList()) { + for (llvm::GlobalVariable &global_var : m_module->globals()) { RegisterOneValue(global_var); } diff --git a/llvm/docs/ProgrammersManual.rst b/llvm/docs/ProgrammersManual.rst index 00d51a5a05b85..71298f4a87828 100644 --- a/llvm/docs/ProgrammersManual.rst +++ b/llvm/docs/ProgrammersManual.rst @@ -3429,17 +3429,14 @@ Important Public Members of the ``Module`` class * | ``Module::global_iterator`` - Typedef for global variable list iterator | ``Module::const_global_iterator`` - Typedef for const_iterator. + | ``Module::insertGlobalVariable()`` - Inserts a global variable to the list. + | ``Module::removeGlobalVariable()`` - Removes a global variable frome the list. + | ``Module::eraseGlobalVariable()`` - Removes a global variable frome the list and deletes it. | ``global_begin()``, ``global_end()``, ``global_size()``, ``global_empty()`` These are forwarding methods that make it easy to access the contents of a ``Module`` object's GlobalVariable_ list. -* ``Module::GlobalListType &getGlobalList()`` - - Returns the list of GlobalVariable_\ s. This is necessary to use when you - need to update the list or perform a complex action that doesn't have a - forwarding method. - * ``SymbolTable *getSymbolTable()`` diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h index dbd3eae0f134c..aacdbbf08b945 100644 --- a/llvm/include/llvm/IR/Module.h +++ b/llvm/include/llvm/IR/Module.h @@ -542,6 +542,24 @@ class LLVM_EXTERNAL_VISIBILITY Module { llvm::Error materializeMetadata(); + /// Detach global variable \p GV from the list but don't delete it. + void removeGlobalVariable(GlobalVariable *GV) { GlobalList.remove(GV); } + /// Remove global variable \p GV from the list and delete it. + void eraseGlobalVariable(GlobalVariable *GV) { GlobalList.erase(GV); } + /// Insert global variable \p GV at the end of the global variable list and + /// take ownership. + void insertGlobalVariable(GlobalVariable *GV) { +insertGlobalVariable(GlobalList.end(), GV); + } + /// Insert global variable \p GV into the global variable list before \p + /// Where and take ownership. + void insertGlobalVariable(GlobalListType::iterator Where, GlobalVariable *GV) { +GlobalList.insert(Where
[Lldb-commits] [PATCH] D142792: Add SBValue::GetValueAsAddress(), strip off ptrauth, TBI, MTE bits on AArch64 systems
jasonmolenda added inline comments. Comment at: lldb/source/API/SBValue.cpp:936 + if (ABISP abi_sp = process_sp->GetABI()) +return abi_sp->FixCodeAddress(ret_val); +return ret_val; DavidSpickett wrote: > We've talked about this before, and for now I think the result of `FixCode` > and `FixData` are the same for debug purposes. In the event that that ever > changes, our path is probably to document this as assuming a code address, > then adding specific `ValueAsCodeAddress` and `ValueAsDataAddress`, correct? > > (which sounds good to me, just checking we've thought that through) > > You could document that in the docstring but there's a good chance it would > cause more confusion than it's worth when at this time, it's not something > users have to care about. Yeah, this is a good point that I punted on a bit. On Darwin we are only using TCR_EL1.T0SZ to tell us how many bits are used for addressing; there's no distinction between code and data for us. I guess I should worry about someone defining a `FixCodeAddress` method in an ABI plugin that clears lower bits when instruction alignment is required. It may be that it's safer to use FixDataAddress if I have to choose between the two without any context. In our internal implementation in the apple sources, we only had FixAddress which were used for both. What do you think? Comment at: lldb/source/Core/ValueObject.cpp:1469 case Value::ValueType::HostAddress: case Value::ValueType::LoadAddress: DavidSpickett wrote: > What even is a host address, and do we care here? > ``` > /// A host address value (for memory in the process that < A is > /// using liblldb). > HostAddress > ``` > I'd have to check more but could that be an issue if I was debugging from x86 > (where the non-address bits must be 1 or 0) to AArch64? > > Maybe it is just included here so we cover all enum values and in fact, > addresses in this path will always be from the debugee. Excellent point. ValueObjects can point to host memory for sure. We can have a problem with AArch64 to AArch64 debug session; macs run in a larger address space than iOS devices for instance, so masking off the target iOS bits from a mac side address could make it invalid. Comment at: lldb/source/Core/ValueObject.cpp:3012 if (pointer_type) { + if (Process *process = exe_ctx.GetProcessPtr()) { +if (ABISP abi_sp = process->GetABI()) { DavidSpickett wrote: > Probably best on its own change but I wonder if it's time to add > Process::Fix<...>Address to dedupe all these conditionals. Yes, this is a good idea. I will do this separately. Comment at: lldb/source/DataFormatters/ValueObjectPrinter.cpp:432 + if (stripped != m_valobj->GetPointerValue()) { +m_stream->Printf(" (actual=0x%" PRIx64 ")", stripped); + } DavidSpickett wrote: > Is there a way to cover this with a test? I think there is one for the > `(actual=` part already, does that cover this part too? Good point. And actually, this codepath was never firing because both things it compared to were stripping the non-addressable bits off. Fixed this method, added to the test case. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D142792/new/ https://reviews.llvm.org/D142792 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D144027: [NFC][IR] Make Module::getGlobalList() private
fmayer added a comment. This seems to have broken our buildbot: https://lab.llvm.org/buildbot/#/builders/169/builds/16797/steps/8/logs/stdio CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /b/sanitizer-x86_64-linux-qemu/build/llvm_build0/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D_LIBCPP_ENABLE_ASSERTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/sanitizer-x86_64-linux-qemu/build/llvm_build2_host/lib/Transforms/IPO -I/b/sanitizer-x86_64-linux-qemu/build/llvm-project/llvm/lib/Transforms/IPO -I/b/sanitizer-x86_64-linux-qemu/build/llvm_build2_host/include -I/b/sanitizer-x86_64-linux-qemu/build/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -fno-exceptions -fno-rtti -UNDEBUG -std=c++17 -MD -MT lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/SCCP.cpp.o -MF lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/SCCP.cpp.o.d -o lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/SCCP.cpp.o -c /b/sanitizer-x86_64-linux-qemu/build/llvm-project/llvm/lib/Transforms/IPO/SCCP.cpp /b/sanitizer-x86_64-linux-qemu/build/llvm-project/llvm/lib/Transforms/IPO/SCCP.cpp:478:19: error: out-of-line definition of 'createIPSCCPPass' does not match any declaration in namespace 'llvm' ModulePass *llvm::createIPSCCPPass() { return new IPSCCPLegacyPass(); } ^~~~ 1 error generated. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144027/new/ https://reviews.llvm.org/D144027 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D144027: [NFC][IR] Make Module::getGlobalList() private
vporpo added a comment. Yeah sorry about that, I reverted it here: b5f239363a3 Revert "[NFC][IR] Make Module::getGlobalList() private" Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144027/new/ https://reviews.llvm.org/D144027 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D142792: Add SBValue::GetValueAsAddress(), strip off ptrauth, TBI, MTE bits on AArch64 systems
jasonmolenda updated this revision to Diff 497461. jasonmolenda added a comment. Updated patch to address David's feedback. Thanks David! Updated comments and SB API doc to conform to English. Not decided on whether we should use FixCodeAddress for our strippings here; the difference between Data & Code didn't come up with the Darwin design. Fixed code in ValueObjectPrinter to correctly append `actual=`. Added a test for `actual=` from the SBValue description to the test case. Limited the test case to Darwin & Linux systems. In further testing, my formatter in ValueObject.cpp is not limited to pointers now. e.g. I have an intptr_t scratch variable and it formats as (lldb) v scratch (intptr_t) scratch = 0x30018000 (actual=0x18000) this `actual=` text should only be appended for a ValueObject that is a pointer type; I don't want this shown for non-pointer types like a uint64_t, that's a bug. I need to fix this & update the patch once more. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D142792/new/ https://reviews.llvm.org/D142792 Files: lldb/bindings/interface/SBValue.i lldb/include/lldb/API/SBValue.h lldb/include/lldb/Core/ValueObject.h lldb/source/API/SBValue.cpp lldb/source/Core/ValueObject.cpp lldb/source/DataFormatters/ValueObjectPrinter.cpp lldb/test/API/api/clear-sbvalue-nonadressable-bits/Makefile lldb/test/API/api/clear-sbvalue-nonadressable-bits/TestClearSBValueNonAddressableBits.py lldb/test/API/api/clear-sbvalue-nonadressable-bits/main.c Index: lldb/test/API/api/clear-sbvalue-nonadressable-bits/main.c === --- /dev/null +++ lldb/test/API/api/clear-sbvalue-nonadressable-bits/main.c @@ -0,0 +1,25 @@ +#include +#include +int global = 10; + +int main() { + int v = 5; + int *v_p = &v; + + // Add some metadata in the top byte (this will crash unless the + // test is running with TBI enabled, but we won't dereference it) + + intptr_t scratch = (intptr_t)v_p; + scratch |= (3ULL << 60); + int *v_invalid_p = (int *)scratch; + + scratch = (intptr_t) dlsym(RTLD_DEFAULT, "main"); + scratch |= (3ULL << 60); + int (*main_invalid_p)() = (int (*)()) scratch; + + scratch = (intptr_t) &global; + scratch |= (3ULL << 60); + int *global_invalid_p = (int*) scratch; + + return v; // break here +} Index: lldb/test/API/api/clear-sbvalue-nonadressable-bits/TestClearSBValueNonAddressableBits.py === --- /dev/null +++ lldb/test/API/api/clear-sbvalue-nonadressable-bits/TestClearSBValueNonAddressableBits.py @@ -0,0 +1,43 @@ +"""Test that SBValue clears non-addressable bits""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestClearSBValueNonAddressableBits(TestBase): + +NO_DEBUG_INFO_TESTCASE = True + +# On AArch64 systems, the top bits that are not used for +# addressing may be used for TBI, MTE, and/or pointer +# authentication. +@skipIf(archs=no_match(['aarch64', 'arm64', 'arm64e'])) + +# Only run this test on systems where TBI is known to be +# enabled, so the address mask will clear the TBI bits. +@skipUnlessPlatform(["linux"]+lldbplatformutil.getDarwinOSTriples()) + +def test(self): +self.source = 'main.c' +self.build() +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + "break here", lldb.SBFileSpec(self.source, False)) + +if self.TraceOn(): +self.runCmd ("v v v_p v_invalid_p") +self.runCmd ("v &v &v_p &v_invalid_p") + +frame = thread.GetFrameAtIndex(0) +v_p = frame.FindVariable("v_p") +v_invalid_p = frame.FindVariable("v_invalid_p") + +self.assertEqual(v_p.GetValueAsUnsigned(), v_invalid_p.GetValueAsAddress()) +self.assertNotEqual(v_invalid_p.GetValueAsUnsigned(), v_invalid_p.GetValueAsAddress()) + +self.assertEqual(5, v_p.Dereference().GetValueAsUnsigned()) +self.assertEqual(5, v_invalid_p.Dereference().GetValueAsUnsigned()) + +strm = lldb.SBStream() +v_invalid_p.GetDescription(strm) +self.assertIn("actual=0x", strm.GetData()) Index: lldb/test/API/api/clear-sbvalue-nonadressable-bits/Makefile === --- /dev/null +++ lldb/test/API/api/clear-sbvalue-nonadressable-bits/Makefile @@ -0,0 +1,3 @@ +C_SOURCES := main.c + +include Makefile.rules Index: lldb/source/DataFormatters/ValueObjectPrinter.cpp === --- lldb/source/DataFormatters/ValueObjectPrinter.cpp +++ lldb/source/DataFormatters/ValueObjectPrinter.cpp @@ -426,6 +426,11 @@ IsPointerValue(m_valobj->GetCompilerType())) { } else { m_stream->Printf(" %s", m
[Lldb-commits] [PATCH] D144044: [lldb] Suppress persistent result when running po
kastiglione updated this revision to Diff 497466. kastiglione added a comment. Add tests Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144044/new/ https://reviews.llvm.org/D144044 Files: lldb/source/Commands/CommandObjectExpression.cpp lldb/test/API/commands/expression/po_persistent_result/Makefile lldb/test/API/commands/expression/po_persistent_result/TestPoPersistentResult.py lldb/test/API/commands/expression/po_persistent_result/main.m Index: lldb/test/API/commands/expression/po_persistent_result/main.m === --- /dev/null +++ lldb/test/API/commands/expression/po_persistent_result/main.m @@ -0,0 +1,6 @@ +#import + +int main() { + NSObject *obj = [NSObject new]; + return 0; // break here +} Index: lldb/test/API/commands/expression/po_persistent_result/TestPoPersistentResult.py === --- /dev/null +++ lldb/test/API/commands/expression/po_persistent_result/TestPoPersistentResult.py @@ -0,0 +1,31 @@ +""" +Test behavior of `po` and persistent results. +""" + +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestCase(TestBase): +def setUp(self): +TestBase.setUp(self) +self.build() +lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.m")) + +def test_po_does_not_print_persistent_result(self): +"""Test `po` doesn't advertise a persistent result variable.""" +self.expect("po obj", matching=False, substrs=["$0 = "]) + +def test_po_does_not_keep_persistent_result(self): +"""Test `po` doesn't leak a persistent result variable.""" +self.expect("po obj") +# Verify `po` used a temporary persistent result. In other words, there +# should be no $0 at this point. +self.expect("expression $0", error=True) +self.expect("expression obj", substrs=["$0 = "]) + +def test_expression_description_verbosity(self): +"""Test printing object description _and_ opt-in to persistent results.""" +self.expect("expression -O -vfull -- obj", substrs=["$0 = "]) +self.expect("expression $0", substrs=["$0 = "]) Index: lldb/test/API/commands/expression/po_persistent_result/Makefile === --- /dev/null +++ lldb/test/API/commands/expression/po_persistent_result/Makefile @@ -0,0 +1,3 @@ +OBJC_SOURCES := main.m + +include Makefile.rules Index: lldb/source/Commands/CommandObjectExpression.cpp === --- lldb/source/Commands/CommandObjectExpression.cpp +++ lldb/source/Commands/CommandObjectExpression.cpp @@ -21,6 +21,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" +#include "lldb/lldb-private-enumerations.h" using namespace lldb; using namespace lldb_private; @@ -346,6 +347,9 @@ CommandObjectExpression::GetEvalOptions(const Target &target) { EvaluateExpressionOptions options; options.SetCoerceToId(m_varobj_options.use_objc); + if (m_command_options.m_verbosity == + eLanguageRuntimeDescriptionDisplayVerbosityCompact) +options.SetSuppressPersistentResult(m_varobj_options.use_objc); options.SetUnwindOnError(m_command_options.unwind_on_error); options.SetIgnoreBreakpoints(m_command_options.ignore_breakpoints); options.SetKeepInMemory(true); Index: lldb/test/API/commands/expression/po_persistent_result/main.m === --- /dev/null +++ lldb/test/API/commands/expression/po_persistent_result/main.m @@ -0,0 +1,6 @@ +#import + +int main() { + NSObject *obj = [NSObject new]; + return 0; // break here +} Index: lldb/test/API/commands/expression/po_persistent_result/TestPoPersistentResult.py === --- /dev/null +++ lldb/test/API/commands/expression/po_persistent_result/TestPoPersistentResult.py @@ -0,0 +1,31 @@ +""" +Test behavior of `po` and persistent results. +""" + +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestCase(TestBase): +def setUp(self): +TestBase.setUp(self) +self.build() +lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.m")) + +def test_po_does_not_print_persistent_result(self): +"""Test `po` doesn't advertise a persistent result variable.""" +self.expect("po obj", matching=False, substrs=["$0 = "]) + +def test_po_does_not_keep_persistent_result(self): +"""Test `po` doesn't leak a persistent result variable.""" +self.expect("po obj") +# Verify `po` used a temporary persistent result. In other words, there +# should be no $0 at this point. +self.expect("ex
[Lldb-commits] [PATCH] D138618: [LLDB] Enable 64 bit debug/type offset
ayermolo updated this revision to Diff 497467. ayermolo added a comment. fixed cross-project tests, and also normal test that I somehow missed. Need to get access to windows machine to figure out why that fails. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138618/new/ https://reviews.llvm.org/D138618 Files: lldb/include/lldb/Core/dwarf.h lldb/include/lldb/Symbol/DWARFCallFrameInfo.h lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp lldb/source/Plugins/SymbolFile/DWARF/DIERef.h lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s lldb/unittests/Expression/DWARFExpressionTest.cpp lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp Index: lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp === --- lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp +++ lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp @@ -45,6 +45,26 @@ EncodeDecode(DIERef(200, DIERef::Section::DebugTypes, 0x11223344)); } +TEST(DWARFIndexCachingTest, DIERefEncodeDecodeMax) { + // Tests DIERef::Encode(...) and DIERef::Decode(...) + EncodeDecode(DIERef(std::nullopt, DIERef::Section::DebugInfo, + DIERef::k_die_offset_mask - 1)); + EncodeDecode(DIERef(std::nullopt, DIERef::Section::DebugTypes, + DIERef::k_die_offset_mask - 1)); + EncodeDecode( + DIERef(100, DIERef::Section::DebugInfo, DIERef::k_die_offset_mask - 1)); + EncodeDecode( + DIERef(200, DIERef::Section::DebugTypes, DIERef::k_die_offset_mask - 1)); + EncodeDecode(DIERef(DIERef::k_file_index_mask, DIERef::Section::DebugInfo, + DIERef::k_file_index_mask)); + EncodeDecode(DIERef(DIERef::k_file_index_mask, DIERef::Section::DebugTypes, + DIERef::k_file_index_mask)); + EncodeDecode(DIERef(DIERef::k_file_index_mask, DIERef::Section::DebugInfo, + 0x11223344)); + EncodeDecode(DIERef(DIERef::k_file_index_mask, DIERef::Section::DebugTypes, + 0x11223344)); +} + static void EncodeDecode(const NameToDIE &object, ByteOrder byte_order) { const uint8_t addr_size = 8; DataEncoder encoder(byte_order, addr_size); Index: lldb/unittests/Expression/DWARFExpressionTest.cpp === --- lldb/unittests/Expression/DWARFExpressionTest.cpp +++ lldb/unittests/Expression/DWARFExpressionTest.cpp @@ -713,7 +713,7 @@ // Entries: // - AbbrCode:0x1 // Values: - // - Value: 0x01020304 + // - Value: 0x0120304 // - AbbrCode:0x0 const char *dwo_yamldata = R"( --- !ELF @@ -750,7 +750,7 @@ auto dwo_module_sp = std::make_shared(dwo_file->moduleSpec()); SymbolFileDWARFDwo dwo_symfile( skeleton_symfile, dwo_module_sp->GetObjectFile()->shared_from_this(), - 0x01020304); + 0x0120304); auto *dwo_dwarf_unit = dwo_symfile.DebugInfo().GetUnitAtIndex(0); testExpressionVendorExtensions(dwo_module_sp, *dwo_dwarf_unit); Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s === --- lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s +++ lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s @@ -8,7 +8,7 @@ # RUN: -o exit | FileCheck %s # Failure was the block range 1..2 was not printed plus: -# error: DW_AT_range-DW_FORM_sec_offset.s.tmp {0x003f}: DIE has DW_AT_ranges(0xc) attribute, but range extraction failed (missing or invalid range list table), please file a bug and attach the file at the start of this error message +# error: DW_AT_range-DW_FORM_sec_offset.s.tmp {0x003f}: DIE has DW_AT_ranges(0xc) attribute, but range extraction failed (missing or invalid range list table), please file a bug and attach the file at the start of this error message # C
[Lldb-commits] [PATCH] D138618: [LLDB] Enable 64 bit debug/type offset
ayermolo updated this revision to Diff 497468. ayermolo added a comment. small clenaup Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138618/new/ https://reviews.llvm.org/D138618 Files: lldb/include/lldb/Core/dwarf.h lldb/include/lldb/Symbol/DWARFCallFrameInfo.h lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp lldb/source/Plugins/SymbolFile/DWARF/DIERef.h lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s lldb/unittests/Expression/DWARFExpressionTest.cpp lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp Index: lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp === --- lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp +++ lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp @@ -45,6 +45,26 @@ EncodeDecode(DIERef(200, DIERef::Section::DebugTypes, 0x11223344)); } +TEST(DWARFIndexCachingTest, DIERefEncodeDecodeMax) { + // Tests DIERef::Encode(...) and DIERef::Decode(...) + EncodeDecode(DIERef(std::nullopt, DIERef::Section::DebugInfo, + DIERef::k_die_offset_mask - 1)); + EncodeDecode(DIERef(std::nullopt, DIERef::Section::DebugTypes, + DIERef::k_die_offset_mask - 1)); + EncodeDecode( + DIERef(100, DIERef::Section::DebugInfo, DIERef::k_die_offset_mask - 1)); + EncodeDecode( + DIERef(200, DIERef::Section::DebugTypes, DIERef::k_die_offset_mask - 1)); + EncodeDecode(DIERef(DIERef::k_file_index_mask, DIERef::Section::DebugInfo, + DIERef::k_file_index_mask)); + EncodeDecode(DIERef(DIERef::k_file_index_mask, DIERef::Section::DebugTypes, + DIERef::k_file_index_mask)); + EncodeDecode(DIERef(DIERef::k_file_index_mask, DIERef::Section::DebugInfo, + 0x11223344)); + EncodeDecode(DIERef(DIERef::k_file_index_mask, DIERef::Section::DebugTypes, + 0x11223344)); +} + static void EncodeDecode(const NameToDIE &object, ByteOrder byte_order) { const uint8_t addr_size = 8; DataEncoder encoder(byte_order, addr_size); Index: lldb/unittests/Expression/DWARFExpressionTest.cpp === --- lldb/unittests/Expression/DWARFExpressionTest.cpp +++ lldb/unittests/Expression/DWARFExpressionTest.cpp @@ -713,7 +713,7 @@ // Entries: // - AbbrCode:0x1 // Values: - // - Value: 0x01020304 + // - Value: 0x0120304 // - AbbrCode:0x0 const char *dwo_yamldata = R"( --- !ELF @@ -750,7 +750,7 @@ auto dwo_module_sp = std::make_shared(dwo_file->moduleSpec()); SymbolFileDWARFDwo dwo_symfile( skeleton_symfile, dwo_module_sp->GetObjectFile()->shared_from_this(), - 0x01020304); + 0x0120304); auto *dwo_dwarf_unit = dwo_symfile.DebugInfo().GetUnitAtIndex(0); testExpressionVendorExtensions(dwo_module_sp, *dwo_dwarf_unit); Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s === --- lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s +++ lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s @@ -8,7 +8,7 @@ # RUN: -o exit | FileCheck %s # Failure was the block range 1..2 was not printed plus: -# error: DW_AT_range-DW_FORM_sec_offset.s.tmp {0x003f}: DIE has DW_AT_ranges(0xc) attribute, but range extraction failed (missing or invalid range list table), please file a bug and attach the file at the start of this error message +# error: DW_AT_range-DW_FORM_sec_offset.s.tmp {0x003f}: DIE has DW_AT_ranges(0xc) attribute, but range extraction failed (missing or invalid range list table), please file a bug and attach the file at the start of this error message # CHECK-LABEL: image lookup -v -s lookup_rnglists # CHECK: Function: id = {0x0029}, name = "rnglists", range = [0x
[Lldb-commits] [PATCH] D143955: Revert "[lldb] Use portable format string PRIx64"
pranavk updated this revision to Diff 497496. pranavk added a comment. Fix Bazel build Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D143955/new/ https://reviews.llvm.org/D143955 Files: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp utils/bazel/llvm-project-overlay/llvm/BUILD.bazel Index: utils/bazel/llvm-project-overlay/llvm/BUILD.bazel === --- utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +++ utils/bazel/llvm-project-overlay/llvm/BUILD.bazel @@ -204,6 +204,7 @@ "lib/Support/BLAKE3/blake3.c", "lib/Support/BLAKE3/blake3_dispatch.c", "lib/Support/BLAKE3/blake3_portable.c", +"lib/Support/BLAKE3/llvm_blake3_prefix.h", ] + select({ "@platforms//cpu:aarch64": [ "lib/Support/BLAKE3/blake3_neon.c", Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp === --- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp @@ -76,8 +76,8 @@ for (size_t i = 0; i < num_entries; ++i) { const RangeToDIE::Entry *entry = m_aranges.GetEntryAtIndex(i); if (entry) - LLDB_LOGF(log, "0x%8.8" PRIx64 ": [0x%" PRIx64 " - 0x%" PRIx64 ")", -entry->data, entry->GetRangeBase(), entry->GetRangeEnd()); + LLDB_LOGF(log, "0x%8.8x: [0x%" PRIx64 " - 0x%" PRIx64 ")", entry->data, +entry->GetRangeBase(), entry->GetRangeEnd()); } } Index: utils/bazel/llvm-project-overlay/llvm/BUILD.bazel === --- utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +++ utils/bazel/llvm-project-overlay/llvm/BUILD.bazel @@ -204,6 +204,7 @@ "lib/Support/BLAKE3/blake3.c", "lib/Support/BLAKE3/blake3_dispatch.c", "lib/Support/BLAKE3/blake3_portable.c", +"lib/Support/BLAKE3/llvm_blake3_prefix.h", ] + select({ "@platforms//cpu:aarch64": [ "lib/Support/BLAKE3/blake3_neon.c", Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp === --- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp @@ -76,8 +76,8 @@ for (size_t i = 0; i < num_entries; ++i) { const RangeToDIE::Entry *entry = m_aranges.GetEntryAtIndex(i); if (entry) - LLDB_LOGF(log, "0x%8.8" PRIx64 ": [0x%" PRIx64 " - 0x%" PRIx64 ")", -entry->data, entry->GetRangeBase(), entry->GetRangeEnd()); + LLDB_LOGF(log, "0x%8.8x: [0x%" PRIx64 " - 0x%" PRIx64 ")", entry->data, +entry->GetRangeBase(), entry->GetRangeEnd()); } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits