Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Alan Hayward <Alan.Hayward@arm.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: nd <nd@arm.com>, Alan Hayward <Alan.Hayward@arm.com>
Subject: [PATCH] Testsuite: Ensure changing directory does not break the log file
Date: Thu, 21 Feb 2019 10:34:00 -0000	[thread overview]
Message-ID: <20190221103420.18162-1-alan.hayward@arm.com> (raw)

get_compiler_info switches to a new log file before checking the compiler
to ensure the checks are not logged. Afterwards it restores back to using
the original log file. However, the logfile uses a relative path name -
if the current test has changed the current directory then all further
output for the test will be lost.  This can confuse the code that collates
the main gdb.log file at the end of a FORCE_PARALLEL run.

fullpath-expand.exp calls gdb_compile after changing the current directory.

The "Ensure stack protection is off for GCC" patch added a call to
get_compiler_info from inside of gdb_compile, causing log file collection
to break for FORCE_PARALLEL runs.

The ideal solution would be to ensure the log file is always created using
an absolute path name. However, this is set at multiple points in
Makefile.in and in some instances just relies on dejagnu common code to set
the log file directory to "."

The simpler and safer solution is to override the builtin cd function. The
new function checks the current log file and if the path is relative, then
it resets the logging using an absolute path. Finally it calls the builtin
cd.  This ensures get_compiler_info (and any other code) can correctly
backup and restore the current log file.

Tested with make check and native-gdbserver.

gdb/testsuite/ChangeLog:

2019-02-21  Alan Hayward  <alan.hayward@arm.com>

	* lib/gdb.exp (builtin_cd): rename of cd.
	(cd): Override builtin.
---
 gdb/testsuite/lib/gdb.exp | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index d05854329d..17e437956d 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -6284,5 +6284,24 @@ proc gdb_define_cmd {command command_list} {
     }
 }
 
+# Safe version of cd that ensures the log file is not stopped.
+
+rename cd builtin_cd
+
+proc cd { dir } {
+    # Get logfile, which will be prefixed with "-a ".
+    set saved_log [log_file -info]
+
+    # If the logfile is a relative path, reset it to an absolute path.
+    if { [regexp "^-a \[^/\]" $saved_log match] } {
+	set saved_log [string replace $saved_log 0 2]
+	log_file
+	log_file -a "[pwd]/$saved_log"
+    }
+
+    # Call the builtin version of cd.
+    builtin_cd $dir
+}
+
 # Always load compatibility stuff.
 load_lib future.exp
-- 
2.17.2 (Apple Git-113)


             reply	other threads:[~2019-02-21 10:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21 10:34 Alan Hayward [this message]
2019-02-21 22:40 ` Tom Tromey
2019-02-22 12:36   ` Alan Hayward
2019-02-22 14:21     ` Pedro Alves
2019-02-22 17:10       ` Alan Hayward

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190221103420.18162-1-alan.hayward@arm.com \
    --to=alan.hayward@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=nd@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox