* declare canonicalize_file_name
@ 2002-03-14 13:28 Richard Henderson
2002-03-14 15:29 ` Andrew Cagney
0 siblings, 1 reply; 7+ messages in thread
From: Richard Henderson @ 2002-03-14 13:28 UTC (permalink / raw)
To: gdb-patches
GDB uses canonicalize_file_name if it detects it in libc,
but doesn't define _GNU_SOURCE to get it declared. This
results in the compiler thinking that the function returns
an integer, which results in the pointer value being
truncated on ia64.
I figured providing a declaration was safer than forcing
_GNU_SOURCE.
Ok?
r~
* configure.in (canonicalize_file_name): Look for declaration.
* configure, config.in: Rebuild.
* utils.c (canonicalize_file_name): Provide decl if required.
Index: configure.in
===================================================================
RCS file: /cvs/src/src/gdb/configure.in,v
retrieving revision 1.83
diff -c -p -d -r1.83 configure.in
*** configure.in 2002/03/06 21:16:00 1.83
--- configure.in 2002/03/14 21:24:49
*************** BFD_NEED_DECLARATION(free)
*** 241,247 ****
BFD_NEED_DECLARATION(strerror)
BFD_NEED_DECLARATION(strdup)
BFD_NEED_DECLARATION(strstr)
!
# The following save_state_t checkery is only necessary for HPUX
# versions earlier than 10.20. When those fade from memory, this
--- 241,247 ----
BFD_NEED_DECLARATION(strerror)
BFD_NEED_DECLARATION(strdup)
BFD_NEED_DECLARATION(strstr)
! BFD_NEED_DECLARATION(canonicalize_file_name)
# The following save_state_t checkery is only necessary for HPUX
# versions earlier than 10.20. When those fade from memory, this
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.68
diff -c -p -d -r1.68 utils.c
*** utils.c 2002/03/01 06:19:24 1.68
--- utils.c 2002/03/14 21:24:49
*************** extern PTR realloc ();
*** 81,86 ****
--- 81,91 ----
#ifdef NEED_DECLARATION_FREE
extern void free ();
#endif
+ /* Actually, we'll never have the decl, since we don't define _GNU_SOURCE. */
+ #if defined(HAVE_CANONICALIZE_FILE_NAME) \
+ && defined(NEED_DECLARATION_CANONICALIZE_FILE_NAME)
+ extern char *canonicalize_file_name (const char *);
+ #endif
#undef XMALLOC
#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: declare canonicalize_file_name
2002-03-14 13:28 declare canonicalize_file_name Richard Henderson
@ 2002-03-14 15:29 ` Andrew Cagney
2002-03-14 14:56 ` Richard Henderson
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Cagney @ 2002-03-14 15:29 UTC (permalink / raw)
To: Richard Henderson; +Cc: gdb-patches
> GDB uses canonicalize_file_name if it detects it in libc,
> but doesn't define _GNU_SOURCE to get it declared. This
> results in the compiler thinking that the function returns
> an integer, which results in the pointer value being
> truncated on ia64.
>
> I figured providing a declaration was safer than forcing
> _GNU_SOURCE.
I believe RichardE's fixed this (or will when he wakes up :-). GDB
should have been using realpath() in preference to
canonicalize_file_name() .
enjoy,
Andrew
(See gdb/409)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: declare canonicalize_file_name
2002-03-14 15:29 ` Andrew Cagney
@ 2002-03-14 14:56 ` Richard Henderson
2002-03-14 15:44 ` Andrew Cagney
0 siblings, 1 reply; 7+ messages in thread
From: Richard Henderson @ 2002-03-14 14:56 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
On Thu, Mar 14, 2002 at 05:33:29PM -0500, Andrew Cagney wrote:
> I believe RichardE's fixed this (or will when he wakes up :-). GDB
> should have been using realpath() in preference to
> canonicalize_file_name() .
The problem will still hold with canonicalize_file_name
should it be used.
Of course, since it's specific to glibc, and glibc also
provides realpath, it won't ever be used. Why not remove
support for it then?
r~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: declare canonicalize_file_name
2002-03-14 14:56 ` Richard Henderson
@ 2002-03-14 15:44 ` Andrew Cagney
2002-03-14 16:07 ` rth
2002-03-15 0:35 ` Alfred M. Szmidt
0 siblings, 2 replies; 7+ messages in thread
From: Andrew Cagney @ 2002-03-14 15:44 UTC (permalink / raw)
To: Richard Henderson, Richard Earnshaw; +Cc: gdb-patches
> On Thu, Mar 14, 2002 at 05:33:29PM -0500, Andrew Cagney wrote:
>
>> I believe RichardE's fixed this (or will when he wakes up :-). GDB
>> should have been using realpath() in preference to
>> canonicalize_file_name() .
>
>
> The problem will still hold with canonicalize_file_name
> should it be used.
>
> Of course, since it's specific to glibc, and glibc also
> provides realpath, it won't ever be used. Why not remove
> support for it then?
The call was only just added for the hurd :-( Hmm,
http://sources.redhat.com/ml/gdb-patches/2002-02/msg00631.html
Oops, ulgh! if RichardE tweeks to code (as I suggested) to simply prefer
realpath() it will break the hurd again. I think prefering realpath()
is correct (only use an obscure function when forced too) but that logic
is going to need to be scrambled a bit more :-(.
RichardE, I guess another re-think.
Andrew
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: declare canonicalize_file_name
2002-03-14 15:44 ` Andrew Cagney
@ 2002-03-14 16:07 ` rth
2002-03-14 16:27 ` Andrew Cagney
2002-03-15 0:35 ` Alfred M. Szmidt
1 sibling, 1 reply; 7+ messages in thread
From: rth @ 2002-03-14 16:07 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Richard Earnshaw, gdb-patches
On Thu, Mar 14, 2002 at 06:43:55PM -0500, Andrew Cagney wrote:
> Oops, ulgh! if RichardE tweeks to code (as I suggested) to simply prefer
> realpath() it will break the hurd again. I think prefering realpath()
> is correct (only use an obscure function when forced too) but that logic
> is going to need to be scrambled a bit more :-(.
What about something like this?
r~
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.68
diff -c -p -d -r1.68 utils.c
*** utils.c 2002/03/01 06:19:24 1.68
--- utils.c 2002/03/15 00:06:43
*************** extern PTR realloc ();
*** 81,86 ****
--- 81,91 ----
#ifdef NEED_DECLARATION_FREE
extern void free ();
#endif
+ /* Actually, we'll never have the decl, since we don't define _GNU_SOURCE. */
+ #if defined(HAVE_CANONICALIZE_FILE_NAME) \
+ && defined(NEED_DECLARATION_CANONICALIZE_FILE_NAME)
+ extern char *canonicalize_file_name (const char *);
+ #endif
#undef XMALLOC
#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
*************** string_to_core_addr (const char *my_stri
*** 2532,2551 ****
char *
gdb_realpath (const char *filename)
{
! #ifdef HAVE_CANONICALIZE_FILE_NAME
! return canonicalize_file_name (filename);
! #elif defined (HAVE_REALPATH)
! #if defined (PATH_MAX)
char buf[PATH_MAX];
! #elif defined (MAXPATHLEN)
char buf[MAXPATHLEN];
! #elif defined (HAVE_UNISTD_H) && defined(HAVE_ALLOCA)
char *buf = alloca ((size_t)pathconf ("/", _PC_PATH_MAX));
! #else
! #error "Neither PATH_MAX nor MAXPATHLEN defined"
! #endif
char *rp = realpath (filename, buf);
return xstrdup (rp ? rp : filename);
#else
return xstrdup (filename);
#endif
--- 2537,2560 ----
char *
gdb_realpath (const char *filename)
{
! #if defined(HAVE_REALPATH)
! # if defined (PATH_MAX)
char buf[PATH_MAX];
! # define USE_REALPATH
! # elif defined (MAXPATHLEN)
char buf[MAXPATHLEN];
! # define USE_REALPATH
! # elif defined (HAVE_UNISTD_H) && defined(HAVE_ALLOCA)
char *buf = alloca ((size_t)pathconf ("/", _PC_PATH_MAX));
! # define USE_REALPATH
! # endif
! #endif /* HAVE_REALPATH */
!
! #if defined(USE_REALPATH)
char *rp = realpath (filename, buf);
return xstrdup (rp ? rp : filename);
+ #elif defined(HAVE_CANONICALIZE_FILE_NAME)
+ return canonicalize_file_name (filename);
#else
return xstrdup (filename);
#endif
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: declare canonicalize_file_name
2002-03-14 16:07 ` rth
@ 2002-03-14 16:27 ` Andrew Cagney
0 siblings, 0 replies; 7+ messages in thread
From: Andrew Cagney @ 2002-03-14 16:27 UTC (permalink / raw)
To: rth; +Cc: Richard Earnshaw, gdb-patches
> On Thu, Mar 14, 2002 at 06:43:55PM -0500, Andrew Cagney wrote:
>
>> Oops, ulgh! if RichardE tweeks to code (as I suggested) to simply prefer
>> realpath() it will break the hurd again. I think prefering realpath()
>> is correct (only use an obscure function when forced too) but that logic
>> is going to need to be scrambled a bit more :-(.
>
>
> What about something like this?
Yes, lets see. Thanks!
Andrew
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: declare canonicalize_file_name
2002-03-14 15:44 ` Andrew Cagney
2002-03-14 16:07 ` rth
@ 2002-03-15 0:35 ` Alfred M. Szmidt
1 sibling, 0 replies; 7+ messages in thread
From: Alfred M. Szmidt @ 2002-03-15 0:35 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Richard Henderson, Richard Earnshaw, gdb-patches
* Andrew Cagney writes:
> The call was only just added for the hurd :-( Hmm,
> http://sources.redhat.com/ml/gdb-patches/2002-02/msg00631.html
This was added because realpath() is horribly broken, and that the Hurd
does not define any MAXPATHLEN/PATH_MAX, which in turn breaks realpath().
Which the old code depended on to be defined.
The only obscure function is realpath() that depends on the values of
MAXPATHLEN/PATH_MAX to be defined, which are not required by POSIX,
and on any system that actually provides canonicalize_file_name() it
should be used. Specially on GNU and GNU/Linux.
> Oops, ulgh! if RichardE tweeks to code (as I suggested) to simply
> prefer realpath() it will break the hurd again. I think prefering
> realpath() is correct (only use an obscure function when forced too)
> but that logic is going to need to be scrambled a bit more :-(.
The code that has been checked in now looks OK, other then the fact that
GNU/Linux will use the obscure function realpath().
--
Alfred M. Szmidt
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-03-15 8:35 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-14 13:28 declare canonicalize_file_name Richard Henderson
2002-03-14 15:29 ` Andrew Cagney
2002-03-14 14:56 ` Richard Henderson
2002-03-14 15:44 ` Andrew Cagney
2002-03-14 16:07 ` rth
2002-03-14 16:27 ` Andrew Cagney
2002-03-15 0:35 ` Alfred M. Szmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox