public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: make gdbarch.sh write gdbarch.{c,h} directly
@ 2020-05-11 21:18 Simon Marchi
  2020-05-12 20:56 ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2020-05-11 21:18 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

It was suggested in this thread [1] that gdbarch.sh should write to
gdbarch.h and gdbarch.c directly.  This patch implements that.

When running gdbarch.sh, we currently need to move new-gdbarch.c over
gdbarch.c and new-gdbarch.h over gdbarch.h.  It might have been useful
at some point to not have gdbarch.sh overwrite gdbarch.h and gdbarch.c,
but with git it's really unnecessary.  Any changes to gdbarch.sh can be
inspected using `git diff`.

A next step would be to have the Makefile automatically run gdbarch.sh
if it sees that gdbarch.c and gdbarch.h are out of date.  Or maybe even
remove gdbarch.c and gdbarch.h from the tree and generate them in the
build directory when building.  But that requires more thinking and
discussions, and I think that this change is already useful in itself.

[1] https://sourceware.org/pipermail/gdb-patches/2020-May/168265.html

gdb/ChangeLog;

	* gdbarch.sh: Write to gdbarch.c/gdbarch.h directly.  Don't
	compare old and new versions.
	(compare_new): Remove.
---
 gdb/gdbarch.c  | 12 +-----------
 gdb/gdbarch.h  | 12 +-----------
 gdb/gdbarch.sh | 39 ++++++---------------------------------
 3 files changed, 8 insertions(+), 55 deletions(-)

diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index e7d4ccca9e7d..55e4a67e2c5a 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -20,17 +20,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-/* This file was created with the aid of ``gdbarch.sh''.
-
-   The Bourne shell script ``gdbarch.sh'' creates the files
-   ``new-gdbarch.c'' and ``new-gdbarch.h and then compares them
-   against the existing ``gdbarch.[hc]''.  Any differences found
-   being reported.
-
-   If editing this file, please also run gdbarch.sh and merge any
-   changes into that script. Conversely, when making sweeping changes
-   to this file, modifying gdbarch.sh and using its output may prove
-   easier.  */
+/* This file was created with the aid of ``gdbarch.sh''.  */
 
 
 #include "defs.h"
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 6dbb9d571ddb..c7621f2fda14 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -20,17 +20,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-/* This file was created with the aid of ``gdbarch.sh''.
-
-   The Bourne shell script ``gdbarch.sh'' creates the files
-   ``new-gdbarch.c'' and ``new-gdbarch.h and then compares them
-   against the existing ``gdbarch.[hc]''.  Any differences found
-   being reported.
-
-   If editing this file, please also run gdbarch.sh and merge any
-   changes into that script. Conversely, when making sweeping changes
-   to this file, modifying gdbarch.sh and using its output may prove
-   easier.  */
+/* This file was created with the aid of ``gdbarch.sh''.  */
 
 #ifndef GDBARCH_H
 #define GDBARCH_H
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 13775078c25a..e297b1c56a09 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -24,22 +24,6 @@
 LANG=C ; export LANG
 LC_ALL=C ; export LC_ALL
 
-
-compare_new ()
-{
-    file=$1
-    if test ! -r "${file}"
-    then
-	echo "${file} missing? cp new-${file} ${file}" 1>&2
-    elif diff -u "${file}" "new-${file}"
-    then
-	echo "${file} unchanged" 1>&2
-    else
-	echo "${file} has changed? cp new-${file} ${file}" 1>&2
-    fi
-}
-
-
 # Format of the input table
 read="class returntype function formal actual staticdefault predefault postdefault invalid_p print garbage_at_eol"
 
@@ -1203,7 +1187,7 @@ EOF
 #
 # The .log file
 #
-exec > new-gdbarch.log
+exec > gdbarch.log
 function_list | while do_read
 do
     cat <<EOF
@@ -1239,7 +1223,6 @@ EOF
 done
 
 exec 1>&2
-compare_new gdbarch.log
 
 
 copyright ()
@@ -1267,17 +1250,7 @@ cat <<EOF
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-/* This file was created with the aid of \`\`gdbarch.sh''.
-
-   The Bourne shell script \`\`gdbarch.sh'' creates the files
-   \`\`new-gdbarch.c'' and \`\`new-gdbarch.h and then compares them
-   against the existing \`\`gdbarch.[hc]''.  Any differences found
-   being reported.
-
-   If editing this file, please also run gdbarch.sh and merge any
-   changes into that script. Conversely, when making sweeping changes
-   to this file, modifying gdbarch.sh and using its output may prove
-   easier.  */
+/* This file was created with the aid of \`\`gdbarch.sh''.  */
 
 EOF
 }
@@ -1695,8 +1668,8 @@ gdbarch_num_cooked_regs (gdbarch *arch)
 #endif
 EOF
 exec 1>&2
-#../move-if-change new-gdbarch.h gdbarch.h
-compare_new gdbarch.h
+../move-if-change new-gdbarch.h gdbarch.h
+rm -f new-gdbarch.h
 
 
 #
@@ -2605,5 +2578,5 @@ EOF
 
 # close things off
 exec 1>&2
