From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27433 invoked by alias); 24 Jun 2014 08:51:23 -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 27422 invoked by uid 89); 24 Jun 2014 08:51:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga09.intel.com Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 24 Jun 2014 08:51:21 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 24 Jun 2014 01:45:52 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 24 Jun 2014 01:51:14 -0700 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s5O8pDsE005694; Tue, 24 Jun 2014 09:51:13 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id s5O8pCoM025570; Tue, 24 Jun 2014 10:51:12 +0200 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id s5O8pCoG025566; Tue, 24 Jun 2014 10:51:12 +0200 From: Markus Metzger To: palves@redhat.com Cc: gdb-patches@sourceware.org Subject: [PATCH v2 1/3] make_corefile_notes: have caller free returned memory Date: Tue, 24 Jun 2014 08:51:00 -0000 Message-Id: <1403599872-25299-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2014-06/txt/msg00835.txt.bz2 The various make_corefile_notes implementations for gdbarch as well as target currently make an xfree cleanup on the data they return. This causes problems when trying to put a TRY_CATCH around the make_corefile_notes call. Specifically, we get a stale cleanup error in restore_my_cleanups. Omit the make_cleanup and have the caller free the memory. 2014-06-24 Markus Metzger * fbsd-nat.c (fbsd_make_corefile_notes): Remove make_cleanup call. * gcore.c (write_gcore_file): Free memory returned from make_corefile_notes. * linux-tdep.c (linux_make_corefile_notes): Remove make_cleanup call. * procfs.c (procfs_make_note_section): Remove make_cleanup call. --- gdb/fbsd-nat.c | 1 - gdb/gcore.c | 5 +++++ gdb/linux-tdep.c | 1 - gdb/procfs.c | 1 - 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 9f30edf..4e115b2 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -214,6 +214,5 @@ fbsd_make_corefile_notes (struct target_ops *self, bfd *obfd, int *note_size) fname, psargs); } - make_cleanup (xfree, note_data); return note_data; } diff --git a/gdb/gcore.c b/gdb/gcore.c index e225080..7a4ded7 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -68,6 +68,7 @@ create_gcore_bfd (const char *filename) void write_gcore_file (bfd *obfd) { + struct cleanup *cleanup; void *note_data = NULL; int note_size = 0; asection *note_sec = NULL; @@ -84,6 +85,8 @@ write_gcore_file (bfd *obfd) if (note_data == NULL || note_size == 0) error (_("Target does not support core file generation.")); + cleanup = make_cleanup (xfree, note_data); + /* Create the note section. */ note_sec = bfd_make_section_anyway_with_flags (obfd, "note0", SEC_HAS_CONTENTS @@ -104,6 +107,8 @@ write_gcore_file (bfd *obfd) /* Write out the contents of the note section. */ if (!bfd_set_section_contents (obfd, note_sec, note_data, 0, note_size)) warning (_("writing note section (%s)"), bfd_errmsg (bfd_get_error ())); + + do_cleanups (cleanup); } static void diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index ca19cf4..d0f1106 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1502,7 +1502,6 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size, note_data = linux_make_mappings_corefile_notes (gdbarch, obfd, note_data, note_size); - make_cleanup (xfree, note_data); return note_data; } diff --git a/gdb/procfs.c b/gdb/procfs.c index cbb44ce..4caaf7b 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -5522,7 +5522,6 @@ procfs_make_note_section (struct target_ops *self, bfd *obfd, int *note_size) xfree (auxv); } - make_cleanup (xfree, note_data); return note_data; } #else /* !Solaris */ -- 1.8.3.1