gdb/
Support shell wildcards for 'set auto-load safe-path'. * auto-load.c: Include fnmatch.h. (filename_is_in_dir): Rename to ... (filename_is_in_pattern_1, filename_is_in_pattern): ... here and split it. Update function comment. Rename dir_len to pattern_len. New variables filename_len, pattern and filename. Add more DEBUG_AUTO_LOAD messages. Use gdb_filename_fnmatch. (filename_is_in_auto_load_safe_path_vec): Rename variable dir to pattern. (_initialize_auto_load): Extend the "set auto-load safe-path" help text. * defs.h (gdb_filename_fnmatch): New declaration. * utils.c: Include fnmatch.h. (gdb_filename_fnmatch): New function. gdb/doc/ * gdb.texinfo (Auto-loading safe path): Note the shell wildcard possibility.
This commit is contained in:
parent
586ec8c1d0
commit
202cbf1c52
6 changed files with 156 additions and 23 deletions
44
gdb/utils.c
44
gdb/utils.c
|
@ -26,6 +26,7 @@
|
|||
#include "event-top.h"
|
||||
#include "exceptions.h"
|
||||
#include "gdbthread.h"
|
||||
#include "fnmatch.h"
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif /* HAVE_SYS_RESOURCE_H */
|
||||
|
@ -3840,6 +3841,49 @@ wait_to_die_with_timeout (pid_t pid, int *status, int timeout)
|
|||
|
||||
#endif /* HAVE_WAITPID */
|
||||
|
||||
/* Provide fnmatch compatible function for FNM_FILE_NAME matching of host files.
|
||||
Both FNM_FILE_NAME and FNM_NOESCAPE must be set in FLAGS.
|
||||
|
||||
It handles correctly HAVE_DOS_BASED_FILE_SYSTEM and
|
||||
HAVE_CASE_INSENSITIVE_FILE_SYSTEM. */
|
||||
|
||||
int
|
||||
gdb_filename_fnmatch (const char *pattern, const char *string, int flags)
|
||||
{
|
||||
gdb_assert ((flags & FNM_FILE_NAME) != 0);
|
||||
|
||||
/* It is unclear how '\' escaping vs. directory separator should coexist. */
|
||||
gdb_assert ((flags & FNM_NOESCAPE) != 0);
|
||||
|
||||
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
|
||||
{
|
||||
char *pattern_slash, *string_slash;
|
||||
|
||||
/* Replace '\' by '/' in both strings. */
|
||||
|
||||
pattern_slash = alloca (strlen (pattern) + 1);
|
||||
strcpy (pattern_slash, pattern);
|
||||
pattern = pattern_slash;
|
||||
for (; *pattern_slash != 0; pattern_slash++)
|
||||
if (IS_DIR_SEPARATOR (*pattern_slash))
|
||||
*pattern_slash = '/';
|
||||
|
||||
string_slash = alloca (strlen (string) + 1);
|
||||
strcpy (string_slash, string);
|
||||
string = string_slash;
|
||||
for (; *string_slash != 0; string_slash++)
|
||||
if (IS_DIR_SEPARATOR (*string_slash))
|
||||
*string_slash = '/';
|
||||
}
|
||||
#endif /* HAVE_DOS_BASED_FILE_SYSTEM */
|
||||
|
||||
#ifdef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
|
||||
flags |= FNM_CASEFOLD;
|
||||
#endif /* HAVE_CASE_INSENSITIVE_FILE_SYSTEM */
|
||||
|
||||
return fnmatch (pattern, string, flags);
|
||||
}
|
||||
|
||||
/* Provide a prototype to silence -Wmissing-prototypes. */
|
||||
extern initialize_file_ftype _initialize_utils;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue