From bae4d08c6a69314b0073ee7d93254076e6574e55 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Wed, 30 Oct 2019 21:35:22 +0100 Subject: [PATCH] Add a test case for skip with inlined functions --- gdb/testsuite/gdb.base/skip2.c | 64 ++++++++++++++++++++++++++++++++++++++ gdb/testsuite/gdb.base/skip2.exp | 67 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 gdb/testsuite/gdb.base/skip2.c create mode 100644 gdb/testsuite/gdb.base/skip2.exp diff --git a/gdb/testsuite/gdb.base/skip2.c b/gdb/testsuite/gdb.base/skip2.c new file mode 100644 index 0000000..295aa23 --- /dev/null +++ b/gdb/testsuite/gdb.base/skip2.c @@ -0,0 +1,64 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2019 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 . */ + +#include + +int bar (void); +int baz (int); +void skip1_test_skip_file_and_function (void); +void test_skip_file_and_function (void); + +static int +foo (void) +{ + return bar (); +} + +int +main () +{ + volatile int x; + + /* step immediately into the inlined code */ + x = baz (foo ()); + + /* step first over non-inline code, this involves a different code path */ + x = 0; x = baz (foo ()); + + test_skip_file_and_function (); + + return 0; +} + +static void +test_skip (void) +{ +} + +static void +end_test_skip_file_and_function (void) +{ + abort (); +} + +void +test_skip_file_and_function (void) +{ + test_skip (); + skip1_test_skip_file_and_function (); + end_test_skip_file_and_function (); +} diff --git a/gdb/testsuite/gdb.base/skip2.exp b/gdb/testsuite/gdb.base/skip2.exp new file mode 100644 index 0000000..db40601 --- /dev/null +++ b/gdb/testsuite/gdb.base/skip2.exp @@ -0,0 +1,67 @@ +# Copyright 2019 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 . + +load_lib completion-support.exp + +standard_testfile + +if { [prepare_for_testing "failed to prepare" "skip2" \ + {skip2.c skip1.c } \ + {debug nowarnings optimize=-O2}] } { + return -1 +} + +set srcfile skip2.c +set srcfile1 skip1.c + +if ![runto_main] { + fail "can't run to main" + return +} + +# Create a skiplist entry for a specified file and function. + +gdb_test "skip function foo" "Function foo will be skipped when stepping\." + +gdb_test "step" ".*" "step in the main" +gdb_test "bt" "\\s*\\#0\\s+main.*" "step in the main" +gdb_test "step" ".*" "step into baz, since foo will be skipped" +gdb_test "bt" "\\s*\\#0\\s+baz.*" "step into baz, since foo will be skipped" +gdb_test "step" ".*" "step in the baz" +gdb_test "bt" "\\s*\\#0\\s+baz.*" "step in the baz" +gdb_test "step" ".*" "step back to main" +gdb_test "bt" "\\s*\\#0\\s+main.*" "step back to main" +gdb_test "step" ".*" "step into baz, since foo will be skipped" +gdb_test "bt" "\\s*\\#0\\s+baz.*" "step into baz, since foo will be skipped" +gdb_test "step" ".*" "step in the baz" +gdb_test "bt" "\\s*\\#0\\s+baz.*" "step in the baz" +gdb_test "step" ".*" "step back to main" +gdb_test "bt" "\\s*\\#0\\s+main.*" "step back to main" + +if ![runto_main] { + fail "can't run to main" + return +} + +gdb_test "step" ".*" "step in the main" +gdb_test "bt" "\\s*\\#0\\s+main.*" "step in the main" +gdb_test "step 2" ".*" "step into baz, since foo will be skipped" +gdb_test "bt" "\\s*\\#0\\s+baz.*" "step into baz, since foo will be skipped" +gdb_test "step" ".*" "step in the baz" +gdb_test "bt" "\\s*\\#0\\s+main.*" "step back to main" +gdb_test "step 2" ".*" "step into baz, since foo will be skipped" +gdb_test "bt" "\\s*\\#0\\s+baz.*" "step into baz, since foo will be skipped" +gdb_test "step" ".*" "step back to main" +gdb_test "bt" "\\s*\\#0\\s+main.*" "step back to main" -- 1.9.1