From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 107256 invoked by alias); 21 Aug 2015 21:21:36 -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 107181 invoked by uid 89); 21 Aug 2015 21:21:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 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; Fri, 21 Aug 2015 21:21:32 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id F369D8E933 for ; Fri, 21 Aug 2015 21:21:30 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-22.ams2.redhat.com [10.36.116.22]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7LLLT22019969 for ; Fri, 21 Aug 2015 17:21:30 -0400 Subject: [PATCH v12 10/32] Code cleanup: Add enum for openp_flags From: Jan Kratochvil To: gdb-patches@sourceware.org Date: Fri, 21 Aug 2015 21:21:00 -0000 Message-ID: <20150821212129.6673.53596.stgit@host1.jankratochvil.net> In-Reply-To: <20150821212006.6673.35100.stgit@host1.jankratochvil.net> References: <20150821212006.6673.35100.stgit@host1.jankratochvil.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00598.txt.bz2 Hi, it is for many reasons better, in C++ it could be even type safe. Jan gdb/ChangeLog 2015-08-18 Jan Kratochvil * cli/cli-cmds.c (find_and_open_script): Use enum openp_flags for search_flags. * defs.h (OPF_TRY_CWD_FIRST, OPF_SEARCH_IN_PATH, OPF_RETURN_REALPATH): Wrap them to a new ... (enum openp_flags): ... enum. (openp): Update prototype. * dwarf2read.c (try_open_dwop_file): Use enum openp_flags for flags. * source.c (openp): Update opts parameter type. Move out OPF_* comments. --- 0 files changed diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index bcd7802..a5a4c7c 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -500,7 +500,7 @@ find_and_open_script (const char *script_file, int search_path, char *file; int fd; struct cleanup *old_cleanups; - int search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH; + enum openp_flags search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH; file = tilde_expand (script_file); old_cleanups = make_cleanup (xfree, file); diff --git a/gdb/defs.h b/gdb/defs.h index f4951ab..3d248f6 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -321,11 +321,25 @@ extern const char *pc_prefix (CORE_ADDR); /* From source.c */ /* See openp function definition for their description. */ -#define OPF_TRY_CWD_FIRST 0x01 -#define OPF_SEARCH_IN_PATH 0x02 -#define OPF_RETURN_REALPATH 0x04 +enum openp_flags +{ + /* Try to open ./STRING before searching PATH (ie pretend the first + element of PATH is "."). This also indicates that, unless + OPF_SEARCH_IN_PATH is also specified, a slash in STRING disables + searching of the path (this is so that "exec-file ./foo" or + "symbol-file ./foo" insures that you get that particular version of + foo or an error message). */ + OPF_TRY_CWD_FIRST = (1 << 0), + + /* Absolute names will also be searched in path (we usually want this + for source files but not for executables). */ + OPF_SEARCH_IN_PATH = (1 << 1), + + /* See openp, to be removed. */ + OPF_RETURN_REALPATH = (1 << 2), +}; -extern int openp (const char *, int, const char *, int, char **); +extern int openp (const char *, enum openp_flags, const char *, int, char **); extern int source_full_path_of (const char *, char **); diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 0c61df7..23b60f9 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -10450,7 +10450,8 @@ static bfd * try_open_dwop_file (const char *file_name, int is_dwp, int search_cwd) { bfd *sym_bfd; - int desc, flags; + int desc; + enum openp_flags flags; char *absolute_name; /* Blech. OPF_TRY_CWD_FIRST also disables searching the path list if FILE_NAME contains a '/'. So we can't use it. Instead prepend "." diff --git a/gdb/source.c b/gdb/source.c index 4cd3046..888ed2b 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -743,17 +743,6 @@ dirnames_to_char_ptr_vec_target_exc (const char *string) OPTS specifies the function behaviour in specific cases. - If OPF_TRY_CWD_FIRST, try to open ./STRING before searching PATH. - (ie pretend the first element of PATH is "."). This also indicates - that, unless OPF_SEARCH_IN_PATH is also specified, a slash in STRING - disables searching of the path (this is so that "exec-file ./foo" or - "symbol-file ./foo" insures that you get that particular version of - foo or an error message). - - If OPTS has OPF_SEARCH_IN_PATH set, absolute names will also be - searched in path (we usually want this for source files but not for - executables). - If FILENAME_OPENED is non-null, set it to a newly allocated string naming the actual file opened (this string will always start with a "/"). We have to take special pains to avoid doubling the "/" between the directory @@ -771,7 +760,7 @@ dirnames_to_char_ptr_vec_target_exc (const char *string) /* >>>> This should only allow files of certain types, >>>> eg executable, non-directory. */ int -openp (const char *path, int opts, const char *string, +openp (const char *path, enum openp_flags opts, const char *string, int mode, char **filename_opened) { int fd;