Skip to content

[lldb][rpc] Fix bug in convert script for RPC #145419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

chelcassanova
Copy link
Contributor

In the script that's used by RPC to convert LLDB headers to LLDB RPC headers, there's a bug with how it converts namespace usage. An overeager regex pattern caused all text before any lldb:: namespace usage to get replaced with lldb_rpc:: instead of just the namespace itself. This commit changes that regex pattern to be less overeager and modifies one of the shell tests for this script to actually check that the namespace usage replacement is working correctly.

rdar://154126268

In the script that's used by RPC to convert LLDB headers to LLDB RPC
headers, there's a bug with how it converts namespace usage. An
overeager regex pattern caused *all* text before any `lldb::` namespace
usage to get replaced with `lldb_rpc::` instead of just the namespace
itself. This commit changes that regex pattern to be less overeager and
modifies one of the shell tests for this script to actually check that
the namespace usage replacement is working correctly.

rdar://154126268
@llvmbot
Copy link
Member

llvmbot commented Jun 23, 2025

@llvm/pr-subscribers-lldb

Author: Chelsea Cassanova (chelcassanova)

Changes

In the script that's used by RPC to convert LLDB headers to LLDB RPC headers, there's a bug with how it converts namespace usage. An overeager regex pattern caused all text before any lldb:: namespace usage to get replaced with lldb_rpc:: instead of just the namespace itself. This commit changes that regex pattern to be less overeager and modifies one of the shell tests for this script to actually check that the namespace usage replacement is working correctly.

rdar://154126268


Full diff: https://github.com/llvm/llvm-project/pull/145419.diff

3 Files Affected:

  • (modified) lldb/scripts/convert-lldb-header-to-rpc-header.py (+1-1)
  • (modified) lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBEnumerations.test (+3)
  • (modified) lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-enumerations.h (+3)
diff --git a/lldb/scripts/convert-lldb-header-to-rpc-header.py b/lldb/scripts/convert-lldb-header-to-rpc-header.py
index d7734280076ff..13b6bed20f778 100755
--- a/lldb/scripts/convert-lldb-header-to-rpc-header.py
+++ b/lldb/scripts/convert-lldb-header-to-rpc-header.py
@@ -27,7 +27,7 @@
 LLDB_NAMESPACE_DEFINITION_REGEX = re.compile(
     r"(?P<comment_marker>//\s*){,1}namespace lldb\s{1}", re.M
 )
-LLDB_NAMESPACE_REGEX = re.compile(r"\s*.+lldb::\s*", re.M)
+LLDB_NAMESPACE_REGEX = re.compile(r"lldb::\s*", re.M)
 
 
 def main():
diff --git a/lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBEnumerations.test b/lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBEnumerations.test
index 0fb3c6f73dd0f..1109086cf731c 100644
--- a/lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBEnumerations.test
+++ b/lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBEnumerations.test
@@ -13,5 +13,8 @@ CHECK: #define LLDB_RPC_ENUMERATIONS_H
 # Change the namespace to lldb_rpc. Also, the comment that closes the namespace should match the namespace.
 CHECK: namespace lldb_rpc {} // namespace lldb_rpc
 
+# When the lldb namespace is used, the namespace must be replaced with lldb_rpc.
+CHECK: void dummyFunction(lldb_rpc::addr_t) {}
+
 # The comment that closes the include guard should match the guard.
 CHECK: #endif // LLDB_RPC_ENUMERATIONS_H
diff --git a/lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-enumerations.h b/lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-enumerations.h
index 42c4bb277fc45..22dd09097d431 100644
--- a/lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-enumerations.h
+++ b/lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-enumerations.h
@@ -11,6 +11,9 @@
 // namespace lldb -> namespace lldb_rpc
 namespace lldb {} // namespace lldb
 
+// When the lldb namespace is used, the namespace must be replaced with lldb_rpc.
+void dummyFunction(lldb::addr_t) {}
+
 // The comment that closes the include guard must change in the same way
 // the original guard did:
 // #endif // LLDB_LLDB_ENUMERATIONS_H -> #endif // LLDB_RPC_ENUMERATIONS_H

Copy link
Member

@bulbazord bulbazord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for the quick fix!

@chelcassanova chelcassanova merged commit 92a7f6f into llvm:main Jun 23, 2025
9 checks passed
DrSergei pushed a commit to DrSergei/llvm-project that referenced this pull request Jun 24, 2025
In the script that's used by RPC to convert LLDB headers to LLDB RPC
headers, there's a bug with how it converts namespace usage. An
overeager regex pattern caused *all* text before any `lldb::` namespace
usage to get replaced with `lldb_rpc::` instead of just the namespace
itself. This commit changes that regex pattern to be less overeager and
modifies one of the shell tests for this script to actually check that
the namespace usage replacement is working correctly.

rdar://154126268
anthonyhatran pushed a commit to anthonyhatran/llvm-project that referenced this pull request Jun 26, 2025
In the script that's used by RPC to convert LLDB headers to LLDB RPC
headers, there's a bug with how it converts namespace usage. An
overeager regex pattern caused *all* text before any `lldb::` namespace
usage to get replaced with `lldb_rpc::` instead of just the namespace
itself. This commit changes that regex pattern to be less overeager and
modifies one of the shell tests for this script to actually check that
the namespace usage replacement is working correctly.

rdar://154126268
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants