From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 103109 invoked by alias); 9 Mar 2016 18:09:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 103091 invoked by uid 89); 9 Mar 2016 18:09:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 spammy=Jon, Turney, turney, sop X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 09 Mar 2016 18:09:07 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 4F8FC19CF3B; Wed, 9 Mar 2016 18:09:06 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u29I95A8007847; Wed, 9 Mar 2016 13:09:05 -0500 Subject: Re: [PATCH] Better handling for realpath() failures in windows_make_so() on Cygwin To: Jon Turney , gdb-patches@sourceware.org References: <1453305146-7364-1-git-send-email-jon.turney@dronecode.org.uk> <569FB386.4010903@redhat.com> <56E06222.9010909@dronecode.org.uk> From: Pedro Alves Message-ID: <56E066C1.3030109@redhat.com> Date: Wed, 09 Mar 2016 18:09:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <56E06222.9010909@dronecode.org.uk> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-03/txt/msg00146.txt.bz2 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