Home | History | Annotate | Line # | Download | only in gdb.python
      1 # Copyright (C) 2021-2024 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 # Test gdb.PendingFrame.level method.
     17 
     18 load_lib gdb-python.exp
     19 
     20 require allow_python_tests
     21 
     22 standard_testfile
     23 
     24 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
     25     return -1
     26 }
     27 
     28 if {![runto_main]} {
     29     return 0
     30 }
     31 
     32 set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
     33 
     34 gdb_breakpoint [gdb_get_line_number "Break here"]
     35 gdb_continue_to_breakpoint "stop at test breakpoint"
     36 
     37 # An initial look at the stack to ensure it is correct.
     38 gdb_test_sequence "bt"  "Initial backtrace" {
     39     "\\r\\n#0 \[^\r\n\]* f0 \\(\\) at "
     40     "\\r\\n#1 \[^\r\n\]* f1 \\(\\) at "
     41     "\\r\\n#2 \[^\r\n\]* f2 \\(\\) at "
     42     "\\r\\n#3 \[^\r\n\]* f3 \\(\\) at "
     43     "\\r\\n#4 \[^\r\n\]* main \\(\\) at "
     44 }
     45 
     46 # Load the script containing the unwinder.
     47 gdb_test_no_output "source ${pyfile}"\
     48     "import python scripts"
     49 
     50 # Now look at the stack again, we should see output from the Python
     51 # unwinder mixed in.
     52 gdb_test_sequence "bt"  "Backtrace with extra Python output" {
     53     "Func f0, Level 0"
     54     "Func f1, Level 1"
     55     "\\r\\n#0 \[^\r\n\]* f0 \\(\\) at "
     56     "\\r\\n#1 \[^\r\n\]* f1 \\(\\) at "
     57     "Func f2, Level 2"
     58     "\\r\\n#2 \[^\r\n\]* f2 \\(\\) at "
     59     "Func f3, Level 3"
     60     "\\r\\n#3 \[^\r\n\]* f3 \\(\\) at "
     61     "Func main, Level 4"
     62     "\\r\\n#4 \[^\r\n\]* main \\(\\) at "
     63 }
     64