This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: set sysroot command on AIX has no effect.

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.


  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]