From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20775 invoked by alias); 17 Apr 2013 20:33:22 -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 20726 invoked by uid 89); 17 Apr 2013 20:33:22 -0000 X-Spam-SWARE-Status: No, score=-6.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 17 Apr 2013 20:33:21 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3HKXFCc008607 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 17 Apr 2013 16:33:15 -0400 Received: from host2.jankratochvil.net (ovpn-116-84.ams2.redhat.com [10.36.116.84]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r3HKXBVX002049 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 17 Apr 2013 16:33:14 -0400 Date: Thu, 18 Apr 2013 08:58:00 -0000 From: Jan Kratochvil To: Aleksandar Ristovski Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 4/8] Prepare linux_find_memory_regions_full & co. for move Message-ID: <20130417203311.GC2090@host2.jankratochvil.net> References: <1365521265-28870-1-git-send-email-ARistovski@qnx.com> <1366127096-5744-1-git-send-email-ARistovski@qnx.com> <1366127096-5744-5-git-send-email-ARistovski@qnx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1366127096-5744-5-git-send-email-ARistovski@qnx.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2013-04/txt/msg00550.txt.bz2 On Tue, 16 Apr 2013 17:44:52 +0200, Aleksandar Ristovski wrote: [...] > --- a/gdb/target.c > +++ b/gdb/target.c > @@ -3476,6 +3476,22 @@ target_fileio_close_cleanup (void *opaque) > target_fileio_close (fd, &target_errno); > } > > +typedef int (read_alloc_pread_ftype) (int handle, gdb_byte *read_buf, int len, > + ULONGEST offset, int *target_errno); This typedef is in the end duplicate both in target.c and in common/common-target.h. It should remain only in common/common-target.h. > + > +static read_alloc_pread_ftype target_fileio_read_alloc_1_pread; > + > +/* Helper for target_fileio_read_alloc_1 to make it interruptible. */ > + > +static int > +target_fileio_read_alloc_1_pread (int handle, gdb_byte *read_buf, int len, > + ULONGEST offset, int *target_errno) > +{ > + QUIT; > + > + return target_fileio_pread (handle, read_buf, len, offset, target_errno); > +} > + > /* Read target file FILENAME. Store the result in *BUF_P and > return the size of the transferred data. PADDING additional bytes are > available in *BUF_P. This is a helper function for [...] > @@ -3534,12 +3548,39 @@ target_fileio_read_alloc_1 (const char *filename, > { > buf_alloc *= 2; > buf = xrealloc (buf, buf_alloc); > + if (memory_to_free_ptr != NULL) > + *memory_to_free_ptr = buf; > } > - > - QUIT; > } > } > > +typedef LONGEST (read_stralloc_func_ftype) (const char *filename, > + gdb_byte **buf_p, int padding); This typedef is in the end duplicate both in target.c and in common/common-target.h. It should remain only in common/common-target.h. > + > +static read_stralloc_func_ftype target_fileio_read_alloc_1; > + > +static LONGEST > +target_fileio_read_alloc_1 (const char *filename, > + gdb_byte **buf_p, int padding) > +{ > + struct cleanup *close_cleanup; > + int fd, target_errno; > + void *memory_to_free = NULL; > + LONGEST retval; > + > + fd = target_fileio_open (filename, FILEIO_O_RDONLY, 0700, &target_errno); > + if (fd == -1) > + return -1; > + > + close_cleanup = make_cleanup (target_fileio_close_cleanup, &fd); > + > + make_cleanup (free_current_contents, &memory_to_free); > + retval = read_alloc (buf_p, fd, target_fileio_read_alloc_1_pread, padding, > + &memory_to_free); > + do_cleanups (close_cleanup); > + return retval; > +} > + > /* Read target file FILENAME. Store the result in *BUF_P and return > the size of the transferred data. See the declaration in "target.h" > function for more information about the return value. */ [...] Thanks, Jan