print_sys_errmsg (pi->pathname, errno);
error ("PIOCWSTOP failed");
}
+ pi->had_event = 1;
#endif
if (attach_flag)
static void
procfs_kill_inferior ()
{
- struct procinfo *pi;
-
- for (pi = procinfo_list; pi; pi = pi->next)
- unconditionally_kill_inferior (pi);
-
target_mourn_inferior ();
}
create_procinfo (pid);
add_thread (pid); /* Setup initial thread */
+
+ /* One trap to exec the shell, one to exec the program being debugged. */
+ startup_inferior (2);
}
/*
proc_set_exec_trap ()
{
sysset_t exitset;
+ sysset_t entryset;
auto char procname[32];
int fd;
if ((fd = open (procname, O_RDWR)) < 0)
{
perror (procname);
- fflush (stderr);
+ gdb_flush (gdb_stderr);
_exit (127);
}
premptyset (&exitset);
+ premptyset (&entryset);
/* GW: Rationale...
Not all systems with /proc have all the exec* syscalls with the same
praddset (&exitset, SYS_execve);
#endif
#ifdef SYS_execv
- praddset(&exitset, SYS_execv);
+ praddset (&exitset, SYS_execv);
#endif
if (ioctl (fd, PIOCSEXIT, &exitset) < 0)
{
perror (procname);
- fflush (stderr);
+ gdb_flush (gdb_stderr);
_exit (127);
}
+ praddset (&entryset, SYS_exit);
+
+ if (ioctl (fd, PIOCSENTRY, &entryset) < 0)
+ {
+ perror (procname);
+ gdb_flush (gdb_stderr);
+ _exit (126);
+ }
+
/* Turn off inherit-on-fork flag so that all grand-children of gdb
start with tracing flags cleared. */
exec_file = (char *) get_exec_file (0);
if (exec_file)
- printf ("Attaching to program `%s', %s\n", exec_file, target_pid_to_str (pid));
+ printf_unfiltered ("Attaching to program `%s', %s\n", exec_file, target_pid_to_str (pid));
else
- printf ("Attaching to %s\n", target_pid_to_str (pid));
+ printf_unfiltered ("Attaching to %s\n", target_pid_to_str (pid));
- fflush (stdout);
+ gdb_flush (gdb_stdout);
}
do_attach (pid);
char *exec_file = get_exec_file (0);
if (exec_file == 0)
exec_file = "";
- printf ("Detaching from program: %s %s\n",
+ printf_unfiltered ("Detaching from program: %s %s\n",
exec_file, target_pid_to_str (inferior_pid));
- fflush (stdout);
+ gdb_flush (gdb_stdout);
}
if (args)
siggnal = atoi (args);
procfs_files_info (ignore)
struct target_ops *ignore;
{
- printf ("\tUsing the running image of %s %s via /proc.\n",
+ printf_unfiltered ("\tUsing the running image of %s %s via /proc.\n",
attach_flag? "attached": "child", target_pid_to_str (inferior_pid));
}
}
else
{
- printf ("Ok, gdb will wait for %s to stop.\n", target_pid_to_str (pid));
+ printf_unfiltered ("Ok, gdb will wait for %s to stop.\n", target_pid_to_str (pid));
}
}
if (ioctl (pi->fd, PIOCSEXIT, &pi->saved_exitset) < 0)
{
print_sys_errmsg (pi->pathname, errno);
- printf ("PIOCSEXIT failed.\n");
+ printf_unfiltered ("PIOCSEXIT failed.\n");
}
if (ioctl (pi->fd, PIOCSENTRY, &pi->saved_entryset) < 0)
{
print_sys_errmsg (pi->pathname, errno);
- printf ("PIOCSENTRY failed.\n");
+ printf_unfiltered ("PIOCSENTRY failed.\n");
}
if (ioctl (pi->fd, PIOCSTRACE, &pi->saved_trace) < 0)
{
print_sys_errmsg (pi->pathname, errno);
- printf ("PIOCSTRACE failed.\n");
+ printf_unfiltered ("PIOCSTRACE failed.\n");
}
if (ioctl (pi->fd, PIOCSHOLD, &pi->saved_sighold) < 0)
{
print_sys_errmsg (pi->pathname, errno);
- printf ("PIOSCHOLD failed.\n");
+ printf_unfiltered ("PIOSCHOLD failed.\n");
}
if (ioctl (pi->fd, PIOCSFAULT, &pi->saved_fltset) < 0)
{
print_sys_errmsg (pi->pathname, errno);
- printf ("PIOCSFAULT failed.\n");
+ printf_unfiltered ("PIOCSFAULT failed.\n");
}
if (ioctl (pi->fd, PIOCSTATUS, &pi->prstatus) < 0)
{
print_sys_errmsg (pi->pathname, errno);
- printf ("PIOCSTATUS failed.\n");
+ printf_unfiltered ("PIOCSTATUS failed.\n");
}
else
{
if (ioctl (pi->fd, PIOCCFAULT, 0))
{
print_sys_errmsg (pi->pathname, errno);
- printf ("PIOCCFAULT failed.\n");
+ printf_unfiltered ("PIOCCFAULT failed.\n");
}
/* Make it run again when we close it. */
if (result)
{
print_sys_errmsg (pi->pathname, errno);
- printf ("PIOCSRLC or PIOCSET failed.\n");
+ printf_unfiltered ("PIOCSRLC or PIOCSET failed.\n");
}
}
}
{
case PR_SIGNALLED:
statval = (what << 8) | 0177;
+ break;
+ case PR_SYSENTRY:
+ if (what != SYS_exit)
+ error ("PR_SYSENTRY, unknown system call %d", what);
+
+ pi->prrun.pr_flags = PRCFAULT;
+
+ if (ioctl (pi->fd, PIOCRUN, &pi->prrun) != 0)
+ perror_with_name (pi->pathname);
+
+ rtnval = wait (&statval);
+
break;
case PR_SYSEXIT:
switch (what)
if (rtnval == -1) /* No more children to wait for */
{
- fprintf (stderr, "Child process unexpectedly missing.\n");
+ fprintf_unfiltered (gdb_stderr, "Child process unexpectedly missing.\n");
*statloc = 42; /* Claim it exited with signal 42 */
return rtnval;
}
{
if (ioctl (procinfo->fd, PIOCSTATUS, &procinfo->prstatus) < 0)
{
- fprintf(stderr, "PIOCSTATUS failed, errno=%d\n", errno);
+ fprintf_unfiltered(gdb_stderr, "PIOCSTATUS failed, errno=%d\n", errno);
}
print_sys_errmsg (procinfo->pathname, errno);
error ("PIOCRUN failed");
static void
procfs_mourn_inferior ()
{
+ struct procinfo *pi;
+
+ for (pi = procinfo_list; pi; pi = pi->next)
+ unconditionally_kill_inferior (pi);
+
unpush_target (&procfs_ops);
generic_mourn_inferior ();
}
OPS_MAGIC /* to_magic */
};
-/*
-
-GLOBAL FUNCTION
-
- _initialize_procfs -- initialize the process file system stuff
-
-SYNOPSIS
-
- void _initialize_procfs (void)
-
-DESCRIPTION
-
- Do required initializations during gdb startup for using the
- /proc file system interface.
-
-*/
-
void
_initialize_procfs ()
{