-#../move-if-change new-gdbarch.c gdbarch.c
-compare_new gdbarch.c
+../move-if-change new-gdbarch.c gdbarch.c
+rm -f new-gdbarch.c
-- 
2.26.2


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

* Re: [PATCH] gdb: make gdbarch.sh write gdbarch.{c,h} directly
  2020-05-11 21:18 [PATCH] gdb: make gdbarch.sh write gdbarch.{c,h} directly Simon Marchi
@ 2020-05-12 20:56 ` Tom Tromey
  2020-05-12 21:16   ` Simon Marchi
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2020-05-12 20:56 UTC (permalink / raw)
  To: Simon Marchi via Gdb-patches; +Cc: Simon Marchi

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

Simon> It was suggested in this thread [1] that gdbarch.sh should write to
Simon> gdbarch.h and gdbarch.c directly.  This patch implements that.

Simon> When running gdbarch.sh, we currently need to move new-gdbarch.c over
Simon> gdbarch.c and new-gdbarch.h over gdbarch.h.  It might have been useful
Simon> at some point to not have gdbarch.sh overwrite gdbarch.h and gdbarch.c,
Simon> but with git it's really unnecessary.  Any changes to gdbarch.sh can be
Simon> inspected using `git diff`.

This is a nice improvement, thanks.

Tom

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

* Re: [PATCH] gdb: make gdbarch.sh write gdbarch.{c,h} directly
  2020-05-12 20:56 ` Tom Tromey
@ 2020-05-12 21:16   ` Simon Marchi
  2020-05-24 15:12     ` Simon Marchi
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2020-05-12 21:16 UTC (permalink / raw)
  To: Tom Tromey, Simon Marchi via Gdb-patches; +Cc: Simon Marchi

On 2020-05-12 4:56 p.m., Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Simon> It was suggested in this thread [1] that gdbarch.sh should write to
> Simon> gdbarch.h and gdbarch.c directly.  This patch implements that.
> 
> Simon> When running gdbarch.sh, we currently need to move new-gdbarch.c over
> Simon> gdbarch.c and new-gdbarch.h over gdbarch.h.  It might have been useful
> Simon> at some point to not have gdbarch.sh overwrite gdbarch.h and gdbarch.c,
> Simon> but with git it's really unnecessary.  Any changes to gdbarch.sh can be
> Simon> inspected using `git diff`.
> 
> This is a nice improvement, thanks.
> 
> Tom
> 

Thanks, I'll wait for more input for the community before pushing, in case somebody
has an objection.

Simon

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

* Re: [PATCH] gdb: make gdbarch.sh write gdbarch.{c,h} directly
  2020-05-12 21:16   ` Simon Marchi
@ 2020-05-24 15:12     ` Simon Marchi
  2020-05-24 15:39       ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2020-05-24 15:12 UTC (permalink / raw)
  To: Tom Tromey, Simon Marchi via Gdb-patches; +Cc: Simon Marchi

On 2020-05-12 5:16 p.m., Simon Marchi wrote:
> On 2020-05-12 4:56 p.m., Tom Tromey wrote:
>>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
>>
>> Simon> It was suggested in this thread [1] that gdbarch.sh should write to
>> Simon> gdbarch.h and gdbarch.c directly.  This patch implements that.
>>
>> Simon> When running gdbarch.sh, we currently need to move new-gdbarch.c over
>> Simon> gdbarch.c and new-gdbarch.h over gdbarch.h.  It might have been useful
>> Simon> at some point to not have gdbarch.sh overwrite gdbarch.h and gdbarch.c,
>> Simon> but with git it's really unnecessary.  Any changes to gdbarch.sh can be
>> Simon> inspected using `git diff`.
>>
>> This is a nice improvement, thanks.
>>
>> Tom
>>
> 
> Thanks, I'll wait for more input for the community before pushing, in case somebody
> has an objection.
> 
> Simon
> 

I pushed this patch.

Simon

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

* Re: [PATCH] gdb: make gdbarch.sh write gdbarch.{c,h} directly
  2020-05-24 15:12     ` Simon Marchi
@ 2020-05-24 15:39       ` Pedro Alves
  0 siblings, 0 replies; 5+ messages in thread
From: Pedro Alves @ 2020-05-24 15:39 UTC (permalink / raw)
  To: Simon Marchi, Tom Tromey, Simon Marchi via Gdb-patches; +Cc: Simon Marchi

On 5/24/20 4:12 PM, Simon Marchi wrote:
> On 2020-05-12 5:16 p.m., Simon Marchi wrote:

>> Thanks, I'll wait for more input for the community before pushing, in case somebody
>> has an objection.
>>
> 
> I pushed this patch.
> 

Thanks for doing this.

Pedro Alves


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

end of thread, other threads:[~2020-05-24 15:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-11 21:18 [PATCH] gdb: make gdbarch.sh write gdbarch.{c,h} directly Simon Marchi
2020-05-12 20:56 ` Tom Tromey
2020-05-12 21:16   ` Simon Marchi
2020-05-24 15:12     ` Simon Marchi
2020-05-24 15:39       ` Pedro Alves

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).