public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
To: gdb-patches@sourceware.org
Cc: palves@redhat.com
Subject: [PATCH 1/2] testsuite: introduce 'default_gdb_start_post_cmd' as an overridable function
Date: Mon, 20 Apr 2020 18:24:42 +0200	[thread overview]
Message-ID: <6f9e6f6454aa63954b2c604d819eab4b5b5463f3.1587399322.git.tankut.baris.aktemur@intel.com> (raw)
In-Reply-To: <cover.1587399322.git.tankut.baris.aktemur@intel.com>
In-Reply-To: <cover.1587399322.git.tankut.baris.aktemur@intel.com>

Introduce a function named 'default_gdb_start_post_cmd' that is
invoked at the end of 'default_gdb_start'.  The function is by default
empty and can be overridden in a board file or a test to perform
setup right after GDB starts.

The need for this function arose from the fact that doing
'maint set target-non-stop on' was not possible when using the
native-extended-gdbserver board file.  This board file overrides
gdb_start as below:

  proc gdb_start { } {
      # Spawn GDB.
      default_gdb_start

      # And then GDBserver, ready for extended-remote mode.
      gdbserver_start_multi

      return 0
  }

That is, GDB is started and an extended-remote target is defined
immediately following it.  However, to set the remote target to
non-stop mode, we would have to issue the 'maint set target-non-stop on'
code ...

  proc gdb_start { } {
      # Spawn GDB.
      default_gdb_start

-->   ### ... right here.

      # And then GDBserver, ready for extended-remote mode.
      gdbserver_start_multi

      return 0
  }

If the target-non-stop mode is set after making the connection,
we see the following problem:

   $ gdb
   (gdb) file a.out
   ...
   (gdb) set remote exec-file a.out
   (gdb) target extended-remote | gdbserver --once --multi -
   ...
   (gdb) maint set target-non-stop on
   (gdb) run
   ...
   Unexpected vCont reply in non-stop mode: T05swbreak:;06:f0dfffffff7f0000;07:10deffffff7f0000;10:d194ddf7ff7f0000;thread:p4706.4706;core:d;

This patch provides a generalized solution and gives the ability to do
custom setup after starting GDB but before connecting to the target.

gdb/testsuite/ChangeLog:
2020-04-20  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* lib/gdb.exp (default_gdb_start_post_cmd): New overridable
	function.
	(default_gdb_start): Invoke 'default_gdb_start_post_cmd'
	at the end.
---
 gdb/testsuite/lib/gdb.exp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 8418c3d8753..626edee6265 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1849,6 +1849,17 @@ proc default_gdb_spawn { } {
     return 0
 }
 
+# Overridable procedure that is called at the end of
+# default_gdb_start.
+
+proc default_gdb_start_post_cmd { } {
+    # Do nothing by default.
+    # You can override this in your board file or your test.
+    #
+    # E.g. Do "maint set target-non-stop on" to start in
+    # all-stop-on-top-of-non-stop mode.
+}
+
 # Default gdb_start procedure.
 
 proc default_gdb_start { } {
@@ -1919,6 +1930,7 @@ proc default_gdb_start { } {
     }
 
     gdb_debug_init
+    default_gdb_start_post_cmd
     return 0
 }
 
-- 
2.17.1


  reply	other threads:[~2020-04-20 16:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-20 16:24 [PATCH 0/2] Context-switch in finish-step-over flow Tankut Baris Aktemur
2020-04-20 16:24 ` Tankut Baris Aktemur [this message]
2020-04-20 16:24 ` [PATCH 2/2] gdb/infrun: switch the context before 'displaced_step_restore' Tankut Baris Aktemur
2020-04-21 14:38   ` Pedro Alves
2020-04-21 15:29     ` Aktemur, Tankut Baris

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=6f9e6f6454aa63954b2c604d819eab4b5b5463f3.1587399322.git.tankut.baris.aktemur@intel.com \
    --to=tankut.baris.aktemur@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).