public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: remove trailing empty line in target-delegates.c
@ 2023-07-26 19:11 Simon Marchi
  2023-07-27 16:12 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2023-07-26 19:11 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

In a review [1], I pointed out that applying the patch, git would say:

    .git/rebase-apply/patch:147: new blank line at EOF.

However, since the empty line is in target-delegates.c (a generated
file), there's nothing the author can do about it.  To avoid this
comment coming up again in the future, change make-target-delegates.py
to avoid the trailing empty line.  Do this by making it output empty
lines before each entity, not after.

Since this needs removing a newline output in gdbcopyright, adjust
ada-unicode.py and gdbarch.py to avoid changes in the files they
generate.

[1] https://inbox.sourceware.org/gdb-patches/20230427210113.45380-1-jhb@FreeBSD.org/T/#m083598405bef19157f67c9d97846d3dd90dc7d1c

Change-Id: Ic4c648f06443b432168cb76603402c918aa6e5d2
---
 gdb/ada-unicode.py           |  1 +
 gdb/gdbarch.py               |  2 ++
 gdb/gdbcopyright.py          |  3 +--
 gdb/make-target-delegates.py | 12 ++++++++----
 gdb/target-delegates.c       |  1 -
 5 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/gdb/ada-unicode.py b/gdb/ada-unicode.py
index 86685a258740..fe5be561aa2a 100755
--- a/gdb/ada-unicode.py
+++ b/gdb/ada-unicode.py
@@ -91,5 +91,6 @@ with open("ada-casefold.h", "w") as f:
         gdbcopyright.copyright("ada-unicode.py", "UTF-32 case-folding for GDB"),
         file=f,
     )
+    print("", file=f)
     for r in all_ranges:
         print(f"   {{{r[0]}, {r[1]}, {r[2]}, {r[3]}}},", file=f)
diff --git a/gdb/gdbarch.py b/gdb/gdbarch.py
index 62592c1b13ee..d776707032b1 100755
--- a/gdb/gdbarch.py
+++ b/gdb/gdbarch.py
@@ -52,6 +52,7 @@ with open("gdbarch-gen.h", "w") as f:
     print(copyright, file=f)
     print(file=f)
     print(file=f)
+    print(file=f)
     print("/* The following are pre-initialized by GDBARCH.  */", file=f)
 
     # Do Info components first.
@@ -121,6 +122,7 @@ with open("gdbarch-gen.h", "w") as f:
 with open("gdbarch.c", "w") as f:
     print(copyright, file=f)
     print(file=f)
+    print(file=f)
     print("/* Maintain the struct gdbarch object.  */", file=f)
     print(file=f)
     #
