Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Omair Javaid <omair.javaid@linaro.org>
To: gdb-patches@sourceware.org
Subject: [PATCH] Fix for GDB failing to interrupt after run when no PID issued by stub
Date: Mon, 29 Jan 2018 10:44:00 -0000	[thread overview]
Message-ID: <1517222676-467-1-git-send-email-omair.javaid@linaro.org> (raw)

This behaviour was observed with OpenOCD GDB stub where gdb was failing to stop when interrupted after issuing run command that does not preceede a continue.

Bug report can be found here: https://bugs.launchpad.net/gcc-arm-embedded/+bug/1594341

Here are the steps to reproduce:
1) arm-none-eabi-gdb file-to-debug.elf
2) target remote :3333
At this stage gdb would have connected and halted successfully.
3) run
Issue ctrl + C to interrupt running program and GDB wont be able to stop.

The reason narrowed down to be a case where gdb was unable to clear stop_soon to NO_STOP_QUIETLY;
As some gdb stubs dont report a PID in stop reply the inferior_ptid stays null. A call to remote_current_thread may assign a magic PID in that case.
Based on inferior_ptid function inferior_clear_proceed_status updates inferior->control.stop_soon = NO_STOP_QUIETLY;
If extended_remote_create_inferior calls inferior_clear_proceed_status before a magic PID is assigned to current inferior then it will fail to set inferior->control.stop_soon = NO_STOP_QUIETLY;

This patch adjusts call to inferior_clear_proceed_status such that a PID is assigned to inferior before we try to update inferior->control.stop_soon.

gdb/ChangeLog:
2018-01-29  Omair Javaid  <omair.javaid@linaro.org>

	* remote.c: (extended_remote_create_inferior): Adjust call to
	inferior_clear_proceed_status.
---
 gdb/remote.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index 5ac84df..3387e1c 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -9688,13 +9688,16 @@ Remote replied unexpectedly while setting startup-with-shell: %s"),
 	 running again.  This will mark breakpoints uninserted, and
 	 get_offsets may insert breakpoints.  */
       init_thread_list ();
-      init_wait_for_inferior ();
     }
 
   /* vRun's success return is a stop reply.  */
   stop_reply = run_worked ? rs->buf : NULL;
   add_current_inferior_and_thread (stop_reply);
 
+  /* We have called add_current_inferior_and_thread above,
+  call init_wait_for_inferior before new inferior begins.  */
+  init_wait_for_inferior ();
+
   /* Get updated offsets, if the stub uses qOffsets.  */
   get_offsets ();
 }
-- 
2.7.4


             reply	other threads:[~2018-01-29 10:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-29 10:44 Omair Javaid [this message]
2018-01-31 16:41 ` Yao Qi
2018-01-31 17:01   ` Omair Javaid
2018-02-01 12:48     ` Yao Qi
2018-02-01 15:56       ` Omair Javaid
2018-02-06 14:47         ` Yao Qi
2018-02-08 10:09           ` Omair Javaid
2018-02-15 15:06             ` Yao Qi

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=1517222676-467-1-git-send-email-omair.javaid@linaro.org \
    --to=omair.javaid@linaro.org \
    --cc=gdb-patches@sourceware.org \
    /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