Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Doug Evans <xdje42@gmail.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [patch+7.7] Fix auto-load 7.7 regression (PR gdb/16626)
Date: Mon, 24 Feb 2014 09:04:00 -0000	[thread overview]
Message-ID: <20140224090356.GA17734@host2.jankratochvil.net> (raw)
In-Reply-To: <CAP9bCMRZYAzFvciG6kB0J_hKSMckJEZbQNVBuQmRoHeBWB6VEA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 773 bytes --]

On Mon, 24 Feb 2014 00:27:29 +0100, Doug Evans wrote:
> The .exp file is missing a test for native

Done.

> or a call to gdb_remote_download to download the script.

I am not sure how to derive there ${targetdir} from ${targetscript} (after
${targetscript} pathname transformatation by gdb_remote_download).

BTW I miss a setup for remote host in:
	https://sourceware.org/gdb/wiki/TestingGDB


> You might also want to add a test to verify gdb won't load the wrong
> file that it's trying to do now.

I do not see such test possible.  It now wrongly tries to load the script from
filename not using 'set auto-load scripts-directory'.  But such filename is
correct, it is tested first.  If such file exists it really should be loaded
first by the code above.


Thanks,
Jan

[-- Attachment #2: autoload.patch --]
[-- Type: text/plain, Size: 5019 bytes --]

gdb/
2014-02-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

	PR gdb/16626
	* auto-load.c (auto_load_objfile_script_1): Change filename to
	debugfile.

gdb/testsuite/
2014-02-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

	PR gdb/16626
	* gdb.base/auto-load-script: New file.
	* gdb.base/auto-load.c: New file.
	* gdb.base/auto-load.exp: New file.

diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 86d4e5e..1112ef2 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -778,17 +778,17 @@ auto_load_objfile_script_1 (struct objfile *objfile, const char *realname,
       make_cleanup_fclose (input);
 
       is_safe
-	= file_is_auto_load_safe (filename,
+	= file_is_auto_load_safe (debugfile,
 				  _("auto-load: Loading %s script \"%s\""
 				    " by extension for objfile \"%s\".\n"),
 				  ext_lang_name (language),
-				  filename, objfile_name (objfile));
+				  debugfile, objfile_name (objfile));
 
       /* Add this script to the hash table too so
 	 "info auto-load ${lang}-scripts" can print it.  */
       pspace_info
 	= get_auto_load_pspace_data_for_loading (current_program_space);
-      maybe_add_script (pspace_info, is_safe, filename, filename, language);
+      maybe_add_script (pspace_info, is_safe, debugfile, debugfile, language);
 
       /* To preserve existing behaviour we don't check for whether the
 	 script was already in the table, and always load it.
diff --git a/gdb/testsuite/gdb.base/auto-load-script b/gdb/testsuite/gdb.base/auto-load-script
new file mode 100644
index 0000000..d02bd1a
--- /dev/null
+++ b/gdb/testsuite/gdb.base/auto-load-script
@@ -0,0 +1,17 @@
+# Copyright 2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+echo script_loaded\n
+set $script_loaded=42
diff --git a/gdb/testsuite/gdb.base/auto-load.c b/gdb/testsuite/gdb.base/auto-load.c
new file mode 100644
index 0000000..4b94803
--- /dev/null
+++ b/gdb/testsuite/gdb.base/auto-load.c
@@ -0,0 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2014 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.base/auto-load.exp b/gdb/testsuite/gdb.base/auto-load.exp
new file mode 100644
index 0000000..226711f
--- /dev/null
+++ b/gdb/testsuite/gdb.base/auto-load.exp
@@ -0,0 +1,41 @@
+# Copyright 2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile
+
+if [is_remote host] {
+    return 0
+}
+
+set targetdir "${binfile}.dir"
+set sourcescript "${binfile}-script"
+set targetscriptdir "${targetdir}/[file dirname ${sourcescript}]"
+set targetscript "${targetscriptdir}/${testfile}-gdb.gdb"
+
+remote_exec host "rm -rf ${targetdir}"
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
+    return -1
+}
+
+remote_exec host "mkdir -p ${targetscriptdir}"
+remote_exec host "cp ${sourcescript} ${targetscript}"
+
+gdb_test_no_output "set auto-load scripts-directory ${targetdir}" "set auto-load scripts-directory"
+gdb_test_no_output "set auto-load safe-path ${targetscript}" "set auto-load safe-path"
+
+gdb_load ${binfile}
+
+gdb_test {print $script_loaded} " = 42"

  reply	other threads:[~2014-02-24  9:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-30  8:58 [commit 2/2] Move processing of .debug_gdb_scripts to auto-load.c Doug Evans
2014-02-23 21:24 ` [patch+7.7] Fix auto-load 7.7 regression [Re: [commit 2/2] Move processing of .debug_gdb_scripts to auto-load.c] Jan Kratochvil
2014-02-23 23:27   ` Doug Evans
2014-02-24  9:04     ` Jan Kratochvil [this message]
2014-02-25 17:41       ` [commit+7.7] [patch+7.7] Fix auto-load 7.7 regression (PR gdb/16626) Jan Kratochvil
2014-02-25 19:07         ` Tom Tromey
2014-02-25 19:50           ` [commit#2+7.7] " Jan Kratochvil

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=20140224090356.GA17734@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=xdje42@gmail.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