From patchwork Sat Sep 8 21:55:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 29260 Received: (qmail 55561 invoked by alias); 8 Sep 2018 21:56:09 -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 55455 invoked by uid 89); 8 Sep 2018 21:56:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL, 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=D*adacore.com, U*brobecker, brobeckeradacorecom, brobecker@adacore.com X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 08 Sep 2018 21:56:05 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 56B6C11728D for ; Sat, 8 Sep 2018 17:56:04 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id mEJJdDlRj8FH for ; Sat, 8 Sep 2018 17:56:04 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 4541D1170ED for ; Sat, 8 Sep 2018 17:56:04 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4233) id 44523489; Sat, 8 Sep 2018 17:56:04 -0400 (EDT) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [PATCH 2/8] (Ada) infinite loop when hitting unhandled exception catchpoint Date: Sat, 8 Sep 2018 17:55:54 -0400 Message-Id: <1536443760-78016-3-git-send-email-brobecker@adacore.com> In-Reply-To: <1536443760-78016-1-git-send-email-brobecker@adacore.com> References: <1536443760-78016-1-git-send-email-brobecker@adacore.com> When debugging a program compiled with an older version of GNAT, hitting a catchpoint on unhandled exceptions can caused GDB to got into an infinite loop. This happens while trying to find the name of the exception that was raised. For that, it searches for a frame corresponding to a specific function we know gets called during the exeption handling. In our particular case, the compiler was too old, and so GDB never found that frame, and eventually got past the "main" subprogram, all the way to system frames, where no symbol was available. As a result, the code addresses could not be resolved into a function name, leading to the infinite loop because of a misplaced update of our loop variable "fi": while (fi != NULL) { char *func_name; enum language func_lang; find_frame_funname (fi, &func_name, &func_lang, NULL); if (func_name != NULL) { make_cleanup (xfree, func_name); if (strcmp (func_name, data->exception_info->catch_exception_sym) == 0) break; /* We found the frame we were looking for... */ fi = get_prev_frame (fi); } } If FUNC_NAME is NULL, then FI never gets updated ever after! gdb/ChangeLog: * ada-lang.c (ada_unhandled_exception_name_addr_from_raise): Move update of loop variable "fi". No testcase added, as the existing testcase gdb.ada/catch_ex.exp should trigger it when using an older version of GNAT as the Ada compiler. --- gdb/ChangeLog | 5 +++++ gdb/ada-lang.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0d87f83..41dee6e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2018-09-08 Joel Brobecker + * ada-lang.c (ada_unhandled_exception_name_addr_from_raise): + Move update of loop variable "fi". + +2018-09-08 Joel Brobecker + * ada-lang.c (value_assign_to_component): In the case of big-endian targets, extract the bits of the given VAL using an src_offset of zero if container is not a scalar. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 3618e1d..87ae275 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -12242,8 +12242,8 @@ ada_unhandled_exception_name_addr_from_raise (void) if (strcmp (func_name.get (), data->exception_info->catch_exception_sym) == 0) break; /* We found the frame we were looking for... */ - fi = get_prev_frame (fi); } + fi = get_prev_frame (fi); } if (fi == NULL)