https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/138028

>From 0b83514cde0b6fa2adc8c31a082a03770248ae4e Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova <chelsea_cassan...@apple.com>
Date: Wed, 30 Apr 2025 13:37:15 -0700
Subject: [PATCH] [lldb][RPC] Upstream Python scripts

As part of upstreaming LLDB RPC, this commit adds python scripts that
are used by LLDB RPC to modify the public lldb header files for use with
RPC.

https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804
---
 .../convert-lldb-header-to-rpc-header.py      | 71 +++++++++++++++++++
 lldb/scripts/framework-header-include-fix.py  | 46 ++++++++++++
 .../TestConvertScript/CheckLLDBDefines.test   | 23 ++++++
 .../CheckLLDBEnumerations.test                | 21 ++++++
 .../TestConvertScript/CheckLLDBTypes.test     | 25 +++++++
 .../TestConvertScript/CheckSBDefines.test     | 23 ++++++
 .../TestConvertScript/Inputs/SBDefines.h      | 22 ++++++
 .../Inputs/lldb-enumerations.h                | 17 +++++
 .../Inputs/lldb-rpc-defines.h                 | 23 ++++++
 .../TestConvertScript/Inputs/lldb-types.h     | 23 ++++++
 .../CheckLLDBDefines.test                     |  9 +++
 .../CheckLLDBTypes.test                       |  9 +++
 .../CheckSBClass.test                         | 10 +++
 .../CheckSBDefines.test                       | 12 ++++
 .../Inputs/SBDefines.h                        |  9 +++
 .../Inputs/SBRPC-FrameworkFix.h               | 10 +++
 .../Inputs/lldb-rpc-defines.h                 |  7 ++
 .../Inputs/lldb-rpc-types.h                   |  7 ++
 18 files changed, 367 insertions(+)
 create mode 100755 lldb/scripts/convert-lldb-header-to-rpc-header.py
 create mode 100755 lldb/scripts/framework-header-include-fix.py
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBDefines.test
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBEnumerations.test
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBTypes.test
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckSBDefines.test
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/SBDefines.h
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-enumerations.h
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-rpc-defines.h
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-types.h
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckLLDBDefines.test
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckLLDBTypes.test
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckSBClass.test
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckSBDefines.test
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/SBDefines.h
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/SBRPC-FrameworkFix.h
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/lldb-rpc-defines.h
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/lldb-rpc-types.h

