diff options
author | Doug Evans <dje@google.com> | 2016-02-23 13:25:18 -0800 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2016-02-23 13:25:18 -0800 |
commit | cce0e92333b872cfe036aae611b6b5d61cf58186 (patch) | |
tree | 8d6534f65086b7fefee20c5ce8b33b8ad877e676 /gdb/utils.c | |
parent | 742e5034ef645112e4ef204e84e28cf312c1b1c5 (diff) | |
download | gdb-cce0e92333b872cfe036aae611b6b5d61cf58186.zip gdb-cce0e92333b872cfe036aae611b6b5d61cf58186.tar.gz gdb-cce0e92333b872cfe036aae611b6b5d61cf58186.tar.bz2 |
Extend "skip" command to support -file, -gfile, -function, -rfunction.
gdb/ChangeLog:
Extend "skip" command to support -file, -gfile, -function, -rfunction.
* NEWS: Document new features.
* skip.c: #include "fnmatch.h", "gdb_regex.h".
(skiplist_entry) <file>: Renamed from filename.
<function>: Renamed from function_name.
<file_is_glob, function_is_regexp>: New members.
<compiled_function_regexp, compiled_function_regexp_is_valid>:
New members.
(make_skip_entry): New function.
(free_skiplist_entry, free_skiplist_entry_cleanup): New functions.
(make_free_skiplist_entry_cleanup): New function.
(skip_file_command): Update.
(skip_function, skip_function_command): Update.
(compile_skip_regexp): New functions.
(skip_command): Add support for new options.
(skip_info): Update.
(skip_file_p, skip_gfile_p): New functions.
(skip_function_p, skip_rfunction_p): New functions.
(function_name_is_marked_for_skip): Update and simplify.
(_initialize_step_skip): Update.
* symtab.c: #include "fnmatch.h".
(compare_glob_filenames_for_search): New function.
* symtab.h (compare_glob_filenames_for_search): Declare.
* utils.c (count_path_elements): New function.
(strip_leading_path_elements): New function.
* utils.h (count_path_elements): Declare.
(strip_leading_path_elements): Declare.
gdb/doc/ChangeLog:
* gdb.texinfo (Skipping Over Functions and Files): Document new
options to "skip" command. Update docs of output of "info skip".
gdb/testsuite/ChangeLog:
* gdb.base/skip.c (test_skip): New function.
(end_test_skip_file_and_function): New function.
(test_skip_file_and_function): New function.
* gdb.base/skip1.c (test_skip): New function.
(skip1_test_skip_file_and_function): New function.
* gdb.base/skip.exp: Add tests for new skip options.
* gdb.base/skip-solib.exp: Update expected output.
* gdb.perf/skip-command.cc: New file.
* gdb.perf/skip-command.exp: New file.
* gdb.perf/skip-command.py: New file.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r-- | gdb/utils.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/gdb/utils.c b/gdb/utils.c index e34c12e..977314b 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -3380,6 +3380,83 @@ gdb_filename_fnmatch (const char *pattern, const char *string, int flags) return fnmatch (pattern, string, flags); } +/* Return the number of path elements in PATH. + / = 1 + /foo = 2 + /foo/ = 2 + foo/bar = 2 + foo/ = 1 */ + +int +count_path_elements (const char *path) +{ + int count = 0; + const char *p = path; + + if (HAS_DRIVE_SPEC (p)) + { + p = STRIP_DRIVE_SPEC (p); + ++count; + } + + while (*p != '\0') + { + if (IS_DIR_SEPARATOR (*p)) + ++count; + ++p; + } + + /* Backup one if last character is /, unless it's the only one. */ + if (p > path + 1 && IS_DIR_SEPARATOR (p[-1])) + --count; + + /* Add one for the file name, if present. */ + if (p > path && !IS_DIR_SEPARATOR (p[-1])) + ++count; + + return count; +} + +/* Remove N leading path elements from PATH. + N must be non-negative. + If PATH has more than N path elements then return NULL. + If PATH has exactly N path elements then return "". + See count_path_elements for a description of how we do the counting. */ + +const char * +strip_leading_path_elements (const char *path, int n) +{ + int i = 0; + const char *p = path; + + gdb_assert (n >= 0); + + if (n == 0) + return p; + + if (HAS_DRIVE_SPEC (p)) + { + p = STRIP_DRIVE_SPEC (p); + ++i; + } + + while (i < n) + { + while (*p != '\0' && !IS_DIR_SEPARATOR (*p)) + ++p; + if (*p == '\0') + { + if (i + 1 == n) + return ""; + return NULL; + } + ++p; + ++i; + } + + return p; +} + /* Provide a prototype to silence -Wmissing-prototypes. */ extern initialize_file_ftype _initialize_utils; |