summaryrefslogtreecommitdiff
path: root/gdb/inf-ptrace.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2010-07-19 17:51:22 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2010-07-19 17:51:22 +0000
commitaa2614659d7863f1afe4da2251312f7da9236ea5 (patch)
tree1663ce4a8923f8bfaf94c63ea6c5a8766d0d1f4d /gdb/inf-ptrace.c
parente7a84eb6873575517586ae3df2844a35c7d031fc (diff)
downloadgdb-aa2614659d7863f1afe4da2251312f7da9236ea5.tar.gz
gdb/
Make core files the process_stratum. * corefile.c (core_target): New variable. (core_file_command): Remove variable t, use core_target. * corelow.c (core_ops): Make it static. (init_core_ops): Change to process_stratum. Initialize CORE_TARGET. * defs.h (make_cleanup_unpush_target): New prototype. * gdbarch.h: Regenerate. * gdbarch.sh (core_pid_to_str): Remove core_stratum from its comment. * gdbcore.h (core_target): New declaration. * inf-ptrace.c (inf_ptrace_create_inferior, inf_ptrace_attach): New variables ops_already_pushed and back_to. Use push_target, make_cleanup_unpush_target and discard_cleanups calls. * record.c (record_open): Replace core_stratum by a core_bfd check. * target.c (target_is_pushed): New function. (find_core_target): Remove. * target.h (enum strata) <core_stratum>: Remove. (target_is_pushed): New declaration. (find_core_target): Remove declaration. * tracepoint.c (init_tfile_ops) <to_stratum>: Remove comment. * utils.c (do_unpush_target, make_cleanup_unpush_target): New functions. gdb/doc/ Make core files the process_stratum. * gdb.texinfo (Active Targets): Remove core_stratum. Include record_stratum example. gdb/testsuite/ Make core files the process_stratum. * gdb.base/corefile.exp (run: load core again) (run: sanity check we see the core file, run: with core) (run: core file is cleared, attach: load core again) (attach: sanity check we see the core file, attach: with core) (attach: core file is cleared): New tests. * gdb.base/coremaker.c (main): New parameters. Implement "sleep" argv.
Diffstat (limited to 'gdb/inf-ptrace.c')
-rw-r--r--gdb/inf-ptrace.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index ba9d8a8aec9..82dfc343fc4 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -121,10 +121,23 @@ inf_ptrace_create_inferior (struct target_ops *ops,
{
int pid;
+ /* Do not change either targets above or the same target if already present.
+ The reason is the target stack is shared across multiple inferiors. */
+ int ops_already_pushed = target_is_pushed (ops);
+ struct cleanup *back_to;
+
+ if (! ops_already_pushed)
+ {
+ /* Clear possible core file with its process_stratum. */
+ push_target (ops);
+ back_to = make_cleanup_unpush_target (ops);
+ }
+
pid = fork_inferior (exec_file, allargs, env, inf_ptrace_me, NULL,
NULL, NULL);
- push_target (ops);
+ if (! ops_already_pushed)
+ discard_cleanups (back_to);
/* On some targets, there must be some explicit synchronization
between the parent and child processes after the debugger
@@ -189,11 +202,24 @@ inf_ptrace_attach (struct target_ops *ops, char *args, int from_tty)
pid_t pid;
struct inferior *inf;
+ /* Do not change either targets above or the same target if already present.
+ The reason is the target stack is shared across multiple inferiors. */
+ int ops_already_pushed = target_is_pushed (ops);
+ struct cleanup *back_to;
+
pid = parse_pid_to_attach (args);
if (pid == getpid ()) /* Trying to masturbate? */
error (_("I refuse to debug myself!"));
+ if (! ops_already_pushed)
+ {
+ /* target_pid_to_str already uses the target. Also clear possible core
+ file with its process_stratum. */
+ push_target (ops);
+ back_to = make_cleanup_unpush_target (ops);
+ }
+
if (from_tty)
{
exec_file = get_exec_file (0);
@@ -226,7 +252,8 @@ inf_ptrace_attach (struct target_ops *ops, char *args, int from_tty)
target, it should decorate the ptid later with more info. */
add_thread_silent (inferior_ptid);
- push_target(ops);
+ if (! ops_already_pushed)
+ discard_cleanups (back_to);
}
#ifdef PT_GET_PROCESS_STATE