diff --git a/lldb/scripts/convert-lldb-header-to-rpc-header.py 
b/lldb/scripts/convert-lldb-header-to-rpc-header.py
new file mode 100755
index 0000000000000..a7fd4733af56f
--- /dev/null
+++ b/lldb/scripts/convert-lldb-header-to-rpc-header.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python3
+"""
+Usage: convert-lldb-header-to-rpc-header.py <path/to/input-header.h> 
<path/to/output-header.h>
+
+This scripts takes common LLDB headers (such as lldb-defines.h) and replaces 
references to LLDB
+with those for RPC. This happens for:
+- namespace definitions
+- namespace usage
+- version string macros
+- ifdef/ifndef lines
+"""
+# Usage: convert-lldb-header-to-rpc-header.py <path/to/input-header.h> 
<path/to/output-header.h>
+
+import argparse
+import os
+import re
+
+
+def main():
+    parser = argparse.ArgumentParser()
+    parser.add_argument("input")
+    parser.add_argument("output")
+    args = parser.parse_args()
+    input_path = str(args.input)
+    output_path = str(args.output)
+    with open(input_path, "r") as input_file:
+        lines = input_file.readlines()
+
+    with open(output_path, "w") as output_file:
+        for line in lines:
+            # NOTE: We do not use lldb-forward.h or lldb-versioning.h in RPC, 
so remove
+            # all includes that are found for these files.
+            if re.match(
+                r'#include "lldb/lldb-forward|#include "lldb/lldb-versioning', 
line
+            ):
+                continue
+            # For lldb-rpc-defines.h, replace the ifndef LLDB_LLDB_ portion 
with LLDB_RPC_ as we're not
+            # using LLDB private definitions in RPC.
+            elif re.match(r".+LLDB_LLDB_", line):
+                output_file.write(re.sub(r"LLDB_LLDB_", r"LLDB_RPC_", line))
+            # Similarly to lldb-rpc-defines.h, replace the ifndef for LLDB_API 
in SBDefines.h to LLDB_RPC_API_ for the same reason.
+            elif re.match(r".+LLDB_API_", line):
+                output_file.write(re.sub(r"LLDB_API_", r"LLDB_RPC_API_", line))
+            # Replace the references for the macros that define the versioning 
strings in
+            # lldb-rpc-defines.h.
+            # NOTE: Here we assume that the versioning info has already been 
uncommented and
+            # populated from the original lldb-defines.h.
+            elif re.match(r".+LLDB_VERSION", line):
+                output_file.write(re.sub(r"LLDB_VERSION", r"LLDB_RPC_VERSION", 
line))
+            elif re.match(r".+LLDB_REVISION", line):
+                output_file.write(re.sub(r"LLDB_REVISION", 
r"LLDB_RPC_REVISION", line))
+            elif re.match(r".+LLDB_VERSION_STRING", line):
+                output_file.write(
+                    re.sub(r"LLDB_VERSION_STRING", r"LLDB_RPC_VERSION_STRING", 
line)
+                )
+            # For local #includes
+            elif re.match(r'#include "lldb/lldb-', line):
+                output_file.write(re.sub(r"lldb/lldb-", r"lldb-rpc-", line))
+            # Rename the lldb namespace definition to lldb-rpc.
+            elif re.match(r".*namespace lldb", line):
+                output_file.write(re.sub(r"lldb", r"lldb_rpc", line))
+            # Rename namespace references
+            elif re.match(r".+lldb::", line):
+                output_file.write(re.sub(r"lldb::", r"lldb_rpc::", line))
+            else:
+                # Write any line that doesn't need to be converted
+                output_file.write(line)
+
+
+if __name__ == "__main__":
+    main()
diff --git a/lldb/scripts/framework-header-include-fix.py 
b/lldb/scripts/framework-header-include-fix.py
new file mode 100755
index 0000000000000..ba4aa27d09de9
--- /dev/null
+++ b/lldb/scripts/framework-header-include-fix.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+"""
+Usage: framework-header-include-fix.py <path/to/input-header.h> 
<path/to/output-header.h>
+
+This script modifies all #include lines in all lldb-rpc headers
+from either filesystem or local includes to liblldbrpc includes.
+"""
+
+import argparse
+import os
+import re
+
+
+def main():
+    parser = argparse.ArgumentParser()
+    parser.add_argument("input")
+    parser.add_argument("output")
+    args = parser.parse_args()
+    input_path = str(args.input)
+    output_path = str(args.output)
+    with open(input_path, "r") as input_file:
+        lines = input_file.readlines()
+
+    with open(output_path, "w") as output_file:
+        for line in lines:
+            # Replace includes from RPCCommon to liblldbrpc includes.
+            # e.g. #include <lldb-rpc/common/RPCArgument.h> -> #include 
<LLDBRPC/RPCArgument.h>
+            if re.match(r".+<lldb-rpc/common", line):
+                output_file.write(re.sub(r"<lldb-rpc/common", r"<LLDBRPC", 
line))
+            # Replace all local file includes to liblldbrpc includes.
+            # e.g. #include "SBFoo.h" -> #include <LLDBRPC/SBFoo.h>
+            elif include_filename := re.match(r'#include "(.*)"', line):
+                output_file.write(
+                    re.sub(
+                        r'#include "(.*)"',
+                        r"#include <LLDBRPC/" + include_filename.group(1) + 
">",
+                        line,
+                    )
+                )
+            else:
+                # Write any line that doesn't need to be converted
+                output_file.write(line)
+
+
+if __name__ == "__main__":
+    main()
diff --git 
a/lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBDefines.test 
b/lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBDefines.test
new file mode 100644
index 0000000000000..9ec403914790f
--- /dev/null
+++ b/lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBDefines.test
@@ -0,0 +1,23 @@
+# Copy lldb-defines.h from source.
+RUN: mkdir -p %t/Outputs
+
+# Run the convert script on it.
+RUN: %python %p/../../../../../scripts/convert-lldb-header-to-rpc-header.py 
%p/Inputs/lldb-defines.h %t/Outputs/lldb-rpc-defines.h
+
+# Check the output
+RUN: cat %t/output/lldb-rpc-defines.h | FileCheck %s
+
+# The include guards must change from LLDB_LLDB_DEFINES_H to 
LLDB_RPC_DEFINES_H.
+CHECK: #ifndef LLDB_RPC_DEFINES_H
+CHECK: #define LLDB_RPC_DEFINES_H
+
+# Includes of other lldb headers must begin with "lldb-rpc-".
+CHECK: #include "lldb-rpc-types.h"
+
+# The version info must be changed from LLDB_VERSION to LLDB_RPC_VERSION
+CHECK: #define LLDB_RPC_VERSION
+CHECK: #define LLDB_RPC_REVISION
+CHECK: #define LLDB_RPC_VERSION_STRING
+
+# The comment that closes the include guard should match the guard.
+CHECK: #endif // LLDB_RPC_DEFINES_H
diff --git 
a/lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBEnumerations.test 
b/lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBEnumerations.test
new file mode 100644
index 0000000000000..c0ce001b5f097
--- /dev/null
+++ b/lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBEnumerations.test
@@ -0,0 +1,21 @@
+RUN: mkdir -p %t/Outputs
+
+# Run the convert script on it.
+RUN: %python %p/../../../../../scripts/convert-lldb-header-to-rpc-header.py 
%p/Inputs/lldb-enumerations.h %t/Outputs/lldb-rpc-enumerations.h
+
+# Check the output
+RUN: cat %t/Outputs/lldb-rpc-enumerations.h
+RUN: cat %t/Outputs/lldb-rpc-enumerations.h | FileCheck %s
+
+# The include guards must change from LLDB_LLDB_ENUMERATIONS_H to 
LLDB_RPC_ENUMERATIONS_H.
+CHECK: #ifndef LLDB_RPC_ENUMERATIONS_H
+CHECK: #define LLDB_RPC_ENUMERATIONS_H
+
+# Change the namespace to lldb_rpc.
+CHECK: namespace lldb_rpc
+
+# The comment that closes the namespace should match the namespace.
+CHECK: // namespace lldb_rpc
+
+# 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/CheckLLDBTypes.test 
b/lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBTypes.test
new file mode 100644
index 0000000000000..ff40d52583d18
--- /dev/null
+++ b/lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBTypes.test
@@ -0,0 +1,25 @@
+RUN: mkdir -p %t/Outputs
+
+# Run the convert script on lldb-types.h
+RUN: %python %p/../../../../../scripts/convert-lldb-header-to-rpc-header.py 
%p/Inputs/lldb-types.h %t/Outputs/lldb-rpc-types.h
+
+# Check the output
+RUN: cat %t/Outputs/lldb-rpc-types.h
+RUN: cat %t/Outputs/lldb-rpc-types.h | FileCheck %s
+
+# The include guards must change from LLDB_LLDB_TYPES_H to LLDB_RPC_TYPES_H.
+CHECK: #ifndef LLDB_RPC_TYPES_H
+CHECK: #define LLDB_RPC_TYPES_H
+
+# Includes of other lldb headers must begin with "lldb-rpc-".
+# Also, the includes for lldb-forward.h should be removed.
+CHECK: #include "lldb-rpc-enumerations.h"
+
+# Change the namespace to lldb_rpc.
+CHECK: namespace lldb_rpc
+
+# The comment that closes the namespace should match the namespace.
+CHECK: // namespace lldb_rpc
+
+# The comment that closes the include guard should match the guard.
+CHECK: #endif // LLDB_RPC_TYPES_H
diff --git a/lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckSBDefines.test 
b/lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckSBDefines.test
new file mode 100644
index 0000000000000..1632c72a03745
--- /dev/null
+++ b/lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckSBDefines.test
@@ -0,0 +1,23 @@
+RUN: mkdir -p %t/Outputs
+
+# Run the convert script on it.
+RUN: %python %p/../../../../../scripts/convert-lldb-header-to-rpc-header.py 
%p/Inputs/SBDefines.h %t/Outputs/SBDefines.h
+
+# Check the output
+RUN: cat %t/Outputs/SBDefines.h
+RUN: cat %t/Outputs/SBDefines.h | FileCheck %s
+
+# The include guards must change from LLDB_LLDB_API_SBDEFINES_H to 
LLDB_RPC_API_SBDEFINES_H.
+CHECK: #ifndef LLDB_RPC_API_SBDEFINES_H
+CHECK: #define LLDB_RPC_API_SBDEFINES_H
+
+# Includes of other lldb headers must begin with "lldb-rpc-".
+# Also, the includes for lldb-forward.h and lldb-versioning.h should be 
removed.
+CHECK: #include "lldb-rpc-defines.h"
+CHECK-NOT: #include "lldb-rpc-forward.h"
+CHECK: #include "lldb-rpc-enumerations.h"
+CHECK: #include "lldb-rpc-types.h"
+CHECK-NOT: #include "lldb-rpc-versioning.h"
+
+# The comment that closes the include guard should match the guard.
+CHECK: #endif // LLDB_RPC_API_SBDEFINES_H
diff --git a/lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/SBDefines.h 
b/lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/SBDefines.h
new file mode 100644
index 0000000000000..50476c402ba72
--- /dev/null
+++ b/lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/SBDefines.h
@@ -0,0 +1,22 @@
+// This is a truncated version of SBDefines.h used to test that the script
+// convert-lldb-header-to-rpc-header.py works correctly. The script changes 
LLDB references in
+// the original file to RPC references.
+
+// The include guard should change from LLDB_LLDB to LLDB_RPC.
+// LLDB_API_SBDEFINES_H -> LLDB_RPC_SBDEFINES_H
+#ifndef LLDB_API_SBDEFINES_H
+#define LLDB_API_SBDEFINES_H
+
+// Includes of public main LLDB headers should change to their RPC equivalents:
+// "lldb/lldb-defines.h" -> "lldb-rpc-defines.h"
+// Also, the includes for lldb-forward.h and lldb-versioning.h should be 
removed.
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-types.h"
+#include "lldb/lldb-versioning.h"
+
+// The comment that closes the include guard must change in the same way
+// the original guard did.
+// #endif // LLDB_API_SBDEFINES_H -> #endif // LLDB_RPC_API_SBDEFINES_H
+#endif // LLDB_API_SBDEFINES_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
new file mode 100644
index 0000000000000..42c4bb277fc45
--- /dev/null
+++ b/lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-enumerations.h
@@ -0,0 +1,17 @@
+// This is a truncated version of lldb-enumerations.h used to test that the 
script
+// convert-lldb-header-to-rpc-header.py works correctly. The script changes 
LLDB references in
+// the original file to RPC references.
+
+// The include guard should change from LLDB_LLDB to LLDB_RPC.
+// LLDB_LLDB_ENUMERATIONS_H -> LLDB_RPC_ENUMERATIONS_H
+#ifndef LLDB_LLDB_ENUMERATIONS_H
+#define LLDB_LLDB_ENUMERATIONS_H
+
+// The namespace definition should change to the lldb_rpc namespace, so should 
the comment that closes it:
+// namespace lldb -> namespace lldb_rpc
+namespace lldb {} // namespace lldb
+
+// 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
+#endif // LLDB_LLDB_ENUMERATIONS_H
diff --git 
a/lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-rpc-defines.h 
b/lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-rpc-defines.h
new file mode 100644
index 0000000000000..326fbf2a6f324
--- /dev/null
+++ b/lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-rpc-defines.h
@@ -0,0 +1,23 @@
+// This is a truncated version of lldb-defines.h used to test that the script
+// convert-lldb-header-to-rpc-header.py works correctly. The script changes 
LLDB references in
+// the original file to RPC references.
+
+// The include guard should change from LLDB_LLDB to LLDB_RPC.
+// LLDB_LLDB_DEFINES_H -> LLDB_RPC_DEFINES_H
+#ifndef LLDB_LLDB_DEFINES_H
+#define LLDB_LLDB_DEFINES_H
+
+// Includes of public main LLDB headers should change to their RPC equivalents:
+// "lldb/lldb-types.h" -> "lldb-rpc-types.h"
+#include "lldb/lldb-types.h"
+
+// The LLDB version must change from LLDB to LLDB_RPC
+// LLDB_VERSION -> LLDB_RPC_VERSION
+#define LLDB_VERSION 21
+#define LLDB_REVISION 0
+#define LLDB_VERSION_STRING 0
+
+// The comment that closes the include guard must change in the same way
+// the original guard did.
+// #endif // LLDB_LLDB_DEFINES_H -> #endif // LLDB_RPC_DEFINES_H
+#endif // LLDB_LLDB_DEFINES_H
diff --git a/lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-types.h 
b/lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-types.h
new file mode 100644
index 0000000000000..5a49920405ec6
--- /dev/null
+++ b/lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-types.h
@@ -0,0 +1,23 @@
+// This is a truncated version of lldb-types.h used to test that the script
+// convert-lldb-header-to-rpc-header.py works correctly. The script changes 
LLDB references in
+// the original file to RPC references.
+
+// The include guard should change from LLDB_LLDB to LLDB_RPC.
+// LLDB_LLDB_TYPES_H -> LLDB_RPC_TYPES_H
+#ifndef LLDB_LLDB_TYPES_H
+#define LLDB_LLDB_TYPES_H
+
+// Includes of public main LLDB headers should change to their RPC equivalents:
+// "lldb/lldb-defines.h" -> "lldb-rpc-defines.h":
+// Also, the includes for lldb-forward.h should be removed.
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
+
+// The namespace definition should change to the lldb_rpc namespace, so should 
the comment that closes it:
+// namespace lldb -> namespace lldb_rpc
+namespace lldb {} // namespace lldb
+
+// The comment that closes the include guard must change in the same way
+// the original guard did:
+// #endif // LLDB_LLDB_TYPES_H -> #endif // LLDB_RPC_TYPES_H
+#endif // LLDB_LLDB_TYPES_H
diff --git 
a/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckLLDBDefines.test
 
