Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Jon Turney <jon.turney@dronecode.org.uk>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Better handling for realpath() failures in windows_make_so() on Cygwin
Date: Wed, 09 Mar 2016 18:09:00 -0000	[thread overview]
Message-ID: <56E066C1.3030109@redhat.com> (raw)
In-Reply-To: <56E06222.9010909@dronecode.org.uk>

On 03/09/2016 05:49 PM, Jon Turney wrote:
> On 20/01/2016 16:19, Pedro Alves wrote:
>> #define SO_NAME_MAX_PATH_SIZE 512       /* FIXME: Should be dynamic */
>>
>> How about just removing the limit altogether?
>>
>> Basically, make struct so_list::so_original_name and
>> struct so_list::so_name pointers instead of arrays?
> 
> I'm sorry, while that would be nice to have, that's not a project that I 
> can take on currently.
> 
> In the meantime, please consider approving this patch, or tell me what I 
> can do to make it acceptable, since it does fix an actual problem that 
> affects some users.

It's not a big change, I think.  Instead of strcpy'ing strings into
so->so_original_name and so->so_name, we'd just xfree the old
strings and xstrdup new ones.  And then in free_so, we xfree 
so->so_original_name and so->so_name.  All other code that refers to 
so->so_original_name / so->so_name should not need to change, as arrays
decay to pointers anyway.

If you want to avoid convert all targets at once, it's still quite
doable.  Add a new make_so_list() to solib.c that just does:

struct so_list *
make_so_list (void)
{
  struct so_list *new_solib = XCNEW (struct so_list);
  new_solib->so_name = xcalloc (1, SO_NAME_MAX_PATH_SIZE);
  new_solib->so_original_name = xcalloc (1, SO_NAME_MAX_PATH_SIZE);
  return new_solib;
}

and do a trivial replace of these XCNEW/XNEW by a call to make_so_list:

solib-aix.c:      struct so_list *new_solib = XCNEW (struct so_list);
solib-dsbt.c:     sop = XCNEW (struct so_list);
solib-frv.c:      sop = XCNEW (struct so_list);
solib-spu.c:              newobj = XCNEW (struct so_list);
solib-spu.c:      newobj = XCNEW (struct so_list);
solib-svr4.c:  newobj = XCNEW (struct so_list);
solib-svr4.c:  new_elem = XCNEW (struct so_list);
solib-svr4.c:  newobj = XCNEW (struct so_list);
solib-svr4.c:      newobj = XCNEW (struct so_list);
solib-target.c:      new_solib = XCNEW (struct so_list);
windows-nat.c:  so = XCNEW (struct so_list);
solib-svr4.c:      newobj = XNEW (struct so_list);

Then you can adjust the windows-nat.c solib-target.c files (the ones
Windows uses), and leave the rest to someone else (though I imagine 
converting all others would be trivial too).

Once all are converted, we can remove the initial allocations in
make_so_list.

Thanks,
Pedro Alves


  reply	other threads:[~2016-03-09 18:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-20 15:54 Jon Turney
2016-01-20 16:19 ` Pedro Alves
2016-03-09 17:49   ` Jon Turney
2016-03-09 18:09     ` Pedro Alves [this message]
2024-03-21  6:53 Orgad Shaneh
2024-03-21  7:22 ` Orgad Shaneh
2024-03-21 15:04   ` Tom Tromey
2024-03-21 14:45 ` Jon Turney
2024-03-21 16:13   ` Pedro Alves
2024-03-21 16:31     ` Orgad Shaneh
2024-03-22 19:07       ` Pedro Alves

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=56E066C1.3030109@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jon.turney@dronecode.org.uk \
    /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