public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/2] Fix solib-display.exp remote check
  2016-05-02 18:18 [PATCH 1/2] Introduce procedure use_gdb_stub Simon Marchi
@ 2016-05-02 18:18 ` Simon Marchi
  2016-05-02 18:30   ` Pedro Alves
  2016-05-02 18:28 ` [PATCH 1/2] Introduce procedure use_gdb_stub Pedro Alves
  1 sibling, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2016-05-02 18:18 UTC (permalink / raw)
  To: gdb-patches

From: Simon Marchi <simon dot marchi at polymtl dot ca>

This test currently uses [is_remote target] to check if the test is
supported.  This is not quite correct, as the limitation is actually
that it requires support for "running", ruling out stub-like targets.
Therefore, it should check for use_gdb_stub.

This has no visible effect right now, but it will once we make the
native-gdbserver board non-dejagnu-remote.

gdb/testsuite/ChangeLog:

	* gdb.base/solib-display.exp: Check for [use_gdb_stub] instead
	of [is_remote target],
---
 gdb/testsuite/gdb.base/solib-display.exp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/solib-display.exp b/gdb/testsuite/gdb.base/solib-display.exp
index 7f65617..e8ab330 100644
--- a/gdb/testsuite/gdb.base/solib-display.exp
+++ b/gdb/testsuite/gdb.base/solib-display.exp
@@ -28,7 +28,13 @@
 # (and thus aren't affected by shared library unloading) are not
 # disabled prematurely.
 
-if { [skip_shlib_tests] || [is_remote target] } {
+if { [skip_shlib_tests] } {
+    return 0
+}
+
+# This test currently requires "run", so it's pointless to test on stub targets.
+
+if { [use_gdb_stub] } {
     return 0
 }
 
-- 
2.8.2

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

* [PATCH 1/2] Introduce procedure use_gdb_stub
@ 2016-05-02 18:18 Simon Marchi
  2016-05-02 18:18 ` [PATCH 2/2] Fix solib-display.exp remote check Simon Marchi
  2016-05-02 18:28 ` [PATCH 1/2] Introduce procedure use_gdb_stub Pedro Alves
  0 siblings, 2 replies; 5+ messages in thread
From: Simon Marchi @ 2016-05-02 18:18 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

This patch introduces the use_gdb_stub procedure, which allows getting
the right value of the use_gdb_stub variable/property in any all
situations.

When calling it before the $use_gdb_stub global variable has been set,
it will return the value of the use_gdb_stub property from the board
file.  This happens when tests want to bail out early (even before gdb
has been started) when the current test setup is a stub.

Otherwise, it returns the value of the $use_gdb_stub global.

It's possible for these two to differ when a test file overrides the
value of the global.

gdb/testsuite/ChangeLog:

	* lib/gdb.exp (use_gdb_stub): New procedure.
---
 gdb/testsuite/lib/gdb.exp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 5a5a8fb..6d25b0c 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3053,6 +3053,26 @@ proc gdb_is_target_remote {} {
     return [gdb_is_target_remote_prompt "$gdb_prompt $"]
 }
 
+# Return the effective value of use_gdb_stub.
+#
+# If the use_gdb_stub global has been set (it is set when the gdb process is
+# spawned), return that.  Otherwise, return the value of the use_gdb_stub
+# property from the board file.
+#
+# This is the preferred way of checking use_gdb_stub, since it allows to check
+# the value before the gdb has been spawned and it will return the correct value
+# even when it was overriden by the test.
+
+proc use_gdb_stub {} {
+  global use_gdb_stub
+
+  if [info exists use_gdb_stub] {
+     return $use_gdb_stub
+  }
+
+  return [target_info exists use_gdb_stub]
+}
+
 # Return 1 if the current remote target is an instance of our GDBserver, 0
 # otherwise.  Return -1 if there was an error and we can't tell.
 
-- 
2.8.2

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

* Re: [PATCH 1/2] Introduce procedure use_gdb_stub
  2016-05-02 18:18 [PATCH 1/2] Introduce procedure use_gdb_stub Simon Marchi
  2016-05-02 18:18 ` [PATCH 2/2] Fix solib-display.exp remote check Simon Marchi
