From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 834 invoked by alias); 23 Jul 2004 06:46:49 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 801 invoked from network); 23 Jul 2004 06:46:47 -0000 Received: from unknown (HELO tisch.mail.mindspring.net) (207.69.200.157) by sourceware.org with SMTP; 23 Jul 2004 06:46:47 -0000 Received: from user-119a90a.biz.mindspring.com ([66.149.36.10] helo=berman.michael-chastain.com) by tisch.mail.mindspring.net with esmtp (Exim 3.33 #1) id 1BntpP-0008Mh-00 for gdb-patches@sources.redhat.com; Fri, 23 Jul 2004 02:46:47 -0400 Received: by berman.michael-chastain.com (Postfix, from userid 502) id 104F74B104; Fri, 23 Jul 2004 02:47:26 -0400 (EDT) To: gdb-patches@sources.redhat.com Subject: [rfc/testsuite] editor.exp: new test script for "edit" command Message-Id: <20040723064726.104F74B104@berman.michael-chastain.com> Date: Fri, 23 Jul 2004 06:46:00 -0000 From: mec.gnu@mindspring.com (Michael Elizabeth Chastain) X-SW-Source: 2004-07/txt/msg00320.txt.bz2 Here is a new test file. "edit" is a little command that locates the current line number and source file and opens an editor for it. The code for edit_command has its own filename construction code and this code does not work with dwarf-2. See PR gdb/1608, and I've heard from another user who ran into the same problem. This script sets the environment variable $EDITOR to "echo", so that the arguments just appear in standard output and the test script doesn't have an editor popping up. gdb.log looks like this: # gdb.log (gdb) PASS: gdb.base/editor.exp: continue to marker_one edit +24 .///berman/fsf/_current_/source/gdb/HEAD/src/gdb/testsuite/gdb.base/editor.c (gdb) PASS: gdb.base/editor.exp: capture editor command arguments And then the script checks the line number (24) and the filename (".///berman/fsf/.../editor.c"). It checks the filename by calling TCL "file exists ...". # gdb.log PASS: gdb.base/editor.exp: line number argument KFAIL: gdb.base/editor.exp: filename argument (PRMS: gdb/1608) There is lots more that this script could do, such as creating multiple source files, source files with code in '*.h' files, and -- especially -- source files with relative paths, because the treatment of absolute and relative paths is different. But this is a start. I'm particularly interested in whether this bit of TCL is okay: if { [file exists $actual_file] } then { ... } else { ... } Should I use "file exists ..." or "remote_file build exists ..." here? This is just RFC so far. I need to understand the remote issue, and I suspect that I'm going to need a lot of "remote_file ..." stuff to create various files on the build system and manipulate them there. Michael C 2004-07-23 Michael Chastain Test for PR cli/1608. * gdb.base/editor.exp: New file. * gdb.base/editor.c: New file. === editor.c /* This test program is part of GDB, the GNU debugger. Copyright 2004 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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ int value = 117; int marker_1 () { return value; /* marker one */ } int main () { marker_1 (); return 0; } === editor.exp # This test script is part of GDB, the GNU debugger. # Copyright 2004 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 2 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, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Test the "edit" command. if $tracelevel { strace $tracelevel } set testfile "editor" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug"] != "" } { perror "Couldn't compile ${srcfile}" return -1 } # Run gdb with EDITOR set to "echo". There is no "set editor" # command so I have to set this in the environment. global env set old_EDITOR "" if [info exists env(EDITOR)] { set old_EDITOR $env(EDITOR) set env(EDITOR) "echo" } gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} if ![runto_main] then { perror "couldn't run to breakpoint" continue } set marker_one [gdb_get_line_number "marker one"] gdb_test "break $marker_one" \ "Breakpoint.*at.* file .*$srcfile, line $marker_one." \ "breakpoint marker_one" gdb_test "continue" \ "Continuing.*marker one.*" \ "continue to marker_one" # Capture the editor command line. # It looks like this: # +24 /path/path/path/$srcfile set actual_line "no line" set actual_file "no file" set testname "capture editor command arguments" gdb_test_multiple "edit" $testname { -re "\[+\](\[0-9\]+) (.*)\r\n$gdb_prompt $" { set actual_line $expect_out(1,string) set actual_file $expect_out(2,string) pass $testname } } # Check the line number argument. if { $actual_line == $marker_one } then { pass "line number argument" } else { fail "line number argument" } # Check the filename. It might have been canonicalized in some way. # Just check that I can read the source file. if { [file exists $actual_file] } then { pass "filename argument" } else { kfail "gdb/1608" "filename argument" } # Restore EDITOR. if [info exists env(EDITOR)] { set env(EDITOR) $old_EDITOR } # More stuff to add: # "edit" with no source file. # A source file in the current directory on the build machine. # A source file with a relative path on the build machine. # Multiple source files. # Breakpoints in header files. # Source files with #line comments.