From patchwork Thu Apr 13 07:26:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 20018 Received: (qmail 118764 invoked by alias); 13 Apr 2017 07:26:20 -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 118624 invoked by uid 89); 13 Apr 2017 07:26:20 -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=Hx-spam-relays-external:74.125.82.67, H*RU:74.125.82.67 X-HELO: mail-wm0-f67.google.com Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Apr 2017 07:26:18 +0000 Received: by mail-wm0-f67.google.com with SMTP id d79so10798634wmi.2 for ; Thu, 13 Apr 2017 00:26:19 -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=9x28fTjphlkn5NLK9cfyjA+SVdsvBlWOeizln8olVjs=; b=djs9tSFm/B9DkEkdJ7KwYDQ2tGSjfBfGq3e3uXU4MK1o6shxrWRKUh/u0/l8SfnvgK TGDXSqIosGMhsxmF88bIyGVA1RYTO+whlvXyDeE9XAbnk0/V0qb5awgaQ/NTnk41GnoL uGeDeAtxddiu1FfzHWNeRnCke1MSo8gZ0n4sT3tJCVlKey2lVlWcAaLF8gXdkc/y9h5T VSXHbj8sJ7HCuy3hFrqp0tCXzjXb+rIgD8jgZteS0WK3wjIN5YbZiCT/9AGP0eLbvbV2 O/z9yMgAaHDippH1E0aOK5xJOTBCSbvqwsMB8nzqLzjb/CPeJrbI/cMZIf5SZpyUtCty +6zA== X-Gm-Message-State: AN3rC/5iO9SElSLc7DIv4T1shDmTRMhm2Px/WCat+b8YmUbX5w8tZeta fVdqSPvxbDNUeu5K X-Received: by 10.28.148.143 with SMTP id w137mr22861440wmd.72.1492068378074; Thu, 13 Apr 2017 00:26:18 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com ([194.214.185.158]) by smtp.gmail.com with ESMTPSA id e21sm8719934wmd.3.2017.04.13.00.26.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Apr 2017 00:26:17 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH OBV 2/9] XCNEW gdbarch_tdep in rl78 and rx Date: Thu, 13 Apr 2017 08:26:06 +0100 Message-Id: <1492068373-4916-3-git-send-email-yao.qi@linaro.org> In-Reply-To: <1492068373-4916-1-git-send-email-yao.qi@linaro.org> References: <1492068373-4916-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes "struct gdbarch_tdep" is XNEW'ed in rl78 and rx, so the memory is not cleared. As the result, tdep->rl78_psw_type may be never initialized properly. struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (tdep->rl78_psw_type == NULL) { tdep->rl78_psw_type = arch_flags_type (gdbarch, "builtin_type_rl78_psw", 1); The bug is found by my unit test in the following patch. gdb: 2017-04-12 Yao Qi * rl78-tdep.c (rl78_gdbarch_init): Use XCNEW instead of XNEW. * rx-tdep.c (rx_gdbarch_init): Likewise. --- gdb/rl78-tdep.c | 2 +- gdb/rx-tdep.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c index 9f2193e..307a760 100644 --- a/gdb/rl78-tdep.c +++ b/gdb/rl78-tdep.c @@ -1412,7 +1412,7 @@ rl78_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* None found, create a new architecture from the information provided. */ - tdep = XNEW (struct gdbarch_tdep); + tdep = XCNEW (struct gdbarch_tdep); gdbarch = gdbarch_alloc (&info, tdep); tdep->elf_flags = elf_flags; diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c index 7b66d6d..1a3d103 100644 --- a/gdb/rx-tdep.c +++ b/gdb/rx-tdep.c @@ -1101,7 +1101,7 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* None found, create a new architecture from the information provided. */ - tdep = XNEW (struct gdbarch_tdep); + tdep = XCNEW (struct gdbarch_tdep); gdbarch = gdbarch_alloc (&info, tdep); tdep->elf_flags = elf_flags;