This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Use exec_file_find to prepend gdb_sysroot in follow_exec
- From: Gary Benson <gbenson at redhat dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 28 Apr 2015 12:29:12 +0100
- Subject: Re: [PATCH] Use exec_file_find to prepend gdb_sysroot in follow_exec
- Authentication-results: sourceware.org; auth=none
- References: <1429277318-26646-1-git-send-email-gbenson at redhat dot com> <553E5CF7 dot 7090309 at redhat dot com>
Pedro Alves wrote:
> On 04/17/2015 02:28 PM, Gary Benson wrote:
> > This commit updates follow_exec to use exec_file_find to prefix
> > the new executable's filename with gdb_sysroot rather than doing
> > it longhand.
> >
> > Built and regtested on RHEL6.6 x86_64.
> >
> > Ok to commit?
>
> OK.
Thanks, I pushed it.
> > - if (gdb_sysroot && *gdb_sysroot)
> > + if (gdb_sysroot != NULL && *gdb_sysroot != '\0')
> > {
> > - char *name = alloca (strlen (gdb_sysroot)
> > - + strlen (execd_pathname)
> > - + 1);
> > + int fd = -1;
> > + char *name;
> >
> > - strcpy (name, gdb_sysroot);
> > - strcat (name, execd_pathname);
> > - execd_pathname = name;
> > + name = exec_file_find (execd_pathname, &fd);
> > + if (fd >= 0)
> > + close (fd);
>
> We now have at least two places that need to remember to call close.
> IWBN if we hid that close in a exec_file_find variant, so that
> callers didn't have to recall to do it. Maybe rename exec_file_find
> to (e.g.) exec_file_find_fd and reuse the exec_file_find name, even.
Good shout. How about I fix solib_find_1 to accept fd == NULL, and
put the closing logic in there? That would work for solib_find too
then (I'm not sure if there are any "solib_find; close" places in
GDB but I'll look.)
Cheers,
Gary
--
http://gbenson.net/