[Lldb-commits] [lldb] [lldb][bytecode] Document invocation in compiler output (PR #187547)
Dave Lee via lldb-commits
lldb-commits at lists.llvm.org
Thu Mar 19 14:49:12 PDT 2026
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/187547
>From c7eddb3534459aec586b1a04e6a9dc0279d4ec45 Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee.com at gmail.com>
Date: Thu, 19 Mar 2026 10:55:48 -0700
Subject: [PATCH 1/2] [lldb][bytecode] Document invocation in compiler output
---
lldb/examples/python/formatter_bytecode.py | 3 +++
.../Inputs/FormatterBytecode/RigidArrayLLDBFormatterC.txt | 2 ++
.../Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt | 2 ++
3 files changed, 7 insertions(+)
diff --git a/lldb/examples/python/formatter_bytecode.py b/lldb/examples/python/formatter_bytecode.py
index 1daf2366ca3e9..38034c70ea265 100644
--- a/lldb/examples/python/formatter_bytecode.py
+++ b/lldb/examples/python/formatter_bytecode.py
@@ -19,6 +19,7 @@
import io
import ast
import enum
+import shlex
import textwrap
from copy import copy
from dataclasses import dataclass
@@ -1179,6 +1180,8 @@ def _main():
section.write_binary(output)
else:
with open(args.output, "w") as output:
+ print("// Generated with:", file=output)
+ print("// ", shlex.join(sys.argv), file=output)
section.write_source(output, language=args.format)
elif args.assemble:
if not args.type_name:
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterC.txt b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterC.txt
index 35c3d08baa458..7356809ed1eb4 100644
--- a/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterC.txt
+++ b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterC.txt
@@ -1,3 +1,5 @@
+// Generated with:
+// examples/python/formatter_bytecode.py --compile test/Shell/ScriptInterpreter/Python/python-bytecode.test --format c --type-name RigidArray --output test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterC.txt
#ifdef __APPLE__
#define FORMATTER_SECTION "__DATA_CONST,__lldbformatters"
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt
index 2041be819d82e..d63ee1f2836a1 100644
--- a/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt
+++ b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt
@@ -1,3 +1,5 @@
+// Generated with:
+// examples/python/formatter_bytecode.py --compile test/Shell/ScriptInterpreter/Python/python-bytecode.test --format swift --type-name RigidArray --output test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt
#if swift(>=6.3)
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS)
@section("__DATA_CONST,__lldbformatters")
>From fc454caf5bbfff0c97854afa904a0b501117e610 Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee.com at gmail.com>
Date: Thu, 19 Mar 2026 14:48:07 -0700
Subject: [PATCH 2/2] Skip invocation comment
---
lldb/examples/python/formatter_bytecode.py | 10 ++++++++--
.../FormatterBytecode/RigidArrayLLDBFormatterC.txt | 2 --
.../FormatterBytecode/RigidArrayLLDBFormatterSwift.txt | 2 --
.../ScriptInterpreter/Python/python-bytecode.test | 4 ++--
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/lldb/examples/python/formatter_bytecode.py b/lldb/examples/python/formatter_bytecode.py
index 38034c70ea265..b1f1d990847f5 100644
--- a/lldb/examples/python/formatter_bytecode.py
+++ b/lldb/examples/python/formatter_bytecode.py
@@ -1147,6 +1147,11 @@ def _main():
help="disassemble bytecode",
)
parser.add_argument("-n", "--type-name", help="source type of formatter")
+ parser.add_argument(
+ "--skip-invocation-comment",
+ action="store_true",
+ help="do not print invocation comment in compiled output",
+ )
parser.add_argument(
"-o",
"--output",
@@ -1180,8 +1185,9 @@ def _main():
section.write_binary(output)
else:
with open(args.output, "w") as output:
- print("// Generated with:", file=output)
- print("// ", shlex.join(sys.argv), file=output)
+ if not args.skip_invocation_comment:
+ print("// Generated with:", file=output)
+ print("// ", shlex.join(sys.argv), file=output)
section.write_source(output, language=args.format)
elif args.assemble:
if not args.type_name:
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterC.txt b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterC.txt
index 7356809ed1eb4..35c3d08baa458 100644
--- a/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterC.txt
+++ b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterC.txt
@@ -1,5 +1,3 @@
-// Generated with:
-// examples/python/formatter_bytecode.py --compile test/Shell/ScriptInterpreter/Python/python-bytecode.test --format c --type-name RigidArray --output test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterC.txt
#ifdef __APPLE__
#define FORMATTER_SECTION "__DATA_CONST,__lldbformatters"
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt
index d63ee1f2836a1..2041be819d82e 100644
--- a/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt
+++ b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt
@@ -1,5 +1,3 @@
-// Generated with:
-// examples/python/formatter_bytecode.py --compile test/Shell/ScriptInterpreter/Python/python-bytecode.test --format swift --type-name RigidArray --output test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt
#if swift(>=6.3)
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS)
@section("__DATA_CONST,__lldbformatters")
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/python-bytecode.test b/lldb/test/Shell/ScriptInterpreter/Python/python-bytecode.test
index 82b5ac19bd6db..b6bc46ccc0ab5 100644
--- a/lldb/test/Shell/ScriptInterpreter/Python/python-bytecode.test
+++ b/lldb/test/Shell/ScriptInterpreter/Python/python-bytecode.test
@@ -1,6 +1,6 @@
# RUN: mkdir -p %t
-# RUN: %python %S/../../../../examples/python/formatter_bytecode.py --compile %s --format c --type-name RigidArray --output %t/c-output.txt
-# RUN: %python %S/../../../../examples/python/formatter_bytecode.py --compile %s --format swift --type-name RigidArray --output %t/swift-output.txt
+# RUN: %python %S/../../../../examples/python/formatter_bytecode.py --compile %s --format c --type-name RigidArray --output %t/c-output.txt --skip-invocation-comment
+# RUN: %python %S/../../../../examples/python/formatter_bytecode.py --compile %s --format swift --type-name RigidArray --output %t/swift-output.txt --skip-invocation-comment
# RUN: diff -u --strip-trailing-cr %S/Inputs/FormatterBytecode/RigidArrayLLDBFormatterC.txt %t/c-output.txt
# RUN: diff -u --strip-trailing-cr %S/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt %t/swift-output.txt
import lldb
More information about the lldb-commits
mailing list