b/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckLLDBDefines.test
new file mode 100644
index 0000000000000..2f96e4a94bd0c
--- /dev/null
+++ 
b/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckLLDBDefines.test
@@ -0,0 +1,9 @@
+RUN: mkdir -p %t/Outputs
+
+RUN: %python %p/../../../../../scripts/framework-header-include-fix.py 
%p/Inputs/lldb-rpc-defines.h %t/Outputs/lldb-rpc-defines.h
+
+# Check the output
+RUN: cat %t/Outputs/lldb-rpc-defines.h | FileCheck %s
+
+# Local includes for LLDB RPC headers must be changed for the framework.
+CHECK: #include <LLDBRPC/lldb-rpc-types.h>
diff --git 
a/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckLLDBTypes.test 
b/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckLLDBTypes.test
new file mode 100644
index 0000000000000..2e623651ae357
--- /dev/null
+++ 
b/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckLLDBTypes.test
@@ -0,0 +1,9 @@
+RUN: mkdir -p %t/Outputs
+
+RUN: %python %p/../../../../../scripts/framework-header-include-fix.py 
%p/Inputs/lldb-rpc-types.h %t/Outputs/lldb-rpc-types.h
+
+# Check the output
+RUN: cat %t/Outputs/lldb-rpc-types.h | FileCheck %s
+
+# Local includes for LLDB RPC headers must be changed for the framework.
+CHECK: #include <LLDBRPC/lldb-rpc-enumerations.h>
diff --git 
a/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckSBClass.test 
b/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckSBClass.test
new file mode 100644
index 0000000000000..635ae158c9da8
--- /dev/null
+++ 
b/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckSBClass.test
@@ -0,0 +1,10 @@
+RUN: mkdir -p %t/Outputs
+
+RUN: %python %p/../../../../../scripts/framework-header-include-fix.py 
%p/Inputs/SBRPC-FrameworkFix.h %t/Outputs/SBRPC-FrameworkFix.h
+
+# Check the output
+RUN: cat %t/Outputs/SBRPC-FrameworkFix.h | FileCheck %s
+
+CHECK: #include <LLDBRPC/RPCPublic.h>
+CHECK: #include <LLDBRPC/SBDefines.h>
+CHECK: #include <LLDBRPC/LLDBRPC.h>
diff --git 
a/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckSBDefines.test 
b/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckSBDefines.test
new file mode 100644
index 0000000000000..bece852d813fa
--- /dev/null
+++ 
b/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckSBDefines.test
@@ -0,0 +1,12 @@
+RUN: mkdir -p %t/Outputs
+
+# Run the framework header fix script on SBDefines.h.
+RUN: %python %p/../../../../../scripts/framework-header-include-fix.py 
%p/Inputs/SBDefines.h %t/Outputs/SBDefines.h
+
+# Check the output.
+RUN: cat %t/Outputs/SBDefines.h | FileCheck %s
+
+# Local includes for LLDB RPC headers must be changed for the framework.
+CHECK: #include <LLDBRPC/lldb-rpc-defines.h>
+CHECK: #include <LLDBRPC/lldb-rpc-enumerations.h>
+CHECK: #include <LLDBRPC/lldb-rpc-types.h>
diff --git 
a/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/SBDefines.h 
b/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/SBDefines.h
new file mode 100644
index 0000000000000..a601e0230fb10
--- /dev/null
+++ 
b/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/SBDefines.h
@@ -0,0 +1,9 @@
+// This is a truncated version of SBDefines.h used to test that the script
+// framework-header-include-fix.py works correctly. The script fixes up header 
files
+// to be used in LLDBRPC.framework.
+
+// Local includes of RPC main header files must be changed to framework 
includes:
+// #include "lldb-rpc-defines.h" -> #include <LLDBRPC/lldb-rpc-defines.h>
+#include "lldb-rpc-defines.h"
+#include "lldb-rpc-enumerations.h"
+#include "lldb-rpc-types.h"
diff --git 
a/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/SBRPC-FrameworkFix.h
 
