From patchwork Tue Mar 25 07:52:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 262 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (caibbdcaaahc.dreamhost.com [208.113.200.72]) by wilcox.dreamhost.com (Postfix) with ESMTP id 669B83600C5 for ; Tue, 25 Mar 2014 00:55:51 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14314964) id 1B04A40AC5A8C; Tue, 25 Mar 2014 00:55:51 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx20.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-mx20.g.dreamhost.com (Postfix) with ESMTPS id E9FE740A7D002 for ; Tue, 25 Mar 2014 00:55:50 -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:from:to:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=ZDDDrOeNYeczEHI1k/enMgwaHuhpi M7tKLweUt9wjpkJBn8phlN+2KaalgucR6pcyGYWeqxoJQk8HGkBGV/E6nMMwzEEG 2OAdaQ9p3mlpEltDTXIHZdAJgpOcyZFSfdJmF1UornRlczn1hkOV8/FlsHFph4YB e0ey+Bjn+jpqdw= 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:from:to:subject:date:message-id:mime-version :content-type; s=default; bh=E4ZWSGeE3MoTkcwo7reyUUrs3WA=; b=cD6 6LidRMLlZ9liMCdWz3eQ0vQv9pseCFluwnWNB4bbMrRqTXXXiVqX+9Uot+XH7L4q W5hjsIaVnpWrcsksH33or3QRwnb7tu6gYrtbgAYUaGoRgAIMBlLndHjLBy0Urikx hLwF8kkNLXQmIxuQMMi/CPyOwnCqVB1Vyc3L42y0= Received: (qmail 31692 invoked by alias); 25 Mar 2014 07:55:48 -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 31680 invoked by uid 89); 25 Mar 2014 07:55:47 -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; Tue, 25 Mar 2014 07:55:46 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WSMD1-00035h-7c from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Tue, 25 Mar 2014 00:55:43 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 25 Mar 2014 00:55:43 -0700 Received: from qiyao.dyndns.org.com (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.2.247.3; Tue, 25 Mar 2014 00:55:42 -0700 From: Yao Qi To: Subject: [PATCH] Check tracefile is generated by binary execution Date: Tue, 25 Mar 2014 15:52:13 +0800 Message-ID: <1395733933-9366-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in In gdb.trace/tfile.exp, we execute binary to generate tracefile, remote_exec target "$binfile" however, this fails on bare metal target. This patch is to handle binary execution failure by running binary in GDB. The binary will do some io operation to generate tracefile, so we need a check 'target_info exists gdb,nofileio'. This patch is to check whether tracefile is generated. tfile.exp can be skipped if generation is failed, while test_tfind_tfile in mi-traceframe-changed.exp is skipped if generated failed. The rest of the mi-traceframe-changed.exp can still be executed, because on some bare metal targets, the remote stub may support tracepoint but doesn't support fileio. This patch is tested on nios2-elf and arm-none-eabi. gdb/testsuite: 2014-03-25 Yao Qi * lib/trace-support.exp (generate_tracefile): New procedure. * gdb.trace/tfile.exp: Skip the test if generate_tracefile return 0. * gdb.trace/mi-traceframe-changed.exp: Invoke test_tfind_tfile if generate_tracefile returns 1. --- gdb/testsuite/gdb.trace/mi-traceframe-changed.exp | 20 ++++++++------- gdb/testsuite/gdb.trace/tfile.exp | 10 ++++---- gdb/testsuite/lib/trace-support.exp | 27 +++++++++++++++++++++ 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp b/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp index 4bcf379..a4c06b0 100644 --- a/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp +++ b/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp @@ -43,14 +43,6 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ remote_file host delete $tfile_basic remote_file target delete $tfile_basic -remote_exec target "$binfile" - -if {!$purely_local} { - # Copy tracefile from target to host. - remote_download host [remote_upload target tfile-basic.tf] \ - tfile-basic.tf -} - proc test_tfind_tfile { } { with_test_prefix "tfile" { global binfile @@ -88,7 +80,17 @@ proc test_tfind_tfile { } { } } -test_tfind_tfile +# If tracefile is generated successfully, copy tracefile to host and +# run tests. +if [generate_tracefile $binfile] { + if {!$purely_local} { + # Copy tracefile from target to host. + remote_download host [remote_upload target tfile-basic.tf] \ + tfile-basic.tf + } + + test_tfind_tfile +} # Change to a different test case in order to run it on target, and get # several traceframes. diff --git a/gdb/testsuite/gdb.trace/tfile.exp b/gdb/testsuite/gdb.trace/tfile.exp index dcf807a..2918eba 100644 --- a/gdb/testsuite/gdb.trace/tfile.exp +++ b/gdb/testsuite/gdb.trace/tfile.exp @@ -34,8 +34,6 @@ if {![is_remote host] && ![is_remote target]} { set purely_local 0 } -gdb_exit -gdb_start standard_testfile if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ executable \ @@ -45,7 +43,6 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ untested ${testfile}.exp return -1 } -gdb_reinitialize_dir $srcdir/$subdir # Make sure we are starting fresh. remote_file host delete $tfile_basic @@ -53,14 +50,17 @@ remote_file host delete $tfile_error remote_file target delete $tfile_basic remote_file target delete $tfile_error -remote_exec target "$binfile" +if { ![generate_tracefile $binfile] } { + unsupported "Unable to generate tfile" +} + if {!$purely_local} { # Copy tracefile from target to host through build. remote_download host [remote_upload target tfile-basic.tf] tfile-basic.tf remote_download host [remote_upload target tfile-error.tf] tfile-error.tf } -gdb_load $binfile +clean_restart $binfile # Program has presumably exited, now target a trace file it created. diff --git a/gdb/testsuite/lib/trace-support.exp b/gdb/testsuite/lib/trace-support.exp index 34c01cb..a076bac 100644 --- a/gdb/testsuite/lib/trace-support.exp +++ b/gdb/testsuite/lib/trace-support.exp @@ -327,3 +327,30 @@ proc get_in_proc_agent {} { return $objdir/../gdbserver/libinproctrace.so } } + +# Execute BINFILE on target to generate tracefile. Return 1 if +# tracefile is generated successfully, return 0 otherwise. + +proc generate_tracefile { binfile } { + set status [remote_exec target "$binfile"] + + if { [lindex $status 0] != 0 } { + # Failed to execute $binfile, for example on bare metal targets. + # Alternatively, load the binary and run it. If target doesn't + # have fileio capabilities, tracefile can't be generated. Skip + # the test. + if [target_info exists gdb,nofileio] { + return 0 + } + + clean_restart $binfile + + if ![runto_main] then { + return 0 + } + gdb_continue_to_end "" continue 1 + gdb_exit + } + + return 1 +}