From patchwork Mon Dec 30 16:25:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 182632 Delivered-To: patch@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6533866ild; Mon, 30 Dec 2019 08:25:55 -0800 (PST) X-Google-Smtp-Source: APXvYqx6Dj/MntxkLGXqGe2/x995wLGg/YaIURayRyx0qCrruVwKPFjGWIsLlRWCEfulN3dk1sSJ X-Received: by 2002:a9d:664a:: with SMTP id q10mr63470001otm.99.1577723155102; Mon, 30 Dec 2019 08:25:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577723155; cv=none; d=google.com; s=arc-20160816; b=WJVjn7jKHWhEidBfpK+EAgLWYehKqlIJ+XRu4tc47eMpzunCXykN+L3YzOhMlg2hkv 6xy2YQ42p8vpqvBYfH49xQ/wEVdfMET1gzGKbTV0cVXrXQIYoYvVaVcOd5AxDI5in2ku 1tJmUOAGIqIXE7MavUhbI+5M0XAx8RQ6kopyi++BHjn51PdOrOE552sxGpiLXtuvz/Wh CweXUkQ8c4aEXhe5prY95k8ZmIBX05SJSU7d6OMsVypLpVUB5OWQTdlFXTt7KSX+ehdO HfYUkD2+GaG6ZZ4mW/i9pKEC+4EQFcg626/SC7dLrf56Nyv3dgpXMrNzFEdKs+aE7hSh k7gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:dkim-signature:delivered-to:sender :list-help:list-post:list-archive:list-subscribe:list-unsubscribe :list-id:precedence:mailing-list:dkim-signature:domainkey-signature; bh=VCtMpGA9eCmjED2VBxoP9WDNQgkDkHfBLF2hTvm/6+A=; b=qOu6OyrsJDjCawgKc/QfBAU7ERJ7iBEsNGX3qR0+sBihTo+OBIYTlm4unpDwHX3/kL EHG4iBhnAQH+MoVX84Mob/K7z6EQOHTkGVhHpTrf1Y058qCTsMqsIYsJbxkczyAod+pi inEylcubtDZ2NY1xO5pRgC5azI4YUDc5LRelGU5yQMC/cYuc+jQDhvOzMoYHZHS/dCkM uBWd7T8ktQootbyK/KWdz6CP8x/t8Xn/hIg6wxL3+CFPeVMEuA5JgYKwDdSEGcPmOKvc XaMv4XhZevN2D3H5ggWAdeieuCi0MIJCx+tCvV/9/8MIDz0SQScAG8SogjuQv9Jdg4yW IuNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=sj4vMdrE; dkim=pass header.i=@linaro.org header.s=google header.b=qs7AiE0r; spf=pass (google.com: domain of gdb-patches-return-162664-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gdb-patches-return-162664-patch=linaro.org@sourceware.org"; dmarc=pass (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 x22si23897287otp.107.2019.12.30.08.25.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Dec 2019 08:25:55 -0800 (PST) Received-SPF: pass (google.com: domain of gdb-patches-return-162664-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=sj4vMdrE; dkim=pass header.i=@linaro.org header.s=google header.b=qs7AiE0r; spf=pass (google.com: domain of gdb-patches-return-162664-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gdb-patches-return-162664-patch=linaro.org@sourceware.org"; dmarc=pass (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=UsA1TcXqjZJplRrdDDJsBg06uTgRSPo4XB5Rr8LpQFkmI5cLVn/1F nV/f7RpqHQa1zHcf92uiEhqay3g8KubvFXJiCjyFHJLiO1aEtz6EmbDcvKc6GN5X //YgJ8wFGAQYERCHKzBTkbtVU/7QLeKIqpnh3L/enNyIyPZQ6fvcN8= 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=bnno54xhbvFRoeJiDqbLMdJXkzU=; b=sj4vMdrErM2eK0Bv+rMG1M4OxkVg qYr9Y9sysS+u6H80EllLeaJq2zbj/sYhRtjL8YsW7bJ476PnPnIcvE6eFMgk9zRb X7NrY+hYfC19LL/1yvGGZreXBea3NPaezzKFK7BD1VgiGFqkI5rIb5q6hr4f/6II 37PRurYVapBrSTM= Received: (qmail 120541 invoked by alias); 30 Dec 2019 16:25:48 -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 120533 invoked by uid 89); 30 Dec 2019 16:25:48 -0000 Authentication-Results: sourceware.org; auth=none 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.1 spammy=whenever, tells, Condition X-HELO: mail-pg1-f194.google.com Received: from mail-pg1-f194.google.com (HELO mail-pg1-f194.google.com) (209.85.215.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 Dec 2019 16:25:46 +0000 Received: by mail-pg1-f194.google.com with SMTP id b9so18223587pgk.12 for ; Mon, 30 Dec 2019 08:25:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id; bh=VCtMpGA9eCmjED2VBxoP9WDNQgkDkHfBLF2hTvm/6+A=; b=qs7AiE0rl8y9F+o3okyXvYihNbr0Hg7tCISWQfpAGMBvQmbKgpx5ja6Qo5McH8V0op A5eh5ZY5/mYHUZoYBfVgFrjlcw+c7sQ8uI0HT8Mn3HS0DV5L+GLfDgmGH+RiP7wSHftu 4TSaweXZruZKbxbFVPSUKpaTC+4R7EgbBqgu9lpcxT6Gad7aYvMjuj7K5IgENHCCRXnB hGTMOIynyZstQ4JWuoPBepElYPqS6907PNYuEMr7pBkBoa0ZjCcS2WhY4+si9//mpEQD BbxmYyclDUBxAegqfCCGvGffB0lcVsssRcHcda69hIYkjlEX3xwZhh3hWqx2kR0T43bo biEg== Return-Path: Received: from localhost.localdomain ([191.251.164.209]) by smtp.gmail.com with ESMTPSA id p24sm52397369pff.69.2019.12.30.08.25.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 08:25:44 -0800 (PST) From: Luis Machado To: gdb-patches@sourceware.org Subject: [PATCH 1/2] [AArch64] Fix step-over-syscall.exp failure Date: Mon, 30 Dec 2019 13:25:34 -0300 Message-Id: <20191230162535.21211-1-luis.machado@linaro.org> X-IsSubscribed: yes In particular, this one: FAIL: gdb.base/step-over-syscall.exp: fork: displaced=on: check_pc_after_cross_syscall: single step over fork final pc When ptrace fork event reporting is enabled, GDB gets a PTRACE_EVENT_FORK event whenever the inferior executes the fork syscall. Then the logic is that GDB needs to step the inferior yet again in order to receive a predetermined SIGTRAP, but no execution takes place because the signal was already queued for delivery. That means the PC should stay the same. I noticed the aarch64 code is currently adjusting the PC in this situation, making the inferior skip an instruction without executing it. The existing code abuses the pc_adjust variable to contain both an offset and also a bool telling GDB when to adjust the PC (pc_adjust != 0). This patch fixes this case by adding a new bool that tells us when we're supposed to adjust the PC, and then proceeding to check if we did not execute the instruction (pc - to == 0), making proper adjustments for such case. Regression tested on aarch64-linux-gnu on the tryserver. gdb/ChangeLog: 2019-12-30 Luis Machado * aarch64-tdep.c (struct aarch64_displaced_step_closure ) : New member. : Adjust the documentation. (aarch64_displaced_step_b): Set should_adjust_pc. (aarch64_displaced_step_b_cond): Likewise. (aarch64_displaced_step_cb): Likewise. (aarch64_displaced_step_tb): Likewise. (aarch64_displaced_step_adr): Likewise. (aarch64_displaced_step_ldr_literal): Likewise. (aarch64_displaced_step_others): Likewise. (aarch64_displaced_step_fixup): Check if PC really moved before adjusting it. Change-Id: I828b7b7f2726f42ce107708f9692f07c63bf728c --- gdb/aarch64-tdep.c | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 1d5fb2001d..a639b753cd 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -2737,7 +2737,12 @@ struct aarch64_displaced_step_closure : public displaced_step_closure is being displaced stepping. */ int cond = 0; - /* PC adjustment offset after displaced stepping. */ + /* True if we should adjust the PC after displaced stepping, false + otherwise. */ + bool should_adjust_pc = false; + + /* PC adjustment offset after displaced stepping, if should_adjust_pc + is true. */ int32_t pc_adjust = 0; }; @@ -2783,6 +2788,9 @@ aarch64_displaced_step_b (const int is_bl, const int32_t offset, emit_nop (dsd->insn_buf); dsd->insn_count++; dsd->dsc->pc_adjust = offset; + + if (offset != 0) + dsd->dsc->should_adjust_pc = true; } if (is_bl) @@ -2818,6 +2826,9 @@ aarch64_displaced_step_b_cond (const unsigned cond, const int32_t offset, dsd->dsc->cond = 1; dsd->dsc->pc_adjust = offset; dsd->insn_count = 1; + + if (offset != 0) + dsd->dsc->should_adjust_pc = true; } /* Dynamically allocate a new register. If we know the register @@ -2852,6 +2863,9 @@ aarch64_displaced_step_cb (const int32_t offset, const int is_cbnz, dsd->insn_count = 1; dsd->dsc->cond = 1; dsd->dsc->pc_adjust = offset; + + if (offset != 0) + dsd->dsc->should_adjust_pc = true; } /* Implementation of aarch64_insn_visitor method "tb". */ @@ -2877,6 +2891,9 @@ aarch64_displaced_step_tb (const int32_t offset, int is_tbnz, dsd->insn_count = 1; dsd->dsc->cond = 1; dsd->dsc->pc_adjust = offset; + + if (offset != 0) + dsd->dsc->should_adjust_pc = true; } /* Implementation of aarch64_insn_visitor method "adr". */ @@ -2902,6 +2919,7 @@ aarch64_displaced_step_adr (const int32_t offset, const unsigned rd, address); dsd->dsc->pc_adjust = 4; + dsd->dsc->should_adjust_pc = true; emit_nop (dsd->insn_buf); dsd->insn_count = 1; } @@ -2929,6 +2947,7 @@ aarch64_displaced_step_ldr_literal (const int32_t offset, const int is_sw, aarch64_register (rt, 1), zero); dsd->dsc->pc_adjust = 4; + dsd->dsc->should_adjust_pc = true; } /* Implementation of aarch64_insn_visitor method "others". */ @@ -2946,10 +2965,12 @@ aarch64_displaced_step_others (const uint32_t insn, if ((insn & 0xfffffc1f) == 0xd65f0000) { /* RET */ - dsd->dsc->pc_adjust = 0; } else - dsd->dsc->pc_adjust = 4; + { + dsd->dsc->pc_adjust = 4; + dsd->dsc->should_adjust_pc = true; + } } static const struct aarch64_insn_visitor visitor = @@ -3030,13 +3051,15 @@ aarch64_displaced_step_fixup (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs) { + ULONGEST pc; + aarch64_displaced_step_closure *dsc = (aarch64_displaced_step_closure *) dsc_; + /* Fetch the current PC, after the displaced execution took place. */ + regcache_cooked_read_unsigned (regs, AARCH64_PC_REGNUM, &pc); + if (dsc->cond) { - ULONGEST pc; - - regcache_cooked_read_unsigned (regs, AARCH64_PC_REGNUM, &pc); if (pc - to == 8) { /* Condition is true. */ @@ -3045,13 +3068,22 @@ aarch64_displaced_step_fixup (struct gdbarch *gdbarch, { /* Condition is false. */ dsc->pc_adjust = 4; + dsc->should_adjust_pc = true; } else gdb_assert_not_reached ("Unexpected PC value after displaced stepping"); } - if (dsc->pc_adjust != 0) + if (dsc->should_adjust_pc) { + + /* Sometimes we may get a SIGTRAP even before executing an instruction. + Such is the case when we are stepping over a fork/vfork/clone syscall + and the instruction after the syscall instruction. Make sure we don't + adjust the PC when we did not really move. */ + if ((pc - to) == 0) + dsc->pc_adjust = 0; + if (debug_displaced) { debug_printf ("displaced: fixup: set PC to %s:%d\n", From patchwork Mon Dec 30 16:25:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 182633 Delivered-To: patch@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6533955ild; Mon, 30 Dec 2019 08:26:00 -0800 (PST) X-Google-Smtp-Source: APXvYqzfBPNO0WmeEokmgU3N9/mhG5yCdRARZlKgwUx/WJOfk52JxsGDRqER8sWLltRVTQz3TLJp X-Received: by 2002:a9d:68cb:: with SMTP id i11mr70794043oto.210.1577723160363; Mon, 30 Dec 2019 08:26:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577723160; cv=none; d=google.com; s=arc-20160816; b=U+5FPRe1fqwufDWMH61g997OzqQ6xv+CZEHQ/wi4Qluh9iFSxPKqOZMqzk9fJ/9N8H 9eWvy6ctk7EJX356CUyeQkEE6iNQuAn2zE4wns6CQMXsRaT0dvL8AbsUkMI9gZn02KIW VN3/OyYT7xrCsOsTizkI75aBbxC5qsAr2XZNGYuOwPJjyNsL/fZRYFUhWORZyceP7Xr/ d+f4Vud6B652ObQgQH/sVQjdupC9BzMIutpDY78U7KRfiuGtSx2C8iv81ylJ5UMRI7UG sEXduAKhbpgmGoR4nAsk+qSPUA1Q3uwkjVwxqIb6r8t/WXn7331qKbPGpBlkfUKNUU9c RiMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=73eCSAP8+WvXzHo751Y2G7ZHg//NC0xYx6BWgP1X780=; b=t0LE+jK+t+V2WU1/XdO+UcD2RgK+eD+kxdkbElGmG4is8OAC3iPXR7fx6Zf+DALwIY v6ClZDW6K35MgVuxa0GQymtn1/H4/bO067+JUni1D2zjWEJox4eAxPkAN4XhGPf4b8BS Gogf7nlrK1EEPyPN2slQV8uZrwojhl/KnVeNXX7PXqJ7+L15fvxd1zbGM9oK3zcRvhc1 Y1d48iXhXt5xZsTVJI3SigjVbR/gJwPNCQobkuuj+3MEorgtt+lkSB3cmRyisyYrKmpi 9t8FPRIckhLyG3BUYpLMEht3wjUMSnqRUg6ISI3WRi8i6xb7lx0yPzOwjk/zv8x+7Qdx axsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="Kn/+sUps"; dkim=pass header.i=@linaro.org header.s=google header.b=blavW6g3; spf=pass (google.com: domain of gdb-patches-return-162665-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gdb-patches-return-162665-patch=linaro.org@sourceware.org"; dmarc=pass (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 k7si22335086otp.22.2019.12.30.08.26.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Dec 2019 08:26:00 -0800 (PST) Received-SPF: pass (google.com: domain of gdb-patches-return-162665-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="Kn/+sUps"; dkim=pass header.i=@linaro.org header.s=google header.b=blavW6g3; spf=pass (google.com: domain of gdb-patches-return-162665-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gdb-patches-return-162665-patch=linaro.org@sourceware.org"; dmarc=pass (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:in-reply-to :references; q=dns; s=default; b=lirZSXgkzSbFgXFWmcAvy7JPXGaYpkR njJxeUpfKropVdd1TcEFqy1yPUqND23w7AOLn9fRtBVqSU0I05hzS51QUXJcGyTC r2c5XGnT6ChkkZmpVTsLkgAaDgEN0Z/HXQiALx9zRbcz2MeZ7LcF/uVAWkX+zvKL 7bjvroCXM/l0= 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:in-reply-to :references; s=default; bh=MP0iYxXClG9h9vDkp6wjzivog0U=; b=Kn/+s Upsukzdu7ouh57ak9QBpgQ8cSSYWldimUAj0PqFQ35Ittypzti7LhSf5E+C8DNoS wjJJfng+f8qzFl5n3oL7Lry3lriNwrxROA4x2/ZR1g0x0kAdwN9PbZ6f0PR4J14l 0I2JnGICJdn12b6Afpj4DXRSNpwT0cApMhkSiw= Received: (qmail 121066 invoked by alias); 30 Dec 2019 16:25:52 -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 121009 invoked by uid 89); 30 Dec 2019 16:25:52 -0000 Authentication-Results: sourceware.org; auth=none 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.1 spammy= X-HELO: mail-pl1-f195.google.com Received: from mail-pl1-f195.google.com (HELO mail-pl1-f195.google.com) (209.85.214.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 Dec 2019 16:25:50 +0000 Received: by mail-pl1-f195.google.com with SMTP id p27so14810579pli.10 for ; Mon, 30 Dec 2019 08:25:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=73eCSAP8+WvXzHo751Y2G7ZHg//NC0xYx6BWgP1X780=; b=blavW6g3bDWWjtlJmAGv0C/L7ektANoqZZpQaARFs4Bu0QA3GWgdZgE8jWCAvNJggP tzZ4Yuq0at12eML2bcWnXOGz5EhlVZL5cij/XRrwk5c6SvzH52JVK4yqG7YOw/av9GO8 TVMj7dYK2ZBon8Lq0TF4BimTOZkA6QIPnOUKcW1V0/DWRsC7J5rMD3qZiVGtObyZAtdj DZif+zUBeBQX9CNsseLaypXIOHfz1IrAUxJUwT0oge7wHJ8IDW9AWOz6dTa2M8nPmbG0 2txxFu8OFyl2+ZoM/B51+KD9ZiJN7DbVONofkwLf9cKuhfKLwVPsgtkWHS1wNpQ/90id dpdg== Return-Path: Received: from localhost.localdomain ([191.251.164.209]) by smtp.gmail.com with ESMTPSA id p24sm52397369pff.69.2019.12.30.08.25.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 08:25:48 -0800 (PST) From: Luis Machado To: gdb-patches@sourceware.org Subject: [PATCH 2/2] [AArch64] Add more debugging output to aarch64_displaced_step_fixup Date: Mon, 30 Dec 2019 13:25:35 -0300 Message-Id: <20191230162535.21211-2-luis.machado@linaro.org> In-Reply-To: <20191230162535.21211-1-luis.machado@linaro.org> References: <20191230162535.21211-1-luis.machado@linaro.org> X-IsSubscribed: yes While debugging the step-over-syscall problem, i wanted to see a bit more debugging output to try to determine the root cause. This patch does this. gdb/ChangeLog: 2019-12-30 Luis Machado * aarch64-tdep.c (aarch64_displaced_step_fixup): Add more debugging output. Signed-off-by: Luis Machado --- gdb/aarch64-tdep.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index a639b753cd..2d6c5a4bcb 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -3058,8 +3058,16 @@ aarch64_displaced_step_fixup (struct gdbarch *gdbarch, /* Fetch the current PC, after the displaced execution took place. */ regcache_cooked_read_unsigned (regs, AARCH64_PC_REGNUM, &pc); + if (debug_displaced) + debug_printf ("displaced: PC after stepping: %s (was %s).\n", + paddress (gdbarch, pc), paddress (gdbarch, to)); + if (dsc->cond) { + if (debug_displaced) + debug_printf ("displaced: [Conditional] pc_adjust before: %d\n", + dsc->pc_adjust); + if (pc - to == 8) { /* Condition is true. */ @@ -3072,8 +3080,17 @@ aarch64_displaced_step_fixup (struct gdbarch *gdbarch, } else gdb_assert_not_reached ("Unexpected PC value after displaced stepping"); + + if (debug_displaced) + debug_printf ("displaced: [Conditional] pc_adjust after: %d\n", + dsc->pc_adjust); } + if (debug_displaced) + debug_printf ("displaced: %s PC by %d\n", + dsc->should_adjust_pc? "adjusting" : "not adjusting", + dsc->pc_adjust); + if (dsc->should_adjust_pc) { @@ -3082,7 +3099,12 @@ aarch64_displaced_step_fixup (struct gdbarch *gdbarch, and the instruction after the syscall instruction. Make sure we don't adjust the PC when we did not really move. */ if ((pc - to) == 0) - dsc->pc_adjust = 0; + { + if (debug_displaced) + debug_printf ("displaced: PC did not move. Discarding PC \ +adjustment.\n"); + dsc->pc_adjust = 0; + } if (debug_displaced) {