From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2711 invoked by alias); 9 Nov 2012 21:28:02 -0000 Received: (qmail 2701 invoked by uid 22791); 9 Nov 2012 21:28:01 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 09 Nov 2012 21:27:51 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qA9LRpmI030907 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 9 Nov 2012 16:27:51 -0500 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qA9LRnvw012607 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 9 Nov 2012 16:27:50 -0500 From: Tom Tromey To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: RFA: handle "MiniDebuginfo" section References: <87wqxuel5k.fsf@fleche.redhat.com> <509D47B5.6020302@redhat.com> Date: Fri, 09 Nov 2012 21:28:00 -0000 In-Reply-To: <509D47B5.6020302@redhat.com> (Pedro Alves's message of "Fri, 09 Nov 2012 18:13:09 +0000") Message-ID: <87haoycvqi.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 X-SW-Source: 2012-11/txt/msg00268.txt.bz2 Pedro> Seems like this won't work with remote hosts as is. Can we make Pedro> it use "remote_file host delete", "remote_spawn host", etc.? If Pedro> not, perhaps just bail early if [is_remote host]. FWIW, I took a stab at this, using the appended patch. However, I could not get it to work. I always get an error: ERROR: bad spawn_id (process died earlier?) while executing "expect { -i $spawn_id -timeout $timeout -re ".+" { append output $expect_out(buffer) if { [string length $output] < 512000 } { exp_contin..." (procedure "local_exec" line 94) invoked from within [...] I don't know if this is my bug, or dejagnu's, or expect's -- but I couldn't find a way to work around it. According to comments in remote.exp it is not ok to use redirections in a remote_exec. So I am going to just skip the remote host case. Tom diff --git a/gdb/testsuite/gdb.dwarf2/dw2-gnu-debugdata.exp b/gdb/testsuite/gdb.dwarf2/dw2-gnu-debugdata.exp index e384412..85391e6 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-gnu-debugdata.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-gnu-debugdata.exp @@ -24,12 +24,20 @@ if [build_executable ${testfile}.exp $testfile] { return -1 } -proc run { test cmdline } { - verbose "cmdline is $cmdline" - set result [catch "exec $cmdline" output] +source /tmp/remote.exp + +set pipeline_counter 0 + +# A wrapper for 'remote_exec host' that passes or fails a test. +# Returns 0 if all went well, nonzero on failure. +# TEST is the name of the test, other arguments are as for +# remote_exec. +proc run {test program args} { + verbose -log "cmdline is remote_exec host $program $args" + set result [eval remote_exec host [list $program] $args] verbose "result is $result" - verbose "output is $output" - if {$result == 0} { + lassign $result output status + if {$status == 0} { pass $test return 0 } else { @@ -38,50 +46,89 @@ proc run { test cmdline } { } } -set strip_program [transform strip] -set nm_program [transform nm] +# Run a pipeline of processes through 'run'. +# TEST is the base name of the test, it is modified and passed to 'run'. +# Each subsequent argument is a list of the form {PROGRAM [ARG]...}. +# It is passed to 'run'. However, before being passed, if input and output +# files are not specified in the list, then this proc provides them. +# Each program in the pipeline takes its input from the previous +# program's output. +proc pipeline {test args} { + global pipeline_counter + + set input_file {} + foreach arglist $args { + verbose -log "raw args are $arglist" + lassign $arglist program arguments input output + + if {$input == ""} { + set input $input_file + } + if {$output == ""} { + set output pipe.[pid].$pipeline_counter + incr pipeline_counter + } + verbose -log "cooked args are [list $program $arguments $input $output]" + + if {[run "$test - invoke $program" $program $arguments \ + $input $output]} { + return -1 + } + + set input_file $output + } + return 0 +} # Extract the dynamic symbols from the main binary, there is no need # to also have these in the normal symbol table. -file delete -- ${binfile}.dynsyms -if [run "nm -D" "[transform nm] -D ${binfile} --format=posix --defined-only | awk \\{print\\ \\\$1\\} | sort > ${binfile}.dynsyms"] { +remote_file host delete ${binfile}.dynsyms +if {[pipeline "nm -D" \ + [list [transform nm] "-D ${binfile} --format=posix --defined-only"] \ + [list awk "\\{print\\ \\\$1\\}"] \ + [list sort "" "" "${binfile}.dynsyms"]]} { return -1 } # Extract all the text (i.e. function) symbols from the debuginfo. -file delete -- ${binfile}.funcsyms -if [run "nm" "[transform nm] ${binfile} --format=posix --defined-only | awk \\{if(\\\$2==\"T\"||\\\$2==\"t\")print\\ \\\$1\\} | sort > ${binfile}.funcsyms"] { +remote_file host delete ${binfile}.funcsyms +if {[pipeline "nm" \ + [list [transform nm] "${binfile} --format=posix --defined-only"] \ + [list awk "\\{if(\\\$2==\"T\"||\\\$2==\"t\")print\\ \\\$1\\}"] \ + [list sort "" "" "${binfile}.funcsyms"]]} { return -1 } # Keep all the function symbols not already in the dynamic symbol # table. -file delete -- ${binfile}.keep_symbols -if [run "comm" "comm -13 ${binfile}.dynsyms ${binfile}.funcsyms > ${binfile}.keep_symbols"] { +remote_file host delete ${binfile}.keep_symbols +if {[run "comm" "comm" "-13 ${binfile}.dynsyms ${binfile}.funcsyms" "" \ + "${binfile}.keep_symbols"]} { return -1 } # Copy the full debuginfo, keeping only a minimal set of symbols and # removing some unnecessary sections. -file delete -- ${binfile}.mini_debuginfo -if [run "objcopy 1" "[transform objcopy] -S --remove-section .gdb_index --remove-section .comment --keep-symbols=${binfile}.keep_symbols ${binfile} ${binfile}.mini_debuginfo"] { +remote_file host delete ${binfile}.mini_debuginfo +if {[run "objcopy 1" [transform objcopy] "-S --remove-section .gdb_index --remove-section .comment --keep-symbols=${binfile}.keep_symbols ${binfile} ${binfile}.mini_debuginfo"]} { return -1 } # GDB specific - we do not have split executable in advance. -file delete -- ${binfile}.strip -if [run "strip" "[transform strip] --strip-all -o ${binfile}.strip ${binfile}"] { +remote_file host delete ${binfile}.strip +if {[run "strip" [transform strip] \ + "--strip-all -o ${binfile}.strip ${binfile}"]} { return -1 } # Inject the compressed data into the .gnu_debugdata section of the # original binary. -file delete -- ${binfile}.mini_debuginfo.xz -if [run "xz" "xz ${binfile}.mini_debuginfo"] { +remote_file host delete ${binfile}.mini_debuginfo.xz +if {[run "xz" "xz" "${binfile}.mini_debuginfo"]} { return -1 } -file delete -- ${binfile}.test -if [run "objcopy 2" "[transform objcopy] --add-section .gnu_debugdata=${binfile}.mini_debuginfo.xz ${binfile}.strip ${binfile}.test"] { +remote_file host delete ${binfile}.test +if {[run "objcopy 2" [transform objcopy] "--add-section .gnu_debugdata=${binfile}.mini_debuginfo.xz ${binfile}.strip ${binfile}.test"]} { return -1 }