old-cross-binutils/gdb/testsuite/gdb.base/skip-solib.exp
Doug Evans cce0e92333 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.
2016-02-23 13:25:18 -08:00

120 lines
3.6 KiB
Text

# Copyright 2011-2016 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file was written by Justin Lebar. (justin.lebar@gmail.com)
#
# Tests skipping shared libraries.
#
# This only works on GNU/Linux.
if { ![isnative] || [is_remote host] || ![istarget *-linux*] || [skip_shlib_tests]} {
continue
}
set test "skip-solib"
set srcfile_main "${test}-main.c"
set executable_main ${test}-test
set binfile_main [standard_output_file ${executable_main}]
set srcfile_lib "${test}-lib.c"
set libname "lib${test}"
set binfile_lib [standard_output_file ${libname}.so]
#
# Compile our program under test. The main program references a shared library
# libskip-solib.so, which contains two functions, square(), which is
# referenced by the main program, and multiply(), which is not referenced by
# the main program.
#
if {[gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list debug additional_flags=-fPIC -Wl,-soname,${libname}.so]] != ""} {
return -1
}
if {[gdb_compile "${srcdir}/${subdir}/${srcfile_main}" "${binfile_main}.o" object debug] != ""} {
return -1
}
set testobjdir [standard_output_file {}]
if {[gdb_compile "${binfile_main}.o" "${binfile_main}" executable \
[list debug "additional_flags=-L$testobjdir -l${test} \
-Wl,-rpath=$testobjdir"]] != ""} {
return -1
}
clean_restart ${executable_main}
#
# At this point, if we try to skip the file ${srcfile_lib} or the function
# multiply(), we should get a prompt asking us if we want to enable the
# skip entry pending a shared library load.
#
gdb_test "skip file ${srcfile_lib}" \
"File ${srcfile_lib} will be skipped when stepping." \
"ignoring file in solib" \
"No source file named ${srcfile_lib}.*
Ignore file pending future shared library load.*" \
"y"
#
# Checkinfo skip list.
#
gdb_test "info skip" \
"Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
1\\s+y\\s+n\\s+${srcfile_lib}\\s+n\\s+<none>\\s*" \
"info skip with pending file"
if ![runto_main] { fail "skip tests suppressed" }
#
# We shouldn't step into square(), since we skipped skip-solib-lib.c.
#
gdb_test "step" ""
gdb_test "bt" "#0\\s+main.*" "step after ignoring solib file."
#
# Now restart gdb and testing ignoring of a function inside a solib.
#
clean_restart ${executable_main}
gdb_test "skip function multiply" \
"Function multiply will be skipped when stepping\\." \
"ignoring function in solib" \
"No function found named multiply..*
Ignore function pending future shared library load.*" \
"y"
if ![runto_main] { fail "skip tests suppressed" }
#
# Our first step should take us into square.
#
gdb_test "step" "square.*"
#
# Now our entry should no longer be pending.
#
gdb_test "info skip" \
"Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*
1\\s+y\\s+n\\s+<none>\\s+n\\s+multiply\\s*" \
"info skip for function multiply"
#
# This step shouldn't go into multiply -- we should skip it and go on to the
# last line of square.
#
gdb_test "step" ""
gdb_test "bt" "#0\\s+square.*"