PageRenderTime 52ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/gdb-6.3-inferior-notification-20050721.patch

#
Patch | 315 lines | 311 code | 4 blank | 0 comment | 0 complexity | 68494aa01c13036add19dbe58c71da06 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, GPL-3.0, LGPL-2.1
  1. 2005-07-21 Jeff Johnston <jjohnstn@redhat.com>
  2. * gdb.base/attach-32.exp: New test for attaching in 32-bit
  3. mode on 64-bit systems.
  4. * gdb.base/attach-32.c: Ditto.
  5. * gdb.base/attach-32b.c: Ditto.
  6. 2007-12-26 Jan Kratochvil <jan.kratochvil@redhat.com>
  7. * gdb.base/attach-32.exp: Fix forgotten $GDBFLAGS as set.
  8. Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32.c
  9. ===================================================================
  10. --- /dev/null 1970-01-01 00:00:00.000000000 +0000
  11. +++ gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32.c 2011-03-20 20:15:57.000000000 +0100
  12. @@ -0,0 +1,20 @@
  13. +/* This program is intended to be started outside of gdb, and then
  14. + attached to by gdb. Thus, it simply spins in a loop. The loop
  15. + is exited when & if the variable 'should_exit' is non-zero. (It
  16. + is initialized to zero in this program, so the loop will never
  17. + exit unless/until gdb sets the variable to non-zero.)
  18. + */
  19. +#include <stdio.h>
  20. +
  21. +int should_exit = 0;
  22. +
  23. +int main ()
  24. +{
  25. + int local_i = 0;
  26. +
  27. + while (! should_exit)
  28. + {
  29. + local_i++;
  30. + }
  31. + return 0;
  32. +}
  33. Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32.exp
  34. ===================================================================
  35. --- /dev/null 1970-01-01 00:00:00.000000000 +0000
  36. +++ gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32.exp 2011-03-20 20:20:03.000000000 +0100
  37. @@ -0,0 +1,245 @@
  38. +# Copyright 2005 Free Software Foundation, Inc.
  39. +
  40. +# This program is free software; you can redistribute it and/or modify
  41. +# it under the terms of the GNU General Public License as published by
  42. +# the Free Software Foundation; either version 2 of the License, or
  43. +# (at your option) any later version.
  44. +#
  45. +# This program is distributed in the hope that it will be useful,
  46. +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  47. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  48. +# GNU General Public License for more details.
  49. +#
  50. +# You should have received a copy of the GNU General Public License
  51. +# along with this program; if not, write to the Free Software
  52. +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  53. +#
  54. +# This test was based on attach.exp and modified for 32/64 bit Linux systems. */
  55. +
  56. +# On HP-UX 11.0, this test is causing a process running the program
  57. +# "attach" to be left around spinning. Until we figure out why, I am
  58. +# commenting out the test to avoid polluting tiamat (our 11.0 nightly
  59. +# test machine) with these processes. RT
  60. +#
  61. +# Setting the magic bit in the target app should work. I added a
  62. +# "kill", and also a test for the R3 register warning. JB
  63. +if { ![istarget "x86_64*-*linux*"]
  64. + && ![istarget "powerpc64*-*linux*"]} {
  65. + return 0
  66. +}
  67. +
  68. +# are we on a target board
  69. +if [is_remote target] then {
  70. + return 0
  71. +}
  72. +
  73. +set testfile "attach-32"
  74. +set srcfile ${testfile}.c
  75. +set srcfile2 ${testfile}b.c
  76. +set binfile ${objdir}/${subdir}/${testfile}
  77. +set binfile2 ${objdir}/${subdir}/${testfile}b
  78. +set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${testfile}]
  79. +
  80. +#execute_anywhere "rm -f ${binfile} ${binfile2}"
  81. +remote_exec build "rm -f ${binfile} ${binfile2}"
  82. +# For debugging this test
  83. +#
  84. +#log_user 1
  85. +
  86. +# build the first test case
  87. +#
  88. +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "additional_flags=-m32"]] != "" } {
  89. + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
  90. +}
  91. +
  92. +# Build the in-system-call test
  93. +
  94. +if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable [list debug "additional_flags=-m32"]] != "" } {
  95. + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
  96. +}
  97. +
  98. +if [get_compiler_info ${binfile}] {
  99. + return -1
  100. +}
  101. +
  102. +proc do_attach_tests {} {
  103. + global gdb_prompt
  104. + global binfile
  105. + global escapedbinfile
  106. + global srcfile
  107. + global testfile
  108. + global objdir
  109. + global subdir
  110. + global timeout
  111. + global testpid
  112. +
  113. + # Verify that we can "see" the variable "should_exit" in the
  114. + # program, and that it is zero.
  115. +
  116. + gdb_test "print should_exit" " = 0" "after attach-32, print should_exit"
  117. +
  118. + # Verify that we can modify the variable "should_exit" in the
  119. + # program.
  120. +
  121. + gdb_test "set should_exit=1" "" "after attach-32, set should_exit"
  122. +
  123. + # Verify that the modification really happened.
  124. +
  125. + send_gdb "tbreak 19\n"
  126. + gdb_expect {
  127. + -re "reakpoint .*at.*$srcfile, line 19.*$gdb_prompt $" {
  128. + pass "after attach-32, set tbreak postloop"
  129. + }
  130. + -re "$gdb_prompt $" {
  131. + fail "after attach-32, set tbreak postloop"
  132. + }
  133. + timeout {
  134. + fail "(timeout) after attach-32, set tbreak postloop"
  135. + }
  136. + }
  137. + send_gdb "continue\n"
  138. + gdb_expect {
  139. + -re "main.*at.*$srcfile:19.*$gdb_prompt $" {
  140. + pass "after attach-32, reach tbreak postloop"
  141. + }
  142. + -re "$gdb_prompt $" {
  143. + fail "after attach-32, reach tbreak postloop"
  144. + }
  145. + timeout {
  146. + fail "(timeout) after attach-32, reach tbreak postloop"
  147. + }
  148. + }
  149. +
  150. + # Allow the test process to exit, to cleanup after ourselves.
  151. +
  152. + gdb_test "continue" {\[Inferior .* exited normally\]} "after attach-32, exit"
  153. +
  154. + # Make sure we don't leave a process around to confuse
  155. + # the next test run (and prevent the compile by keeping
  156. + # the text file busy), in case the "set should_exit" didn't
  157. + # work.
  158. +
  159. + remote_exec build "kill -9 ${testpid}"
  160. +
  161. + # Start the program running and then wait for a bit, to be sure
  162. + # that it can be attached to.
  163. +
  164. + set testpid [eval exec $binfile &]
  165. + exec sleep 2
  166. + if { [istarget "*-*-cygwin*"] } {
  167. + # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
  168. + # different due to the way fork/exec works.
  169. + set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
  170. + }
  171. +
  172. + # Verify that we can attach to the process, and find its a.out
  173. + # when we're cd'd to some directory that doesn't contain the
  174. + # a.out. (We use the source path set by the "dir" command.)
  175. +
  176. + gdb_test "dir ${objdir}/${subdir}" "Source directories searched: .*" \
  177. + "set source path"
  178. +
  179. + gdb_test "cd /tmp" "Working directory /tmp." \
  180. + "cd away from process working directory"
  181. +
  182. + # Explicitly flush out any knowledge of the previous attachment.
  183. +
  184. + set test "before attach-32-3, flush symbols"
  185. + gdb_test_multiple "symbol" "$test" {
  186. + -re "Discard symbol table from.*y or n. $" {
  187. + gdb_test "y" "No symbol file now." \
  188. + "$test"
  189. + }
  190. + -re "No symbol file now.*$gdb_prompt $" {
  191. + pass "$test"
  192. + }
  193. + }
  194. +
  195. + gdb_test "exec" "No executable file now." \
  196. + "before attach-32-3, flush exec"
  197. +
  198. + gdb_test "attach $testpid" \
  199. + "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*" \
  200. + "attach-32 when process' a.out not in cwd"
  201. +
  202. + set test "after attach-32-3, exit"
  203. + gdb_test_multiple "kill" "$test" {
  204. + -re "Kill the program being debugged.*y or n. $" {
  205. + gdb_test "y" "" "$test"
  206. + }
  207. + }
  208. +
  209. + # Another "don't leave a process around"
  210. + remote_exec build "kill -9 ${testpid}"
  211. +}
  212. +
  213. +proc do_call_attach_tests {} {
  214. + global gdb_prompt
  215. + global binfile2
  216. + global testpid
  217. +
  218. + # See if other registers are problems
  219. +
  220. + set test "info other register"
  221. + gdb_test_multiple "i r r3" "$test" {
  222. + -re "warning: reading register.*$gdb_prompt $" {
  223. + fail "$test"
  224. + }
  225. + -re "r3.*$gdb_prompt $" {
  226. + pass "$test"
  227. + }
  228. + }
  229. +
  230. + # Get rid of the process
  231. +
  232. + gdb_test "p should_exit = 1"
  233. + gdb_test "c" {\[Inferior .* exited normally\]}
  234. +
  235. + # Be paranoid
  236. +
  237. + remote_exec build "kill -9 ${testpid}"
  238. +}
  239. +
  240. +
  241. +# Start with a fresh gdb
  242. +
  243. +gdb_exit
  244. +set testpid [eval exec $binfile &]
  245. +exec sleep 3
  246. +if { [istarget "*-*-cygwin*"] } {
  247. + # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
  248. + # different due to the way fork/exec works.
  249. + set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
  250. +}
  251. +
  252. +set GDBFLAGS_orig $GDBFLAGS
  253. +set GDBFLAGS "--pid=$testpid"
  254. +gdb_start
  255. +set GDBFLAGS $GDBFLAGS_orig
  256. +
  257. +gdb_reinitialize_dir $srcdir/$subdir
  258. +
  259. +# This is a test of gdb's ability to attach to a running process.
  260. +
  261. +do_attach_tests
  262. +
  263. +# Test attaching when the target is inside a system call
  264. +
  265. +gdb_exit
  266. +set testpid [eval exec $binfile2 &]
  267. +exec sleep 3
  268. +if { [istarget "*-*-cygwin*"] } {
  269. + # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
  270. + # different due to the way fork/exec works.
  271. + set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
  272. +}
  273. +
  274. +set GDBFLAGS_orig $GDBFLAGS
  275. +set GDBFLAGS "--pid=$testpid"
  276. +gdb_start
  277. +set GDBFLAGS $GDBFLAGS_orig
  278. +
  279. +gdb_reinitialize_dir $srcdir/$subdir
  280. +do_call_attach_tests
  281. +
  282. +return 0
  283. Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32b.c
  284. ===================================================================
  285. --- /dev/null 1970-01-01 00:00:00.000000000 +0000
  286. +++ gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32b.c 2011-03-20 20:15:57.000000000 +0100
  287. @@ -0,0 +1,24 @@
  288. +/* This program is intended to be started outside of gdb, and then
  289. + attached to by gdb. Thus, it simply spins in a loop. The loop
  290. + is exited when & if the variable 'should_exit' is non-zero. (It
  291. + is initialized to zero in this program, so the loop will never
  292. + exit unless/until gdb sets the variable to non-zero.)
  293. + */
  294. +#include <stdio.h>
  295. +#include <stdlib.h>
  296. +#include <unistd.h>
  297. +
  298. +int should_exit = 0;
  299. +
  300. +int main ()
  301. +{
  302. + int local_i = 0;
  303. +
  304. + sleep( 10 ); /* System call causes register fetch to fail */
  305. + /* This is a known HPUX "feature" */
  306. + while (! should_exit)
  307. + {
  308. + local_i++;
  309. + }
  310. + return (0);
  311. +}