This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: set sysroot command on AIX has no effect.
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: sangamesh dot swamy at in dot ibm dot com (Sangamesh Mallayya)
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 7 Oct 2016 21:31:07 +0200 (CEST)
- Subject: Re: set sysroot command on AIX has no effect.
- Authentication-results: sourceware.org; auth=none
Sangamesh Mallaya wrote:
> Calling solib_find returning a prefixed sysroot path and the duplication
> can be avoided as you suggested.
> But calling solib_bfd_fopen after this is causing the assertion to fail on
> NULL path as solib_bfd_fopen doing xfree of pathname at the end.
Well, of course, you have to check for NULL. What I'm suggesting is to
use something along the lines of:
found_pathname = solib_find (filename, &found_file);
if (found_pathname == NULL)
// error handling
archive_bfd = solib_bfd_fopen (found_pathname, found_file);
where the code currently does:
archive_bfd = gdb_bfd_open (filename, gnutarget, -1);
if (archive_bfd == NULL)
// error handling
> + pathname = solib_find (filename, &found_file);
> + if (pathname == NULL)
> + perror_with_name (filename);
> archive_bfd = gdb_bfd_open (filename, gnutarget, -1);
> if (archive_bfd == NULL)
> {
This has a number of problems:
- you still use gdb_bfd_open with filename, which means it still won't
find the file (I assume you meant to use pathname?)
- if solib_find actually finds the file, "found_file" is an open file
descriptor, which the code now leaks
- actually, the pathname string now also leaks
- and finally, at the bottom:
object_bfd->filename = xstrdup (pathname);
you now miss the object file name (in parentheses), so
"info sharedlibrary" will no longer show it
Most of those should be fixed when using the approach above.
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU/Linux compilers and toolchain
Ulrich.Weigand@de.ibm.com