public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Have regdat.sh always rewrite the output register file
@ 2014-01-10  3:56 Patrick Palka
  2014-01-13 19:52 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Palka @ 2014-01-10  3:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Patrick Palka

The rules for generating the output register files look like:

amd64.c : $(srcdir)/../regformats/i386/amd64.dat $(regdat_sh)
	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/i386/amd64.dat amd64.c

According to this rule, if regdat.sh is newer than amd64.c, then
regdat.sh shall be invoked on amd64.dat.  According to regdat.sh, if the
script determines that the output file amd64.c has not changed, then it
will not overwrite the existing output file.  This means that a
subsequent invocation of make will trigger the above rule again as
regdat.sh will be perpetually newer than amd64.c.

This then shows up in the make output like so:

/bin/bash ./../regformats/regdat.sh ./../regformats/i386/amd64-linux.dat amd64-linux.c
amd64-linux.c unchanged.
/bin/bash ./../regformats/regdat.sh ./../regformats/i386/amd64-avx-linux.dat amd64-avx-linux.c
amd64-avx-linux.c unchanged.
...

To fix this pathological behavior, it suffices to have regdat.sh
unconditionally rewrite the output register file.

On my machine, which has a regdat.sh file that is newer than some of the
input register files, this change speeds up every invocation of make
under gdb/ by about 5 seconds.
---
 gdb/ChangeLog            |  4 ++++
 gdb/regformats/regdat.sh | 14 +-------------
 2 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e878efa..cdd6616 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2014-01-10  Patrick Palka  <patrick@parcs.ath.cx>
+
+	* regformats/regdat.sh: Always rewrite the register file.
+
 2014-01-02  Patrick Palka  <patrick@parcs.ath.cx>
 
 	PR gdb/16120
diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh
index 0cf4588..fabc910 100755
--- a/gdb/regformats/regdat.sh
+++ b/gdb/regformats/regdat.sh
@@ -18,18 +18,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-move_if_change ()
-{
-    file=$1
-    if test -r ${file} && cmp -s "${file}" new-"${file}"
-    then
-	echo "${file} unchanged." 1>&2
-    else
-	mv new-"${file}" "${file}"
-	echo "${file} updated." 1>&2
-    fi
-}
-
 # Format of the input files
 read="type entry"
 
@@ -202,4 +190,4 @@ EOF
 
 # close things off
 exec 1>&2
-move_if_change $2
+mv -- "new-$2" "$2"
-- 
1.8.5.2

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

* Re: [PATCH] Have regdat.sh always rewrite the output register file
  2014-01-10  3:56 [PATCH] Have regdat.sh always rewrite the output register file Patrick Palka
@ 2014-01-13 19:52 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2014-01-13 19:52 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gdb-patches

>>>>> "Patrick" == Patrick Palka <patrick@parcs.ath.cx> writes:

Patrick> +2014-01-10  Patrick Palka  <patrick@parcs.ath.cx>
Patrick> +
Patrick> +	* regformats/regdat.sh: Always rewrite the register file.
Patrick> +

This is ok.  I'll push it momentarily.

Do you have a copyright assignment in place?
I think this particular patch falls under the limit, following the "one
way to write it" rule; but if you don't have an assignment, it would be
good to get one for future patches.  Contact me off-list if you need this.

Tom

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

end of thread, other threads:[~2014-01-13 19:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-10  3:56 [PATCH] Have regdat.sh always rewrite the output register file Patrick Palka
2014-01-13 19:52 ` Tom Tromey

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