| 1 | # Copyright 2012-2016 Free Software Foundation, Inc. |
| 2 | |
| 3 | # This program is free software; you can redistribute it and/or modify |
| 4 | # it under the terms of the GNU General Public License as published by |
| 5 | # the Free Software Foundation; either version 3 of the License, or |
| 6 | # (at your option) any later version. |
| 7 | # |
| 8 | # This program is distributed in the hope that it will be useful, |
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | # GNU General Public License for more details. |
| 12 | # |
| 13 | # You should have received a copy of the GNU General Public License |
| 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | |
| 16 | # Note that the testcase gdb.dwarf2/dw2-inline-break.exp largely |
| 17 | # mirrors this testcase, and should be updated if this testcase is |
| 18 | # changed. |
| 19 | |
| 20 | standard_testfile |
| 21 | |
| 22 | if { [prepare_for_testing "failed to prepare" $testfile $srcfile \ |
| 23 | {debug additional_flags=-Winline}] } { |
| 24 | return -1 |
| 25 | } |
| 26 | |
| 27 | # |
| 28 | # func1 is a static inlined function that is called once. |
| 29 | # The result should be a single-location breakpoint. |
| 30 | # |
| 31 | gdb_test "break func1" \ |
| 32 | "Breakpoint.*at.* file .*$srcfile, line.*" |
| 33 | |
| 34 | # |
| 35 | # func2 is a non-static inlined function that is called once. |
| 36 | # The result should be a breakpoint with two locations: the |
| 37 | # out-of-line function and the single inlined instance. |
| 38 | # |
| 39 | gdb_test "break func2" \ |
| 40 | "Breakpoint.*at.*func2.*\\(2 locations\\)" |
| 41 | |
| 42 | # |
| 43 | # func3b is a static inlined function that is called once from |
| 44 | # within another static inlined function. The result should be |
| 45 | # a single-location breakpoint. |
| 46 | # |
| 47 | gdb_test "break func3b" \ |
| 48 | "Breakpoint.*at.* file .*$srcfile, line.*" |
| 49 | |
| 50 | # |
| 51 | # func4b is a static inlined function that is called once from |
| 52 | # within a non-static inlined function. The result should be |
| 53 | # a breakpoint with two locations: the inlined instance within |
| 54 | # the inlined call to func4a in main, and the inlined instance |
| 55 | # within the out-of-line func4a. |
| 56 | # |
| 57 | gdb_test "break func4b" \ |
| 58 | "Breakpoint.*at.*func4b.*\\(2 locations\\)" |
| 59 | |
| 60 | # |
| 61 | # func5b is a non-static inlined function that is called once |
| 62 | # from within a static inlined function. The result should be a |
| 63 | # breakpoint with two locations: the out-of-line function and the |
| 64 | # inlined instance within the inlined call to func5a in main. |
| 65 | # |
| 66 | gdb_test "break func5b" \ |
| 67 | "Breakpoint.*at.*func5b.*\\(2 locations\\)" |
| 68 | # |
| 69 | # func6b is a non-static inlined function that is called once from |
| 70 | # within another non-static inlined function. The result should be |
| 71 | # a breakpoint with three locations: the out-of-line function, the |
| 72 | # inlined instance within the out-of-line func6a, and the inlined |
| 73 | # instance within the inlined call to func6a in main, |
| 74 | # |
| 75 | gdb_test "break func6b" \ |
| 76 | "Breakpoint.*at.*func6b.*\\(3 locations\\)" |
| 77 | |
| 78 | # |
| 79 | # func7b is a static inlined function that is called twice: once from |
| 80 | # func7a, and once from main. The result should be a breakpoint with |
| 81 | # two locations: the inlined instance within the inlined instance of |
| 82 | # func7a, and the inlined instance within main. |
| 83 | # |
| 84 | gdb_test "break func7b" \ |
| 85 | "Breakpoint.*at.*func7b.*\\(2 locations\\)" |
| 86 | |
| 87 | # |
| 88 | # func8b is a non-static inlined function that is called twice: once |
| 89 | # func8a, and once from main. The result should be a breakpoint with |
| 90 | # three locations: the out-of-line function, the inlined instance |
| 91 | # within the inlined instance of func7a, and the inlined instance |
| 92 | # within main. |
| 93 | # |
| 94 | gdb_test "break func8b" \ |
| 95 | "Breakpoint.*at.*func8b.*\\(3 locations\\)" |
| 96 | |
| 97 | # |
| 98 | # func1 is a static inlined function. The result should be that no |
| 99 | # symbol is found to print. |
| 100 | # |
| 101 | gdb_test "print func1" \ |
| 102 | "No symbol \"func1\" in current context." |
| 103 | |
| 104 | # |
| 105 | # func2 is a non-static inlined function. The result should be that |
| 106 | # one symbol is found to print, and that the printed symbol is called |
| 107 | # "func2". Note that this does not cover the failure case that two |
| 108 | # symbols were found, but that gdb chose the out-of-line copy to |
| 109 | # print, but if this was failing the "print func1" test would likely |
| 110 | # fail instead. |
| 111 | # |
| 112 | gdb_test "print func2" \ |
| 113 | "\\\$.* = {int \\(int\\)} .* <func2>" |