From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26814 invoked by alias); 20 May 2014 13:16:28 -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 26803 invoked by uid 89); 20 May 2014 13:16:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 May 2014 13:16:26 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4KDGNtb014674 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 20 May 2014 09:16:25 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s4KCe6u3031079; Tue, 20 May 2014 08:40:06 -0400 Message-ID: <537B4D25.3000303@redhat.com> Date: Tue, 20 May 2014 13:16:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Markus Metzger CC: gdb-patches@sourceware.org Subject: Re: [PATCH v2 3/3] btrace, vdso: add vdso target sections References: <1400587236-18836-1-git-send-email-markus.t.metzger@intel.com> <1400587236-18836-3-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1400587236-18836-3-git-send-email-markus.t.metzger@intel.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-05/txt/msg00416.txt.bz2 Thanks. On 05/20/2014 01:00 PM, Markus Metzger wrote: > @@ -92,6 +92,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, > struct section_addr_info *sai; > unsigned int i; > struct cleanup *cleanup; > + struct target_section *sections, *sections_end, *tsec; > > if (bfd_get_flavour (templ) != bfd_target_elf_flavour) > error (_("add-symbol-file-from-memory not supported for this target")); > @@ -131,6 +132,22 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, > from_tty ? SYMFILE_VERBOSE : 0, > sai, OBJF_SHARED, NULL); > > + sections = NULL; > + sections_end = NULL; > + make_cleanup (xfree, sections); This will always xfree NULL. You either want: make_cleanup (free_current_contents, §ions); or move the cleanup to within the if/then block. You also need to make sure to discard the cleanup on success. Or, better yet, not install a cleanup at all? build_section_table allocates the memory, and then the array is passed directly to add_target_sections, which can be seen as a transfer of ownership. If something throws after that call, we don't want the sections be be simply xfree'd as that'd leave dangling pointers in the target sections table. > + > + if (build_section_table (nbfd, §ions, §ions_end) == 0) > + { > + /* Adjust the target section addresses by the load address. */ > + for (tsec = sections; tsec != sections_end; ++tsec) > + { > + tsec->addr += loadbase; > + tsec->endaddr += loadbase; > + } > + > + add_target_sections (&nbfd, sections, sections_end); > + } > + > /* This might change our ideas about frames already looked at. */ > reinit_frame_cache (); > +# capture the disassembly of gettimeofday while live debugging > +set live_gettimeofday [capture_command_output "disassemble gettimeofday" ""] > + > +# trace the test code > +gdb_test_no_output "record btrace" > +gdb_test "next" "main\.2.*" > + > +# capture the disassembly of gettimeofday while replaying > +gdb_test "record goto begin" "main\.1.*" > +set replay_gettimeofday [capture_command_output "disassemble gettimeofday" ""] I think these two capture_command_output calls generate duplicate gdb.sum output ? That's why I had with_test_prefix in my suggestion. -- Pedro Alves