[Lldb-commits] [lldb] [lldb] add RISCV target specific info in API tests (PR #99039)
@@ -34,6 +34,8 @@ def check_first_register_readable(test_case): test_case.expect("register read r0", substrs=["r0 = 0x"]) elif arch in ["powerpc64le"]: test_case.expect("register read r0", substrs=["r0 = 0x"]) +elif arch in ["rv64gc"]: DavidSpickett wrote: To be honest I was asking more for understanding than anything else. Good to know it would be easy to extend. I would leave this as is on the grounds that you only know for sure that rv64 works here, and anyone working on anything else will have the ability to validate the test themselves. So leave it to future them (maybe future you) to update the name here. Just update the PR title and commit message to be clear that you're doing this for rv64 only. https://github.com/llvm/llvm-project/pull/99039 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add RISCV target specific info in API tests (PR #99039)
@@ -34,6 +34,8 @@ def check_first_register_readable(test_case): test_case.expect("register read r0", substrs=["r0 = 0x"]) elif arch in ["powerpc64le"]: test_case.expect("register read r0", substrs=["r0 = 0x"]) +elif arch in ["rv64gc"]: DavidSpickett wrote: If you have a way to test rv32 as well that's great but up to you. https://github.com/llvm/llvm-project/pull/99039 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a751f65 - [lldb][RISCV] function prologue backtrace fix (#99043)
Author: dlav-sc Date: 2024-07-17T09:36:19+01:00 New Revision: a751f653b40f2021f091a2f1ebcc2d91bc4cc89d URL: https://github.com/llvm/llvm-project/commit/a751f653b40f2021f091a2f1ebcc2d91bc4cc89d DIFF: https://github.com/llvm/llvm-project/commit/a751f653b40f2021f091a2f1ebcc2d91bc4cc89d.diff LOG: [lldb][RISCV] function prologue backtrace fix (#99043) CreateFunctionEntryUnwindPlan RISCV ABI function fix needed to receive a valid backtrace at the start of functions. Fixed tests for RISCV target: TestNumThreads.NumberOfThreadsTestCase TestCPPExceptionBreakpoints.CPPBreakpointTestCase TestStepThroughTrampoline.StepThroughTrampoline TestOSPluginStepping.TestOSPluginStepping TestSteppingOutWithArtificialFrames.TestArtificialFrameThreadStepOut1 TestStepAvoidsRegexp.StepAvoidsRegexTestCase TestInlineStepping.TestInlineStepping TestStepOverBreakpoint.StepOverBreakpointsTestCase TestStepOverBreakpoint.StepOverBreakpointsTestCase TestSteppingOutWithArtificialFrames.TestArtificialFrameThreadStepOut1 TestTailCallFrameSBAPI.TestTailCallFrameSBAPI TestThreadPlanUserBreakpoint.ThreadPlanUserBreakpointsTestCase Added: Modified: lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp Removed: diff --git a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp index 6395f5bb5bd9b..35d4f0521bf1f 100644 --- a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp +++ b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp @@ -13,6 +13,7 @@ #include "llvm/IR/DerivedTypes.h" +#include "Utility/RISCV_DWARF_Registers.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" @@ -643,9 +644,9 @@ bool ABISysV_riscv::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) { unwind_plan.Clear(); unwind_plan.SetRegisterKind(eRegisterKindDWARF); - uint32_t pc_reg_num = LLDB_REGNUM_GENERIC_PC; - uint32_t sp_reg_num = LLDB_REGNUM_GENERIC_SP; - uint32_t ra_reg_num = LLDB_REGNUM_GENERIC_RA; + uint32_t pc_reg_num = riscv_dwarf::dwarf_gpr_pc; + uint32_t sp_reg_num = riscv_dwarf::dwarf_gpr_sp; + uint32_t ra_reg_num = riscv_dwarf::dwarf_gpr_ra; UnwindPlan::RowSP row(new UnwindPlan::Row); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RISCV] function prologue backtrace fix (PR #99043)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/99043 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RISCV] function prologue backtrace fix (PR #99043)
github-actions[bot] wrote: @dlav-sc Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/99043 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/Commands] Add `scripting template list` command with auto discovery (PR #97273)
https://github.com/medismailben updated https://github.com/llvm/llvm-project/pull/97273 >From d812b8067d622b84af2ee62b837b87cb4479a477 Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Wed, 17 Jul 2024 02:21:21 -0700 Subject: [PATCH] [lldb/Commands] Add `scripting template list` command with auto discovery This patch introduces a new `template` multiword sub-command to the `scripting` top-level command. As the name suggests, this sub-command operates on scripting templates, and currently has the ability to automatically discover the various scripting extensions that lldb supports. Signed-off-by: Med Ismail Bennani --- lldb/include/lldb/Core/PluginManager.h| 20 +++ .../Interfaces/ScriptedInterface.h| 7 + .../Interfaces/ScriptedInterfaceUsages.h | 43 ++ lldb/include/lldb/lldb-private-interfaces.h | 3 + .../Commands/CommandObjectScripting.cpp | 127 +- lldb/source/Commands/Options.td | 6 + lldb/source/Core/PluginManager.cpp| 65 + lldb/source/Interpreter/CMakeLists.txt| 4 + .../Interpreter/Interfaces/CMakeLists.txt | 10 ++ .../Interfaces/ScriptedInterfaceUsages.cpp| 37 + lldb/source/Plugins/CMakeLists.txt| 3 + .../Python/Interfaces/CMakeLists.txt | 6 + .../OperatingSystemPythonInterface.cpp| 17 +++ .../OperatingSystemPythonInterface.h | 13 +- .../ScriptedProcessPythonInterface.cpp| 23 .../ScriptedProcessPythonInterface.h | 13 +- .../ScriptedThreadPlanPythonInterface.cpp | 18 +++ .../ScriptedThreadPlanPythonInterface.h | 13 +- 18 files changed, 423 insertions(+), 5 deletions(-) create mode 100644 lldb/include/lldb/Interpreter/Interfaces/ScriptedInterfaceUsages.h create mode 100644 lldb/source/Interpreter/Interfaces/CMakeLists.txt create mode 100644 lldb/source/Interpreter/Interfaces/ScriptedInterfaceUsages.cpp diff --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h index f2296e2920238..8c1b93f1653d3 100644 --- a/lldb/include/lldb/Core/PluginManager.h +++ b/lldb/include/lldb/Core/PluginManager.h @@ -10,6 +10,7 @@ #define LLDB_CORE_PLUGINMANAGER_H #include "lldb/Core/Architecture.h" +#include "lldb/Interpreter/Interfaces/ScriptedInterfaceUsages.h" #include "lldb/Symbol/TypeSystem.h" #include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/FileSpec.h" @@ -487,6 +488,25 @@ class PluginManager { static LanguageSet GetAllTypeSystemSupportedLanguagesForExpressions(); + // Scripted Interface + static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, + ScriptedInterfaceCreateInstance create_callback, + lldb::ScriptLanguage language, + ScriptedInterfaceUsages usages); + + static bool UnregisterPlugin(ScriptedInterfaceCreateInstance create_callback); + + static uint32_t GetNumScriptedInterfaces(); + + static llvm::StringRef GetScriptedInterfaceNameAtIndex(uint32_t idx); + + static llvm::StringRef GetScriptedInterfaceDescriptionAtIndex(uint32_t idx); + + static lldb::ScriptLanguage GetScriptedInterfaceLanguageAtIndex(uint32_t idx); + + static ScriptedInterfaceUsages + GetScriptedInterfaceUsagesAtIndex(uint32_t idx); + // REPL static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, REPLCreateInstance create_callback, diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h index 69504dbcda5dc..3ce47d0584a8a 100644 --- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h +++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h @@ -9,6 +9,8 @@ #ifndef LLDB_INTERPRETER_INTERFACES_SCRIPTEDINTERFACE_H #define LLDB_INTERPRETER_INTERFACES_SCRIPTEDINTERFACE_H +#include "ScriptedInterfaceUsages.h" + #include "lldb/Core/StructuredDataImpl.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" @@ -68,6 +70,11 @@ class ScriptedInterface { return true; } + static bool CreateInstance(lldb::ScriptLanguage language, + ScriptedInterfaceUsages usages) { +return false; + } + protected: StructuredData::GenericSP m_object_instance_sp; }; diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterfaceUsages.h b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterfaceUsages.h new file mode 100644 index 0..36c0cfdca546e --- /dev/null +++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterfaceUsages.h @@ -0,0 +1,43 @@ +//===-- ScriptedInterfaceUsages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LL
[Lldb-commits] [lldb] [lldb] Refactor TypeQuery::ContextMatches (PR #99305)
https://github.com/labath created https://github.com/llvm/llvm-project/pull/99305 This is a preparatory step for teaching the function about anonymous namespaces. It started out as a way to remove the assumption that the pattern and target contexts must be of the same length -- that's will not be correct with anonymous namespaces, and probably isn't even correct right now for AnyModule matches. To make that work, I needed to reverse the direction of the matching (since partial matches can ignore outermost contexts). This in turn made me realise that reversing the greedy AnyModule matching algorithm would not preserve current behavior, and AnyModule would greedily consume everything, and leave nothing for the exact module name matches that are before it (the same thing could happen in the original algorithm with modules that come after an AnyModule pattern, but I guess we just don't make queries like that). That's why the bulk of this patch is concerned with implementing a more correct (maybe? I'm assuming the intention was to provide glob-like matching) matching for AnyModule patterns. The algorithm is technically quadratic, but that's probably fine as I don't think we have deeply nested modules or many wildcard matches. >From 9c6575640e3fa3f179454e669ec389e43899a1a4 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 16 Jul 2024 14:18:27 + Subject: [PATCH] [lldb] Refactor TypeQuery::ContextMatches This is a preparatory step for teaching the function about anonymous namespaces. It started out as a way to remove the assumption that the pattern and target contexts must be of the same length -- that's will not be correct with anonymous namespaces, and probably isn't even correct right now for AnyModule matches. To make that work, I needed to reverse the direction of the matching (since partial matches can ignore outermost contexts). This in turn made me realise that reversing the greedy AnyModule matching algorithm would not preserve current behavior, and AnyModule would greedily consume everything, and leave nothing for the exact module name matches that are before it (the same thing could happen in the original algorithm with modules that come after an AnyModule pattern, but I guess we just don't make queries like that). That's why the bulk of this patch is concerned with implementing a more correct (maybe? I'm assuming the intention was to provide glob-like matching) matching for AnyModule patterns. The algorithm is technically quadratic, but that's probably fine as I don't think we have deeply nested modules or many wildcard matches. --- lldb/include/lldb/Symbol/Type.h| 5 -- lldb/source/Symbol/Type.cpp| 128 +++-- lldb/unittests/Symbol/TestType.cpp | 118 ++ 3 files changed, 169 insertions(+), 82 deletions(-) diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h index c6f30cde81867..365f600343e1d 100644 --- a/lldb/include/lldb/Symbol/Type.h +++ b/lldb/include/lldb/Symbol/Type.h @@ -65,11 +65,6 @@ struct CompilerContext { llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const CompilerContext &rhs); -/// Match \p context_chain against \p pattern, which may contain "Any" -/// kinds. The \p context_chain should *not* contain any "Any" kinds. -bool contextMatches(llvm::ArrayRef context_chain, -llvm::ArrayRef pattern); - FLAGS_ENUM(TypeQueryOptions){ e_none = 0u, /// If set, TypeQuery::m_context contains an exact context that must match diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp index e76574795733f..67ed4a2e41f49 100644 --- a/lldb/source/Symbol/Type.cpp +++ b/lldb/source/Symbol/Type.cpp @@ -6,7 +6,9 @@ // //===--===// +#include #include +#include #include #include "lldb/Core/Module.h" @@ -30,6 +32,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/lldb-enumerations.h" +#include "lldb/lldb-private-enumerations.h" #include "llvm/ADT/StringRef.h" @@ -43,35 +46,6 @@ llvm::raw_ostream &lldb_private::operator<<(llvm::raw_ostream &os, return os << lldb_stream.GetString(); } -bool lldb_private::contextMatches(llvm::ArrayRef context_chain, - llvm::ArrayRef pattern) { - auto ctx = context_chain.begin(); - auto ctx_end = context_chain.end(); - for (const CompilerContext &pat : pattern) { -// Early exit if the pattern is too long. -if (ctx == ctx_end) - return false; -if (*ctx != pat) { - // Skip any number of module matches. - if (pat.kind == CompilerContextKind::AnyModule) { -// Greedily match 0..n modules. -ctx = std::find_if(ctx, ctx_end, [](const CompilerContext &ctx) { - return ctx.kind != CompilerContextKind::Module; -}); -continue; - } - // See if there is a k
[Lldb-commits] [lldb] [lldb] Refactor TypeQuery::ContextMatches (PR #99305)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Pavel Labath (labath) Changes This is a preparatory step for teaching the function about anonymous namespaces. It started out as a way to remove the assumption that the pattern and target contexts must be of the same length -- that's will not be correct with anonymous namespaces, and probably isn't even correct right now for AnyModule matches. To make that work, I needed to reverse the direction of the matching (since partial matches can ignore outermost contexts). This in turn made me realise that reversing the greedy AnyModule matching algorithm would not preserve current behavior, and AnyModule would greedily consume everything, and leave nothing for the exact module name matches that are before it (the same thing could happen in the original algorithm with modules that come after an AnyModule pattern, but I guess we just don't make queries like that). That's why the bulk of this patch is concerned with implementing a more correct (maybe? I'm assuming the intention was to provide glob-like matching) matching for AnyModule patterns. The algorithm is technically quadratic, but that's probably fine as I don't think we have deeply nested modules or many wildcard matches. --- Full diff: https://github.com/llvm/llvm-project/pull/99305.diff 3 Files Affected: - (modified) lldb/include/lldb/Symbol/Type.h (-5) - (modified) lldb/source/Symbol/Type.cpp (+86-42) - (modified) lldb/unittests/Symbol/TestType.cpp (+83-35) ``diff diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h index c6f30cde81867..365f600343e1d 100644 --- a/lldb/include/lldb/Symbol/Type.h +++ b/lldb/include/lldb/Symbol/Type.h @@ -65,11 +65,6 @@ struct CompilerContext { llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const CompilerContext &rhs); -/// Match \p context_chain against \p pattern, which may contain "Any" -/// kinds. The \p context_chain should *not* contain any "Any" kinds. -bool contextMatches(llvm::ArrayRef context_chain, -llvm::ArrayRef pattern); - FLAGS_ENUM(TypeQueryOptions){ e_none = 0u, /// If set, TypeQuery::m_context contains an exact context that must match diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp index e76574795733f..67ed4a2e41f49 100644 --- a/lldb/source/Symbol/Type.cpp +++ b/lldb/source/Symbol/Type.cpp @@ -6,7 +6,9 @@ // //===--===// +#include #include +#include #include #include "lldb/Core/Module.h" @@ -30,6 +32,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/lldb-enumerations.h" +#include "lldb/lldb-private-enumerations.h" #include "llvm/ADT/StringRef.h" @@ -43,35 +46,6 @@ llvm::raw_ostream &lldb_private::operator<<(llvm::raw_ostream &os, return os << lldb_stream.GetString(); } -bool lldb_private::contextMatches(llvm::ArrayRef context_chain, - llvm::ArrayRef pattern) { - auto ctx = context_chain.begin(); - auto ctx_end = context_chain.end(); - for (const CompilerContext &pat : pattern) { -// Early exit if the pattern is too long. -if (ctx == ctx_end) - return false; -if (*ctx != pat) { - // Skip any number of module matches. - if (pat.kind == CompilerContextKind::AnyModule) { -// Greedily match 0..n modules. -ctx = std::find_if(ctx, ctx_end, [](const CompilerContext &ctx) { - return ctx.kind != CompilerContextKind::Module; -}); -continue; - } - // See if there is a kind mismatch; they should have 1 bit in common. - if (((uint16_t)ctx->kind & (uint16_t)pat.kind) == 0) -return false; - // The name is ignored for AnyModule, but not for AnyType. - if (pat.kind != CompilerContextKind::AnyModule && ctx->name != pat.name) -return false; -} -++ctx; - } - return true; -} - static CompilerContextKind ConvertTypeClass(lldb::TypeClass type_class) { if (type_class == eTypeClassAny) return CompilerContextKind::AnyType; @@ -153,19 +127,89 @@ void TypeQuery::SetLanguages(LanguageSet languages) { bool TypeQuery::ContextMatches( llvm::ArrayRef context_chain) const { - if (GetExactMatch() || context_chain.size() == m_context.size()) -return ::contextMatches(context_chain, m_context); - - // We don't have an exact match, we need to bottom m_context.size() items to - // match for a successful lookup. - if (context_chain.size() < m_context.size()) -return false; // Not enough items in context_chain to allow for a match. - - size_t compare_count = context_chain.size() - m_context.size(); - return ::contextMatches( - llvm::ArrayRef(context_chain.data() + compare_count, - m_context.size()), - m_context); + auto ctx = context_chain.rbegin(), ctx_end = context_chain.rend(); +
[Lldb-commits] [lldb] [lldb] Fixed the error `unable to launch a GDB server` in API tests (PR #98833)
slydiman wrote: > Agreed, so silent UB would just be making things worse. So, this patch fixes that issue, right? > Perhaps I am spelling the port option differently, or you mean a lldb-server > gdbserver launched by a platform ignores the port. It seems it depends on the system. Note I'm working on a patch to fix #97537 and all port mapping related issues. The idea is to use threads for platform mode and use a common port map for all connections instead of making a new `portmap_for_child` with 1 port. https://github.com/llvm/llvm-project/pull/98833 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixed the error `unable to launch a GDB server` in API tests (PR #98833)
DavidSpickett wrote: > So, this patch fixes that issue, right? Yes I think so, give me some time to test it myself. https://github.com/llvm/llvm-project/pull/98833 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/99266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
@@ -456,21 +492,15 @@ ifeq (1, $(USE_SYSTEM_STDLIB)) endif CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(SDKROOT)/usr/include/c++/v1 LDFLAGS += -L$(SDKROOT)/usr/lib -Wl,-rpath,$(SDKROOT)/usr/lib -lc++ +else +ifneq (,$(findstring clang,$(CC))) +# Force clang looking for the gcc's headers at specific rootfs folder. +CXXFLAGS += -stdlib=libstdc++ $(GCC_TOOLCHAIN_FLAGS) labath wrote: ..and then change this to not pass any flags by default? (I don't know what `-stdlib=libstdc++` will do for windows, but I don't expect it to go down well) https://github.com/llvm/llvm-project/pull/99266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
@@ -80,9 +78,21 @@ endif # Also reset BUILDDIR value because "pwd" returns cygwin or msys path # which needs to be converted to windows path. #-- -ifeq "$(OS)" "Windows_NT" - SHELL = $(WINDIR)\system32\cmd.exe +path_wrapper = $(1) +ifeq "$(HOST_OS)" "Windows_NT" + # Windows 10 and later has the lower-case 'windir' env variable. + SHELL := $(or $(windir),$(WINDIR),C:\WINDOWS)\system32\cmd.exe BUILDDIR := $(shell echo %cd%) + + ifneq (,$(filter $(OS), Linux Android)) labath wrote: Why is this based on the target OS? I would expect that something like this would be keyed off of host os being windows, not *target* os *not* being linux. https://github.com/llvm/llvm-project/pull/99266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
@@ -418,11 +437,28 @@ ifeq (1, $(USE_SYSTEM_STDLIB)) endif endif +# No C++ library has been specifieed. Use libstdc++ by default. +ifeq (,$(filter 1, $(USE_LIBSTDCPP) $(USE_LIBCPP) $(USE_SYSTEM_STDLIB))) + # If no explicit request was made, but we have paths to a custom libcxx, use + # them. + ifneq ($(and $(LIBCPP_INCLUDE_DIR), $(LIBCPP_LIBRARY_DIR)),) +CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(LIBCPP_INCLUDE_DIR) +ifneq "$(LIBCPP_INCLUDE_TARGET_DIR)" "" + CXXFLAGS += -cxx-isystem $(LIBCPP_INCLUDE_TARGET_DIR) +endif +LDFLAGS += -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++ -lc++abi + # Otherwise no C++ library has been specified. Use stdc++ by default. + else +USE_LIBSTDCPP := 1 labath wrote: this default doesn't make sense for darwin and windows builds. Could we default to the system library instead? https://github.com/llvm/llvm-project/pull/99266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
@@ -263,9 +280,9 @@ CFLAGS += $(NO_LIMIT_DEBUG_INFO_FLAGS) $(ARCH_CFLAGS) # Use this one if you want to build one part of the result without debug information: ifeq "$(OS)" "Darwin" - CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) -isysroot "$(SDKROOT)" + CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) $(SYSROOT_FLAGS) labath wrote: The two branches are equivalent now (yay), right ? Can we merge them? https://github.com/llvm/llvm-project/pull/99266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
@@ -432,18 +468,18 @@ ifeq (1,$(USE_LIBCPP)) ifneq "$(LIBCPP_INCLUDE_TARGET_DIR)" "" CXXFLAGS += -cxx-isystem $(LIBCPP_INCLUDE_TARGET_DIR) endif - LDFLAGS += -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++ + LDFLAGS += -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++ -lc++abi else ifeq "$(OS)" "Android" # Nothing to do, this is already handled in # Android.rules. else CXXFLAGS += -stdlib=libc++ - LDFLAGS += -stdlib=libc++ + LDFLAGS += -stdlib=libc++ -lc++abi labath wrote: Why is this necessary. Is this a static/dynamic linking thing? https://github.com/llvm/llvm-project/pull/99266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
@@ -296,11 +313,13 @@ endif CFLAGS += $(CFLAGS_EXTRAS) CXXFLAGS += -std=c++11 $(CFLAGS) $(ARCH_CXXFLAGS) LD = $(CC) -LDFLAGS ?= $(CFLAGS) +# Copy common options to the linker flags (dwarf, arch. & etc). +#Note: we get some 'garbage' options for linker here (such as -I, --isystem & etc). +LDFLAGS += $(CFLAGS) LDFLAGS += $(LD_EXTRAS) $(ARCH_LDFLAGS) ifeq (,$(filter $(OS), Windows_NT Android Darwin)) ifneq (,$(filter YES,$(ENABLE_THREADS))) - LDFLAGS += -pthread + LDFLAGS += -lpthread labath wrote: My understanding was that `-pthread` is the recommended flag here. Why change it? https://github.com/llvm/llvm-project/pull/99266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
@@ -296,11 +313,13 @@ endif CFLAGS += $(CFLAGS_EXTRAS) CXXFLAGS += -std=c++11 $(CFLAGS) $(ARCH_CXXFLAGS) LD = $(CC) -LDFLAGS ?= $(CFLAGS) +# Copy common options to the linker flags (dwarf, arch. & etc). +#Note: we get some 'garbage' options for linker here (such as -I, --isystem & etc). labath wrote: Add space after '#' https://github.com/llvm/llvm-project/pull/99266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
https://github.com/labath commented: It may be better to split this into smaller patches, given the fragility of this code. (Basically, one patch for each of your bullet points). Also, can you elaborate on this part? > Paths are turned into POSIX-style since some tests and Unix utilities use > them for manipulating files. It helps to avoid compiler/linker errors because > of broken paths. What exactly does it help with? Given that you're canonicalizing to a forward slash, does that mean that some of the tools you use don't accept backslashes (perhaps because they come from cygwin or the like)? https://github.com/llvm/llvm-project/pull/99266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)
@@ -56,15 +57,12 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../ # inherited all the way down to the process spawned for make. #-- ifeq "$(HOST_OS)" "" - HOST_OS := $(shell uname -s) -endif - -ifneq (,$(findstring windows32,$(HOST_OS))) - HOST_OS := Windows_NT -endif - -ifneq (,$(findstring MSYS_NT,$(HOST_OS))) - HOST_OS := Windows_NT +HOST_OS := $(shell uname -s) +ifneq (,$(or \ +$(findstring windows32,$(HOST_OS)),\ +$(findstring MSYS_NT,$(HOST_OS +HOST_OS := Windows_NT +endif labath wrote: Why do we need to do this if we're already setting HOST_OS in python (7021e44b2f0e11717c0d82456bad0fed4a0b48f9)? If the python code is not sufficient, could we fix it (and delete this code) to keep everything in one place? https://github.com/llvm/llvm-project/pull/99266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Disable verbose_trap.test on Windows (PR #99323)
https://github.com/luporl created https://github.com/llvm/llvm-project/pull/99323 verbose_trap.test, added in #80368, fails on some Windows bots. See https://lab.llvm.org/buildbot/#/builders/141/builds/808. >From f57dd945e6c2e4d4b3d5a97b2ed05418d91902ac Mon Sep 17 00:00:00 2001 From: Leandro Lupori Date: Wed, 17 Jul 2024 10:12:11 -0300 Subject: [PATCH] [lldb] Disable verbose_trap.test on Windows verbose_trap.test, added in #80368, fails on some Windows bots. See https://lab.llvm.org/buildbot/#/builders/141/builds/808. --- lldb/test/Shell/Recognizer/verbose_trap.test | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lldb/test/Shell/Recognizer/verbose_trap.test b/lldb/test/Shell/Recognizer/verbose_trap.test index 45ef84bef611f..dafab7bdea688 100644 --- a/lldb/test/Shell/Recognizer/verbose_trap.test +++ b/lldb/test/Shell/Recognizer/verbose_trap.test @@ -1,3 +1,5 @@ +# UNSUPPORTED: system-windows +# # RUN: %clang_host -g -O0 %S/Inputs/verbose_trap.cpp -o %t.out -DVERBOSE_TRAP_TEST_CATEGORY=\"Foo\" -DVERBOSE_TRAP_TEST_MESSAGE=\"Bar\" # RUN: %lldb -b -s %s %t.out | FileCheck %s --check-prefixes=CHECK,CHECK-BOTH # ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Disable verbose_trap.test on Windows (PR #99323)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Leandro Lupori (luporl) Changes verbose_trap.test, added in #80368, fails on some Windows bots. See https://lab.llvm.org/buildbot/#/builders/141/builds/808. --- Full diff: https://github.com/llvm/llvm-project/pull/99323.diff 1 Files Affected: - (modified) lldb/test/Shell/Recognizer/verbose_trap.test (+2) ``diff diff --git a/lldb/test/Shell/Recognizer/verbose_trap.test b/lldb/test/Shell/Recognizer/verbose_trap.test index 45ef84bef611f..dafab7bdea688 100644 --- a/lldb/test/Shell/Recognizer/verbose_trap.test +++ b/lldb/test/Shell/Recognizer/verbose_trap.test @@ -1,3 +1,5 @@ +# UNSUPPORTED: system-windows +# # RUN: %clang_host -g -O0 %S/Inputs/verbose_trap.cpp -o %t.out -DVERBOSE_TRAP_TEST_CATEGORY=\"Foo\" -DVERBOSE_TRAP_TEST_MESSAGE=\"Bar\" # RUN: %lldb -b -s %s %t.out | FileCheck %s --check-prefixes=CHECK,CHECK-BOTH # `` https://github.com/llvm/llvm-project/pull/99323 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Disable verbose_trap.test on Windows (PR #99323)
https://github.com/DavidSpickett approved this pull request. Disabling this for now is fine with me. ``` # shell parser error on RUN: at line 1: c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe --target=specify-a-target-or-use-a-_host-substitution --target=aarch64-pc-windows-msvc -fmodules-cache-path=C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/lldb-test-build.noindex/module-cache-clang\lldb-shell -g -O0 C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\Shell\Recognizer/Inputs/verbose_trap.cpp -o C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\Recognizer\Output\verbose_trap.test.tmp.out -DVERBOSE_TRAP_TEST_CATEGORY=\"Foo\" -DVERBOSE_TRAP_TEST_MESSAGE=\"Bar\" ``` But it feels like some terminal syntax issue, so I hope we can figure that out as well. https://github.com/llvm/llvm-project/pull/99323 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ec9d62f - [lldb] Disable verbose_trap.test on Windows (#99323)
Author: Leandro Lupori Date: 2024-07-17T11:45:49-03:00 New Revision: ec9d62fe84fe314370a256306c083a9e7079b80b URL: https://github.com/llvm/llvm-project/commit/ec9d62fe84fe314370a256306c083a9e7079b80b DIFF: https://github.com/llvm/llvm-project/commit/ec9d62fe84fe314370a256306c083a9e7079b80b.diff LOG: [lldb] Disable verbose_trap.test on Windows (#99323) verbose_trap.test, added in #80368, fails on some Windows bots. See https://lab.llvm.org/buildbot/#/builders/141/builds/808. Added: Modified: lldb/test/Shell/Recognizer/verbose_trap.test Removed: diff --git a/lldb/test/Shell/Recognizer/verbose_trap.test b/lldb/test/Shell/Recognizer/verbose_trap.test index 45ef84bef611f..dafab7bdea688 100644 --- a/lldb/test/Shell/Recognizer/verbose_trap.test +++ b/lldb/test/Shell/Recognizer/verbose_trap.test @@ -1,3 +1,5 @@ +# UNSUPPORTED: system-windows +# # RUN: %clang_host -g -O0 %S/Inputs/verbose_trap.cpp -o %t.out -DVERBOSE_TRAP_TEST_CATEGORY=\"Foo\" -DVERBOSE_TRAP_TEST_MESSAGE=\"Bar\" # RUN: %lldb -b -s %s %t.out | FileCheck %s --check-prefixes=CHECK,CHECK-BOTH # ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Disable verbose_trap.test on Windows (PR #99323)
https://github.com/luporl closed https://github.com/llvm/llvm-project/pull/99323 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][RISCV] function calls support in lldb expressions (PR #99336)
https://github.com/dlav-sc created https://github.com/llvm/llvm-project/pull/99336 To make function calls inside lldb expressions ABI support, JIT engine support are required. This patch augments corresponding functionality to RISCV ABI and implements RISCV relocation resolver in JIT, which allows to make function calls with integer and void function arguments and return value. Also it adds RISCV specific DirectToIndirectFunctionCallsReplacement IR pass, that allows to make assembly jumps at any 64bit address without RISCV large code model, which has not been implemented yet. This pass is needed, because jitted code contains more that +-2GB jumps, which are not available in RISCV without large code model now. Fixed tests: ``` TestCallThatRestarts.ExprCommandThatRestartsTestCase TestMainThreadExit.ThreadExitTestCase TestSBValuePersist.SBValuePersistTestCase TestThisClassTypeMixing.TestCase Test11588.Issue11581TestCase TestExprsChar.ExprCharTestCase TestExpressions.TestExpressions TestCallWithTimeout.ExprCommandWithTimeoutsTestCase TestInlineNamespace.TestInlineNamespace TestInlineNamespaceAlias.TestInlineNamespace TestSetValues.SetValuesTestCase TestValueAPIAddressOfVoidStar.ValueAPIVoidStarTestCase TestXValuePrinting.ExprXValuePrintingTestCase lldbsuite.test.lldbtest.TestRedefinitionsInInlines lldbsuite.test.lldbtest.TestVirtualOverload TestSetValues.SetValuesTestCase TestExprs.BasicExprCommandsTestCase TestExprHelpExamples.Radar9673644TestCase TestExprEntryBP.ExprEntryBPTestCase TestExprInsideLambdas.ExprInsideLambdaTestCase TestConstStaticIntegralMemberInt128.TestCase TestDWIMPrint.TestCase TestCPPStaticMembers.TestCase TestNestedPersistentTypes.NestedPersistentTypesTestCase TestSaveJITObjects.SaveJITObjectsTestCase TestNamespaceLookup.NamespaceLookupTestCase TestCCallingConventions.TestCase TestCppTypedef.TestCppTypedef TestUnwindExpression.UnwindFromExpressionTest TestCxxChar8_t.CxxChar8_tTestCase TestCallCPPFunction.CallCPPFunctionTestCase TestExprDoesntBlock.ExprDoesntDeadlockTestCase TestEnumTypes.EnumTypesTestCase TestAnonymous.AnonymousTestCase ``` >From c35ab331df2bc76a32d36a51ecb020ea2c13ff39 Mon Sep 17 00:00:00 2001 From: Daniil Avdeev Date: Thu, 11 Jul 2024 11:21:36 + Subject: [PATCH 1/5] [lldb][RISCV] add jitted function calls to ABI Function calls support in LLDB expressions for RISCV: 1 of 5 Augments corresponding functionality to RISCV ABI, which allows to jit lldb expressions and thus make function calls inside them. Only function calls with integer and void function arguments and return value are supported. --- .../Plugins/ABI/RISCV/ABISysV_riscv.cpp | 89 +-- lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.h | 3 + 2 files changed, 85 insertions(+), 7 deletions(-) diff --git a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp index 6395f5bb5bd9b..f3edee1dd6dc1 100644 --- a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp +++ b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp @@ -10,7 +10,9 @@ #include #include +#include +#include "llvm/ADT/STLExtras.h" #include "llvm/IR/DerivedTypes.h" #include "lldb/Core/PluginManager.h" @@ -19,6 +21,7 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/RegisterValue.h" #define DEFINE_REG_NAME(reg_num) ConstString(#reg_num).GetCString() @@ -163,11 +166,83 @@ TotalArgsSizeInWords(bool is_rv64, return total_size; } +static bool UpdateRegister(RegisterContext *reg_ctx, + const lldb::RegisterKind reg_kind, + const uint32_t reg_num, const addr_t value) { + Log *log = GetLog(LLDBLog::Expressions); + + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(reg_kind, reg_num); + + LLDB_LOG(log, "Writing %s: 0x%" PRIx64, reg_info->name, + static_cast(value)); + if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, value)) { +LLDB_LOG(log, "Writing %s: failed", reg_info->name); +return false; + } + return true; +} + +static void LogInitInfo(Log *log, const Thread &thread, addr_t sp, +addr_t func_addr, addr_t return_addr, +const llvm::ArrayRef args) { + assert(log); + std::stringstream ss; + ss << "ABISysV_riscv::PrepareTrivialCall" + << " (tid = 0x%" << std::hex << thread.GetID() << ", sp = 0x%" << sp + << ", func_addr = 0x%" << func_addr << ", return_addr = 0x%" + << return_addr; + + for (auto &&[idx, arg] : enumerate(args)) +ss << ", arg" << std::dec << idx << " = 0x%" << std::hex << arg; + ss << ")"; + log->PutString(ss.str()); +} + bool ABISysV_riscv::PrepareTrivialCall(Thread &thread, addr_t sp, addr_t func_addr, addr_t return_addr, llvm::ArrayRef args) const { - // TODO: Implement - return false; + Log *lo
[Lldb-commits] [lldb] [llvm] [lldb][RISCV] function calls support in lldb expressions (PR #99336)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (dlav-sc) Changes To make function calls inside lldb expressions ABI support, JIT engine support are required. This patch augments corresponding functionality to RISCV ABI and implements RISCV relocation resolver in JIT, which allows to make function calls with integer and void function arguments and return value. Also it adds RISCV specific DirectToIndirectFunctionCallsReplacement IR pass, that allows to make assembly jumps at any 64bit address without RISCV large code model, which has not been implemented yet. This pass is needed, because jitted code contains more that +-2GB jumps, which are not available in RISCV without large code model now. Fixed tests: ``` TestCallThatRestarts.ExprCommandThatRestartsTestCase TestMainThreadExit.ThreadExitTestCase TestSBValuePersist.SBValuePersistTestCase TestThisClassTypeMixing.TestCase Test11588.Issue11581TestCase TestExprsChar.ExprCharTestCase TestExpressions.TestExpressions TestCallWithTimeout.ExprCommandWithTimeoutsTestCase TestInlineNamespace.TestInlineNamespace TestInlineNamespaceAlias.TestInlineNamespace TestSetValues.SetValuesTestCase TestValueAPIAddressOfVoidStar.ValueAPIVoidStarTestCase TestXValuePrinting.ExprXValuePrintingTestCase lldbsuite.test.lldbtest.TestRedefinitionsInInlines lldbsuite.test.lldbtest.TestVirtualOverload TestSetValues.SetValuesTestCase TestExprs.BasicExprCommandsTestCase TestExprHelpExamples.Radar9673644TestCase TestExprEntryBP.ExprEntryBPTestCase TestExprInsideLambdas.ExprInsideLambdaTestCase TestConstStaticIntegralMemberInt128.TestCase TestDWIMPrint.TestCase TestCPPStaticMembers.TestCase TestNestedPersistentTypes.NestedPersistentTypesTestCase TestSaveJITObjects.SaveJITObjectsTestCase TestNamespaceLookup.NamespaceLookupTestCase TestCCallingConventions.TestCase TestCppTypedef.TestCppTypedef TestUnwindExpression.UnwindFromExpressionTest TestCxxChar8_t.CxxChar8_tTestCase TestCallCPPFunction.CallCPPFunctionTestCase TestExprDoesntBlock.ExprDoesntDeadlockTestCase TestEnumTypes.EnumTypesTestCase TestAnonymous.AnonymousTestCase ``` --- Patch is 35.55 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/99336.diff 15 Files Affected: - (modified) lldb/include/lldb/Core/Architecture.h (+12) - (modified) lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp (+82-7) - (modified) lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.h (+3) - (modified) lldb/source/Plugins/Architecture/CMakeLists.txt (+1) - (added) lldb/source/Plugins/Architecture/RISCV/ArchitectureRISCV.cpp (+55) - (added) lldb/source/Plugins/Architecture/RISCV/ArchitectureRISCV.h (+34) - (added) lldb/source/Plugins/Architecture/RISCV/CMakeLists.txt (+12) - (added) lldb/source/Plugins/Architecture/RISCV/DirectToIndirectFCR.cpp (+194) - (added) lldb/source/Plugins/Architecture/RISCV/DirectToIndirectFCR.h (+58) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (+23) - (added) lldb/test/API/riscv/expressions/Makefile (+3) - (added) lldb/test/API/riscv/expressions/TestExpressions.py (+88) - (added) lldb/test/API/riscv/expressions/main.cpp (+51) - (modified) llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp (+152-3) - (modified) llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h (+7) ``diff diff --git a/lldb/include/lldb/Core/Architecture.h b/lldb/include/lldb/Core/Architecture.h index b6fc1a20e1e69..ca6a9207d8012 100644 --- a/lldb/include/lldb/Core/Architecture.h +++ b/lldb/include/lldb/Core/Architecture.h @@ -12,6 +12,7 @@ #include "lldb/Core/PluginInterface.h" #include "lldb/Target/DynamicRegisterInfo.h" #include "lldb/Target/MemoryTagManager.h" +#include "llvm/IR/LegacyPassManager.h" namespace lldb_private { @@ -129,6 +130,17 @@ class Architecture : public PluginInterface { RegisterContext ®_context) const { return false; } + + // Takes a Pass Manager and adds passes for this Architecture that should be + // run before IRForTarget + virtual std::unique_ptr + GetArchitectureCustomPasses(const ExecutionContext &exe_ctx, + const llvm::StringRef expr) const { +return nullptr; + } + + static constexpr llvm::StringLiteral s_target_incompatibility_marker = + "target_incompatibility_detected"; }; } // namespace lldb_private diff --git a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp index 6395f5bb5bd9b..f3edee1dd6dc1 100644 --- a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp +++ b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp @@ -10,7 +10,9 @@ #include #include +#include +#include "llvm/ADT/STLExtras.h" #include "llvm/IR/DerivedTypes.h" #include "lldb/Core/PluginManager.h" @@ -19,6 +21,7 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/LLDBLog.h" #include "lldb/Utility
[Lldb-commits] [lldb] [llvm] [lldb][RISCV] function calls support in lldb expressions (PR #99336)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r ac4b6b662630cd4d3bf6929f2b39ea203c0054a1...3ad75f024eec22f2dfd0ae7cc911f6d70202932d lldb/test/API/riscv/expressions/TestExpressions.py `` View the diff from darker here. ``diff --- TestExpressions.py 2024-07-17 14:07:09.00 + +++ TestExpressions.py 2024-07-17 15:11:09.239265 + @@ -7,22 +7,21 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil class TestExpressions(TestBase): - def common_setup(self): self.build() lldbutil.run_to_source_breakpoint( self, "// break here", lldb.SBFileSpec("main.cpp") ) @skipIf(archs=no_match(["rv64gc"])) def test_int_arg(self): self.common_setup() self.expect_expr("foo(foo(5), foo())", result_type="int", result_value="8") - + @skipIf(archs=no_match(["rv64gc"])) def test_double_arg(self): self.common_setup() self.expect( "expr func_with_double_arg(1, 6.5)", @@ -32,11 +31,11 @@ @skipIf(archs=no_match(["rv64gc"])) def test_ptr_arg(self): self.common_setup() self.expect( -"expr func_with_ptr_arg(\"bla\")", +'expr func_with_ptr_arg("bla")', error=True, substrs=["Architecture passes failure on function $__lldb_expr"], ) @skipIf(archs=no_match(["rv64gc"])) @@ -83,6 +82,5 @@ self.expect( "expr func_with_unsupported_struct_return()", error=True, substrs=["Architecture passes failure on function $__lldb_expr"], ) - `` https://github.com/llvm/llvm-project/pull/99336 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] progressive progress reporting for darwin kernel/firmware (PR #98845)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/98845 >From cead9ae6de627ee64fb58a829fa3485f526a0afc Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Sun, 14 Jul 2024 16:59:51 -0700 Subject: [PATCH 1/8] [lldb] progressive progress reporting for darwin kernel/firmware When doing firmware/kernel debugging, it is frequent that binaries and debug info need to be retrieved / downloaded, and the lack of progress reports made for a poor experience, with lldb seemingly hung while downloading things over the network. This PR adds progress reports to the critical sites for these use cases. --- lldb/source/Core/DynamicLoader.cpp| 27 +++-- .../DynamicLoaderDarwinKernel.cpp | 39 --- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp index 7871be6fc451d..a59136381c23b 100644 --- a/lldb/source/Core/DynamicLoader.cpp +++ b/lldb/source/Core/DynamicLoader.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/Progress.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/MemoryRegionInfo.h" @@ -195,20 +196,40 @@ ModuleSP DynamicLoader::LoadBinaryWithUUIDAndAddress( Target &target = process->GetTarget(); Status error; + StreamString prog_str; + if (!name.empty()) { +prog_str << name.str() << " "; + } + if (uuid.IsValid()) +prog_str << uuid.GetAsString(); + if (value_is_offset == 0 && value != LLDB_INVALID_ADDRESS) { +prog_str << "at "; +prog_str.PutHex64(value); + } + if (!uuid.IsValid() && !value_is_offset) { +Progress progress_memread("Reading load commands from memory", + prog_str.GetString().str()); memory_module_sp = ReadUnnamedMemoryModule(process, value, name); -if (memory_module_sp) +if (memory_module_sp) { uuid = memory_module_sp->GetUUID(); + if (uuid.IsValid()) { +prog_str << " "; +prog_str << uuid.GetAsString(); + } +} } ModuleSpec module_spec; module_spec.GetUUID() = uuid; FileSpec name_filespec(name); - if (FileSystem::Instance().Exists(name_filespec)) -module_spec.GetFileSpec() = name_filespec; if (uuid.IsValid()) { +Progress progress("Locating external symbol file", + prog_str.GetString().str()); + // Has lldb already seen a module with this UUID? +// Or have external lookup enabled in DebugSymbols on macOS. if (!module_sp) error = ModuleList::GetSharedModule(module_spec, module_sp, nullptr, nullptr, nullptr); diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index 8d83937aab668..93eb1e7b9dea9 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/Progress.h" #include "lldb/Core/Section.h" #include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Symbol/ObjectFile.h" @@ -757,6 +758,23 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule( const ModuleList &target_images = target.GetImages(); m_module_sp = target_images.FindModule(m_uuid); +std::unique_ptr progress_up; +if (IsKernel()) { + StreamString prog_str; + // 'mach_kernel' is a fake name we make up to find kernels + // that were located by the local filesystem scan. + if (GetName() != "mach_kernel") +prog_str << GetName() << " "; + if (GetUUID().IsValid()) +prog_str << GetUUID().GetAsString() << " "; + if (GetLoadAddress() != LLDB_INVALID_ADDRESS) { +prog_str << "at "; +prog_str.PutHex64(GetLoadAddress()); + } + progress_up = std::make_unique("Loading kernel", + prog_str.GetString().str()); +} + // Search for the kext on the local filesystem via the UUID if (!m_module_sp && m_uuid.IsValid()) { ModuleSpec module_spec; @@ -1058,12 +1076,9 @@ void DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded() { } } } - -if (m_kernel.GetLoadAddress() != LLDB_INVALID_ADDRESS) { - if (!m_kernel.LoadImageUsingMemoryModule(m_process)) { +if (m_kernel.GetLoadAddress() != LLDB_INVALID_ADDRESS) + if (!m_kernel.LoadImageUsingMemoryModule(m_process)) m_kernel.LoadImageAtFileAddress(m_process); - } -} // The operating system plugin gets loaded and initialized in // LoadImageUsingMemoryModule when we
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -1222,7 +1223,19 @@ lldb::SBError SBProcess::SaveCore(const char *file_name) { lldb::SBError SBProcess::SaveCore(const char *file_name, const char *flavor, SaveCoreStyle core_style) { - LLDB_INSTRUMENT_VA(this, file_name, flavor, core_style); + SBFileSpec fspec(file_name); + SBCoreDumpOptions options; + options.SetOutputFile(fspec); + options.SetCoreDumpPluginName(flavor); + options.SetCoreDumpStyle(core_style); + return SaveCore(options); +} + +lldb::SBError SBProcess::SaveCore(SBCoreDumpOptions &options) { + + LLDB_INSTRUMENT_VA(this, options.GetOutputFile(), + options.GetCoreDumpPluginName(), + options.GetCoreDumpStyle()); Jlalond wrote: The original source code asked for each individual field, so I kept roughly the same behavior, if we have a way to decompose the object in `INSTUMENT_VA` I would prefer to pass the object as this API will implicitly expand as the options object gains members/options. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -1271,13 +1271,13 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed { switch (short_option) { case 'p': -m_requested_plugin_name = option_arg.str(); +m_core_dump_options.SetCoreDumpPluginName(option_arg.data()); Jlalond wrote: I agree with the API change, but the underlying CoreDumpOptions would then need to reference the plugin manager and enumerate the plugins correct? https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 86ef699 - [lldb] progressive progress reporting for darwin kernel/firmware (#98845)
Author: Jason Molenda Date: 2024-07-17T10:05:55-07:00 New Revision: 86ef699060394c82dcda7e86ff70d8cabeabcc2a URL: https://github.com/llvm/llvm-project/commit/86ef699060394c82dcda7e86ff70d8cabeabcc2a DIFF: https://github.com/llvm/llvm-project/commit/86ef699060394c82dcda7e86ff70d8cabeabcc2a.diff LOG: [lldb] progressive progress reporting for darwin kernel/firmware (#98845) When doing firmware/kernel debugging, it is frequent that binaries and debug info need to be retrieved / downloaded, and the lack of progress reports made for a poor experience, with lldb seemingly hung while downloading things over the network. This PR adds progress reports to the critical sites for these use cases. Added: Modified: lldb/source/Core/DynamicLoader.cpp lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h lldb/source/Target/Process.cpp Removed: diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp index 7871be6fc451d..7758a87403b5a 100644 --- a/lldb/source/Core/DynamicLoader.cpp +++ b/lldb/source/Core/DynamicLoader.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/Progress.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/MemoryRegionInfo.h" @@ -195,20 +196,37 @@ ModuleSP DynamicLoader::LoadBinaryWithUUIDAndAddress( Target &target = process->GetTarget(); Status error; + StreamString prog_str; + if (!name.empty()) { +prog_str << name.str() << " "; + } + if (uuid.IsValid()) +prog_str << uuid.GetAsString(); + if (value_is_offset == 0 && value != LLDB_INVALID_ADDRESS) { +prog_str << "at 0x"; +prog_str.PutHex64(value); + } + if (!uuid.IsValid() && !value_is_offset) { memory_module_sp = ReadUnnamedMemoryModule(process, value, name); -if (memory_module_sp) +if (memory_module_sp) { uuid = memory_module_sp->GetUUID(); + if (uuid.IsValid()) { +prog_str << " "; +prog_str << uuid.GetAsString(); + } +} } ModuleSpec module_spec; module_spec.GetUUID() = uuid; FileSpec name_filespec(name); - if (FileSystem::Instance().Exists(name_filespec)) -module_spec.GetFileSpec() = name_filespec; if (uuid.IsValid()) { +Progress progress("Locating binary", prog_str.GetString().str()); + // Has lldb already seen a module with this UUID? +// Or have external lookup enabled in DebugSymbols on macOS. if (!module_sp) error = ModuleList::GetSharedModule(module_spec, module_sp, nullptr, nullptr, nullptr); diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index 8d83937aab668..20e5652c65bf8 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/Progress.h" #include "lldb/Core/Section.h" #include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Symbol/ObjectFile.h" @@ -714,7 +715,7 @@ void DynamicLoaderDarwinKernel::KextImageInfo::SetIsKernel(bool is_kernel) { } bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule( -Process *process) { +Process *process, Progress *progress) { Log *log = GetLog(LLDBLog::DynamicLoader); if (IsLoaded()) return true; @@ -757,11 +758,37 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule( const ModuleList &target_images = target.GetImages(); m_module_sp = target_images.FindModule(m_uuid); +StreamString prog_str; +// 'mach_kernel' is a fake name we make up to find kernels +// that were located by the local filesystem scan. +if (GetName() != "mach_kernel") + prog_str << GetName() << " "; +if (GetUUID().IsValid()) + prog_str << GetUUID().GetAsString() << " "; +if (GetLoadAddress() != LLDB_INVALID_ADDRESS) { + prog_str << "at 0x"; + prog_str.PutHex64(GetLoadAddress()); +} + +std::unique_ptr progress_up; +if (progress) + progress->Increment(1, prog_str.GetString().str()); +else { + if (IsKernel()) +progress_up = std::make_unique("Loading kernel", + prog_str.GetString().str()); + else +progress_up = std::make_unique("Loading kext", + prog_str.GetString().str()); +} + // Search for the kext on the local files
[Lldb-commits] [lldb] [lldb] progressive progress reporting for darwin kernel/firmware (PR #98845)
https://github.com/jasonmolenda closed https://github.com/llvm/llvm-project/pull/98845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,45 @@ +//===-- CoreDumpOptions.cpp -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Symbol/CoreDumpOptions.h" + +using namespace lldb; +using namespace lldb_private; + +void CoreDumpOptions::SetCoreDumpPluginName(const char * name) { + m_plugin_name = name; +} + +void CoreDumpOptions::SetCoreDumpStyle(lldb::SaveCoreStyle style) { + m_style = style; +} + +void CoreDumpOptions::SetOutputFile(FileSpec file) { + m_file = file; +} + +std::optional CoreDumpOptions::GetCoreDumpPluginName() const { + return m_plugin_name; +} + +lldb::SaveCoreStyle CoreDumpOptions::GetCoreDumpStyle() const { + // If unspecified, default to stack only + if (m_style == lldb::eSaveCoreUnspecified) +return lldb::eSaveCoreStackOnly; Jlalond wrote: @jasonmolenda I think we should keep the default behaviors for this diff (as it's getting fairly big), this does mean we'll need a non const options object being passed around. With the `const-ness` being the only reason I removed the default behaviors. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix simulator test for std::unique_ptr (PR #99357)
https://github.com/luporl created https://github.com/llvm/llvm-project/pull/99357 libcxx-simulators/unique_ptr/main.cpp uses __builtin_printf, that maps to printf on Windows. Include stdio.h to avoid linker errors on Windows. See https://lab.llvm.org/buildbot/#/builders/141/builds/853 >From 9d34bd13ee92b1bb1eacac522c6167cbf607f0fa Mon Sep 17 00:00:00 2001 From: Leandro Lupori Date: Wed, 17 Jul 2024 14:08:47 -0300 Subject: [PATCH] [lldb][test] Fix simulator test for std::unique_ptr libcxx-simulators/unique_ptr/main.cpp uses __builtin_printf, that maps to printf on Windows. Include stdio.h to avoid linker errors on Windows. See https://lab.llvm.org/buildbot/#/builders/141/builds/853 --- .../data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp| 2 ++ 1 file changed, 2 insertions(+) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp index 08324e24f9cc4..a6bfaa3febebb 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp @@ -1,5 +1,7 @@ #include +#include + namespace std { namespace __lldb { template struct default_delete { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix simulator test for std::unique_ptr (PR #99357)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Leandro Lupori (luporl) Changes libcxx-simulators/unique_ptr/main.cpp uses __builtin_printf, that maps to printf on Windows. Include stdio.h to avoid linker errors on Windows. See https://lab.llvm.org/buildbot/#/builders/141/builds/853 --- Full diff: https://github.com/llvm/llvm-project/pull/99357.diff 1 Files Affected: - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp (+2) ``diff diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp index 08324e24f9cc4..a6bfaa3febebb 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp @@ -1,5 +1,7 @@ #include +#include + namespace std { namespace __lldb { template struct default_delete { `` https://github.com/llvm/llvm-project/pull/99357 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix simulator test for std::unique_ptr (PR #99357)
luporl wrote: Test added in #98330. https://github.com/llvm/llvm-project/pull/99357 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][debuginfod] Fix the DebugInfoD PR that caused issues when working with stripped binaries (PR #99362)
https://github.com/kevinfrei created https://github.com/llvm/llvm-project/pull/99362 @walter-erquinigo found the the [PR with testing and a fix for DebugInfoD](https://github.com/llvm/llvm-project/pull/98344) caused an issue when working with stripped binaries. The issue is that when you're working with split-dwarf, there are *3* possible files: The stripped binary the user is debugging, the "only-keep-debug" *or* unstripped binary, plus the `.dwp` file. The debuginfod plugin should provide the unstripped/OKD binary. However, if the debuginfod plugin fails, the default symbol locator plugin will just return the stripped binary, which doesn't help. So, to address that, the SymbolVendorELF code checks to see if the SymbolLocator's ExecutableObjectFile request returned the same file, and bails if that's the case. You can see the specific diff as the second commit in the PR. I'm investigating adding a test: I can't quite get a simple repro, and I'm unwilling to make any additional changes to Makefile.rules to this diff, for Pavlovian reasons. >From 1494617c82065e44617b013c96ba51e578706d75 Mon Sep 17 00:00:00 2001 From: Kevin Frei Date: Mon, 25 Mar 2024 08:23:47 -0700 Subject: [PATCH 1/2] Trying to deal with Linux AArch64 test failures :/ Reapply "DebugInfoD tests + fixing issues exposed by tests (#85693)" This reverts commit 7fc2fbb3f1961e0ad0722c2d749ddd6264195a1c. Switched to using LLDB to get UUID at @clayborg's suggestion Disable tests on non-x86 Linux platforms, as they appear to fail on AArch64/Arm buildbots Moved the @skipIf to each test, off of the class itself Added CURL dependency to lit configuration 'stuff' Fixed comments in the tests Fix stupid formatter issue Updated to respond to (very late) code review feedback Fixed the script to acquire the UUID without creating a target Updated tests to not run on Mac/Windows Added LLVM_ENABLE_CURL to the config.h.cmake to work in test's @skipIf thing Attempting to prefer llvm-dwp over gnu's dwp Disabled the DWP tests Missed disabling the baseline test for DWP stuff --- lldb/include/lldb/Host/Config.h.cmake | 2 + .../Python/lldbsuite/test/decorators.py | 4 + .../Python/lldbsuite/test/make/Makefile.rules | 36 +++- lldb/source/API/SBDebugger.cpp| 13 +- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 38 ++-- .../Plugins/SymbolLocator/CMakeLists.txt | 7 +- .../SymbolVendor/ELF/SymbolVendorELF.cpp | 29 ++- lldb/test/API/debuginfod/Normal/Makefile | 19 ++ .../API/debuginfod/Normal/TestDebuginfod.py | 186 + lldb/test/API/debuginfod/Normal/main.c| 7 + lldb/test/API/debuginfod/SplitDWARF/Makefile | 23 ++ .../SplitDWARF/TestDebuginfodDWP.py | 196 ++ lldb/test/API/debuginfod/SplitDWARF/main.c| 7 + 13 files changed, 545 insertions(+), 22 deletions(-) create mode 100644 lldb/test/API/debuginfod/Normal/Makefile create mode 100644 lldb/test/API/debuginfod/Normal/TestDebuginfod.py create mode 100644 lldb/test/API/debuginfod/Normal/main.c create mode 100644 lldb/test/API/debuginfod/SplitDWARF/Makefile create mode 100644 lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py create mode 100644 lldb/test/API/debuginfod/SplitDWARF/main.c diff --git a/lldb/include/lldb/Host/Config.h.cmake b/lldb/include/lldb/Host/Config.h.cmake index 3defa454f6d42..9e538534086a2 100644 --- a/lldb/include/lldb/Host/Config.h.cmake +++ b/lldb/include/lldb/Host/Config.h.cmake @@ -33,6 +33,8 @@ #cmakedefine01 LLDB_ENABLE_LZMA +#cmakedefine01 LLVM_ENABLE_CURL + #cmakedefine01 LLDB_ENABLE_CURSES #cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index ecc7b81035f11..0e8ca159efd55 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -1053,6 +1053,10 @@ def _get_bool_config_skip_if_decorator(key): return unittest.skipIf(not have, "requires " + key) +def skipIfCurlSupportMissing(func): +return _get_bool_config_skip_if_decorator("curl")(func) + + def skipIfCursesSupportMissing(func): return _get_bool_config_skip_if_decorator("curses")(func) diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules index 3d562285ce9cc..d1a2de8b2478a 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../ # # GNUWin32 uname gives "windows32" or "server version windows32" while # some versions of MSYS uname return "MSYS_NT*", but most environments -# standardize on "Windows_NT", so we'll make it consistent here. +# standardize on "Windows_NT", so we'll make it consistent here. # When running tests from Visual Studio, the environment v
[Lldb-commits] [lldb] [lldb][debuginfod] Fix the DebugInfoD PR that caused issues when working with stripped binaries (PR #99362)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Kevin Frei (kevinfrei) Changes @walter-erquinigo found the the [PR with testing and a fix for DebugInfoD](https://github.com/llvm/llvm-project/pull/98344) caused an issue when working with stripped binaries. The issue is that when you're working with split-dwarf, there are *3* possible files: The stripped binary the user is debugging, the "only-keep-debug" *or* unstripped binary, plus the `.dwp` file. The debuginfod plugin should provide the unstripped/OKD binary. However, if the debuginfod plugin fails, the default symbol locator plugin will just return the stripped binary, which doesn't help. So, to address that, the SymbolVendorELF code checks to see if the SymbolLocator's ExecutableObjectFile request returned the same file, and bails if that's the case. You can see the specific diff as the second commit in the PR. I'm investigating adding a test: I can't quite get a simple repro, and I'm unwilling to make any additional changes to Makefile.rules to this diff, for Pavlovian reasons. --- Patch is 28.52 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/99362.diff 13 Files Affected: - (modified) lldb/include/lldb/Host/Config.h.cmake (+2) - (modified) lldb/packages/Python/lldbsuite/test/decorators.py (+4) - (modified) lldb/packages/Python/lldbsuite/test/make/Makefile.rules (+35-1) - (modified) lldb/source/API/SBDebugger.cpp (+8-5) - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+25-13) - (modified) lldb/source/Plugins/SymbolLocator/CMakeLists.txt (+6-1) - (modified) lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp (+34-2) - (added) lldb/test/API/debuginfod/Normal/Makefile (+19) - (added) lldb/test/API/debuginfod/Normal/TestDebuginfod.py (+186) - (added) lldb/test/API/debuginfod/Normal/main.c (+7) - (added) lldb/test/API/debuginfod/SplitDWARF/Makefile (+23) - (added) lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py (+196) - (added) lldb/test/API/debuginfod/SplitDWARF/main.c (+7) ``diff diff --git a/lldb/include/lldb/Host/Config.h.cmake b/lldb/include/lldb/Host/Config.h.cmake index 3defa454f6d42..9e538534086a2 100644 --- a/lldb/include/lldb/Host/Config.h.cmake +++ b/lldb/include/lldb/Host/Config.h.cmake @@ -33,6 +33,8 @@ #cmakedefine01 LLDB_ENABLE_LZMA +#cmakedefine01 LLVM_ENABLE_CURL + #cmakedefine01 LLDB_ENABLE_CURSES #cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index ecc7b81035f11..0e8ca159efd55 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -1053,6 +1053,10 @@ def _get_bool_config_skip_if_decorator(key): return unittest.skipIf(not have, "requires " + key) +def skipIfCurlSupportMissing(func): +return _get_bool_config_skip_if_decorator("curl")(func) + + def skipIfCursesSupportMissing(func): return _get_bool_config_skip_if_decorator("curses")(func) diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules index 3d562285ce9cc..d1a2de8b2478a 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../ # # GNUWin32 uname gives "windows32" or "server version windows32" while # some versions of MSYS uname return "MSYS_NT*", but most environments -# standardize on "Windows_NT", so we'll make it consistent here. +# standardize on "Windows_NT", so we'll make it consistent here. # When running tests from Visual Studio, the environment variable isn't # inherited all the way down to the process spawned for make. #-- @@ -213,6 +213,12 @@ else ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" DSYM = $(EXE).debug endif + + ifeq "$(MAKE_DWP)" "YES" + MAKE_DWO := YES + DWP_NAME = $(EXE).dwp + DYLIB_DWP_NAME = $(DYLIB_NAME).dwp + endif endif LIMIT_DEBUG_INFO_FLAGS = @@ -361,6 +367,17 @@ ifneq "$(OS)" "Darwin" OBJCOPY ?= $(call replace_cc_with,objcopy) ARCHIVER ?= $(call replace_cc_with,ar) + # Look for llvm-dwp or gnu dwp + DWP ?= $(call replace_cc_with,llvm-dwp) + ifeq ($(wildcard $(DWP)),) + DWP = $(call replace_cc_with,dwp) + ifeq ($(wildcard $(DWP)),) + DWP = $(shell command -v llvm-dwp 2> /dev/null) + ifeq ($(wildcard $(DWP)),) + DWP = $(shell command -v dwp 2> /dev/null) + endif + endif + endif override AR = $(ARCHIVER) endif @@ -531,6 +548,10 @@ ifneq "$(CXX)" "" endif endif
[Lldb-commits] [lldb] [lldb][test] Fix simulator test for std::unique_ptr (PR #99357)
luporl wrote: Merging to fix https://lab.llvm.org/buildbot/#/builders/141/builds/853, which has been broken for over 36 hours. https://github.com/llvm/llvm-project/pull/99357 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 93d38d7 - [lldb][test] Fix simulator test for std::unique_ptr (#99357)
Author: Leandro Lupori Date: 2024-07-17T14:49:22-03:00 New Revision: 93d38d7f08864397f1e751c8cecde5ea302ecced URL: https://github.com/llvm/llvm-project/commit/93d38d7f08864397f1e751c8cecde5ea302ecced DIFF: https://github.com/llvm/llvm-project/commit/93d38d7f08864397f1e751c8cecde5ea302ecced.diff LOG: [lldb][test] Fix simulator test for std::unique_ptr (#99357) libcxx-simulators/unique_ptr/main.cpp uses __builtin_printf, that maps to printf on Windows. Include stdio.h to avoid linker errors on Windows. See https://lab.llvm.org/buildbot/#/builders/141/builds/853 Added: Modified: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp Removed: diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp index 08324e24f9cc4..a6bfaa3febebb 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp @@ -1,5 +1,7 @@ #include +#include + namespace std { namespace __lldb { template struct default_delete { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix simulator test for std::unique_ptr (PR #99357)
https://github.com/luporl closed https://github.com/llvm/llvm-project/pull/99357 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Refactor TypeQuery::ContextMatches (PR #99305)
https://github.com/clayborg commented: Anytime we change this code it makes me nervous. The unit tests are quite simple and not sure how they match up against real world lookups, but as far as I can tell this looks ok. https://github.com/llvm/llvm-project/pull/99305 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][debuginfod] Fix the DebugInfoD PR that caused issues when working with stripped binaries (PR #99362)
@@ -106,12 +106,19 @@ SymbolVendorELF::CreateInstance(const lldb::ModuleSP &module_sp, FileSpec dsym_fspec = PluginManager::LocateExecutableSymbolFile(module_spec, search_paths); if (!dsym_fspec || IsDwpSymbolFile(module_sp, dsym_fspec)) { -// If we have a stripped binary or if we got a DWP file, we should prefer -// symbols in the executable acquired through a plugin. +// If we have a stripped binary or if we have a DWP file, symbol locator +// plugins may be able to give us an unstripped binary or an +// 'only-keep-debug' stripped file. ModuleSpec unstripped_spec = PluginManager::LocateExecutableObjectFile(module_spec); if (!unstripped_spec) return nullptr; +// If we got the original binary back from the plugin manager, the plugins +// didn't find anything more useful that the stripped binary. (The default +// symbol locator plugin returns the original binary if it can't find +// anything else.) +if (unstripped_spec.GetFileSpec() == module_spec.GetFileSpec()) Jlalond wrote: Nit, this comment is pretty hard to grok. I also think it can be trimmed down a bit ``` // If the plugin manager returns the original binary, // then it failed to find anything else and we should return ``` https://github.com/llvm/llvm-project/pull/99362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][debuginfod] Fix the DebugInfoD PR that caused issues when working with stripped binaries (PR #99362)
Jlalond wrote: [Most recent commit on this](b97d59c78ac0e25e1af15608f711b0f7a3f5b1bd) on this sisyphean patch LGTM. I did leave a nit for wording on the comment but view it as optional. https://github.com/llvm/llvm-project/pull/99362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][debuginfod] Fix the DebugInfoD PR that caused issues when working with stripped binaries (PR #99362)
https://github.com/kevinfrei updated https://github.com/llvm/llvm-project/pull/99362 >From 1494617c82065e44617b013c96ba51e578706d75 Mon Sep 17 00:00:00 2001 From: Kevin Frei Date: Mon, 25 Mar 2024 08:23:47 -0700 Subject: [PATCH 1/2] Trying to deal with Linux AArch64 test failures :/ Reapply "DebugInfoD tests + fixing issues exposed by tests (#85693)" This reverts commit 7fc2fbb3f1961e0ad0722c2d749ddd6264195a1c. Switched to using LLDB to get UUID at @clayborg's suggestion Disable tests on non-x86 Linux platforms, as they appear to fail on AArch64/Arm buildbots Moved the @skipIf to each test, off of the class itself Added CURL dependency to lit configuration 'stuff' Fixed comments in the tests Fix stupid formatter issue Updated to respond to (very late) code review feedback Fixed the script to acquire the UUID without creating a target Updated tests to not run on Mac/Windows Added LLVM_ENABLE_CURL to the config.h.cmake to work in test's @skipIf thing Attempting to prefer llvm-dwp over gnu's dwp Disabled the DWP tests Missed disabling the baseline test for DWP stuff --- lldb/include/lldb/Host/Config.h.cmake | 2 + .../Python/lldbsuite/test/decorators.py | 4 + .../Python/lldbsuite/test/make/Makefile.rules | 36 +++- lldb/source/API/SBDebugger.cpp| 13 +- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 38 ++-- .../Plugins/SymbolLocator/CMakeLists.txt | 7 +- .../SymbolVendor/ELF/SymbolVendorELF.cpp | 29 ++- lldb/test/API/debuginfod/Normal/Makefile | 19 ++ .../API/debuginfod/Normal/TestDebuginfod.py | 186 + lldb/test/API/debuginfod/Normal/main.c| 7 + lldb/test/API/debuginfod/SplitDWARF/Makefile | 23 ++ .../SplitDWARF/TestDebuginfodDWP.py | 196 ++ lldb/test/API/debuginfod/SplitDWARF/main.c| 7 + 13 files changed, 545 insertions(+), 22 deletions(-) create mode 100644 lldb/test/API/debuginfod/Normal/Makefile create mode 100644 lldb/test/API/debuginfod/Normal/TestDebuginfod.py create mode 100644 lldb/test/API/debuginfod/Normal/main.c create mode 100644 lldb/test/API/debuginfod/SplitDWARF/Makefile create mode 100644 lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py create mode 100644 lldb/test/API/debuginfod/SplitDWARF/main.c diff --git a/lldb/include/lldb/Host/Config.h.cmake b/lldb/include/lldb/Host/Config.h.cmake index 3defa454f6d42..9e538534086a2 100644 --- a/lldb/include/lldb/Host/Config.h.cmake +++ b/lldb/include/lldb/Host/Config.h.cmake @@ -33,6 +33,8 @@ #cmakedefine01 LLDB_ENABLE_LZMA +#cmakedefine01 LLVM_ENABLE_CURL + #cmakedefine01 LLDB_ENABLE_CURSES #cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index ecc7b81035f11..0e8ca159efd55 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -1053,6 +1053,10 @@ def _get_bool_config_skip_if_decorator(key): return unittest.skipIf(not have, "requires " + key) +def skipIfCurlSupportMissing(func): +return _get_bool_config_skip_if_decorator("curl")(func) + + def skipIfCursesSupportMissing(func): return _get_bool_config_skip_if_decorator("curses")(func) diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules index 3d562285ce9cc..d1a2de8b2478a 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../ # # GNUWin32 uname gives "windows32" or "server version windows32" while # some versions of MSYS uname return "MSYS_NT*", but most environments -# standardize on "Windows_NT", so we'll make it consistent here. +# standardize on "Windows_NT", so we'll make it consistent here. # When running tests from Visual Studio, the environment variable isn't # inherited all the way down to the process spawned for make. #-- @@ -213,6 +213,12 @@ else ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" DSYM = $(EXE).debug endif + + ifeq "$(MAKE_DWP)" "YES" + MAKE_DWO := YES + DWP_NAME = $(EXE).dwp + DYLIB_DWP_NAME = $(DYLIB_NAME).dwp + endif endif LIMIT_DEBUG_INFO_FLAGS = @@ -361,6 +367,17 @@ ifneq "$(OS)" "Darwin" OBJCOPY ?= $(call replace_cc_with,objcopy) ARCHIVER ?= $(call replace_cc_with,ar) + # Look for llvm-dwp or gnu dwp + DWP ?= $(call replace_cc_with,llvm-dwp) + ifeq ($(wildcard $(DWP)),) + DWP = $(call replace_cc_with,dwp) + ifeq ($(wildcard $(DWP)),) + DWP = $(shell command -v llvm-dwp 2> /dev/null) + ifeq ($(wildcard $(DWP)),) +
[Lldb-commits] [lldb] [lldb][debuginfod] Fix the DebugInfoD PR that caused issues when working with stripped binaries (PR #99362)
@@ -106,12 +106,19 @@ SymbolVendorELF::CreateInstance(const lldb::ModuleSP &module_sp, FileSpec dsym_fspec = PluginManager::LocateExecutableSymbolFile(module_spec, search_paths); if (!dsym_fspec || IsDwpSymbolFile(module_sp, dsym_fspec)) { -// If we have a stripped binary or if we got a DWP file, we should prefer -// symbols in the executable acquired through a plugin. +// If we have a stripped binary or if we have a DWP file, symbol locator +// plugins may be able to give us an unstripped binary or an +// 'only-keep-debug' stripped file. ModuleSpec unstripped_spec = PluginManager::LocateExecutableObjectFile(module_spec); if (!unstripped_spec) return nullptr; +// If we got the original binary back from the plugin manager, the plugins +// didn't find anything more useful that the stripped binary. (The default +// symbol locator plugin returns the original binary if it can't find +// anything else.) +if (unstripped_spec.GetFileSpec() == module_spec.GetFileSpec()) kevinfrei wrote: Cleaned the comment up a bit. https://github.com/llvm/llvm-project/pull/99362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][debuginfod] Fix the DebugInfoD PR that caused issues when working with stripped binaries (PR #99362)
walter-erquinigo wrote: This LGTM, although I'd rather have someone like @clayborg taking a look https://github.com/llvm/llvm-project/pull/99362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] IRMemoryMap zero address mapping fix (PR #99045)
jasonmolenda wrote: To make sure I'm clear: I don't have a problem with the basic idea of the change, although we could comment what is going on more clearly, and I'm curious about that qMemoryRegionInfo packet. But it looks like you're connecting to a device which can't allocate memory through gdb remote serial protocol (common for jtag/vm type stubs), but can report memory region info (much less common, it's an lldb extension I believe), and the memory region at address 0 is reported as being inaccessible (reasonable). So the IRMemoryMap is trying to use address 0 and that overlaps with actual addresses seen in the process, leading to confusion. Most similar environments, that can't allocate memory, don't support qMemoryRegionInfo so we pick one of our bogus addresses ranges (in higher memory) to get a better chance of avoiding actual program addresses. https://github.com/llvm/llvm-project/pull/99045 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][debuginfod] Fix the DebugInfoD PR that caused issues when working with stripped binaries (PR #99362)
kevinfrei wrote: > This LGTM, although I'd rather have someone like @clayborg taking a look Yeah, I try not to bug him too much, since he's a coworker and I already get his time in a few recurring meetings. I might actually try to grab a VC with him to see if there's some other scenario I'm missing. https://github.com/llvm/llvm-project/pull/99362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
https://github.com/Jlalond updated https://github.com/llvm/llvm-project/pull/98403 >From 4752adac6b8d39512bbfb46726205ceb2301d1c2 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde Date: Tue, 9 Jul 2024 13:30:46 -0700 Subject: [PATCH 1/5] Create CoreDumpOption class, and SB equivalent --- lldb/include/lldb/API/SBCoreDumpOptions.h | 37 +++ lldb/source/API/SBCoreDumpOptions.cpp | 16 .../Plugins/ObjectFile/CoreDumpOptions.cpp| 25 + .../Plugins/ObjectFile/CoreDumpOptions.h | 37 +++ 4 files changed, 115 insertions(+) create mode 100644 lldb/include/lldb/API/SBCoreDumpOptions.h create mode 100644 lldb/source/API/SBCoreDumpOptions.cpp create mode 100644 lldb/source/Plugins/ObjectFile/CoreDumpOptions.cpp create mode 100644 lldb/source/Plugins/ObjectFile/CoreDumpOptions.h diff --git a/lldb/include/lldb/API/SBCoreDumpOptions.h b/lldb/include/lldb/API/SBCoreDumpOptions.h new file mode 100644 index 0..523fa34c17f36 --- /dev/null +++ b/lldb/include/lldb/API/SBCoreDumpOptions.h @@ -0,0 +1,37 @@ +//===-- SBCoreDumpOptions.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBCOREDUMPOPTIONS_H +#define LLDB_API_SBCOREDUMPOPTIONS_H + +namespace lldb { + +class LLDB_API SBCoreDumpOptions { +public: + SBCoreDumpOptions() {}; + SBStatisticsOptions(const lldb::SBCoreDumpOptions &rhs); + ~SBExpressionOptions() = default; + + const SBStatisticsOptions &operator=(const lldb::SBStatisticsOptions &rhs); + + void SetCoreDumpPluginName(const char* plugin); + const char* GetCoreDumpPluginName(); + + void SetCoreDumpStyle(const char* style); + const char* GetCoreDumpStyle(); + + void SetOutputFilePath(const char* path); + const char* GetOutputFilePath(); + +private: + std::unique_ptr m_opaque_up; +}; // SBCoreDumpOptions + +}; // namespace lldb + +#endif // LLDB_API_SBCOREDUMPOPTIONS_H diff --git a/lldb/source/API/SBCoreDumpOptions.cpp b/lldb/source/API/SBCoreDumpOptions.cpp new file mode 100644 index 0..d051c5b6bef6b --- /dev/null +++ b/lldb/source/API/SBCoreDumpOptions.cpp @@ -0,0 +1,16 @@ +//===-- SBCoreDumpOptions.cpp ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/API/SBCoreDumpOptions.h" + +using namespace lldb; +using namespace lldb_private; + +void SBCoreDumpOptions::SetCoreDumpPluginName(const char *name) { + +}; diff --git a/lldb/source/Plugins/ObjectFile/CoreDumpOptions.cpp b/lldb/source/Plugins/ObjectFile/CoreDumpOptions.cpp new file mode 100644 index 0..00333d1550790 --- /dev/null +++ b/lldb/source/Plugins/ObjectFile/CoreDumpOptions.cpp @@ -0,0 +1,25 @@ +//===-- CoreDumpOptions.cpp -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/API/CoreDumpOptions.h" + +CoreDumpOptions::SetCoreDumpPluginName(const char *name) { + m_core_dump_plugin_name = name; +} + +CoreDumpOptions::GetCoreDumpPluginName() { return m_core_dump_plugin_name; } + +CoreDumpOptions::SetCoreDumpStyle(lldb::SaveCoreStyle style) { + m_core_dump_style = style; +} + +CoreDumpOptions::GetCoreDumpStyle() { return m_core_dump_style; } + +CoreDumpOptions::SetCoreDumpFile(const char *file) { m_core_dump_file = file; } + +CoreDumpOptions::GetCoreDumpFile() { return m_core_dump_file; } diff --git a/lldb/source/Plugins/ObjectFile/CoreDumpOptions.h b/lldb/source/Plugins/ObjectFile/CoreDumpOptions.h new file mode 100644 index 0..fe369b0490674 --- /dev/null +++ b/lldb/source/Plugins/ObjectFile/CoreDumpOptions.h @@ -0,0 +1,37 @@ +//===-- CoreDumpOptions.h ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H +#define LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H + +#include + +using namespace lldb; + +class CoreDumpOptions { + public: +
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -1271,13 +1271,13 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed { switch (short_option) { case 'p': -m_requested_plugin_name = option_arg.str(); +m_core_dump_options.SetPluginName(option_arg.data()); Jlalond wrote: @clayborg Should we return here the error here from setting an invalid plugin name? https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -355,11 +355,9 @@ size_t ObjectFilePECOFF::GetModuleSpecifications( } bool ObjectFilePECOFF::SaveCore(const lldb::ProcessSP &process_sp, -const lldb_private::FileSpec &outfile, -lldb::SaveCoreStyle &core_style, +const lldb_private::CoreDumpOptions &core_options, lldb_private::Status &error) { - core_style = eSaveCoreFull; Jlalond wrote: For this function COFF never actually references the corestyle in saveminidump, so I am resolving. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
https://github.com/Jlalond updated https://github.com/llvm/llvm-project/pull/98403 >From 4752adac6b8d39512bbfb46726205ceb2301d1c2 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde Date: Tue, 9 Jul 2024 13:30:46 -0700 Subject: [PATCH 1/6] Create CoreDumpOption class, and SB equivalent --- lldb/include/lldb/API/SBCoreDumpOptions.h | 37 +++ lldb/source/API/SBCoreDumpOptions.cpp | 16 .../Plugins/ObjectFile/CoreDumpOptions.cpp| 25 + .../Plugins/ObjectFile/CoreDumpOptions.h | 37 +++ 4 files changed, 115 insertions(+) create mode 100644 lldb/include/lldb/API/SBCoreDumpOptions.h create mode 100644 lldb/source/API/SBCoreDumpOptions.cpp create mode 100644 lldb/source/Plugins/ObjectFile/CoreDumpOptions.cpp create mode 100644 lldb/source/Plugins/ObjectFile/CoreDumpOptions.h diff --git a/lldb/include/lldb/API/SBCoreDumpOptions.h b/lldb/include/lldb/API/SBCoreDumpOptions.h new file mode 100644 index 0..523fa34c17f36 --- /dev/null +++ b/lldb/include/lldb/API/SBCoreDumpOptions.h @@ -0,0 +1,37 @@ +//===-- SBCoreDumpOptions.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBCOREDUMPOPTIONS_H +#define LLDB_API_SBCOREDUMPOPTIONS_H + +namespace lldb { + +class LLDB_API SBCoreDumpOptions { +public: + SBCoreDumpOptions() {}; + SBStatisticsOptions(const lldb::SBCoreDumpOptions &rhs); + ~SBExpressionOptions() = default; + + const SBStatisticsOptions &operator=(const lldb::SBStatisticsOptions &rhs); + + void SetCoreDumpPluginName(const char* plugin); + const char* GetCoreDumpPluginName(); + + void SetCoreDumpStyle(const char* style); + const char* GetCoreDumpStyle(); + + void SetOutputFilePath(const char* path); + const char* GetOutputFilePath(); + +private: + std::unique_ptr m_opaque_up; +}; // SBCoreDumpOptions + +}; // namespace lldb + +#endif // LLDB_API_SBCOREDUMPOPTIONS_H diff --git a/lldb/source/API/SBCoreDumpOptions.cpp b/lldb/source/API/SBCoreDumpOptions.cpp new file mode 100644 index 0..d051c5b6bef6b --- /dev/null +++ b/lldb/source/API/SBCoreDumpOptions.cpp @@ -0,0 +1,16 @@ +//===-- SBCoreDumpOptions.cpp ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/API/SBCoreDumpOptions.h" + +using namespace lldb; +using namespace lldb_private; + +void SBCoreDumpOptions::SetCoreDumpPluginName(const char *name) { + +}; diff --git a/lldb/source/Plugins/ObjectFile/CoreDumpOptions.cpp b/lldb/source/Plugins/ObjectFile/CoreDumpOptions.cpp new file mode 100644 index 0..00333d1550790 --- /dev/null +++ b/lldb/source/Plugins/ObjectFile/CoreDumpOptions.cpp @@ -0,0 +1,25 @@ +//===-- CoreDumpOptions.cpp -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/API/CoreDumpOptions.h" + +CoreDumpOptions::SetCoreDumpPluginName(const char *name) { + m_core_dump_plugin_name = name; +} + +CoreDumpOptions::GetCoreDumpPluginName() { return m_core_dump_plugin_name; } + +CoreDumpOptions::SetCoreDumpStyle(lldb::SaveCoreStyle style) { + m_core_dump_style = style; +} + +CoreDumpOptions::GetCoreDumpStyle() { return m_core_dump_style; } + +CoreDumpOptions::SetCoreDumpFile(const char *file) { m_core_dump_file = file; } + +CoreDumpOptions::GetCoreDumpFile() { return m_core_dump_file; } diff --git a/lldb/source/Plugins/ObjectFile/CoreDumpOptions.h b/lldb/source/Plugins/ObjectFile/CoreDumpOptions.h new file mode 100644 index 0..fe369b0490674 --- /dev/null +++ b/lldb/source/Plugins/ObjectFile/CoreDumpOptions.h @@ -0,0 +1,37 @@ +//===-- CoreDumpOptions.h ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H +#define LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H + +#include + +using namespace lldb; + +class CoreDumpOptions { + public: +
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
https://github.com/Jlalond updated https://github.com/llvm/llvm-project/pull/98403 >From 4752adac6b8d39512bbfb46726205ceb2301d1c2 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde Date: Tue, 9 Jul 2024 13:30:46 -0700 Subject: [PATCH 1/7] Create CoreDumpOption class, and SB equivalent --- lldb/include/lldb/API/SBCoreDumpOptions.h | 37 +++ lldb/source/API/SBCoreDumpOptions.cpp | 16 .../Plugins/ObjectFile/CoreDumpOptions.cpp| 25 + .../Plugins/ObjectFile/CoreDumpOptions.h | 37 +++ 4 files changed, 115 insertions(+) create mode 100644 lldb/include/lldb/API/SBCoreDumpOptions.h create mode 100644 lldb/source/API/SBCoreDumpOptions.cpp create mode 100644 lldb/source/Plugins/ObjectFile/CoreDumpOptions.cpp create mode 100644 lldb/source/Plugins/ObjectFile/CoreDumpOptions.h diff --git a/lldb/include/lldb/API/SBCoreDumpOptions.h b/lldb/include/lldb/API/SBCoreDumpOptions.h new file mode 100644 index 0..523fa34c17f36 --- /dev/null +++ b/lldb/include/lldb/API/SBCoreDumpOptions.h @@ -0,0 +1,37 @@ +//===-- SBCoreDumpOptions.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBCOREDUMPOPTIONS_H +#define LLDB_API_SBCOREDUMPOPTIONS_H + +namespace lldb { + +class LLDB_API SBCoreDumpOptions { +public: + SBCoreDumpOptions() {}; + SBStatisticsOptions(const lldb::SBCoreDumpOptions &rhs); + ~SBExpressionOptions() = default; + + const SBStatisticsOptions &operator=(const lldb::SBStatisticsOptions &rhs); + + void SetCoreDumpPluginName(const char* plugin); + const char* GetCoreDumpPluginName(); + + void SetCoreDumpStyle(const char* style); + const char* GetCoreDumpStyle(); + + void SetOutputFilePath(const char* path); + const char* GetOutputFilePath(); + +private: + std::unique_ptr m_opaque_up; +}; // SBCoreDumpOptions + +}; // namespace lldb + +#endif // LLDB_API_SBCOREDUMPOPTIONS_H diff --git a/lldb/source/API/SBCoreDumpOptions.cpp b/lldb/source/API/SBCoreDumpOptions.cpp new file mode 100644 index 0..d051c5b6bef6b --- /dev/null +++ b/lldb/source/API/SBCoreDumpOptions.cpp @@ -0,0 +1,16 @@ +//===-- SBCoreDumpOptions.cpp ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/API/SBCoreDumpOptions.h" + +using namespace lldb; +using namespace lldb_private; + +void SBCoreDumpOptions::SetCoreDumpPluginName(const char *name) { + +}; diff --git a/lldb/source/Plugins/ObjectFile/CoreDumpOptions.cpp b/lldb/source/Plugins/ObjectFile/CoreDumpOptions.cpp new file mode 100644 index 0..00333d1550790 --- /dev/null +++ b/lldb/source/Plugins/ObjectFile/CoreDumpOptions.cpp @@ -0,0 +1,25 @@ +//===-- CoreDumpOptions.cpp -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/API/CoreDumpOptions.h" + +CoreDumpOptions::SetCoreDumpPluginName(const char *name) { + m_core_dump_plugin_name = name; +} + +CoreDumpOptions::GetCoreDumpPluginName() { return m_core_dump_plugin_name; } + +CoreDumpOptions::SetCoreDumpStyle(lldb::SaveCoreStyle style) { + m_core_dump_style = style; +} + +CoreDumpOptions::GetCoreDumpStyle() { return m_core_dump_style; } + +CoreDumpOptions::SetCoreDumpFile(const char *file) { m_core_dump_file = file; } + +CoreDumpOptions::GetCoreDumpFile() { return m_core_dump_file; } diff --git a/lldb/source/Plugins/ObjectFile/CoreDumpOptions.h b/lldb/source/Plugins/ObjectFile/CoreDumpOptions.h new file mode 100644 index 0..fe369b0490674 --- /dev/null +++ b/lldb/source/Plugins/ObjectFile/CoreDumpOptions.h @@ -0,0 +1,37 @@ +//===-- CoreDumpOptions.h ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H +#define LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H + +#include + +using namespace lldb; + +class CoreDumpOptions { + public: +
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -132,8 +132,13 @@ def test_save_linux_mini_dump(self): stacks_to_sp_map, ) +options = lldb.SBCoreDumpOptions() +core_sb_stack_spec = lldb.SBFileSpec(core_sb_stack) +options.SetOutputFile(core_sb_stack_spec) +options.SetCoreDumpPluginName("minidump") Jlalond wrote: Created a new unit test file for this https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -178,6 +178,8 @@ class PluginManager { static bool UnregisterPlugin(ObjectFileCreateInstance create_callback); + static bool IsRegisteredPluginName(const char *name); clayborg wrote: This function name needs to be more complete to say we are searching for a valid object file plug-in name because we have many different kinds of plugins use the same type as the way names are stored, so use `llvm::StringRef`: ``` static bool IsRegisteredObjectFilePluginName(llvm::StringRef name); ``` https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -639,6 +640,18 @@ static ObjectFileInstances &GetObjectFileInstances() { return g_instances; } +bool PluginManager::IsRegisteredPluginName(const char *name) { clayborg wrote: `name` will now be a `llvm::StringRef` https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -56,18 +56,20 @@ size_t ObjectFileMinidump::GetModuleSpecifications( } bool ObjectFileMinidump::SaveCore(const lldb::ProcessSP &process_sp, - const lldb_private::FileSpec &outfile, - lldb::SaveCoreStyle &core_style, + const lldb_private::CoreDumpOptions &options, lldb_private::Status &error) { - // Set default core style if it isn't set. - if (core_style == SaveCoreStyle::eSaveCoreUnspecified) -core_style = SaveCoreStyle::eSaveCoreStackOnly; - + assert(options.GetOutputFile().has_value()); if (!process_sp) return false; clayborg wrote: Might as well check this in the plugin manager and assert(process_sp) with an appropriate comment like we did above. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -1256,7 +1256,7 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed { class CommandOptions : public Options { public: -CommandOptions() = default; +CommandOptions(){}; clayborg wrote: revert this to use "= default;". The code is the same, but not need to change a line of code if we don't have to. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,55 @@ +//===-- CoreDumpOptions.cpp -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Symbol/CoreDumpOptions.h" +#include "lldb/Core/PluginManager.h" + +using namespace lldb; +using namespace lldb_private; + +Status CoreDumpOptions::SetPluginName(const char *name) { + Status error; + if (!name || !name[0]) { +m_plugin_name = std::nullopt; +error.SetErrorString("no plugin name specified"); + } + + if (!PluginManager::IsRegisteredPluginName(name)) { +error.SetErrorStringWithFormat( +"plugin name '%s' is not a registered plugin", name); +return error; + } + + m_plugin_name = name; + return error; +} + +void CoreDumpOptions::SetStyle(lldb::SaveCoreStyle style) { m_style = style; } + +void CoreDumpOptions::SetOutputFile(FileSpec file) { m_file = file; } + +std::optional CoreDumpOptions::GetPluginName() const { + return m_plugin_name; +} + +lldb::SaveCoreStyle CoreDumpOptions::GetStyle() const { + if (!m_style.has_value()) +return lldb::eSaveCoreUnspecified; + return m_style.value(); clayborg wrote: These three lines can be: ``` return m_style.value_or(lldb::eSaveCoreUnspecified); ``` https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,55 @@ +//===-- CoreDumpOptions.cpp -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Symbol/CoreDumpOptions.h" +#include "lldb/Core/PluginManager.h" + +using namespace lldb; +using namespace lldb_private; + +Status CoreDumpOptions::SetPluginName(const char *name) { + Status error; + if (!name || !name[0]) { +m_plugin_name = std::nullopt; +error.SetErrorString("no plugin name specified"); clayborg wrote: This isn't an error, but a way to clear the specified plug-in name. So no error here, just clear the plug-in name and that is a success https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,25 @@ +"""Test the SBCoreDumpOptions APIs.""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * + + +class SBCoreDumpOptionsAPICase(TestBase): +def test_plugin_name_assignment(self): +"""Test""" +options = lldb.SBCoreDumpOptions() +error = options.SetPluginName(None) +self.assertTrue(error.Fail()) clayborg wrote: This shouldn't fail, setting it to None clears the setting. So this test should probably set it to something valid first, like "minidump", verify you get that name back, then set it to None, verify you get None back. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -6519,14 +6519,16 @@ struct page_object { }; bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp, - const FileSpec &outfile, - lldb::SaveCoreStyle &core_style, Status &error) { - if (!process_sp) -return false; - - // Default on macOS is to create a dirty-memory-only corefile. + const lldb_private::CoreDumpOptions &options, + Status &error) { + auto core_style = options.GetStyle(); if (core_style == SaveCoreStyle::eSaveCoreUnspecified) core_style = SaveCoreStyle::eSaveCoreDirtyOnly; + // The FileSpec is already checked in PluginManager::SaveCore. + assert(options.GetOutputFile().has_value()); + const FileSpec outfile = options.GetOutputFile().value(); + if (!process_sp) +return false; clayborg wrote: This would be checked in the `PluginManager::SaveCore(...)` and we can do a assert like we did for the options.GetOutputFile() above https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,76 @@ +//===-- SBCoreDumpOptions.cpp ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/API/SBCoreDumpOptions.h" +#include "lldb/API/SBError.h" +#include "lldb/API/SBFileSpec.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Symbol/CoreDumpOptions.h" +#include "lldb/Utility/Instrumentation.h" + +#include "Utils.h" + +using namespace lldb; + +SBCoreDumpOptions::SBCoreDumpOptions() { + LLDB_INSTRUMENT_VA(this) + + m_opaque_up = std::make_unique(); +} + +SBCoreDumpOptions::SBCoreDumpOptions(const SBCoreDumpOptions &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); + + m_opaque_up = clone(rhs.m_opaque_up); +} + +const SBCoreDumpOptions & +SBCoreDumpOptions::operator=(const SBCoreDumpOptions &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); + + if (this != &rhs) +m_opaque_up = clone(rhs.m_opaque_up); + return *this; +} + +SBError SBCoreDumpOptions::SetPluginName(const char *name) { + lldb_private::Status error = m_opaque_up->SetPluginName(name); clayborg wrote: Add LLDB_INSTRUMENT_VA here and too all methods. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,55 @@ +//===-- CoreDumpOptions.cpp -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Symbol/CoreDumpOptions.h" +#include "lldb/Core/PluginManager.h" + +using namespace lldb; +using namespace lldb_private; + +Status CoreDumpOptions::SetPluginName(const char *name) { + Status error; + if (!name || !name[0]) { +m_plugin_name = std::nullopt; +error.SetErrorString("no plugin name specified"); + } + + if (!PluginManager::IsRegisteredPluginName(name)) { +error.SetErrorStringWithFormat( +"plugin name '%s' is not a registered plugin", name); clayborg wrote: "plugin name '%s' is not a valid ObjectFile plugin name" https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -639,6 +640,18 @@ static ObjectFileInstances &GetObjectFileInstances() { return g_instances; } +bool PluginManager::IsRegisteredPluginName(const char *name) { + if (!name || !name[0]) clayborg wrote: Ask the `llvm::StringRef` if is it empty: ``` if (name.empty()) ``` https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
https://github.com/clayborg edited https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
https://github.com/clayborg requested changes to this pull request. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,86 @@ +//===-- SBCoreDumpOptions.cpp ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/API/SBCoreDumpOptions.h" +#include "lldb/API/SBError.h" +#include "lldb/API/SBFileSpec.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Symbol/CoreDumpOptions.h" +#include "lldb/Utility/Instrumentation.h" + +#include "Utils.h" + +using namespace lldb; + +SBCoreDumpOptions::SBCoreDumpOptions() { + LLDB_INSTRUMENT_VA(this) + + m_opaque_up = std::make_unique(); +} + +SBCoreDumpOptions::SBCoreDumpOptions(const SBCoreDumpOptions &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); + + m_opaque_up = clone(rhs.m_opaque_up); +} + +const SBCoreDumpOptions & +SBCoreDumpOptions::operator=(const SBCoreDumpOptions &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); + + if (this != &rhs) +m_opaque_up = clone(rhs.m_opaque_up); + return *this; +} + +SBError SBCoreDumpOptions::SetPluginName(const char *name) { + LLDB_INSTRUMENT_VA(this, name); + lldb_private::Status error = m_opaque_up->SetPluginName(name); + return SBError(error); +} + +void SBCoreDumpOptions::SetStyle(lldb::SaveCoreStyle style) { + LLDB_INSTRUMENT_VA(this, style); + m_opaque_up->SetStyle(style); +} + +void SBCoreDumpOptions::SetOutputFile(lldb::SBFileSpec file_spec) { + LLDB_INSTRUMENT_VA(this, file_spec); + m_opaque_up->SetOutputFile(file_spec.ref()); +} + +const char *SBCoreDumpOptions::GetPluginName() const { + LLDB_INSTRUMENT_VA(this); + const auto name = m_opaque_up->GetPluginName(); + if (!name) +return nullptr; + return lldb_private::ConstString(name.value()).GetCString(); +} + +SBFileSpec SBCoreDumpOptions::GetOutputFile() const { + LLDB_INSTRUMENT_VA(this); + const auto file_spec = m_opaque_up->GetOutputFile(); + if (file_spec) +return SBFileSpec(file_spec.value()); + return SBFileSpec(); +} + +lldb::SaveCoreStyle SBCoreDumpOptions::GetStyle() const { + LLDB_INSTRUMENT_VA(this); + return m_opaque_up->GetStyle(); +} + +lldb_private::CoreDumpOptions &SBCoreDumpOptions::ref() const { + LLDB_INSTRUMENT_VA(this); clayborg wrote: This is an internal API we don't need to log... Anything private or protected doesn't need to be instrumented. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -689,30 +702,38 @@ PluginManager::GetObjectFileCreateMemoryCallbackForPluginName( } Status PluginManager::SaveCore(const lldb::ProcessSP &process_sp, - const FileSpec &outfile, - lldb::SaveCoreStyle &core_style, - llvm::StringRef plugin_name) { - if (plugin_name.empty()) { + const lldb_private::CoreDumpOptions &options) { + Status error; + if (!options.GetOutputFile()) { +error.SetErrorString("No output file specified"); +return error; + } + clayborg wrote: You added `assert(process_sp)` in the object file plugins, but didn't check the process here. Add: ``` if (!process_sp) { error.SetErrorString("Invalid process"); return error; } ``` https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -6519,14 +6519,15 @@ struct page_object { }; bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp, - const FileSpec &outfile, - lldb::SaveCoreStyle &core_style, Status &error) { - if (!process_sp) -return false; - - // Default on macOS is to create a dirty-memory-only corefile. + const lldb_private::CoreDumpOptions &options, + Status &error) { + auto core_style = options.GetStyle(); if (core_style == SaveCoreStyle::eSaveCoreUnspecified) core_style = SaveCoreStyle::eSaveCoreDirtyOnly; + // The FileSpec and Process are already checked in PluginManager::SaveCore. + assert(options.GetOutputFile().has_value()); + const FileSpec outfile = options.GetOutputFile().value(); + assert(process_sp); clayborg wrote: move this up a line so the comment makes more sense. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)
@@ -229,6 +229,17 @@ bool ScriptedThread::CalculateStopInfo() { LLVM_PRETTY_FUNCTION, "Failed to get scripted thread stop info.", error, LLDBLog::Thread); + // If we're at a BreakpointSite, mark that we stopped there and jasonmolenda wrote: This comment was meant to be on ProcessGDBRemote.cpp where I removed a section of code for a thread that had no stop signal/reason, but is sitting at a BreakpointSite. The old comment on this: ``` // If a thread is stopped at a breakpoint site, set that as the stop // reason even if it hasn't executed the breakpoint instruction yet. // We will silently step over the breakpoint when we resume execution // and miss the fact that this thread hit the breakpoint. ``` That's the old stepping behavior. The new stepping behavior is if a thread stops at a BreakpointSite but has no signal/breakpoint hit reason, we call `Thread::SetThreadStoppedAtUnexecutedBP(pc)`. This is done at the top of `ProcessGDBRemote::SetThreadStopInfo` already if the thread stops at a BreakpointSite but hasn't hit it, so there's no need for this block to still be around. https://github.com/llvm/llvm-project/pull/96260 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] IRMemoryMap zero address mapping fix (PR #99045)
dlav-sc wrote: I connect to a riscv (rv64gv) machine, nothing special. Lldb can just allocate memory on remote target only if the target supports executing JIT-compiled code (`if (process_is_alive && process_sp->CanJIT())` on the line `68`), otherwise lldb falls through and starts finding suitable memory region for a mapping. The problem is that riscv targets currently don't support JIT-compiled code execution, but can only execute simple lldb expressions interpreting its IR, like for example ``` expr ``` or ``` expr *(type_z*)pz ``` If in the case above `pz == nullptr` and lldb have mapped zero address, then instead of the error we will get a valid result: ``` output: (type_z) $0 = { y = (dummy = 0) } ``` I take this example from `TestAnonymous.py`. Logs you have asked for: Without patch: ``` lldb < 23> send packet: $qMemoryRegionInfo:0#44 lldb < 28> read packet: $start:0;size:2aa000;#0b lldb IRMemoryMap::Malloc (23, 0x8, 0x3, eAllocationPolicyHostOnly) -> 0x0 lldb < 26> send packet: $qMemoryRegionInfo:1000#d5 lldb < 31> read packet: $start:1000;size:2a9000;#74 lldb IRMemoryMap::Malloc (524295, 0x8, 0x3, eAllocationPolicyHostOnly) -> 0x1000 ``` With patch: ``` lldb < 23> send packet: $qMemoryRegionInfo:0#44 lldb < 28> read packet: $start:0;size:2aa000;#0b lldb < 32> send packet: $qMemoryRegionInfo:2aa000#1c lldb < 81> read packet: $start:2aa000;size:1000;permissions:rx;flags:;name:2f726f6f742f612e6f7574;#fc lldb < 32> send packet: $qMemoryRegionInfo:2ab000#1d lldb < 80> read packet: $start:2ab000;size:1000;permissions:r;flags:;name:2f726f6f742f612e6f7574;#85 lldb < 32> send packet: $qMemoryRegionInfo:2ac000#1e lldb < 81> read packet: $start:2ac000;size:1000;permissions:rw;flags:;name:2f726f6f742f612e6f7574;#fd lldb < 32> send packet: $qMemoryRegionInfo:2ad000#1f lldb < 72> read packet: $start:2ad000;size:21000;permissions:rw;flags:;name:5b686561705d;#5a
[Lldb-commits] [lldb] [lldb] change .sbss section type to eSectionTypeZeroFill (PR #99044)
https://github.com/dlav-sc updated https://github.com/llvm/llvm-project/pull/99044 >From 2bca6288a3d7ce04191c28280d05d6255fc3019a Mon Sep 17 00:00:00 2001 From: Daniil Avdeev Date: Thu, 11 Jul 2024 14:09:04 + Subject: [PATCH] [lldb] SHT_NOBITS sections type Sections with SHT_NOBITS type should be recognized as eSectionTypeZeroFill. --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 4 1 file changed, 4 insertions(+) diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 51bd34e95c77d..30431b9097634 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -1713,6 +1713,10 @@ SectionType ObjectFileELF::GetSectionType(const ELFSectionHeaderInfo &H) const { if (H.sh_flags & SHF_EXECINSTR) return eSectionTypeCode; break; + case SHT_NOBITS: +if (H.sh_flags & SHF_ALLOC) + return eSectionTypeZeroFill; +break; case SHT_SYMTAB: return eSectionTypeELFSymbolTable; case SHT_DYNSYM: ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] change .sbss section type to eSectionTypeZeroFill (PR #99044)
https://github.com/dlav-sc updated https://github.com/llvm/llvm-project/pull/99044 >From 2b62658701e6a2c2cb651dc1a634c03bbb385f0d Mon Sep 17 00:00:00 2001 From: Daniil Avdeev Date: Thu, 11 Jul 2024 14:09:04 + Subject: [PATCH] [lldb] SHT_NOBITS sections type Sections with SHT_NOBITS type should be recognized as eSectionTypeZeroFill. --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 51bd34e95c77d..890db5c274814 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -1696,7 +1696,6 @@ static SectionType GetSectionTypeFromName(llvm::StringRef Name) { return llvm::StringSwitch(Name) .Case(".ARM.exidx", eSectionTypeARMexidx) .Case(".ARM.extab", eSectionTypeARMextab) - .Cases(".bss", ".tbss", eSectionTypeZeroFill) .Case(".ctf", eSectionTypeDebug) .Cases(".data", ".tdata", eSectionTypeData) .Case(".eh_frame", eSectionTypeEHFrame) @@ -1713,6 +1712,10 @@ SectionType ObjectFileELF::GetSectionType(const ELFSectionHeaderInfo &H) const { if (H.sh_flags & SHF_EXECINSTR) return eSectionTypeCode; break; + case SHT_NOBITS: +if (H.sh_flags & SHF_ALLOC) + return eSectionTypeZeroFill; +break; case SHT_SYMTAB: return eSectionTypeELFSymbolTable; case SHT_DYNSYM: ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] change .sbss section type to eSectionTypeZeroFill (PR #99044)
dlav-sc wrote: > I'm wondering if there's a more fundamental fix to be made here. Like perhaps > treating treating any allocatable SHT_NOBITS section as ZeroFill. > > Basically to add `case SHT_NOBITS: if (H.sh_flags & SHF_ALLOC) return > eSectionTypeZeroFill;` to `GetSectionType` (line 1716) Yes, thanks, works fine. https://github.com/llvm/llvm-project/pull/99044 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add RISCV target specific info in API tests (PR #99039)
https://github.com/dlav-sc updated https://github.com/llvm/llvm-project/pull/99039 >From e0e8ce7f438b17bfd1931021361ff5044e6e7ced Mon Sep 17 00:00:00 2001 From: Daniil Avdeev Date: Thu, 11 Jul 2024 11:08:43 + Subject: [PATCH] [lldb] add RISCV target specific info in API tests Add information about RISCV first register in python API testsuite, that is used to check register readability in tests. Fixed tests on RISCV target: TestBreakpointByFileColonLine.BreakpointByLineAndColumnTestCase TestAddressBreakpoints.AddressBreakpointTestCase TestBreakpointAutoContinue.BreakpointAutoContinue TestInterruptBacktrace.TestInterruptingBacktrace TestBadAddressBreakpoints.BadAddressBreakpointTestCase TestScriptedResolver.TestScriptedResolver TestStopHookScripted.TestStopHooks TestBreakpointConditions.BreakpointConditionsTestCase TestLocalVariables.LocalVariablesTestCase TestFindLineEntry.FindLineEntry TestScriptedResolver.TestScriptedResolver TestInlineSourceFiles.InlineSourceFilesTestCase TestModuleAndSection.ModuleAndSectionAPIsTestCase TestFrameVar.TestFrameVar TestInferiorAssert.AssertingInferiorTestCase TestInferiorCrashing.CrashingInferiorTestCase TestInferiorCrashingStep.CrashingInferiorStepTestCase TestRegistersIterator.RegistersIteratorTestCase TestCoroutineHandle.TestCoroutineHandle TestWithLimitDebugInfo.TestWithLimitDebugInfo TestLLDBIterator.LLDBIteratorTestCase TestMemoryWrite.MemoryWriteTestCase TestNestedTemplate.NestedTemplateTestCase TestParrayVrsCharArrayChild.TestParrayVrsCharArrayChild TestRecursiveInferior.CrashingRecursiveInferiorTestCase TestRecursiveInferiorStep.CrashingRecursiveInferiorStepTestCase TestRunLocker.TestRunLocker TestSampleTest.RenameThisSampleTestTestCase TestUniqueTypes3.UniqueTypesTestCase3 TestPrintStackTraces.ThreadsStackTracesTestCase TestUnicodeSymbols.TestUnicodeSymbols TestUnusedInlinedParameters.TestUnusedInlinedParameters TestValueVarUpdate.ValueVarUpdateTestCase TestPtrRef2Typedef.PtrRef2TypedefTestCase TestDataFormatterStdIterator.StdIteratorDataFormatterTestCase TestDataFormatterStdString.StdStringDataFormatterTestCase TestDataFormatterStdVBool.StdVBoolDataFormatterTestCase --- lldb/packages/Python/lldbsuite/test/lldbplatformutil.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py index 818fdf0e6b5c5..b7e6f240f59f6 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py @@ -34,6 +34,8 @@ def check_first_register_readable(test_case): test_case.expect("register read r0", substrs=["r0 = 0x"]) elif arch in ["powerpc64le"]: test_case.expect("register read r0", substrs=["r0 = 0x"]) +elif re.match("^rv(32|64)", arch): +test_case.expect("register read zero", substrs=["zero = 0x"]) else: # TODO: Add check for other architectures test_case.fail( ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add RISCV target specific info in API tests (PR #99039)
@@ -34,6 +34,8 @@ def check_first_register_readable(test_case): test_case.expect("register read r0", substrs=["r0 = 0x"]) elif arch in ["powerpc64le"]: test_case.expect("register read r0", substrs=["r0 = 0x"]) +elif arch in ["rv64gc"]: dlav-sc wrote: I have finally decided to add simple regexp, so it's going to work with any riscv target, not only `rv64gc`. https://github.com/llvm/llvm-project/pull/99039 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][RISCV] function calls support in lldb expressions (PR #99336)
https://github.com/dlav-sc updated https://github.com/llvm/llvm-project/pull/99336 >From c35ab331df2bc76a32d36a51ecb020ea2c13ff39 Mon Sep 17 00:00:00 2001 From: Daniil Avdeev Date: Thu, 11 Jul 2024 11:21:36 + Subject: [PATCH 1/5] [lldb][RISCV] add jitted function calls to ABI Function calls support in LLDB expressions for RISCV: 1 of 5 Augments corresponding functionality to RISCV ABI, which allows to jit lldb expressions and thus make function calls inside them. Only function calls with integer and void function arguments and return value are supported. --- .../Plugins/ABI/RISCV/ABISysV_riscv.cpp | 89 +-- lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.h | 3 + 2 files changed, 85 insertions(+), 7 deletions(-) diff --git a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp index 6395f5bb5bd9b..f3edee1dd6dc1 100644 --- a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp +++ b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp @@ -10,7 +10,9 @@ #include #include +#include +#include "llvm/ADT/STLExtras.h" #include "llvm/IR/DerivedTypes.h" #include "lldb/Core/PluginManager.h" @@ -19,6 +21,7 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/RegisterValue.h" #define DEFINE_REG_NAME(reg_num) ConstString(#reg_num).GetCString() @@ -163,11 +166,83 @@ TotalArgsSizeInWords(bool is_rv64, return total_size; } +static bool UpdateRegister(RegisterContext *reg_ctx, + const lldb::RegisterKind reg_kind, + const uint32_t reg_num, const addr_t value) { + Log *log = GetLog(LLDBLog::Expressions); + + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(reg_kind, reg_num); + + LLDB_LOG(log, "Writing %s: 0x%" PRIx64, reg_info->name, + static_cast(value)); + if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, value)) { +LLDB_LOG(log, "Writing %s: failed", reg_info->name); +return false; + } + return true; +} + +static void LogInitInfo(Log *log, const Thread &thread, addr_t sp, +addr_t func_addr, addr_t return_addr, +const llvm::ArrayRef args) { + assert(log); + std::stringstream ss; + ss << "ABISysV_riscv::PrepareTrivialCall" + << " (tid = 0x%" << std::hex << thread.GetID() << ", sp = 0x%" << sp + << ", func_addr = 0x%" << func_addr << ", return_addr = 0x%" + << return_addr; + + for (auto &&[idx, arg] : enumerate(args)) +ss << ", arg" << std::dec << idx << " = 0x%" << std::hex << arg; + ss << ")"; + log->PutString(ss.str()); +} + bool ABISysV_riscv::PrepareTrivialCall(Thread &thread, addr_t sp, addr_t func_addr, addr_t return_addr, llvm::ArrayRef args) const { - // TODO: Implement - return false; + Log *log = GetLog(LLDBLog::Expressions); + if (log) +LogInitInfo(log, thread, sp, func_addr, return_addr, args); + + const auto reg_ctx_sp = thread.GetRegisterContext(); + if (!reg_ctx_sp) { +LLDB_LOG(log, "Failed to get RegisterContext"); +return false; + } + + if (args.size() > s_regs_for_args_count) { +LLDB_LOG(log, "Function has %lu arguments, but only %lu are allowed!", + args.size(), s_regs_for_args_count); +return false; + } + + // Write arguments to registers + for (auto &&[idx, arg] : enumerate(args)) { +const RegisterInfo *reg_info = reg_ctx_sp->GetRegisterInfo( +eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + idx); +LLDB_LOG(log, "About to write arg%lu (0x%" PRIx64 ") into %s", idx, arg, + reg_info->name); + +if (!reg_ctx_sp->WriteRegisterFromUnsigned(reg_info, arg)) { + LLDB_LOG(log, "Failed to write arg%lu (0x%" PRIx64 ") into %s", idx, arg, + reg_info->name); + return false; +} + } + + if (!UpdateRegister(reg_ctx_sp.get(), eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_PC, func_addr)) +return false; + if (!UpdateRegister(reg_ctx_sp.get(), eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_SP, sp)) +return false; + if (!UpdateRegister(reg_ctx_sp.get(), eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_RA, return_addr)) +return false; + + LLDB_LOG(log, "ABISysV_riscv::%s: success", __func__); + return true; } bool ABISysV_riscv::PrepareTrivialCall( @@ -221,14 +296,14 @@ bool ABISysV_riscv::PrepareTrivialCall( assert(prototype.getFunctionNumParams() == args.size()); const size_t num_args = args.size(); - const size_t regs_for_args_count = 8U; const size_t num_args_in_regs = - num_args > regs_for_args_count ? regs_for_args_count : num_args; + num_args > s_regs_for_args_count ? s_regs_for_args_count : num_args; // Number of arguments passed on stack. size_t args_size = TotalArgsSizeInWor
[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/96260 >From 9b541e6a035635e26c6a24eca022de8552fa4c17 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Thu, 20 Jun 2024 17:53:17 -0700 Subject: [PATCH 1/7] [lldb] Change lldb's breakpoint handling behavior lldb today has two rules: When a thread stops at a BreakpointSite, we set the thread's StopReason to be "breakpoint hit" (regardless if we've actually hit the breakpoint, or if we've merely stopped *at* the breakpoint instruction/point and haven't tripped it yet). And second, when resuming a process, any thread sitting at a BreakpointSite is silently stepped over the BreakpointSite -- because we've already flagged the breakpoint hit when we stopped there originally. In this patch, I change lldb to only set a thread's stop reason to breakpoint-hit when we've actually executed the instruction/triggered the breakpoint. When we resume, we only silently step past a BreakpointSite that we've registered as hit. We preserve this state across inferior function calls that the user may do while stopped, etc. Also, when a user adds a new breakpoint at $pc while stopped, or changes $pc to be the address of a BreakpointSite, we will silently step past that breakpoint when the process resumes. This is purely a UX call, I don't think there's any person who wants to set a breakpoint at $pc and then hit it immediately on resuming. One non-intuitive UX from this change, but I'm convinced it is necessary: If you're stopped at a BreakpointSite that has not yet executed, you `stepi`, you will hit the breakpoint and the pc will not yet advance. This thread has not completed its stepi, and the thread plan is still on the stack. If you then `continue` the thread, lldb will now stop and say, "instruction step completed", one instruction past the BreakpointSite. You can continue a second time to resume execution. I discussed this with Jim, and trying to paper over this behavior will lead to more complicated scenarios behaving non-intuitively. And mostly it's the testsuite that was trying to instruction step past a breakpoint and getting thrown off -- and I changed those tests to expect the new behavior. The bugs driving this change are all from lldb dropping the real stop reason for a thread and setting it to breakpoint-hit when that was not the case. Jim hit one where we have an aarch64 watchpoint that triggers one instruction before a BreakpointSite. On this arch we are notified of the watchpoint hit after the instruction has been unrolled -- we disable the watchpoint, instruction step, re-enable the watchpoint and collect the new value. But now we're on a BreakpointSite so the watchpoint-hit stop reason is lost. Another was reported by ZequanWu in https://discourse.llvm.org/t/lldb-unable-to-break-at-start/78282 we attach to/launch a process with the pc at a BreakpointSite and misbehave. Caroline Tice mentioned it is also a problem they've had with putting a breakpoint on _dl_debug_state. The change to each Process plugin that does execution control is that 1. If we've stopped at a BreakpointSite (whether we hit it or not), we call Thread::SetThreadStoppedAtBreakpointSite(pc) to record the state at the point when the thread stopped. (so we can detect newly-added breakpoints, or when the pc is changed to an instruction that is a BreakpointSite) 2. When we have actually hit a breakpoint, and it is enabled for this thread, we call Thread::SetThreadHitBreakpointAtAddr(pc) so we know that it should be silently stepped past when we resume execution. When resuming, we silently step over a breakpoint if we've hit it, or if it is newly added (or the pc was changed to an existing BreakpointSite). The biggest set of changes is to StopInfoMachException where we translate a Mach Exception into a stop reason. The Mach exception codes differ in a few places depending on the target (unambiguously), and I didn't want to duplicate the new code for each target so I've tested what mach exceptions we get for each action on each target, and reorganized StopInfoMachException::CreateStopReasonWithMachException to document these possible values, and handle them without specializing based on the target arch. rdar://123942164 --- lldb/include/lldb/Target/Thread.h | 29 ++ .../Process/Utility/StopInfoMachException.cpp | 296 +++--- .../Process/Windows/Common/ProcessWindows.cpp | 16 +- .../Process/gdb-remote/ProcessGDBRemote.cpp | 118 +++ .../Process/scripted/ScriptedThread.cpp | 9 + lldb/source/Target/Thread.cpp | 17 +- .../TestConsecutiveBreakpoints.py | 26 +- .../TestStepOverBreakpoint.py | 6 +- 8 files changed, 235 insertions(+), 282 deletions(-) diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index c17bddf4d98b8..1e1aead896018 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread
[Lldb-commits] [lldb] [lldb] SHT_NOBITS sections type (PR #99044)
https://github.com/dlav-sc edited https://github.com/llvm/llvm-project/pull/99044 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] SHT_NOBITS sections type (PR #99044)
dlav-sc wrote: I have also removed `.Cases(".bss", ".tbss", eSectionTypeZeroFill)`. To be honest, I'm not sure about that. .bss and .tbss have SHT_NOBITS type and SHF_ALLOC flag by [Linux Specification](https://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/specialsections.html), but anyway I have doubts. https://github.com/llvm/llvm-project/pull/99044 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)
https://github.com/jasonmolenda edited https://github.com/llvm/llvm-project/pull/96260 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -355,11 +355,10 @@ size_t ObjectFilePECOFF::GetModuleSpecifications( } bool ObjectFilePECOFF::SaveCore(const lldb::ProcessSP &process_sp, -const lldb_private::FileSpec &outfile, -lldb::SaveCoreStyle &core_style, +const lldb_private::CoreDumpOptions &options, lldb_private::Status &error) { - core_style = eSaveCoreFull; - return SaveMiniDump(process_sp, outfile, error); + assert(options.GetOutputFile().has_value()); clayborg wrote: Add same comment and add `assert(process_sp);` https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,69 @@ +//===-- SBCoreDumpOptions.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBCOREDUMPOPTIONS_H +#define LLDB_API_SBCOREDUMPOPTIONS_H + +#include "lldb/API/SBDefines.h" +#include "lldb/Symbol/CoreDumpOptions.h" + +namespace lldb { + +class LLDB_API SBCoreDumpOptions { clayborg wrote: Should we change the name to `SBSaveCoreOptions`? `SBCoreDumpOptions` seems like they would be used to dump a core dump to the terminal? https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,44 @@ +//===-- CoreDumpOptions.h ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H +#define LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H + +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" + +#include +#include + +namespace lldb_private { + +class CoreDumpOptions { clayborg wrote: If we rename `SBCoreDumpOptions` to `SBSaveCoreOptions`, this should become `SaveCoreOptions` https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,52 @@ +//===-- CoreDumpOptions.cpp -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Symbol/CoreDumpOptions.h" +#include "lldb/Core/PluginManager.h" + +using namespace lldb; +using namespace lldb_private; + +Status CoreDumpOptions::SetPluginName(const char *name) { + Status error; + if (!name || !name[0]) { +m_plugin_name = std::nullopt; + } clayborg wrote: remove braces from single statement `if` per llvm coding guidelines, or add a `return error;` inside the `if` statement. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang][AST] fix ast-print of extern with >=2 declarators, fixed, fixed (PR #98795)
lhames wrote: > > Regarding the orc-rt test failures: I tried building one of the failing > > objects and I can't reproduce the failure. Perhaps, because the tests are > > run on Windows and I'm running on Linux? It would be very helpful if > > @Prabhuk could run the failing command on a debug build. > > CC @lhames This is a frontend crash, rather than a JIT one, and I don't have access to a Windows dev machine so I'm not well placed to look into this. https://github.com/llvm/llvm-project/pull/98795 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits