From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v12 10/32] Code cleanup: Add enum for openp_flags
Date: Fri, 21 Aug 2015 21:21:00 -0000 [thread overview]
Message-ID: <20150821212129.6673.53596.stgit@host1.jankratochvil.net> (raw)
In-Reply-To: <20150821212006.6673.35100.stgit@host1.jankratochvil.net>
Hi,
it is for many reasons better, in C++ it could be even type safe.
Jan
gdb/ChangeLog
2015-08-18 Jan Kratochvil <jan.kratochvil@redhat.com>
* 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;
next prev parent reply other threads:[~2015-08-21 21:21 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-21 21:20 [PATCH v12 00/32] Validate binary before use Jan Kratochvil
2015-08-21 21:20 ` [PATCH v12 01/32] Create empty common/linux-maps.[ch] and common/target-utils.[ch] Jan Kratochvil
2015-08-21 21:20 ` [PATCH v12 03/32] Prepare linux_find_memory_regions_full & co. for move Jan Kratochvil
2015-08-21 21:20 ` [PATCH v12 02/32] Move gdb_regex* to common/ Jan Kratochvil
2015-08-21 21:20 ` [PATCH v12 04/32] Move linux_find_memory_regions_full & co Jan Kratochvil
2015-08-21 21:20 ` [PATCH v12 05/32] gdbserver build-id attribute generator Jan Kratochvil
2015-08-22 7:17 ` Eli Zaretskii
2015-08-21 21:21 ` [PATCH v12 11/32] Code cleanup: Remove OPF_RETURN_REALPATH Jan Kratochvil
2015-08-21 21:21 ` [PATCH v12 07/32] Code cleanup: Make solib_find_1 variable const Jan Kratochvil
2015-08-21 21:21 ` [PATCH v12 12/32] Code cleanup: Remove openp parameter mode Jan Kratochvil
2015-08-21 21:21 ` [PATCH v12 06/32] Validate symbol file using build-id Jan Kratochvil
2015-08-22 7:23 ` Eli Zaretskii
2015-08-22 19:19 ` Jan Kratochvil
2015-08-21 21:21 ` Jan Kratochvil [this message]
2015-08-21 21:21 ` [PATCH v12 08/32] Permit multiple sysroot directories Jan Kratochvil
2015-08-22 7:31 ` Eli Zaretskii
2015-08-22 19:24 ` Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 20/32] symfile_bfd_open: Make it use openp_bfd() Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 14/32] Provide new gdb_bfd_open_from_target Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 09/32] Change sysroot to ":target:" Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 17/32] Add file_location utility functions Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 16/32] gdb_bfd_open_from_target: Optionally do not close fd Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 18/32] Refactor openp() to return file_location Jan Kratochvil
2015-08-25 19:07 ` [PATCH v13 " Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 15/32] gdb_bfd_open_from_target: Support real fd Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 13/32] Code cleanup: openp parameter filename_opened is never NULL Jan Kratochvil
2015-08-21 21:22 ` [PATCH v12 19/32] solib_find: Make it use file_location Jan Kratochvil
2015-08-21 21:23 ` [PATCH v12 25/32] Verify the build-id Jan Kratochvil
2015-08-21 21:23 ` [PATCH v12 26/32] solib_bfd_open: Optimize opening twice Jan Kratochvil
2015-08-21 21:23 ` [PATCH v12 27/32] build_id_verify: Make it more verbose Jan Kratochvil
2015-08-21 21:23 ` [PATCH v12 22/32] Add dummy build-id params to prototypes Jan Kratochvil
2015-08-21 21:23 ` [PATCH v12 24/32] solib_find: Search also by build-id Jan Kratochvil
2015-08-21 21:23 ` [PATCH v12 23/32] build_id_to_bfd: Make it return file_location Jan Kratochvil
2015-08-21 21:23 ` [PATCH v12 21/32] build_id_to_debug_bfd: Make it also non-.debug capable Jan Kratochvil
2015-08-21 21:24 ` [PATCH v12 31/32] Make only user-specified executable and symbol filenames sticky Jan Kratochvil
2015-08-21 21:24 ` [PATCH v12 30/32] Code cleanup: New hex2bin_allocate() Jan Kratochvil
2015-08-21 21:24 ` [PATCH v12 32/32] Support build-id for main executables Jan Kratochvil
2015-08-21 21:24 ` [PATCH v12 29/32] testcase: Test also locating shlibs by build-id Jan Kratochvil
2015-08-21 21:24 ` [PATCH v12 28/32] Tests for validate symbol file using build-id Jan Kratochvil
2015-09-02 3:57 ` [PATCH v12 00/32] Validate binary before use Doug Evans
2015-09-02 7:41 ` Jan Kratochvil
2015-09-02 14:58 ` Doug Evans
2015-09-02 15:14 ` Jan Kratochvil
2015-09-02 15:22 ` Doug Evans
2015-09-02 19:12 ` Jan Kratochvil
2015-09-15 1:37 ` Doug Evans
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=20150821212129.6673.53596.stgit@host1.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
/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