From patchwork Fri Mar 2 20:09:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 26162 Received: (qmail 21246 invoked by alias); 2 Mar 2018 20:10:01 -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 21134 invoked by uid 89); 2 Mar 2018 20:10:01 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.7 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= X-HELO: mail-wr0-f193.google.com Received: from mail-wr0-f193.google.com (HELO mail-wr0-f193.google.com) (209.85.128.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Mar 2018 20:09:59 +0000 Received: by mail-wr0-f193.google.com with SMTP id p104so11270270wrc.12 for ; Fri, 02 Mar 2018 12:09:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=5UxYspzSS6k4phYkuIYXB8qFwP3tu6S4pd71kAZJGEU=; b=m/SQy9A/iFrAxyaWZonsvlC/dkqU6bMLWotYlfY6ztBzkJQD4/lfLxCEddA4BCuaBy jmzmicgBYtWxiqyDD4MSIhfF992dWbPbCS5mtOsnfRhYu1CtwzCeXeeXhbNTT6G+nJr6 xLfu13TvcckqgmId+z7Bfjqs9n5AH3tdvi5Ri3BKIsHSlwxGuOx2fTmi4c9g2UXeBftM EfZWAkmlWXxRDjcHpZZtUS1312ApvQD6u56gEobVk1NxDLOtl8yKk8OUa14PiMoOwQET 6mp4UDJC+iGZR9Nwyff0+MgCRWUcSlS1DKk1vKYq6Ilf+LewSQROvTQP1w+C7Q5jaZaA YSMw== X-Gm-Message-State: APf1xPAsuhTHxWNGVUaKqwZmjuBqID6/pxF4LImZ6my+ZYG5hqnrtXwk A7g8+q7dNc0369XEvyZ3aIiNXgnk X-Google-Smtp-Source: AG47ELsdHOHty3qh2ig3Gf8TeGjtm4+ew17JGk4E6at8LnZwd5cegRa5retTVDpBgbFe7gZtAgKuEQ== X-Received: by 10.223.166.106 with SMTP id k97mr5936867wrc.64.1520021397297; Fri, 02 Mar 2018 12:09:57 -0800 (PST) Received: from localhost (host86-164-103-156.range86-164.btcentralplus.com. [86.164.103.156]) by smtp.gmail.com with ESMTPSA id q74sm2588968wmg.11.2018.03.02.12.09.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Mar 2018 12:09:56 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Simon Marchi , Eli Zaretskii , Andrew Burgess Subject: [PATCHv3 1/2] gdb/amd64: Ignore zero sized fields when calling functions Date: Fri, 2 Mar 2018 20:09:48 +0000 Message-Id: In-Reply-To: References: In-Reply-To: References: <1b9ec42a-a0fd-667b-59a5-780e84cce451@simark.ca> X-IsSubscribed: yes In some cases passing an argument to a function on amd64, or attempting to fetch the return value, can trigger an assertion failure within GDB. An example of a type that would trigger such an error is: struct foo_t { long double a; struct { struct { /* Empty. */ } es1; } s1; }; GCC does permit empty structures, so we should probably support this. The test that exposes this bug is in the next commit along with the RiscV support. gdb/ChangeLog: * amd64-tdep.c (amd64_classify_aggregate): Ignore zero sized fields within aggregates. --- gdb/ChangeLog | 5 +++++ gdb/amd64-tdep.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 6b92c9244c6..07eef5ea9f0 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -601,8 +601,9 @@ amd64_classify_aggregate (struct type *type, enum amd64_reg_class theclass[2]) bitsize = TYPE_LENGTH (subtype) * 8; endpos = (TYPE_FIELD_BITPOS (type, i) + bitsize - 1) / 64; - /* Ignore static fields. */ - if (field_is_static (&TYPE_FIELD (type, i))) + /* Ignore static fields, or empty fields, for example nested + empty structures.*/ + if (field_is_static (&TYPE_FIELD (type, i)) || bitsize == 0) continue; gdb_assert (pos == 0 || pos == 1);