From patchwork Fri Apr 18 11:42:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 619 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id D9082360060 for ; Fri, 18 Apr 2014 04:45:15 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14314964) id 6746B62A006B9; Fri, 18 Apr 2014 04:45:15 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx23.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx23.g.dreamhost.com (Postfix) with ESMTPS id C57176287FF7D for ; Fri, 18 Apr 2014 04:45:14 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; q=dns; s=default; b=NhfjIebaGiNlb/iVamHRKaduNJjk6TIcBWdq8nuD/VU H/o3uBycJ/+vNPYS19ivnqiGAdjI20f2LRwmm6iTh74OXEWqzZa2ngDZjxMoU2Vl frdvmXM/QS9ZwC0F7TH99L9YzWcphC9/dPOaVtuSanSITL7yeMMm7AwS8S2g5TpU = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; s=default; bh=zhk4KQe9OXPbIgF1v49AsiQnf0A=; b=W3GhrwJzdMS5HGTdp vGNQWFXJQjt2PjE7T5z4TIc/U6S4p5+HToA2M8BHG5EZWVhSinccQup70CagKoaS kK9cr5QnPoit1QY4c9olK18zgWZNVB7NE3yLaHQzG7F/ELFfl13XxYxfvYJ9FYQo tmIOIKVWOAFQHiMMWHpcUVDYrQ= Received: (qmail 405 invoked by alias); 18 Apr 2014 11:45:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 395 invoked by uid 89); 18 Apr 2014 11:45:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 18 Apr 2014 11:45:09 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1Wb7EA-0000j1-6j from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Fri, 18 Apr 2014 04:45:06 -0700 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); Fri, 18 Apr 2014 04:45:03 -0700 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; Fri, 18 Apr 2014 04:45:02 -0700 Message-ID: <53510FB3.1060202@codesourcery.com> Date: Fri, 18 Apr 2014 19:42:43 +0800 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Subject: Re: [PATCH 11/12] Test case References: <1392367471-13527-1-git-send-email-yao@codesourcery.com> <1392367471-13527-12-git-send-email-yao@codesourcery.com> In-Reply-To: <1392367471-13527-12-git-send-email-yao@codesourcery.com> X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in On 02/14/2014 04:44 PM, Yao Qi wrote: > - Remove hard-coded breakpoint number, but it depends on this patch > > [PATCH] Accept convenience variable in commands -break-passcount and -break-commands > https://sourceware.org/ml/gdb-patches/2014-01/msg00936.html This patch above isn't acceptable as its current shape, so I revert this patch back to use hard-coded breakpoint number. diff --git a/gdb/config/djgpp/fnchange.lst b/gdb/config/djgpp/fnchange.lst index cbf11c6..b94c77e 100644 --- a/gdb/config/djgpp/fnchange.lst +++ b/gdb/config/djgpp/fnchange.lst @@ -506,6 +506,10 @@ @V@/gdb/testsuite/gdb.mi/mi2-var-display.exp @V@/gdb/testsuite/gdb.mi/mi2vardisplay.exp @V@/gdb/testsuite/gdb.mi/mi-nonstop-exit.exp @V@/gdb/testsuite/gdb.mi/minonstop-exit.exp @V@/gdb/testsuite/gdb.mi/non-stop-exit.c @V@/gdb/testsuite/gdb.mi/nonstop-exit.c +@V@/gdb/testsuite/gdb.trace/available-children-only.c @V@/gdb/testsuite/gdb.trace/availnly.c +@V@/gdb/testsuite/gdb.trace/mi-available-children-only.exp @V@/gdb/testsuite/gdb.trace/availnly.exp +@V@/gdb/testsuite/gdb.trace/mi-available-children-only-cxx.exp @V@/gdb/testsuite/gdb.trace/availcxx.exp +@V@/gdb/testsuite/gdb.trace/available-children-only.cc @V@/gdb/testsuite/gdb.trace/availcxx.cc @V@/gdb/testsuite/gdb.threads/watchthreads2.c @V@/gdb/testsuite/gdb.threads/watchth2.c @V@/gdb/testsuite/gdb.threads/watchthreads2.exp @V@/gdb/testsuite/gdb.threads/watchth2.exp @V@/gdb/amd64-linux-tdep.c @V@/gdb/amd64-ltdep.c 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..b13f130 --- /dev/null +++ b/gdb/testsuite/gdb.trace/available-children-only.c @@ -0,0 +1,69 @@ +/* Copyright 2013-2014 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..f9f06e7 --- /dev/null +++ b/gdb/testsuite/gdb.trace/available-children-only.cc @@ -0,0 +1,45 @@ +/* Copyright 2013-2014 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..cc6b0f2 --- /dev/null +++ b/gdb/testsuite/gdb.trace/mi-available-children-only-cxx.exp @@ -0,0 +1,126 @@ +# Copyright 2013-2014 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..247c32c --- /dev/null +++ b/gdb/testsuite/gdb.trace/mi-available-children-only.exp @@ -0,0 +1,198 @@ +# Copyright 2013-2014 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"