Home | History | Annotate | Line # | Download | only in gdb.btrace
reconnect.exp revision 1.1
      1  1.1  christos # This testcase is part of GDB, the GNU debugger.
      2  1.1  christos #
      3  1.1  christos # Copyright 2016 Free Software Foundation, Inc.
      4  1.1  christos #
      5  1.1  christos # Contributed by Intel Corp. <tim.wiederhake (at) intel.com>
      6  1.1  christos #
      7  1.1  christos # This program is free software; you can redistribute it and/or modify
      8  1.1  christos # it under the terms of the GNU General Public License as published by
      9  1.1  christos # the Free Software Foundation; either version 3 of the License, or
     10  1.1  christos # (at your option) any later version.
     11  1.1  christos #
     12  1.1  christos # This program is distributed in the hope that it will be useful,
     13  1.1  christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  1.1  christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15  1.1  christos # GNU General Public License for more details.
     16  1.1  christos #
     17  1.1  christos # You should have received a copy of the GNU General Public License
     18  1.1  christos # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     19  1.1  christos 
     20  1.1  christos load_lib gdbserver-support.exp
     21  1.1  christos 
     22  1.1  christos if { [skip_btrace_tests] } { return -1 }
     23  1.1  christos if { [skip_gdbserver_tests] } { return -1 }
     24  1.1  christos 
     25  1.1  christos standard_testfile
     26  1.1  christos if [prepare_for_testing $testfile.exp $testfile $srcfile] {
     27  1.1  christos     return -1
     28  1.1  christos }
     29  1.1  christos 
     30  1.1  christos # Make sure we're disconnected and no recording is active, in case
     31  1.1  christos # we're testing with an extended-remote board, therefore already
     32  1.1  christos # connected.
     33  1.1  christos with_test_prefix "preparation" {
     34  1.1  christos   gdb_test "record stop" ".*"
     35  1.1  christos   gdb_test "disconnect" ".*"
     36  1.1  christos }
     37  1.1  christos 
     38  1.1  christos # Start fresh gdbserver.
     39  1.1  christos set gdbserver_reconnect_p 1
     40  1.1  christos set res [gdbserver_start "" $binfile]
     41  1.1  christos set gdbserver_protocol [lindex $res 0]
     42  1.1  christos set gdbserver_gdbport [lindex $res 1]
     43  1.1  christos gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
     44  1.1  christos 
     45  1.1  christos # Create a record, check, reconnect
     46  1.1  christos with_test_prefix "first" {
     47  1.1  christos   gdb_test_no_output "record btrace" "record btrace enable"
     48  1.1  christos   gdb_test "stepi 19" "0x.* in .* from target.*"
     49  1.1  christos 
     50  1.1  christos   gdb_test "info record" [multi_line \
     51  1.1  christos     "Active record target: .*" \
     52  1.1  christos     "Recorded 19 instructions in .+ functions \\(. gaps\\) for thread 1 \\(Thread .*\\)."
     53  1.1  christos   ]
     54  1.1  christos 
     55  1.1  christos   gdb_test "disconnect" "Ending remote debugging."
     56  1.1  christos   gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
     57  1.1  christos }
     58  1.1  christos 
     59  1.1  christos # Test if we can access the recorded data from first connect.
     60  1.1  christos # Note: BTS loses the first function call entry with its associated
     61  1.1  christos # instructions for technical reasons.  This is why we test for
     62  1.1  christos # "a number between 10 and 19", so we catch at least the case where
     63  1.1  christos # there are 0 instructions in the record.
     64  1.1  christos with_test_prefix "second" {
     65  1.1  christos   gdb_test "info record" [multi_line \
     66  1.1  christos     "Active record target: .*" \
     67  1.1  christos     "Recorded 1. instructions in .+ functions \\(. gaps\\) for thread 1 \\(Thread .*\\)."
     68  1.1  christos   ]
     69  1.1  christos 
     70  1.1  christos   gdb_test "record stop" "Process record is stopped and all execution logs are deleted."
     71  1.1  christos 
     72  1.1  christos   gdb_test "disconnect" "Ending remote debugging."
     73  1.1  christos   gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
     74  1.1  christos }
     75  1.1  christos 
     76  1.1  christos # Test that recording is now off.
     77  1.1  christos with_test_prefix "third" {
     78  1.1  christos   gdb_test "info record" "No record target is currently active."
     79  1.1  christos }
     80