From patchwork Mon Jan 29 10:44:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omair Javaid X-Patchwork-Id: 126162 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp2324805ljd; Mon, 29 Jan 2018 02:45:03 -0800 (PST) X-Google-Smtp-Source: AH8x225+/aATjB3M2LQincyUOnG+3qTOf9pZW+lJ1XS2fnfXKe9/aHcDWjjaqacs4/+OzNRyEztI X-Received: by 2002:a17:902:758a:: with SMTP id j10-v6mr12094471pll.410.1517222703132; Mon, 29 Jan 2018 02:45:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517222703; cv=none; d=google.com; s=arc-20160816; b=e2d5HHnLxgsIbc4KlnknZLAuIuJcmkR0jBfCVw9dyw6XC1gWKbexIWT2B+kvC8UdTW VP7O1vSS6sLHyR4/nkjgyfkBAJPl+vXOi7Z91QjtoSNFUSyN0eTMsozj7/Qs+7k/V2ii 5s7SMjfJZRgirZyeoEhJtREzJKCADqo/sA1ot2V2w2020OHZs5Cijxr4+gsCmHFms/SZ wqW1z9s9GA4WxCAzXG3+ytzWL76oZjS5c5pTrgi0hrnPgUVnEKNcslOKSCXSjLkGgm82 2ePj/Fz6jGdv2+R5ghOr56LIkUwNKitLoevrpSPja1Iey6QmueuY29FH/+IeurtwUs1d qLFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=BlKrx9cQx3aCzJQn3nVpOitAwfUcF21n3nWIcEzMOPA=; b=uGm977uiL9XEN7GLDLepMvhAvvhv4B1FE6YV6zvLdbXy8Y+B9zrYpSmf/C9Yb3TR+O 8m9lZx7GFee5E3OMa1RFMNRr12mVfNjE0dAvasi7Yds1OykFVqlWBTE6YanL2NFbiLIb GiAOH2X+HUp4WiG/XRKznEwM06R2Lwm34rr7gbfL0RjgijOErZ+XbjQpX5Oza6PWArsq 1JemULPFuWCg28oowsFDJcbSNannUC1oL4yKPIGawkTEnT+tlUBXl+oYaOomsErwan1p 3mExOWQ800He2OtG/stZua5q84eGg+SmBV0al0YhnWZiBJfnQ+6bP/wVnzhSg5Uovr5X AWSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=FKkikIsM; spf=pass (google.com: domain of gdb-patches-return-145111-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gdb-patches-return-145111-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id b75si1158311pfk.309.2018.01.29.02.45.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jan 2018 02:45:03 -0800 (PST) Received-SPF: pass (google.com: domain of gdb-patches-return-145111-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=FKkikIsM; spf=pass (google.com: domain of gdb-patches-return-145111-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gdb-patches-return-145111-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=WnRdJWPxMA1+72VuSwbkcyaLSlmIyFGBo7JUJ2rQt0kAfuNXEgGxf 7UhNgT8H3bcEInKq9xHVQR1X+RZ9TOhlzfIPWIyu+19tP0VGQgMTZ4cowj2q+0mx 0gOMBcuOXMJWgQcKavWMBQTBkNhW/ZLoo8oCWeQO2JdpBJQkw0euWo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=Hp+mv7/g0tL21aG2/oYJI9i/GZM=; b=FKkikIsM93gqjcQAQnL856G+wd+w EZwBJjmVBv7BwUTAT8SIc7ur+CXAVLPnJXKXMsTGsIO1cXt+/0W0AjFzySGe31lT 5/xRkUG81hdrpYSq1ZYJG5ZEGTldx1qFpzkw23nKzADdvxoJmavh8PLEXUN+cheg pTenRFEeVg3z+gM= Received: (qmail 14215 invoked by alias); 29 Jan 2018 10:44:56 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 14199 invoked by uid 89); 29 Jan 2018 10:44:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=replied X-HELO: mail-wm0-f49.google.com Received: from mail-wm0-f49.google.com (HELO mail-wm0-f49.google.com) (74.125.82.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 29 Jan 2018 10:44:54 +0000 Received: by mail-wm0-f49.google.com with SMTP id x4so44266718wmc.0 for ; Mon, 29 Jan 2018 02:44:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=BlKrx9cQx3aCzJQn3nVpOitAwfUcF21n3nWIcEzMOPA=; b=qSBt+6gy9w7CrLu7oFXwW61LfnfZMY9TyTK8Shukjp62XpqwH3JJ3rWnfFSiu3iWW1 u+FSIuS0GFv/hxfnLV0kj2goltzBb6jA0LO2cCAofYNVooFlptPDpdWoBYl0zBWU1em/ lZ/vxQ3KWy8sW+Fx0Llp1NgzfLLytMOjx68IBFqIpZ+gmvjbptX7+Jp/VkM0EcJ44r0q gCF1QPzWMgURG+6t5pXCCxhVKgrWr17TvcBd5byubvcJP0HyOnOZLuvAVx/Z4GNZfuSh V/kt3r5/SL3FW5ZGcq/DrgOZj8Oj9dzVAUYu66OIGEneOwjtBh0yGy25yGgSZhfqnr4r VR0Q== X-Gm-Message-State: AKwxytenv/Ne/MvZmwwWSknU4BK6+VWpWQMNwBnjEgE8iBHbazheyhoN 4j9fCpjm2uA0f/h11jlBx8e91TqDLmM= X-Received: by 10.28.6.203 with SMTP id 194mr16346893wmg.8.1517222692205; Mon, 29 Jan 2018 02:44:52 -0800 (PST) Received: from localhost.localdomain ([39.55.195.39]) by smtp.gmail.com with ESMTPSA id z74sm10501316wmz.21.2018.01.29.02.44.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Jan 2018 02:44:51 -0800 (PST) From: Omair Javaid 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 15:44:36 +0500 Message-Id: <1517222676-467-1-git-send-email-omair.javaid@linaro.org> X-IsSubscribed: yes 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 * remote.c: (extended_remote_create_inferior): Adjust call to inferior_clear_proceed_status. --- gdb/remote.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.7.4 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 (); }