Mirror of the gdb-patches mailing list
 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: Sat, 08 Oct 2016 14:38:00 -0000	[thread overview]
Message-ID: <20161008143755.10ABE10BEE3@oc8523832656.ibm.com> (raw)
In-Reply-To: <OF848F0736.112F16BD-ON65258046.00477D54-65258046.0048C0EC@notes.na.collabserv.com> from "Sangamesh Mallayya" at Oct 08, 2016 06:44:40 PM

Sangamesh Mallayya wrote:

>> 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);
>
>Yes, i did try these steps. But this won't set the sysroot path as we 
>intend to.
>The final object filename we want is the one returned from solib_find, 
>which is a sysroot prefixed pathname.
>After solib_bfd_fopen call we can't refer to found_pathname as it's been 
>freed in solib_bfd_fopen at the end, and assertion failure later.

Well, if you want to reuse the found_pathname, you'll just have to
duplicate it (there's already a call to xstrdup later in the function,
you may have to move it earlier).

>> > +   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?)
>
>pathname we get is something like "/usr/lib/libc.a(shr.o)", Offcourse 
>their is no such file with this pathname in the system.
>So we set a filename as "/usr/lib/libc.a" after separating member name 
>from actual file and gdb_bfd_open does find the file and return it's bfd.
>Here if we pass the path returned from solib_find to gdb_bfd_open instead 
>of filename then no issue is seen.

My point was, the code as shown above does *not* pass the path returned
from solib_find to gdb_bfd_open!  The path returned from solib_find is
assigned to "pathname" (overriding the value pathname that was input to
the function), but then gdb_bfd_open is still called with "filename".

>I think, better we use found_pathname variable to store returned value 
>from solib_find instead of using existing pathname variable to avoid 
>confusion.
>And may assign object filename as "object_bfd->filename = xstrdup 
>(found_pathname);" ?

Agreed (see above).  However, note that this will *not* contain the
object name in parentheses.  For example, if you initially get a
pathname of:
  /usr/lib/libc.a(shr.o)
Then you separate out the filename into:
  /usr/lib/libc.a
Then you pass this to solib_find and get a full name including sysroot:
  /path/to/sysroot/usr/lib/libc.a
But what you probably want to use as name in the final solib object is:
  /path/to/sysroot/usr/lib/libc.a(shr.o)

My point was that in order to get this, you'll have to append the
"(shr.o)" back on to the result you got from solib_find.

>The only problem i think if we use solib_find without using 
>solib_bfd_fopen is found_file descriptor.
>Let me know your view.

Please do use the pair of solib_find / solib_bfd_fopen; they were
designed to be used with each other, that's why they have the
interface they do.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com


  reply	other threads:[~2016-10-08 14:38 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
2016-10-08 13:15           ` Sangamesh Mallayya
2016-10-08 14:38             ` Ulrich Weigand [this message]
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=20161008143755.10ABE10BEE3@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