public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/16188] New: Verify PTRACE_TRACEME succeeded?
@ 2013-11-18 23:09 dje at google dot com
  2013-11-19 10:39 ` [Bug gdb/16188] " palves at redhat dot com
  0 siblings, 1 reply; 2+ messages in thread
From: dje at google dot com @ 2013-11-18 23:09 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=16188

            Bug ID: 16188
           Summary: Verify PTRACE_TRACEME succeeded?
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: dje at google dot com

It would help when debugging certain kinds of problems if one could know
whether the PTRACE_TRACEME call succeeded.

Maybe this could pass a pass/fail code to its caller and the caller could at
least notify the user?

static void
inf_ptrace_me (void)
{
  /* "Trace me, Dr. Memory!"  */
  ptrace (PT_TRACE_ME, 0, (PTRACE_TYPE_ARG3)0, 0);
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug gdb/16188] Verify PTRACE_TRACEME succeeded?
  2013-11-18 23:09 [Bug gdb/16188] New: Verify PTRACE_TRACEME succeeded? dje at google dot com
@ 2013-11-19 10:39 ` palves at redhat dot com
  0 siblings, 0 replies; 2+ messages in thread
From: palves at redhat dot com @ 2013-11-19 10:39 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=16188

Pedro Alves <palves at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |palves at redhat dot com

--- Comment #1 from Pedro Alves <palves at redhat dot com> ---
Yeah.  In fork_inferior, we handle a similar case, when the fork child fails to
exec:

      /* "Trace me, Dr. Memory!"  */
      (*traceme_fun) ();
...
      environ = env;

      if (exec_fun != NULL)
        (*exec_fun) (argv[0], argv, env);
      else
        execvp (argv[0], argv);

      /* If we get here, it's an error.  */
      save_errno = errno;
      fprintf_unfiltered (gdb_stderr, "Cannot exec %s", exec_file);
      for (i = 1; argv[i] != NULL; i++)
    fprintf_unfiltered (gdb_stderr, " %s", argv[i]);
      fprintf_unfiltered (gdb_stderr, ".\n");
      fprintf_unfiltered (gdb_stderr, "Error: %s\n",
              safe_strerror (save_errno));
      gdb_flush (gdb_stderr);
      _exit (0177);
    }


So it seems like what's missing is making traceme_fun return an error
indication, and then change

      (*traceme_fun) ();

to check for failure and _exit with error.  This will make startup_inferior see
the child exit (before the number of expected traps), and error out with
"During startup program exited with code ...".

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-11-19 10:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-18 23:09 [Bug gdb/16188] New: Verify PTRACE_TRACEME succeeded? dje at google dot com
2013-11-19 10:39 ` [Bug gdb/16188] " palves at redhat dot com

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).