Home | History | Annotate | Line # | Download | only in gdb.python
      1 # Copyright (C) 2018-2024 Free Software Foundation, Inc.
      2 # This program is free software; you can redistribute it and/or modify
      3 # it under the terms of the GNU General Public License as published by
      4 # the Free Software Foundation; either version 3 of the License, or
      5 # (at your option) any later version.
      6 #
      7 # This program is distributed in the hope that it will be useful,
      8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
      9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     10 # GNU General Public License for more details.
     11 #
     12 # You should have received a copy of the GNU General Public License
     13 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     14 
     15 # Tests whether -var-info-path-expression fails as documented when
     16 # invoked on a dynamic varobj.
     17 
     18 load_lib mi-support.exp
     19 set MIFLAGS "-i=mi"
     20 
     21 require allow_python_tests
     22 
     23 #
     24 # Start here
     25 #
     26 standard_testfile
     27 
     28 if {[gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable {debug}] != "" } {
     29     return -1
     30 }
     31 
     32 mi_clean_restart $binfile
     33 
     34 set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
     35 mi_gdb_test "source ${pyfile}" \
     36   ".*\\^done" \
     37   "load python file"
     38 
     39 mi_gdb_test "-enable-pretty-printing" \
     40   "\\^done" \
     41   "-enable-pretty-printing"
     42 
     43 mi_gdb_test "set python print-stack full" \
     44   ".*\\^done" \
     45   "set python print-stack full"
     46 
     47 mi_runto_main
     48 
     49 mi_continue_to_line [gdb_get_line_number "next line" ${srcfile}] \
     50   "step to breakpoint"
     51 
     52 mi_gdb_test "-var-create c1 * &c1" \
     53    "\\^done.*" \
     54    "-var-create c1 * &c1"
     55 
     56 mi_gdb_test "-var-info-path-expression c1" \
     57   "\\^done,path_expr=\"&c1\"" \
     58   "-var-info-path-expression c1"
     59 
     60 mi_gdb_test "-var-list-children c1" \
     61   "\\^done,numchild=\"2\",children=.child=\{name=\"c1.car\".*child=\{name=\"c1.cdr\".*" \
     62   "-var-list-children c1"
     63 
     64 mi_gdb_test "-var-info-path-expression c1.cdr" \
     65   "\\^error,msg=\".*\"" \
     66   "-var-info-path-expression c1.cdr"
     67 
     68 mi_gdb_test "-var-list-children c1.cdr" \
     69   "\\^done,numchild=\"2\",children=.child=\{name=\"c1.cdr.car\".*child=\{name=\"c1.cdr.cdr\".*" \
     70   "-var-list-children c1.cdr"
     71 
     72 mi_gdb_test "-var-info-path-expression c1.cdr.cdr" \
     73   "\\^error,msg=\".*\"" \
     74   "-var-info-path-expression c1.cdr.cdr"
     75 
     76 mi_gdb_test "-var-list-children c1.car" \
     77   "\\^done,numchild=\"1\",children=.child=\{name=\"c1.car.atom\".*" \
     78   "-var-list-children c1.car"
     79 
     80 mi_gdb_test "-var-list-children c1.car.atom" \
     81   "\\^done,numchild=\"1\",children=.child=\{name=\"c1.car.atom.ival\".*" \
     82   "-var-list-children c1.car.atom"
     83 
     84 mi_gdb_test "-var-info-path-expression c1.car.atom.ival" \
     85   "\\^error,msg=\".*\"" \
     86   "-var-info-path-expression c1.car.atom.ival"
     87 
     88 
     89 # Regression test for a crasher that would occur when deleting a
     90 # varobj that held an iterator that hadn't yet been completed.
     91 # See PR varobj/28131.
     92 mi_gdb_test "-var-create c1_again * &c1" \
     93    "\\^done.*" \
     94    "-var-create c1_again * &c1"
     95 mi_gdb_test "-var-list-children c1_again 0 1" \
     96   "\\^done,numchild=\"1\",children=.child=\{name=\"c1_again.car\".*" \
     97   "-var-list-children c1_again"
     98 mi_delete_varobj c1_again "delete c1_again"
     99