From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8636 invoked by alias); 31 Jul 2017 22:22:13 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 8584 invoked by uid 89); 31 Jul 2017 22:22:13 -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=(unknown) X-HELO: mail-it0-f53.google.com Received: from mail-it0-f53.google.com (HELO mail-it0-f53.google.com) (209.85.214.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 31 Jul 2017 22:22:11 +0000 Received: by mail-it0-f53.google.com with SMTP id v127so16815199itd.0 for ; Mon, 31 Jul 2017 15:22:10 -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=n9N7cbqx08kYeiGrXGeZBA1Jz+qf3jP3dxWI5oNcJrk=; b=eMI2yOx9u7yMJlqt4eGMQ3KkcZtKdiZ7hq295/5uBrHZB91qM4sgbDudhVFAEpd7v9 R5V6WryzRxOC1dVBvPEL7MTAnvMHoWrW6dHl2lkGCQwNNUe3DYXASTaPxvDmzCl9rDfq L2vn/L9ba/wGVOKtu5rwa8ku6A6LWmaJhT9HGy65Lq41Vpo9iL5z7Mgl3oRBzuGkGoCH u7HAgzdTd/+1EA8Lart2jlrC8kqe5WUuES7n0p9WEgq/7keGOjCH9GLXlbnctw19vNQ2 RLVjyO5gBVQGqYmJLjXqqnH2BENsVv9IHQOjCs4/x+3VRHWRXybXnRS11vvR8D6oRLCi MljQ== X-Gm-Message-State: AIVw112cxawv8cFVivkEOZUy3y7mc0TiuwWNUf+Vqpq4JFEWmZgsscwb JbntMcLTxS5SBraN X-Received: by 10.36.94.15 with SMTP id h15mr20591137itb.71.1501539729238; Mon, 31 Jul 2017 15:22:09 -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.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Jul 2017 15:22:08 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 4/9] Reset *THIS_CACHE in frame_unwind_try_unwinder in case of exception Date: Mon, 31 Jul 2017 22:22:00 -0000 Message-Id: <1501539715-8049-5-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 X-SW-Source: 2017-07/txt/msg00469.txt.bz2 It is required that unwinder->sniffer should set *this_cache to NULL if the unwinder is not applicable or exception is thrown, so 78ac5f831692f70b841044961069e50d4ba6a76f adds clear_pointer_cleanup to set *this_cache to NULL in case of exception in order to fix PR 14100. https://sourceware.org/ml/gdb-patches/2012-08/msg00075.html This patch removes that clear_pointer_cleanup, and catch all exception in the caller of unwinder->sniffer. In case of exception, reset *this_case. gdb: 2017-07-20 Yao Qi * dwarf2-frame.c (clear_pointer_cleanup): Remove. (dwarf2_frame_cache): Remove reset_cache_cleanup. (dwarf2_frame_cache): * frame-unwind.c (frame_unwind_try_unwinder): Catch RETURN_MASK_ALL and set *this_case to NULL. * frame-unwind.h: Update comments. --- gdb/dwarf2-frame.c | 14 -------------- gdb/frame-unwind.c | 7 ++++++- gdb/frame-unwind.h | 3 ++- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c index 0cb40d9..f8e6522 100644 --- a/gdb/dwarf2-frame.c +++ b/gdb/dwarf2-frame.c @@ -960,20 +960,9 @@ struct dwarf2_frame_cache int entry_cfa_sp_offset_p; }; -/* A cleanup that sets a pointer to NULL. */ - -static void -clear_pointer_cleanup (void *arg) -{ - void **ptr = (void **) arg; - - *ptr = NULL; -} - static struct dwarf2_frame_cache * dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache) { - struct cleanup *reset_cache_cleanup; struct gdbarch *gdbarch = get_frame_arch (this_frame); const int num_regs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); @@ -989,7 +978,6 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache) cache = FRAME_OBSTACK_ZALLOC (struct dwarf2_frame_cache); cache->reg = FRAME_OBSTACK_CALLOC (num_regs, struct dwarf2_frame_state_reg); *this_cache = cache; - reset_cache_cleanup = make_cleanup (clear_pointer_cleanup, this_cache); /* Unwind the PC. @@ -1078,7 +1066,6 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache) if (ex.error == NOT_AVAILABLE_ERROR) { cache->unavailable_retaddr = 1; - discard_cleanups (reset_cache_cleanup); return cache; } @@ -1184,7 +1171,6 @@ incomplete CFI data; unspecified registers (e.g., %s) at %s"), && fs.regs.reg[fs.retaddr_column].how == DWARF2_FRAME_REG_UNDEFINED) cache->undefined_retaddr = 1; - discard_cleanups (reset_cache_cleanup); return cache; } diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index 4d21349..3a75013 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -106,8 +106,11 @@ frame_unwind_try_unwinder (struct frame_info *this_frame, void **this_cache, { res = unwinder->sniffer (unwinder, this_frame, this_cache); } - CATCH (ex, RETURN_MASK_ERROR) + CATCH (ex, RETURN_MASK_ALL) { + /* Catch all exceptions, caused by either interrupt or error. + Reset *THIS_CACHE. */ + *this_cache = NULL; if (ex.error == NOT_AVAILABLE_ERROR) { /* This usually means that not even the PC is available, @@ -128,6 +131,8 @@ frame_unwind_try_unwinder (struct frame_info *this_frame, void **this_cache, } else { + /* Don't set *THIS_CACHE to NULL here, because sniffer has to do + so. */ do_cleanups (old_cleanup); return 0; } diff --git a/gdb/frame-unwind.h b/gdb/frame-unwind.h index 4588cef..8226b6d 100644 --- a/gdb/frame-unwind.h +++ b/gdb/frame-unwind.h @@ -46,7 +46,8 @@ struct value; the PC and attributes) and if SELF is the applicable unwinder, return non-zero. Possibly also initialize THIS_PROLOGUE_CACHE; but only if returning 1. Initializing THIS_PROLOGUE_CACHE in other - cases (0 return, or exception) is invalid. */ + cases (0 return) is invalid. In case of exception, the caller has + to set *THIS_PROLOGUE_CACHE to NULL. */ typedef int (frame_sniffer_ftype) (const struct frame_unwind *self, struct frame_info *this_frame, -- 1.9.1