diff options
author | Sergio Durigan Junior <sergiodj@redhat.com> | 2018-09-12 13:16:02 -0400 |
---|---|---|
committer | Sergio Durigan Junior <sergiodj@redhat.com> | 2018-09-12 13:58:30 -0400 |
commit | 3c025cfe5efc44eb4dfb03b53dca28e75096dd1e (patch) | |
tree | 5c15b2fa8fd56bf90f4162dbff83b7161c5fa607 /gdb/common/common-utils.c | |
parent | 3e68067fb2d59ea93ea95d713a6c27b635332912 (diff) | |
download | binutils-3c025cfe5efc44eb4dfb03b53dca28e75096dd1e.zip binutils-3c025cfe5efc44eb4dfb03b53dca28e75096dd1e.tar.gz binutils-3c025cfe5efc44eb4dfb03b53dca28e75096dd1e.tar.bz2 |
Move 'is_regular_file' from common-utils.c to filestuff.c
There is no reason for 'is_regular_file' to be in common-utils.c; it
belongs to 'filestuff.c'. This commit moves the function definition
and its prototype to the appropriate files.
The motivation behind this move is a failure that happens on certain
cross-compilation environments when compiling the IPA library, due to
the way gnulib probes the need for a 'stat' call replacement. Because
configure checks when cross-compiling are more limited, gnulib decides
that it needs to substitute the 'stat' calls its own 'rpl_stat';
however, the IPA library doesn't link with gnulib, which leads to an
error when compiling 'common-utils.c':
...
/opt/x86-core2--musl--bleeding-edge-2018.09-1/bin/i686-buildroot-linux-musl-g++ -shared -fPIC -Wl,--soname=libinproctrace.so -Wl,--no-undefined -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -I. -I. -I./../common -I./../regformats -I./.. -I./../../include -I./../gnulib/import -Ibuild-gnulib-gdbserver/import -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-narrowing -Wno-error=maybe-uninitialized -DGDBSERVER \
-Wl,--dynamic-list=./proc-service.list -o libinproctrace.so ax-ipa.o common-utils-ipa.o errors-ipa.o format-ipa.o print-utils-ipa.o regcache-ipa.o remote-utils-ipa.o rsp-low-ipa.o tdesc-ipa.o tracepoint-ipa.o utils-ipa.o vec-ipa.o linux-i386-ipa.o linux-x86-tdesc-ipa.o arch/i386-ipa.o -ldl -pthread
/opt/x86-core2--musl--bleeding-edge-2018.09-1/lib/gcc/i686-buildroot-linux-musl/8.2.0/../../../../i686-buildroot-linux-musl/bin/ld: common-utils-ipa.o: in function `is_regular_file(char const*, int*)':
common-utils.c:(.text+0x695): undefined reference to `rpl_stat'
collect2: error: ld returned 1 exit status
Makefile:413: recipe for target 'libinproctrace.so' failed
make[1]: *** [libinproctrace.so] Error 1
...
More details can also be found at:
https://sourceware.org/ml/gdb-patches/2018-09/msg00304.html
The most simple fix for this problem is to move 'is_regular_file' to
'filestuff.c', which is not used by IPA. This ends up making the
files more logically organized as well, since 'is_regular_file' is a
file operation.
No regressions found.
gdb/ChangeLog:
2018-09-12 Sergio Durigan Junior <sergiodj@redhat.com>
* common/common-utils.c: Don't include '<sys/stat.h>'.
(is_regular_file): Move to...
* common/filestuff.c (is_regular_file): ... here.
* common/common-utils.h (is_regular_file): Move to...
* common/filestuff.h (is_regular_file): ... here.
Diffstat (limited to 'gdb/common/common-utils.c')
-rw-r--r-- | gdb/common/common-utils.c | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/gdb/common/common-utils.c b/gdb/common/common-utils.c index 8d839d1..24b3936 100644 --- a/gdb/common/common-utils.c +++ b/gdb/common/common-utils.c @@ -20,7 +20,6 @@ #include "common-defs.h" #include "common-utils.h" #include "host-defs.h" -#include <sys/stat.h> #include <ctype.h> /* The xmalloc() (libiberty.h) family of memory management routines. @@ -412,37 +411,6 @@ stringify_argv (const std::vector<char *> &args) /* See common/common-utils.h. */ -bool -is_regular_file (const char *name, int *errno_ptr) -{ - struct stat st; - const int status = stat (name, &st); - - /* Stat should never fail except when the file does not exist. - If stat fails, analyze the source of error and return true - unless the file does not exist, to avoid returning false results - on obscure systems where stat does not work as expected. */ - - if (status != 0) - { - if (errno != ENOENT) - return true; - *errno_ptr = ENOENT; - return false; - } - - if (S_ISREG (st.st_mode)) - return true; - - if (S_ISDIR (st.st_mode)) - *errno_ptr = EISDIR; - else - *errno_ptr = EINVAL; - return false; -} - -/* See common/common-utils.h. */ - ULONGEST align_up (ULONGEST v, int n) { |