From patchwork Mon Jul 31 22:21:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 21836 Received: (qmail 9665 invoked by alias); 31 Jul 2017 22:22:19 -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 9580 invoked by uid 89); 31 Jul 2017 22:22:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:sk:static. X-HELO: mail-it0-f41.google.com Received: from mail-it0-f41.google.com (HELO mail-it0-f41.google.com) (209.85.214.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 31 Jul 2017 22:22:16 +0000 Received: by mail-it0-f41.google.com with SMTP id h199so2129503ith.1 for ; Mon, 31 Jul 2017 15:22:16 -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=5lqOygSpjXX1ShIh7dKewWeAv+s+1IfCqhvL9EJWY8g=; b=gc013EbI0lv6Hd0oqYspi/uSLJwGKKY0h6Ay2JFYLaPsLmRn0mwP0jHFRJayKrZTyS S/P/fZS3YFj82KpMKHAerw8lM/4IEtKs0EheSgZXKC3xP7vcZOQZr0MUCjfTU/O537pF WuI1aGWVFoqgDXQhKdy1bLLKI1wrWI1oYSKS5Xf/ekFxTqSc/cwX9fCQLfBA75tNrsAh JknOGpkvJBPRwSfNzkuZeFuG8wph3SIZ8+Z4My59iIeTpFJQgwOiwlyCM8WCEoQYFB+a KicRUOiBpCFmrjbiAPeM49zNfSEt7JK+cAdmzTp7ajSr5ycb226Y4eg7ALcFDzv3FVkw Y+yg== X-Gm-Message-State: AIVw112/5nCT9HXEcfPGLA7PWz1bZlzf4Hwb+ugOqA3Z7aYC+w9NBlhZ DPLjgcsjAradAHOT X-Received: by 10.36.124.75 with SMTP id a72mr20583300itd.41.1501539735078; Mon, 31 Jul 2017 15:22:15 -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.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Jul 2017 15:22:14 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 8/9] Throw exception in i386 unwinders Date: Mon, 31 Jul 2017 23:21:54 +0100 Message-Id: <1501539715-8049-9-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 i386 unwinders not to throw exceptions. gdb: 2017-07-31 Yao Qi * i386-tdep.c (i386_frame_cache) : Remove. (i386_alloc_frame_cache): Update. (i386_frame_cache_1): Likewise. (i386_frame_cache): Don't catch exceptions. (i386_frame_this_id): Don't check cache->base_p. (i386_frame_unwind_stop_reason): Likewise. (i386_epilogue_frame_cache): Don't catch exceptions. (i386_epilogue_frame_unwind_stop_reason): Don't check cache->base_p. (i386_epilogue_frame_this_id): Likewise. (i386_sigtramp_frame_cache): Don't catch exceptions. (i386_sigtramp_frame_unwind_stop_reason): Don't check cache->base_p. (i386_sigtramp_frame_this_id): Likewise. --- gdb/i386-tdep.c | 111 ++++++++++++++------------------------------------------ 1 file changed, 27 insertions(+), 84 deletions(-) diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index bd728f0..c09130e 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -1074,7 +1074,6 @@ struct i386_frame_cache { /* Base address. */ CORE_ADDR base; - int base_p; LONGEST sp_offset; CORE_ADDR pc; @@ -1099,7 +1098,6 @@ i386_alloc_frame_cache (void) cache = FRAME_OBSTACK_ZALLOC (struct i386_frame_cache); /* Base address. */ - cache->base_p = 0; cache->base = 0; cache->sp_offset = -4; cache->pc = 0; @@ -1997,10 +1995,7 @@ i386_frame_cache_1 (struct frame_info *this_frame, get_frame_register (this_frame, I386_EBP_REGNUM, buf); cache->base = extract_unsigned_integer (buf, 4, byte_order); if (cache->base == 0) - { - cache->base_p = 1; - return; - } + return; /* For normal frames, %eip is stored at 4(%ebp). */ cache->saved_regs[I386_EIP_REGNUM] = 4; @@ -2071,8 +2066,6 @@ i386_frame_cache_1 (struct frame_info *this_frame, for (i = 0; i < I386_NUM_SAVED_REGS; i++) if (cache->saved_regs[i] != -1) cache->saved_regs[i] += cache->base; - - cache->base_p = 1; } static struct i386_frame_cache * @@ -2086,16 +2079,7 @@ i386_frame_cache (struct frame_info *this_frame, void **this_cache) cache = i386_alloc_frame_cache (); *this_cache = cache; - TRY - { - i386_frame_cache_1 (this_frame, cache); - } - CATCH (ex, RETURN_MASK_ERROR) - { - if (ex.error != NOT_AVAILABLE_ERROR) - throw_exception (ex); - } - END_CATCH + i386_frame_cache_1 (this_frame, cache); return cache; } @@ -2106,9 +2090,7 @@ i386_frame_this_id (struct frame_info *this_frame, void **this_cache, { struct i386_frame_cache *cache = i386_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. */ } @@ -2125,9 +2107,6 @@ i386_frame_unwind_stop_reason (struct frame_info *this_frame, { struct i386_frame_cache *cache = i386_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; @@ -2256,26 +2235,15 @@ i386_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) cache = i386_alloc_frame_cache (); *this_cache = cache; - TRY - { - cache->pc = get_frame_func (this_frame); + cache->pc = get_frame_func (this_frame); - /* At this point the stack looks as if we just entered the - function, with the return address at the top of the - stack. */ - sp = get_frame_register_unsigned (this_frame, I386_ESP_REGNUM); - cache->base = sp + cache->sp_offset; - cache->saved_sp = cache->base + 8; - cache->saved_regs[I386_EIP_REGNUM] = cache->base + 4; - - cache->base_p = 1; - } - CATCH (ex, RETURN_MASK_ERROR) - { - if (ex.error != NOT_AVAILABLE_ERROR) - throw_exception (ex); - } - END_CATCH + /* At this point the stack looks as if we just entered the + function, with the return address at the top of the + stack. */ + sp = get_frame_register_unsigned (this_frame, I386_ESP_REGNUM); + cache->base = sp + cache->sp_offset; + cache->saved_sp = cache->base + 8; + cache->saved_regs[I386_EIP_REGNUM] = cache->base + 4; return cache; } @@ -2287,9 +2255,6 @@ i386_epilogue_frame_unwind_stop_reason (struct frame_info *this_frame, struct i386_frame_cache *cache = i386_epilogue_frame_cache (this_frame, this_cache); - if (!cache->base_p) - return UNWIND_UNAVAILABLE; - return UNWIND_NO_REASON; } @@ -2301,10 +2266,7 @@ i386_epilogue_frame_this_id (struct frame_info *this_frame, struct i386_frame_cache *cache = i386_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 struct value * @@ -2442,36 +2404,25 @@ i386_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) cache = i386_alloc_frame_cache (); - TRY - { - get_frame_register (this_frame, I386_ESP_REGNUM, buf); - cache->base = extract_unsigned_integer (buf, 4, byte_order) - 4; + get_frame_register (this_frame, I386_ESP_REGNUM, buf); + cache->base = extract_unsigned_integer (buf, 4, byte_order) - 4; - addr = tdep->sigcontext_addr (this_frame); - if (tdep->sc_reg_offset) - { - int i; + addr = tdep->sigcontext_addr (this_frame); + if (tdep->sc_reg_offset) + { + int i; - gdb_assert (tdep->sc_num_regs <= I386_NUM_SAVED_REGS); + gdb_assert (tdep->sc_num_regs <= I386_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]; - } - else - { - cache->saved_regs[I386_EIP_REGNUM] = addr + tdep->sc_pc_offset; - cache->saved_regs[I386_ESP_REGNUM] = addr + tdep->sc_sp_offset; - } - - cache->base_p = 1; + 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]; } - CATCH (ex, RETURN_MASK_ERROR) + else { - if (ex.error != NOT_AVAILABLE_ERROR) - throw_exception (ex); + cache->saved_regs[I386_EIP_REGNUM] = addr + tdep->sc_pc_offset; + cache->saved_regs[I386_ESP_REGNUM] = addr + tdep->sc_sp_offset; } - END_CATCH *this_cache = cache; return cache; @@ -2484,9 +2435,6 @@ i386_sigtramp_frame_unwind_stop_reason (struct frame_info *this_frame, struct i386_frame_cache *cache = i386_sigtramp_frame_cache (this_frame, this_cache); - if (!cache->base_p) - return UNWIND_UNAVAILABLE; - return UNWIND_NO_REASON; } @@ -2497,13 +2445,8 @@ i386_sigtramp_frame_this_id (struct frame_info *this_frame, void **this_cache, struct i386_frame_cache *cache = i386_sigtramp_frame_cache (this_frame, this_cache); - if (!cache->base_p) - (*this_id) = frame_id_build_unavailable_stack (get_frame_pc (this_frame)); - else - { - /* See the end of i386_push_dummy_call. */ - (*this_id) = frame_id_build (cache->base + 8, get_frame_pc (this_frame)); - } + /* See the end of i386_push_dummy_call. */ + (*this_id) = frame_id_build (cache->base + 8, get_frame_pc (this_frame)); } static struct value *