aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2014-02-28 09:47:34 -0700
committerTom Tromey <tromey@redhat.com>2014-03-12 13:05:58 -0600
commitb3ccfe11d3b0fc84f8ccd4e4fa25b75d1dc71cfc (patch)
treebcaf99bcdc993f80db556b6851fa051a00f55fdf /gdb/testsuite/gdb.base
parent55d9b4c146716a683d9fea769e5f4106eadb30fc (diff)
downloadfsf-binutils-gdb-b3ccfe11d3b0fc84f8ccd4e4fa25b75d1dc71cfc.zip
fsf-binutils-gdb-b3ccfe11d3b0fc84f8ccd4e4fa25b75d1dc71cfc.tar.gz
fsf-binutils-gdb-b3ccfe11d3b0fc84f8ccd4e4fa25b75d1dc71cfc.tar.bz2
fix regressions with target-async
A patch in the target cleanup series caused a regression when using record with target-async. Version 4 of the patch is here: https://sourceware.org/ml/gdb-patches/2014-03/msg00159.html The immediate problem is that record supplies to_can_async_p and to_is_async_p methods, but does not supply a to_async method. So, when target-async is set, record claims to support async -- but if the underlying target does not support async, then the to_async method call will end up in that method's default implementation, namely tcomplain. This worked previously because the record target used to provide a to_async method; one that (erroneously, only at push time) checked the other members of the target stack, and then simply dropped to_async calls in the "does not implement async" case. My first thought was to simply drop tcomplain as the default for to_async. This works, but Pedro pointed out that the only reason record has to supply to_can_async_p and to_is_async_p is that these default to using the find_default_run_target machinery -- and these defaults are only needed by "run" and "attach". So, a nicer solution presents itself: change run and attach to explicitly call into the default run target when needed; and change to_is_async_p and to_can_async_p to default to "return 0". This makes the target stack simpler to use and lets us remove the method implementations from record. This is also in harmony with other plans for the target stack; namely trying to reduce the impact of find_default_run_target. This approach makes it clear that find_default_is_async_p is not needed -- it is asking whether a target that may not even be pushed is actually async, which seems like a nonsensical question. While an improvement, this approach proved to introduce the same bug when using the core target. Looking a bit deeper, the issue is that code in "attach" and "run" may need to use either the current target stack or the default run target -- but different calls into the target API in those functions could wind up querying different targets. This new patch makes the target to use more explicit in "run" and "attach". Then these commands explicitly make the needed calls against that target. This ensures that a single target is used for all relevant operations. This lets us remove a couple find_default_* functions from various targets, including the dummy target. I think this is a decent understandability improvement. One issue I see with this patch is that the new calls in "run" and "attach" are not very much like the rest of the target API. I think fundamentally this is due to bad factoring in the target API, which may need to be fixed for multi-target. Tackling that seemed ambitious for a regression fix. While working on this I noticed that there don't seem to be any test cases that involve both target-async and record, so this patch changes break-precsave.exp to add some. It also changes corefile.exp to add some target-async tests; these pass with current trunk and with this patch applied, but fail with the v1 patch. This patch differs from v4 in that it moves initialization of to_can_async_p and to_supports_non_stop into inf-child, adds some assertions to complete_target_initialization, and adds some comments to target.h. Built and regtested on x86-64 Fedora 20. 2014-03-12 Tom Tromey <tromey@redhat.com> * inf-child.c (return_zero): New function. (inf_child_target): Set to_can_async_p, to_supports_non_stop. * aix-thread.c (aix_thread_inferior_created): New function. (aix_thread_attach): Remove. (init_aix_thread_ops): Don't set to_attach. (_initialize_aix_thread): Register inferior_created observer. * corelow.c (init_core_ops): Don't set to_attach or to_create_inferior. * exec.c (init_exec_ops): Don't set to_attach or to_create_inferior. * infcmd.c (run_command_1): Use find_run_target. Make direct target calls. (attach_command): Use find_attach_target. Make direct target calls. * record-btrace.c (init_record_btrace_ops): Don't set to_create_inferior. * record-full.c (record_full_can_async_p, record_full_is_async_p): Remove. (init_record_full_ops, init_record_full_core_ops): Update. Don't set to_create_inferior. * target.c (complete_target_initialization): Add assertion. (target_create_inferior): Remove. (find_default_attach, find_default_create_inferior): Remove. (find_attach_target, find_run_target): New functions. (find_default_is_async_p, find_default_can_async_p) (target_supports_non_stop, target_attach): Remove. (init_dummy_target): Don't set to_create_inferior or to_supports_non_stop. * target.h (struct target_ops) <to_attach>: Add comment. Remove TARGET_DEFAULT_FUNC. <to_create_inferior>: Add comment. <to_can_async_p, to_is_async_p, to_supports_non_stop>: Use TARGET_DEFAULT_RETURN. <to_can_async_p, to_supports_non_stop, to_can_run>: Add comments. (find_attach_target, find_run_target): Declare. (target_create_inferior): Remove. (target_has_execution_1): Update comment. (target_supports_non_stop): Remove. * target-delegates.c: Rebuild. 2014-03-12 Tom Tromey <tromey@redhat.com> * gdb.base/corefile.exp (corefile_test_run, corefile_test_attach): New procs. Add target-async tests. * gdb.reverse/break-precsave.exp (precsave_tests): New proc. Add target-async tests.
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r--gdb/testsuite/gdb.base/corefile.exp115
1 files changed, 71 insertions, 44 deletions
diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp
index 61c13c4..6eb1f02 100644
--- a/gdb/testsuite/gdb.base/corefile.exp
+++ b/gdb/testsuite/gdb.base/corefile.exp
@@ -185,35 +185,41 @@ gdb_test "core" "No core file now."
# Test a run (start) command will clear any loaded core file.
-gdb_test "core-file $corefile" "Core was generated by .*" "run: load core again"
-gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "run: sanity check we see the core file"
-
-set test "run: with core"
-if [runto_main] {
- pass $test
-} else {
- fail $test
-}
+proc corefile_test_run {} {
+ global corefile gdb_prompt
+
+ gdb_test "core-file $corefile" "Core was generated by .*" "run: load core again"
+ gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "run: sanity check we see the core file"
-set test "run: core file is cleared"
-gdb_test_multiple "info files" $test {
- -re "\r\nLocal core dump file:\r\n.*\r\n$gdb_prompt $" {
+ set test "run: with core"
+ if [runto_main] {
+ pass $test
+ } else {
fail $test
}
- -re "\r\n$gdb_prompt $" {
- pass $test
+
+ set test "run: core file is cleared"
+ gdb_test_multiple "info files" $test {
+ -re "\r\nLocal core dump file:\r\n.*\r\n$gdb_prompt $" {
+ fail $test
+ }
+ -re "\r\n$gdb_prompt $" {
+ pass $test
+ }
}
-}
-set test "quit with a process"
-gdb_test_multiple "quit" $test {
- -re "A debugging session is active.\r\n.*\r\nQuit anyway\\? \\(y or n\\) $" {
- pass $test
- gdb_test "n" {Not confirmed\.} "quit with processes: n"
+ set test "quit with a process"
+ gdb_test_multiple "quit" $test {
+ -re "A debugging session is active.\r\n.*\r\nQuit anyway\\? \\(y or n\\) $" {
+ pass $test
+ gdb_test "n" {Not confirmed\.} "quit with processes: n"
+ }
}
+
+ gdb_exit
}
-gdb_exit
+corefile_test_run
# Verify there is no question if only a core file is loaded.
@@ -235,37 +241,48 @@ gdb_exit
# Test an attach command will clear any loaded core file.
-if ![is_remote target] {
- set test "attach: spawn sleep"
- set res [remote_spawn host "$binfile sleep"]
- if { $res < 0 || $res == "" } {
- fail $test
- return
- }
- set pid [exp_pid -i $res]
- # We don't care whether the program is still in the startup phase when we
- # attach.
-
- gdb_start
+proc corefile_test_attach {{async 0}} {
+ global binfile corefile gdb_prompt
- gdb_test "core-file $corefile" "Core was generated by .*" "attach: load core again"
- gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "attach: sanity check we see the core file"
+ if ![is_remote target] {
+ set test "attach: spawn sleep"
+ set res [remote_spawn host "$binfile sleep"]
+ if { $res < 0 || $res == "" } {
+ fail $test
+ return
+ }
+ set pid [exp_pid -i $res]
+ # We don't care whether the program is still in the startup phase when we
+ # attach.
- gdb_test "attach $pid" "Attaching to process $pid\r\n.*" "attach: with core"
+ gdb_start
- set test "attach: core file is cleared"
- gdb_test_multiple "info files" $test {
- -re "\r\nLocal core dump file:\r\n.*\r\n$gdb_prompt $" {
- fail $test
+ if {$async} {
+ gdb_test_no_output "set target-async on" \
+ "enable target-async for attach tests"
}
- -re "\r\n$gdb_prompt $" {
- pass $test
+
+ gdb_test "core-file $corefile" "Core was generated by .*" "attach: load core again"
+ gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "attach: sanity check we see the core file"
+
+ gdb_test "attach $pid" "Attaching to process $pid\r\n.*" "attach: with core"
+
+ set test "attach: core file is cleared"
+ gdb_test_multiple "info files" $test {
+ -re "\r\nLocal core dump file:\r\n.*\r\n$gdb_prompt $" {
+ fail $test
+ }
+ -re "\r\n$gdb_prompt $" {
+ pass $test
+ }
}
- }
- gdb_exit
+ gdb_exit
+ }
}
+corefile_test_attach
+
# Test warning-free core file load. E.g., a Linux vDSO used to
# trigger this warning:
# warning: Can't read pathname for load map: Input/output error.
@@ -281,3 +298,13 @@ gdb_test_multiple "core-file $corefile" $test {
pass $test
}
}
+
+
+# Try a couple tests again with target-async.
+with_test_prefix "target-async" {
+ clean_restart ${testfile}
+
+ gdb_test_no_output "set target-async on"
+ corefile_test_run
+ corefile_test_attach 1
+}