public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: sangamesh.swamy@in.ibm.com (Sangamesh Mallayya)
Cc: gdb-patches@sourceware.org
Subject: Re: set sysroot command on AIX has no effect.
Date: Fri, 07 Oct 2016 19:31:00 -0000	[thread overview]
Message-ID: <20161007193107.9C39210C1FE@oc8523832656.ibm.com> (raw)
In-Reply-To: <OFD72EBFAF.9D379364-ON65258042.0048192D-65258042.00492DBD@notes.na.collabserv.com> from "Sangamesh Mallayya" at Oct 04, 2016 06:49:18 PM

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

  reply	other threads:[~2016-10-07 19:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-13  9:05 Sangamesh Mallayya
2016-09-29 15:33 ` Ulrich Weigand
2016-09-30 14:15   ` Sangamesh Mallayya
2016-09-30 14:38     ` Ulrich Weigand
2016-10-04 13:19       ` Sangamesh Mallayya
2016-10-07 19:31         ` Ulrich Weigand [this message]
2016-10-08 13:15           ` Sangamesh Mallayya
2016-10-08 14:38             ` Ulrich Weigand
2016-10-10 12:11               ` Sangamesh Mallayya
2016-10-10 16:29                 ` Ulrich Weigand
2016-10-11  7:17                   ` Ulrich Weigand
2016-10-13 13:42                     ` Sangamesh Mallayya
2016-10-13 14:03                       ` Ulrich Weigand
2016-10-13 17:44                         ` Sangamesh Mallayya
2016-10-14 13:13                           ` Ulrich Weigand
     [not found] <OFBAE0EEF6.511F8BA2-ON6525802D.00305F69-6525802D.0031DA2D@LocalDomain>
2016-09-27 11:39 ` Sangamesh Mallayya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161007193107.9C39210C1FE@oc8523832656.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sangamesh.swamy@in.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).