[Lldb-commits] [lldb] [lldb-dap] Fix build failure on Windows. (PR #125156)
https://github.com/dzhidzhoev approved this pull request. https://github.com/llvm/llvm-project/pull/125156 ___ 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 for Makefile.rules (PR #124758)
kper wrote: > Only those with [write > access](https://docs.github.com/articles/what-are-the-different-access-permissions) > to this repository can merge pull requests. @JDevlieghere Thank you, I think that one of you needs to merge it. Next to this message is also a "Update branch" button but I am not sure whether I will lose the approval if I rebase. https://github.com/llvm/llvm-project/pull/124758 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add Lexer (with tests) for DIL (Data Inspection Language). (PR #123521)
https://github.com/cmtice updated https://github.com/llvm/llvm-project/pull/123521 >From 468f73f8539dcb8addf8ed9618d9eb797dabbb01 Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Sun, 19 Jan 2025 09:15:34 -0800 Subject: [PATCH 1/4] [LLDB] Add Lexer (with tests) for DIL (Data Inspection Language). This adds the basic lexer, with unittests, for the Data Inspection Language (DIL) -- see https://discourse.llvm.org/t/rfc-data-inspection-language/69893 This version of the lexer only handles local variables and namespaces, and is designed to work with https://github.com/llvm/llvm-project/pull/120971. --- lldb/include/lldb/ValueObject/DILLexer.h | 156 ++ lldb/source/ValueObject/DILLexer.cpp | 205 +++ lldb/unittests/ValueObject/CMakeLists.txt| 1 + lldb/unittests/ValueObject/DILLexerTests.cpp | 193 + 4 files changed, 555 insertions(+) create mode 100644 lldb/include/lldb/ValueObject/DILLexer.h create mode 100644 lldb/source/ValueObject/DILLexer.cpp create mode 100644 lldb/unittests/ValueObject/DILLexerTests.cpp diff --git a/lldb/include/lldb/ValueObject/DILLexer.h b/lldb/include/lldb/ValueObject/DILLexer.h new file mode 100644 index 00..45c506b2f4106d --- /dev/null +++ b/lldb/include/lldb/ValueObject/DILLexer.h @@ -0,0 +1,156 @@ +//===-- DILLexer.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_VALUEOBJECT_DILLEXER_H_ +#define LLDB_VALUEOBJECT_DILLEXER_H_ + +#include "llvm/ADT/StringRef.h" +#include +#include +#include +#include +#include + +namespace lldb_private { + +namespace dil { + +enum class TokenKind { + coloncolon, + eof, + identifier, + invalid, + kw_namespace, + l_paren, + none, + r_paren, + unknown, +}; + +/// Class defining the tokens generated by the DIL lexer and used by the +/// DIL parser. +class DILToken { +public: + DILToken(dil::TokenKind kind, std::string spelling, uint32_t start) + : m_kind(kind), m_spelling(spelling), m_start_pos(start) {} + + DILToken() : m_kind(dil::TokenKind::none), m_spelling(""), m_start_pos(0) {} + + void setKind(dil::TokenKind kind) { m_kind = kind; } + dil::TokenKind getKind() const { return m_kind; } + + std::string getSpelling() const { return m_spelling; } + + uint32_t getLength() const { return m_spelling.size(); } + + bool is(dil::TokenKind kind) const { return m_kind == kind; } + + bool isNot(dil::TokenKind kind) const { return m_kind != kind; } + + bool isOneOf(dil::TokenKind kind1, dil::TokenKind kind2) const { +return is(kind1) || is(kind2); + } + + template bool isOneOf(dil::TokenKind kind, Ts... Ks) const { +return is(kind) || isOneOf(Ks...); + } + + uint32_t getLocation() const { return m_start_pos; } + + void setValues(dil::TokenKind kind, std::string spelling, uint32_t start) { +m_kind = kind; +m_spelling = spelling; +m_start_pos = start; + } + + static const std::string getTokenName(dil::TokenKind kind); + +private: + dil::TokenKind m_kind; + std::string m_spelling; + uint32_t m_start_pos; // within entire expression string +}; + +/// Class for doing the simple lexing required by DIL. +class DILLexer { +public: + DILLexer(llvm::StringRef dil_expr) : m_expr(dil_expr.str()) { +m_cur_pos = m_expr.begin(); +// Use UINT_MAX to indicate invalid/uninitialized value. +m_tokens_idx = UINT_MAX; + } + + bool Lex(DILToken &result, bool look_ahead = false); + + bool Is_Word(std::string::iterator start, uint32_t &length); + + uint32_t GetLocation() { return m_cur_pos - m_expr.begin(); } + + /// Update 'result' with the other paremeter values, create a + /// duplicate token, and push the duplicate token onto the vector of + /// lexed tokens. + void UpdateLexedTokens(DILToken &result, dil::TokenKind tok_kind, + std::string tok_str, uint32_t tok_pos); + + /// Return the lexed token N+1 positions ahead of the 'current' token + /// being handled by the DIL parser. + const DILToken &LookAhead(uint32_t N); + + const DILToken &AcceptLookAhead(uint32_t N); + + /// Return the index for the 'current' token being handled by the DIL parser. + uint32_t GetCurrentTokenIdx() { return m_tokens_idx; } + + /// Return the current token to be handled by the DIL parser. + DILToken &GetCurrentToken() { return m_lexed_tokens[m_tokens_idx]; } + + /// Update the index for the 'current' token, to point to the next lexed + /// token. + bool IncrementTokenIdx() { +if (m_tokens_idx >= m_lexed_tokens.size() - 1) + return false; + +m_tokens_idx++; +return true; + } + + /// Set the index for the 'current' token (to be handled by the parser) + /// to a par
[Lldb-commits] [lldb] [LLDB] Add Lexer (with tests) for DIL (Data Inspection Language). (PR #123521)
cmtice wrote: I think I have addressed/fixed all the latest review comments. Please take another look now. https://github.com/llvm/llvm-project/pull/123521 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use llvm::Error instead of CommandReturnObject for error reporting (PR #125125)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/125125 >From 24ddc550e3ee61b863cbaea05ff49981bc20f7ad Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 30 Jan 2025 14:25:16 -0800 Subject: [PATCH 1/3] [lldb] Use llvm::Error instead of CommandReturnObject for error reporting Use `llvm::Error` instead of `CommandReturnObject` for error reporting. The command return objects were populated with errors but never displayed. With this patch they're at least logged. --- lldb/include/lldb/Interpreter/Options.h | 4 +- lldb/source/Interpreter/CommandAlias.cpp | 49 +-- lldb/source/Interpreter/CommandObject.cpp | 2 +- lldb/source/Interpreter/Options.cpp | 87 ++- .../DarwinLog/StructuredDataDarwinLog.cpp | 9 +- 5 files changed, 77 insertions(+), 74 deletions(-) diff --git a/lldb/include/lldb/Interpreter/Options.h b/lldb/include/lldb/Interpreter/Options.h index 9a6a17c2793fa4c..864bda6f24c8cc5 100644 --- a/lldb/include/lldb/Interpreter/Options.h +++ b/lldb/include/lldb/Interpreter/Options.h @@ -76,12 +76,12 @@ class Options { // This gets passed the short option as an integer... void OptionSeen(int short_option); - bool VerifyOptions(CommandReturnObject &result); + llvm::Error VerifyOptions(); // Verify that the options given are in the options table and can be used // together, but there may be some required options that are missing (used to // verify options that get folded into command aliases). - bool VerifyPartialOptions(CommandReturnObject &result); + llvm::Error VerifyPartialOptions(); void OutputFormattedUsageText(Stream &strm, const OptionDefinition &option_def, diff --git a/lldb/source/Interpreter/CommandAlias.cpp b/lldb/source/Interpreter/CommandAlias.cpp index c5971b52f837faf..ac0c7a3279e64b9 100644 --- a/lldb/source/Interpreter/CommandAlias.cpp +++ b/lldb/source/Interpreter/CommandAlias.cpp @@ -10,6 +10,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/FormatAdapters.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandObject.h" @@ -20,20 +21,17 @@ using namespace lldb; using namespace lldb_private; -static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp, +static llvm::Error +ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp, llvm::StringRef options_args, OptionArgVectorSP &option_arg_vector_sp) { - bool success = true; OptionArgVector *option_arg_vector = option_arg_vector_sp.get(); if (options_args.size() < 1) -return true; +return llvm::Error::success(); Args args(options_args); std::string options_string(options_args); - // TODO: Find a way to propagate errors in this CommandReturnObject up the - // stack. - CommandReturnObject result(false); // Check to see if the command being aliased can take any command options. Options *options = cmd_obj_sp->GetOptions(); if (options) { @@ -45,34 +43,30 @@ static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp, llvm::Expected args_or = options->ParseAlias(args, option_arg_vector, options_string); -if (!args_or) { - result.AppendError(toString(args_or.takeError())); - result.AppendError("Unable to create requested alias.\n"); - return false; -} +if (!args_or) + return llvm::createStringError( + llvm::formatv("unable to create alias: {0}", +llvm::fmt_consume(args_or.takeError(; args = std::move(*args_or); -options->VerifyPartialOptions(result); -if (!result.Succeeded() && -result.GetStatus() != lldb::eReturnStatusStarted) { - result.AppendError("Unable to create requested alias.\n"); - return false; -} +if (llvm::Error error = options->VerifyPartialOptions()) + return error; } if (!options_string.empty()) { -if (cmd_obj_sp->WantsRawCommandString()) - option_arg_vector->emplace_back(CommandInterpreter::g_argument, - -1, options_string); -else { +if (cmd_obj_sp->WantsRawCommandString()) { + option_arg_vector->emplace_back(CommandInterpreter::g_argument, -1, + options_string); +} else { for (auto &entry : args.entries()) { if (!entry.ref().empty()) - option_arg_vector->emplace_back(std::string(CommandInterpreter::g_argument), -1, + option_arg_vector->emplace_back( + std::string(CommandInterpreter::g_argument), -1, std::string(entry.ref())); } } } - return success; + return llvm::Error::success(); } CommandAlias::CommandAlias(CommandInterpreter &interpreter, @@ -85,10 +79,15 @@ CommandAlias::CommandAlias(CommandIn
[Lldb-commits] [lldb] [LLDB-DAP] SBDebugger don't prefix title on progress updates (PR #124648)
https://github.com/Jlalond updated https://github.com/llvm/llvm-project/pull/124648 >From 55e22921d0b1b5088540ffa29a6e67a7816949cf Mon Sep 17 00:00:00 2001 From: Jacob Lalonde Date: Mon, 27 Jan 2025 13:41:58 -0800 Subject: [PATCH 1/3] Only include title on the first message --- lldb/include/lldb/Core/DebuggerEvents.h | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lldb/include/lldb/Core/DebuggerEvents.h b/lldb/include/lldb/Core/DebuggerEvents.h index 49a4ecf8e537e3..52e4f77d7637d3 100644 --- a/lldb/include/lldb/Core/DebuggerEvents.h +++ b/lldb/include/lldb/Core/DebuggerEvents.h @@ -44,12 +44,15 @@ class ProgressEventData : public EventData { uint64_t GetCompleted() const { return m_completed; } uint64_t GetTotal() const { return m_total; } std::string GetMessage() const { -std::string message = m_title; -if (!m_details.empty()) { - message.append(": "); - message.append(m_details); -} -return message; +if (m_completed == 0) { + std::string message = m_title; + if (!m_details.empty()) { +message.append(": "); +message.append(m_details); + } + return message; +} else + return !m_details.empty() ? m_details : std::string(); } const std::string &GetTitle() const { return m_title; } const std::string &GetDetails() const { return m_details; } >From bea28f7aa583a18443ed42c2046980f2eb7406fb Mon Sep 17 00:00:00 2001 From: Jacob Lalonde Date: Mon, 27 Jan 2025 14:48:01 -0800 Subject: [PATCH 2/3] Add comment explaining if and add a test --- lldb/include/lldb/Core/DebuggerEvents.h | 1 + lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py | 5 + 2 files changed, 6 insertions(+) diff --git a/lldb/include/lldb/Core/DebuggerEvents.h b/lldb/include/lldb/Core/DebuggerEvents.h index 52e4f77d7637d3..ca06ee835fde38 100644 --- a/lldb/include/lldb/Core/DebuggerEvents.h +++ b/lldb/include/lldb/Core/DebuggerEvents.h @@ -44,6 +44,7 @@ class ProgressEventData : public EventData { uint64_t GetCompleted() const { return m_completed; } uint64_t GetTotal() const { return m_total; } std::string GetMessage() const { +// Only put the title in the message of the progress create event. if (m_completed == 0) { std::string message = m_title; if (!m_details.empty()) { diff --git a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py index 36c0cef9c47143..945c3f7633364c 100755 --- a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py +++ b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py @@ -41,8 +41,13 @@ def test_output(self): for event in self.dap_server.progress_events: event_type = event["event"] if "progressStart" in event_type: +title = event["body"]["title"] +self.assertIn("Progress tester", title) start_found = True if "progressUpdate" in event_type: +message = event["body"]["message"] +print(f"Progress update: {message}") +self.assertNotIn("Progres tester", message) update_found = True self.assertTrue(start_found) >From ca2f7e3d27006e4ef8f10e233fe8ebb910d15fc6 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde Date: Thu, 30 Jan 2025 10:04:04 -0800 Subject: [PATCH 3/3] Migrate to structured data Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D68927453 --- lldb/include/lldb/Core/DebuggerEvents.h | 16 +++- lldb/tools/lldb-dap/lldb-dap.cpp| 54 + 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/lldb/include/lldb/Core/DebuggerEvents.h b/lldb/include/lldb/Core/DebuggerEvents.h index ca06ee835fde38..49a4ecf8e537e3 100644 --- a/lldb/include/lldb/Core/DebuggerEvents.h +++ b/lldb/include/lldb/Core/DebuggerEvents.h @@ -44,16 +44,12 @@ class ProgressEventData : public EventData { uint64_t GetCompleted() const { return m_completed; } uint64_t GetTotal() const { return m_total; } std::string GetMessage() const { -// Only put the title in the message of the progress create event. -if (m_completed == 0) { - std::string message = m_title; - if (!m_details.empty()) { -message.append(": "); -message.append(m_details); - } - return message; -} else - return !m_details.empty() ? m_details : std::string(); +std::string message = m_title; +if (!m_details.empty()) { + message.append(": "); + message.append(m_details); +} +return message; } const std::string &GetTitle() const { return m_title; } const std::string &GetDetails() const { return m_details; } diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp index 6b12569d90a831..be9d71a3bd6afa 100644 --- a/lldb/
[Lldb-commits] [lldb] [LLDB-DAP] SBDebugger don't prefix title on progress updates (PR #124648)
@@ -411,6 +412,30 @@ void SendStdOutStdErr(DAP &dap, lldb::SBProcess &process) { dap.SendOutput(OutputType::Stderr, llvm::StringRef(buffer, count)); } +static std::string GetStringFromStructuredData(lldb::SBStructuredData &data, Jlalond wrote: @JDevlieghere is there a less clunky way to do this? I know we want to handle string creation on the side of lldb-dap so we get some wins not needing to constify, but I don't like my code. https://github.com/llvm/llvm-project/pull/124648 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb] Change lldb's breakpoint detection behavior [WIP] (PR #105594)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/105594 >From 56ca564185bdceea25162a1ce3b1e8c8fa2641e2 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Fri, 19 Jul 2024 17:26:13 -0700 Subject: [PATCH 1/9] [lldb] Change lldb's breakpoint handling behavior (#96260) 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 that has not been executed yet, we will call Thread::SetThreadStoppedAtUnexecutedBP(pc) to record that. When the thread resumes, if the pc is still at the same site, we will continue, hit the breakpoint, and stop again. 2. When we've actually hit a breakpoint (enabled for this thread or not), the Process plugin should call Thread::SetThreadHitBreakpointSite(). When we go to resume the thread, we will push a step-over-breakpoint ThreadPlan before resuming. 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 | 24 ++ .../Process/Utility/StopInfoMachException.cpp | 322 -- .../Process/Windows/Common/ProcessWindows.cpp | 32 +- .../Process/gdb-remote/ProcessGDBRemote.cpp | 93 ++--- .../Process/scripted/ScriptedThread.cpp | 11 + lldb/source/Target/StopInfo.cpp | 2 + lldb/source/Target/Thread.cpp | 15 +- .../TestConsecutiveBreakpoints.py | 26 +- .../TestStepOverBreakpoint.py | 6 +- 9 files changed, 266 insertions(+), 265 deletions(-) diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index 38b65b2bc58490..22d452c7b4b8a3 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -131,6 +131,7 @@ class Thread : public std::enable_shared_from_this, register
[Lldb-commits] [lldb] [lldb] Add RISCV for Makefile.rules (PR #124758)
JDevlieghere wrote: @kper Please let us know if you need one of us to press the merge button for you. https://github.com/llvm/llvm-project/pull/124758 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Partially reverting OutputRedirector changes. (PR #125136)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: John Harrison (ashgti) Changes I just noticed with these changes lldb-dap was using 200% of my CPU and root causing the issue it seems that lldb_private::Pipe::Read() (without a timeout) is using a timeout of `std::chrono::microseconds::zero()` which ends up setting the SelectHelper timeout to `now + 0` (see https://github.com/llvm/llvm-project/blob/7ceef1b1824073fcfd4724539f5942442da1a9c2/lldb/source/Host/posix/PipePosix.cpp#L314 and https://github.com/llvm/llvm-project/blob/7ceef1b1824073fcfd4724539f5942442da1a9c2/lldb/source/Utility/SelectHelper.cpp#L46) which causes SelectHelper to return immediately with a timeout error. As a result the `lldb_dap::OutputRedirector::RedirectTo()` to turn into a busy loop. Additionally, the 'read' call is waiting until the output buffer is full before returning, which prevents any partial output (see https://github.com/llvm/llvm-project/blob/7ceef1b1824073fcfd4724539f5942442da1a9c2/lldb/source/Host/posix/PipePosix.cpp#L325C9-L326C17). This is not the desired behavior for lldb-dap. Instead we want a write to the FD to result in a callback to send the DAP Output event, which mean we want partial output. To mitigate this, I'm reverting the reading operation to the previous behavior before 873426bea3dd67d80dd10650e64e91c69796614f but keeping the refactored structure and thread management. --- Full diff: https://github.com/llvm/llvm-project/pull/125136.diff 2 Files Affected: - (modified) lldb/tools/lldb-dap/OutputRedirector.cpp (+42-24) - (modified) lldb/tools/lldb-dap/OutputRedirector.h (+4-2) ``diff diff --git a/lldb/tools/lldb-dap/OutputRedirector.cpp b/lldb/tools/lldb-dap/OutputRedirector.cpp index 8fcbcfec99c4431..7935e17a653bec3 100644 --- a/lldb/tools/lldb-dap/OutputRedirector.cpp +++ b/lldb/tools/lldb-dap/OutputRedirector.cpp @@ -6,6 +6,9 @@ // //===--===/ +#include "OutputRedirector.h" +#include "DAP.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include #if defined(_WIN32) @@ -15,45 +18,59 @@ #include #endif -#include "DAP.h" -#include "OutputRedirector.h" -#include "llvm/ADT/StringRef.h" - using lldb_private::Pipe; -using lldb_private::Status; using llvm::createStringError; using llvm::Error; using llvm::Expected; +using llvm::inconvertibleErrorCode; using llvm::StringRef; namespace lldb_dap { +int OutputRedirector::kInvalidDescriptor = -1; + +OutputRedirector::OutputRedirector() : m_fd(kInvalidDescriptor) {} + Expected OutputRedirector::GetWriteFileDescriptor() { - if (!m_pipe.CanWrite()) + if (m_fd == kInvalidDescriptor) return createStringError(std::errc::bad_file_descriptor, "write handle is not open for writing"); - return m_pipe.GetWriteFileDescriptor(); + return m_fd; } Error OutputRedirector::RedirectTo(std::function callback) { - Status status = m_pipe.CreateNew(/*child_process_inherit=*/false); - if (status.Fail()) -return status.takeError(); + assert(m_fd == kInvalidDescriptor && "Output readirector already started."); + int new_fd[2]; - m_forwarder = std::thread([this, callback]() { -char buffer[OutputBufferSize]; -while (m_pipe.CanRead() && !m_stopped) { - size_t bytes_read; - Status status = m_pipe.Read(&buffer, sizeof(buffer), bytes_read); - if (status.Fail()) -continue; +#if defined(_WIN32) + if (::_pipe(new_fd, OutputBufferSize, O_TEXT) == -1) { +#else + if (::pipe(new_fd) == -1) { +#endif +int error = errno; +return createStringError(inconvertibleErrorCode(), + "Couldn't create new pipe %s", strerror(error)); + } - // EOF detected - if (bytes_read == 0 || m_stopped) + int read_fd = new_fd[0]; + m_fd = new_fd[1]; + m_forwarder = std::thread([this, callback, read_fd]() { +char buffer[OutputBufferSize]; +while (!m_stopped) { + ssize_t bytes_count = ::read(read_fd, &buffer, sizeof(buffer)); + // EOF detected. + if (bytes_count == 0) +break; + if (bytes_count == -1) { +// Skip non-fatal errors. +if (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK) + continue; break; + } - callback(StringRef(buffer, bytes_read)); + callback(StringRef(buffer, bytes_count)); } +::close(read_fd); }); return Error::success(); @@ -62,14 +79,15 @@ Error OutputRedirector::RedirectTo(std::function callback) { void OutputRedirector::Stop() { m_stopped = true; - if (m_pipe.CanWrite()) { + if (m_fd != kInvalidDescriptor) { +int fd = m_fd; +m_fd = kInvalidDescriptor; // Closing the pipe may not be sufficient to wake up the thread in case the // write descriptor is duplicated (to stdout/err or to another process). // Write a null byte to ensure the read call returns. char buf[] = "\0"; -siz
[Lldb-commits] [lldb] [lldb] Store the command in the CommandReturnObject (PR #125132)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/125132 None >From 24ddc550e3ee61b863cbaea05ff49981bc20f7ad Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 30 Jan 2025 14:25:16 -0800 Subject: [PATCH 1/4] [lldb] Use llvm::Error instead of CommandReturnObject for error reporting Use `llvm::Error` instead of `CommandReturnObject` for error reporting. The command return objects were populated with errors but never displayed. With this patch they're at least logged. --- lldb/include/lldb/Interpreter/Options.h | 4 +- lldb/source/Interpreter/CommandAlias.cpp | 49 +-- lldb/source/Interpreter/CommandObject.cpp | 2 +- lldb/source/Interpreter/Options.cpp | 87 ++- .../DarwinLog/StructuredDataDarwinLog.cpp | 9 +- 5 files changed, 77 insertions(+), 74 deletions(-) diff --git a/lldb/include/lldb/Interpreter/Options.h b/lldb/include/lldb/Interpreter/Options.h index 9a6a17c2793fa4..864bda6f24c8cc 100644 --- a/lldb/include/lldb/Interpreter/Options.h +++ b/lldb/include/lldb/Interpreter/Options.h @@ -76,12 +76,12 @@ class Options { // This gets passed the short option as an integer... void OptionSeen(int short_option); - bool VerifyOptions(CommandReturnObject &result); + llvm::Error VerifyOptions(); // Verify that the options given are in the options table and can be used // together, but there may be some required options that are missing (used to // verify options that get folded into command aliases). - bool VerifyPartialOptions(CommandReturnObject &result); + llvm::Error VerifyPartialOptions(); void OutputFormattedUsageText(Stream &strm, const OptionDefinition &option_def, diff --git a/lldb/source/Interpreter/CommandAlias.cpp b/lldb/source/Interpreter/CommandAlias.cpp index c5971b52f837fa..ac0c7a3279e64b 100644 --- a/lldb/source/Interpreter/CommandAlias.cpp +++ b/lldb/source/Interpreter/CommandAlias.cpp @@ -10,6 +10,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/FormatAdapters.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandObject.h" @@ -20,20 +21,17 @@ using namespace lldb; using namespace lldb_private; -static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp, +static llvm::Error +ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp, llvm::StringRef options_args, OptionArgVectorSP &option_arg_vector_sp) { - bool success = true; OptionArgVector *option_arg_vector = option_arg_vector_sp.get(); if (options_args.size() < 1) -return true; +return llvm::Error::success(); Args args(options_args); std::string options_string(options_args); - // TODO: Find a way to propagate errors in this CommandReturnObject up the - // stack. - CommandReturnObject result(false); // Check to see if the command being aliased can take any command options. Options *options = cmd_obj_sp->GetOptions(); if (options) { @@ -45,34 +43,30 @@ static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp, llvm::Expected args_or = options->ParseAlias(args, option_arg_vector, options_string); -if (!args_or) { - result.AppendError(toString(args_or.takeError())); - result.AppendError("Unable to create requested alias.\n"); - return false; -} +if (!args_or) + return llvm::createStringError( + llvm::formatv("unable to create alias: {0}", +llvm::fmt_consume(args_or.takeError(; args = std::move(*args_or); -options->VerifyPartialOptions(result); -if (!result.Succeeded() && -result.GetStatus() != lldb::eReturnStatusStarted) { - result.AppendError("Unable to create requested alias.\n"); - return false; -} +if (llvm::Error error = options->VerifyPartialOptions()) + return error; } if (!options_string.empty()) { -if (cmd_obj_sp->WantsRawCommandString()) - option_arg_vector->emplace_back(CommandInterpreter::g_argument, - -1, options_string); -else { +if (cmd_obj_sp->WantsRawCommandString()) { + option_arg_vector->emplace_back(CommandInterpreter::g_argument, -1, + options_string); +} else { for (auto &entry : args.entries()) { if (!entry.ref().empty()) - option_arg_vector->emplace_back(std::string(CommandInterpreter::g_argument), -1, + option_arg_vector->emplace_back( + std::string(CommandInterpreter::g_argument), -1, std::string(entry.ref())); } } } - return success; + return llvm::Error::success(); } CommandAlias::CommandAlias(CommandInterpreter &interpreter, @@ -85,10 +79,15 @@ CommandAlias::CommandAlias(Command
[Lldb-commits] [lldb] [lldb-dap] Partially reverting OutputRedirector changes. (PR #125136)
https://github.com/ashgti created https://github.com/llvm/llvm-project/pull/125136 I just noticed with these changes lldb-dap was using 200% of my CPU and root causing the issue it seems that lldb_private::Pipe::Read() (without a timeout) is using a timeout of `std::chrono::microseconds::zero()` which ends up setting the SelectHelper timeout to `now + 0` (see https://github.com/llvm/llvm-project/blob/7ceef1b1824073fcfd4724539f5942442da1a9c2/lldb/source/Host/posix/PipePosix.cpp#L314 and https://github.com/llvm/llvm-project/blob/7ceef1b1824073fcfd4724539f5942442da1a9c2/lldb/source/Utility/SelectHelper.cpp#L46) which causes SelectHelper to return immediately with a timeout error. As a result the `lldb_dap::OutputRedirector::RedirectTo()` to turn into a busy loop. Additionally, the 'read' call is waiting until the output buffer is full before returning, which prevents any partial output (see https://github.com/llvm/llvm-project/blob/7ceef1b1824073fcfd4724539f5942442da1a9c2/lldb/source/Host/posix/PipePosix.cpp#L325C9-L326C17). This is not the desired behavior for lldb-dap. Instead we want a write to the FD to result in a callback to send the DAP Output event, which mean we want partial output. To mitigate this, I'm reverting the reading operation to the previous behavior before 873426bea3dd67d80dd10650e64e91c69796614f but keeping the refactored structure and thread management. >From d5feadb1e216065f2205e161c174e3cad344 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Thu, 30 Jan 2025 14:39:37 -0800 Subject: [PATCH] [lldb-dap] Partially reverting OutputRedirector changes. I just noticed with these changes lldb-dap was using 200% of my CPU and root causing the issue it seems that lldb_private::Pipe::Read() (without a timeout) is using a timeout of `std::chrono::microseconds::zero()` which ends up setting the SelectHelper timeout to `now + 0`. This causes the `lldb_dap::OutputRedirector::RedirectTo()` to turn into a busy loop. Additionally, the 'Read' call is not peforming parital reads and will only invoke the redirect callback once the output buffer is filled. This is not the desired behavior for lldb-dap. Instead we want a write to the FD to result in a callback to send the DAP Output event, which mean we want partial output. To mitigate this, I'm reverting the reading operation to the previous behavior before 873426bea3dd67d80dd10650e64e91c69796614f but keeping the refactored structure and thread management. --- lldb/tools/lldb-dap/OutputRedirector.cpp | 66 +++- lldb/tools/lldb-dap/OutputRedirector.h | 6 ++- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/lldb/tools/lldb-dap/OutputRedirector.cpp b/lldb/tools/lldb-dap/OutputRedirector.cpp index 8fcbcfec99c4431..7935e17a653bec3 100644 --- a/lldb/tools/lldb-dap/OutputRedirector.cpp +++ b/lldb/tools/lldb-dap/OutputRedirector.cpp @@ -6,6 +6,9 @@ // //===--===/ +#include "OutputRedirector.h" +#include "DAP.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include #if defined(_WIN32) @@ -15,45 +18,59 @@ #include #endif -#include "DAP.h" -#include "OutputRedirector.h" -#include "llvm/ADT/StringRef.h" - using lldb_private::Pipe; -using lldb_private::Status; using llvm::createStringError; using llvm::Error; using llvm::Expected; +using llvm::inconvertibleErrorCode; using llvm::StringRef; namespace lldb_dap { +int OutputRedirector::kInvalidDescriptor = -1; + +OutputRedirector::OutputRedirector() : m_fd(kInvalidDescriptor) {} + Expected OutputRedirector::GetWriteFileDescriptor() { - if (!m_pipe.CanWrite()) + if (m_fd == kInvalidDescriptor) return createStringError(std::errc::bad_file_descriptor, "write handle is not open for writing"); - return m_pipe.GetWriteFileDescriptor(); + return m_fd; } Error OutputRedirector::RedirectTo(std::function callback) { - Status status = m_pipe.CreateNew(/*child_process_inherit=*/false); - if (status.Fail()) -return status.takeError(); + assert(m_fd == kInvalidDescriptor && "Output readirector already started."); + int new_fd[2]; - m_forwarder = std::thread([this, callback]() { -char buffer[OutputBufferSize]; -while (m_pipe.CanRead() && !m_stopped) { - size_t bytes_read; - Status status = m_pipe.Read(&buffer, sizeof(buffer), bytes_read); - if (status.Fail()) -continue; +#if defined(_WIN32) + if (::_pipe(new_fd, OutputBufferSize, O_TEXT) == -1) { +#else + if (::pipe(new_fd) == -1) { +#endif +int error = errno; +return createStringError(inconvertibleErrorCode(), + "Couldn't create new pipe %s", strerror(error)); + } - // EOF detected - if (bytes_read == 0 || m_stopped) + int read_fd = new_fd[0]; + m_fd = new_fd[1]; + m_forwarder = std::thread([this, callback, read_fd]() { +char buffer[OutputBufferSize]; +
[Lldb-commits] [lldb] [lldb-dap] Fix build failure on Windows. (PR #125156)
https://github.com/ashgti created https://github.com/llvm/llvm-project/pull/125156 A previous change is triggering a failure due to SOCKET not being defined in IOStream.h. Adjusting the Windows includes to correct the imports and using a more narrow import (winsock2.h vs windows.h). Also removed a stale comment. Tested this on an x86_64 wins 11 vm. >From 35baa052e3051570c658af94797d16677ab9509d Mon Sep 17 00:00:00 2001 From: John Harrison Date: Thu, 30 Jan 2025 20:07:09 -0800 Subject: [PATCH] [lldb-dap] Fix build failure on Windows. A previous change is triggering a failure due to SOCKET not being defined in IOStream.h. Adjusting the Windows includes to correct the imports and using a more narrow import (winsock2.h vs windows.h). Also removed a stale comment. --- lldb/tools/lldb-dap/IOStream.h | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lldb/tools/lldb-dap/IOStream.h b/lldb/tools/lldb-dap/IOStream.h index 74889eb2e5a866..c91b2f717893c8 100644 --- a/lldb/tools/lldb-dap/IOStream.h +++ b/lldb/tools/lldb-dap/IOStream.h @@ -10,13 +10,8 @@ #define LLDB_TOOLS_LLDB_DAP_IOSTREAM_H #if defined(_WIN32) -// We need to #define NOMINMAX in order to skip `min()` and `max()` macro -// definitions that conflict with other system headers. -// We also need to #undef GetObject (which is defined to GetObjectW) because -// the JSON code we use also has methods named `GetObject()` and we conflict -// against these. -#define NOMINMAX -#include +#include "lldb/Host/windows/windows.h" +#include #else typedef int SOCKET; #endif ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Fix build failure on Windows. (PR #125156)
https://github.com/ashgti edited https://github.com/llvm/llvm-project/pull/125156 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Fix build failure on Windows. (PR #125156)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: John Harrison (ashgti) Changes A previous change is triggering a failure due to SOCKET not being defined in IOStream.h. Adjusting the Windows includes to correct the imports and using a more narrow import (winsock2.h vs windows.h). Also removed a stale comment. Tested this on an x86_64 wins 11 vm. This should fix https://lab.llvm.org/buildbot/#/builders/197/builds/1379 and https://lab.llvm.org/buildbot/#/builders/141/builds/5878 --- Full diff: https://github.com/llvm/llvm-project/pull/125156.diff 1 Files Affected: - (modified) lldb/tools/lldb-dap/IOStream.h (+2-7) ``diff diff --git a/lldb/tools/lldb-dap/IOStream.h b/lldb/tools/lldb-dap/IOStream.h index 74889eb2e5a866..c91b2f717893c8 100644 --- a/lldb/tools/lldb-dap/IOStream.h +++ b/lldb/tools/lldb-dap/IOStream.h @@ -10,13 +10,8 @@ #define LLDB_TOOLS_LLDB_DAP_IOSTREAM_H #if defined(_WIN32) -// We need to #define NOMINMAX in order to skip `min()` and `max()` macro -// definitions that conflict with other system headers. -// We also need to #undef GetObject (which is defined to GetObjectW) because -// the JSON code we use also has methods named `GetObject()` and we conflict -// against these. -#define NOMINMAX -#include +#include "lldb/Host/windows/windows.h" +#include #else typedef int SOCKET; #endif `` https://github.com/llvm/llvm-project/pull/125156 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Partially reverting OutputRedirector changes. (PR #125136)
vvereschaka wrote: @ashgti , these changes break the windows build with the following errors: ``` C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\tools\lldb-dap\IOStream.h(41): error C2061: syntax error: identifier 'SOCKET' C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\tools\lldb-dap\IOStream.h(48): error C3646: 'm_socket': unknown override specifier C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\tools\lldb-dap\IOStream.h(48): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 68.008 [200/18/5080]Building CXX object tools\lldb\tools\lldb-dap\CMakeFiles\lldb-dap.dir\FunctionBreakpoint.cpp.obj ``` https://lab.llvm.org/buildbot/#/builders/197/builds/1379/steps/8/logs/stdio https://lab.llvm.org/buildbot/#/builders/197/builds/1379 would you take care of it? https://github.com/llvm/llvm-project/pull/125136 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Partially reverting OutputRedirector changes. (PR #125136)
slydiman wrote: Note that this error occurred on Windows host building `tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp` using MSVC. https://github.com/llvm/llvm-project/pull/125136 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Partially reverting OutputRedirector changes. (PR #125136)
ashgti wrote: #125156 should fix this https://github.com/llvm/llvm-project/pull/125136 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0d46657 - Only include necessary files in the lldb-dap VSIX (#124986)
Author: Matthew Bastien Date: 2025-01-30T12:18:55-08:00 New Revision: 0d46657cb6bf04430ff8222e1974e49441767d47 URL: https://github.com/llvm/llvm-project/commit/0d46657cb6bf04430ff8222e1974e49441767d47 DIFF: https://github.com/llvm/llvm-project/commit/0d46657cb6bf04430ff8222e1974e49441767d47.diff LOG: Only include necessary files in the lldb-dap VSIX (#124986) The published VSIX for the LLDB DAP extension contains a bunch of unnecessary files: ``` ❯ tar tf llvm-vs-code-extensions.lldb-dap-0.2.8.vsix extension.vsixmanifest [Content_Types].xml extension/.github/workflows/auto_publish.yml extension/.github/workflows/integrate_llvmproject.yml extension/.gitignore extension/.vscode/launch.json extension/.vscode/tasks.json extension/LICENSE.TXT extension/out/debug-adapter-factory.js extension/out/debug-adapter-factory.js.map extension/out/disposable-context.js extension/out/disposable-context.js.map extension/out/extension.js extension/out/extension.js.map extension/out/types.js extension/out/types.js.map extension/package.json extension/README.md extension/src-ts/debug-adapter-factory.ts extension/src-ts/disposable-context.ts extension/src-ts/extension.ts extension/src-ts/types.ts extension/syntaxes/arm.disasm extension/syntaxes/arm64.disasm extension/syntaxes/disassembly.json extension/syntaxes/x86.disasm extension/tsconfig.json ``` All that's really needed is the package.json, license, README, syntaxes folder, and compiled sources. This PR adds a `.vscodeignore` file that requires files and directories to be explicitly added to the VSIX. Contents of the VSIX after applying this change and running `npm run package`: ``` ❯ tar tf out/lldb-dap.vsix extension.vsixmanifest [Content_Types].xml extension/LICENSE.TXT extension/out/debug-adapter-factory.js extension/out/debug-adapter-factory.js.map extension/out/disposable-context.js extension/out/disposable-context.js.map extension/out/extension.js extension/out/extension.js.map extension/package.json extension/README.md extension/syntaxes/arm.disasm extension/syntaxes/arm64.disasm extension/syntaxes/disassembly.json extension/syntaxes/x86.disasm ``` I did a very basic sanity check of installing the packaged extension and debugging a simple swift application in VS Code to make sure the extension was still functional. Added: lldb/tools/lldb-dap/.vscodeignore Modified: Removed: diff --git a/lldb/tools/lldb-dap/.vscodeignore b/lldb/tools/lldb-dap/.vscodeignore new file mode 100644 index 00..0491ba879fc3f0 --- /dev/null +++ b/lldb/tools/lldb-dap/.vscodeignore @@ -0,0 +1,9 @@ +// Ignore everything by default +**/* + +// Only include specific files and directories +!LICENSE.TXT +!package.json +!README.md +!out/** +!syntaxes/** ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Only include necessary files in the lldb-dap VSIX (PR #124986)
github-actions[bot] wrote: @matthewbastien 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/124986 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Only include necessary files in the lldb-dap VSIX (PR #124986)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/124986 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb] Change lldb's breakpoint detection behavior [WIP] (PR #105594)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 62f6d637c015a6fcf6e493e25e91f5d833da999f a0ba821cf6f0a20e3cdc8de196b27fb85e0399d1 --extensions h,c,cpp -- lldb/test/API/functionalities/thread/finish-from-empty-func/main.c lldb/include/lldb/Target/Thread.h lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/Process/scripted/ScriptedThread.cpp lldb/source/Target/StopInfo.cpp lldb/source/Target/Thread.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/test/API/functionalities/thread/finish-from-empty-func/main.c b/lldb/test/API/functionalities/thread/finish-from-empty-func/main.c index 202bca4060..bc66a548a8 100644 --- a/lldb/test/API/functionalities/thread/finish-from-empty-func/main.c +++ b/lldb/test/API/functionalities/thread/finish-from-empty-func/main.c @@ -1,8 +1,8 @@ #include -void done() { } +void done() {} int main() { - puts ("in main"); + puts("in main"); done(); - puts ("leaving main"); + puts("leaving main"); return 0; } `` https://github.com/llvm/llvm-project/pull/105594 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add SBDebugger:: AddNotificationCallback API (PR #111206)
jimingham wrote: There were a bunch of review comments that need to be addressed. But I also am a bit nervous about adding a feature that is intended to be a general "lldb interesting classes lifecycle notification" but when designed only supports Debugger Lifecycle Events. Those are the simplest and least common of all the events we'd want to handle. https://github.com/llvm/llvm-project/pull/111206 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use llvm::Error instead of CommandReturnObject for error reporting (PR #125125)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/125125 >From 24ddc550e3ee61b863cbaea05ff49981bc20f7ad Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 30 Jan 2025 14:25:16 -0800 Subject: [PATCH 1/2] [lldb] Use llvm::Error instead of CommandReturnObject for error reporting Use `llvm::Error` instead of `CommandReturnObject` for error reporting. The command return objects were populated with errors but never displayed. With this patch they're at least logged. --- lldb/include/lldb/Interpreter/Options.h | 4 +- lldb/source/Interpreter/CommandAlias.cpp | 49 +-- lldb/source/Interpreter/CommandObject.cpp | 2 +- lldb/source/Interpreter/Options.cpp | 87 ++- .../DarwinLog/StructuredDataDarwinLog.cpp | 9 +- 5 files changed, 77 insertions(+), 74 deletions(-) diff --git a/lldb/include/lldb/Interpreter/Options.h b/lldb/include/lldb/Interpreter/Options.h index 9a6a17c2793fa4..864bda6f24c8cc 100644 --- a/lldb/include/lldb/Interpreter/Options.h +++ b/lldb/include/lldb/Interpreter/Options.h @@ -76,12 +76,12 @@ class Options { // This gets passed the short option as an integer... void OptionSeen(int short_option); - bool VerifyOptions(CommandReturnObject &result); + llvm::Error VerifyOptions(); // Verify that the options given are in the options table and can be used // together, but there may be some required options that are missing (used to // verify options that get folded into command aliases). - bool VerifyPartialOptions(CommandReturnObject &result); + llvm::Error VerifyPartialOptions(); void OutputFormattedUsageText(Stream &strm, const OptionDefinition &option_def, diff --git a/lldb/source/Interpreter/CommandAlias.cpp b/lldb/source/Interpreter/CommandAlias.cpp index c5971b52f837fa..ac0c7a3279e64b 100644 --- a/lldb/source/Interpreter/CommandAlias.cpp +++ b/lldb/source/Interpreter/CommandAlias.cpp @@ -10,6 +10,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/FormatAdapters.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandObject.h" @@ -20,20 +21,17 @@ using namespace lldb; using namespace lldb_private; -static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp, +static llvm::Error +ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp, llvm::StringRef options_args, OptionArgVectorSP &option_arg_vector_sp) { - bool success = true; OptionArgVector *option_arg_vector = option_arg_vector_sp.get(); if (options_args.size() < 1) -return true; +return llvm::Error::success(); Args args(options_args); std::string options_string(options_args); - // TODO: Find a way to propagate errors in this CommandReturnObject up the - // stack. - CommandReturnObject result(false); // Check to see if the command being aliased can take any command options. Options *options = cmd_obj_sp->GetOptions(); if (options) { @@ -45,34 +43,30 @@ static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp, llvm::Expected args_or = options->ParseAlias(args, option_arg_vector, options_string); -if (!args_or) { - result.AppendError(toString(args_or.takeError())); - result.AppendError("Unable to create requested alias.\n"); - return false; -} +if (!args_or) + return llvm::createStringError( + llvm::formatv("unable to create alias: {0}", +llvm::fmt_consume(args_or.takeError(; args = std::move(*args_or); -options->VerifyPartialOptions(result); -if (!result.Succeeded() && -result.GetStatus() != lldb::eReturnStatusStarted) { - result.AppendError("Unable to create requested alias.\n"); - return false; -} +if (llvm::Error error = options->VerifyPartialOptions()) + return error; } if (!options_string.empty()) { -if (cmd_obj_sp->WantsRawCommandString()) - option_arg_vector->emplace_back(CommandInterpreter::g_argument, - -1, options_string); -else { +if (cmd_obj_sp->WantsRawCommandString()) { + option_arg_vector->emplace_back(CommandInterpreter::g_argument, -1, + options_string); +} else { for (auto &entry : args.entries()) { if (!entry.ref().empty()) - option_arg_vector->emplace_back(std::string(CommandInterpreter::g_argument), -1, + option_arg_vector->emplace_back( + std::string(CommandInterpreter::g_argument), -1, std::string(entry.ref())); } } } - return success; + return llvm::Error::success(); } CommandAlias::CommandAlias(CommandInterpreter &interpreter, @@ -85,10 +79,15 @@ CommandAlias::CommandAlias(CommandInterp
[Lldb-commits] [lldb] 6a05bee - [NFC][lldb] Document a few ivars on the value object system. (#124971)
Author: Augusto Noronha Date: 2025-01-30T14:29:16-08:00 New Revision: 6a05beeb2bed366f7e6e0056a758c6f8d385fdde URL: https://github.com/llvm/llvm-project/commit/6a05beeb2bed366f7e6e0056a758c6f8d385fdde DIFF: https://github.com/llvm/llvm-project/commit/6a05beeb2bed366f7e6e0056a758c6f8d385fdde.diff LOG: [NFC][lldb] Document a few ivars on the value object system. (#124971) Co-authored-by: Jonas Devlieghere Added: Modified: lldb/include/lldb/Core/Value.h lldb/include/lldb/Expression/ExpressionVariable.h lldb/include/lldb/ValueObject/ValueObjectConstResultImpl.h lldb/source/Expression/Materializer.cpp Removed: diff --git a/lldb/include/lldb/Core/Value.h b/lldb/include/lldb/Core/Value.h index d0c338ffec0cd3..3714621b469ecf 100644 --- a/lldb/include/lldb/Core/Value.h +++ b/lldb/include/lldb/Core/Value.h @@ -109,8 +109,10 @@ class Value { Scalar &ResolveValue(ExecutionContext *exe_ctx, Module *module = nullptr); + /// See comment on m_scalar to understand what GetScalar returns. const Scalar &GetScalar() const { return m_value; } + /// See comment on m_scalar to understand what GetScalar returns. Scalar &GetScalar() { return m_value; } size_t ResizeData(size_t len); @@ -148,6 +150,32 @@ class Value { static ValueType GetValueTypeFromAddressType(AddressType address_type); protected: + /// Represents a value, which can be a scalar, a load address, a file address, + /// or a host address. + /// + /// The interpretation of `m_value` depends on `m_value_type`: + /// - Scalar: `m_value` contains the scalar value. + /// - Load Address: `m_value` contains the load address. + /// - File Address: `m_value` contains the file address. + /// - Host Address: `m_value` contains a pointer to the start of the buffer in + ///host memory. + /// Currently, this can point to either: + /// - The `m_data_buffer` of this Value instance (e.g., in DWARF + /// computations). + /// - The `m_data` of a Value Object containing this Value. + // TODO: the GetScalar() API relies on knowledge not codified by the type + // system, making it hard to understand and easy to misuse. + // - Separate the scalar from the variable that contains the address (be it a + // load, file or host address). + // - Rename GetScalar() to something more indicative to what the scalar is, + // like GetScalarOrAddress() for example. + // - Split GetScalar() into two functions, GetScalar() and GetAddress(), which + // verify (or assert) what m_value_type is to make sure users of the class are + // querying the right thing. + // TODO: It's confusing to point to multiple possible buffers when the + // ValueType is a host address. Value should probably always own its buffer. + // Perhaps as a shared pointer with a copy on write system if the same buffer + // can be shared by multiple classes. Scalar m_value; CompilerType m_compiler_type; void *m_context = nullptr; diff --git a/lldb/include/lldb/Expression/ExpressionVariable.h b/lldb/include/lldb/Expression/ExpressionVariable.h index fc36793b3a475c..f5bd9389219668 100644 --- a/lldb/include/lldb/Expression/ExpressionVariable.h +++ b/lldb/include/lldb/Expression/ExpressionVariable.h @@ -107,9 +107,18 @@ class ExpressionVariable FlagType m_flags; // takes elements of Flags - // these should be private + /// These members should be private. + /// @{ + /// A value object whose value's data lives in host (lldb's) memory. lldb::ValueObjectSP m_frozen_sp; + /// The ValueObject counterpart to m_frozen_sp that tracks the value in + /// inferior memory. This object may not always exist; its presence depends on + /// whether it is logical for the value to exist in the inferior memory. For + /// example, when evaluating a C++ expression that generates an r-value, such + /// as a single function call, there is no memory address in the inferior to + /// track. lldb::ValueObjectSP m_live_sp; + /// @} }; /// \class ExpressionVariableList ExpressionVariable.h diff --git a/lldb/include/lldb/ValueObject/ValueObjectConstResultImpl.h b/lldb/include/lldb/ValueObject/ValueObjectConstResultImpl.h index dbd68160acb4dc..5509886a8965da 100644 --- a/lldb/include/lldb/ValueObject/ValueObjectConstResultImpl.h +++ b/lldb/include/lldb/ValueObject/ValueObjectConstResultImpl.h @@ -66,6 +66,10 @@ class ValueObjectConstResultImpl { private: ValueObject *m_impl_backend; + /// The memory address in the inferior process that this ValueObject tracks. + /// This address is used to request additional memory when the actual data + /// size exceeds the initial local buffer size, such as when a dynamic type + /// resolution results in a type larger than its statically determined type. lldb::addr_t m_live_address; AddressType m_live_address_type; lldb::ValueObjectSP m_address_of_backend; diff --git a/lldb
[Lldb-commits] [lldb] adb9ef0 - [lldb-dap] Partially reverting OutputRedirector changes. (#125136)
Author: John Harrison Date: 2025-01-30T16:35:15-08:00 New Revision: adb9ef035552d7fc42a34560677f89f4f6421295 URL: https://github.com/llvm/llvm-project/commit/adb9ef035552d7fc42a34560677f89f4f6421295 DIFF: https://github.com/llvm/llvm-project/commit/adb9ef035552d7fc42a34560677f89f4f6421295.diff LOG: [lldb-dap] Partially reverting OutputRedirector changes. (#125136) I just noticed with these changes lldb-dap was using 200% of my CPU and root causing the issue it seems that lldb_private::Pipe::Read() (without a timeout) is using a timeout of `std::chrono::microseconds::zero()` which ends up setting the SelectHelper timeout to `now + 0` (see https://github.com/llvm/llvm-project/blob/7ceef1b1824073fcfd4724539f5942442da1a9c2/lldb/source/Host/posix/PipePosix.cpp#L314 and https://github.com/llvm/llvm-project/blob/7ceef1b1824073fcfd4724539f5942442da1a9c2/lldb/source/Utility/SelectHelper.cpp#L46) which causes SelectHelper to return immediately with a timeout error. As a result the `lldb_dap::OutputRedirector::RedirectTo()` to turn into a busy loop. Additionally, the 'read' call is waiting until the output buffer is full before returning, which prevents any partial output (see https://github.com/llvm/llvm-project/blob/7ceef1b1824073fcfd4724539f5942442da1a9c2/lldb/source/Host/posix/PipePosix.cpp#L325C9-L326C17). This is not the desired behavior for lldb-dap. Instead we want a write to the FD to result in a callback to send the DAP Output event, which mean we want partial output. To mitigate this, I'm reverting the reading operation to the previous behavior before 873426bea3dd67d80dd10650e64e91c69796614f but keeping the refactored structure and thread management. Added: Modified: lldb/tools/lldb-dap/OutputRedirector.cpp lldb/tools/lldb-dap/OutputRedirector.h Removed: diff --git a/lldb/tools/lldb-dap/OutputRedirector.cpp b/lldb/tools/lldb-dap/OutputRedirector.cpp index 8fcbcfec99c443..7935e17a653bec 100644 --- a/lldb/tools/lldb-dap/OutputRedirector.cpp +++ b/lldb/tools/lldb-dap/OutputRedirector.cpp @@ -6,6 +6,9 @@ // //===--===/ +#include "OutputRedirector.h" +#include "DAP.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include #if defined(_WIN32) @@ -15,45 +18,59 @@ #include #endif -#include "DAP.h" -#include "OutputRedirector.h" -#include "llvm/ADT/StringRef.h" - using lldb_private::Pipe; -using lldb_private::Status; using llvm::createStringError; using llvm::Error; using llvm::Expected; +using llvm::inconvertibleErrorCode; using llvm::StringRef; namespace lldb_dap { +int OutputRedirector::kInvalidDescriptor = -1; + +OutputRedirector::OutputRedirector() : m_fd(kInvalidDescriptor) {} + Expected OutputRedirector::GetWriteFileDescriptor() { - if (!m_pipe.CanWrite()) + if (m_fd == kInvalidDescriptor) return createStringError(std::errc::bad_file_descriptor, "write handle is not open for writing"); - return m_pipe.GetWriteFileDescriptor(); + return m_fd; } Error OutputRedirector::RedirectTo(std::function callback) { - Status status = m_pipe.CreateNew(/*child_process_inherit=*/false); - if (status.Fail()) -return status.takeError(); + assert(m_fd == kInvalidDescriptor && "Output readirector already started."); + int new_fd[2]; - m_forwarder = std::thread([this, callback]() { -char buffer[OutputBufferSize]; -while (m_pipe.CanRead() && !m_stopped) { - size_t bytes_read; - Status status = m_pipe.Read(&buffer, sizeof(buffer), bytes_read); - if (status.Fail()) -continue; +#if defined(_WIN32) + if (::_pipe(new_fd, OutputBufferSize, O_TEXT) == -1) { +#else + if (::pipe(new_fd) == -1) { +#endif +int error = errno; +return createStringError(inconvertibleErrorCode(), + "Couldn't create new pipe %s", strerror(error)); + } - // EOF detected - if (bytes_read == 0 || m_stopped) + int read_fd = new_fd[0]; + m_fd = new_fd[1]; + m_forwarder = std::thread([this, callback, read_fd]() { +char buffer[OutputBufferSize]; +while (!m_stopped) { + ssize_t bytes_count = ::read(read_fd, &buffer, sizeof(buffer)); + // EOF detected. + if (bytes_count == 0) +break; + if (bytes_count == -1) { +// Skip non-fatal errors. +if (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK) + continue; break; + } - callback(StringRef(buffer, bytes_read)); + callback(StringRef(buffer, bytes_count)); } +::close(read_fd); }); return Error::success(); @@ -62,14 +79,15 @@ Error OutputRedirector::RedirectTo(std::function callback) { void OutputRedirector::Stop() { m_stopped = true; - if (m_pipe.CanWrite()) { + if (m_fd != kInvalidDescriptor) { +int fd = m_fd; +m_fd = kInvalidDescriptor;
[Lldb-commits] [lldb] [lldb] Make ValueObjectDynamicValue::UpdateValue() point to a host b… (PR #125143)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Augusto Noronha (augusto2112) Changes …uffer ValueObjectDynamicValue::UpdateValue() assumes that the dynamic type found by GetDynamicTypeAndAddress() would return an address in the inferior. This commit makes it so it can deal with being passed a host address instead. This is needed downstream by the Swift fork. rdar://143357274 --- Full diff: https://github.com/llvm/llvm-project/pull/125143.diff 2 Files Affected: - (modified) lldb/include/lldb/Target/LanguageRuntime.h (+3-1) - (modified) lldb/source/ValueObject/ValueObjectDynamicValue.cpp (+18-6) ``diff diff --git a/lldb/include/lldb/Target/LanguageRuntime.h b/lldb/include/lldb/Target/LanguageRuntime.h index 4a0214b04e235e..08db8a17a67e69 100644 --- a/lldb/include/lldb/Target/LanguageRuntime.h +++ b/lldb/include/lldb/Target/LanguageRuntime.h @@ -105,7 +105,9 @@ class LanguageRuntime : public Runtime, public PluginInterface { "language doesn't support getting vtable information"); } - // this call should return true if it could set the name and/or the type + // This call should return true if it could set the name and/or the type. + // address can be either a legitimate address on the inferior, or an address + // in lldb, if value_type == HostAddress. virtual bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic, TypeAndOrName &class_type_or_name, diff --git a/lldb/source/ValueObject/ValueObjectDynamicValue.cpp b/lldb/source/ValueObject/ValueObjectDynamicValue.cpp index 588c644bbfd07b..10a5a9d0b76919 100644 --- a/lldb/source/ValueObject/ValueObjectDynamicValue.cpp +++ b/lldb/source/ValueObject/ValueObjectDynamicValue.cpp @@ -239,11 +239,19 @@ bool ValueObjectDynamicValue::UpdateValue() { if (m_address.IsValid()) SetValueDidChange(true); -// We've moved, so we should be fine... -m_address = dynamic_address; -lldb::TargetSP target_sp(GetTargetSP()); -lldb::addr_t load_address = m_address.GetLoadAddress(target_sp.get()); -m_value.GetScalar() = load_address; +// If we found a host address, point to the buffer in host memory. +// Later on this function will copy the buffer over. +if (value_type == Value::ValueType::HostAddress) { + m_value.GetScalar() = dynamic_address.GetOffset(); + m_address = LLDB_INVALID_ADDRESS; +} else { + // Otherwise we have a legitimate address on the target. Point to the load + // address. + m_address = dynamic_address; + lldb::TargetSP target_sp(GetTargetSP()); + lldb::addr_t load_address = m_address.GetLoadAddress(target_sp.get()); + m_value.GetScalar() = load_address; +} } if (runtime) @@ -258,7 +266,11 @@ bool ValueObjectDynamicValue::UpdateValue() { LLDB_LOGF(log, "[%s %p] has a new dynamic type %s", GetName().GetCString(), static_cast(this), GetTypeName().GetCString()); - if (m_address.IsValid() && m_dynamic_type_info) { + // m_address could be invalid but we could still have a local buffer + // containing the dynamic value. + if ((m_address.IsValid() || + m_value.GetValueType() == Value::ValueType::HostAddress) && + m_dynamic_type_info) { // The variable value is in the Scalar value inside the m_value. We can // point our m_data right to it. m_error = m_value.GetValueAsData(&exe_ctx, m_data, GetModule().get()); `` https://github.com/llvm/llvm-project/pull/125143 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB-DAP] SBDebugger don't prefix title on progress updates (PR #124648)
@@ -411,6 +412,30 @@ void SendStdOutStdErr(DAP &dap, lldb::SBProcess &process) { dap.SendOutput(OutputType::Stderr, llvm::StringRef(buffer, count)); } +static std::string GetStringFromStructuredData(lldb::SBStructuredData &data, + const char *key) { + lldb::SBStructuredData keyValue = data.GetValueForKey(key); + if (!keyValue) +return std::string(); + + size_t size = keyValue.GetStringValue(nullptr, 0); + std::cout << "Size for " << key << " " << size << std::endl; + std::string stringValue; + stringValue.resize(size); + keyValue.GetStringValue(&stringValue[0], size + 1); + std::cout << "String value after: " << stringValue << std::endl; + return stringValue; +} + +static uint64_t GetUintFromStructuredData(lldb::SBStructuredData &data, + const char *key) { + lldb::SBStructuredData keyValue = data.GetValueForKey(key); + + if (!keyValue.IsValid()) Jlalond wrote: @clayborg I added -1 here, I think it might just be better to let it fail at 0. That's certainly more succint, thoughts? https://github.com/llvm/llvm-project/pull/124648 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add SBDebugger:: AddNotificationCallback API (PR #111206)
ZequanWu wrote: Is there any update on this PR? I'm interested in working on a similar callback that can be triggered when target is created, but I want to wait for this one to get landed first as they will share some common code. https://github.com/llvm/llvm-project/pull/111206 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Partially reverting OutputRedirector changes. (PR #125136)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/125136 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make ValueObjectDynamicValue::UpdateValue() point to a host b… (PR #125143)
jimingham wrote: I worry a bit about the fact that in the host case, GetValueAsData is going to end up calling: memcpy(dst, reinterpret_cast(address), byte_size); where address is the host data buffer and byte_size is the size of the new dynamic type. But in the case where the Value has data in the m_data_buffer, address points to a buffer. The code makes sure that the destination buffer (pointed to by dst) is big enough to fit byte_size, but I don't see the guarantee that the original contents are not smaller than the new dynamic type byte size. If we get that wrong, then we'll crash here or worse sample lldb internal memory and present that to the user as a value. How do you know that can't happen? https://github.com/llvm/llvm-project/pull/125143 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/115005 >From 4d797371598960baf7729d05590aa1a8c7077694 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 4 Nov 2024 14:33:45 +0500 Subject: [PATCH 01/10] [lldb] Analyze enum promotion type during parsing --- clang/include/clang/AST/Decl.h| 2 +- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 95 ++- .../TypeSystem/Clang/TypeSystemClang.cpp | 26 + 3 files changed, 98 insertions(+), 25 deletions(-) diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 16403774e72b31..41cb47516f5803 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -3903,6 +3903,7 @@ class EnumDecl : public TagDecl { void setInstantiationOfMemberEnum(ASTContext &C, EnumDecl *ED, TemplateSpecializationKind TSK); +public: /// Sets the width in bits required to store all the /// non-negative enumerators of this enum. void setNumPositiveBits(unsigned Num) { @@ -3914,7 +3915,6 @@ class EnumDecl : public TagDecl { /// negative enumerators of this enum. (see getNumNegativeBits) void setNumNegativeBits(unsigned Num) { EnumDeclBits.NumNegativeBits = Num; } -public: /// True if this tag declaration is a scoped enumeration. Only /// possible in C++11 mode. void setScoped(bool Scoped = true) { EnumDeclBits.IsScoped = Scoped; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index e77188bfbd2e4a..bb9c35a235c1ff 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2316,6 +2316,8 @@ size_t DWARFASTParserClang::ParseChildEnumerators( return 0; size_t enumerators_added = 0; + unsigned NumNegativeBits = 0; + unsigned NumPositiveBits = 0; for (DWARFDIE die : parent_die.children()) { const dw_tag_t tag = die.Tag(); @@ -2367,11 +2369,102 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( clang_type, decl, name, enum_value, enumerator_byte_size * 8); ++enumerators_added; + + llvm::APSInt InitVal = ECD->getInitVal(); + // Keep track of the size of positive and negative values. + if (InitVal.isUnsigned() || InitVal.isNonNegative()) { +// If the enumerator is zero that should still be counted as a positive +// bit since we need a bit to store the value zero. +unsigned ActiveBits = InitVal.getActiveBits(); +NumPositiveBits = std::max({NumPositiveBits, ActiveBits, 1u}); + } else { +NumNegativeBits = +std::max(NumNegativeBits, (unsigned)InitVal.getSignificantBits()); + } } } + + /// The following code follows the same logic as in Sema::ActOnEnumBody + /// clang/lib/Sema/SemaDecl.cpp + // If we have an empty set of enumerators we still need one bit. + // From [dcl.enum]p8 + // If the enumerator-list is empty, the values of the enumeration are as if + // the enumeration had a single enumerator with value 0 + if (!NumPositiveBits && !NumNegativeBits) +NumPositiveBits = 1; + + clang::QualType qual_type(ClangUtil::GetQualType(clang_type)); + clang::EnumDecl *enum_decl = qual_type->getAs()->getDecl(); + enum_decl->setNumPositiveBits(NumPositiveBits); + enum_decl->setNumNegativeBits(NumNegativeBits); + + // C++0x N3000 [conv.prom]p3: + // An rvalue of an unscoped enumeration type whose underlying + // type is not fixed can be converted to an rvalue of the first + // of the following types that can represent all the values of + // the enumeration: int, unsigned int, long int, unsigned long + // int, long long int, or unsigned long long int. + // C99 6.4.4.3p2: + // An identifier declared as an enumeration constant has type int. + // The C99 rule is modified by C23. + clang::QualType BestPromotionType; + unsigned BestWidth; + + auto &Context = m_ast.getASTContext(); + unsigned LongWidth = Context.getTargetInfo().getLongWidth(); + unsigned IntWidth = Context.getTargetInfo().getIntWidth(); + unsigned CharWidth = Context.getTargetInfo().getCharWidth(); + unsigned ShortWidth = Context.getTargetInfo().getShortWidth(); + + bool is_cpp = Language::LanguageIsCPlusPlus( + SymbolFileDWARF::GetLanguage(*parent_die.GetCU())); + + if (NumNegativeBits) { +// If there is a negative value, figure out the smallest integer type (of +// int/long/longlong) that fits. +if (NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) { + BestWidth = CharWidth; +} else if (NumNegativeBits <= ShortWidth && NumPositiveBits < ShortWidth) { + BestWidth = ShortWidth; +} else if (NumNegativeBits <= IntWidth &
[Lldb-commits] [clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
@@ -2367,11 +2369,38 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( clang_type, decl, name, enum_value, enumerator_byte_size * 8); ++enumerators_added; + + llvm::APSInt InitVal = ECD->getInitVal(); + // Keep track of the size of positive and negative values. + if (InitVal.isUnsigned() || InitVal.isNonNegative()) { +// If the enumerator is zero that should still be counted as a positive +// bit since we need a bit to store the value zero. +unsigned ActiveBits = InitVal.getActiveBits(); +NumPositiveBits = std::max({NumPositiveBits, ActiveBits, 1u}); kuilpd wrote: I don't think I can move the entire loop into a separate function, the way `DWARFASTParserClang` and `SemaDecl` iterate over enum values is completely different, so for now I just moved these few lines that determine the updated `NumPositiveBits` `NumNegativeBits`. https://github.com/llvm/llvm-project/pull/115005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [NFC] changes to AArch64 ACLE types definitions (PR #125063)
tmatheson-arm wrote: I've just noticed 2/3 of these are redundant now since the existing neon functions have been removed. I'll remove them. https://github.com/llvm/llvm-project/pull/125063 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support CommandInterpreter print callbacks (PR #125006)
JDevlieghere wrote: > It's not clear from the patch description whether you actually need the > ability to suppress the command output, or if you just want the ability to > "access" the diagnostics. Because, if its the latter, then perhaps an (async) > event would be a slightly more lightweight alternative? Yes, part of the requirement is that the output isn't printed by lldb itself, although the implementer is still in control with the return value. https://github.com/llvm/llvm-project/pull/125006 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (PR #123945)
DavidSpickett wrote: The easy one to fix is: ``` Traceback (most recent call last): File "C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\functionalities\reverse-execution\TestReverseContinueNotSupported.py", line 25, in test_reverse_continue_not_supported self.assertFailure( File "C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py", line 2589, in assertFailure self.assertEqual(error, error_str, msg) AssertionError: 'error: windows does not support reverse execution of processes' != 'error: gdb-remote does not support reverse execution of processes' - error: windows does not support reverse execution of processes ?^^^ ^^ + error: gdb-remote does not support reverse execution of processes ?^ + ^^ ``` The odd one is: ``` ERROR: test_continue_preserves_direction (TestReverseContinueBreakpoints.TestReverseContinueBreakpoints.test_continue_preserves_direction) -- Traceback (most recent call last): File "C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\functionalities\reverse-execution\TestReverseContinueBreakpoints.py", line 95, in test_continue_preserves_direction self.continue_preserves_direction_internal(async_mode=False) File "C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\functionalities\reverse-execution\TestReverseContinueBreakpoints.py", line 102, in continue_preserves_direction_internal target, process, initial_threads = self.setup_recording(async_mode) File "C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\functionalities\reverse-execution\TestReverseContinueBreakpoints.py", line 140, in setup_recording self.assertEqual(len(initial_threads), 1) TypeError: object of type 'NoneType' has no len() ``` I will revert this and reproduce it tomorrow. https://github.com/llvm/llvm-project/pull/123945 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert "Reland "[lldb] Implement basic support for reverse-continue" (#123906)"" (PR #125091)
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/125091 Reverts llvm/llvm-project#123945 Has failed on the Windows on Arm buildbot: https://lab.llvm.org/buildbot/#/builders/141/builds/5865 ``` Unresolved Tests (2): lldb-api :: functionalities/reverse-execution/TestReverseContinueBreakpoints.py lldb-api :: functionalities/reverse-execution/TestReverseContinueWatchpoints.py Failed Tests (1): lldb-api :: functionalities/reverse-execution/TestReverseContinueNotSupported.py ``` Reverting while I reproduce locally. >From 140f0918c81a9e4e2142f404103c5870fdf7cb34 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Thu, 30 Jan 2025 16:44:34 + Subject: [PATCH] =?UTF-8?q?Revert=20"Reland=20"[lldb]=20Implement=20basic?= =?UTF-8?q?=20support=20for=20reverse-continue"=20(#123906=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 0caba6c8dc2f6f0da61f30c169f59d40591cddbc. --- lldb/include/lldb/API/SBProcess.h | 1 - lldb/include/lldb/Target/Process.h| 28 +- lldb/include/lldb/Target/StopInfo.h | 7 - lldb/include/lldb/Target/Thread.h | 9 +- lldb/include/lldb/Target/ThreadList.h | 6 +- lldb/include/lldb/Target/ThreadPlan.h | 13 - lldb/include/lldb/Target/ThreadPlanBase.h | 2 - lldb/include/lldb/lldb-enumerations.h | 6 - .../Python/lldbsuite/test/gdbclientutils.py | 5 +- .../Python/lldbsuite/test/lldbgdbproxy.py | 175 -- .../Python/lldbsuite/test/lldbreverse.py | 541 -- .../Python/lldbsuite/test/lldbtest.py | 2 - .../tools/lldb-server/lldbgdbserverutils.py | 14 +- lldb/source/API/SBProcess.cpp | 12 - lldb/source/API/SBThread.cpp | 2 - .../source/Interpreter/CommandInterpreter.cpp | 3 +- .../Process/Linux/NativeThreadLinux.cpp | 3 - .../Process/MacOSX-Kernel/ProcessKDP.cpp | 8 +- .../Process/MacOSX-Kernel/ProcessKDP.h| 2 +- .../Process/Windows/Common/ProcessWindows.cpp | 9 +- .../Process/Windows/Common/ProcessWindows.h | 2 +- .../GDBRemoteCommunicationClient.cpp | 20 - .../gdb-remote/GDBRemoteCommunicationClient.h | 6 - .../GDBRemoteCommunicationServerLLGS.cpp | 1 - .../Process/gdb-remote/ProcessGDBRemote.cpp | 98 +--- .../Process/gdb-remote/ProcessGDBRemote.h | 4 +- .../Process/scripted/ScriptedProcess.cpp | 9 +- .../Process/scripted/ScriptedProcess.h| 2 +- lldb/source/Target/Process.cpp| 24 +- lldb/source/Target/StopInfo.cpp | 28 - lldb/source/Target/Thread.cpp | 9 +- lldb/source/Target/ThreadList.cpp | 32 +- lldb/source/Target/ThreadPlanBase.cpp | 4 - .../reverse-execution/Makefile| 3 - .../TestReverseContinueBreakpoints.py | 157 - .../TestReverseContinueNotSupported.py| 31 - .../TestReverseContinueWatchpoints.py | 134 - .../functionalities/reverse-execution/main.c | 25 - lldb/tools/lldb-dap/JSONUtils.cpp | 3 - lldb/tools/lldb-dap/LLDBUtils.cpp | 1 - 40 files changed, 47 insertions(+), 1394 deletions(-) delete mode 100644 lldb/packages/Python/lldbsuite/test/lldbgdbproxy.py delete mode 100644 lldb/packages/Python/lldbsuite/test/lldbreverse.py delete mode 100644 lldb/test/API/functionalities/reverse-execution/Makefile delete mode 100644 lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py delete mode 100644 lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py delete mode 100644 lldb/test/API/functionalities/reverse-execution/TestReverseContinueWatchpoints.py delete mode 100644 lldb/test/API/functionalities/reverse-execution/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 882b8bd837131d1..1624e02070b1b21 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -159,7 +159,6 @@ class LLDB_API SBProcess { lldb::SBError Destroy(); lldb::SBError Continue(); - lldb::SBError ContinueInDirection(lldb::RunDirection direction); lldb::SBError Stop(); diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index b14eb3fbd91d000..a184e6dd891affa 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1089,13 +1089,6 @@ class Process : public std::enable_shared_from_this, /// Returns an error object. virtual Status WillResume() { return Status(); } - /// Reports whether this process supports reverse execution. - /// - /// \return - /// Returns true if the process supports reverse execution (at least - /// under some circumstances). - virtual bool SupportsReverseDirection() { return false
[Lldb-commits] [lldb] a774de8 - Revert "Reland "[lldb] Implement basic support for reverse-continue" (#123906)"" (#125091)
Author: David Spickett Date: 2025-01-30T16:45:36Z New Revision: a774de807e56c1147d4630bfec3110c11d41776e URL: https://github.com/llvm/llvm-project/commit/a774de807e56c1147d4630bfec3110c11d41776e DIFF: https://github.com/llvm/llvm-project/commit/a774de807e56c1147d4630bfec3110c11d41776e.diff LOG: Revert "Reland "[lldb] Implement basic support for reverse-continue" (#123906)"" (#125091) Reverts llvm/llvm-project#123945 Has failed on the Windows on Arm buildbot: https://lab.llvm.org/buildbot/#/builders/141/builds/5865 ``` Unresolved Tests (2): lldb-api :: functionalities/reverse-execution/TestReverseContinueBreakpoints.py lldb-api :: functionalities/reverse-execution/TestReverseContinueWatchpoints.py Failed Tests (1): lldb-api :: functionalities/reverse-execution/TestReverseContinueNotSupported.py ``` Reverting while I reproduce locally. Added: Modified: lldb/include/lldb/API/SBProcess.h lldb/include/lldb/Target/Process.h lldb/include/lldb/Target/StopInfo.h lldb/include/lldb/Target/Thread.h lldb/include/lldb/Target/ThreadList.h lldb/include/lldb/Target/ThreadPlan.h lldb/include/lldb/Target/ThreadPlanBase.h lldb/include/lldb/lldb-enumerations.h lldb/packages/Python/lldbsuite/test/gdbclientutils.py lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py lldb/source/API/SBProcess.cpp lldb/source/API/SBThread.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp lldb/source/Plugins/Process/scripted/ScriptedProcess.h lldb/source/Target/Process.cpp lldb/source/Target/StopInfo.cpp lldb/source/Target/Thread.cpp lldb/source/Target/ThreadList.cpp lldb/source/Target/ThreadPlanBase.cpp lldb/tools/lldb-dap/JSONUtils.cpp lldb/tools/lldb-dap/LLDBUtils.cpp Removed: lldb/packages/Python/lldbsuite/test/lldbgdbproxy.py lldb/packages/Python/lldbsuite/test/lldbreverse.py lldb/test/API/functionalities/reverse-execution/Makefile lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py lldb/test/API/functionalities/reverse-execution/TestReverseContinueWatchpoints.py lldb/test/API/functionalities/reverse-execution/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 882b8bd837131d..1624e02070b1b2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -159,7 +159,6 @@ class LLDB_API SBProcess { lldb::SBError Destroy(); lldb::SBError Continue(); - lldb::SBError ContinueInDirection(lldb::RunDirection direction); lldb::SBError Stop(); diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index b14eb3fbd91d00..a184e6dd891aff 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1089,13 +1089,6 @@ class Process : public std::enable_shared_from_this, /// Returns an error object. virtual Status WillResume() { return Status(); } - /// Reports whether this process supports reverse execution. - /// - /// \return - /// Returns true if the process supports reverse execution (at least - /// under some circumstances). - virtual bool SupportsReverseDirection() { return false; } - /// Resumes all of a process's threads as configured using the Thread run /// control functions. /// @@ -,13 +1104,9 @@ class Process : public std::enable_shared_from_this, /// \see Thread:Resume() /// \see Thread:Step() /// \see Thread:Suspend() - virtual Status DoResume(lldb::RunDirection direction) { -if (direction == lldb::RunDirection::eRunForward) - return Status::FromErrorStringWithFormatv( - "error: {0} does not support resuming processes", GetPluginName()); + virtual Status DoResume() { return Status::FromErrorStringWithFormatv( -"error: {0} does not support reverse execution of processes", -GetPluginName()); +"error: {0} does not support resuming processes"
[Lldb-commits] [lldb] Revert "Reland "[lldb] Implement basic support for reverse-continue" (#123906)"" (PR #125091)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: David Spickett (DavidSpickett) Changes Reverts llvm/llvm-project#123945 Has failed on the Windows on Arm buildbot: https://lab.llvm.org/buildbot/#/builders/141/builds/5865 ``` Unresolved Tests (2): lldb-api :: functionalities/reverse-execution/TestReverseContinueBreakpoints.py lldb-api :: functionalities/reverse-execution/TestReverseContinueWatchpoints.py Failed Tests (1): lldb-api :: functionalities/reverse-execution/TestReverseContinueNotSupported.py ``` Reverting while I reproduce locally. --- Patch is 86.41 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/125091.diff 40 Files Affected: - (modified) lldb/include/lldb/API/SBProcess.h (-1) - (modified) lldb/include/lldb/Target/Process.h (+2-26) - (modified) lldb/include/lldb/Target/StopInfo.h (-7) - (modified) lldb/include/lldb/Target/Thread.h (+5-4) - (modified) lldb/include/lldb/Target/ThreadList.h (+1-5) - (modified) lldb/include/lldb/Target/ThreadPlan.h (-13) - (modified) lldb/include/lldb/Target/ThreadPlanBase.h (-2) - (modified) lldb/include/lldb/lldb-enumerations.h (-6) - (modified) lldb/packages/Python/lldbsuite/test/gdbclientutils.py (+2-3) - (removed) lldb/packages/Python/lldbsuite/test/lldbgdbproxy.py (-175) - (removed) lldb/packages/Python/lldbsuite/test/lldbreverse.py (-541) - (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (-2) - (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py (+5-9) - (modified) lldb/source/API/SBProcess.cpp (-12) - (modified) lldb/source/API/SBThread.cpp (-2) - (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+1-2) - (modified) lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp (-3) - (modified) lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp (+1-7) - (modified) lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h (+1-1) - (modified) lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp (+1-8) - (modified) lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h (+1-1) - (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (-20) - (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (-6) - (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp (-1) - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+13-85) - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (+1-3) - (modified) lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp (+2-7) - (modified) lldb/source/Plugins/Process/scripted/ScriptedProcess.h (+1-1) - (modified) lldb/source/Target/Process.cpp (+4-20) - (modified) lldb/source/Target/StopInfo.cpp (-28) - (modified) lldb/source/Target/Thread.cpp (+3-6) - (modified) lldb/source/Target/ThreadList.cpp (+3-29) - (modified) lldb/source/Target/ThreadPlanBase.cpp (-4) - (removed) lldb/test/API/functionalities/reverse-execution/Makefile (-3) - (removed) lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py (-157) - (removed) lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py (-31) - (removed) lldb/test/API/functionalities/reverse-execution/TestReverseContinueWatchpoints.py (-134) - (removed) lldb/test/API/functionalities/reverse-execution/main.c (-25) - (modified) lldb/tools/lldb-dap/JSONUtils.cpp (-3) - (modified) lldb/tools/lldb-dap/LLDBUtils.cpp (-1) ``diff diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 882b8bd837131d1..1624e02070b1b21 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -159,7 +159,6 @@ class LLDB_API SBProcess { lldb::SBError Destroy(); lldb::SBError Continue(); - lldb::SBError ContinueInDirection(lldb::RunDirection direction); lldb::SBError Stop(); diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index b14eb3fbd91d000..a184e6dd891affa 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1089,13 +1089,6 @@ class Process : public std::enable_shared_from_this, /// Returns an error object. virtual Status WillResume() { return Status(); } - /// Reports whether this process supports reverse execution. - /// - /// \return - /// Returns true if the process supports reverse execution (at least - /// under some circumstances). - virtual bool SupportsReverseDirection() { return false; } - /// Resumes all of a process's threads as configured using the Thread run /// control functions. /// @@ -,13 +1104,9 @@ class Process : public std::enable_shared_from_this, /// \see Thread:Resume() /// \see Thread:Step() /// \see Thread:Suspend() - virtual Status DoResume(lldb::RunDirection direction) { -if (dir
[Lldb-commits] [lldb] Revert "Reland "[lldb] Implement basic support for reverse-continue" (#123906)"" (PR #125091)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/125091 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (PR #123945)
DavidSpickett wrote: Arm and AArch64 Linux were fine (aside from a flaky test on the latter). Windows on Arm is complaining, I'm investigating. https://github.com/llvm/llvm-project/pull/123945 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 38cb693 - [lldb][test] explicit-member-function-quals.cpp: fix triple flag
Author: Michael Buch Date: 2025-01-30T15:09:53Z New Revision: 38cb69373eef033c219efc7aaa11b84d9b307e69 URL: https://github.com/llvm/llvm-project/commit/38cb69373eef033c219efc7aaa11b84d9b307e69 DIFF: https://github.com/llvm/llvm-project/commit/38cb69373eef033c219efc7aaa11b84d9b307e69.diff LOG: [lldb][test] explicit-member-function-quals.cpp: fix triple flag The compilation was failing because `triple` is an `Xclang` flag. The failure was hidden by the XFAIL. Added: Modified: lldb/test/Shell/SymbolFile/DWARF/x86/explicit-member-function-quals.cpp Removed: diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/explicit-member-function-quals.cpp b/lldb/test/Shell/SymbolFile/DWARF/x86/explicit-member-function-quals.cpp index bda9bb99f04a0f..103aa0a9684749 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/x86/explicit-member-function-quals.cpp +++ b/lldb/test/Shell/SymbolFile/DWARF/x86/explicit-member-function-quals.cpp @@ -3,7 +3,7 @@ // Tests that we correctly deduce the CV-quals and storage // class of explicit object member functions. // -// RUN: %clangxx_host %s -triple x86_64-pc-linux -g -std=c++23 -c -o %t +// RUN: %clangxx_host %s -target x86_64-pc-linux -g -std=c++23 -c -o %t // RUN: %lldb %t -b -o "type lookup Foo" 2>&1 | FileCheck %s // // CHECK: (lldb) type lookup Foo ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)
@@ -575,6 +575,10 @@ Changes to LLDB 24 int main() { Likely cause: f->b->d accessed 0x4 ``` +* LLDB now supports hardware watchpoints for AArch64 Windows targets. Windows + does not provide API to query the number of supported hardware watchpoints. + Therefore current implementation allows only 1 watchpoint, as tested with + Windows 11 on the Microsoft SQ2 and Snapdragon Elite X platforms. DavidSpickett wrote: Only thing I can think of is perhaps `check-lldb` at `-j1` manages to start the new processes faster than running the test using lit alone. You could try running one of the tests using lit, in a loop. But it's not like we don't have watchpoint glitches elsewhere, and if it's a kernel problem, this PR is certainly not going to fix that. So I think we say this is one more reason this feature is experimental. https://github.com/llvm/llvm-project/pull/108072 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)
omjavaid wrote: > This is a problem with watchpoints too, right? Yes this happens with watchpoints too on both AArch64 and x64 WIndows. > I can see an argument that says code breakpoints are much more likely to be > placed before the initial stop, so watchpoints are still useful even with > this limitation and this PR should still be merged. Yes because LLDB requires a running process to set watchpoints however for breakpoints thats not the case. In most cases user sets breakpoint on main and then set watchpoints which masks this problem altogether. > But please open an issue for that, describing the problem and as far as you > know. why it might be occurring. It will give us something to "mark as > duplicate" :) I have create #125054 https://github.com/llvm/llvm-project/pull/108072 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)
@@ -575,6 +575,10 @@ Changes to LLDB 24 int main() { Likely cause: f->b->d accessed 0x4 ``` +* LLDB now supports hardware watchpoints for AArch64 Windows targets. Windows + does not provide API to query the number of supported hardware watchpoints. + Therefore current implementation allows only 1 watchpoint, as tested with + Windows 11 on the Microsoft SQ2 and Snapdragon Elite X platforms. omjavaid wrote: I am not actually sure about the cause but `-j1` doesnt really fix the issue with test failures. This appears to be somehow while running the testsuite in batch mode we somehow start python with different set of permissions. Although thats just a guess I do not have evidence supporting that claim. https://github.com/llvm/llvm-project/pull/108072 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add test for detecting CV-quals of explicit object member functions (PR #125053)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/125053 >From 310d7d6362a2f36503a9d8f94713fdb16c3bf65c Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 30 Jan 2025 12:04:59 + Subject: [PATCH 1/3] [lldb][test] Add test for detecting CV-quals of explicit object member functions This is XFAILed for now until we find a good way to locate the DW_AT_object_pointer of function declarations (a possible solution being https://github.com/llvm/llvm-project/pull/124790). --- .../DWARF/explicit-member-function-quals.cpp | 22 +++ 1 file changed, 22 insertions(+) create mode 100644 lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp diff --git a/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp b/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp new file mode 100644 index 00..8e742600dc10e9 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp @@ -0,0 +1,22 @@ +// XFAIL: * + +// Tests that we correctly deduce the CV-quals and storage +// class of explicit object member functions. +// +// RUN: %clangxx_host %s -g -std=c++23 -c -o %t +// RUN: %lldb %t -b -o "type lookup Foo" 2>&1 | FileCheck %s +// +// CHECK: (lldb) type lookup Foo +// CHECK-NEXT: struct Foo { +// CHECK-NEXT: void Method(Foo); +// CHECK-NEXT: void cMethod(Foo const&); +// CHECK-NEXT: void vMethod(Foo volatile&); +// CHECK-NEXT: void cvMethod(const Foo volatile&) const volatile; +// CHECK-NEXT: } + +struct Foo { + void Method(this Foo) {} + void cMethod(this Foo const&) {} + void vMethod(this Foo volatile&) {} + void cvMethod(this Foo const volatile&) {} +} f; >From 27405d65cb112bc0ad90bd5133c7ca0a6cd8407c Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 30 Jan 2025 12:17:32 + Subject: [PATCH 2/3] fixup! clang-format --- .../SymbolFile/DWARF/explicit-member-function-quals.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp b/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp index 8e742600dc10e9..675d964323b884 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp +++ b/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp @@ -16,7 +16,7 @@ struct Foo { void Method(this Foo) {} - void cMethod(this Foo const&) {} - void vMethod(this Foo volatile&) {} - void cvMethod(this Foo const volatile&) {} + void cMethod(this Foo const &) {} + void vMethod(this Foo volatile &) {} + void cvMethod(this Foo const volatile &) {} } f; >From c0c2ba1acf588c3531d3414715ca04018c7b2d27 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 30 Jan 2025 12:31:48 + Subject: [PATCH 3/3] fixup! specify triple explicitly --- .../DWARF/{ => x86}/explicit-member-function-quals.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename lldb/test/Shell/SymbolFile/DWARF/{ => x86}/explicit-member-function-quals.cpp (89%) diff --git a/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp b/lldb/test/Shell/SymbolFile/DWARF/x86/explicit-member-function-quals.cpp similarity index 89% rename from lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp rename to lldb/test/Shell/SymbolFile/DWARF/x86/explicit-member-function-quals.cpp index 675d964323b884..bda9bb99f04a0f 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp +++ b/lldb/test/Shell/SymbolFile/DWARF/x86/explicit-member-function-quals.cpp @@ -3,7 +3,7 @@ // Tests that we correctly deduce the CV-quals and storage // class of explicit object member functions. // -// RUN: %clangxx_host %s -g -std=c++23 -c -o %t +// RUN: %clangxx_host %s -triple x86_64-pc-linux -g -std=c++23 -c -o %t // RUN: %lldb %t -b -o "type lookup Foo" 2>&1 | FileCheck %s // // CHECK: (lldb) type lookup Foo ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] LLDB: WatchAddress ignores modify option (PR #124847)
puremourning wrote: Hmm seems the behaviour on intel differs to arm. will need to think about it. https://github.com/llvm/llvm-project/pull/124847 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support CommandInterpreter print callbacks (PR #125006)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/125006 >From fdac9c0292cef848b880904cf84b2c0083065005 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 28 Jan 2025 15:43:31 -0800 Subject: [PATCH 1/5] [lldb] Fix CommandInterpreter formatting (NFC) --- .../lldb/Interpreter/CommandInterpreter.h| 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 2bafc30cc8e23a..910c1d84303354 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -100,8 +100,7 @@ class CommandInterpreterRunOptions { LazyBool stop_on_error, LazyBool stop_on_crash, LazyBool echo_commands, LazyBool echo_comments, LazyBool print_results, LazyBool print_errors, - LazyBool add_to_history, - LazyBool handle_repeats) + LazyBool add_to_history, LazyBool handle_repeats) : m_stop_on_continue(stop_on_continue), m_stop_on_error(stop_on_error), m_stop_on_crash(stop_on_crash), m_echo_commands(echo_commands), m_echo_comment_commands(echo_comments), m_print_results(print_results), @@ -248,13 +247,13 @@ class CommandInterpreter : public Broadcaster, enum CommandTypes { eCommandTypesBuiltin = 0x0001, //< native commands such as "frame" eCommandTypesUserDef = 0x0002, //< scripted commands -eCommandTypesUserMW = 0x0004, //< multiword commands (command containers) +eCommandTypesUserMW = 0x0004, //< multiword commands (command containers) eCommandTypesAliases = 0x0008, //< aliases such as "po" -eCommandTypesHidden = 0x0010, //< commands prefixed with an underscore +eCommandTypesHidden = 0x0010, //< commands prefixed with an underscore eCommandTypesAllThem = 0x //< all commands }; - // The CommandAlias and CommandInterpreter both have a hand in + // The CommandAlias and CommandInterpreter both have a hand in // substituting for alias commands. They work by writing special tokens // in the template form of the Alias command, and then detecting them when the // command is executed. These are the special tokens: @@ -334,9 +333,8 @@ class CommandInterpreter : public Broadcaster, /// dummy "contains everything MWC, so we return null here, but /// in this case error.Success is true. - CommandObjectMultiword *VerifyUserMultiwordCmdPath(Args &path, - bool leaf_is_command, - Status &result); + CommandObjectMultiword * + VerifyUserMultiwordCmdPath(Args &path, bool leaf_is_command, Status &result); CommandAlias *AddAlias(llvm::StringRef alias_name, lldb::CommandObjectSP &command_obj_sp, @@ -596,7 +594,7 @@ class CommandInterpreter : public Broadcaster, void SetEchoCommentCommands(bool enable); bool GetRepeatPreviousCommand() const; - + bool GetRequireCommandOverwrite() const; const CommandObject::CommandMap &GetUserCommands() const { >From e1e8d1487194c4e21cf9724da99588796a03883d Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 28 Jan 2025 16:10:33 -0800 Subject: [PATCH 2/5] [lldb] Constify methods in CommandReturnObject (NFC) --- lldb/include/lldb/Interpreter/CommandReturnObject.h | 10 +- lldb/include/lldb/Utility/StreamTee.h | 2 +- lldb/source/Interpreter/CommandReturnObject.cpp | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h b/lldb/include/lldb/Interpreter/CommandReturnObject.h index 9fef59337016df..f96da34889a324 100644 --- a/lldb/include/lldb/Interpreter/CommandReturnObject.h +++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h @@ -32,9 +32,9 @@ class CommandReturnObject { ~CommandReturnObject() = default; /// Format any inline diagnostics with an indentation of \c indent. - std::string GetInlineDiagnosticString(unsigned indent); + std::string GetInlineDiagnosticString(unsigned indent) const; - llvm::StringRef GetOutputString() { + llvm::StringRef GetOutputString() const { lldb::StreamSP stream_sp(m_out_stream.GetStreamAtIndex(eStreamStringIndex)); if (stream_sp) return std::static_pointer_cast(stream_sp)->GetString(); @@ -46,7 +46,7 @@ class CommandReturnObject { /// If \c with_diagnostics is true, all diagnostics are also /// rendered into the string. Otherwise the expectation is that they /// are fetched with \ref GetInlineDiagnosticString(). - std::string GetErrorString(bool with_diagnostics = true); + std::string GetErrorString(bool with_diagnostics = true) const; StructuredData:
[Lldb-commits] [lldb] [lldb] Support CommandInterpreter print callbacks (PR #125006)
@@ -743,3 +743,41 @@ void SBCommand::SetFlags(uint32_t flags) { if (IsValid()) m_opaque_sp->GetFlags().Set(flags); } + +namespace lldb_private { +struct CommandCallbackData { + SBCommandPrintCallback callback; + void *callback_baton; +}; + +class CommandPrintCallbackBaton +: public lldb_private::TypedBaton { +public: + CommandPrintCallbackBaton(SBCommandPrintCallback callback, void *baton) + : TypedBaton(std::make_unique()) { +getItem()->callback = callback; +getItem()->callback_baton = baton; + } + + static lldb::CommandReturnObjectCallbackResult + PrivateCallback(lldb_private::CommandReturnObject &result, void *baton) { +if (baton) { + CommandCallbackData *data = (CommandCallbackData *)baton; + SBCommandReturnObject sb_result(result); + return data->callback(sb_result, data->callback_baton); +} +return eCommandReturnObjectPrintCallbackSkipped; + } +}; +} // namespace lldb_private + +void SBCommandInterpreter::SetPrintCallback( +lldb::SBCommandPrintCallback callback, void *baton) { + LLDB_INSTRUMENT_VA(this, callback, baton); + + BatonSP baton_sp = + std::make_shared(callback, baton); JDevlieghere wrote: Good point, I was mimicking what we do for breakpoint callbacks. I suspect we could simplify that with the same trick. Updated the PR. https://github.com/llvm/llvm-project/pull/125006 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add test for detecting CV-quals of explicit object member functions (PR #125053)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff b68b4f64a2bd2e0a22375cf89a4d655fc3667e11 310d7d6362a2f36503a9d8f94713fdb16c3bf65c --extensions cpp -- lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp b/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp index 8e742600dc..675d964323 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp +++ b/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp @@ -16,7 +16,7 @@ struct Foo { void Method(this Foo) {} - void cMethod(this Foo const&) {} - void vMethod(this Foo volatile&) {} - void cvMethod(this Foo const volatile&) {} + void cMethod(this Foo const &) {} + void vMethod(this Foo volatile &) {} + void cvMethod(this Foo const volatile &) {} } f; `` https://github.com/llvm/llvm-project/pull/125053 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add test for detecting CV-quals of explicit object member functions (PR #125053)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/125053 >From 310d7d6362a2f36503a9d8f94713fdb16c3bf65c Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 30 Jan 2025 12:04:59 + Subject: [PATCH 1/2] [lldb][test] Add test for detecting CV-quals of explicit object member functions This is XFAILed for now until we find a good way to locate the DW_AT_object_pointer of function declarations (a possible solution being https://github.com/llvm/llvm-project/pull/124790). --- .../DWARF/explicit-member-function-quals.cpp | 22 +++ 1 file changed, 22 insertions(+) create mode 100644 lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp diff --git a/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp b/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp new file mode 100644 index 00..8e742600dc10e9 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp @@ -0,0 +1,22 @@ +// XFAIL: * + +// Tests that we correctly deduce the CV-quals and storage +// class of explicit object member functions. +// +// RUN: %clangxx_host %s -g -std=c++23 -c -o %t +// RUN: %lldb %t -b -o "type lookup Foo" 2>&1 | FileCheck %s +// +// CHECK: (lldb) type lookup Foo +// CHECK-NEXT: struct Foo { +// CHECK-NEXT: void Method(Foo); +// CHECK-NEXT: void cMethod(Foo const&); +// CHECK-NEXT: void vMethod(Foo volatile&); +// CHECK-NEXT: void cvMethod(const Foo volatile&) const volatile; +// CHECK-NEXT: } + +struct Foo { + void Method(this Foo) {} + void cMethod(this Foo const&) {} + void vMethod(this Foo volatile&) {} + void cvMethod(this Foo const volatile&) {} +} f; >From 27405d65cb112bc0ad90bd5133c7ca0a6cd8407c Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 30 Jan 2025 12:17:32 + Subject: [PATCH 2/2] fixup! clang-format --- .../SymbolFile/DWARF/explicit-member-function-quals.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp b/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp index 8e742600dc10e9..675d964323b884 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp +++ b/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp @@ -16,7 +16,7 @@ struct Foo { void Method(this Foo) {} - void cMethod(this Foo const&) {} - void vMethod(this Foo volatile&) {} - void cvMethod(this Foo const volatile&) {} + void cMethod(this Foo const &) {} + void vMethod(this Foo volatile &) {} + void cvMethod(this Foo const volatile &) {} } f; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add test for detecting CV-quals of explicit object member functions (PR #125053)
@@ -0,0 +1,22 @@ +// XFAIL: * + +// Tests that we correctly deduce the CV-quals and storage +// class of explicit object member functions. +// +// RUN: %clangxx_host %s -g -std=c++23 -c -o %t labath wrote: I *think* you need -gdwarf to produce dwarf on windows. But maybe it's better to hardcode your favourite triple for reproducibility? https://github.com/llvm/llvm-project/pull/125053 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add test for detecting CV-quals of explicit object member functions (PR #125053)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/125053 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for gdb-style 'x' packet (PR #124733)
@@ -0,0 +1,36 @@ +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase + + +class TestReadMemory(GDBRemoteTestBase): +def test_x_with_prefix(self): +class MyResponder(MockGDBServerResponder): +def qSupported(self, client_features): +return super().qSupported(client_features) + ";binary-upload+" + +def x(self, addr, length): +return "bfoobar" if addr == 0x1000 else "E01" labath wrote: Yeah, I think that's enough. I generally try to avoid raising errors from the mock server runs, as it runs on a different thread, and the result of its abrupt termination isn't pretty. https://github.com/llvm/llvm-project/pull/124733 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for gdb-style 'x' packet (PR #124733)
@@ -0,0 +1,36 @@ +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase + + +class TestReadMemory(GDBRemoteTestBase): +def test_x_with_prefix(self): +class MyResponder(MockGDBServerResponder): +def qSupported(self, client_features): +return super().qSupported(client_features) + ";binary-upload+" + +def x(self, addr, length): +return "bfoobar" if addr == 0x1000 else "E01" + +self.server.responder = MyResponder() +target = self.dbg.CreateTargetWithFileAndTargetTriple("", "x86_64-pc-linux") +process = self.connect(target) + +error = lldb.SBError() +self.assertEqual(b"foobar", process.ReadMemory(0x1000, 10, error)) + +def test_x_bare(self): +class MyResponder(MockGDBServerResponder): +def x(self, addr, length): +if addr == 0 and length == 0: +return "OK" +return "foobar" if addr == 0x1000 else "E01" + +self.server.responder = MyResponder() +target = self.dbg.CreateTargetWithFileAndTargetTriple("", "x86_64-pc-linux") +process = self.connect(target) + +error = lldb.SBError() +self.assertEqual(b"foobar", process.ReadMemory(0x1000, 10, error)) labath wrote: Sort of is, but I can squeeze it in as its very easy. https://github.com/llvm/llvm-project/pull/124733 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4b57236 - [lldb][test] Add test for detecting CV-quals of explicit object member functions (#125053)
Author: Michael Buch Date: 2025-01-30T12:50:57Z New Revision: 4b57236bace610d3b05dbba0e9f5b11ed3a9fbee URL: https://github.com/llvm/llvm-project/commit/4b57236bace610d3b05dbba0e9f5b11ed3a9fbee DIFF: https://github.com/llvm/llvm-project/commit/4b57236bace610d3b05dbba0e9f5b11ed3a9fbee.diff LOG: [lldb][test] Add test for detecting CV-quals of explicit object member functions (#125053) This is XFAILed for now until we find a good way to locate the DW_AT_object_pointer of function declarations (a possible solution being https://github.com/llvm/llvm-project/pull/124790). Made it a shell test because I couldn't find any SBAPIs that i could query to find the CV-qualifiers/etc. of member functions. Added: lldb/test/Shell/SymbolFile/DWARF/x86/explicit-member-function-quals.cpp Modified: Removed: diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/explicit-member-function-quals.cpp b/lldb/test/Shell/SymbolFile/DWARF/x86/explicit-member-function-quals.cpp new file mode 100644 index 00..bda9bb99f04a0f --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/x86/explicit-member-function-quals.cpp @@ -0,0 +1,22 @@ +// XFAIL: * + +// Tests that we correctly deduce the CV-quals and storage +// class of explicit object member functions. +// +// RUN: %clangxx_host %s -triple x86_64-pc-linux -g -std=c++23 -c -o %t +// RUN: %lldb %t -b -o "type lookup Foo" 2>&1 | FileCheck %s +// +// CHECK: (lldb) type lookup Foo +// CHECK-NEXT: struct Foo { +// CHECK-NEXT: void Method(Foo); +// CHECK-NEXT: void cMethod(Foo const&); +// CHECK-NEXT: void vMethod(Foo volatile&); +// CHECK-NEXT: void cvMethod(const Foo volatile&) const volatile; +// CHECK-NEXT: } + +struct Foo { + void Method(this Foo) {} + void cMethod(this Foo const &) {} + void vMethod(this Foo volatile &) {} + void cvMethod(this Foo const volatile &) {} +} f; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add test for detecting CV-quals of explicit object member functions (PR #125053)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/125053 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for gdb-style 'x' packet (PR #124733)
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/124733 >From bf011ccc02c0122e7dfd74e089143eb833c1686e Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 28 Jan 2025 12:27:46 +0100 Subject: [PATCH 1/2] [lldb] Add support for gdb-style 'x' packet DO NOT SUBMIT until the mechanism for detection of the packet format is confirmed. --- .../Python/lldbsuite/test/gdbclientutils.py | 6 .../GDBRemoteCommunicationClient.cpp | 22 +++- .../gdb-remote/GDBRemoteCommunicationClient.h | 9 +++-- .../Process/gdb-remote/ProcessGDBRemote.cpp | 36 --- .../gdb_remote_client/TestReadMemory.py | 36 +++ 5 files changed, 85 insertions(+), 24 deletions(-) create mode 100644 lldb/test/API/functionalities/gdb_remote_client/TestReadMemory.py diff --git a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py index 1784487323ad6b..4b782b3b470fe2 100644 --- a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py +++ b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py @@ -126,6 +126,9 @@ def respond(self, packet): if packet[0] == "m": addr, length = [int(x, 16) for x in packet[1:].split(",")] return self.readMemory(addr, length) +if packet[0] == "x": +addr, length = [int(x, 16) for x in packet[1:].split(",")] +return self.x(addr, length) if packet[0] == "M": location, encoded_data = packet[1:].split(":") addr, length = [int(x, 16) for x in location.split(",")] @@ -267,6 +270,9 @@ def writeRegister(self, register, value_hex): def readMemory(self, addr, length): return "00" * length +def x(self, addr, length): +return "" + def writeMemory(self, addr, data_hex): return "OK" diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index b3f1c6f052955b..581dd8f8e0b6b6 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -275,7 +275,6 @@ void GDBRemoteCommunicationClient::ResetDiscoverableSettings(bool did_exec) { m_supports_vCont_s = eLazyBoolCalculate; m_supports_vCont_S = eLazyBoolCalculate; m_supports_p = eLazyBoolCalculate; -m_supports_x = eLazyBoolCalculate; m_supports_QSaveRegisterState = eLazyBoolCalculate; m_qHostInfo_is_valid = eLazyBoolCalculate; m_curr_pid_is_valid = eLazyBoolCalculate; @@ -295,6 +294,7 @@ void GDBRemoteCommunicationClient::ResetDiscoverableSettings(bool did_exec) { m_supports_qXfer_siginfo_read = eLazyBoolCalculate; m_supports_augmented_libraries_svr4_read = eLazyBoolCalculate; m_uses_native_signals = eLazyBoolCalculate; +m_x_packet_state.reset(); m_supports_qProcessInfoPID = true; m_supports_qfProcessInfo = true; m_supports_qUserName = true; @@ -348,6 +348,7 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { m_supports_memory_tagging = eLazyBoolNo; m_supports_qSaveCore = eLazyBoolNo; m_uses_native_signals = eLazyBoolNo; + m_x_packet_state.reset(); m_max_packet_size = UINT64_MAX; // It's supposed to always be there, but if // not, we assume no limit @@ -401,6 +402,8 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { m_supports_qSaveCore = eLazyBoolYes; else if (x == "native-signals+") m_uses_native_signals = eLazyBoolYes; + else if (x == "binary-upload+") +m_x_packet_state = xPacketState::Prefixed; // Look for a list of compressions in the features list e.g. // qXfer:features:read+;PacketSize=2;qEcho+;SupportedCompressions=zlib- // deflate,lzma @@ -715,19 +718,20 @@ Status GDBRemoteCommunicationClient::WriteMemoryTags( return status; } -bool GDBRemoteCommunicationClient::GetxPacketSupported() { - if (m_supports_x == eLazyBoolCalculate) { +GDBRemoteCommunicationClient::xPacketState +GDBRemoteCommunicationClient::GetxPacketState() { + if (!m_x_packet_state) +GetRemoteQSupported(); + if (!m_x_packet_state) { StringExtractorGDBRemote response; -m_supports_x = eLazyBoolNo; -char packet[256]; -snprintf(packet, sizeof(packet), "x0,0"); -if (SendPacketAndWaitForResponse(packet, response) == +m_x_packet_state = xPacketState::Unimplemented; +if (SendPacketAndWaitForResponse("x0,0", response) == PacketResult::Success) { if (response.IsOKResponse()) -m_supports_x = eLazyBoolYes; +m_x_packet_state = xPacketState::Bare; } } - return m_supports_x; + return *m_x_packet_state; } lldb::pid_t GDBRemoteCommunicationClient::GetCurrentProcessID(bool allow_lazy) { diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemot
[Lldb-commits] [lldb] [llvm] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)
DavidSpickett wrote: Also thanks for tackling this, I know I said once (possibly twice) that I'd do it but kept getting distracted. I know you put a bunch of research time into this too. https://github.com/llvm/llvm-project/pull/108072 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)
https://github.com/DavidSpickett approved this pull request. We're hitting limitations in Windows itself, and 1 watchpoint is more useful than zero, so this LGTM. To preempt a potential discussion: I think this should not be backported to 20. Unless you've got a very good reason for it. We don't have the most comprehensive testing on Windows and we already have a few caveats here. We might encounter more as time goes on and fixes may be complex. But, by LLDB 21, maybe we will have ironed those out. https://github.com/llvm/llvm-project/pull/108072 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0caba6c - Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (#123945)
Author: David Spickett Date: 2025-01-30T14:03:01Z New Revision: 0caba6c8dc2f6f0da61f30c169f59d40591cddbc URL: https://github.com/llvm/llvm-project/commit/0caba6c8dc2f6f0da61f30c169f59d40591cddbc DIFF: https://github.com/llvm/llvm-project/commit/0caba6c8dc2f6f0da61f30c169f59d40591cddbc.diff LOG: Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (#123945) This reverts commit 22561cfb443267905d4190f0e2a738e6b412457f and fixes b7b9ccf44988edf49886743ae5c3cf4184db211f (#112079). The problem is that x86_64 and Arm 32-bit have memory regions above the stack that are readable but not writeable. First Arm: ``` (lldb) memory region --all <...> [0xfffcf000-0x) rw- [stack] [0x-0x1000) r-x [vectors] [0x1000-0x) --- ``` Then x86_64: ``` $ cat /proc/self/maps <...> 7ffdcd148000-7ffdcd16a000 rw-p 00:00 0 [stack] 7ffdcd193000-7ffdcd196000 r--p 00:00 0 [vvar] 7ffdcd196000-7ffdcd197000 r-xp 00:00 0 [vdso] ff60-ff601000 --xp 00:00 0 [vsyscall] ``` Compare this to AArch64 where the test did pass: ``` $ cat /proc/self/maps <...> b87dc000-b87dd000 r--p 00:00 0 [vvar] b87dd000-b87de000 r-xp 00:00 0 [vdso] b87de000-b87e r--p 0002a000 00:3c 76927217 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 b87e-b87e2000 rw-p 0002c000 00:3c 76927217 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 f4216000-f4237000 rw-p 00:00 0 [stack] ``` To solve this, look up the memory region of the stack pointer (using https://lldb.llvm.org/resources/lldbgdbremote.html#qmemoryregioninfo-addr) and constrain the read to within that region. Since we know the stack is all readable and writeable. I have also added skipIfRemote to the tests, since getting them working in that context is too complex to be worth it. Memory write failures now display the range they tried to write, and register write errors will show the name of the register where possible. The patch also includes a workaround for a an issue where the test code could mistake an `x` response that happens to begin with an `O` for an output packet (stdout). This workaround will not be necessary one we start using the [new implementation](https://discourse.llvm.org/t/rfc-fixing-incompatibilties-of-the-x-packet-w-r-t-gdb/84288) of the `x` packet. - Co-authored-by: Pavel Labath Added: lldb/packages/Python/lldbsuite/test/lldbgdbproxy.py lldb/packages/Python/lldbsuite/test/lldbreverse.py lldb/test/API/functionalities/reverse-execution/Makefile lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py lldb/test/API/functionalities/reverse-execution/TestReverseContinueWatchpoints.py lldb/test/API/functionalities/reverse-execution/main.c Modified: lldb/include/lldb/API/SBProcess.h lldb/include/lldb/Target/Process.h lldb/include/lldb/Target/StopInfo.h lldb/include/lldb/Target/Thread.h lldb/include/lldb/Target/ThreadList.h lldb/include/lldb/Target/ThreadPlan.h lldb/include/lldb/Target/ThreadPlanBase.h lldb/include/lldb/lldb-enumerations.h lldb/packages/Python/lldbsuite/test/gdbclientutils.py lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py lldb/source/API/SBProcess.cpp lldb/source/API/SBThread.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp lldb/source/Plugins/Process/scripted/ScriptedProcess.h lldb/source/Target/Process.cpp lldb/source/Target/StopInfo.cpp lldb/source/Target/Thread.cpp lldb/source/Target/ThreadList.cpp lldb/source/Target/ThreadPlanBase.cpp lldb/tools/lldb-dap/JSONUtils.cpp lldb/tools/lldb-dap/LLDBUtils.cpp Removed: diff --git a/lldb/inc
[Lldb-commits] [lldb] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (PR #123945)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/123945 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (PR #123945)
DavidSpickett wrote: My inbox is ready :) https://github.com/llvm/llvm-project/pull/123945 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)
DavidSpickett wrote: > In most cases user sets breakpoint on main and then set watchpoints which > masks this problem altogether. Agreed, this isn't ideal but it is an improvement from the current features. https://github.com/llvm/llvm-project/pull/108072 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for gdb-style 'x' packet (PR #124733)
@@ -0,0 +1,36 @@ +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase + + +class TestReadMemory(GDBRemoteTestBase): +def test_x_with_prefix(self): +class MyResponder(MockGDBServerResponder): +def qSupported(self, client_features): +return super().qSupported(client_features) + ";binary-upload+" + +def x(self, addr, length): +return "bfoobar" if addr == 0x1000 else "E01" DavidSpickett wrote: Oh right yeah, I've had it stall for ages while it realises what happened. Best avoided then. https://github.com/llvm/llvm-project/pull/124733 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for gdb-style 'x' packet (PR #124733)
https://github.com/DavidSpickett approved this pull request. LGTM, thanks for handling this. Maybe the final say goes to @rocallahan since `rr` is the origin of the issue? We have to wait on GDB for a bit anyway I expect. https://github.com/llvm/llvm-project/pull/124733 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)
DavidSpickett wrote: I want to be 100% sure of the status of this issue: > Initial Stop Behavior: Hardware breakpoints or watchpoints set on the initial > stop do not trigger, even though they are correctly written to the Windows > context. They only trigger if set after the main program has started. This > issue causes the test suite to fail when it attempts to set hardware > breakpoints on the main function before running, as these do not get > triggered. This is a problem with watchpoints too, right? I can see an argument that says code breakpoints are much more likely to be placed before the initial stop, so watchpoints are still useful even with this limitation and this PR should still be merged. But please open an issue for that, describing the problem and as far as you know. why it might be occurring. It will give us something to "mark as duplicate" :) https://github.com/llvm/llvm-project/pull/108072 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix "in function" detection in "thread until" (PR #123622)
@@ -1007,29 +1009,29 @@ class CommandObjectThreadUntil : public CommandObjectParsed { addr_t address = line_entry.range.GetBaseAddress().GetLoadAddress(target); if (address != LLDB_INVALID_ADDRESS) { - if (fun_addr_range.ContainsLoadAddress(address, target)) + AddressRange unused; + if (sc.function->GetRangeContainingLoadAddress(address, *target, + unused)) address_list.push_back(address); - else -all_in_function = false; } start_idx_ptr++; } } for (lldb::addr_t address : m_options.m_until_addrs) { - if (fun_addr_range.ContainsLoadAddress(address, target)) + AddressRange unused; + if (sc.function->GetRangeContainingLoadAddress(address, *target, + unused)) address_list.push_back(address); - else -all_in_function = false; } if (address_list.empty()) { labath wrote: I don't think so. address_list being empty is the "error" case. In case of success, the full list of addressed is used for stepping (line 1040) https://github.com/llvm/llvm-project/pull/123622 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] LLDB: WatchAddress ignores modify option (PR #124847)
puremourning wrote: > This looks good to me, thanks for fixing this. This method used to take two > bools, `read`, and `write`, I redefined the second to `modified` when I > changed the default watchpoints to be modify-style. The method previously had > a block doing > > ``` > -uint32_t watch_type = 0; > -if (read) > - watch_type |= LLDB_WATCH_TYPE_READ; > -if (write) > - watch_type |= LLDB_WATCH_TYPE_WRITE; > ``` > > and in rewriting this to set an SBWatchpointOptions object, I didn't update > it correctly to allow someone to request a read-only watchpoint. The test > cases look good, thanks for taking the time to write those. I'd address the > nit Jonas pointed out. Thanks, yeah I figured. Nit squashed. https://github.com/llvm/llvm-project/pull/124847 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix "in function" detection in "thread until" (PR #123622)
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/123622 >From 0a80b7a54b49de65758ab48acdb6d92f9b674d71 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 20 Jan 2025 15:03:14 +0100 Subject: [PATCH 1/4] [lldb] Fix "in function" detection in "thread until" The implementation has an optimization which detects the range of line table entries covered by the function and then only searches for a matching line between them. This optimization was interfering with the logic for detecting whether a line belongs to the function because the first call to FindLineEntry was made with exact=false, which meant that if the function did not contain any exact matches, we would just pick the closest line number in that range, even if it was very far away. This patch fixes that by first attempting an inexact search across the entire line table, and then use the (potentially inexact) result of that for searching within the function. This makes the optimization a less effective, but I don't think we can differentiate between a line that belongs to the function (but doesn't have any code) and a line outside the function without that. The patch also avoids the use of (deprecated) Function::GetAddressRange by iterating over the GetAddressRanges result to find the full range of line entries for the function. --- lldb/source/Commands/CommandObjectThread.cpp | 57 ++- .../thread/step_until/TestStepUntil.py| 38 - 2 files changed, 65 insertions(+), 30 deletions(-) diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 4e2c4c1126bc3f..829abb8c5839bb 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -959,7 +959,6 @@ class CommandObjectThreadUntil : public CommandObjectParsed { } LineEntry function_start; -uint32_t index_ptr = 0, end_ptr = UINT32_MAX; std::vector address_list; // Find the beginning & end index of the function, but first make @@ -970,19 +969,22 @@ class CommandObjectThreadUntil : public CommandObjectParsed { return; } -AddressRange fun_addr_range = sc.function->GetAddressRange(); -Address fun_start_addr = fun_addr_range.GetBaseAddress(); -line_table->FindLineEntryByAddress(fun_start_addr, function_start, - &index_ptr); -Address fun_end_addr(fun_start_addr.GetSection(), - fun_start_addr.GetOffset() + - fun_addr_range.GetByteSize()); +uint32_t lowest_func_idx = UINT32_MAX; +uint32_t highest_func_idx = 0; +for (AddressRange range : sc.function->GetAddressRanges()) { + uint32_t idx; + LineEntry unused; + Address addr = range.GetBaseAddress(); + if (line_table->FindLineEntryByAddress(addr, unused, &idx)) +lowest_func_idx = std::min(lowest_func_idx, idx); -bool all_in_function = true; + addr.Slide(range.GetByteSize()); + if (line_table->FindLineEntryByAddress(addr, unused, &idx)) +highest_func_idx = std::max(highest_func_idx, idx); +} -line_table->FindLineEntryByAddress(fun_end_addr, function_start, - &end_ptr); +bool found_something = false; // Since not all source lines will contribute code, check if we are // setting the breakpoint on the exact line number or the nearest @@ -991,14 +993,15 @@ class CommandObjectThreadUntil : public CommandObjectParsed { for (uint32_t line_number : line_numbers) { LineEntry line_entry; bool exact = false; - uint32_t start_idx_ptr = index_ptr; - start_idx_ptr = sc.comp_unit->FindLineEntry( - index_ptr, line_number, nullptr, exact, &line_entry); - if (start_idx_ptr != UINT32_MAX) -line_number = line_entry.line; + if (sc.comp_unit->FindLineEntry(0, line_number, nullptr, exact, + &line_entry) == UINT32_MAX) +continue; + + found_something = true; + line_number = line_entry.line; exact = true; - start_idx_ptr = index_ptr; - while (start_idx_ptr <= end_ptr) { + uint32_t start_idx_ptr = lowest_func_idx; + while (start_idx_ptr <= highest_func_idx) { start_idx_ptr = sc.comp_unit->FindLineEntry( start_idx_ptr, line_number, nullptr, exact, &line_entry); if (start_idx_ptr == UINT32_MAX) @@ -1007,29 +1010,29 @@ class CommandObjectThreadUntil : public CommandObjectParsed { addr_t address = line_entry.range.GetBaseAddress().GetLoadAddress(target); if (address != LLDB_INVALID_ADDRESS) { - if (fun_addr_range.Cont
[Lldb-commits] [lldb] LLDB: WatchAddress ignores modify option (PR #124847)
puremourning wrote: OK so the test is failing on CI, that's bad news. will check ``` FAIL: LLDB (/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-j6q2n-1/llvm-project/github-pull-requests/build/bin/clang-x86_64) :: test_read_watchpoint_watch_address (TestWatchpointRead.SetReadOnlyWatchpointTestCase) FAIL: LLDB (/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-j6q2n-1/llvm-project/github-pull-requests/build/bin/clang-x86_64) :: test_read_watchpoint_watch_create_by_address (TestWatchpointRead.SetReadOnlyWatchpointTestCase) == FAIL: test_read_watchpoint_watch_address (TestWatchpointRead.SetReadOnlyWatchpointTestCase) -- Traceback (most recent call last): File "/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-j6q2n-1/llvm-project/github-pull-requests/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py", line 69, in test_read_watchpoint_watch_address self.assertTrue( AssertionError: False is not true : The local variable has been incremented Config=x86_64-/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-j6q2n-1/llvm-project/github-pull-requests/build/bin/clang == FAIL: test_read_watchpoint_watch_create_by_address (TestWatchpointRead.SetReadOnlyWatchpointTestCase) -- Traceback (most recent call last): File "/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-j6q2n-1/llvm-project/github-pull-requests/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py", line 123, in test_read_watchpoint_watch_create_by_address self.assertTrue( AssertionError: False is not true : The local variable has been incremented Config=x86_64-/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-j6q2n-1/llvm-project/github-pull-requests/build/bin/clang -- Ran 2 tests in 0.908s ``` https://github.com/llvm/llvm-project/pull/124847 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix "in function" detection in "thread until" (PR #123622)
@@ -970,19 +969,21 @@ class CommandObjectThreadUntil : public CommandObjectParsed { return; } -AddressRange fun_addr_range = sc.function->GetAddressRange(); -Address fun_start_addr = fun_addr_range.GetBaseAddress(); -line_table->FindLineEntryByAddress(fun_start_addr, function_start, - &index_ptr); - -Address fun_end_addr(fun_start_addr.GetSection(), - fun_start_addr.GetOffset() + - fun_addr_range.GetByteSize()); - -bool all_in_function = true; +uint32_t lowest_func_idx = UINT32_MAX; +uint32_t highest_func_idx = 0; +for (AddressRange range : sc.function->GetAddressRanges()) { + uint32_t idx; + LineEntry unused; + Address addr = range.GetBaseAddress(); + if (line_table->FindLineEntryByAddress(addr, unused, &idx)) +lowest_func_idx = std::min(lowest_func_idx, idx); + + addr.Slide(range.GetByteSize() - 1); labath wrote: I think the new version might be even better (or at least, more similar to what was happening with the single range). Let me know what you think. https://github.com/llvm/llvm-project/pull/123622 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (PR #123945)
labath wrote: > @labath does this pass on x86-via-Rosetta Mac? Should we retry merging with > this change? Yes, it passes on Rosetta. I think we're ready for another try :) https://github.com/llvm/llvm-project/pull/123945 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix "in function" detection in "thread until" (PR #123622)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/123622 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add test for detecting CV-quals of explicit object member functions (PR #125053)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/125053 This is XFAILed for now until we find a good way to locate the DW_AT_object_pointer of function declarations (a possible solution being https://github.com/llvm/llvm-project/pull/124790). Made it a shell test because I couldn't find any SBAPIs that i could query to find the CV-qualifiers/etc. of member functions. >From 310d7d6362a2f36503a9d8f94713fdb16c3bf65c Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 30 Jan 2025 12:04:59 + Subject: [PATCH] [lldb][test] Add test for detecting CV-quals of explicit object member functions This is XFAILed for now until we find a good way to locate the DW_AT_object_pointer of function declarations (a possible solution being https://github.com/llvm/llvm-project/pull/124790). --- .../DWARF/explicit-member-function-quals.cpp | 22 +++ 1 file changed, 22 insertions(+) create mode 100644 lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp diff --git a/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp b/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp new file mode 100644 index 00..8e742600dc10e9 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp @@ -0,0 +1,22 @@ +// XFAIL: * + +// Tests that we correctly deduce the CV-quals and storage +// class of explicit object member functions. +// +// RUN: %clangxx_host %s -g -std=c++23 -c -o %t +// RUN: %lldb %t -b -o "type lookup Foo" 2>&1 | FileCheck %s +// +// CHECK: (lldb) type lookup Foo +// CHECK-NEXT: struct Foo { +// CHECK-NEXT: void Method(Foo); +// CHECK-NEXT: void cMethod(Foo const&); +// CHECK-NEXT: void vMethod(Foo volatile&); +// CHECK-NEXT: void cvMethod(const Foo volatile&) const volatile; +// CHECK-NEXT: } + +struct Foo { + void Method(this Foo) {} + void cMethod(this Foo const&) {} + void vMethod(this Foo volatile&) {} + void cvMethod(this Foo const volatile&) {} +} f; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add test for detecting CV-quals of explicit object member functions (PR #125053)
@@ -0,0 +1,22 @@ +// XFAIL: * + +// Tests that we correctly deduce the CV-quals and storage +// class of explicit object member functions. +// +// RUN: %clangxx_host %s -g -std=c++23 -c -o %t +// RUN: %lldb %t -b -o "type lookup Foo" 2>&1 | FileCheck %s +// +// CHECK: (lldb) type lookup Foo +// CHECK-NEXT: struct Foo { +// CHECK-NEXT: void Method(Foo); +// CHECK-NEXT: void cMethod(Foo const&); +// CHECK-NEXT: void vMethod(Foo volatile&); +// CHECK-NEXT: void cvMethod(const Foo volatile&) const volatile; Michael137 wrote: The representation here doesn't look right also. But that's a separate bug probably with the AST that LLDB creates https://github.com/llvm/llvm-project/pull/125053 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add test for detecting CV-quals of explicit object member functions (PR #125053)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes This is XFAILed for now until we find a good way to locate the DW_AT_object_pointer of function declarations (a possible solution being https://github.com/llvm/llvm-project/pull/124790). Made it a shell test because I couldn't find any SBAPIs that i could query to find the CV-qualifiers/etc. of member functions. --- Full diff: https://github.com/llvm/llvm-project/pull/125053.diff 1 Files Affected: - (added) lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp (+22) ``diff diff --git a/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp b/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp new file mode 100644 index 00..8e742600dc10e9 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/explicit-member-function-quals.cpp @@ -0,0 +1,22 @@ +// XFAIL: * + +// Tests that we correctly deduce the CV-quals and storage +// class of explicit object member functions. +// +// RUN: %clangxx_host %s -g -std=c++23 -c -o %t +// RUN: %lldb %t -b -o "type lookup Foo" 2>&1 | FileCheck %s +// +// CHECK: (lldb) type lookup Foo +// CHECK-NEXT: struct Foo { +// CHECK-NEXT: void Method(Foo); +// CHECK-NEXT: void cMethod(Foo const&); +// CHECK-NEXT: void vMethod(Foo volatile&); +// CHECK-NEXT: void cvMethod(const Foo volatile&) const volatile; +// CHECK-NEXT: } + +struct Foo { + void Method(this Foo) {} + void cMethod(this Foo const&) {} + void vMethod(this Foo volatile&) {} + void cvMethod(this Foo const volatile&) {} +} f; `` https://github.com/llvm/llvm-project/pull/125053 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support CommandInterpreter print callbacks (PR #125006)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/125006 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support CommandInterpreter print callbacks (PR #125006)
@@ -743,3 +743,41 @@ void SBCommand::SetFlags(uint32_t flags) { if (IsValid()) m_opaque_sp->GetFlags().Set(flags); } + +namespace lldb_private { +struct CommandCallbackData { + SBCommandPrintCallback callback; + void *callback_baton; +}; + +class CommandPrintCallbackBaton +: public lldb_private::TypedBaton { +public: + CommandPrintCallbackBaton(SBCommandPrintCallback callback, void *baton) + : TypedBaton(std::make_unique()) { +getItem()->callback = callback; +getItem()->callback_baton = baton; + } + + static lldb::CommandReturnObjectCallbackResult + PrivateCallback(lldb_private::CommandReturnObject &result, void *baton) { +if (baton) { + CommandCallbackData *data = (CommandCallbackData *)baton; + SBCommandReturnObject sb_result(result); + return data->callback(sb_result, data->callback_baton); +} +return eCommandReturnObjectPrintCallbackSkipped; + } +}; +} // namespace lldb_private + +void SBCommandInterpreter::SetPrintCallback( +lldb::SBCommandPrintCallback callback, void *baton) { + LLDB_INSTRUMENT_VA(this, callback, baton); + + BatonSP baton_sp = + std::make_shared(callback, baton); labath wrote: I know this is here as a form of dependency inversion, and that we have this Baton thingy already, but it all fields unnecessarily elaborate. Couldn't the private callback type be a `std::function`, and just wrap things in a lambda? https://github.com/llvm/llvm-project/pull/125006 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support CommandInterpreter print callbacks (PR #125006)
@@ -0,0 +1,66 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class BreakpointAPITestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def run_command_interpreter_with_output_file(self, out_filename, input_str): +with open(out_filename, "w") as f: +self.dbg.SetOutputFileHandle(f, False) +self.dbg.SetInputString(input_str) +opts = lldb.SBCommandInterpreterRunOptions() +self.dbg.RunCommandInterpreter(True, False, opts, 0, False, False) + +def test_command_interpreter_print_callback(self): +"""Make sure that if an SBBreakpoint gets deleted its IsValid returns false.""" +self.build() +exe = self.getBuildArtifact("a.out") + +target = self.dbg.CreateTarget(exe) +self.assertTrue(target, VALID_TARGET) + +lldbutil.run_to_source_breakpoint( +self, "// Break here", lldb.SBFileSpec("main.c") +) + +out_filename = self.getBuildArtifact("output") +ci = self.dbg.GetCommandInterpreter() +called = False + +# The string we'll be looking for in the command output. +needle = "Show a list of all debugger commands" + +# Test registering a callback that handles the printing. Make sure the +# result is passed to the callback and that we don't print the result. +def handling_callback(return_object): +nonlocal called labath wrote: TIL https://github.com/llvm/llvm-project/pull/125006 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support CommandInterpreter print callbacks (PR #125006)
https://github.com/labath commented: It's not clear from the patch description whether you actually need the ability to suppress the command output, or if you just want the ability to "access" the diagnostics. Because, if its the latter, then perhaps an (async) event would be a slightly more lightweight alternative? https://github.com/llvm/llvm-project/pull/125006 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (PR #123945)
labath wrote: Done. https://github.com/llvm/llvm-project/pull/123945 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (PR #123945)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/123945 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] LLDB: WatchAddress ignores modify option (PR #124847)
https://github.com/puremourning updated https://github.com/llvm/llvm-project/pull/124847 >From 169a8d84d4af08218227058db4968bed9fc701eb Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Tue, 28 Jan 2025 21:47:24 + Subject: [PATCH] LLDB: WatchAddress ignores modify option The WatchAddress API includes a flag to indicate if watchpoint should be for read, modify or both. This API uses 2 booleans, but the 'modify' flag was ignored and WatchAddress unconditionally watched write (actually modify). We now only watch for modify when the modify flag is true. --- lldb/source/API/SBTarget.cpp | 3 +- .../watchpoint/TestWatchpointRead.py | 125 ++ .../watchlocation/TestTargetWatchAddress.py | 71 +- 3 files changed, 197 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/watchpoint/TestWatchpointRead.py diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 2a33161bc21edc..dd9caa724ea362 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -1342,7 +1342,8 @@ lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, SBWatchpointOptions options; options.SetWatchpointTypeRead(read); - options.SetWatchpointTypeWrite(eWatchpointWriteTypeOnModify); + if (modify) +options.SetWatchpointTypeWrite(eWatchpointWriteTypeOnModify); return WatchpointCreateByAddress(addr, size, options, error); } diff --git a/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py b/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py new file mode 100644 index 00..c0d06e41faea47 --- /dev/null +++ b/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py @@ -0,0 +1,125 @@ +""" +Use lldb Python SBTarget API to set read watchpoints +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class SetReadOnlyWatchpointTestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def setUp(self): +# Call super's setUp(). +TestBase.setUp(self) +# Our simple source filename. +self.source = "main.c" +# Find the line number to break inside main(). +self.line = line_number(self.source, "// Set break point at this line.") +self.build() + +def test_read_watchpoint_watch_address(self): +exe = self.getBuildArtifact("a.out") + +target = self.dbg.CreateTarget(exe) +self.assertTrue(target, VALID_TARGET) + +# Now create a breakpoint on main.c. +breakpoint = target.BreakpointCreateByLocation(self.source, self.line) +self.assertTrue( +breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT +) + +# Now launch the process, and do not stop at the entry point. +process = target.LaunchSimple(None, None, self.get_process_working_directory()) + +# We should be stopped due to the breakpoint. Get frame #0. +process = target.GetProcess() +self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) +thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +frame0 = thread.GetFrameAtIndex(0) + +value = frame0.FindValue("global", lldb.eValueTypeVariableGlobal) +local = frame0.FindValue("local", lldb.eValueTypeVariableLocal) +error = lldb.SBError() + +watchpoint = target.WatchAddress(value.GetLoadAddress(), 1, True, False, error) +self.assertTrue( +value and local and watchpoint, +"Successfully found the values and set a watchpoint", +) +self.DebugSBValue(value) +self.DebugSBValue(local) + +# Hide stdout if not running with '-t' option. +if not self.TraceOn(): +self.HideStdout() + +print(watchpoint) + +# Continue. Expect the program to stop due to the variable being +# read, but *not* written to. +process.Continue() + +if self.TraceOn(): +lldbutil.print_stacktraces(process) + +self.assertTrue( +local.GetValueAsSigned() > 0, "The local variable has been incremented" +) + +def test_read_watchpoint_watch_create_by_address(self): +exe = self.getBuildArtifact("a.out") + +target = self.dbg.CreateTarget(exe) +self.assertTrue(target, VALID_TARGET) + +# Now create a breakpoint on main.c. +breakpoint = target.BreakpointCreateByLocation(self.source, self.line) +self.assertTrue( +breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT +) + +# Now launch the process, and do not stop at the entry point. +process = target.LaunchSimple(None, None, self.get_process_working_directory()) + +# We should be stopped due to the breakpoint. Get frame #0. +process = target.GetProcess() +
[Lldb-commits] [lldb] [lldb] Add support for gdb-style 'x' packet (PR #124733)
labath wrote: GDB has already implemented this, and it looks like they'll do a new release this weekend: https://sourceware.org/pipermail/gdb/2025-January/051731.html Robert, any last words before I merge this? :) https://github.com/llvm/llvm-project/pull/124733 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [NFC] changes to AArch64 ACLE types definitions (PR #125063)
https://github.com/tmatheson-arm created https://github.com/llvm/llvm-project/pull/125063 - Rename AArch64SVEACLETypes.def to AArch64Types.def - Remove string literals from the macro calls - Rename macros so that the hierarchy makes sense >From 63159e8e82b56850213fb0e2479bd708f008ea81 Mon Sep 17 00:00:00 2001 From: Tomas Matheson Date: Wed, 22 Jan 2025 11:11:33 + Subject: [PATCH 1/4] [NFC] rename AArch64SVEACLETypes.def to AArch64Types.def This file also defines NEON types. --- clang/include/clang/AST/ASTContext.h | 2 +- clang/include/clang/AST/Type.h | 2 +- clang/include/clang/AST/TypeProperties.td| 2 +- .../{AArch64SVEACLETypes.def => AArch64Types.def}| 0 clang/include/clang/Serialization/ASTBitCodes.h | 2 +- clang/include/module.modulemap | 2 +- clang/lib/AST/ASTContext.cpp | 12 ++-- clang/lib/AST/ASTImporter.cpp| 2 +- clang/lib/AST/ExprConstant.cpp | 2 +- clang/lib/AST/ItaniumMangle.cpp | 2 +- clang/lib/AST/MicrosoftMangle.cpp| 2 +- clang/lib/AST/NSAPI.cpp | 2 +- clang/lib/AST/PrintfFormatString.cpp | 2 +- clang/lib/AST/Type.cpp | 6 +++--- clang/lib/AST/TypeLoc.cpp| 2 +- clang/lib/CodeGen/CGDebugInfo.cpp| 2 +- clang/lib/CodeGen/CodeGenTypes.cpp | 2 +- clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 +- clang/lib/CodeGen/Targets/AArch64.cpp| 2 +- clang/lib/Index/USRGeneration.cpp| 2 +- clang/lib/Sema/Sema.cpp | 2 +- clang/lib/Sema/SemaExpr.cpp | 4 ++-- clang/lib/Serialization/ASTCommon.cpp| 2 +- clang/lib/Serialization/ASTReader.cpp| 2 +- clang/tools/libclang/CIndex.cpp | 2 +- .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 2 +- 26 files changed, 33 insertions(+), 33 deletions(-) rename clang/include/clang/Basic/{AArch64SVEACLETypes.def => AArch64Types.def} (100%) diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 4e9b961688d559..d7066e341cfe05 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1204,7 +1204,7 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/OpenCLExtensionTypes.def" #define SVE_TYPE(Name, Id, SingletonId) \ CanQualType SingletonId; -#include "clang/Basic/AArch64SVEACLETypes.def" +#include "clang/Basic/AArch64Types.def" #define PPC_VECTOR_TYPE(Name, Id, Size) \ CanQualType Id##Ty; #include "clang/Basic/PPCTypes.def" diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 3457d524c63aaa..983b710df7161c 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3042,7 +3042,7 @@ class BuiltinType : public Type { #include "clang/Basic/OpenCLExtensionTypes.def" // SVE Types #define SVE_TYPE(Name, Id, SingletonId) Id, -#include "clang/Basic/AArch64SVEACLETypes.def" +#include "clang/Basic/AArch64Types.def" // PPC MMA Types #define PPC_VECTOR_TYPE(Name, Id, Size) Id, #include "clang/Basic/PPCTypes.def" diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 6f1a76bd18fb50..f6521ca3a32cd6 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -886,7 +886,7 @@ let Class = BuiltinType in { #define SVE_TYPE(NAME, ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; -#include "clang/Basic/AArch64SVEACLETypes.def" +#include "clang/Basic/AArch64Types.def" #define PPC_VECTOR_TYPE(NAME, ID, SIZE) \ case BuiltinType::ID: return ctx.ID##Ty; diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64Types.def similarity index 100% rename from clang/include/clang/Basic/AArch64SVEACLETypes.def rename to clang/include/clang/Basic/AArch64Types.def diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index d568d2fd7aa301..05d1cf1fd5cdb6 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -1129,7 +1129,7 @@ enum PredefinedTypeIDs { #include "clang/Basic/OpenCLExtensionTypes.def" // \brief SVE types with auto numeration #define SVE_TYPE(Name, Id, SingletonId) PREDEF_TYPE_##Id##_ID, -#include "clang/Basic/AArch64SVEACLETypes.def" +#include "clang/Basic/AArch64Types.def" // \brief PowerPC MMA types with auto numeration #define PPC_VECTOR_TYPE(Name, Id, Size) PREDEF_TYPE_##Id##_ID, #include "clang/Basic/PPCTypes.def" diff --git a/clang/include/module.modulemap b/clang/include/module.mo
[Lldb-commits] [clang] [lldb] [NFC] changes to AArch64 ACLE types definitions (PR #125063)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Tomas Matheson (tmatheson-arm) Changes - Rename AArch64SVEACLETypes.def to AArch64Types.def - Remove string literals from the macro calls - Rename macros so that the hierarchy makes sense --- Patch is 47.44 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/125063.diff 27 Files Affected: - (modified) clang/include/clang/AST/ASTContext.h (+2-3) - (modified) clang/include/clang/AST/Type.h (+2-2) - (modified) clang/include/clang/AST/TypeProperties.td (+2-2) - (removed) clang/include/clang/Basic/AArch64SVEACLETypes.def (-216) - (added) clang/include/clang/Basic/AArch64Types.def (+216) - (modified) clang/include/clang/Serialization/ASTBitCodes.h (+2-2) - (modified) clang/include/module.modulemap (+1-1) - (modified) clang/lib/AST/ASTContext.cpp (+15-16) - (modified) clang/lib/AST/ASTImporter.cpp (+3-3) - (modified) clang/lib/AST/ExprConstant.cpp (+2-3) - (modified) clang/lib/AST/ItaniumMangle.cpp (+10-10) - (modified) clang/lib/AST/MicrosoftMangle.cpp (+2-3) - (modified) clang/lib/AST/NSAPI.cpp (+2-3) - (modified) clang/lib/AST/PrintfFormatString.cpp (+2-3) - (modified) clang/lib/AST/Type.cpp (+8-9) - (modified) clang/lib/AST/TypeLoc.cpp (+2-3) - (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+2-2) - (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+2-2) - (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+2-3) - (modified) clang/lib/CodeGen/Targets/AArch64.cpp (+2-2) - (modified) clang/lib/Index/USRGeneration.cpp (+5-4) - (modified) clang/lib/Sema/Sema.cpp (+3-3) - (modified) clang/lib/Sema/SemaExpr.cpp (+4-6) - (modified) clang/lib/Serialization/ASTCommon.cpp (+4-4) - (modified) clang/lib/Serialization/ASTReader.cpp (+5-5) - (modified) clang/tools/libclang/CIndex.cpp (+2-2) - (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+2-2) ``diff diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 4e9b961688d559..4583b2cc2fa1af 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1202,9 +1202,8 @@ class ASTContext : public RefCountedBase { #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ CanQualType Id##Ty; #include "clang/Basic/OpenCLExtensionTypes.def" -#define SVE_TYPE(Name, Id, SingletonId) \ - CanQualType SingletonId; -#include "clang/Basic/AArch64SVEACLETypes.def" +#define AARCH64_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AArch64Types.def" #define PPC_VECTOR_TYPE(Name, Id, Size) \ CanQualType Id##Ty; #include "clang/Basic/PPCTypes.def" diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 3457d524c63aaa..9e853c11c97c6a 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3041,8 +3041,8 @@ class BuiltinType : public Type { #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) Id, #include "clang/Basic/OpenCLExtensionTypes.def" // SVE Types -#define SVE_TYPE(Name, Id, SingletonId) Id, -#include "clang/Basic/AArch64SVEACLETypes.def" +#define AARCH64_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AArch64Types.def" // PPC MMA Types #define PPC_VECTOR_TYPE(Name, Id, Size) Id, #include "clang/Basic/PPCTypes.def" diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 6f1a76bd18fb50..6fe8635ea79962 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -884,9 +884,9 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.ID##Ty; #include "clang/Basic/OpenCLExtensionTypes.def" -#define SVE_TYPE(NAME, ID, SINGLETON_ID) \ +#define AARCH64_TYPE(NAME, ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; -#include "clang/Basic/AArch64SVEACLETypes.def" +#include "clang/Basic/AArch64Types.def" #define PPC_VECTOR_TYPE(NAME, ID, SIZE) \ case BuiltinType::ID: return ctx.ID##Ty; diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def deleted file mode 100644 index 063cac1f4a58ee..00 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ /dev/null @@ -1,216 +0,0 @@ -//===-- AArch64SVEACLETypes.def - Metadata about SVE types --*- 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 -// -//===--===// -// -// This file defines various SVE builtin types. The macros are: -// -//SVE_TYPE: -//- (Name, MangledName, Id, SingletonId) -//A builtin type that has not been covered by any other #define. Defining -//this macro covers all the builtin types. -// -//SVE_VECTOR_TYPE, SVE_PREDICATE_TYPE, SVE_OPAQUE_TYPE: -//- (
[Lldb-commits] [clang] [lldb] [NFC] changes to AArch64 ACLE types definitions (PR #125063)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen Author: Tomas Matheson (tmatheson-arm) Changes - Rename AArch64SVEACLETypes.def to AArch64Types.def - Remove string literals from the macro calls - Rename macros so that the hierarchy makes sense --- Patch is 47.44 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/125063.diff 27 Files Affected: - (modified) clang/include/clang/AST/ASTContext.h (+2-3) - (modified) clang/include/clang/AST/Type.h (+2-2) - (modified) clang/include/clang/AST/TypeProperties.td (+2-2) - (removed) clang/include/clang/Basic/AArch64SVEACLETypes.def (-216) - (added) clang/include/clang/Basic/AArch64Types.def (+216) - (modified) clang/include/clang/Serialization/ASTBitCodes.h (+2-2) - (modified) clang/include/module.modulemap (+1-1) - (modified) clang/lib/AST/ASTContext.cpp (+15-16) - (modified) clang/lib/AST/ASTImporter.cpp (+3-3) - (modified) clang/lib/AST/ExprConstant.cpp (+2-3) - (modified) clang/lib/AST/ItaniumMangle.cpp (+10-10) - (modified) clang/lib/AST/MicrosoftMangle.cpp (+2-3) - (modified) clang/lib/AST/NSAPI.cpp (+2-3) - (modified) clang/lib/AST/PrintfFormatString.cpp (+2-3) - (modified) clang/lib/AST/Type.cpp (+8-9) - (modified) clang/lib/AST/TypeLoc.cpp (+2-3) - (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+2-2) - (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+2-2) - (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+2-3) - (modified) clang/lib/CodeGen/Targets/AArch64.cpp (+2-2) - (modified) clang/lib/Index/USRGeneration.cpp (+5-4) - (modified) clang/lib/Sema/Sema.cpp (+3-3) - (modified) clang/lib/Sema/SemaExpr.cpp (+4-6) - (modified) clang/lib/Serialization/ASTCommon.cpp (+4-4) - (modified) clang/lib/Serialization/ASTReader.cpp (+5-5) - (modified) clang/tools/libclang/CIndex.cpp (+2-2) - (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+2-2) ``diff diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 4e9b961688d559..4583b2cc2fa1af 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1202,9 +1202,8 @@ class ASTContext : public RefCountedBase { #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ CanQualType Id##Ty; #include "clang/Basic/OpenCLExtensionTypes.def" -#define SVE_TYPE(Name, Id, SingletonId) \ - CanQualType SingletonId; -#include "clang/Basic/AArch64SVEACLETypes.def" +#define AARCH64_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AArch64Types.def" #define PPC_VECTOR_TYPE(Name, Id, Size) \ CanQualType Id##Ty; #include "clang/Basic/PPCTypes.def" diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 3457d524c63aaa..9e853c11c97c6a 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3041,8 +3041,8 @@ class BuiltinType : public Type { #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) Id, #include "clang/Basic/OpenCLExtensionTypes.def" // SVE Types -#define SVE_TYPE(Name, Id, SingletonId) Id, -#include "clang/Basic/AArch64SVEACLETypes.def" +#define AARCH64_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AArch64Types.def" // PPC MMA Types #define PPC_VECTOR_TYPE(Name, Id, Size) Id, #include "clang/Basic/PPCTypes.def" diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 6f1a76bd18fb50..6fe8635ea79962 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -884,9 +884,9 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.ID##Ty; #include "clang/Basic/OpenCLExtensionTypes.def" -#define SVE_TYPE(NAME, ID, SINGLETON_ID) \ +#define AARCH64_TYPE(NAME, ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; -#include "clang/Basic/AArch64SVEACLETypes.def" +#include "clang/Basic/AArch64Types.def" #define PPC_VECTOR_TYPE(NAME, ID, SIZE) \ case BuiltinType::ID: return ctx.ID##Ty; diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def deleted file mode 100644 index 063cac1f4a58ee..00 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ /dev/null @@ -1,216 +0,0 @@ -//===-- AArch64SVEACLETypes.def - Metadata about SVE types --*- 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 -// -//===--===// -// -// This file defines various SVE builtin types. The macros are: -// -//SVE_TYPE: -//- (Name, MangledName, Id, SingletonId) -//A builtin type that has not been covered by any other #define. Defining -//this macro covers all the builtin types. -// -//SVE_VECTOR_TYPE, SVE_PREDICATE_TYPE, SVE_OPAQUE_TYPE: -
[Lldb-commits] [clang] [lldb] [NFC] changes to AArch64 ACLE types definitions (PR #125063)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/125063 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for gdb-style 'x' packet (PR #124733)
rocallahan wrote: It sounds fine. rr HEAD uses the Gdb flavour for GDB and the old-LLDB flavor for LLDB. After a decent amount of time has passed I will update to the new regime. https://github.com/llvm/llvm-project/pull/124733 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for gdb-style 'x' packet (PR #124733)
rocallahan wrote: And thanks! https://github.com/llvm/llvm-project/pull/124733 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support CommandInterpreter print callbacks (PR #125006)
jimingham wrote: > > If this result printing callback was also passed the command string (which > > it has from just above where the callback is called) then this would also > > be an easy way to do logging of command execution. That's not needed for > > your current purpose, but would add another strong motivation for this > > change... > > Adrian made a similar observation offline. What do you think about putting > that in the `CommandReturnObject`? This seems generally useful and that way > it's not tied to the callback. That's a good idea. https://github.com/llvm/llvm-project/pull/125006 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][lldb] Document a few ivars on the value object system. (PR #124971)
https://github.com/augusto2112 updated https://github.com/llvm/llvm-project/pull/124971 >From c6a1cd5115894b9f075229e878796c8b343ecde9 Mon Sep 17 00:00:00 2001 From: Augusto Noronha Date: Wed, 29 Jan 2025 10:53:23 -0800 Subject: [PATCH] [NFC][lldb] Document a few ivars on the value object system. --- lldb/include/lldb/Core/Value.h| 28 +++ .../lldb/Expression/ExpressionVariable.h | 11 +++- .../ValueObject/ValueObjectConstResultImpl.h | 4 +++ lldb/source/Expression/Materializer.cpp | 3 ++ 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/lldb/include/lldb/Core/Value.h b/lldb/include/lldb/Core/Value.h index d0c338ffec0cd3..3fd3ff1d2ccfa4 100644 --- a/lldb/include/lldb/Core/Value.h +++ b/lldb/include/lldb/Core/Value.h @@ -109,8 +109,10 @@ class Value { Scalar &ResolveValue(ExecutionContext *exe_ctx, Module *module = nullptr); + /// See comment on m_scalar to understand what GetScalar returns. const Scalar &GetScalar() const { return m_value; } + /// See comment on m_scalar to understand what GetScalar returns. Scalar &GetScalar() { return m_value; } size_t ResizeData(size_t len); @@ -148,6 +150,32 @@ class Value { static ValueType GetValueTypeFromAddressType(AddressType address_type); protected: + /// Represents a value, which can be a scalar, a load address, a file address, + /// or a host address. + /// + /// The interpretation of `m_value` depends on `m_value_type`: + /// - Scalar: `m_value` contains the scalar value. + /// - Load Address: `m_value` contains the load address. + /// - File Address: `m_value` contains the file address. + /// - Host Address: `m_value` contains a pointer to the start of the buffer in + /// host memory. + /// Currently, this can point to either: + /// - The `m_data_buffer` of this Value instance (e.g., in DWARF + /// computations). + /// - The `m_data` of a Value Object containing this Value. + // TODO: the GetScalar() API relies on knowledge not codified by the type + // system, making it hard to understand and easy to misuse. + // - Separate the scalar from the variable that contains the address (be it a + // load, file or host address). + // - Rename GetScalar() to something more indicative to what the scalar is, + // like GetScalarOrAddress() for example. + // - Split GetScalar() into two functions, GetScalar() and GetAddress(), which + // verify (or assert) what m_value_type is to make sure users of the class are + // querying the right thing. + // TODO: It's confusing to point to multiple possible buffers when the + // ValueType is a host address. Value should probably always own its buffer. + // Perhaps as a shared pointer with a copy on write system if the same buffer + // can be shared by multiple classes. Scalar m_value; CompilerType m_compiler_type; void *m_context = nullptr; diff --git a/lldb/include/lldb/Expression/ExpressionVariable.h b/lldb/include/lldb/Expression/ExpressionVariable.h index fc36793b3a475c..f5bd9389219668 100644 --- a/lldb/include/lldb/Expression/ExpressionVariable.h +++ b/lldb/include/lldb/Expression/ExpressionVariable.h @@ -107,9 +107,18 @@ class ExpressionVariable FlagType m_flags; // takes elements of Flags - // these should be private + /// These members should be private. + /// @{ + /// A value object whose value's data lives in host (lldb's) memory. lldb::ValueObjectSP m_frozen_sp; + /// The ValueObject counterpart to m_frozen_sp that tracks the value in + /// inferior memory. This object may not always exist; its presence depends on + /// whether it is logical for the value to exist in the inferior memory. For + /// example, when evaluating a C++ expression that generates an r-value, such + /// as a single function call, there is no memory address in the inferior to + /// track. lldb::ValueObjectSP m_live_sp; + /// @} }; /// \class ExpressionVariableList ExpressionVariable.h diff --git a/lldb/include/lldb/ValueObject/ValueObjectConstResultImpl.h b/lldb/include/lldb/ValueObject/ValueObjectConstResultImpl.h index dbd68160acb4dc..5509886a8965da 100644 --- a/lldb/include/lldb/ValueObject/ValueObjectConstResultImpl.h +++ b/lldb/include/lldb/ValueObject/ValueObjectConstResultImpl.h @@ -66,6 +66,10 @@ class ValueObjectConstResultImpl { private: ValueObject *m_impl_backend; + /// The memory address in the inferior process that this ValueObject tracks. + /// This address is used to request additional memory when the actual data + /// size exceeds the initial local buffer size, such as when a dynamic type + /// resolution results in a type larger than its statically determined type. lldb::addr_t m_live_address; AddressType m_live_address_type; lldb::ValueObjectSP m_address_of_backend; diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp index 8cd050f9fdb7ef..13a72a9921e1d6 100644 --- a/lldb/source/Expression
[Lldb-commits] [lldb] [NFC][lldb] Document a few ivars on the value object system. (PR #124971)
augusto2112 wrote: Re-requesting review as I added more comments. https://github.com/llvm/llvm-project/pull/124971 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][lldb] Document a few ivars on the value object system. (PR #124971)
@@ -148,6 +150,32 @@ class Value { static ValueType GetValueTypeFromAddressType(AddressType address_type); protected: + /// Represents a value, which can be a scalar, a load address, a file address, + /// or a host address. + /// + /// The interpretation of `m_value` depends on `m_value_type`: + /// - Scalar: `m_value` contains the scalar value. + /// - Load Address: `m_value` contains the load address. + /// - File Address: `m_value` contains the file address. + /// - Host Address: `m_value` contains a pointer to the start of the buffer in + /// host memory. + /// Currently, this can point to either: + /// - The `m_data_buffer` of this Value instance (e.g., in DWARF + /// computations). + /// - The `m_data` of a Value Object containing this Value. + // TODO: the GetScalar() API relies on knowledge not codified by the type + // system, making it hard to understand and easy to misuse. + // - Separate the scalar from the variable that contains the address (be it a + // load, file or host address). + // - Rename GetScalar() to something more indicative to what the scalar is, + // like GetScalarOrAddress() for example. + // - Split GetScalar() into two functions, GetScalar() and GetAddress(), which + // verify (or assert) what m_value_type is to make sure users of the class are + // querying the right thing. JDevlieghere wrote: ```suggestion // - Separate the scalar from the variable that contains the address (be it a // load, file or host address). // - Rename GetScalar() to something more indicative to what the scalar is, // like GetScalarOrAddress() for example. // - Split GetScalar() into two functions, GetScalar() and GetAddress(), which // verify (or assert) what m_value_type is to make sure users of the class are // querying the right thing. ``` https://github.com/llvm/llvm-project/pull/124971 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][lldb] Document a few ivars on the value object system. (PR #124971)
@@ -148,6 +150,32 @@ class Value { static ValueType GetValueTypeFromAddressType(AddressType address_type); protected: + /// Represents a value, which can be a scalar, a load address, a file address, + /// or a host address. + /// + /// The interpretation of `m_value` depends on `m_value_type`: + /// - Scalar: `m_value` contains the scalar value. + /// - Load Address: `m_value` contains the load address. + /// - File Address: `m_value` contains the file address. + /// - Host Address: `m_value` contains a pointer to the start of the buffer in + /// host memory. JDevlieghere wrote: ```suggestion /// - Scalar: `m_value` contains the scalar value. /// - Load Address: `m_value` contains the load address. /// - File Address: `m_value` contains the file address. /// - Host Address: `m_value` contains a pointer to the start of the buffer in ///host memory. ``` https://github.com/llvm/llvm-project/pull/124971 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][lldb] Document a few ivars on the value object system. (PR #124971)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/124971 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][lldb] Document a few ivars on the value object system. (PR #124971)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/124971 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][lldb] Document a few ivars on the value object system. (PR #124971)
https://github.com/JDevlieghere approved this pull request. LGMT with some formatting nits. https://github.com/llvm/llvm-project/pull/124971 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
@@ -2367,11 +2369,36 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( Michael137 wrote: I do think you can move the iteration into a helper function on clang ASTContext. It would look something like this: ``` // In ASTContext class template bool computeEnumBits(unsigned &NumNegativeBits, unsigned &NumPositiveBits, RangeT Elements); ``` Then in `SemaDecl.cpp` you would call it as follows: ``` unsigned NumNegativeBits; unsigned NumPositiveBits; bool MembersRepresentableByInt = Context.computeEnumBits(NumNegativeBits, NumPositiveBits, Elements); ``` And in LLDB in `CompleteTagDeclarationDefinition`, you would call it like so: ``` ast.computeEnumBits(NumNegativeBits, NumPositiveBits, enum_decl->enumerators()); enum_decl->completeDefinition(enum_decl->getIntegerType(), promotion_qual_type, NumPositiveBits, NumNegativeBits); ``` Wdyt? And please do the Clang-side changes in a separate NFC PR https://github.com/llvm/llvm-project/pull/115005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits