public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Mark Kettenis <mark.kettenis@xs4all.nl>,
	Joel Brobecker <brobecker@adacore.com>,
	gdb-patches@sourceware.org
Subject: Re: [patch] Forbid run with a core file loaded
Date: Sun, 23 May 2010 21:16:00 -0000	[thread overview]
Message-ID: <201005232208.44968.pedro@codesourcery.com> (raw)
In-Reply-To: <20100523185440.GA12068@host0.dyn.jankratochvil.net>

On Sunday 23 May 2010 19:54:40, Jan Kratochvil wrote:
> On Fri, 21 May 2010 17:06:07 +0200, Pedro Alves wrote:
> > I don't think it makes that much sense nowadays to have a
> > distinct core_stratum vs process_stratum.
> 
> OK, removed core_stratum.

Thanks.

> @@ -194,6 +195,10 @@ inf_ptrace_attach (struct target_ops *ops, char *args, int from_tty)
>    if (pid == getpid ())                /* Trying to masturbate?  */
>      error (_("I refuse to debug myself!"));
>  
> +  /* target_pid_to_str already uses the target.  Clear possible core file with
> +     its process_stratum.  */
> +  pop_all_targets_above (ops->to_stratum - 1, 0);
> +

Unfortunately, this would break multiprocess.  For example, you may
be attaching to your second process (e.g., "start", "add-inferior",
"inferior 2", "attach $pid"), and the thread stratum needs to remain
pushed for the first inferior/process.

> +  /* Clear possible core file with its process_stratum.  */
> +  push_target (ops);
> +
>    pid = fork_inferior (exec_file, allargs, env, inf_ptrace_me, NULL,
>                        NULL, NULL);
>  
> -  push_target (ops);

This makes sense, as indeed fork_inferior touches the current
target, even today, but, can you check what happens if fork_inferior
throws an error?  I worry that if, for example, exec fails, we still
end up with the target pushed.  Probably not a big issue for linux-nat.c,
which since it support multi-process, handles being pushed with
inferior_ptid == null_ptid, but other ptrace targets don't.

> On Fri, 21 May 2010 17:02:31 +0200, Joel Brobecker wrote:
> > > +set test "start with core"
> > > +gdb_test_multiple "start" $test {
> > > +    -re {Core file is already loaded.  Unload it[?] [(]y or n[)] } {
> > > +   pass $test
> > > +    }
> > > +}
> > 
> > We should not use the "start" command in testcases, as it does not
> > work with remote targets. I'm afraid we're going to have to rely on
> > the run command instead.

There's some confusion here.  "start" doesn't work with "target remote",
just as much as "run" doesn't work.  In other words, if "run" would
work, so would "start", as the latter is just the former plus an
internal temporary breakpoint on `main'.

> OK, used runto_main now.  Attach test does not run with gdbserver the same way
> gdb.base/attach.exp does not.  Tested this testfile with runtest-gdbserver
> (only on localhost).

-- 
Pedro Alves

  parent reply	other threads:[~2010-05-23 21:08 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-21 14:47 Jan Kratochvil
2010-05-21 15:02 ` Mark Kettenis
2010-05-21 15:05   ` Pedro Alves
2010-05-21 15:54     ` Mark Kettenis
2010-05-21 16:08       ` Pedro Alves
2010-05-21 15:05   ` Joel Brobecker
2010-05-21 15:40     ` Mark Kettenis
2010-05-23 19:38       ` Jan Kratochvil
2010-05-23 21:08         ` Eli Zaretskii
2010-06-06 19:51           ` Jan Kratochvil
2010-06-06 23:08             ` Eli Zaretskii
2010-06-07 11:21             ` Pedro Alves
2010-06-08  2:33               ` Tom Tromey
2010-06-08 11:03                 ` Pedro Alves
2010-07-08 17:17               ` Jan Kratochvil
2010-07-08 18:28                 ` Eli Zaretskii
2010-07-19 18:02                   ` Jan Kratochvil
2010-07-19 18:05                     ` Eli Zaretskii
2010-07-19 18:16                       ` Jan Kratochvil
2010-07-27 16:00                     ` Joel Brobecker
2010-07-19 14:37                 ` Pedro Alves
2010-05-23 21:16         ` Pedro Alves [this message]
2010-05-21 15:07   ` Jan Kratochvil
2010-05-21 15:04 ` Joel Brobecker
2010-05-21 15:06 ` Pedro Alves
2010-05-21 15:15   ` Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201005232208.44968.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=mark.kettenis@xs4all.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).