@ 2016-05-02 18:28 ` Pedro Alves
  1 sibling, 0 replies; 5+ messages in thread
From: Pedro Alves @ 2016-05-02 18:28 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

OK.

Thanks,
Pedro Alves

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

* Re: [PATCH 2/2] Fix solib-display.exp remote check
  2016-05-02 18:18 ` [PATCH 2/2] Fix solib-display.exp remote check Simon Marchi
@ 2016-05-02 18:30   ` Pedro Alves
  2016-05-04 13:37     ` Simon Marchi
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2016-05-02 18:30 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

OK.

As mentioned in the other thread, I think it'd be nice to add
bits of the info you found about why "run" is required.
Thanks,
Pedro Alves

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

* Re: [PATCH 2/2] Fix solib-display.exp remote check
  2016-05-02 18:30   ` Pedro Alves
@ 2016-05-04 13:37     ` Simon Marchi
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Marchi @ 2016-05-04 13:37 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches

On 16-05-02 02:30 PM, Pedro Alves wrote:
> OK.
> 
> As mentioned in the other thread, I think it'd be nice to add
> bits of the info you found about why "run" is required.
> Thanks,
> Pedro Alves

Ok, I pushed both patches, with the comment added in this one:


From 02e370d94ee3abc6f910602e79c6d4515d9c720d Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@ericsson.com>
Date: Wed, 4 May 2016 09:27:34 -0400
Subject: [PATCH] Fix solib-display.exp remote check
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This test currently uses [is_remote target] to check if the test is
supported.  This is not quite correct, as the limitation is actually
that it requires support for "running", ruling out stub-like targets.
Therefore, it should check for use_gdb_stub.

This has no visible effect right now, but it will once we make the
native-gdbserver board non-dejagnu-remote.

gdb/testsuite/ChangeLog:

	* gdb.base/solib-display.exp: Check for [use_gdb_stub] instead
	of [is_remote target],
---
 gdb/testsuite/ChangeLog                  |  5 +++++
 gdb/testsuite/gdb.base/solib-display.exp | 19 ++++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index e3830b6..e1fdd38 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
 2016-05-04  Simon Marchi  <simon.marchi@ericsson.com>

+	* gdb.base/solib-display.exp: Check for [use_gdb_stub] instead
+	of [is_remote target],
+
+2016-05-04  Simon Marchi  <simon.marchi@ericsson.com>
+
 	* lib/gdb.exp (use_gdb_stub): New procedure.

 2016-05-03  Yunlian Jiang <yunlian@google.com>
diff --git a/gdb/testsuite/gdb.base/solib-display.exp b/gdb/testsuite/gdb.base/solib-display.exp
index 7f65617..a82ec2e 100644
--- a/gdb/testsuite/gdb.base/solib-display.exp
+++ b/gdb/testsuite/gdb.base/solib-display.exp
@@ -28,7 +28,24 @@
 # (and thus aren't affected by shared library unloading) are not
 # disabled prematurely.

-if { [skip_shlib_tests] || [is_remote target] } {
+if { [skip_shlib_tests] } {
+    return 0
+}
+
+# This test is currently not supported for stub targets, because it uses the
+# start command (through gdb_start_cmd).  In theory, it could be changed to
+# use something else (kill + gdb_run_cmd with a manual breakpoint at main).
+# However, when we try that with the native-gdbserver board, we see that the
+# test fails and gdb outputs this upon connection:
+#
+#   warning: Unable to display "a_global": No symbol "a_global" in current context.
+#   warning: Unable to display "b_global": No symbol "b_global" in current context.
+#   warning: Unable to display "c_global": No symbol "c_global" in current context.
+#
+# This is because the initial stop is done before the shared libraries are
+# loaded.
+
+if { [use_gdb_stub] } {
     return 0
 }

-- 
2.8.2



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

end of thread, other threads:[~2016-05-04 13:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-02 18:18 [PATCH 1/2] Introduce procedure use_gdb_stub Simon Marchi
2016-05-02 18:18 ` [PATCH 2/2] Fix solib-display.exp remote check Simon Marchi
2016-05-02 18:30   ` Pedro Alves
2016-05-04 13:37     ` Simon Marchi
2016-05-02 18:28 ` [PATCH 1/2] Introduce procedure use_gdb_stub 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).