* [PATCH] Use enum flags for flags passed to openp
@ 2018-02-13 2:31 Simon Marchi
2018-02-13 16:51 ` Yao Qi
0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2018-02-13 2:31 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
gdb/ChangeLog:
* defs.h (enum openp_flags): New enum.
(OPF_TRY_CWD_FIRST, OPF_SEARCH_IN_PATH, OPF_RETURN_REALPATH):
Move to enum openp_flags.
(openp_flags): New enum flags.
(openp): Change parameter type to openp_flags.
* source.c (openp): Change parameter type to openp_flags.
* cli/cli-cmds.c (find_and_open_script): Use openp_flags.
* dwarf2read.c (try_open_dwop_file): Use openp_flags.
---
gdb/cli/cli-cmds.c | 2 +-
gdb/defs.h | 14 ++++++++++----
gdb/dwarf2read.c | 4 ++--
gdb/source.c | 2 +-
4 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 18d1d4b383..c3962e939e 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -496,7 +496,7 @@ gdb::optional<open_script>
find_and_open_script (const char *script_file, int search_path)
{
int fd;
- int search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH;
+ openp_flags search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH;
gdb::optional<open_script> opened;
gdb::unique_xmalloc_ptr<char> file (tilde_expand (script_file));
diff --git a/gdb/defs.h b/gdb/defs.h
index 4fb2129b30..70389ad745 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -342,11 +342,17 @@ 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
-extern int openp (const char *, int, const char *, int, char **);
+enum openp_flag
+{
+ OPF_TRY_CWD_FIRST = 0x01,
+ OPF_SEARCH_IN_PATH = 0x02,
+ OPF_RETURN_REALPATH = 0x04,
+};
+
+DEF_ENUM_FLAGS_TYPE(openp_flag, openp_flags);
+
+extern int openp (const char *, 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 cbfd34154a..93453431c1 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -12880,7 +12880,7 @@ static gdb_bfd_ref_ptr
try_open_dwop_file (struct dwarf2_per_objfile *dwarf2_per_objfile,
const char *file_name, int is_dwp, int search_cwd)
{
- int desc, flags;
+ int desc;
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 "."
@@ -12899,7 +12899,7 @@ try_open_dwop_file (struct dwarf2_per_objfile *dwarf2_per_objfile,
else
search_path = xstrdup (debug_file_directory);
- flags = OPF_RETURN_REALPATH;
+ openp_flags flags = OPF_RETURN_REALPATH;
if (is_dwp)
flags |= OPF_SEARCH_IN_PATH;
desc = openp (search_path, flags, file_name,
diff --git a/gdb/source.c b/gdb/source.c
index 009bec5285..eba06f6e6b 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -736,7 +736,7 @@ is_regular_file (const char *name, int *errno_ptr)
/* >>>> 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, openp_flags opts, const char *string,
int mode, char **filename_opened)
{
int fd;
--
2.16.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] Use enum flags for flags passed to openp
2018-02-13 2:31 [PATCH] Use enum flags for flags passed to openp Simon Marchi
@ 2018-02-13 16:51 ` Yao Qi
2018-02-13 17:16 ` Simon Marchi
0 siblings, 1 reply; 3+ messages in thread
From: Yao Qi @ 2018-02-13 16:51 UTC (permalink / raw)
To: Simon Marchi; +Cc: GDB Patches
On Tue, Feb 13, 2018 at 2:31 AM, Simon Marchi <simon.marchi@polymtl.ca> wrote:
> gdb/ChangeLog:
>
> * defs.h (enum openp_flags): New enum.
> (OPF_TRY_CWD_FIRST, OPF_SEARCH_IN_PATH, OPF_RETURN_REALPATH):
> Move to enum openp_flags.
> (openp_flags): New enum flags.
> (openp): Change parameter type to openp_flags.
> * source.c (openp): Change parameter type to openp_flags.
> * cli/cli-cmds.c (find_and_open_script): Use openp_flags.
> * dwarf2read.c (try_open_dwop_file): Use openp_flags.
Patch is good to me.
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Use enum flags for flags passed to openp
2018-02-13 16:51 ` Yao Qi
@ 2018-02-13 17:16 ` Simon Marchi
0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2018-02-13 17:16 UTC (permalink / raw)
To: Yao Qi; +Cc: GDB Patches
On 2018-02-13 11:51, Yao Qi wrote:
> On Tue, Feb 13, 2018 at 2:31 AM, Simon Marchi <simon.marchi@polymtl.ca>
> wrote:
>> gdb/ChangeLog:
>>
>> * defs.h (enum openp_flags): New enum.
>> (OPF_TRY_CWD_FIRST, OPF_SEARCH_IN_PATH, OPF_RETURN_REALPATH):
>> Move to enum openp_flags.
>> (openp_flags): New enum flags.
>> (openp): Change parameter type to openp_flags.
>> * source.c (openp): Change parameter type to openp_flags.
>> * cli/cli-cmds.c (find_and_open_script): Use openp_flags.
>> * dwarf2read.c (try_open_dwop_file): Use openp_flags.
>
> Patch is good to me.
Thanks, pushed.
Simon
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-13 17:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-13 2:31 [PATCH] Use enum flags for flags passed to openp Simon Marchi
2018-02-13 16:51 ` Yao Qi
2018-02-13 17:16 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox