attach.exp
来自「模拟嵌入式硬件平台的软件源代码」· EXP 代码 · 共 447 行 · 第 1/2 页
EXP
447 行
# Copyright 1997, 1999, 2002 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. */# Please email any bugs, comments, and/or additions to this file to:# bug-gdb@prep.ai.mit.eduif $tracelevel then { strace $tracelevel }set prms_id 0set bug_id 0# On HP-UX 11.0, this test is causing a process running the program# "attach" to be left around spinning. Until we figure out why, I am# commenting out the test to avoid polluting tiamat (our 11.0 nightly# test machine) with these processes. RT## Setting the magic bit in the target app should work. I added a# "kill", and also a test for the R3 register warning. JBif { [istarget "hppa*-*-hpux*"] } { return 0}# are we on a target boardif [is_remote target] then { return 0}set testfile "attach"set srcfile ${testfile}.cset srcfile2 ${testfile}2.cset binfile ${objdir}/${subdir}/${testfile}set binfile2 ${objdir}/${subdir}/${testfile}2set cleanupfile ${objdir}/${subdir}/${testfile}.awk#execute_anywhere "rm -f ${binfile} ${binfile2}"remote_exec build "rm -f ${binfile} ${binfile2}"# For debugging this test##log_user 1# Clean out any old files from past runs.#remote_exec build "${cleanupfile}"# build the first test case#if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."}# Because we can't attach over nfs, copy binfile to /tmp/${binfile}.${pid}# and replace binfile with a symbolic link set pid [pid] exec /bin/cp -f ${binfile} /tmp/attach1.${pid} exec rm -f ${binfile} set binfile /tmp/attach1.${pid}# exec ln -s /tmp/attach1.${pid} ${binfile}# Build the in-system-call testif { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."}# Because we can't attach over nfs, copy binfile2 to /tmp/${binfile2}.${pid}# and replace binfile2 with a symbolic link set pid [pid] exec cp -f ${binfile2} /tmp/attach2.${pid} exec rm -f ${binfile2} set binfile2 /tmp/attach2.${pid}# exec ln -s /tmp/attach2.${pid} ${binfile2}if [get_compiler_info ${binfile}] { return -1}proc do_attach_tests {} { global gdb_prompt global binfile global srcfile global testfile global objdir global subdir global timeout # Start the program running and then wait for a bit, to be sure # that it can be attached to. # set testpid [eval exec $binfile &] exec sleep 2 # Verify that we cannot attach to nonsense. # send_gdb "attach abc\n" gdb_expect { -re ".*Illegal process-id: abc.*$gdb_prompt $"\ {pass "attach to nonsense is prohibited"} -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $"\ { # Response expected from /proc-based systems. pass "attach to nonsense is prohibited" } -re "Attaching to.*$gdb_prompt $"\ {fail "attach to nonsense is prohibited (bogus pid allowed)"} -re "$gdb_prompt $" {fail "attach to nonsense is prohibited"} timeout {fail "(timeout) attach to nonsense is prohibited"} } # Verify that we cannot attach to what appears to be a valid # process ID, but is a process that doesn't exist. (I don't # believe any process is ever assigned #0, at least on HPUX.) # send_gdb "attach 0\n" gdb_expect { -re "Attaching to.*, process 0.*No such process.*$gdb_prompt $"\ { # Response expected on HP-UX 10.20 (i.e., ptrace-based). pass "attach to nonexistent process is prohibited" } -re "Attaching to.*, process 0 failed.*Hint.*$gdb_prompt $"\ { # Response expected on HP-UX 11.0 (i.e., ttrace-based). pass "attach to nonexistent process is prohibited" } -re "Attaching to.*, process 0.*denied.*$gdb_prompt $"\ {pass "attach to nonexistent process is prohibited"} -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $"\ { # Response expected from /proc-based systems. pass "attach to nonexistent process is prohibited" } -re "$gdb_prompt $" {fail "attach to nonexistent process is prohibited"} timeout {fail "(timeout) attach to nonexistent process is prohibited"} } # Verify that we can attach to the process by first giving its # executable name via the file command, and using attach with # the process ID. # # (Actually, the test system appears to do this automatically # for us. So, we must also be prepared to be asked if we want # to discard an existing set of symbols.) # send_gdb "file $binfile\n" gdb_expect { -re "Load new symbol table from.*y or n.*$" { send_gdb "y\n" gdb_expect { -re "Reading symbols from $binfile\.\.\.*done.*$gdb_prompt $"\ {pass "(re)set file, before attach1"} -re "$gdb_prompt $" {fail "(re)set file, before attach1"} timeout {fail "(timeout) (re)set file, before attach1"} } } -re "Reading symbols from $binfile\.\.\.*done.*$gdb_prompt $"\ {pass "set file, before attach1"} -re "$gdb_prompt $" {fail "set file, before attach1"} timeout {fail "(timeout) set file, before attach1"} } send_gdb "attach $testpid\n" gdb_expect { -re "Attaching to program.*`?$binfile'?, process $testpid.*main.*at .*$srcfile:.*$gdb_prompt $"\ {pass "attach1, after setting file"} -re "$gdb_prompt $" {fail "attach1, after setting file"} timeout {fail "(timeout) attach1, after setting file"} } # Verify that we can "see" the variable "should_exit" in the # program, and that it is zero. # send_gdb "print should_exit\n" gdb_expect { -re ".* = 0.*$gdb_prompt $"\ {pass "after attach1, print should_exit"} -re "$gdb_prompt $" {fail "after attach1, print should_exit"} timeout {fail "(timeout) after attach1, print should_exit"} } # Detach the process. # send_gdb "detach\n" gdb_expect { -re "Detaching from program: .*$binfile.*$gdb_prompt $"\ {pass "attach1 detach"} -re "$gdb_prompt $" {fail "attach1 detach"} timeout {fail "(timeout) attach1 detach"} } # Wait a bit for gdb to finish detaching # exec sleep 5 # Purge the symbols from gdb's brain. (We want to be certain # the next attach, which won't be preceded by a "file" command, # is really getting the executable file without our help.) # set old_timeout $timeout set timeout 15 send_gdb "file\n" gdb_expect { -re ".*gdb internal error.*$" { fail "Internal error, prob. Memory corruption" } -re "No executable file now.*Discard symbol table.*y or n.*$" { send_gdb "y\n"
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?