From 0a6a68db2424048148435578d1817127d90f2bbe Mon Sep 17 00:00:00 2001 From: wuyuanchao Date: Mon, 10 Feb 2025 15:21:08 +0800 Subject: [PATCH] [lldb] fixed PC natvie debug can not be connected in domain-socket mode. Select the formatted URL string based on the value of scheme. Add test cases for domain-socket mode. Issue: https://gitee.com/openharmony/third_party_llvm-project/issues/IBK4TY q Signed-off-by: wuyuanchao --- .../gdb-server/PlatformRemoteGDBServer.cpp | 6 ++++- lldb/test/API/linux/domain-socket/Makefile | 2 ++ .../domain-socket/TestDomainSocketConnect.py | 26 +++++++++++++++++++ lldb/test/API/linux/domain-socket/main.c | 6 +++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 lldb/test/API/linux/domain-socket/Makefile create mode 100644 lldb/test/API/linux/domain-socket/TestDomainSocketConnect.py create mode 100644 lldb/test/API/linux/domain-socket/main.c diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp index 626d26ab6a07..736a54a092d8 100644 --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -788,7 +788,11 @@ std::string PlatformRemoteGDBServer::MakeUrl(const char *scheme, const char *hostname, uint16_t port, const char *path) { StreamString result; - result.Printf("%s://[%s]", scheme, hostname); + // OHOS_LOCAL begin + bool is_abstract = !strcmp(scheme, "unix-abstract-connect"); + auto* fmt_str = is_abstract ? "%s://%s" : "%s://[%s]"; + result.Printf(fmt_str, scheme, hostname); + // OHOS_LOCAL end if (port != 0) result.Printf(":%u", port); if (path) diff --git a/lldb/test/API/linux/domain-socket/Makefile b/lldb/test/API/linux/domain-socket/Makefile new file mode 100644 index 000000000000..c9319d6e6888 --- /dev/null +++ b/lldb/test/API/linux/domain-socket/Makefile @@ -0,0 +1,2 @@ +C_SOURCES := main.c +include Makefile.rules diff --git a/lldb/test/API/linux/domain-socket/TestDomainSocketConnect.py b/lldb/test/API/linux/domain-socket/TestDomainSocketConnect.py new file mode 100644 index 000000000000..1fcdb21a2dfb --- /dev/null +++ b/lldb/test/API/linux/domain-socket/TestDomainSocketConnect.py @@ -0,0 +1,26 @@ +''' +Test PC native debug can be connected in domain-socket mode. +''' + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestDomainSocketConnect(TestBase): + + @skipUnlessPlatform("remote-linux") + def test_with_run_command(self): + """Test that auto types work in the expression parser""" + self.build() + lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.c")) + + self.expect_expr('auto f = 123456; f', result_type='int', result_value='123456') + self.expect( + 'expr struct Test { int x; int y; Test() : x(123), y(456) {} }; auto t = Test(); t', + substrs=[ + 'Test', + '123', + '456']) + self.expect_expr("auto s = foo; s", result_type="long", result_value="1234") diff --git a/lldb/test/API/linux/domain-socket/main.c b/lldb/test/API/linux/domain-socket/main.c new file mode 100644 index 000000000000..3ead9e4957a6 --- /dev/null +++ b/lldb/test/API/linux/domain-socket/main.c @@ -0,0 +1,6 @@ +int main() +{ + long foo = 1234; + + return 0; // break here +} -- Gitee