[Lldb-commits] [lldb] [lldb] Correct 32-bit build failure in StopInfoMachException.cpp (PR #159523)
https://github.com/DavidSpickett created
https://github.com/llvm/llvm-project/pull/159523
uintptr_t is usually a good idea when handling pointers, but lldb has to handle
64-bit addresses that might be from a remote system, on a 32-bit system.
So I've changed a few instances here to use addr_t which is 64-bit everywhere.
Before we got:
https://lab.llvm.org/buildbot/#/builders/18/builds/21247
```
../llvm-project/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:81:28:
error: constexpr variable 'g_mte_tag_mask' must be initialized by a constant
expression
81 | static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f <<
g_mte_tag_shift;
|^
~~
../llvm-project/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:81:61:
note: shift count 56 >= width of type 'uintptr_t' (aka 'unsigned int') (32
bits)
81 | static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f <<
g_mte_tag_shift;
| ^
1 error generated.
```
>From 51dc720f818333980580bead376bcf5ec1f4ff75 Mon Sep 17 00:00:00 2001
From: David Spickett
Date: Thu, 18 Sep 2025 09:53:36 +0100
Subject: [PATCH] [lldb] Correct 32-bit build failure in
StopInfoMachException.cpp
uintptr_t is usually a good idea when handling pointers, but lldb
has to handle 64-bit addresses that might be from a remote system,
on a 32-bit system.
So I've changed a few instances here to use addr_t which is 64-bit
everywhere.
Before we got:
https://lab.llvm.org/buildbot/#/builders/18/builds/21247
```
../llvm-project/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:81:28:
error: constexpr variable 'g_mte_tag_mask' must be initialized by a constant
expression
81 | static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f <<
g_mte_tag_shift;
|^
~~
../llvm-project/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:81:61:
note: shift count 56 >= width of type 'uintptr_t' (aka 'unsigned int') (32
bits)
81 | static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f <<
g_mte_tag_shift;
| ^
1 error generated.
```
---
lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
index 6853121f3e01c..601cfdcb4e9f7 100644
--- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -78,7 +78,7 @@ static void DescribeAddressBriefly(Stream &strm, const
Address &addr,
}
static constexpr uint8_t g_mte_tag_shift = 64 - 8;
-static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f << g_mte_tag_shift;
+static constexpr addr_t g_mte_tag_mask = (addr_t)0x0f << g_mte_tag_shift;
bool StopInfoMachException::DetermineTagMismatch(ExecutionContext &exe_ctx) {
const bool IsBadAccess = m_value == 1;// EXC_BAD_ACCESS
@@ -97,7 +97,7 @@ bool
StopInfoMachException::DetermineTagMismatch(ExecutionContext &exe_ctx) {
m_exc_code, bad_address);
const uint8_t tag = (bad_address & g_mte_tag_mask) >> g_mte_tag_shift;
- const uint64_t canonical_addr = bad_address & ~g_mte_tag_mask;
+ const addr_t canonical_addr = bad_address & ~g_mte_tag_mask;
strm.Printf(
"Note: MTE tag mismatch detected: pointer tag=%d, address=0x%" PRIx64,
tag, canonical_addr);
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add support for the structured data plugins in lldb-server (PR #159457)
https://github.com/walter-erquinigo closed https://github.com/llvm/llvm-project/pull/159457 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 1dc6bf3 - [lldb][lldb-dap] Disable all lldb-dap tests on Windows on Arm (#159542)
Author: David Spickett
Date: 2025-09-18T11:01:19+01:00
New Revision: 1dc6bf3ff98c25dd29c6db3407c81d2064bc6977
URL:
https://github.com/llvm/llvm-project/commit/1dc6bf3ff98c25dd29c6db3407c81d2064bc6977
DIFF:
https://github.com/llvm/llvm-project/commit/1dc6bf3ff98c25dd29c6db3407c81d2064bc6977.diff
LOG: [lldb][lldb-dap] Disable all lldb-dap tests on Windows on Arm (#159542)
This reverts the following commits:
a0a82ee19d6f2ff1013407ba4c973bfe5428423f
757bb36a58c7d7151a28c6a5fc7caa2e1f44de87
83b48b13f3a70bf56053e92593270c519859cfd7
b45f1fb377636a34c01e34b89341c97d19975554
d2e153981e62fb2ea781ef456ff744f9893e0733
e2d1bbebbb099c7010a31fad62a9128166ef14a0
71cae12442e7476e6397fd73db05e127bfe2d035
7dd879bdc01297a551196a60bb5a5a90ca4dd1ed
f3b542e3148cfc244f63cb7c987ccf8ebc71942b
Where I had disabled specific tests due to them being flakey on our
Windows on Arm bot.
Clearly this strategy isn't working because
every day I see a new random test failing.
Until something can be done about this, disable
every lldb-dap test on Windows on Arm. The coverage we get is just not
worth spamming contributors
who have nothing to do with lldb-dap.
See #137660
Added:
Modified:
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py
lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
lldb/test/API/tools/lldb-dap/io/TestDAP_io.py
lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
lldb/test/API/tools/lldb-dap/startDebugging/TestDAP_startDebugging.py
lldb/test/API/tools/lldb-dap/step/TestDAP_step.py
lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py
Removed:
diff --git
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 882eec9971a73..f7b1ed80fceb5 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -5,12 +5,16 @@
import dap_server
from dap_server import Source
+from lldbsuite.test.decorators import skipIf
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbplatformutil
import lldbgdbserverutils
import base64
+# DAP tests as a whole have been flakey on the Windows on Arm bot. See:
+# https://github.com/llvm/llvm-project/issues/137660
+@skipIf(oslist=["windows"], archs=["aarch64"])
class DAPTestCaseBase(TestBase):
# set timeout based on whether ASAN was enabled or not. Increase
# timeout by a factor of 10 if ASAN is enabled.
diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
index d3952e150e125..c54e21c1b973a 100644
--- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
+++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
@@ -40,7 +40,6 @@ def set_and_hit_breakpoint(self, continueToExit=True):
self.continue_to_exit()
@skipIfNetBSD # Hangs on NetBSD as well
-@skipIfWindows # https://github.com/llvm/llvm-project/issues/137660
def test_by_pid(self):
"""
Tests attaching to a process by process ID.
@@ -56,7 +55,6 @@ def test_by_pid(self):
self.set_and_hit_breakpoint(continueToExit=True)
@skipIfNetBSD # Hangs on NetBSD as well
-@skipIfWindows # https://github.com/llvm/llvm-project/issues/137660
def test_by_name(self):
"""
Tests attaching to a process by process name.
@@ -95,7 +93,6 @@ def test_by_name_waitFor(self):
self.set_and_hit_breakpoint(continueToExit=True)
@skipIfNetBSD # Hangs on NetBSD as well
-@skipIfWindows
def test_commands(self):
"""
Tests the "initCommands", "preRunCommands", "stopCommands",
diff --git a/lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py
b/lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py
index 9dea325694f00..e722fcea9283a 100644
--- a/lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py
+++ b/lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py
@@ -37,7 +37,6 @@ def async_blocking_request(self, duration: float) -> int:
def async_cancel(self, requestId: int) -> int:
return self.send_async_req(command="cancel", arguments={"requestId":
requestId})
-@skipIfWindows
def test_pending_request(self):
"""
Tests cancelling a pending request.
@@ -70,7 +69,6 @@ def test_pending_request(self):
self.assertEqual(cancel_resp["success"], True)
self.continue_to_exit()
-@skipIfWindows # https://github.com/llvm/llvm-project/issues/137660
def test_inflight_request(self):
"""
Tests cancelling an inflight request.
diff --git a/lldb/test/API/tools/lldb-dap/console/TestDAP_console
[Lldb-commits] [lldb] [lldb][nfc] Remove no-op calls to Fix*Address (PR #159586)
https://github.com/jasonmolenda approved this pull request. LGTM. The early Fixing of the register value before doing a memory read is from early in our adoption of AArch64 PAC where the bits would not be cleared at use-time when we read/write memory. https://github.com/llvm/llvm-project/pull/159586 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 113357f - [lldb][nfc] Remove no-op calls to Fix*Address (#159586)
Author: Felipe de Azevedo Piovezan
Date: 2025-09-18T10:33:51-07:00
New Revision: 113357f1a8feb0bfa337bb8a0b9d1d6eaa2d4f0f
URL:
https://github.com/llvm/llvm-project/commit/113357f1a8feb0bfa337bb8a0b9d1d6eaa2d4f0f
DIFF:
https://github.com/llvm/llvm-project/commit/113357f1a8feb0bfa337bb8a0b9d1d6eaa2d4f0f.diff
LOG: [lldb][nfc] Remove no-op calls to Fix*Address (#159586)
The first call, in InitializeNonZerothFrame, is inside a logging branch.
For that, it's better to log the real value instead of the fixed one.
The second call, inside RegisterContextUnwind::ReadFrameAddress, is
computing an address which is then passed to
ReadRegisterValueFromMemory, which boils down to a Process::ReadMemory,
which fixes the address if it wants to. The current variable names are
misleading, making readers believe it is the cfa value itself that is
being passed to Fix*Address; that's not the case. This commit renames
the variable to make this abundantly clear.
Added:
Modified:
lldb/source/Target/RegisterContextUnwind.cpp
Removed:
diff --git a/lldb/source/Target/RegisterContextUnwind.cpp
b/lldb/source/Target/RegisterContextUnwind.cpp
index 3b018c09b8b72..7f6ead1e7ccab 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -361,16 +361,10 @@ void RegisterContextUnwind::InitializeNonZerothFrame() {
if (log) {
UnwindLogMsg("pc = 0x%" PRIx64, pc);
addr_t reg_val;
-if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP, reg_val)) {
- if (abi_sp)
-reg_val = abi_sp->FixDataAddress(reg_val);
+if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP, reg_val))
UnwindLogMsg("fp = 0x%" PRIx64, reg_val);
-}
-if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, reg_val)) {
- if (abi_sp)
-reg_val = abi_sp->FixDataAddress(reg_val);
+if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, reg_val))
UnwindLogMsg("sp = 0x%" PRIx64, reg_val);
-}
}
// A pc of 0x0 means it's the end of the stack crawl unless we're above a
trap
@@ -2026,30 +2020,31 @@ bool RegisterContextUnwind::ReadFrameAddress(
switch (fa.GetValueType()) {
case UnwindPlan::Row::FAValue::isRegisterDereferenced: {
UnwindLogMsg("CFA value via dereferencing reg");
-RegisterNumber cfa_reg(m_thread, row_register_kind,
- fa.GetRegisterNumber());
-if (ReadGPRValue(cfa_reg, cfa_reg_contents)) {
+RegisterNumber regnum_to_deref(m_thread, row_register_kind,
+ fa.GetRegisterNumber());
+addr_t reg_to_deref_contents;
+if (ReadGPRValue(regnum_to_deref, reg_to_deref_contents)) {
const RegisterInfo *reg_info =
- GetRegisterInfoAtIndex(cfa_reg.GetAsKind(eRegisterKindLLDB));
+ GetRegisterInfoAtIndex(regnum_to_deref.GetAsKind(eRegisterKindLLDB));
RegisterValue reg_value;
if (reg_info) {
-if (abi_sp)
- cfa_reg_contents = abi_sp->FixDataAddress(cfa_reg_contents);
Status error = ReadRegisterValueFromMemory(
-reg_info, cfa_reg_contents, reg_info->byte_size, reg_value);
+reg_info, reg_to_deref_contents, reg_info->byte_size, reg_value);
if (error.Success()) {
address = reg_value.GetAsUInt64();
UnwindLogMsg(
"CFA value via dereferencing reg %s (%d): reg has val 0x%" PRIx64
", CFA value is 0x%" PRIx64,
- cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB),
- cfa_reg_contents, address);
+ regnum_to_deref.GetName(),
+ regnum_to_deref.GetAsKind(eRegisterKindLLDB),
+ reg_to_deref_contents, address);
return true;
} else {
UnwindLogMsg("Tried to deref reg %s (%d) [0x%" PRIx64
"] but memory read failed.",
- cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB),
- cfa_reg_contents);
+ regnum_to_deref.GetName(),
+ regnum_to_deref.GetAsKind(eRegisterKindLLDB),
+ reg_to_deref_contents);
}
}
}
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Remove no-op calls to Fix*Address (PR #159586)
https://github.com/felipepiovezan closed https://github.com/llvm/llvm-project/pull/159586 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [vscode-lldb] Restart server when the lldb-dap binary's modification time has changed (PR #159481)
@@ -149,27 +149,40 @@ Restarting the server will interrupt any existing debug
sessions and start a new
this.cleanUp(this.serverProcess);
}
- cleanUp(process: child_process.ChildProcessWithoutNullStreams) {
+ private cleanUp(process: child_process.ChildProcessWithoutNullStreams) {
// If the following don't equal, then the fields have already been updated
// (either a new process has started, or the fields were already cleaned
// up), and so the cleanup should be skipped.
if (this.serverProcess === process) {
this.serverProcess = undefined;
this.serverInfo = undefined;
+ this.serverSpawnInfo = undefined;
}
}
- getSpawnInfo(
+ private async getSpawnInfo(
path: string,
args: string[],
env: NodeJS.ProcessEnv | { [key: string]: string } | undefined,
- ): string[] {
+ ): Promise {
return [
path,
...args,
...Object.entries(env ?? {}).map(
(entry) => String(entry[0]) + "=" + String(entry[1]),
),
+ `(${await this.getFileModifiedTimestamp(path)})`,
];
}
+
+ private async getFileModifiedTimestamp(file: string): Promise
{
+try {
+ if (!(await fs.pathExists(file))) {
+return null;
+ }
+ return (await fs.promises.stat(file)).mtime.toLocaleString();
+} catch (error) {
+ return null;
+}
+ }
royitaqi wrote:
(The following is probably more for my learning.)
I did a [Google
search](https://www.google.com/search?q=does+vscode.createFileSystemWatcher+detect+changes+from+touch%3F&sca_esv=a1feb94103ceaa7e&ei=IEfMaI7NMZ-i0PEP6orIwQE&ved=0ahUKEwiO3dHC8OKPAxUfETQIHWoFMhgQ4dUDCBA&uact=5&oq=does+vscode.createFileSystemWatcher+detect+changes+from+touch%3F&gs_lp=Egxnd3Mtd2l6LXNlcnAiPmRvZXMgdnNjb2RlLmNyZWF0ZUZpbGVTeXN0ZW1XYXRjaGVyIGRldGVjdCBjaGFuZ2VzIGZyb20gdG91Y2g_SKwhUJIHWKwfcAV4AZABAJgBkwGgAbEKqgEDNS43uAEDyAEA-AEBmAIKoALQBMICChAAGLADGNYEGEfCAgUQABjvBcICCBAAGIAEGKIEmAMA4gMFEgExIECIBgGQBgiSBwM2LjSgB7YosgcDMS40uAfEBMIHBTAuOS4xyAcV&sclient=gws-wiz-serp)
and it said this:
> While vscode.createFileSystemWatcher is reliable, file system watching is not
> always perfect and can be affected by the operating system. According to the
> VS Code team, the OS may decide to drop file events at any time, so there is
> no 100% guarantee that an event will be detected.
It seems it's because the underlying `fs.watch` is ["not always
reliable"](https://www.javascriptcheatsheet.org/cheatsheet/directory-files#:~:text=The%20exact%20behavior%20of%20%60fs.watch%60%20can%20vary%20across%20different%20platforms%20and%20situations.%20It%27s%20not%20always%20reliable%2C%20especially%20on%20network%20file%20systems%20and%20certain%20file%20systems%20like%20NFS%20and%20VFS.%20For%20more%20reliable%20file%20watching%2C%20consider%20using%20a%20library%20like%20%60chokidar%60.).
--
FWIW, I have a local implementation using the `createFileSystemWatcher` but
somehow it's not triggering when I `touch` the lldb-dap binary. Still trying to
figure out why.
--
Overall, I have no strong opinion. Currently it appears to me that checking the
file modification time is better in terms of debuggability (user can verify the
modification time).
https://github.com/llvm/llvm-project/pull/159481
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Simplify logic in ABIMacOSX_arm64::FixDataAddress (PR #159612)
https://github.com/jasonmolenda approved this pull request. This looks fine, although we're not using `tbi_mask` anywhere now? We should probably remove it if it's not being used. https://github.com/llvm/llvm-project/pull/159612 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Simplify logic in ABIMacOSX_arm64::FixDataAddress (PR #159612)
felipepiovezan wrote: > This looks fine, although we're not using `tbi_mask` anywhere now? We should > probably remove it if it's not being used. It is! ``` if (mask == LLDB_INVALID_ADDRESS_MASK) mask = tbi_mask; ``` https://github.com/llvm/llvm-project/pull/159612 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change directory creation logic in framework-header-fix (PR #158355)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/158355 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [vscode-lldb] Restart server when the lldb-dap binary's modification time has changed (PR #159481)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/159481 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [vscode-lldb] Restart server when the lldb-dap binary's modification time has changed (PR #159481)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/159481 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
https://github.com/JDevlieghere commented: I did a first pass but I definitely need to do another pass with everything I learned during the first round, but don't want to hold back initial comment on that. https://github.com/llvm/llvm-project/pull/159160 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
@@ -50,17 +56,88 @@ class TransportUnhandledContentsError
std::string m_unhandled_contents;
};
+class InvalidParams : public llvm::ErrorInfo {
+public:
+ static char ID;
+
+ explicit InvalidParams(std::string method, std::string context)
+ : m_method(std::move(method)), m_context(std::move(context)) {}
+
+ void log(llvm::raw_ostream &OS) const override;
+ std::error_code convertToErrorCode() const override;
+
+private:
+ std::string m_method;
+ std::string m_context;
+};
+
+// Value for tracking functions that have a void param or result.
+using VoidT = std::monostate;
+
+template using Callback = llvm::unique_function;
JDevlieghere wrote:
Is this enclosed in a namespace? This is to generic to belongs in the
`lldb_private` namespace. Maybe we can limit this in scope by wrapping
everything in a `lldb_private::transport` namespace?
https://github.com/llvm/llvm-project/pull/159160
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
@@ -100,22 +175,301 @@ template
class Transport {
virtual llvm::Expected
RegisterMessageHandler(MainLoop &loop, MessageHandler &handler) = 0;
- // FIXME: Refactor mcp::Server to not directly access log on the transport.
- // protected:
+protected:
template inline auto Logv(const char *Fmt, Ts &&...Vals) {
Log(llvm::formatv(Fmt, std::forward(Vals)...).str());
}
virtual void Log(llvm::StringRef message) = 0;
+
+ /// Function object to reply to a call.
+ /// Each instance must be called exactly once, otherwise:
+ /// - the bug is logged, and (in debug mode) an assert will fire
+ /// - if there was no reply, an error reply is sent
+ /// - if there were multiple replies, only the first is sent
+ class ReplyOnce {
+std::atomic replied = {false};
+const Req req;
+JSONTransport *transport; // Null when moved-from.
+JSONTransport::MessageHandler *handler; // Null when moved-from.
+
+ public:
+ReplyOnce(const Req req, JSONTransport *transport,
+ JSONTransport::MessageHandler *handler)
+: req(req), transport(transport), handler(handler) {
+ assert(handler);
+}
+ReplyOnce(ReplyOnce &&other)
+: replied(other.replied.load()), req(other.req),
+ transport(other.transport), handler(other.handler) {
+ other.transport = nullptr;
+ other.handler = nullptr;
+}
+ReplyOnce &operator=(ReplyOnce &&) = delete;
+ReplyOnce(const ReplyOnce &) = delete;
+ReplyOnce &operator=(const ReplyOnce &) = delete;
+
+~ReplyOnce() {
+ if (transport && handler && !replied) {
+assert(false && "must reply to all calls!");
+(*this)(MakeResponse(
+req, llvm::createStringError("failed to reply")));
+ }
+}
+
+void operator()(const Resp &resp) {
+ assert(transport && handler && "moved-from!");
+ if (replied.exchange(true)) {
+assert(false && "must reply to each call only once!");
+return;
+ }
+
+ if (llvm::Error error = transport->Send(resp))
+handler->OnError(std::move(error));
+}
+ };
+
+public:
+ class Binder;
+ using BinderUP = std::unique_ptr;
+
+ /// Binder collects a table of functions that handle calls.
JDevlieghere wrote:
I think this new class warrants a bit more documentation. IIUC, this is
basically a forwarded of messages, which allows you to register a handler by
name. By defining message types we can get that automatically out of the
messages, and then have it call the right callback?
Basically, this hoist the logic we have both in MCP and DAP into the transport
class. Which leads to my next question: does this need to be tied to
JSONTransport? Can this be built on top of an arbitrary transport?
https://github.com/llvm/llvm-project/pull/159160
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
@@ -50,17 +56,88 @@ class TransportUnhandledContentsError
std::string m_unhandled_contents;
};
+class InvalidParams : public llvm::ErrorInfo {
+public:
+ static char ID;
+
+ explicit InvalidParams(std::string method, std::string context)
+ : m_method(std::move(method)), m_context(std::move(context)) {}
+
+ void log(llvm::raw_ostream &OS) const override;
+ std::error_code convertToErrorCode() const override;
+
+private:
+ std::string m_method;
JDevlieghere wrote:
Similar comment, what does method refer to here? Is this meant as a
generalization of a MCP tool? If so, can we keep this more concrete at a lower
layer?
https://github.com/llvm/llvm-project/pull/159160
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
@@ -50,17 +56,88 @@ class TransportUnhandledContentsError
std::string m_unhandled_contents;
};
+class InvalidParams : public llvm::ErrorInfo {
JDevlieghere wrote:
This is the first file in the diff, so maybe its purpose will become clear
later, but at this point it's unclear what this is supposed to be used for
(other than representing invalid parameters). Can you add a Doxygen comment?
https://github.com/llvm/llvm-project/pull/159160
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
@@ -50,17 +56,88 @@ class TransportUnhandledContentsError
std::string m_unhandled_contents;
};
+class InvalidParams : public llvm::ErrorInfo {
+public:
+ static char ID;
+
+ explicit InvalidParams(std::string method, std::string context)
+ : m_method(std::move(method)), m_context(std::move(context)) {}
+
+ void log(llvm::raw_ostream &OS) const override;
+ std::error_code convertToErrorCode() const override;
+
+private:
+ std::string m_method;
+ std::string m_context;
+};
+
+// Value for tracking functions that have a void param or result.
+using VoidT = std::monostate;
+
+template using Callback = llvm::unique_function;
JDevlieghere wrote:
Applies to some of the types below as well.
https://github.com/llvm/llvm-project/pull/159160
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/159160 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
@@ -50,17 +56,88 @@ class TransportUnhandledContentsError
std::string m_unhandled_contents;
};
+class InvalidParams : public llvm::ErrorInfo {
+public:
+ static char ID;
+
+ explicit InvalidParams(std::string method, std::string context)
+ : m_method(std::move(method)), m_context(std::move(context)) {}
+
+ void log(llvm::raw_ostream &OS) const override;
+ std::error_code convertToErrorCode() const override;
+
+private:
+ std::string m_method;
ashgti wrote:
I added a comment about this, this comes from the Binder. In JSONRPC the refer
to the remote calls as 'methods'. In the DAP, which isn't precisely a JSONRPC
transport, its a 'command' or an 'event', so the terminology isn't consistent.
I went with the JSONRPC based name.
https://github.com/llvm/llvm-project/pull/159160
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix unordered-map test (PR #156033)
da-viper wrote:
> The "frame var" expression would be more similar to script
> lldb.frame.FindVariable("ptr1").Dereference().GetChildAtIndex(0)
This works in this case.
```sh
>>> lldb.frame.FindVariable("ptr1").Dereference().GetChildAtIndex(0)
(std::pair, std::basic_string >) [0] =
(first = "Hello", second = "World")
```
https://github.com/llvm/llvm-project/pull/156033
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Instrumentation] Set selected frame to outside sanitizer libraries (PR #133079)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `cross-project-tests-sie-ubuntu` running on `doug-worker-1a` while building `lldb` at step 6 "test-build-unified-tree-check-cross-project". Full details are available at: https://lab.llvm.org/buildbot/#/builders/181/builds/27444 Here is the relevant piece of the build log for the reference ``` Step 6 (test-build-unified-tree-check-cross-project) failure: test (failure) TEST 'cross-project-tests :: debuginfo-tests/dexter-tests/optnone-struct-and-methods.cpp' FAILED Exit Code: 2 Command Output (stdout): -- optnone-struct-and-methods.cpp: nan/nan (nan) [Command '['/usr/bin/python3.8', '/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter/dex/../dexter.py', 'run-debugger-internal-', '/tmp/lit-tmp-l306fh39/dexter/tmpi_3ukuqr/tmpkp72n71y', '--working-directory=/tmp/lit-tmp-l306fh39/dexter/tmpi_3ukuqr', '--unittest=off', '--indent-timer-level=3']' returned non-zero exit status 1.] Command '['/usr/bin/python3.8', '/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter/dex/../dexter.py', 'run-debugger-internal-', '/tmp/lit-tmp-l306fh39/dexter/tmpi_3ukuqr/tmpkp72n71y', '--working-directory=/tmp/lit-tmp-l306fh39/dexter/tmpi_3ukuqr', '--unittest=off', '--indent-timer-level=3']' returned non-zero exit status 1. -- Command Output (stderr): -- /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/bin/clang++ -std=gnu++11 -O2 -g /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter-tests/optnone-struct-and-methods.cpp -o /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/projects/cross-project-tests/debuginfo-tests/dexter-tests/Output/optnone-struct-and-methods.cpp.tmp # RUN: at line 1 + /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/bin/clang++ -std=gnu++11 -O2 -g /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter-tests/optnone-struct-and-methods.cpp -o /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/projects/cross-project-tests/debuginfo-tests/dexter-tests/Output/optnone-struct-and-methods.cpp.tmp /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter-tests/optnone-struct-and-methods.cpp:69:22: warning: first argument in call to '__builtin_memset' is a pointer to non-trivially copyable type '(anonymous namespace)::A' [-Wnontrivial-memcall] 69 | __builtin_memset(this, 0xFF, sizeof(*this)); | ^ /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter-tests/optnone-struct-and-methods.cpp:69:22: note: explicitly cast the pointer to silence this warning 69 | __builtin_memset(this, 0xFF, sizeof(*this)); | ^ | (void*) 1 warning generated. "/usr/bin/python3.8" "/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter/dexter.py" test --fail-lt 1.0 -w --binary /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/projects/cross-project-tests/debuginfo-tests/dexter-tests/Output/optnone-struct-and-methods.cpp.tmp --lldb-executable "/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/bin/lldb-dap" --debugger lldb-dap --dap-message-log=/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/projects/cross-project-tests/debuginfo-tests/dexter-tests/Output/optnone-struct-and-methods.cpp.tmp.dap.log -v -- /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter-tests/optnone-struct-and-methods.cpp # RUN: at line 2 + /usr/bin/python3.8 /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter/dexter.py test --fail-lt 1.0 -w --binary /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/projects/cross-project-tests/debuginfo-tests/dexter-tests/Output/optnone-struct-and-methods.cpp.tmp --lldb-executable /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/bin/lldb-dap --debugger lldb-dap --dap-message-log=/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/projects/cross-project-tests/debuginfo-tests/dexter-tests/Output/optnone-struct-and-methods.cpp.tmp.dap.log -v -- /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter-tests/optnone-struct-and-methods.cpp note: Opening DAP server: /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/bin/lldb-dap warning: DAP: Unknown support flag: $__lldb_version warning: DAP: Unknown support flag: c
[Lldb-commits] [lldb] [vscode-lldb] Improve logging in Server Mode (PR #159672)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/159672 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)
tgs-sc wrote: I think I can add this change into a separate commit in this PR, so that changes we already made will still be relevant. https://github.com/llvm/llvm-project/pull/154123 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f1a02c6 - [lldb] Fix unordered-map data formatter for const types (#156033)
Author: Ebuka Ezike
Date: 2025-09-15T15:19:55+01:00
New Revision: f1a02c681f0d092bb28ac3ff2e79eff11ecb95dc
URL:
https://github.com/llvm/llvm-project/commit/f1a02c681f0d092bb28ac3ff2e79eff11ecb95dc
DIFF:
https://github.com/llvm/llvm-project/commit/f1a02c681f0d092bb28ac3ff2e79eff11ecb95dc.diff
LOG: [lldb] Fix unordered-map data formatter for const types (#156033)
The test was failing because the const qualifier is not removed when checking
if the type is an `unordered_map`
Added:
Modified:
lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
Removed:
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index f88a5319068a2..4b183a8d62e53 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -113,10 +113,11 @@ CompilerType
lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
// wraps a std::pair. Peel away the internal wrapper type - whose structure
is
// of no value to users, to expose the std::pair. This matches the structure
// returned by the std::map synthetic provider.
- if (isUnorderedMap(m_backend.GetCompilerType()
- .GetNonReferenceType()
- .GetCanonicalType()
- .GetTypeName())) {
+ CompilerType backend_type = m_backend.GetCompilerType();
+ if (backend_type.IsPointerOrReferenceType())
+backend_type = backend_type.GetPointeeType();
+
+ if (isUnorderedMap(backend_type.GetCanonicalType().GetTypeName())) {
std::string name;
CompilerType field_type =
element_type.GetFieldAtIndex(0, name, nullptr, nullptr, nullptr);
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
@@ -50,17 +56,88 @@ class TransportUnhandledContentsError
std::string m_unhandled_contents;
};
+class InvalidParams : public llvm::ErrorInfo {
ashgti wrote:
Added comments to this and a bunch of other classes in this file.
https://github.com/llvm/llvm-project/pull/159160
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)
https://github.com/Michael137 auto_merge_enabled https://github.com/llvm/llvm-project/pull/154123 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][ProcessWindows] Set exit status on instance rather than going through all targets (PR #159308)
https://github.com/Nerixyz closed https://github.com/llvm/llvm-project/pull/159308 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Disable a procfile test when threading is not enabled (PR #159559)
https://github.com/DavidSpickett updated
https://github.com/llvm/llvm-project/pull/159559
>From 959edbe1add44159d473602d4151cf533cac4050 Mon Sep 17 00:00:00 2001
From: David Spickett
Date: Thu, 18 Sep 2025 12:51:55 +0100
Subject: [PATCH 1/2] [lldb][test] Disable a procfile test when threading is
not enabled
As is done for other procfile tests.
---
lldb/unittests/Host/posix/SupportTest.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lldb/unittests/Host/posix/SupportTest.cpp
b/lldb/unittests/Host/posix/SupportTest.cpp
index 5393ad83ad8ac..1b11f0caa0981 100644
--- a/lldb/unittests/Host/posix/SupportTest.cpp
+++ b/lldb/unittests/Host/posix/SupportTest.cpp
@@ -26,7 +26,7 @@ TEST(Support, getProcFile_Pid) {
}
#endif // #ifndef __APPLE__
-#if defined(_AIX) || defined(__linux__)
+#if (defined(_AIX) || defined(__linux__)) && defined(LLVM_ENABLE_THREADING)
TEST(Support, getProcFile_Tid) {
auto BufferOrError = getProcFile(getpid(), llvm::get_threadid(),
#ifdef _AIX
@@ -38,4 +38,4 @@ TEST(Support, getProcFile_Tid) {
ASSERT_TRUE(BufferOrError);
ASSERT_TRUE(*BufferOrError);
}
-#endif // #if defined(_AIX) || defined(__linux__)
+#endif // #if (defined(_AIX) || defined(__linux__)) &&
defined(LLVM_ENABLE_THREADING)
>From f95e9b99a8ae639744257a418bd9dd05a679751c Mon Sep 17 00:00:00 2001
From: David Spickett
Date: Thu, 18 Sep 2025 12:57:14 +0100
Subject: [PATCH 2/2] format
---
lldb/unittests/Host/posix/SupportTest.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lldb/unittests/Host/posix/SupportTest.cpp
b/lldb/unittests/Host/posix/SupportTest.cpp
index 1b11f0caa0981..ed2ff2082066e 100644
--- a/lldb/unittests/Host/posix/SupportTest.cpp
+++ b/lldb/unittests/Host/posix/SupportTest.cpp
@@ -38,4 +38,5 @@ TEST(Support, getProcFile_Tid) {
ASSERT_TRUE(BufferOrError);
ASSERT_TRUE(*BufferOrError);
}
-#endif // #if (defined(_AIX) || defined(__linux__)) &&
defined(LLVM_ENABLE_THREADING)
+#endif // #if (defined(_AIX) || defined(__linux__)) &&
+ // defined(LLVM_ENABLE_THREADING)
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Disable a procfile test when threading is not enabled (PR #159559)
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 origin/main HEAD --extensions cpp --
lldb/unittests/Host/posix/SupportTest.cpp
``
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
View the diff from clang-format here.
``diff
diff --git a/lldb/unittests/Host/posix/SupportTest.cpp
b/lldb/unittests/Host/posix/SupportTest.cpp
index 1b11f0caa..ed2ff2082 100644
--- a/lldb/unittests/Host/posix/SupportTest.cpp
+++ b/lldb/unittests/Host/posix/SupportTest.cpp
@@ -38,4 +38,5 @@ TEST(Support, getProcFile_Tid) {
ASSERT_TRUE(BufferOrError);
ASSERT_TRUE(*BufferOrError);
}
-#endif // #if (defined(_AIX) || defined(__linux__)) &&
defined(LLVM_ENABLE_THREADING)
+#endif // #if (defined(_AIX) || defined(__linux__)) &&
+ // defined(LLVM_ENABLE_THREADING)
``
https://github.com/llvm/llvm-project/pull/159559
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Disable a procfile test when threading is not enabled (PR #159559)
llvmbot wrote:
@llvm/pr-subscribers-lldb
Author: David Spickett (DavidSpickett)
Changes
As is done for other procfile tests.
---
Full diff: https://github.com/llvm/llvm-project/pull/159559.diff
1 Files Affected:
- (modified) lldb/unittests/Host/posix/SupportTest.cpp (+2-2)
``diff
diff --git a/lldb/unittests/Host/posix/SupportTest.cpp
b/lldb/unittests/Host/posix/SupportTest.cpp
index 5393ad83ad8ac..1b11f0caa0981 100644
--- a/lldb/unittests/Host/posix/SupportTest.cpp
+++ b/lldb/unittests/Host/posix/SupportTest.cpp
@@ -26,7 +26,7 @@ TEST(Support, getProcFile_Pid) {
}
#endif // #ifndef __APPLE__
-#if defined(_AIX) || defined(__linux__)
+#if (defined(_AIX) || defined(__linux__)) && defined(LLVM_ENABLE_THREADING)
TEST(Support, getProcFile_Tid) {
auto BufferOrError = getProcFile(getpid(), llvm::get_threadid(),
#ifdef _AIX
@@ -38,4 +38,4 @@ TEST(Support, getProcFile_Tid) {
ASSERT_TRUE(BufferOrError);
ASSERT_TRUE(*BufferOrError);
}
-#endif // #if defined(_AIX) || defined(__linux__)
+#endif // #if (defined(_AIX) || defined(__linux__)) &&
defined(LLVM_ENABLE_THREADING)
``
https://github.com/llvm/llvm-project/pull/159559
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Disable a procfile test when threading is not enabled (PR #159559)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/159559 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 1fc9b34 - [lldb][test] Disable a procfile test when threading is not enabled (#159559)
Author: David Spickett
Date: 2025-09-18T13:01:55+01:00
New Revision: 1fc9b344889aeb1f83cfee29f61d844ec927a5cd
URL:
https://github.com/llvm/llvm-project/commit/1fc9b344889aeb1f83cfee29f61d844ec927a5cd
DIFF:
https://github.com/llvm/llvm-project/commit/1fc9b344889aeb1f83cfee29f61d844ec927a5cd.diff
LOG: [lldb][test] Disable a procfile test when threading is not enabled
(#159559)
As is done for other procfile tests.
Added:
Modified:
lldb/unittests/Host/posix/SupportTest.cpp
Removed:
diff --git a/lldb/unittests/Host/posix/SupportTest.cpp
b/lldb/unittests/Host/posix/SupportTest.cpp
index 5393ad83ad8ac..ed2ff2082066e 100644
--- a/lldb/unittests/Host/posix/SupportTest.cpp
+++ b/lldb/unittests/Host/posix/SupportTest.cpp
@@ -26,7 +26,7 @@ TEST(Support, getProcFile_Pid) {
}
#endif // #ifndef __APPLE__
-#if defined(_AIX) || defined(__linux__)
+#if (defined(_AIX) || defined(__linux__)) && defined(LLVM_ENABLE_THREADING)
TEST(Support, getProcFile_Tid) {
auto BufferOrError = getProcFile(getpid(), llvm::get_threadid(),
#ifdef _AIX
@@ -38,4 +38,5 @@ TEST(Support, getProcFile_Tid) {
ASSERT_TRUE(BufferOrError);
ASSERT_TRUE(*BufferOrError);
}
-#endif // #if defined(_AIX) || defined(__linux__)
+#endif // #if (defined(_AIX) || defined(__linux__)) &&
+ // defined(LLVM_ENABLE_THREADING)
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4f72abd - [LLDB] Add support for the structured data plugins in lldb-server (#159457)
Author: Walter Erquinigo
Date: 2025-09-18T10:40:55-04:00
New Revision: 4f72abd8404efa3de32188429d5f079ad12264e3
URL:
https://github.com/llvm/llvm-project/commit/4f72abd8404efa3de32188429d5f079ad12264e3
DIFF:
https://github.com/llvm/llvm-project/commit/4f72abd8404efa3de32188429d5f079ad12264e3.diff
LOG: [LLDB] Add support for the structured data plugins in lldb-server (#159457)
The LLDB client has support for structured data plugins, but lldb-server
doesn't have corresponding support for it. This patch adds the missing
functionality in LLGS for servers to register their supported plugins
and send corresponding async messages.
Added:
Modified:
lldb/include/lldb/Host/common/NativeProcessProtocol.h
lldb/include/lldb/Utility/StringExtractorGDBRemote.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
lldb/source/Utility/StringExtractorGDBRemote.cpp
lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp
Removed:
diff --git a/lldb/include/lldb/Host/common/NativeProcessProtocol.h
b/lldb/include/lldb/Host/common/NativeProcessProtocol.h
index 1d5fecfcd5c27..06b36c2cc9eb5 100644
--- a/lldb/include/lldb/Host/common/NativeProcessProtocol.h
+++ b/lldb/include/lldb/Host/common/NativeProcessProtocol.h
@@ -409,6 +409,14 @@ class NativeProcessProtocol {
"Not implemented");
}
+ /// Get the list of structured data plugins supported by this process. They
+ /// must match the `type` field used by the corresponding
+ /// StructuredDataPlugins in the client.
+ ///
+ /// \return
+ /// A vector of structured data plugin names.
+ virtual std::vector GetStructuredDataPlugins() { return {}; };
+
protected:
struct SoftwareBreakpoint {
uint32_t ref_count;
diff --git a/lldb/include/lldb/Utility/StringExtractorGDBRemote.h
b/lldb/include/lldb/Utility/StringExtractorGDBRemote.h
index dd468ef5bddef..439245fdc3083 100644
--- a/lldb/include/lldb/Utility/StringExtractorGDBRemote.h
+++ b/lldb/include/lldb/Utility/StringExtractorGDBRemote.h
@@ -119,6 +119,7 @@ class StringExtractorGDBRemote : public StringExtractor {
eServerPacketType_qRegisterInfo,
eServerPacketType_qShlibInfoAddr,
eServerPacketType_qStepPacketSupported,
+eServerPacketType_qStructuredDataPlugins,
eServerPacketType_qSupported,
eServerPacketType_qSyncThreadStateSupported,
eServerPacketType_qThreadExtraInfo,
diff --git
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index e3202d62ec7c8..2f62415446b7a 100644
---
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -146,6 +146,9 @@ void
GDBRemoteCommunicationServerLLGS::RegisterPacketHandlers() {
RegisterMemberFunctionHandler(
StringExtractorGDBRemote::eServerPacketType_QSetWorkingDir,
&GDBRemoteCommunicationServerLLGS::Handle_QSetWorkingDir);
+ RegisterMemberFunctionHandler(
+ StringExtractorGDBRemote::eServerPacketType_qStructuredDataPlugins,
+ &GDBRemoteCommunicationServerLLGS::Handle_qStructuredDataPlugins);
RegisterMemberFunctionHandler(
StringExtractorGDBRemote::eServerPacketType_qsThreadInfo,
&GDBRemoteCommunicationServerLLGS::Handle_qsThreadInfo);
@@ -1245,6 +1248,19 @@ Status
GDBRemoteCommunicationServerLLGS::InitializeConnection(
return error;
}
+GDBRemoteCommunication::PacketResult
+GDBRemoteCommunicationServerLLGS::SendStructuredDataPacket(
+const llvm::json::Value &value) {
+ std::string json_string;
+ raw_string_ostream os(json_string);
+ os << value;
+
+ StreamGDBRemote escaped_response;
+ escaped_response.PutCString("JSON-async:");
+ escaped_response.PutEscapedBytes(json_string.c_str(), json_string.size());
+ return SendPacketNoLock(escaped_response.GetString());
+}
+
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerLLGS::SendONotification(const char *buffer,
uint32_t len) {
@@ -1436,6 +1452,21 @@
GDBRemoteCommunicationServerLLGS::Handle_jLLDBTraceGetBinaryData(
return SendErrorResponse(bytes.takeError());
}
+GDBRemoteCommunication::PacketResult
+GDBRemoteCommunicationServerLLGS::Handle_qStructuredDataPlugins(
+StringExtractorGDBRemote &packet) {
+ // Fail if we don't have a current process.
+ if (!m_current_process ||
+ (m_current_process->GetID() == LLDB_INVALID_PROCESS_ID))
+return SendErrorResponse(68);
+
+ std::vector structured_data_plugins =
+ m_current_process->GetStructuredDataPlugins();
+
+ return SendJSONResponse(
+ llvm::json::Value(llvm::json::Array(structured_data_plugins)));
+}
+
GDBRemoteCommuni
[Lldb-commits] [lldb] RISCV unwinding enable (PR #158161)
https://github.com/barsolo2000 updated
https://github.com/llvm/llvm-project/pull/158161
>From 827f68dcc9b6e207ff324f1be353561ee10892d1 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik
Date: Thu, 11 Sep 2025 14:06:05 -0700
Subject: [PATCH 1/5] RISCV unwinding enable
---
lldb/include/lldb/Core/Opcode.h | 4 +-
.../RISCV/EmulateInstructionRISCV.cpp | 165 +--
.../RISCV/EmulateInstructionRISCV.h | 4 +
lldb/unittests/Instruction/CMakeLists.txt | 5 +
.../RISCV/TestRiscvInstEmulation.cpp | 194 ++
5 files changed, 359 insertions(+), 13 deletions(-)
create mode 100644 lldb/unittests/Instruction/RISCV/TestRiscvInstEmulation.cpp
diff --git a/lldb/include/lldb/Core/Opcode.h b/lldb/include/lldb/Core/Opcode.h
index 7bbd73d039f99..7e756d3f15d22 100644
--- a/lldb/include/lldb/Core/Opcode.h
+++ b/lldb/include/lldb/Core/Opcode.h
@@ -223,7 +223,9 @@ class Opcode {
int Dump(Stream *s, uint32_t min_byte_width) const;
const void *GetOpcodeBytes() const {
-return ((m_type == Opcode::eTypeBytes) ? m_data.inst.bytes : nullptr);
+return ((m_type == Opcode::eTypeBytes || m_type ==
Opcode::eType16_32Tuples)
+? m_data.inst.bytes
+: nullptr);
}
uint32_t GetByteSize() const {
diff --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
index 5e429a92613ce..7a56dcaa2f2db 100644
--- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
+++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
@@ -230,10 +230,36 @@ Load(EmulateInstructionRISCV &emulator, I inst, uint64_t
(*extend)(E)) {
auto addr = LoadStoreAddr(emulator, inst);
if (!addr)
return false;
- return transformOptional(
- emulator.ReadMem(*addr),
- [&](T t) { return inst.rd.Write(emulator, extend(E(t))); })
- .value_or(false);
+
+ // Set up context for the load operation, similar to ARM64
+ EmulateInstructionRISCV::Context context;
+
+ // Get register info for base register
+ uint32_t rs1_lldb = GPREncodingToLLDB(inst.rs1.rs);
+ std::optional reg_info_rs1 =
+ emulator.GetRegisterInfo(eRegisterKindLLDB, rs1_lldb);
+
+ if (!reg_info_rs1)
+return false;
+
+ // Set context type based on whether this is a stack-based load
+ if (inst.rs1.rs == 2) { // x2 is the stack pointer in RISC-V
+context.type = EmulateInstruction::eContextPopRegisterOffStack;
+ } else {
+context.type = EmulateInstruction::eContextRegisterLoad;
+ }
+
+ // Set the context address information
+ context.SetAddress(*addr);
+
+ // Read from memory with context and write to register
+ bool success = false;
+ uint64_t value =
+ emulator.ReadMemoryUnsigned(context, *addr, sizeof(T), 0, &success);
+ if (!success)
+return false;
+
+ return inst.rd.Write(emulator, extend(E(T(value;
}
template
@@ -242,9 +268,38 @@ Store(EmulateInstructionRISCV &emulator, I inst) {
auto addr = LoadStoreAddr(emulator, inst);
if (!addr)
return false;
- return transformOptional(
- inst.rs2.Read(emulator),
- [&](uint64_t rs2) { return emulator.WriteMem(*addr, rs2); })
+
+ // Set up context for the store operation, similar to ARM64
+ EmulateInstructionRISCV::Context context;
+
+ // Get register info for source and base registers
+ uint32_t rs1_lldb = GPREncodingToLLDB(inst.rs1.rs);
+ uint32_t rs2_lldb = GPREncodingToLLDB(inst.rs2.rs);
+ std::optional reg_info_rs1 =
+ emulator.GetRegisterInfo(eRegisterKindLLDB, rs1_lldb);
+ std::optional reg_info_rs2 =
+ emulator.GetRegisterInfo(eRegisterKindLLDB, rs2_lldb);
+
+ if (!reg_info_rs1 || !reg_info_rs2)
+return false;
+
+ // Set context type based on whether this is a stack-based store
+ if (inst.rs1.rs == 2) { // x2 is the stack pointer in RISC-V
+context.type = EmulateInstruction::eContextPushRegisterOnStack;
+ } else {
+context.type = EmulateInstruction::eContextRegisterStore;
+ }
+
+ // Set the context to show which register is being stored to which base
+ // register + offset
+ context.SetRegisterToRegisterPlusOffset(*reg_info_rs2, *reg_info_rs1,
+ SignExt(inst.imm));
+
+ return transformOptional(inst.rs2.Read(emulator),
+ [&](uint64_t rs2) {
+ return emulator.WriteMemoryUnsigned(
+ context, *addr, rs2, sizeof(T));
+ })
.value_or(false);
}
@@ -737,11 +792,42 @@ class Executor {
bool operator()(SH inst) { return Store(m_emu, inst); }
bool operator()(SW inst) { return Store(m_emu, inst); }
bool operator()(ADDI inst) {
-return transformOptional(inst.rs1.ReadI64(m_emu),
- [&](int64_t rs1) {
- return inst.rd.Write(
- m_em
[Lldb-commits] [lldb] 88b5c74 - [lldb] Correct 32-bit build failure in StopInfoMachException.cpp (#159523)
Author: David Spickett
Date: 2025-09-18T09:59:02+01:00
New Revision: 88b5c7435e70702d54772c1ec3864013099edc6c
URL:
https://github.com/llvm/llvm-project/commit/88b5c7435e70702d54772c1ec3864013099edc6c
DIFF:
https://github.com/llvm/llvm-project/commit/88b5c7435e70702d54772c1ec3864013099edc6c.diff
LOG: [lldb] Correct 32-bit build failure in StopInfoMachException.cpp (#159523)
uintptr_t is usually a good idea when handling pointers, but lldb has to
handle 64-bit addresses that might be from a remote system, on a 32-bit
system.
So I've changed a few instances here to use addr_t which is 64-bit
everywhere.
Before we got:
https://lab.llvm.org/buildbot/#/builders/18/builds/21247
```
../llvm-project/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:81:28:
error: constexpr variable 'g_mte_tag_mask' must be initialized by a constant
expression
81 | static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f <<
g_mte_tag_shift;
|^
~~
../llvm-project/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:81:61:
note: shift count 56 >= width of type 'uintptr_t' (aka 'unsigned int') (32
bits)
81 | static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f <<
g_mte_tag_shift;
| ^
1 error generated.
```
Original code added by #159117.
Added:
Modified:
lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
Removed:
diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
index 6853121f3e01c..601cfdcb4e9f7 100644
--- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -78,7 +78,7 @@ static void DescribeAddressBriefly(Stream &strm, const
Address &addr,
}
static constexpr uint8_t g_mte_tag_shift = 64 - 8;
-static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f << g_mte_tag_shift;
+static constexpr addr_t g_mte_tag_mask = (addr_t)0x0f << g_mte_tag_shift;
bool StopInfoMachException::DetermineTagMismatch(ExecutionContext &exe_ctx) {
const bool IsBadAccess = m_value == 1;// EXC_BAD_ACCESS
@@ -97,7 +97,7 @@ bool
StopInfoMachException::DetermineTagMismatch(ExecutionContext &exe_ctx) {
m_exc_code, bad_address);
const uint8_t tag = (bad_address & g_mte_tag_mask) >> g_mte_tag_shift;
- const uint64_t canonical_addr = bad_address & ~g_mte_tag_mask;
+ const addr_t canonical_addr = bad_address & ~g_mte_tag_mask;
strm.Printf(
"Note: MTE tag mismatch detected: pointer tag=%d, address=0x%" PRIx64,
tag, canonical_addr);
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)
https://github.com/tgs-sc updated
https://github.com/llvm/llvm-project/pull/154123
>From a2390655ad8a77ef9f1087e24089e36d8925e604 Mon Sep 17 00:00:00 2001
From: Timur Golubovich
Date: Mon, 18 Aug 2025 17:29:01 +0300
Subject: [PATCH 1/2] [lldb][DWARFASTParserClang] Added a check for the
specialization existence
While debugging an application with incorrect dwarf information, where
DW_TAG_template_value_parameter was lost, I found that lldb does not
check that the corresponding specialization exists. As a result, at the
stage when ASTImporter works, the type is completed in such a way that
it inherits from itself. And during the calculation of layout, an
infinite recursion occurs. To catch this error, I added a corresponding check
at the stage of restoring the type from dwarf information.
---
.../SymbolFile/DWARF/DWARFASTParserClang.cpp | 18 +
.../unittests/SymbolFile/DWARF/CMakeLists.txt | 3 +-
.../DWARF/DWARFASTParserClangTests.cpp| 33 +
.../Inputs/DW_AT_spec_decl_exists-test.yaml | 675 ++
4 files changed, 728 insertions(+), 1 deletion(-)
create mode 100644
lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_spec_decl_exists-test.yaml
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index c76d67b47b336..153730f05f3cd 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1873,6 +1873,24 @@ DWARFASTParserClang::ParseStructureLikeDIE(const
SymbolContext &sc,
clang_type =
m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
+// Try to find an existing specialization with these template arguments and
+// template parameter list.
+void *InsertPos = nullptr;
+llvm::ArrayRef args =
+template_param_infos.GetArgs();
+if (!args.empty() &&
+!class_template_decl->findSpecialization(args, InsertPos))
+ // Add this specialization to the class template.
+ class_template_decl->AddSpecialization(class_specialization_decl,
+ InsertPos);
+else {
+ dwarf->GetObjectFile()->GetModule()->LogMessage(
+ "SymbolFileDWARF({0:p}) - Specialization for "
+ "clang::ClassTemplateDecl({1:p}) already exists.",
+ static_cast(this), static_cast(class_template_decl));
+ return TypeSP();
+}
+
m_ast.SetMetadata(class_template_decl, metadata);
m_ast.SetMetadata(class_specialization_decl, metadata);
}
diff --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
index eb2e00adba64b..88492188e794b 100644
--- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -27,6 +27,7 @@ add_lldb_unittest(SymbolFileDWARFTests
set(test_inputs
test-dwarf.exe
- DW_AT_default_value-test.yaml)
+ DW_AT_default_value-test.yaml
+ DW_AT_spec_decl_exists-test.yaml)
add_unittest_inputs(SymbolFileDWARFTests "${test_inputs}")
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
index d608a57382096..7886c5f16a053 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
@@ -599,6 +599,39 @@ TEST_F(DWARFASTParserClangTests,
TestDefaultTemplateParamParsing) {
}
}
+TEST_F(DWARFASTParserClangTests, TestSpecDeclExistsError) {
+ // Tests checking error if ClassTemplateSpecializationDecl already exists.
+ auto BufferOrError = llvm::MemoryBuffer::getFile(
+ GetInputFilePath("DW_AT_spec_decl_exists-test.yaml"), /*IsText=*/true);
+ ASSERT_TRUE(BufferOrError);
+ YAMLModuleTester t(BufferOrError.get()->getBuffer());
+
+ DWARFUnit *unit = t.GetDwarfUnit();
+ ASSERT_NE(unit, nullptr);
+ const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();
+ ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);
+ DWARFDIE cu_die(unit, cu_entry);
+
+ auto holder = std::make_unique("ast");
+ auto &ast_ctx = *holder->GetAST();
+ DWARFASTParserClangStub ast_parser(ast_ctx);
+
+ llvm::SmallVector types;
+ for (DWARFDIE die : cu_die.children()) {
+if (die.Tag() == DW_TAG_structure_type) {
+ SymbolContext sc;
+ bool new_type = false;
+ auto type = ast_parser.ParseTypeFromDWARF(sc, die, &new_type);
+ types.push_back(std::move(type));
+}
+ }
+
+ ASSERT_EQ(types.size(), 3U);
+ ASSERT_NE(types[0], nullptr);
+ ASSERT_NE(types[1], nullptr);
+ ASSERT_EQ(types[2], nullptr);
+}
+
TEST_F(DWARFASTParserClangTests, TestUniqueDWARFASTTypeMap_CppInsertMapFind) {
// This tests the behaviour of UniqueDWARFASTTypeMap under
// following scenario:
diff --git
a/lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_spec_decl_exists-test.yaml
b/lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_spec_decl_exi
[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)
@@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -foverflow-behavior-types -std=c++11 -ast-print %s -o - | FileCheck %s + +extern int __attribute__((overflow_behavior(no_wrap))) a; +extern int __attribute__((overflow_behavior(wrap))) b; + +// CHECK: extern __no_wrap int a; +// CHECK: extern __wrap int b; JustinStitt wrote: I am not inheriting from `AttributedType`. These overflow behavior types are being turned directly into a canonical OBT. ```c typedef int __attribute__((overflow_behavior(no_wrap))) nw_int; ... `-TypedefDecl 0x55d0afc0d998 col:57 nw_int 'int __attribute__((overflow_behavior(no_wrap)))' `-OverflowBehaviorType 0x55d0afc0d7b0 'int __attribute__((overflow_behavior(no_wrap)))' `-BuiltinType 0x55d0afba5000 'int' ``` Also, to get the argument (behavior kind) to appear I believe we need to do this manually -- like what is done for `TypePrinter::printBTFTagAttributedBefore()`. This let's me get `overflow_behavior(no_wrap)` or `overflow_behavior(wrap)` printed out. So to summarize, I'm not sure if I can re-use the `AttributedType` handling for OBTs and even if we could, I'd still need to manually re-insert the behavior kind. https://github.com/llvm/llvm-project/pull/148914 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Remove no-op calls to Fix*Address (PR #159586)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/159586 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Architecture plugins should report the vector element order (PR #157198)
https://github.com/DavidSpickett approved this pull request. If this is required for the parent PR and that PR is eventually approved, this LGTM. Please add System Z to the listed systems in the PR description. That detail may come in handy one day. https://github.com/llvm/llvm-project/pull/157198 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [vscode-lldb] Restart server when the lldb-dap binary's modification time has changed (PR #159481)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/159481 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [vscode-lldb] Restart server when the lldb-dap binary's modification time has changed (PR #159481)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/159481 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Simplify logic in ABIMacOSX_arm64::FixDataAddress (PR #159612)
https://github.com/felipepiovezan updated
https://github.com/llvm/llvm-project/pull/159612
>From 9214bba07c1e0e0795d2a963d4161b208f96ed85 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan
Date: Mon, 15 Sep 2025 15:53:39 -0700
Subject: [PATCH 1/3] [lldb][NFC] Simplify logic in
ABIMacOSX_arm64::FixDataAddress
---
.../Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp | 52 ++-
1 file changed, 28 insertions(+), 24 deletions(-)
diff --git a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
index 094e0523a4edf..db4e73ba76544 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
@@ -758,41 +758,45 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
}
addr_t ABIMacOSX_arm64::FixCodeAddress(addr_t pc) {
- addr_t pac_sign_extension = 0x0080ULL;
+ ProcessSP process_sp = GetProcessSP();
+ if (!process_sp)
+return pc;
+
+ addr_t mask = process_sp->GetCodeAddressMask();
addr_t tbi_mask = 0xff80ULL;
- addr_t mask = 0;
-
- if (ProcessSP process_sp = GetProcessSP()) {
-mask = process_sp->GetCodeAddressMask();
-if (pc & pac_sign_extension) {
- addr_t highmem_mask = process_sp->GetHighmemCodeAddressMask();
- if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
-mask = highmem_mask;
-}
- }
if (mask == LLDB_INVALID_ADDRESS_MASK)
mask = tbi_mask;
- return (pc & pac_sign_extension) ? pc | mask : pc & (~mask);
+ addr_t pac_sign_extension = 0x0080ULL;
+ if (pc & pac_sign_extension) {
+addr_t highmem_mask = process_sp->GetHighmemCodeAddressMask();
+if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
+ return pc | highmem_mask;
+return pc | mask;
+ }
+
+ return pc & (~mask);
}
addr_t ABIMacOSX_arm64::FixDataAddress(addr_t pc) {
- addr_t pac_sign_extension = 0x0080ULL;
+ ProcessSP process_sp = GetProcessSP();
+ if (!process_sp)
+return pc;
+
+ addr_t mask = process_sp->GetDataAddressMask();
addr_t tbi_mask = 0xff80ULL;
- addr_t mask = 0;
-
- if (ProcessSP process_sp = GetProcessSP()) {
-mask = process_sp->GetDataAddressMask();
-if (pc & pac_sign_extension) {
- addr_t highmem_mask = process_sp->GetHighmemDataAddressMask();
- if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
-mask = highmem_mask;
-}
- }
if (mask == LLDB_INVALID_ADDRESS_MASK)
mask = tbi_mask;
- return (pc & pac_sign_extension) ? pc | mask : pc & (~mask);
+ addr_t pac_sign_extension = 0x0080ULL;
+ if (pc & pac_sign_extension) {
+addr_t highmem_mask = process_sp->GetHighmemDataAddressMask();
+if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
+ return pc | highmem_mask;
+return pc | mask;
+ }
+
+ return pc & (~mask);
}
void ABIMacOSX_arm64::Initialize() {
>From 3243ab7bced75c3e69469e8270c16e284af68a19 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan
Date: Thu, 18 Sep 2025 10:29:58 -0700
Subject: [PATCH 2/3] fixup! Reuse code across functions
---
.../Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp | 47 ---
1 file changed, 19 insertions(+), 28 deletions(-)
diff --git a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
index db4e73ba76544..16aafe640b1a4 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
@@ -757,46 +757,37 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
return return_valobj_sp;
}
-addr_t ABIMacOSX_arm64::FixCodeAddress(addr_t pc) {
- ProcessSP process_sp = GetProcessSP();
+constexpr addr_t tbi_mask = 0xff80ULL;
+constexpr addr_t pac_sign_extension = 0x0080ULL;
+
+static addr_t DoFixAddr(addr_t addr, bool is_code, ProcessSP process_sp) {
if (!process_sp)
-return pc;
+return addr;
- addr_t mask = process_sp->GetCodeAddressMask();
- addr_t tbi_mask = 0xff80ULL;
+ addr_t mask = is_code ? process_sp->GetCodeAddressMask()
+: process_sp->GetDataAddressMask();
if (mask == LLDB_INVALID_ADDRESS_MASK)
mask = tbi_mask;
- addr_t pac_sign_extension = 0x0080ULL;
- if (pc & pac_sign_extension) {
-addr_t highmem_mask = process_sp->GetHighmemCodeAddressMask();
+ if (addr & pac_sign_extension) {
+addr_t highmem_mask = is_code ? process_sp->GetHighmemCodeAddressMask()
+ : process_sp->GetHighmemCodeAddressMask();
if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
- return pc | highmem_mask;
-return pc | mask;
+ return addr | highmem_mask;
+return addr | mask;
}
- return pc & (~mask);
+ return addr & (~mask);
}
-addr_t ABIMacOSX_arm64::FixDataAddress(addr_t pc) {
+addr_t ABIMacOSX_arm64::FixCodeAddress(addr_t pc) {
ProcessSP process_sp = GetProcessSP();
- if (!process_sp
[Lldb-commits] [lldb] [vscode-lldb] Restart server when the lldb-dap binary's modification time has changed (PR #159481)
https://github.com/royitaqi updated
https://github.com/llvm/llvm-project/pull/159481
>From bb9541a27f618326abb1968c0d89313cd38dbbde Mon Sep 17 00:00:00 2001
From: Roy Shi
Date: Wed, 17 Sep 2025 16:26:06 -0700
Subject: [PATCH 1/2] [vscode-lldb] Restart server when lldb-dap's modification
time has changed
---
lldb/tools/lldb-dap/.vscode/launch.json | 10 +--
lldb/tools/lldb-dap/package-lock.json | 66 +++
lldb/tools/lldb-dap/package.json | 4 ++
lldb/tools/lldb-dap/src-ts/lldb-dap-server.ts | 31 ++---
4 files changed, 97 insertions(+), 14 deletions(-)
diff --git a/lldb/tools/lldb-dap/.vscode/launch.json
b/lldb/tools/lldb-dap/.vscode/launch.json
index 8241a5aca0354..524fc2dd5ce7b 100644
--- a/lldb/tools/lldb-dap/.vscode/launch.json
+++ b/lldb/tools/lldb-dap/.vscode/launch.json
@@ -14,11 +14,11 @@
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
- ],
- "preLaunchTask": {
- "type": "npm",
- "script": "watch"
- }
+ ]
+ // "preLaunchTask": {
+ // "type": "npm",
+ // "script": "watch"
+ // }
}
]
}
diff --git a/lldb/tools/lldb-dap/package-lock.json
b/lldb/tools/lldb-dap/package-lock.json
index 26db1ce6df2fd..92143f7f37268 100644
--- a/lldb/tools/lldb-dap/package-lock.json
+++ b/lldb/tools/lldb-dap/package-lock.json
@@ -8,7 +8,11 @@
"name": "lldb-dap",
"version": "0.2.16",
"license": "Apache 2.0 License with LLVM exceptions",
+ "dependencies": {
+"fs-extra": "^11.3.2"
+ },
"devDependencies": {
+"@types/fs-extra": "^11.0.4",
"@types/node": "^18.19.41",
"@types/tabulator-tables": "^6.2.10",
"@types/vscode": "1.75.0",
@@ -835,6 +839,27 @@
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
+"node_modules/@types/fs-extra": {
+ "version": "11.0.4",
+ "resolved":
"https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.4.tgz";,
+ "integrity":
"sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+"@types/jsonfile": "*",
+"@types/node": "*"
+ }
+},
+"node_modules/@types/jsonfile": {
+ "version": "6.1.4",
+ "resolved":
"https://registry.npmjs.org/@types/jsonfile/-/jsonfile-6.1.4.tgz";,
+ "integrity":
"sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+"@types/node": "*"
+ }
+},
"node_modules/@types/node": {
"version": "18.19.75",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.75.tgz";,
@@ -1748,6 +1773,20 @@
"dev": true,
"optional": true
},
+"node_modules/fs-extra": {
+ "version": "11.3.2",
+ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.2.tgz";,
+ "integrity":
"sha512-Xr9F6z6up6Ws+NjzMCZc6WXg2YFRlrLP9NQDO3VQrWrfiojdhS56TzueT88ze0uBdCTwEIhQ3ptnmKeWGFAe0A==",
+ "license": "MIT",
+ "dependencies": {
+"graceful-fs": "^4.2.0",
+"jsonfile": "^6.0.1",
+"universalify": "^2.0.0"
+ },
+ "engines": {
+"node": ">=14.14"
+ }
+},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved":
"https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz";,
@@ -1877,6 +1916,12 @@
"url": "https://github.com/sponsors/ljharb";
}
},
+"node_modules/graceful-fs": {
+ "version": "4.2.11",
+ "resolved":
"https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz";,
+ "integrity":
"sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
+ "license": "ISC"
+},
"node_modules/has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz";,
@@ -2094,6 +2139,18 @@
"integrity":
"sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==",
"dev": true
},
+"node_modules/jsonfile": {
+ "version": "6.2.0",
+ "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz";,
+ "integrity":
"sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==",
+ "license": "MIT",
+ "dependencies": {
+"universalify": "^2.0.0"
+ },
+ "optionalDependencies": {
+"graceful-fs": "^4.1.6"
+ }
+},
"node_modules/jsonwebtoken": {
"version": "9.0.2",
"r
[Lldb-commits] [lldb] [vscode-lldb] Restart server when the lldb-dap binary's modification time has changed (PR #159481)
royitaqi wrote: Reverted the unintended changes in the "modification time" approach by 4b989d8536bdee440d434f05ccc76c1c4bdc5647. cc @walter-erquinigo, in case you think the "modification time" approach is okay to go after reading [my last comment](https://github.com/llvm/llvm-project/pull/159481#discussion_r2360564909). -- Still trying to figure out why my local `createFileSystemWatcher` implementation doesn't work... https://github.com/llvm/llvm-project/pull/159481 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix a bug where an error was emitted for GCC union types. (PR #159401)
Teemperor wrote: LGTM, but maybe wait a few days for one of the actually active contributors before merging https://github.com/llvm/llvm-project/pull/159401 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Simplify logic in ABIMacOSX_arm64::FixDataAddress (PR #159612)
https://github.com/felipepiovezan created
https://github.com/llvm/llvm-project/pull/159612
I've intentionally split this into two commits to make it easier that this is
an NFC patch; don't think we need to preserve them separately though upon
merging.
>From 9214bba07c1e0e0795d2a963d4161b208f96ed85 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan
Date: Mon, 15 Sep 2025 15:53:39 -0700
Subject: [PATCH 1/2] [lldb][NFC] Simplify logic in
ABIMacOSX_arm64::FixDataAddress
---
.../Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp | 52 ++-
1 file changed, 28 insertions(+), 24 deletions(-)
diff --git a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
index 094e0523a4edf..db4e73ba76544 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
@@ -758,41 +758,45 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
}
addr_t ABIMacOSX_arm64::FixCodeAddress(addr_t pc) {
- addr_t pac_sign_extension = 0x0080ULL;
+ ProcessSP process_sp = GetProcessSP();
+ if (!process_sp)
+return pc;
+
+ addr_t mask = process_sp->GetCodeAddressMask();
addr_t tbi_mask = 0xff80ULL;
- addr_t mask = 0;
-
- if (ProcessSP process_sp = GetProcessSP()) {
-mask = process_sp->GetCodeAddressMask();
-if (pc & pac_sign_extension) {
- addr_t highmem_mask = process_sp->GetHighmemCodeAddressMask();
- if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
-mask = highmem_mask;
-}
- }
if (mask == LLDB_INVALID_ADDRESS_MASK)
mask = tbi_mask;
- return (pc & pac_sign_extension) ? pc | mask : pc & (~mask);
+ addr_t pac_sign_extension = 0x0080ULL;
+ if (pc & pac_sign_extension) {
+addr_t highmem_mask = process_sp->GetHighmemCodeAddressMask();
+if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
+ return pc | highmem_mask;
+return pc | mask;
+ }
+
+ return pc & (~mask);
}
addr_t ABIMacOSX_arm64::FixDataAddress(addr_t pc) {
- addr_t pac_sign_extension = 0x0080ULL;
+ ProcessSP process_sp = GetProcessSP();
+ if (!process_sp)
+return pc;
+
+ addr_t mask = process_sp->GetDataAddressMask();
addr_t tbi_mask = 0xff80ULL;
- addr_t mask = 0;
-
- if (ProcessSP process_sp = GetProcessSP()) {
-mask = process_sp->GetDataAddressMask();
-if (pc & pac_sign_extension) {
- addr_t highmem_mask = process_sp->GetHighmemDataAddressMask();
- if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
-mask = highmem_mask;
-}
- }
if (mask == LLDB_INVALID_ADDRESS_MASK)
mask = tbi_mask;
- return (pc & pac_sign_extension) ? pc | mask : pc & (~mask);
+ addr_t pac_sign_extension = 0x0080ULL;
+ if (pc & pac_sign_extension) {
+addr_t highmem_mask = process_sp->GetHighmemDataAddressMask();
+if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
+ return pc | highmem_mask;
+return pc | mask;
+ }
+
+ return pc & (~mask);
}
void ABIMacOSX_arm64::Initialize() {
>From 3243ab7bced75c3e69469e8270c16e284af68a19 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan
Date: Thu, 18 Sep 2025 10:29:58 -0700
Subject: [PATCH 2/2] fixup! Reuse code across functions
---
.../Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp | 47 ---
1 file changed, 19 insertions(+), 28 deletions(-)
diff --git a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
index db4e73ba76544..16aafe640b1a4 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
@@ -757,46 +757,37 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
return return_valobj_sp;
}
-addr_t ABIMacOSX_arm64::FixCodeAddress(addr_t pc) {
- ProcessSP process_sp = GetProcessSP();
+constexpr addr_t tbi_mask = 0xff80ULL;
+constexpr addr_t pac_sign_extension = 0x0080ULL;
+
+static addr_t DoFixAddr(addr_t addr, bool is_code, ProcessSP process_sp) {
if (!process_sp)
-return pc;
+return addr;
- addr_t mask = process_sp->GetCodeAddressMask();
- addr_t tbi_mask = 0xff80ULL;
+ addr_t mask = is_code ? process_sp->GetCodeAddressMask()
+: process_sp->GetDataAddressMask();
if (mask == LLDB_INVALID_ADDRESS_MASK)
mask = tbi_mask;
- addr_t pac_sign_extension = 0x0080ULL;
- if (pc & pac_sign_extension) {
-addr_t highmem_mask = process_sp->GetHighmemCodeAddressMask();
+ if (addr & pac_sign_extension) {
+addr_t highmem_mask = is_code ? process_sp->GetHighmemCodeAddressMask()
+ : process_sp->GetHighmemCodeAddressMask();
if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
- return pc | highmem_mask;
-return pc | mask;
+ return addr | highmem_mask;
+return addr | mask;
}
- return pc & (~mask);
+ return addr & (~mask);
}
-a
[Lldb-commits] [lldb] [lldb][NFC] Simplify logic in ABIMacOSX_arm64::FixDataAddress (PR #159612)
llvmbot wrote:
@llvm/pr-subscribers-lldb
Author: Felipe de Azevedo Piovezan (felipepiovezan)
Changes
I've intentionally split this into two commits to make it easier that this is
an NFC patch; don't think we need to preserve them separately though upon
merging.
---
Full diff: https://github.com/llvm/llvm-project/pull/159612.diff
1 Files Affected:
- (modified) lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp (+25-30)
``diff
diff --git a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
index 094e0523a4edf..16aafe640b1a4 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
@@ -757,42 +757,37 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
return return_valobj_sp;
}
-addr_t ABIMacOSX_arm64::FixCodeAddress(addr_t pc) {
- addr_t pac_sign_extension = 0x0080ULL;
- addr_t tbi_mask = 0xff80ULL;
- addr_t mask = 0;
-
- if (ProcessSP process_sp = GetProcessSP()) {
-mask = process_sp->GetCodeAddressMask();
-if (pc & pac_sign_extension) {
- addr_t highmem_mask = process_sp->GetHighmemCodeAddressMask();
- if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
-mask = highmem_mask;
-}
- }
+constexpr addr_t tbi_mask = 0xff80ULL;
+constexpr addr_t pac_sign_extension = 0x0080ULL;
+
+static addr_t DoFixAddr(addr_t addr, bool is_code, ProcessSP process_sp) {
+ if (!process_sp)
+return addr;
+
+ addr_t mask = is_code ? process_sp->GetCodeAddressMask()
+: process_sp->GetDataAddressMask();
if (mask == LLDB_INVALID_ADDRESS_MASK)
mask = tbi_mask;
- return (pc & pac_sign_extension) ? pc | mask : pc & (~mask);
+ if (addr & pac_sign_extension) {
+addr_t highmem_mask = is_code ? process_sp->GetHighmemCodeAddressMask()
+ : process_sp->GetHighmemCodeAddressMask();
+if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
+ return addr | highmem_mask;
+return addr | mask;
+ }
+
+ return addr & (~mask);
}
-addr_t ABIMacOSX_arm64::FixDataAddress(addr_t pc) {
- addr_t pac_sign_extension = 0x0080ULL;
- addr_t tbi_mask = 0xff80ULL;
- addr_t mask = 0;
-
- if (ProcessSP process_sp = GetProcessSP()) {
-mask = process_sp->GetDataAddressMask();
-if (pc & pac_sign_extension) {
- addr_t highmem_mask = process_sp->GetHighmemDataAddressMask();
- if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
-mask = highmem_mask;
-}
- }
- if (mask == LLDB_INVALID_ADDRESS_MASK)
-mask = tbi_mask;
+addr_t ABIMacOSX_arm64::FixCodeAddress(addr_t pc) {
+ ProcessSP process_sp = GetProcessSP();
+ return DoFixAddr(pc, true /*is_code*/, GetProcessSP());
+}
- return (pc & pac_sign_extension) ? pc | mask : pc & (~mask);
+addr_t ABIMacOSX_arm64::FixDataAddress(addr_t addr) {
+ ProcessSP process_sp = GetProcessSP();
+ return DoFixAddr(addr, false /*is_code*/, GetProcessSP());
}
void ABIMacOSX_arm64::Initialize() {
``
https://github.com/llvm/llvm-project/pull/159612
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixed UB in CPlusPlusLanguage plug-in (PR #158304)
https://github.com/slydiman created
https://github.com/llvm/llvm-project/pull/158304
C++11 allows the use of Universal Character Names (UCNs) in identifiers,
including function names.
According to the spec the behavior of std::isalpha(ch) and std::isalnum(ch) is
undefined if the argument's value is neither representable as unsigned char nor
equal to EOF. To use these functions safely with plain chars (or signed chars),
the argument should first be converted to unsigned char.
>From fb325b76b2fa8ae3898fe26e0859e50ad6ba Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev
Date: Fri, 12 Sep 2025 18:06:29 +0400
Subject: [PATCH] [lldb] Fixed UB in CPlusPlusLanguage plug-in
C++11 allows the use of Universal Character Names (UCNs) in identifiers,
including function names.
According to the spec the behavior of std::isalpha(ch) and std::isalnum(ch) is
undefined if the argument's value is neither representable as unsigned char nor
equal to EOF. To use these functions safely with plain chars (or signed chars),
the argument should first be converted to unsigned char.
---
.../source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp | 6 --
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp | 6 --
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 277de8f444828..1f7b8d48d0fc8 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -190,14 +190,16 @@ static bool IsTrivialBasename(const llvm::StringRef
&basename) {
if (basename.size() <= idx)
return false; // Empty string or "~"
- if (!std::isalpha(basename[idx]) && basename[idx] != '_')
+ if (!std::isalpha(static_cast(basename[idx])) &&
+ basename[idx] != '_')
return false; // First character (after removing the possible '~'') isn't
in
// [A-Za-z_]
// Read all characters matching [A-Za-z_0-9]
++idx;
while (idx < basename.size()) {
-if (!std::isalnum(basename[idx]) && basename[idx] != '_')
+if (!std::isalnum(static_cast(basename[idx])) &&
+basename[idx] != '_')
break;
++idx;
}
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 6053d042b29b1..141c5c9a2caf9 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -40,8 +40,10 @@ using namespace lldb_private::formatters;
static void consumeInlineNamespace(llvm::StringRef &name) {
// Delete past an inline namespace, if any: __[a-zA-Z0-9_]+::
auto scratch = name;
- if (scratch.consume_front("__") && std::isalnum(scratch[0])) {
-scratch = scratch.drop_while([](char c) { return std::isalnum(c); });
+ if (scratch.consume_front("__") &&
+ std::isalnum(static_cast(scratch[0]))) {
+scratch = scratch.drop_while(
+[](char c) { return std::isalnum(static_cast(c)); });
if (scratch.consume_front("::")) {
// Successfully consumed a namespace.
name = scratch;
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add memory event (PR #158437)
https://github.com/walter-erquinigo approved this pull request. https://github.com/llvm/llvm-project/pull/158437 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Don't call FixDataAddress when reading fp in ReadGPRValue (PR #159606)
https://github.com/felipepiovezan created https://github.com/llvm/llvm-project/pull/159606 Based on testing on processors that use pointer metadata, and with all the work done to delay calls to FixDataAddress, this is no longer necessary. Note that, with debugserver in particular, this is an NFC change: the code path here is for frame zero, and debugserver will strip metadata when reading fp from frame zero anyway. >From b92a88b62f27cce3df63e4bdad2e919015a8f7fc Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Thu, 18 Sep 2025 09:53:51 -0700 Subject: [PATCH] [lldb] Don't call FixDataAddress when reading fp in ReadGPRValue Based on testing on processors that use pointer metadata, and with all the work done to delay calls to FixDataAddress, this is no longer necessary. Note that, with debugserver in particular, this is an NFC change: the code path here is for frame zero, and debugserver will strip metadata when reading fp from frame zero anyway. --- lldb/source/Target/RegisterContextUnwind.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/lldb/source/Target/RegisterContextUnwind.cpp b/lldb/source/Target/RegisterContextUnwind.cpp index 3b018c09b8b72..197e1dd090bac 100644 --- a/lldb/source/Target/RegisterContextUnwind.cpp +++ b/lldb/source/Target/RegisterContextUnwind.cpp @@ -2228,9 +2228,6 @@ bool RegisterContextUnwind::ReadGPRValue(lldb::RegisterKind register_kind, if (generic_regnum == LLDB_REGNUM_GENERIC_PC || generic_regnum == LLDB_REGNUM_GENERIC_RA) value = abi_sp->FixCodeAddress(value); -if (generic_regnum == LLDB_REGNUM_GENERIC_SP || -generic_regnum == LLDB_REGNUM_GENERIC_FP) - value = abi_sp->FixDataAddress(value); } return true; } ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Don't call FixDataAddress when reading fp in ReadGPRValue (PR #159606)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Felipe de Azevedo Piovezan (felipepiovezan) Changes Based on testing on processors that use pointer metadata, and with all the work done to delay calls to FixDataAddress, this is no longer necessary. Note that, with debugserver in particular, this is an NFC change: the code path here is for frame zero, and debugserver will strip metadata when reading fp from frame zero anyway. --- Full diff: https://github.com/llvm/llvm-project/pull/159606.diff 1 Files Affected: - (modified) lldb/source/Target/RegisterContextUnwind.cpp (-3) ``diff diff --git a/lldb/source/Target/RegisterContextUnwind.cpp b/lldb/source/Target/RegisterContextUnwind.cpp index 3b018c09b8b72..197e1dd090bac 100644 --- a/lldb/source/Target/RegisterContextUnwind.cpp +++ b/lldb/source/Target/RegisterContextUnwind.cpp @@ -2228,9 +2228,6 @@ bool RegisterContextUnwind::ReadGPRValue(lldb::RegisterKind register_kind, if (generic_regnum == LLDB_REGNUM_GENERIC_PC || generic_regnum == LLDB_REGNUM_GENERIC_RA) value = abi_sp->FixCodeAddress(value); -if (generic_regnum == LLDB_REGNUM_GENERIC_SP || -generic_regnum == LLDB_REGNUM_GENERIC_FP) - value = abi_sp->FixDataAddress(value); } return true; } `` https://github.com/llvm/llvm-project/pull/159606 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Track CFA pointer metadata in StackID (PR #157498)
DavidSpickett wrote: I agree with the ultimate goal of being able to control the handling of non-address bits, but help me understand this part: > However, the CFA inside StackIDs is also used in other contexts through the > method StackID::GetCallFrameAddress. One notable case is DWARFExpression: the > computation of DW_OP_call_frame_address is done using StackID. This feeds > into many other places, e.g. expression evaluation (which may require a > signed pointer). As such, StackID must be able to provide both versions of > the CFA. Is this because this pointer may be used to work out the address of variables and if we had for example, a memory tagged stack variable, its address must preserve that tag so we can access it. That sort of thing? https://github.com/llvm/llvm-project/pull/157498 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB]Fix buffer-over-flow bug introduced in 157170 (PR #159588)
https://github.com/oontvoo closed https://github.com/llvm/llvm-project/pull/159588 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
@@ -100,22 +175,301 @@ template
class Transport {
virtual llvm::Expected
RegisterMessageHandler(MainLoop &loop, MessageHandler &handler) = 0;
- // FIXME: Refactor mcp::Server to not directly access log on the transport.
- // protected:
+protected:
template inline auto Logv(const char *Fmt, Ts &&...Vals) {
Log(llvm::formatv(Fmt, std::forward(Vals)...).str());
}
virtual void Log(llvm::StringRef message) = 0;
+
+ /// Function object to reply to a call.
+ /// Each instance must be called exactly once, otherwise:
+ /// - the bug is logged, and (in debug mode) an assert will fire
+ /// - if there was no reply, an error reply is sent
+ /// - if there were multiple replies, only the first is sent
+ class ReplyOnce {
+std::atomic replied = {false};
+const Req req;
+JSONTransport *transport; // Null when moved-from.
+JSONTransport::MessageHandler *handler; // Null when moved-from.
+
+ public:
+ReplyOnce(const Req req, JSONTransport *transport,
+ JSONTransport::MessageHandler *handler)
+: req(req), transport(transport), handler(handler) {
+ assert(handler);
+}
+ReplyOnce(ReplyOnce &&other)
+: replied(other.replied.load()), req(other.req),
+ transport(other.transport), handler(other.handler) {
+ other.transport = nullptr;
+ other.handler = nullptr;
+}
+ReplyOnce &operator=(ReplyOnce &&) = delete;
+ReplyOnce(const ReplyOnce &) = delete;
+ReplyOnce &operator=(const ReplyOnce &) = delete;
+
+~ReplyOnce() {
+ if (transport && handler && !replied) {
+assert(false && "must reply to all calls!");
+(*this)(MakeResponse(
+req, llvm::createStringError("failed to reply")));
+ }
+}
+
+void operator()(const Resp &resp) {
+ assert(transport && handler && "moved-from!");
+ if (replied.exchange(true)) {
+assert(false && "must reply to each call only once!");
+return;
+ }
+
+ if (llvm::Error error = transport->Send(resp))
+handler->OnError(std::move(error));
+}
+ };
+
+public:
+ class Binder;
+ using BinderUP = std::unique_ptr;
+
+ /// Binder collects a table of functions that handle calls.
ashgti wrote:
> By defining message types we can get that automatically out of the messages,
> and then have it call the right callback?
Yea, for example, from the Server.cpp
```
MCPTransport::BinderUP Server::Bind(MCPTransport &transport) {
MCPTransport::BinderUP binder =
std::make_unique(transport);
binder->bind(
"initialize", &Server::InitializeHandler, this);
binder->bind("tools/list", &Server::ToolsListHandler,
this);
binder->bind("tools/call",
&Server::ToolsCallHandler, this);
binder->bind("resources/list",
&Server::ResourcesListHandler, this);
binder->bind(
"resources/read", &Server::ResourcesReadHandler, this);
binder->bind("notifications/initialized",
[this]() { Log("MCP initialization complete"); });
return binder;
}
```
The `bind` method setups the serialization of the Params and Results and wraps
them into the `Request` and `Response` types.
This means the server doesn't need to implement its own method dispatching
mechanism, that can be handled by the `Binder` and Server can be simplified a
bit. You can also see an example in JSONTransportTest.cpp that does this simple
binding of a incoming call, outgoing call, incoming event and outgoing event.
> does this need to be tied to JSONTransport? Can this be built on top of an
> arbitrary transport?
Within each `bind` call we do assume that `Params` and `Result` types are all
JSON serializable.
That could be pulled apart a bit more though if we wanted to remove the JSON
requirement. That could become a parameter to the template I suppose.
https://github.com/llvm/llvm-project/pull/159160
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
@@ -100,22 +175,301 @@ template
class Transport {
virtual llvm::Expected
RegisterMessageHandler(MainLoop &loop, MessageHandler &handler) = 0;
- // FIXME: Refactor mcp::Server to not directly access log on the transport.
- // protected:
+protected:
template inline auto Logv(const char *Fmt, Ts &&...Vals) {
Log(llvm::formatv(Fmt, std::forward(Vals)...).str());
}
virtual void Log(llvm::StringRef message) = 0;
+
+ /// Function object to reply to a call.
+ /// Each instance must be called exactly once, otherwise:
+ /// - the bug is logged, and (in debug mode) an assert will fire
+ /// - if there was no reply, an error reply is sent
+ /// - if there were multiple replies, only the first is sent
+ class ReplyOnce {
+std::atomic replied = {false};
+const Req req;
+JSONTransport *transport; // Null when moved-from.
+JSONTransport::MessageHandler *handler; // Null when moved-from.
+
+ public:
+ReplyOnce(const Req req, JSONTransport *transport,
+ JSONTransport::MessageHandler *handler)
+: req(req), transport(transport), handler(handler) {
+ assert(handler);
+}
+ReplyOnce(ReplyOnce &&other)
+: replied(other.replied.load()), req(other.req),
+ transport(other.transport), handler(other.handler) {
+ other.transport = nullptr;
+ other.handler = nullptr;
+}
+ReplyOnce &operator=(ReplyOnce &&) = delete;
+ReplyOnce(const ReplyOnce &) = delete;
+ReplyOnce &operator=(const ReplyOnce &) = delete;
+
+~ReplyOnce() {
+ if (transport && handler && !replied) {
+assert(false && "must reply to all calls!");
+(*this)(MakeResponse(
+req, llvm::createStringError("failed to reply")));
+ }
+}
+
+void operator()(const Resp &resp) {
+ assert(transport && handler && "moved-from!");
+ if (replied.exchange(true)) {
+assert(false && "must reply to each call only once!");
+return;
+ }
+
+ if (llvm::Error error = transport->Send(resp))
+handler->OnError(std::move(error));
+}
+ };
+
+public:
+ class Binder;
+ using BinderUP = std::unique_ptr;
+
+ /// Binder collects a table of functions that handle calls.
ashgti wrote:
Also, another benefit of the binder not being part of the Server implementation
here specifically is that the Server can choose if it wants to handle a single
client or multiple clients per instance. We can bind the methods with
additional context parameters to make the server independent of the transport.
https://github.com/llvm/llvm-project/pull/159160
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Correct 32-bit build failure in StopInfoMachException.cpp (PR #159523)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/159523 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Implement `AddSymbols` (PR #154121)
https://github.com/Nerixyz closed https://github.com/llvm/llvm-project/pull/154121 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add a static_assert that g_core_definitions matches the Core enum (PR #159452)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/159452 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add a static_assert that g_core_definitions matches the Core enum (PR #159452)
https://github.com/DavidSpickett commented: `ArchSpecValidator` starts instantiating a chain of `ArchSpecValidator` until it gets to `ArchSpecValidator` which does not inherit from anything so it stops there. `arm_generic` being the first core value and `wasm32` being the last. At least right now. Could you use `kNum_Cores` so we don't have to remember to update this when new ones are added? Also the `eCore_wasm32` one has ane mpty body, so does that mean it does not get checked? And you say 2 cores were in the wrong order but only one is moved in the diff. Maybe the other is a downstream thing? https://github.com/llvm/llvm-project/pull/159452 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Disable all lldb-dap tests on Windows on Arm (PR #159542)
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/159542 This reverts the following commits: a0a82ee19d6f2ff1013407ba4c973bfe5428423f 757bb36a58c7d7151a28c6a5fc7caa2e1f44de87 83b48b13f3a70bf56053e92593270c519859cfd7 b45f1fb377636a34c01e34b89341c97d19975554 d2e153981e62fb2ea781ef456ff744f9893e0733 e2d1bbebbb099c7010a31fad62a9128166ef14a0 71cae12442e7476e6397fd73db05e127bfe2d035 7dd879bdc01297a551196a60bb5a5a90ca4dd1ed f3b542e3148cfc244f63cb7c987ccf8ebc71942b Where I had disabled specific tests due to them being flakey on our Windows on Arm bot. Clearly this strategy isn't working because every day I see a new random test failing. Until something can be done about this, disable every lldb-dap test on Windows on Arm. The coverage we get is just not worth spamming contributors who have nothing to do with lldb-dap. See #137660 >From 7cc12e75cc522cd35e246c39a714fbab1c958dc3 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Thu, 18 Sep 2025 10:53:26 +0100 Subject: [PATCH] [lldb][lldb-dap] Disable all lldb-dap tests on Windows on Arm This reverts the following commits: a0a82ee19d6f2ff1013407ba4c973bfe5428423f 757bb36a58c7d7151a28c6a5fc7caa2e1f44de87 83b48b13f3a70bf56053e92593270c519859cfd7 b45f1fb377636a34c01e34b89341c97d19975554 d2e153981e62fb2ea781ef456ff744f9893e0733 e2d1bbebbb099c7010a31fad62a9128166ef14a0 71cae12442e7476e6397fd73db05e127bfe2d035 7dd879bdc01297a551196a60bb5a5a90ca4dd1ed f3b542e3148cfc244f63cb7c987ccf8ebc71942b Where I had disabled specific tests due to them being flakey on our Windows on Arm bot. Clearly this strategy isn't working because every day I see a new random test failing. Until something can be done about this, disable every lldb-dap test on Windows on Arm. The coverage we get is just not worth spamming contributors who have nothing to do with lldb-dap. See #137660 --- .../Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py | 4 lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py | 3 --- lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py | 2 -- lldb/test/API/tools/lldb-dap/console/TestDAP_console.py | 1 - lldb/test/API/tools/lldb-dap/io/TestDAP_io.py | 1 - lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py | 3 --- .../tools/lldb-dap/startDebugging/TestDAP_startDebugging.py | 1 - lldb/test/API/tools/lldb-dap/step/TestDAP_step.py | 1 - .../API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py | 1 - 9 files changed, 4 insertions(+), 13 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index 882eec9971a73..f7b1ed80fceb5 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -5,12 +5,16 @@ import dap_server from dap_server import Source +from lldbsuite.test.decorators import skipIf from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbplatformutil import lldbgdbserverutils import base64 +# DAP tests as a whole have been flakey on the Windows on Arm bot. See: +# https://github.com/llvm/llvm-project/issues/137660 +@skipIf(oslist=["windows"], archs=["aarch64"]) class DAPTestCaseBase(TestBase): # set timeout based on whether ASAN was enabled or not. Increase # timeout by a factor of 10 if ASAN is enabled. diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py index d3952e150e125..c54e21c1b973a 100644 --- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py +++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py @@ -40,7 +40,6 @@ def set_and_hit_breakpoint(self, continueToExit=True): self.continue_to_exit() @skipIfNetBSD # Hangs on NetBSD as well -@skipIfWindows # https://github.com/llvm/llvm-project/issues/137660 def test_by_pid(self): """ Tests attaching to a process by process ID. @@ -56,7 +55,6 @@ def test_by_pid(self): self.set_and_hit_breakpoint(continueToExit=True) @skipIfNetBSD # Hangs on NetBSD as well -@skipIfWindows # https://github.com/llvm/llvm-project/issues/137660 def test_by_name(self): """ Tests attaching to a process by process name. @@ -95,7 +93,6 @@ def test_by_name_waitFor(self): self.set_and_hit_breakpoint(continueToExit=True) @skipIfNetBSD # Hangs on NetBSD as well -@skipIfWindows def test_commands(self): """ Tests the "initCommands", "preRunCommands", "stopCommands", diff --git a/lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py b/lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py index 9dea325694f00..e722fcea9283a 100644 --- a/lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py +++ b/lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py @@ -37,7
[Lldb-commits] [lldb] [LLDB]Fix buffer-over-flow bug introduced in 157170 (PR #159588)
oontvoo wrote: > Thanks for the fix. The new variable `m_executable_name` is used to save the > name so that we can find the NT_FILE entries for the main executable, which > is handled in a different part of the code. > > There is the same fix in #159375. Oops, my bad - hadn't noticed the existing fix. This was breaking our internal build so I thought I'd just merge the fix quickly. https://github.com/llvm/llvm-project/pull/159588 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 44a1f7e - [lldb] Fix unsafe map mutation in ProcessElfCore::FindModuleUUID (#159444)
Author: David Peixotto
Date: 2025-09-18T08:20:09-07:00
New Revision: 44a1f7e7cabebff853ccfbbb669f79673a2ec335
URL:
https://github.com/llvm/llvm-project/commit/44a1f7e7cabebff853ccfbbb669f79673a2ec335
DIFF:
https://github.com/llvm/llvm-project/commit/44a1f7e7cabebff853ccfbbb669f79673a2ec335.diff
LOG: [lldb] Fix unsafe map mutation in ProcessElfCore::FindModuleUUID (#159444)
The `ProcessElfCore::FindModuleUUID` function can be called by multiple
threads at the same time when `target.parallel-module-load` is true. We
were using the `operator[]` to lookup the UUID which will mutate the map
when the key is not present. This is unsafe in a multi-threaded contex
so we now use a read-only `find` operation and explicitly return an
invalid UUID when the key is not present.
The `m_uuids` map can follow a create-then-query pattern. It is
populated in the `DoLoadCore` function which looks like it is only
called in a single-threaded context so we do not need extra locking as
long as we keep the other accesses read-only.
Other fixes I considered
* Use a lock to protect access - We don't need to modify the map after
creation so we can allow concurrent read-only access.
* Store the map in a const pointer container to prevent accidental
mutation in other places.
- Only accessed in one place currently so just added a comment.
* Store the UUID in the NT_FILE_Entry after building the mapping
correctly in `UpdateBuildIdForNTFileEntries`. - The map lets us avoid a
linear search in `FindModuleUUID`.
This commit also reverts the temporary workaround from #159395 which
disabled parallel module loading to avoid the test failure.
Fixes #159377
Added:
Modified:
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
Removed:
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 38bf13543c617..b7029fb3a95b3 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -308,7 +308,13 @@ llvm::StringRef ProcessElfCore::GetMainExecutablePath() {
}
UUID ProcessElfCore::FindModuleUUID(const llvm::StringRef path) {
- return m_uuids[std::string(path)];
+ // Lookup the UUID for the given path in the map.
+ // Note that this could be called by multiple threads so make sure
+ // we access the map in a thread safe way (i.e. don't use operator[]).
+ auto it = m_uuids.find(std::string(path));
+ if (it != m_uuids.end())
+return it->second;
+ return UUID();
}
lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
diff --git
a/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
b/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
index 179dbdf88fa8a..ff1ef21e02e31 100644
--- a/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
+++ b/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
@@ -117,8 +117,6 @@ def check_backtrace(self, thread, filename, backtrace):
)
def do_test(self, filename, pid, region_count):
-# Temporary workaround for
https://github.com/llvm/llvm-project/issues/159377
-self.runCmd("settings set target.parallel-module-load false")
target = self.dbg.CreateTarget(filename)
process = target.LoadCore(filename + ".core")
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix unsafe map mutation in ProcessElfCore::FindModuleUUID (PR #159444)
https://github.com/dmpots closed https://github.com/llvm/llvm-project/pull/159444 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Disable all lldb-dap tests on Windows on Arm (PR #159542)
llvmbot wrote:
@llvm/pr-subscribers-lldb
Author: David Spickett (DavidSpickett)
Changes
This reverts the following commits:
a0a82ee19d6f2ff1013407ba4c973bfe5428423f
757bb36a58c7d7151a28c6a5fc7caa2e1f44de87
83b48b13f3a70bf56053e92593270c519859cfd7
b45f1fb377636a34c01e34b89341c97d19975554
d2e153981e62fb2ea781ef456ff744f9893e0733
e2d1bbebbb099c7010a31fad62a9128166ef14a0
71cae12442e7476e6397fd73db05e127bfe2d035
7dd879bdc01297a551196a60bb5a5a90ca4dd1ed
f3b542e3148cfc244f63cb7c987ccf8ebc71942b
Where I had disabled specific tests due to them being flakey on our Windows on
Arm bot.
Clearly this strategy isn't working because
every day I see a new random test failing.
Until something can be done about this, disable
every lldb-dap test on Windows on Arm. The coverage we get is just not worth
spamming contributors
who have nothing to do with lldb-dap.
See #137660
---
Full diff: https://github.com/llvm/llvm-project/pull/159542.diff
9 Files Affected:
- (modified)
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py (+4)
- (modified) lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py (-3)
- (modified) lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py (-2)
- (modified) lldb/test/API/tools/lldb-dap/console/TestDAP_console.py (-1)
- (modified) lldb/test/API/tools/lldb-dap/io/TestDAP_io.py (-1)
- (modified) lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py (-3)
- (modified)
lldb/test/API/tools/lldb-dap/startDebugging/TestDAP_startDebugging.py (-1)
- (modified) lldb/test/API/tools/lldb-dap/step/TestDAP_step.py (-1)
- (modified)
lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py (-1)
``diff
diff --git
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 882eec9971a73..f7b1ed80fceb5 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -5,12 +5,16 @@
import dap_server
from dap_server import Source
+from lldbsuite.test.decorators import skipIf
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbplatformutil
import lldbgdbserverutils
import base64
+# DAP tests as a whole have been flakey on the Windows on Arm bot. See:
+# https://github.com/llvm/llvm-project/issues/137660
+@skipIf(oslist=["windows"], archs=["aarch64"])
class DAPTestCaseBase(TestBase):
# set timeout based on whether ASAN was enabled or not. Increase
# timeout by a factor of 10 if ASAN is enabled.
diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
index d3952e150e125..c54e21c1b973a 100644
--- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
+++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
@@ -40,7 +40,6 @@ def set_and_hit_breakpoint(self, continueToExit=True):
self.continue_to_exit()
@skipIfNetBSD # Hangs on NetBSD as well
-@skipIfWindows # https://github.com/llvm/llvm-project/issues/137660
def test_by_pid(self):
"""
Tests attaching to a process by process ID.
@@ -56,7 +55,6 @@ def test_by_pid(self):
self.set_and_hit_breakpoint(continueToExit=True)
@skipIfNetBSD # Hangs on NetBSD as well
-@skipIfWindows # https://github.com/llvm/llvm-project/issues/137660
def test_by_name(self):
"""
Tests attaching to a process by process name.
@@ -95,7 +93,6 @@ def test_by_name_waitFor(self):
self.set_and_hit_breakpoint(continueToExit=True)
@skipIfNetBSD # Hangs on NetBSD as well
-@skipIfWindows
def test_commands(self):
"""
Tests the "initCommands", "preRunCommands", "stopCommands",
diff --git a/lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py
b/lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py
index 9dea325694f00..e722fcea9283a 100644
--- a/lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py
+++ b/lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py
@@ -37,7 +37,6 @@ def async_blocking_request(self, duration: float) -> int:
def async_cancel(self, requestId: int) -> int:
return self.send_async_req(command="cancel", arguments={"requestId":
requestId})
-@skipIfWindows
def test_pending_request(self):
"""
Tests cancelling a pending request.
@@ -70,7 +69,6 @@ def test_pending_request(self):
self.assertEqual(cancel_resp["success"], True)
self.continue_to_exit()
-@skipIfWindows # https://github.com/llvm/llvm-project/issues/137660
def test_inflight_request(self):
"""
Tests cancelling an inflight request.
diff --git a/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
b/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
index 202b23abc1811..ceddaeb50cd3b 100644
--- a/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
[Lldb-commits] [lldb] [lldb] Correct 32-bit build failure in StopInfoMachException.cpp (PR #159523)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/159523 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Correct 32-bit build failure in StopInfoMachException.cpp (PR #159523)
llvmbot wrote:
@llvm/pr-subscribers-lldb
Author: David Spickett (DavidSpickett)
Changes
uintptr_t is usually a good idea when handling pointers, but lldb has to handle
64-bit addresses that might be from a remote system, on a 32-bit system.
So I've changed a few instances here to use addr_t which is 64-bit everywhere.
Before we got:
https://lab.llvm.org/buildbot/#/builders/18/builds/21247
```
../llvm-project/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:81:28:
error: constexpr variable 'g_mte_tag_mask' must be initialized by a constant
expression
81 | static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f <<
g_mte_tag_shift;
|^
~~
../llvm-project/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:81:61:
note: shift count 56 >= width of type 'uintptr_t' (aka 'unsigned int') (32
bits)
81 | static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f <<
g_mte_tag_shift;
| ^
1 error generated.
```
---
Full diff: https://github.com/llvm/llvm-project/pull/159523.diff
1 Files Affected:
- (modified) lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
(+2-2)
``diff
diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
index 6853121f3e01c..601cfdcb4e9f7 100644
--- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -78,7 +78,7 @@ static void DescribeAddressBriefly(Stream &strm, const
Address &addr,
}
static constexpr uint8_t g_mte_tag_shift = 64 - 8;
-static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f << g_mte_tag_shift;
+static constexpr addr_t g_mte_tag_mask = (addr_t)0x0f << g_mte_tag_shift;
bool StopInfoMachException::DetermineTagMismatch(ExecutionContext &exe_ctx) {
const bool IsBadAccess = m_value == 1;// EXC_BAD_ACCESS
@@ -97,7 +97,7 @@ bool
StopInfoMachException::DetermineTagMismatch(ExecutionContext &exe_ctx) {
m_exc_code, bad_address);
const uint8_t tag = (bad_address & g_mte_tag_mask) >> g_mte_tag_shift;
- const uint64_t canonical_addr = bad_address & ~g_mte_tag_mask;
+ const addr_t canonical_addr = bad_address & ~g_mte_tag_mask;
strm.Printf(
"Note: MTE tag mismatch detected: pointer tag=%d, address=0x%" PRIx64,
tag, canonical_addr);
``
https://github.com/llvm/llvm-project/pull/159523
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Remove no-op calls to Fix*Address (PR #159586)
llvmbot wrote:
@llvm/pr-subscribers-lldb
Author: Felipe de Azevedo Piovezan (felipepiovezan)
Changes
The first call, in InitializeNonZerothFrame, is inside a logging branch. For
that, it's better to log the real value instead of the fixed one.
The second call, inside RegisterContextUnwind::ReadFrameAddress, is computing
an address which is then passed to
ReadRegisterValueFromMemory. The current variable names are misleading, making
readers believe it is the cfa value itself that is being passed to Fix*Address;
that's not the case. This commit renames the variable to make this abundantly
clear.
---
Full diff: https://github.com/llvm/llvm-project/pull/159586.diff
1 Files Affected:
- (modified) lldb/source/Target/RegisterContextUnwind.cpp (+14-19)
``diff
diff --git a/lldb/source/Target/RegisterContextUnwind.cpp
b/lldb/source/Target/RegisterContextUnwind.cpp
index 3b018c09b8b72..7f6ead1e7ccab 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -361,16 +361,10 @@ void RegisterContextUnwind::InitializeNonZerothFrame() {
if (log) {
UnwindLogMsg("pc = 0x%" PRIx64, pc);
addr_t reg_val;
-if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP, reg_val)) {
- if (abi_sp)
-reg_val = abi_sp->FixDataAddress(reg_val);
+if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP, reg_val))
UnwindLogMsg("fp = 0x%" PRIx64, reg_val);
-}
-if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, reg_val)) {
- if (abi_sp)
-reg_val = abi_sp->FixDataAddress(reg_val);
+if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, reg_val))
UnwindLogMsg("sp = 0x%" PRIx64, reg_val);
-}
}
// A pc of 0x0 means it's the end of the stack crawl unless we're above a
trap
@@ -2026,30 +2020,31 @@ bool RegisterContextUnwind::ReadFrameAddress(
switch (fa.GetValueType()) {
case UnwindPlan::Row::FAValue::isRegisterDereferenced: {
UnwindLogMsg("CFA value via dereferencing reg");
-RegisterNumber cfa_reg(m_thread, row_register_kind,
- fa.GetRegisterNumber());
-if (ReadGPRValue(cfa_reg, cfa_reg_contents)) {
+RegisterNumber regnum_to_deref(m_thread, row_register_kind,
+ fa.GetRegisterNumber());
+addr_t reg_to_deref_contents;
+if (ReadGPRValue(regnum_to_deref, reg_to_deref_contents)) {
const RegisterInfo *reg_info =
- GetRegisterInfoAtIndex(cfa_reg.GetAsKind(eRegisterKindLLDB));
+ GetRegisterInfoAtIndex(regnum_to_deref.GetAsKind(eRegisterKindLLDB));
RegisterValue reg_value;
if (reg_info) {
-if (abi_sp)
- cfa_reg_contents = abi_sp->FixDataAddress(cfa_reg_contents);
Status error = ReadRegisterValueFromMemory(
-reg_info, cfa_reg_contents, reg_info->byte_size, reg_value);
+reg_info, reg_to_deref_contents, reg_info->byte_size, reg_value);
if (error.Success()) {
address = reg_value.GetAsUInt64();
UnwindLogMsg(
"CFA value via dereferencing reg %s (%d): reg has val 0x%" PRIx64
", CFA value is 0x%" PRIx64,
- cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB),
- cfa_reg_contents, address);
+ regnum_to_deref.GetName(),
+ regnum_to_deref.GetAsKind(eRegisterKindLLDB),
+ reg_to_deref_contents, address);
return true;
} else {
UnwindLogMsg("Tried to deref reg %s (%d) [0x%" PRIx64
"] but memory read failed.",
- cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB),
- cfa_reg_contents);
+ regnum_to_deref.GetName(),
+ regnum_to_deref.GetAsKind(eRegisterKindLLDB),
+ reg_to_deref_contents);
}
}
}
``
https://github.com/llvm/llvm-project/pull/159586
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Correct 32-bit build failure in StopInfoMachException.cpp (PR #159523)
DavidSpickett wrote: Landing this to fix the build, but @JDevlieghere please do give it a look. https://github.com/llvm/llvm-project/pull/159523 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a868f28 - [LLDB][ProcessWindows] Set exit status on instance rather than going through all targets (#159308)
Author: nerix
Date: 2025-09-18T11:27:25+02:00
New Revision: a868f28c6e9beecb2b3fbe8acfbe0d272fabd14d
URL:
https://github.com/llvm/llvm-project/commit/a868f28c6e9beecb2b3fbe8acfbe0d272fabd14d
DIFF:
https://github.com/llvm/llvm-project/commit/a868f28c6e9beecb2b3fbe8acfbe0d272fabd14d.diff
LOG: [LLDB][ProcessWindows] Set exit status on instance rather than going
through all targets (#159308)
When quitting LLDB on Windows while a process was still running, LLDB
would take unusually long to exit. This was due to a temporary deadlock:
The main thread was destroying the processes. In doing so, it iterated
over the target list:
https://github.com/llvm/llvm-project/blob/88c64f76ed2ca226da99b99f60d316b1519fc7d8/lldb/source/Core/Debugger.cpp#L1095-L1098
This locks the list for the whole iteration. Finalizing the process
would eventually lead to `DebuggerThread::StopDebugging`, which
terminates the process and waits for it to exit:
https://github.com/llvm/llvm-project/blob/88c64f76ed2ca226da99b99f60d316b1519fc7d8/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp#L196
The debugger loop (on a separate thread) would see that the process
exited and call
[`ProcessWindows::OnExitProcess`](https://github.com/llvm/llvm-project/blob/88c64f76ed2ca226da99b99f60d316b1519fc7d8/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp#L656-L673).
This calls the static function
[`Process::SetProcessExitStatus`](https://github.com/llvm/llvm-project/blob/0a7a7d56fc882653335beba0d1f8ea9f26089c22/lldb/source/Target/Process.cpp#L1098-L1126).
This tries to find the process by its ID from the debugger's target
list. Doing so requires locking the list, so the debugger thread would
then be stuck on
https://github.com/llvm/llvm-project/blob/0a7a7d56fc882653335beba0d1f8ea9f26089c22/lldb/source/Target/TargetList.cpp#L403
After 5s, the main thread would give up waiting. So every exit where the
process was still running would be delayed by about 5s.
Since `ProcessWindows` would find itself when calling
`SetProcessExitStatus`, we can call `SetExitStatus` directly.
This can also make some tests run faster. For example, the DIA PDB tests
previously took 15s to run on my PC (24 jobs) and now take 5s. For all
shell tests, the difference isn't that big (only about 3s), because most
don't run into this and the tests run in parallel.
Added:
Modified:
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
Removed:
diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
index 27530f032ce51..0fecefe23b88e 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -666,7 +666,7 @@ void ProcessWindows::OnExitProcess(uint32_t exit_code) {
target->ModulesDidUnload(unloaded_modules, true);
}
- SetProcessExitStatus(GetID(), true, 0, exit_code);
+ SetExitStatus(exit_code, /*exit_string=*/"");
SetPrivateState(eStateExited);
ProcessDebugger::OnExitProcess(exit_code);
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4625c8f - [LLDB][NativePDB] Add modifiers to modified type name (#159296)
Author: nerix
Date: 2025-09-18T11:55:15+02:00
New Revision: 4625c8f076a85a4b3799a71b9299424a426a9de3
URL:
https://github.com/llvm/llvm-project/commit/4625c8f076a85a4b3799a71b9299424a426a9de3
DIFF:
https://github.com/llvm/llvm-project/commit/4625c8f076a85a4b3799a71b9299424a426a9de3.diff
LOG: [LLDB][NativePDB] Add modifiers to modified type name (#159296)
When creating LLDB types from `LF_MODIFIER` records, the type name of
the modified type was used. This didn't include the modifiers
(`const`/`volatile`/`__unaligned`). With this PR, they're included.
The DIA plugin had a test for this. That test also assumed that function
types had a name. I removed that check here, because function/procedure
types themselves in PDB don't have a name:
```
0x1015 | LF_ARGLIST [size = 20, hash = 0xBCB6]
0x0074 (int): `int`
0x1013: `int* __restrict`
0x1014: `int& __restrict`
0x1016 | LF_PROCEDURE [size = 16, hash = 0x3F611]
return type = 0x0003 (void), # args = 3, param list = 0x1015
calling conv = cdecl, options = None
```
I assume DIA gets the name from the function symbol itself. In the
native plugin, that name isn't included and multiple functions with the
same signature will reuse one type, whereas DIA would create a new type
for each function. The
[Shell/SymbolFile/PDB/func-symbols.test](https://github.com/llvm/llvm-project/blob/b29c7ded31d81ca47aed0157c543c8b6a0f5866c/lldb/test/Shell/SymbolFile/PDB/func-symbols.test)
also relies on this.
Added:
Modified:
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test
lldb/test/Shell/SymbolFile/PDB/type-quals.test
Removed:
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index b866e473853f3..8b3d775afc163 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -549,10 +549,18 @@ lldb::TypeSP
SymbolFileNativePDB::CreateModifierType(PdbTypeSymId type_id,
TpiStream &stream = m_index->tpi();
std::string name;
+
+ if ((mr.Modifiers & ModifierOptions::Const) != ModifierOptions::None)
+name += "const ";
+ if ((mr.Modifiers & ModifierOptions::Volatile) != ModifierOptions::None)
+name += "volatile ";
+ if ((mr.Modifiers & ModifierOptions::Unaligned) != ModifierOptions::None)
+name += "__unaligned ";
+
if (mr.ModifiedType.isSimple())
-name = std::string(GetSimpleTypeName(mr.ModifiedType.getSimpleKind()));
+name += GetSimpleTypeName(mr.ModifiedType.getSimpleKind());
else
-name = computeTypeName(stream.typeCollection(), mr.ModifiedType);
+name += computeTypeName(stream.typeCollection(), mr.ModifiedType);
Declaration decl;
lldb::TypeSP modified_type = GetOrCreateType(mr.ModifiedType);
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test
b/lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test
index 769f18de51472..695a909defa22 100644
--- a/lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test
+++ b/lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test
@@ -74,10 +74,10 @@
# CHECK: LineEntry: [0x000140001004-0x00014000100c): /tmp/a.h:5
# CHECK-NEXT: Symbol: id = {{.*}}, range =
[0x000140001000-0x000140001046), name="main"
# CHECK-NEXT: Variable: id = {{.*}}, name = "x", type = "int", valid ranges =
, location = , decl =
-# CHECK-NEXT: Variable: id = {{.*}}, name = "foo_local", type = "int", valid
ranges = , location = [0x000140001004, 0x000140001039) ->
DW_OP_breg7 RSP+44
+# CHECK-NEXT: Variable: id = {{.*}}, name = "foo_local", type = "volatile
int", valid ranges = , location = [0x000140001004,
0x000140001039) -> DW_OP_breg7 RSP+44
# CHECK-NEXT: Variable: id = {{.*}}, name = "argc", type = "int", valid
ranges = , location = [0x000140001000, 0x00014000102d) ->
DW_OP_reg26 XMM9
# CHECK-NEXT: Variable: id = {{.*}}, name = "argv", type = "char **", valid
ranges = , location = [0x000140001000, 0x000140001045) ->
DW_OP_reg3 RBX
-# CHECK-NEXT: Variable: id = {{.*}}, name = "main_local", type = "int", valid
ranges = , location = [0x000140001004, 0x000140001046) ->
DW_OP_breg7 RSP+48
+# CHECK-NEXT: Variable: id = {{.*}}, name = "main_local", type = "volatile
int", valid ranges = , location = [0x000140001004,
0x000140001046) -> DW_OP_breg7 RSP+48
# CHECK-LABEL: (lldb) image lookup -a 0x140001010 -v
# CHECK: Summary: {{.*}}`main + 16 [inlined] Namespace1::foo + 12 at
a.h:7
@@ -88,10 +88,10 @@
# CHECK: LineEntry: [0x000140001010-0x000140001018): /tmp/a.h:7
# CHECK-NEXT: Symbol: id = {{.*}}, range =
[0x000140001000-0x000140001046), name="main"
# CHECK-NEXT: Variable: id
[Lldb-commits] [lldb] [LLDB]Fix buffer-over-flow bug introduced in 157170 (PR #159588)
https://github.com/oontvoo created
https://github.com/llvm/llvm-project/pull/159588
If `pr_name` is longer than 16, it would be a non-null terminated string.
Assigning it to `std::string m_executable_name` would cause an overflow read.
Instead, just copy the name from thread_data.name.
(Question: why is the new variable needed in the first place? can't the
thread_data.name be used?)
>From 973c220bd8dc406285d7400f55de5b5e0e0b396b Mon Sep 17 00:00:00 2001
From: Vy Nguyen
Date: Thu, 18 Sep 2025 10:38:51 -0400
Subject: [PATCH] [LLDB]Fix buffer-over-flow bug.
If `pr_name` is longer than 16, it would be a non-null terminated string.
Assigning it to `std::string m_executable_name` would cause an overflow read.
Instead, just copy the name from thread_data.name.
(Question: why is the new variable needed in the first place? can't the
thread_data.name be used?)
---
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 8f5f1242116f5..38bf13543c617 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -952,7 +952,7 @@ llvm::Error
ProcessElfCore::parseLinuxNotes(llvm::ArrayRef notes) {
return status.ToError();
thread_data.name.assign (prpsinfo.pr_fname, strnlen (prpsinfo.pr_fname,
sizeof (prpsinfo.pr_fname)));
SetID(prpsinfo.pr_pid);
- m_executable_name = prpsinfo.pr_fname;
+ m_executable_name = thread_data.name;
break;
}
case ELF::NT_SIGINFO: {
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Linux] Fix potential out of bounds read of pr_fname (PR #159375)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/159375 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB]Fix buffer-over-flow bug introduced in 157170 (PR #159588)
llvmbot wrote:
@llvm/pr-subscribers-lldb
Author: Vy Nguyen (oontvoo)
Changes
If `pr_name` is longer than 16, it would be a non-null terminated string.
Assigning it to `std::string m_executable_name` would cause an overflow read.
Instead, just copy the name from thread_data.name.
(Question: why is the new variable needed in the first place? can't the
thread_data.name be used?)
---
Full diff: https://github.com/llvm/llvm-project/pull/159588.diff
1 Files Affected:
- (modified) lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp (+1-1)
``diff
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 8f5f1242116f5..38bf13543c617 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -952,7 +952,7 @@ llvm::Error
ProcessElfCore::parseLinuxNotes(llvm::ArrayRef notes) {
return status.ToError();
thread_data.name.assign (prpsinfo.pr_fname, strnlen (prpsinfo.pr_fname,
sizeof (prpsinfo.pr_fname)));
SetID(prpsinfo.pr_pid);
- m_executable_name = prpsinfo.pr_fname;
+ m_executable_name = thread_data.name;
break;
}
case ELF::NT_SIGINFO: {
``
https://github.com/llvm/llvm-project/pull/159588
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Remove no-op calls to Fix*Address (PR #159586)
https://github.com/felipepiovezan edited https://github.com/llvm/llvm-project/pull/159586 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB]Fix buffer-over-flow bug introduced in 157170 (PR #159588)
https://github.com/oontvoo edited https://github.com/llvm/llvm-project/pull/159588 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add support for the structured data plugins in lldb-server (PR #159457)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `lldb-aarch64-ubuntu` running on `linaro-lldb-aarch64-ubuntu` while building `lldb` at step 6 "test". Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/24402 Here is the relevant piece of the build log for the reference ``` Step 6 (test) failure: build (failure) ... PASS: lldb-unit :: ValueObject/./LLDBValueObjectTests/9/12 (2313 of 2322) PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/0/3 (2314 of 2322) PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/1/3 (2315 of 2322) PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/2/3 (2316 of 2322) PASS: lldb-unit :: Target/./TargetTests/11/14 (2317 of 2322) PASS: lldb-unit :: Host/./HostTests/4/9 (2318 of 2322) PASS: lldb-unit :: Host/./HostTests/5/9 (2319 of 2322) PASS: lldb-unit :: Host/./HostTests/8/9 (2320 of 2322) PASS: lldb-unit :: Process/gdb-remote/./ProcessGdbRemoteTests/8/9 (2321 of 2322) UNRESOLVED: lldb-api :: tools/lldb-server/TestLldbGdbServer.py (2322 of 2322) TEST 'lldb-api :: tools/lldb-server/TestLldbGdbServer.py' FAILED Script: -- /usr/bin/python3.10 /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --arch aarch64 --build-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb --compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang --dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --cmake-build-type Release /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-server -p TestLldbGdbServer.py -- Exit Code: 1 Command Output (stdout): -- lldb version 22.0.0git (https://github.com/llvm/llvm-project.git revision 4f72abd8404efa3de32188429d5f079ad12264e3) clang revision 4f72abd8404efa3de32188429d5f079ad12264e3 llvm revision 4f72abd8404efa3de32188429d5f079ad12264e3 Skipping the following test categories: ['libc++', 'msvcstl', 'dsym', 'gmodules', 'debugserver', 'objc'] -- Command Output (stderr): -- UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_Hc_then_Csignal_signals_correct_thread_launch_debugserver (TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any category of interest for this run) PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_Hc_then_Csignal_signals_correct_thread_launch_llgs (TestLldbGdbServer.LldbGdbServerTestCase) PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_Hg_fails_on_another_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase) PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_Hg_fails_on_minus_one_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase) PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_Hg_fails_on_zero_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase) UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_Hg_switches_to_3_threads_launch_debugserver (TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any category of interest for this run) PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_Hg_switches_to_3_threads_launch_llgs (TestLldbGdbServer.LldbGdbServerTestCase) UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_P_and_p_thread_suffix_work_debugserver (TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any category of interest for this run) PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_P_and_p_thread_suffix_work_llgs (TestLldbGdbServer.LldbGdbServerTestCase) UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_P_writes_all_gpr_registers_debugserver (TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall
[Lldb-commits] [lldb] [lldb][Linux] Fix potential out of bounds read of pr_fname (PR #159375)
DavidSpickett wrote: https://github.com/llvm/llvm-project/pull/159588 already fixed this. https://github.com/llvm/llvm-project/pull/159375 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 09e0f1e - [LLDB]Fix buffer-over-flow bug introduced in 157170 (#159588)
Author: Vy Nguyen
Date: 2025-09-18T10:43:42-04:00
New Revision: 09e0f1e035b348e2cd694e5f4b943a78cb6ad639
URL:
https://github.com/llvm/llvm-project/commit/09e0f1e035b348e2cd694e5f4b943a78cb6ad639
DIFF:
https://github.com/llvm/llvm-project/commit/09e0f1e035b348e2cd694e5f4b943a78cb6ad639.diff
LOG: [LLDB]Fix buffer-over-flow bug introduced in 157170 (#159588)
If `pr_name` is longer than 16, it would be a non-null terminated
string. Assigning it to `std::string m_executable_name` would cause an
overflow read. Instead, just copy the name from thread_data.name.
To repro, run the `elf-core/TestLinuxCore.py` with asan
(Question: why is the new variable needed in the first place? can't the
thread_data.name be used?)
Added:
Modified:
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
Removed:
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 8f5f1242116f5..38bf13543c617 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -952,7 +952,7 @@ llvm::Error
ProcessElfCore::parseLinuxNotes(llvm::ArrayRef notes) {
return status.ToError();
thread_data.name.assign (prpsinfo.pr_fname, strnlen (prpsinfo.pr_fname,
sizeof (prpsinfo.pr_fname)));
SetID(prpsinfo.pr_pid);
- m_executable_name = prpsinfo.pr_fname;
+ m_executable_name = thread_data.name;
break;
}
case ELF::NT_SIGINFO: {
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Add modifiers to modified type name (PR #159296)
https://github.com/Nerixyz closed https://github.com/llvm/llvm-project/pull/159296 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Remove no-op calls to Fix*Address (PR #159586)
https://github.com/felipepiovezan created
https://github.com/llvm/llvm-project/pull/159586
The first call, in InitializeNonZerothFrame, is inside a logging branch. For
that, it's better to log the real value instead of the fixed one.
The second call, inside RegisterContextUnwind::ReadFrameAddress, is computing
an address which is then passed to
ReadRegisterValueFromMemory. The current variable names are misleading, making
readers believe it is the cfa value itself that is being passed to Fix*Address;
that's not the case. This commit renames the variable to make this abundantly
clear.
>From f6f7a6992e738908ad07df9e1d021ef02e17085f Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan
Date: Thu, 18 Sep 2025 07:25:03 -0700
Subject: [PATCH] [lldb][nfc] Remove no-op calls to Fix*Address
The first call, in InitializeNonZerothFrame, is inside a logging branch.
For that, it's better to log the real value instead of the fixed one.
The second call, inside RegisterContextUnwind::ReadFrameAddress, is
computing an address which is then passed to
ReadRegisterValueFromMemory. The current variable names are misleading,
making readers believe it is the cfa value itself that is being passed
to Fix*Address; that's not the case. This commit renames the variable to
make this abundantly clear.
---
lldb/source/Target/RegisterContextUnwind.cpp | 33 +---
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/lldb/source/Target/RegisterContextUnwind.cpp
b/lldb/source/Target/RegisterContextUnwind.cpp
index 3b018c09b8b72..7f6ead1e7ccab 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -361,16 +361,10 @@ void RegisterContextUnwind::InitializeNonZerothFrame() {
if (log) {
UnwindLogMsg("pc = 0x%" PRIx64, pc);
addr_t reg_val;
-if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP, reg_val)) {
- if (abi_sp)
-reg_val = abi_sp->FixDataAddress(reg_val);
+if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP, reg_val))
UnwindLogMsg("fp = 0x%" PRIx64, reg_val);
-}
-if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, reg_val)) {
- if (abi_sp)
-reg_val = abi_sp->FixDataAddress(reg_val);
+if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, reg_val))
UnwindLogMsg("sp = 0x%" PRIx64, reg_val);
-}
}
// A pc of 0x0 means it's the end of the stack crawl unless we're above a
trap
@@ -2026,30 +2020,31 @@ bool RegisterContextUnwind::ReadFrameAddress(
switch (fa.GetValueType()) {
case UnwindPlan::Row::FAValue::isRegisterDereferenced: {
UnwindLogMsg("CFA value via dereferencing reg");
-RegisterNumber cfa_reg(m_thread, row_register_kind,
- fa.GetRegisterNumber());
-if (ReadGPRValue(cfa_reg, cfa_reg_contents)) {
+RegisterNumber regnum_to_deref(m_thread, row_register_kind,
+ fa.GetRegisterNumber());
+addr_t reg_to_deref_contents;
+if (ReadGPRValue(regnum_to_deref, reg_to_deref_contents)) {
const RegisterInfo *reg_info =
- GetRegisterInfoAtIndex(cfa_reg.GetAsKind(eRegisterKindLLDB));
+ GetRegisterInfoAtIndex(regnum_to_deref.GetAsKind(eRegisterKindLLDB));
RegisterValue reg_value;
if (reg_info) {
-if (abi_sp)
- cfa_reg_contents = abi_sp->FixDataAddress(cfa_reg_contents);
Status error = ReadRegisterValueFromMemory(
-reg_info, cfa_reg_contents, reg_info->byte_size, reg_value);
+reg_info, reg_to_deref_contents, reg_info->byte_size, reg_value);
if (error.Success()) {
address = reg_value.GetAsUInt64();
UnwindLogMsg(
"CFA value via dereferencing reg %s (%d): reg has val 0x%" PRIx64
", CFA value is 0x%" PRIx64,
- cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB),
- cfa_reg_contents, address);
+ regnum_to_deref.GetName(),
+ regnum_to_deref.GetAsKind(eRegisterKindLLDB),
+ reg_to_deref_contents, address);
return true;
} else {
UnwindLogMsg("Tried to deref reg %s (%d) [0x%" PRIx64
"] but memory read failed.",
- cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB),
- cfa_reg_contents);
+ regnum_to_deref.GetName(),
+ regnum_to_deref.GetAsKind(eRegisterKindLLDB),
+ reg_to_deref_contents);
}
}
}
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Remove no-op calls to Fix*Address (PR #159586)
https://github.com/felipepiovezan updated
https://github.com/llvm/llvm-project/pull/159586
>From f7f958aa2cb9c0354852921f07a88639c3b049a8 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan
Date: Thu, 18 Sep 2025 07:25:03 -0700
Subject: [PATCH] [lldb][nfc] Remove no-op calls to Fix*Address
The first call, in InitializeNonZerothFrame, is inside a logging branch.
For that, it's better to log the real value instead of the fixed one.
The second call, inside RegisterContextUnwind::ReadFrameAddress, is
computing an address which is then passed to
ReadRegisterValueFromMemory, which boils down to a Process::ReadMemory,
which fixes the address if it wants to. The current variable names are
misleading, making readers believe it is the cfa value itself that is
being passed to Fix*Address; that's not the case. This commit renames
the variable to make this abundantly clear.
---
lldb/source/Target/RegisterContextUnwind.cpp | 33 +---
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/lldb/source/Target/RegisterContextUnwind.cpp
b/lldb/source/Target/RegisterContextUnwind.cpp
index 3b018c09b8b72..7f6ead1e7ccab 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -361,16 +361,10 @@ void RegisterContextUnwind::InitializeNonZerothFrame() {
if (log) {
UnwindLogMsg("pc = 0x%" PRIx64, pc);
addr_t reg_val;
-if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP, reg_val)) {
- if (abi_sp)
-reg_val = abi_sp->FixDataAddress(reg_val);
+if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP, reg_val))
UnwindLogMsg("fp = 0x%" PRIx64, reg_val);
-}
-if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, reg_val)) {
- if (abi_sp)
-reg_val = abi_sp->FixDataAddress(reg_val);
+if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, reg_val))
UnwindLogMsg("sp = 0x%" PRIx64, reg_val);
-}
}
// A pc of 0x0 means it's the end of the stack crawl unless we're above a
trap
@@ -2026,30 +2020,31 @@ bool RegisterContextUnwind::ReadFrameAddress(
switch (fa.GetValueType()) {
case UnwindPlan::Row::FAValue::isRegisterDereferenced: {
UnwindLogMsg("CFA value via dereferencing reg");
-RegisterNumber cfa_reg(m_thread, row_register_kind,
- fa.GetRegisterNumber());
-if (ReadGPRValue(cfa_reg, cfa_reg_contents)) {
+RegisterNumber regnum_to_deref(m_thread, row_register_kind,
+ fa.GetRegisterNumber());
+addr_t reg_to_deref_contents;
+if (ReadGPRValue(regnum_to_deref, reg_to_deref_contents)) {
const RegisterInfo *reg_info =
- GetRegisterInfoAtIndex(cfa_reg.GetAsKind(eRegisterKindLLDB));
+ GetRegisterInfoAtIndex(regnum_to_deref.GetAsKind(eRegisterKindLLDB));
RegisterValue reg_value;
if (reg_info) {
-if (abi_sp)
- cfa_reg_contents = abi_sp->FixDataAddress(cfa_reg_contents);
Status error = ReadRegisterValueFromMemory(
-reg_info, cfa_reg_contents, reg_info->byte_size, reg_value);
+reg_info, reg_to_deref_contents, reg_info->byte_size, reg_value);
if (error.Success()) {
address = reg_value.GetAsUInt64();
UnwindLogMsg(
"CFA value via dereferencing reg %s (%d): reg has val 0x%" PRIx64
", CFA value is 0x%" PRIx64,
- cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB),
- cfa_reg_contents, address);
+ regnum_to_deref.GetName(),
+ regnum_to_deref.GetAsKind(eRegisterKindLLDB),
+ reg_to_deref_contents, address);
return true;
} else {
UnwindLogMsg("Tried to deref reg %s (%d) [0x%" PRIx64
"] but memory read failed.",
- cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB),
- cfa_reg_contents);
+ regnum_to_deref.GetName(),
+ regnum_to_deref.GetAsKind(eRegisterKindLLDB),
+ reg_to_deref_contents);
}
}
}
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add a static_assert that g_core_definitions matches the Core enum (PR #159452)
https://github.com/JDevlieghere updated
https://github.com/llvm/llvm-project/pull/159452
>From 57198d217f9e5df387c8e35452c82577756f2bb0 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere
Date: Wed, 17 Sep 2025 13:56:13 -0700
Subject: [PATCH] [lldb] Add a static_assert that g_core_definitions matches
the Core enum
This PR uses the same trick as 7ced9fff95473 to ensure the
g_core_definitions table is correctly indexed by the Core enum. It's
easy to make a mistake. Case in point: this caught two entries that
appeared in the wrong order.
---
lldb/source/Utility/ArchSpec.cpp | 15 ---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index 2a87cc6bf7de9..dfe4351f0c45b 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -41,7 +41,7 @@ struct CoreDefinition {
} // namespace lldb_private
// This core information can be looked using the ArchSpec::Core as the index
-static const CoreDefinition g_core_definitions[] = {
+static constexpr const CoreDefinition g_core_definitions[] = {
{eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_generic,
"arm"},
{eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv4,
@@ -90,12 +90,12 @@ static const CoreDefinition g_core_definitions[] = {
"thumbv6m"},
{eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv7,
"thumbv7"},
-{eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv7f,
- "thumbv7f"},
{eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv7s,
"thumbv7s"},
{eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv7k,
"thumbv7k"},
+{eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv7f,
+ "thumbv7f"},
{eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv7m,
"thumbv7m"},
{eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb, ArchSpec::eCore_thumbv7em,
@@ -257,6 +257,15 @@ static_assert(sizeof(g_core_definitions) /
sizeof(CoreDefinition) ==
ArchSpec::kNumCores,
"make sure we have one core definition for each core");
+template struct ArchSpecValidator : ArchSpecValidator {
+ static_assert(g_core_definitions[I].core == I,
+"g_core_definitions order doesn't match Core enumeration");
+};
+
+template <> struct ArchSpecValidator {};
+
+ArchSpecValidator validator;
+
struct ArchDefinitionEntry {
ArchSpec::Core core;
uint32_t cpu;
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add a static_assert that g_core_definitions matches the Core enum (PR #159452)
JDevlieghere wrote: > Could you use `kNum_Cores` so we don't have to remember to update this when > new ones are added? > > Also the `eCore_wasm32` one has an empty body, so does that mean it does not > get checked? Good catch, that's an unintentional off-by-one. Using `kNum_Cores` addresses both. > And you say 2 cores were in the wrong order but only one is moved in the > diff. Maybe the other is a downstream thing? Haha, I guess it depends on how you (or the diff algorithm) looks at it. `thumbv7s` and `thumbv7k` showed up before `thumbv7f` which is why I said 2, which of course can be be fixed by moving just `thumbv7f` which is equivalent to moving the other two down. https://github.com/llvm/llvm-project/pull/159452 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB]Fix buffer-over-flow bug introduced in 157170 (PR #159588)
https://github.com/dmpots commented: Thanks for the fix. The new variable `m_executable_name` is used to save the name so that we can find the NT_FILE entries for the main executable, which is handled in a different part of the code. There is the same fix in #159375. https://github.com/llvm/llvm-project/pull/159588 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] RISCV unwinding enable (PR #158161)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `lldb-remote-linux-ubuntu` running on `as-builder-9` while building `lldb` at step 15 "test-check-lldb-unit". Full details are available at: https://lab.llvm.org/buildbot/#/builders/195/builds/14788 Here is the relevant piece of the build log for the reference ``` Step 15 (test-check-lldb-unit) failure: Test just built components: check-lldb-unit completed (failure) TEST 'lldb-unit :: Instruction/./EmulatorTests/62/63' FAILED Script(shard): -- GTEST_OUTPUT=json:/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb/unittests/Instruction/./EmulatorTests-lldb-unit-3928114-62-63.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=63 GTEST_SHARD_INDEX=62 /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb/unittests/Instruction/./EmulatorTests -- Script: -- /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb/unittests/Instruction/./EmulatorTests --gtest_filter=TestRiscvInstEmulation.TestSimpleRiscvFunction -- /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/unittests/Instruction/RISCV/TestRiscvInstEmulation.cpp:114: Failure Value of: engine->GetNonCallSiteUnwindPlanFromAssembly( sample_range, data, sizeof(data), unwind_plan) Actual: false Expected: true /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/unittests/Instruction/RISCV/TestRiscvInstEmulation.cpp:132: Failure Expected equality of these values: 2 row->GetOffset() Which is: 0 /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/unittests/Instruction/RISCV/TestRiscvInstEmulation.cpp:135: Failure Expected equality of these values: 16 row->GetCFAValue().GetOffset() Which is: 0 /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/unittests/Instruction/RISCV/TestRiscvInstEmulation.cpp:145: Failure Expected equality of these values: 4 row->GetOffset() Which is: 0 /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/unittests/Instruction/RISCV/TestRiscvInstEmulation.cpp:148: Failure Expected equality of these values: 16 row->GetCFAValue().GetOffset() Which is: 0 /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/unittests/Instruction/RISCV/TestRiscvInstEmulation.cpp:154: Failure Value of: regloc.IsAtCFAPlusOffset() Actual: false Expected: true /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/unittests/Instruction/RISCV/TestRiscvInstEmulation.cpp:155: Failure Expected equality of these values: -8 regloc.GetOffset() Which is: 0 ... ``` https://github.com/llvm/llvm-project/pull/158161 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 082d1d9 - [lldb-dap] Bump form-data from 4.0.1 to 4.0.4
Author: Jonas Devlieghere
Date: 2025-09-18T14:40:18-07:00
New Revision: 082d1d911c1cd79849f74ac203fbcbfbb6737cef
URL:
https://github.com/llvm/llvm-project/commit/082d1d911c1cd79849f74ac203fbcbfbb6737cef
DIFF:
https://github.com/llvm/llvm-project/commit/082d1d911c1cd79849f74ac203fbcbfbb6737cef.diff
LOG: [lldb-dap] Bump form-data from 4.0.1 to 4.0.4
Bumps form-data from 4.0.1 to 4.0.4 to resolve a critical security
vulnerability in form-data.
Added:
Modified:
lldb/tools/lldb-dap/package-lock.json
Removed:
diff --git a/lldb/tools/lldb-dap/package-lock.json
b/lldb/tools/lldb-dap/package-lock.json
index 26db1ce6df2fd..f3ae6b76be6d0 100644
--- a/lldb/tools/lldb-dap/package-lock.json
+++ b/lldb/tools/lldb-dap/package-lock.json
@@ -1167,9 +1167,9 @@
"dev": true
},
"node_modules/brace-expansion": {
- "version": "1.1.11",
- "resolved":
"https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz";,
- "integrity":
"sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
+ "version": "1.1.12",
+ "resolved":
"https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz";,
+ "integrity":
"sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -1629,6 +1629,22 @@
"node": ">= 0.4"
}
},
+"node_modules/es-set-tostringtag": {
+ "version": "2.1.0",
+ "resolved":
"https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz";,
+ "integrity":
"sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+"es-errors": "^1.3.0",
+"get-intrinsic": "^1.2.6",
+"has-tostringtag": "^1.0.2",
+"hasown": "^2.0.2"
+ },
+ "engines": {
+"node": ">= 0.4"
+ }
+},
"node_modules/esbuild": {
"version": "0.25.9",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.9.tgz";,
@@ -1727,14 +1743,16 @@
}
},
"node_modules/form-data": {
- "version": "4.0.1",
- "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz";,
- "integrity":
"sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==",
+ "version": "4.0.4",
+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz";,
+ "integrity":
"sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==",
"dev": true,
"license": "MIT",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
+"es-set-tostringtag": "^2.1.0",
+"hasown": "^2.0.2",
"mime-types": "^2.1.12"
},
"engines": {
@@ -1829,9 +1847,9 @@
}
},
"node_modules/glob/node_modules/brace-expansion": {
- "version": "2.0.1",
- "resolved":
"https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz";,
- "integrity":
"sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
+ "version": "2.0.2",
+ "resolved":
"https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz";,
+ "integrity":
"sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -1899,6 +1917,22 @@
"url": "https://github.com/sponsors/ljharb";
}
},
+"node_modules/has-tostringtag": {
+ "version": "1.0.2",
+ "resolved":
"https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz";,
+ "integrity":
"sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+"has-symbols": "^1.0.3"
+ },
+ "engines": {
+"node": ">= 0.4"
+ },
+ "funding": {
+"url": "https://github.com/sponsors/ljharb";
+ }
+},
"node_modules/hasown": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz";,
@@ -3067,10 +3101,11 @@
"license": "MIT"
},
"node_modules/tar-fs": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz";,
- "integrity":
"sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==",
+ "version": "2.1.4",
+ "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.4.tgz";,
+ "integrity":
"sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6
[Lldb-commits] [lldb] [lldb][NFC] Fix style issues with StackID.h (PR #157483)
https://github.com/felipepiovezan updated
https://github.com/llvm/llvm-project/pull/157483
>From 668e90948beabe437ea283b84ae0ffc9ea7c4a78 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan
Date: Mon, 8 Sep 2025 07:43:38 -0700
Subject: [PATCH] [lldb][NFC] Fix style issues with StackID.h
Some comments were "suffixed" to member variable declarations; these are
moved to before the variable.
Some constructors and operators were just defaulted and not necessary.
Some comments dividing the class into logical sections, like "//
constructors and destructors", were not applied everywhere. These were
removed. They are used in some parts of LLDB, but are the exception.
An include was not needed.
The operator != can be defined in terms of ==.
---
lldb/include/lldb/Target/StackID.h | 50 ++
lldb/source/Target/StackID.cpp | 11 +--
2 files changed, 17 insertions(+), 44 deletions(-)
diff --git a/lldb/include/lldb/Target/StackID.h
b/lldb/include/lldb/Target/StackID.h
index fddbc8e48dfdc..4b49964853f7b 100644
--- a/lldb/include/lldb/Target/StackID.h
+++ b/lldb/include/lldb/Target/StackID.h
@@ -10,7 +10,6 @@
#define LLDB_TARGET_STACKID_H
#include "lldb/Core/AddressRange.h"
-#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -18,15 +17,11 @@ class Process;
class StackID {
public:
- // Constructors and Destructors
StackID() = default;
explicit StackID(lldb::addr_t pc, lldb::addr_t cfa,
SymbolContextScope *symbol_scope, Process *process);
- StackID(const StackID &rhs)
- : m_pc(rhs.m_pc), m_cfa(rhs.m_cfa), m_symbol_scope(rhs.m_symbol_scope) {}
-
~StackID() = default;
lldb::addr_t GetPC() const { return m_pc; }
@@ -51,41 +46,28 @@ class StackID {
void Dump(Stream *s);
- // Operators
- const StackID &operator=(const StackID &rhs) {
-if (this != &rhs) {
- m_pc = rhs.m_pc;
- m_cfa = rhs.m_cfa;
- m_symbol_scope = rhs.m_symbol_scope;
-}
-return *this;
- }
-
protected:
friend class StackFrame;
void SetPC(lldb::addr_t pc, Process *process);
void SetCFA(lldb::addr_t cfa, Process *process);
- lldb::addr_t m_pc =
- LLDB_INVALID_ADDRESS; // The pc value for the function/symbol for this
-// frame. This will
- // only get used if the symbol scope is nullptr (the code where we are
- // stopped is not represented by any function or symbol in any shared
- // library).
- lldb::addr_t m_cfa =
- LLDB_INVALID_ADDRESS; // The call frame address (stack pointer) value
-// at the beginning of the function that uniquely
-// identifies this frame (along with m_symbol_scope
-// below)
- SymbolContextScope *m_symbol_scope =
- nullptr; // If nullptr, there is no block or symbol for this frame.
- // If not nullptr, this will either be the scope for the
- // lexical block for the frame, or the scope for the
- // symbol. Symbol context scopes are always be unique
- // pointers since the are part of the Block and Symbol
- // objects and can easily be used to tell if a stack ID
- // is the same as another.
+ // The pc value for the function/symbol for this frame. This will only get
+ // used if the symbol scope is nullptr (the code where we are stopped is not
+ // represented by any function or symbol in any shared library).
+ lldb::addr_t m_pc = LLDB_INVALID_ADDRESS;
+
+ // The call frame address (stack pointer) value at the beginning of the
+ // function that uniquely identifies this frame (along with m_symbol_scope
+ // below)
+ lldb::addr_t m_cfa = LLDB_INVALID_ADDRESS;
+
+ // If nullptr, there is no block or symbol for this frame. If not nullptr,
+ // this will either be the scope for the lexical block for the frame, or the
+ // scope for the symbol. Symbol context scopes are always be unique pointers
+ // since the are part of the Block and Symbol objects and can easily be used
+ // to tell if a stack ID is the same as another.
+ SymbolContextScope *m_symbol_scope = nullptr;
};
bool operator==(const StackID &lhs, const StackID &rhs);
diff --git a/lldb/source/Target/StackID.cpp b/lldb/source/Target/StackID.cpp
index b1795970802ae..f879276527dda 100644
--- a/lldb/source/Target/StackID.cpp
+++ b/lldb/source/Target/StackID.cpp
@@ -63,16 +63,7 @@ bool lldb_private::operator==(const StackID &lhs, const
StackID &rhs) {
}
bool lldb_private::operator!=(const StackID &lhs, const StackID &rhs) {
- if (lhs.GetCallFrameAddress() != rhs.GetCallFrameAddress())
-return true;
-
- SymbolContextScope *lhs_scope = lhs.GetSymbolContextScope();
- SymbolContextScope *rhs_scope = rhs.GetSymbolContextScope();
-
- if (lhs_scope == nullptr && rhs_scope == nullptr)
-return lhs.GetPC() != rhs.GetPC();
-
- return lhs_scope != rhs_scope;
+ return !(lhs == rhs);
}
bo
[Lldb-commits] [lldb] RISCV unwinding enable (PR #158161)
satyajanga wrote: looks good to me. https://github.com/llvm/llvm-project/pull/158161 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 1c95d80 - RISCV enable assembly unwinding (#158161)
Author: barsolo2000
Date: 2025-09-18T15:41:16-05:00
New Revision: 1c95d80ba68efd2ca9a0336529ea5fb7dc871417
URL:
https://github.com/llvm/llvm-project/commit/1c95d80ba68efd2ca9a0336529ea5fb7dc871417
DIFF:
https://github.com/llvm/llvm-project/commit/1c95d80ba68efd2ca9a0336529ea5fb7dc871417.diff
LOG: RISCV enable assembly unwinding (#158161)
**Added emulator unwinding support for RISCV files.**
Emulated Instructions:
ADD (addi sp, sp, imm)
STORE (sd ra, offset(sp))
LOAD (ld ra, offset(sp)).
We had to overwrite SetInstructions() since UnwindAssemblyInstEmulation
calls EvaluateInstruction() directly after calling SetInstruction(), but
it never calls ReadInstruction(). This means that the m_decoded member
variable in the instruction emulator is never properly initialized. By
overriding SetInstruction(), we decode the instruction bytes and set
m_decoded directly. This ensures that subsequent emulation (including
unwinding) operates on the correct instruction.
We also had to change the the OpCode GetOpcodeBytes function since
recent changes made it so GetOpcodeBytes will return None for type
eType16_32Tuples (an alternative and longer way, would've been to type
check during the overwritten SetInstruction() and call a DataExtractor
with .GetU16(&offset) to set the inst_data.
Added a test - TestSimpleRiscvFunction (took inspiration from:
[link](https://github.com/llvm/llvm-project/blob/main/lldb/unittests/UnwindAssembly/ARM64/TestArm64InstEmulation.cpp))
[--] 1 test from TestRiscvInstEmulation
[ RUN ] TestRiscvInstEmulation.TestSimpleRiscvFunction
[ OK ] TestRiscvInstEmulation.TestSimpleRiscvFunction (1 ms)
[--] 1 test from TestRiscvInstEmulation (1 ms total)
[--] Global test environment tear-down
[==] 63 tests from 5 test suites ran. (11 ms total)
[ PASSED ] 63 tests.
-
Co-authored-by: Bar Soloveychik
Added:
lldb/unittests/Instruction/RISCV/TestRiscvInstEmulation.cpp
Modified:
lldb/include/lldb/Core/Opcode.h
lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h
lldb/unittests/Instruction/CMakeLists.txt
Removed:
diff --git a/lldb/include/lldb/Core/Opcode.h b/lldb/include/lldb/Core/Opcode.h
index 7bbd73d039f99..7e756d3f15d22 100644
--- a/lldb/include/lldb/Core/Opcode.h
+++ b/lldb/include/lldb/Core/Opcode.h
@@ -223,7 +223,9 @@ class Opcode {
int Dump(Stream *s, uint32_t min_byte_width) const;
const void *GetOpcodeBytes() const {
-return ((m_type == Opcode::eTypeBytes) ? m_data.inst.bytes : nullptr);
+return ((m_type == Opcode::eTypeBytes || m_type ==
Opcode::eType16_32Tuples)
+? m_data.inst.bytes
+: nullptr);
}
uint32_t GetByteSize() const {
diff --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
index 5e429a92613ce..20661290ca4c6 100644
--- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
+++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
@@ -33,6 +33,10 @@ LLDB_PLUGIN_DEFINE_ADV(EmulateInstructionRISCV,
InstructionRISCV)
namespace lldb_private {
+// RISC-V General Purpose Register numbers
+static constexpr uint32_t RISCV_GPR_SP = 2; // x2 is the stack pointer
+static constexpr uint32_t RISCV_GPR_FP = 8; // x8 is the frame pointer
+
/// Returns all values wrapped in Optional, or std::nullopt if any of the
values
/// is std::nullopt.
template
@@ -108,6 +112,16 @@ static uint32_t FPREncodingToLLDB(uint32_t reg_encode) {
return LLDB_INVALID_REGNUM;
}
+// Helper function to get register info from GPR encoding
+static std::optional
+GPREncodingToRegisterInfo(EmulateInstructionRISCV &emulator,
+ uint32_t reg_encode) {
+ uint32_t lldb_reg = GPREncodingToLLDB(reg_encode);
+ if (lldb_reg == LLDB_INVALID_REGNUM)
+return std::nullopt;
+ return emulator.GetRegisterInfo(eRegisterKindLLDB, lldb_reg);
+}
+
bool Rd::Write(EmulateInstructionRISCV &emulator, uint64_t value) {
uint32_t lldb_reg = GPREncodingToLLDB(rd);
EmulateInstruction::Context ctx;
@@ -230,10 +244,34 @@ Load(EmulateInstructionRISCV &emulator, I inst, uint64_t
(*extend)(E)) {
auto addr = LoadStoreAddr(emulator, inst);
if (!addr)
return false;
- return transformOptional(
- emulator.ReadMem(*addr),
- [&](T t) { return inst.rd.Write(emulator, extend(E(t))); })
- .value_or(false);
+
+ // Set up context for the load operation, similar to ARM64.
+ EmulateInstructionRISCV::Context context;
+
+ // Get register info for base register
+ std::optional reg_info_rs1 =
+ GPREncodingToRegisterInfo(emulator, inst.rs1.rs);
+
+ if (!reg_info_rs1)
+return false;
+
+ // Set context type based on whether this is a stack-based load.
+ i
[Lldb-commits] [lldb] RISCV unwinding enable (PR #158161)
https://github.com/satyajanga closed https://github.com/llvm/llvm-project/pull/158161 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a666286 - [lldb][NFC] Simplify logic in ABIMacOSX_arm64::FixDataAddress (#159612)
Author: Felipe de Azevedo Piovezan
Date: 2025-09-18T13:49:56-07:00
New Revision: a6662866e88a887ab125c4d533659d27c4134108
URL:
https://github.com/llvm/llvm-project/commit/a6662866e88a887ab125c4d533659d27c4134108
DIFF:
https://github.com/llvm/llvm-project/commit/a6662866e88a887ab125c4d533659d27c4134108.diff
LOG: [lldb][NFC] Simplify logic in ABIMacOSX_arm64::FixDataAddress (#159612)
I've intentionally split this into two commits to make it easier that
this is an NFC patch; don't think we need to preserve them separately
though upon merging.
Added:
Modified:
lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
Removed:
diff --git a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
index 094e0523a4edf..c595564f6fb8e 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
@@ -757,42 +757,39 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
return return_valobj_sp;
}
-addr_t ABIMacOSX_arm64::FixCodeAddress(addr_t pc) {
- addr_t pac_sign_extension = 0x0080ULL;
- addr_t tbi_mask = 0xff80ULL;
- addr_t mask = 0;
-
- if (ProcessSP process_sp = GetProcessSP()) {
-mask = process_sp->GetCodeAddressMask();
-if (pc & pac_sign_extension) {
- addr_t highmem_mask = process_sp->GetHighmemCodeAddressMask();
- if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
-mask = highmem_mask;
-}
- }
+constexpr addr_t tbi_mask = 0xff80ULL;
+constexpr addr_t pac_sign_extension = 0x0080ULL;
+
+/// Consults the process for its {code, data} address masks and applies it to
+/// `addr`.
+static addr_t DoFixAddr(addr_t addr, bool is_code, ProcessSP process_sp) {
+ if (!process_sp)
+return addr;
+
+ addr_t mask = is_code ? process_sp->GetCodeAddressMask()
+: process_sp->GetDataAddressMask();
if (mask == LLDB_INVALID_ADDRESS_MASK)
mask = tbi_mask;
- return (pc & pac_sign_extension) ? pc | mask : pc & (~mask);
+ if (addr & pac_sign_extension) {
+addr_t highmem_mask = is_code ? process_sp->GetHighmemCodeAddressMask()
+ : process_sp->GetHighmemCodeAddressMask();
+if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
+ return addr | highmem_mask;
+return addr | mask;
+ }
+
+ return addr & (~mask);
}
-addr_t ABIMacOSX_arm64::FixDataAddress(addr_t pc) {
- addr_t pac_sign_extension = 0x0080ULL;
- addr_t tbi_mask = 0xff80ULL;
- addr_t mask = 0;
-
- if (ProcessSP process_sp = GetProcessSP()) {
-mask = process_sp->GetDataAddressMask();
-if (pc & pac_sign_extension) {
- addr_t highmem_mask = process_sp->GetHighmemDataAddressMask();
- if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
-mask = highmem_mask;
-}
- }
- if (mask == LLDB_INVALID_ADDRESS_MASK)
-mask = tbi_mask;
+addr_t ABIMacOSX_arm64::FixCodeAddress(addr_t pc) {
+ ProcessSP process_sp = GetProcessSP();
+ return DoFixAddr(pc, true /*is_code*/, GetProcessSP());
+}
- return (pc & pac_sign_extension) ? pc | mask : pc & (~mask);
+addr_t ABIMacOSX_arm64::FixDataAddress(addr_t addr) {
+ ProcessSP process_sp = GetProcessSP();
+ return DoFixAddr(addr, false /*is_code*/, GetProcessSP());
}
void ABIMacOSX_arm64::Initialize() {
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Simplify logic in ABIMacOSX_arm64::FixDataAddress (PR #159612)
https://github.com/felipepiovezan closed https://github.com/llvm/llvm-project/pull/159612 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