b/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/SBRPC-FrameworkFix.h
new file mode 100644
index 0000000000000..182a106f08cec
--- /dev/null
+++ 
b/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/SBRPC-FrameworkFix.h
@@ -0,0 +1,10 @@
+// This is a truncated version of a generated SB API header file used to test 
that the script
+// framework-header-include-fix.py works correctly. The script fixes up header 
files
+// to be used in LLDBRPC.framework.
+
+// Local includes of RPC main header and includes of RPC common files must be 
changed to framework includes:
+// #include "SBDefines.h" -> #include <LLDBRPC/SBDefines.h>
+// #include <lldb-rpc/common/RPCPublic.h> -> #include <LLDBRPC/RPCPublic.h>
+#include "LLDBRPC.h"
+#include "SBDefines.h"
+#include <lldb-rpc/common/RPCPublic.h>
diff --git 
a/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/lldb-rpc-defines.h
 
b/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/lldb-rpc-defines.h
new file mode 100644
index 0000000000000..723078c5c57fd
--- /dev/null
+++ 
b/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/lldb-rpc-defines.h
@@ -0,0 +1,7 @@
+// This is a truncated version of lldb-rpc-defines.h used to test that the 
script
+// framework-header-include-fix.py works correctly. The script fixes up header 
files
+// to be used in LLDBRPC.framework.
+
+// Includes of public main LLDB headers should change to their RPC equivalents:
+// #include "lldb-rpc-types.h" -> #include <LLDBRPC/lldb-rpc-types.h>
+#include "lldb-rpc-types.h"
diff --git 
a/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/lldb-rpc-types.h
 
b/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/lldb-rpc-types.h
new file mode 100644
index 0000000000000..e578031c0dc09
--- /dev/null
+++ 
b/lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/lldb-rpc-types.h
@@ -0,0 +1,7 @@
+// This is a truncated version of lldb-rpc-types.h used to test that the script
+// framework-header-include-fix.py works correctly. The script fixes up header 
files
+// to be used in LLDBRPC.framework.
+
+// Local includes of RPC main header files must be changed to framework 
includes:
+// #include "lldb-rpc-enumerations.h" -> #include 
<LLDBRPC/lldb-rpc-enumerations.h>
+#include "lldb/lldb-rpc-enumerations.h"

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to