From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22842 invoked by alias); 24 Nov 2013 02:12:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 22561 invoked by uid 89); 24 Nov 2013 02:12:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL,BAYES_50,RDNS_NONE,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: relay1.mentorg.com Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 24 Nov 2013 02:12:08 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1VkPB9-0006rN-Cr from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Sat, 23 Nov 2013 18:12:07 -0800 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Sat, 23 Nov 2013 18:12:07 -0800 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.2.247.3; Sat, 23 Nov 2013 18:12:06 -0800 From: Yao Qi To: Subject: [PATCH 11/11] Test case Date: Sun, 24 Nov 2013 02:12:00 -0000 Message-ID: <1385258996-26047-12-git-send-email-yao@codesourcery.com> In-Reply-To: <1385258996-26047-1-git-send-email-yao@codesourcery.com> References: <1385258996-26047-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00734.txt.bz2 This patch adds two test cases for the new option. mi-available-children-only-cxx.exp focuses on the C++ fake children. gdb/testsuite: 2013-11-24 Yao Qi * gdb.trace/available-children-only.c: New. * gdb.trace/mi-available-children-only.exp: New. * gdb.trace/mi-available-children-only-cxx.exp: New. * gdb.trace/available-children-only.cc: New. --- gdb/testsuite/gdb.trace/available-children-only.c | 69 +++++++ gdb/testsuite/gdb.trace/available-children-only.cc | 45 +++++ .../gdb.trace/mi-available-children-only-cxx.exp | 126 +++++++++++++ .../gdb.trace/mi-available-children-only.exp | 198 ++++++++++++++++++++ 4 files changed, 438 insertions(+), 0 deletions(-) create mode 100644 gdb/testsuite/gdb.trace/available-children-only.c create mode 100644 gdb/testsuite/gdb.trace/available-children-only.cc create mode 100644 gdb/testsuite/gdb.trace/mi-available-children-only-cxx.exp create mode 100644 gdb/testsuite/gdb.trace/mi-available-children-only.exp diff --git a/gdb/testsuite/gdb.trace/available-children-only.c b/gdb/testsuite/gdb.trace/available-children-only.c new file mode 100644 index 0000000..1697a8b --- /dev/null +++ b/gdb/testsuite/gdb.trace/available-children-only.c @@ -0,0 +1,69 @@ +/* Copyright 2013 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 . */ + +/* Two trace actions are set, and they collect different fields to + reproduce the case that children appear in the different orders. */ + +struct simple +{ + int a; /* Collected by both. */ + int b; /* Collected by action 2. */ + struct + { + struct + { + int g; /* Collected by action 1. */ + int h; /* Collected by action 2. */ + } s3; + int d; /* Collected by action 1. */ + } s1; + + struct + { + int e; + int f; /* Collected by action 1. */ + } s2; +}; + +struct simple s; + +static void +marker1 (void) +{ +} + +static void +marker2 (void) +{ +} + +static void +end (void) +{ +} + +int +main (void) +{ + marker1 (); + + marker2 (); + + end (); + + return 0; +} diff --git a/gdb/testsuite/gdb.trace/available-children-only.cc b/gdb/testsuite/gdb.trace/available-children-only.cc new file mode 100644 index 0000000..2ff4a4c --- /dev/null +++ b/gdb/testsuite/gdb.trace/available-children-only.cc @@ -0,0 +1,45 @@ +/* Copyright 2013 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 . */ + +class Fake +{ + private: + int pri1; /* Collected. */ + + public: + int pub1; + +}; + +Fake fake; + +static void +marker (void) +{} + +static void +end (void) +{} + +int +main (void) +{ + marker (); + + end (); + return 0; +} diff --git a/gdb/testsuite/gdb.trace/mi-available-children-only-cxx.exp b/gdb/testsuite/gdb.trace/mi-available-children-only-cxx.exp new file mode 100644 index 0000000..f72a13f --- /dev/null +++ b/gdb/testsuite/gdb.trace/mi-available-children-only-cxx.exp @@ -0,0 +1,126 @@ +# Copyright 2013 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 . + +# Test for C++ fake children. + +load_lib mi-support.exp +load_lib trace-support.exp +set MIFLAGS "-i=mi" + +standard_testfile available-children-only.cc + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ + executable {debug c++}] != "" } { + untested "Couldn't compile ${srcfile}" + return -1 +} + +# Test target supports tracepoints or not. + +clean_restart $testfile + +if ![runto_main] { + fail "Can't run to main to check for trace support" + return -1 +} + +if ![gdb_target_supports_trace] { + unsupported "Current target does not support trace" + return -1 +} +gdb_exit + +if [mi_gdb_start] { + continue +} + +mi_run_to_main + +mi_gdb_test "-break-insert -a marker" "\\^done.*" \ + "trace marker" + +mi_gdb_test "-break-commands 2 \"collect fake.pri1\" \"end\" " \ + {\^done} "set action on marker" + +mi_gdb_test "-trace-start" ".*\\^done.*" "trace start" +mi_continue_to end +mi_gdb_test "-trace-stop" "\\^done.*" "trace stop" +# Save trace frames to trace file. +set tracefile [standard_output_file ${testfile}] +mi_gdb_test "-trace-save ${tracefile}.tfile" \ + ".*" \ + "save tfile trace" + +# In live target, '--available-children-only' shouldn't have any +# effects. + +mi_gdb_test "-trace-find frame-number 0" \ + ".*\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"0\",frame=\{.*" \ + "-trace-find frame-number 0" + +mi_gdb_test "-var-create --available-children-only fake @ fake" \ + {\^done,name="fake",numchild="0",value=".*",type="Fake",dynamic="1",has_more="1"} \ + "-var-create --available-children-only fake" + +mi_list_varobj_children { fake --available-children-only } { + { fake.public public 0 } + { fake.private private 0 } +} "-var-list-children --available-children-only fake" + +mi_gdb_test "-var-info-num-children --available-children-only fake" \ + "\\^done,numchild=\"2\"" \ + "-var-info-num-children --available-children-only fake" + +mi_gdb_test "-var-delete fake" {\^done,ndeleted="3"} "-var-delete fake" + +# Select a traceframe, and '--available-children-only' have some +# effects. + +proc check_with_traceframe { } { + global decimal + + with_test_prefix "w/ setting traceframe" { + mi_gdb_test "-trace-find frame-number 0" \ + ".*\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"0\",frame=\{.*" \ + "-trace-find frame-number 0" + + mi_gdb_test "-var-create --available-children-only fake @ fake" \ + {\^done,name="fake",numchild="0",value=".*",type="Fake",dynamic="1",has_more="1"} \ + "-var-create --available-children-only fake" + + mi_list_varobj_children "fake" { + { fake.public public 1 } + { fake.private private 1 } + } "-var-list-children fake" + + mi_gdb_test "-var-info-num-children fake" \ + "\\^done,numchild=\"2\"" "-var-info-num-children fake" + + mi_list_varobj_children {"fake" "--available-children-only" } { + { fake.public public 0 } + { fake.private private 0 } + } "-var-list-children --available-children-only fake" + + mi_gdb_test "-var-info-num-children --available-children-only fake" \ + "\\^done,numchild=\"2\"" \ + "-var-info-num-children --available-children-only fake" + + mi_gdb_test "-var-delete fake" {\^done,ndeleted="3"} "-var-delete fake" + } + mi_gdb_test "-trace-find none" ".*\\^done,found=\"0\".*" \ + "-trace-find none" +} + +check_with_traceframe diff --git a/gdb/testsuite/gdb.trace/mi-available-children-only.exp b/gdb/testsuite/gdb.trace/mi-available-children-only.exp new file mode 100644 index 0000000..73f85d7 --- /dev/null +++ b/gdb/testsuite/gdb.trace/mi-available-children-only.exp @@ -0,0 +1,198 @@ +# Copyright 2013 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 mi-support.exp +load_lib trace-support.exp +set MIFLAGS "-i=mi" + +standard_testfile available-children-only.c + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested mi-available-children-only.exp + return -1 +} + +# Test target supports tracepoints or not. + +clean_restart $testfile + +if ![runto_main] { + fail "Can't run to main to check for trace support" + return -1 +} + +if ![gdb_target_supports_trace] { + unsupported "Current target does not support trace" + return -1 +} +gdb_exit + +if [mi_gdb_start] { + continue +} + +mi_run_to_main +mi_gdb_test "-break-insert -a marker1" "\\^done.*" \ + "trace marker1" + +mi_gdb_test "-break-commands 2 \"collect s.a\" \"collect s.s1.d\" \"collect s.s1.s3.g\" \"collect s.s2.f\" \"end\" " \ + {\^done} "set action on marker1" + +mi_gdb_test "-break-insert -a marker2" "\\^done.*" \ + "trace marker2" + +mi_gdb_test "-break-commands 3 \"collect s.a\" \"collect s.b\" \"collect s.s1.s3.h\" \"end\" " \ + {\^done} "set action on marker2" + +mi_gdb_test "-trace-start" ".*\\^done.*" "trace start" +mi_continue_to end +mi_gdb_test "-trace-stop" "\\^done.*" "trace stop" + +# Save trace frames to trace file. +set tracefile [standard_output_file ${testfile}] +mi_gdb_test "-trace-save ${tracefile}.tfile" \ + ".*" \ + "save tfile trace" + +# In live target, '--available-children-only' shouldn't have any +# effects. +mi_gdb_test "-var-create --available-children-only s1 @ s" \ + {\^done,name="s1",numchild="0",value=".*",type="struct simple",dynamic="1",has_more="1"} \ + "-var-create --available-children-only s1" + +mi_list_varobj_children { "s1" "--available-children-only" } { + { s1.a a 0 int } + { s1.b b 0 int } + { s1.s1 s1 0 "struct \\{\\.\\.\\.\\}" } + { s1.s2 s2 0 "struct \\{\\.\\.\\.\\}" } +} "-var-list-children --available-children-only s1" + +mi_gdb_test "-var-info-num-children --available-children-only s1" \ + "\\^done,numchild=\"4\"" \ + "-var-info-num-children --available-children-only s1" + +mi_gdb_test "-var-delete s1" {\^done,ndeleted="5"} "-var-delete s1" + +# Select a traceframe, and '--available-children-only' have some +# effects. + +proc check_with_traceframe { } { + global decimal + + mi_gdb_test "-trace-find frame-number 0" \ + ".*\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"0\",frame=\{.*" \ + "-trace-find frame-number 0" + + with_test_prefix "traceframe 0" { + mi_gdb_test "-var-create --available-children-only s2 @ s" \ + {\^done,name="s2",numchild="0",value=".*",type="struct simple",dynamic="1",has_more="1"} \ + "-var-create --available-children-only s2" + + mi_gdb_test "-var-list-children s2" \ + "\\^done,numchild=\"4\",.*,has_more=\"0\"" \ + "-var-list-children s2" + + mi_gdb_test "-var-info-num-children s2" \ + "\\^done,numchild=\"4\"" \ + "-var-info-num-children s2" + + # "s2" should have children "a", "s1" and "s2". + mi_list_varobj_children { "s2" "--available-children-only" } { + { s2.a a 0 int } + { s2.s1 s1 0 "struct \\{\\.\\.\\.\\}" } + { s2.s2 s2 0 "struct \\{\\.\\.\\.\\}" } + } "-var-list-children --available-children-only s2" + + mi_gdb_test "-var-info-num-children --available-children-only s2" \ + "\\^done,numchild=\"3\"" \ + "-var-info-num-children --available-children-only s2" + + mi_list_varobj_children { "s2.s1" "--available-children-only" } { + { s2.s1.s3 s3 0 "struct \\{\\.\\.\\.\\}" } + { s2.s1.d d 0 int } + } "-var-list-children --available-children-only s2.s1" + + } + + mi_gdb_test "-trace-find frame-number 1" \ + ".*\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"1\",frame=\{.*" \ + "-trace-find frame-number 1" + + with_test_prefix "traceframe 1" { + mi_list_varobj_children { "s2" "--available-children-only" } { + { s2.a a 0 int } + { s2.b b 0 int } + { s2.s1 s1 0 "struct \\{\\.\\.\\.\\}" } + } "-var-list-children --available-children-only s2" + + mi_list_varobj_children { "s2.s1" "--available-children-only" } { + { s2.s1.s3 s3 0 "struct \\{\\.\\.\\.\\}" } + } "-var-list-children --available-children-only s2.s1" + + mi_list_varobj_children { "s2.s1.s3" "--available-children-only" } { + { s2.s1.s3.h h 0 int } + } "-var-list-children --available-children-only s2.s1.s3" + + mi_gdb_test "-var-info-num-children --available-children-only s2" \ + "\\^done,numchild=\"3\"" \ + "-var-info-num-children --available-children-only s2" + + mi_gdb_test "-var-delete s2" {\^done,ndeleted="6"} "-var-delete s2" + } + + mi_gdb_test "-trace-find none" ".*\\^done,found=\"0\".*" \ + "-trace-find none" +} + +check_with_traceframe + +# Test when changing target from remote to ${target}. + +proc test_from_remote { target } { + global mi_gdb_prompt decimal + global tracefile + + with_test_prefix "remote to ${target}" { + # Change target to ${target}. + mi_gdb_test "-target-select ${target} ${tracefile}.${target}" ".*\\^connected.*" \ + "change target to ${target}" + + with_test_prefix "w/ setting traceframe" { + check_with_traceframe + } + } +} + +test_from_remote "tfile" + +proc test_from_exec { target } { + global binfile + global tracefile + + mi_gdb_exit + if [mi_gdb_start] { + return + } + mi_gdb_load ${binfile} + + with_test_prefix "exec to ${target}" { + mi_gdb_test "-target-select ${target} ${tracefile}.${target}" ".*\\^connected.*" \ + "change target to ${target}" + + check_with_traceframe + } +} + +test_from_exec "tfile" -- 1.7.7.6