From patchwork Mon Jul 31 22:21:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 21835 Received: (qmail 9459 invoked by alias); 31 Jul 2017 22:22:18 -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 9390 invoked by uid 89); 31 Jul 2017 22:22:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.1 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:sk:static. X-HELO: mail-it0-f54.google.com Received: from mail-it0-f54.google.com (HELO mail-it0-f54.google.com) (209.85.214.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 31 Jul 2017 22:22:15 +0000 Received: by mail-it0-f54.google.com with SMTP id m34so3302972iti.1 for ; Mon, 31 Jul 2017 15:22:15 -0700 (PDT) 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:in-reply-to :references; bh=4NLzvDbH5Zcvgj35eOKu8s5Ctd09Aw17ldflGat6CXg=; b=HwoqJ3csjDMuV6Io0Nub9nrrqn8tqvcV4acVkTSjmiI7xQvDiYg5VafKKbyRPGj1of uXZFV7spTjHcU17UjsX2gtJ4lCV4WZsKnOnWLKKjbXeclyfR/MeqnY6eU7E0SNbL0SdV gh2KPg+dAcKLSw3DFw1+rtpJX0QwCtodSgZe+Dpym4ZVmobvHMF0eXP73MLyRbqn22UJ YKOUF96RBYTiZn0jfbmaJKBNTH8dHLXUhYV14pb2FBA9YcDpzlSb1XXBWWqRkgTk8qqc m6QiF3YcY8VJfqpXpXE3mHlWtZc19++ll6XOj17xofIYAm7JlBmlTmbr+hACBaUQGzJm Yw1A== X-Gm-Message-State: AIVw1107FnNth224SJrayb5oyXWHuCbnh04zGK/+UBMSXarrTnQ++c7Y uH/vgAkYAE4IJLH7 X-Received: by 10.36.17.142 with SMTP id 136mr20747120itf.90.1501539733641; Mon, 31 Jul 2017 15:22:13 -0700 (PDT) Received: from E107787-LIN.Home (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id s204sm5963117itd.34.2017.07.31.15.22.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Jul 2017 15:22:13 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 7/9] Throw exception in amd64 unwinders Date: Mon, 31 Jul 2017 23:21:53 +0100 Message-Id: <1501539715-8049-8-git-send-email-yao.qi@linaro.org> In-Reply-To: <1501539715-8049-1-git-send-email-yao.qi@linaro.org> References: <1501539715-8049-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes This patch changes amd64 unwinders not to throw exceptions. gdb: 2017-07-31 Yao Qi * amd64-tdep.c (amd64_frame_cache) : Remove. (amd64_init_frame_cache): Update. (amd64_frame_cache_1): Update. (amd64_frame_unwind_stop_reason): Don't check cache->base_p. (amd64_frame_this_id): Likewise. (amd64_sigtramp_frame_cache): Don't catch exception. (amd64_sigtramp_frame_unwind_stop_reason): Don't check cache->base_p. (amd64_sigtramp_frame_this_id): Likewise. (amd64_epilogue_frame_cache): Don't catch exception. (amd64_epilogue_frame_unwind_stop_reason): Don't check cache->base_p. (amd64_epilogue_frame_this_id): Likewise. --- gdb/amd64-tdep.c | 95 +++++++++++++------------------------------------------- 1 file changed, 22 insertions(+), 73 deletions(-) diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index f647402..256147b 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -1876,7 +1876,6 @@ struct amd64_frame_cache { /* Base address. */ CORE_ADDR base; - int base_p; CORE_ADDR sp_offset; CORE_ADDR pc; @@ -1898,7 +1897,6 @@ amd64_init_frame_cache (struct amd64_frame_cache *cache) /* Base address. */ cache->base = 0; - cache->base_p = 0; cache->sp_offset = -8; cache->pc = 0; @@ -2531,8 +2529,6 @@ amd64_frame_cache_1 (struct frame_info *this_frame, for (i = 0; i < AMD64_NUM_SAVED_REGS; i++) if (cache->saved_regs[i] != -1) cache->saved_regs[i] += cache->base; - - cache->base_p = 1; } static struct amd64_frame_cache * @@ -2546,16 +2542,7 @@ amd64_frame_cache (struct frame_info *this_frame, void **this_cache) cache = amd64_alloc_frame_cache (); *this_cache = cache; - TRY - { - amd64_frame_cache_1 (this_frame, cache); - } - CATCH (ex, RETURN_MASK_ERROR) - { - if (ex.error != NOT_AVAILABLE_ERROR) - throw_exception (ex); - } - END_CATCH + amd64_frame_cache_1 (this_frame, cache); return cache; } @@ -2567,9 +2554,6 @@ amd64_frame_unwind_stop_reason (struct frame_info *this_frame, struct amd64_frame_cache *cache = amd64_frame_cache (this_frame, this_cache); - if (!cache->base_p) - return UNWIND_UNAVAILABLE; - /* This marks the outermost frame. */ if (cache->base == 0) return UNWIND_OUTERMOST; @@ -2584,9 +2568,7 @@ amd64_frame_this_id (struct frame_info *this_frame, void **this_cache, struct amd64_frame_cache *cache = amd64_frame_cache (this_frame, this_cache); - if (!cache->base_p) - (*this_id) = frame_id_build_unavailable_stack (cache->pc); - else if (cache->base == 0) + if (cache->base == 0) { /* This marks the outermost frame. */ return; @@ -2664,26 +2646,15 @@ amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) cache = amd64_alloc_frame_cache (); - TRY - { - get_frame_register (this_frame, AMD64_RSP_REGNUM, buf); - cache->base = extract_unsigned_integer (buf, 8, byte_order) - 8; - - addr = tdep->sigcontext_addr (this_frame); - gdb_assert (tdep->sc_reg_offset); - gdb_assert (tdep->sc_num_regs <= AMD64_NUM_SAVED_REGS); - for (i = 0; i < tdep->sc_num_regs; i++) - if (tdep->sc_reg_offset[i] != -1) - cache->saved_regs[i] = addr + tdep->sc_reg_offset[i]; + get_frame_register (this_frame, AMD64_RSP_REGNUM, buf); + cache->base = extract_unsigned_integer (buf, 8, byte_order) - 8; - cache->base_p = 1; - } - CATCH (ex, RETURN_MASK_ERROR) - { - if (ex.error != NOT_AVAILABLE_ERROR) - throw_exception (ex); - } - END_CATCH + addr = tdep->sigcontext_addr (this_frame); + gdb_assert (tdep->sc_reg_offset); + gdb_assert (tdep->sc_num_regs <= AMD64_NUM_SAVED_REGS); + for (i = 0; i < tdep->sc_num_regs; i++) + if (tdep->sc_reg_offset[i] != -1) + cache->saved_regs[i] = addr + tdep->sc_reg_offset[i]; *this_cache = cache; return cache; @@ -2696,9 +2667,6 @@ amd64_sigtramp_frame_unwind_stop_reason (struct frame_info *this_frame, struct amd64_frame_cache *cache = amd64_sigtramp_frame_cache (this_frame, this_cache); - if (!cache->base_p) - return UNWIND_UNAVAILABLE; - return UNWIND_NO_REASON; } @@ -2709,9 +2677,7 @@ amd64_sigtramp_frame_this_id (struct frame_info *this_frame, struct amd64_frame_cache *cache = amd64_sigtramp_frame_cache (this_frame, this_cache); - if (!cache->base_p) - (*this_id) = frame_id_build_unavailable_stack (get_frame_pc (this_frame)); - else if (cache->base == 0) + if (cache->base == 0) { /* This marks the outermost frame. */ return; @@ -2841,30 +2807,19 @@ amd64_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) cache = amd64_alloc_frame_cache (); *this_cache = cache; - TRY - { - /* Cache base will be %esp plus cache->sp_offset (-8). */ - get_frame_register (this_frame, AMD64_RSP_REGNUM, buf); - cache->base = extract_unsigned_integer (buf, 8, - byte_order) + cache->sp_offset; + /* Cache base will be %esp plus cache->sp_offset (-8). */ + get_frame_register (this_frame, AMD64_RSP_REGNUM, buf); + cache->base = extract_unsigned_integer (buf, 8, + byte_order) + cache->sp_offset; - /* Cache pc will be the frame func. */ - cache->pc = get_frame_pc (this_frame); + /* Cache pc will be the frame func. */ + cache->pc = get_frame_pc (this_frame); - /* The saved %esp will be at cache->base plus 16. */ - cache->saved_sp = cache->base + 16; + /* The saved %esp will be at cache->base plus 16. */ + cache->saved_sp = cache->base + 16; - /* The saved %eip will be at cache->base plus 8. */ - cache->saved_regs[AMD64_RIP_REGNUM] = cache->base + 8; - - cache->base_p = 1; - } - CATCH (ex, RETURN_MASK_ERROR) - { - if (ex.error != NOT_AVAILABLE_ERROR) - throw_exception (ex); - } - END_CATCH + /* The saved %eip will be at cache->base plus 8. */ + cache->saved_regs[AMD64_RIP_REGNUM] = cache->base + 8; return cache; } @@ -2876,9 +2831,6 @@ amd64_epilogue_frame_unwind_stop_reason (struct frame_info *this_frame, struct amd64_frame_cache *cache = amd64_epilogue_frame_cache (this_frame, this_cache); - if (!cache->base_p) - return UNWIND_UNAVAILABLE; - return UNWIND_NO_REASON; } @@ -2890,10 +2842,7 @@ amd64_epilogue_frame_this_id (struct frame_info *this_frame, struct amd64_frame_cache *cache = amd64_epilogue_frame_cache (this_frame, this_cache); - if (!cache->base_p) - (*this_id) = frame_id_build_unavailable_stack (cache->pc); - else - (*this_id) = frame_id_build (cache->base + 8, cache->pc); + (*this_id) = frame_id_build (cache->base + 8, cache->pc); } static const struct frame_unwind amd64_epilogue_frame_unwind =