diff --git a/gdb/gdbcopyright.py b/gdb/gdbcopyright.py
index 4e27356556b5..ae4f6d6a118f 100644
--- a/gdb/gdbcopyright.py
+++ b/gdb/gdbcopyright.py
@@ -49,5 +49,4 @@ def copyright(tool: str, description: str):
 
 /* To regenerate this file, run:
    ./{tool}
-*/
-"""
+*/"""
diff --git a/gdb/make-target-delegates.py b/gdb/make-target-delegates.py
index c8e5a94b5f93..704d3f1cb67a 100755
--- a/gdb/make-target-delegates.py
+++ b/gdb/make-target-delegates.py
@@ -199,6 +199,7 @@ def write_declaration(f: TextIO, name: str, return_type: str, argtypes: List[str
 
 # Write out a delegation function.
 def write_delegator(f: TextIO, name: str, return_type: str, argtypes: List[str]):
+    print("", file=f)
     names = write_function_header(
         f, False, "target_ops::" + name, return_type, argtypes
     )
@@ -208,7 +209,7 @@ def write_delegator(f: TextIO, name: str, return_type: str, argtypes: List[str])
     print("this->beneath ()->" + name + " (", file=f, end="")
     print(", ".join(names), file=f, end="")
     print(");", file=f)
-    print("}\n", file=f)
+    print("}", file=f)
 
 
 # Write out a default function.
@@ -220,6 +221,7 @@ def write_tdefault(
     return_type: str,
     argtypes: List[str],
 ):
+    print("", file=f)
     name = "dummy_target::" + name
     names = write_function_header(f, False, name, return_type, argtypes)
     if style == "FUNC":
@@ -238,7 +240,7 @@ def write_tdefault(
         pass
     else:
         raise RuntimeError("unrecognized style: " + style)
-    print("}\n", file=f)
+    print("}", file=f)
 
 
 def munge_type(typename: str):
@@ -263,6 +265,7 @@ def munge_type(typename: str):
 def write_debugmethod(
     f: TextIO, content: str, name: str, return_type: str, argtypes: List[str]
 ):
+    print("", file=f)
     debugname = "debug_target::" + name
     names = write_function_header(f, False, debugname, return_type, argtypes)
     if return_type != "void":
@@ -305,7 +308,7 @@ def write_debugmethod(
     if return_type != "void":
         print("  return result;", file=f)
 
-    print("}\n", file=f)
+    print("}", file=f)
 
 
 def print_class(
@@ -314,6 +317,7 @@ def print_class(
     delegators: List[str],
     entries: Dict[str, Entry],
 ):
+    print("", file=f)
     print("struct " + class_name + " : public target_ops", file=f)
     print("{", file=f)
     print("  const target_info &info () const override;", file=f)
@@ -326,7 +330,7 @@ def print_class(
         entry = entries[name]
         write_declaration(f, name, entry.return_type, entry.argtypes)
 
-    print("};\n", file=f)
+    print("};", file=f)
 
 
 delegators: List[str] = []
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 57b66ce87b1e..e4e14380181b 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -4535,4 +4535,3 @@ debug_target::store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector
   gdb_puts ("\n", gdb_stdlog);
   return result;
 }
-

base-commit: 9d1e07bd19fb126edf5ac8bb098777bee9364ca5
-- 
2.41.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb: remove trailing empty line in target-delegates.c
  2023-07-26 19:11 [PATCH] gdb: remove trailing empty line in target-delegates.c Simon Marchi
@ 2023-07-27 16:12 ` Tom Tromey
  2023-07-27 17:33   ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2023-07-27 16:12 UTC (permalink / raw)
  To: Simon Marchi via Gdb-patches; +Cc: Simon Marchi

>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:

Simon> In a review [1], I pointed out that applying the patch, git would say:
Simon>     .git/rebase-apply/patch:147: new blank line at EOF.

Simon> However, since the empty line is in target-delegates.c (a generated
Simon> file), there's nothing the author can do about it.  To avoid this
Simon> comment coming up again in the future, change make-target-delegates.py
Simon> to avoid the trailing empty line.  Do this by making it output empty
Simon> lines before each entity, not after.

Simon> Since this needs removing a newline output in gdbcopyright, adjust
Simon> ada-unicode.py and gdbarch.py to avoid changes in the files they
Simon> generate.

Seems totally fine to me, thank you.

Approved-By: Tom Tromey <tom@tromey.com>


Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb: remove trailing empty line in target-delegates.c
  2023-07-27 16:12 ` Tom Tromey
@ 2023-07-27 17:33   ` Simon Marchi
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2023-07-27 17:33 UTC (permalink / raw)
  To: Tom Tromey, Simon Marchi via Gdb-patches; +Cc: Simon Marchi



On 2023-07-27 12:12, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Simon> In a review [1], I pointed out that applying the patch, git would say:
> Simon>     .git/rebase-apply/patch:147: new blank line at EOF.
> 
> Simon> However, since the empty line is in target-delegates.c (a generated
> Simon> file), there's nothing the author can do about it.  To avoid this
> Simon> comment coming up again in the future, change make-target-delegates.py
> Simon> to avoid the trailing empty line.  Do this by making it output empty
> Simon> lines before each entity, not after.
> 
> Simon> Since this needs removing a newline output in gdbcopyright, adjust
> Simon> ada-unicode.py and gdbarch.py to avoid changes in the files they
> Simon> generate.
> 
> Seems totally fine to me, thank you.
> 
> Approved-By: Tom Tromey <tom@tromey.com>
> 
> 
> Tom

Thanks, pushed.

Simon

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-27 17:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-26 19:11 [PATCH] gdb: remove trailing empty line in target-delegates.c Simon Marchi
2023-07-27 16:12 ` Tom Tromey
2023-07-27 17:33   ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).