*/
static void procfs_open (char *, int);
-static void procfs_attach (char *, int);
-static void procfs_detach (char *, int);
+static void procfs_attach (struct target_ops *, char *, int);
+static void procfs_detach (struct target_ops *, char *, int);
static void procfs_resume (ptid_t, int, enum target_signal);
static int procfs_can_run (void);
static void procfs_stop (ptid_t);
static void procfs_notice_signals (ptid_t);
static void procfs_prepare_to_store (struct regcache *);
static void procfs_kill_inferior (void);
-static void procfs_mourn_inferior (void);
-static void procfs_create_inferior (char *, char *, char **, int);
+static void procfs_mourn_inferior (struct target_ops *ops);
+static void procfs_create_inferior (struct target_ops *, char *,
+ char *, char **, int);
static ptid_t procfs_wait (ptid_t, struct target_waitstatus *);
-static int procfs_xfer_memory (CORE_ADDR, char *, int, int,
+static int procfs_xfer_memory (CORE_ADDR, gdb_byte *, int, int,
struct mem_attrib *attrib,
struct target_ops *);
static LONGEST procfs_xfer_partial (struct target_ops *ops,
enum target_object object,
const char *annex,
- void *readbuf, const void *writebuf,
+ gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, LONGEST len);
static int procfs_thread_alive (ptid_t);
static procinfo *
create_procinfo (int pid, int tid)
{
- procinfo *pi, *parent;
+ procinfo *pi, *parent = NULL;
if ((pi = find_procinfo (pid, tid)))
return pi; /* Already exists, nothing to do. */
kill (pi->pid, SIGKILL);
destroy_procinfo (pi);
- error ((msg));
+ error ("%s", msg);
}
/*
void *ptr;
gdb_assert (sizeof (ptr) == TYPE_LENGTH (ptr_type));
- gdbarch_address_to_pointer (target_gdbarch, ptr_type, &ptr, addr);
+ gdbarch_address_to_pointer (target_gdbarch, ptr_type,
+ (gdb_byte *) &ptr, addr);
return ptr;
}
/* Find procinfo for the lwp. */
if ((pi = find_procinfo (PIDGET (ptid), TIDGET (ptid))) == NULL)
{
- warning (_("procfs_find_LDT_entry: could not find procinfo for %d:%d."),
+ warning (_("procfs_find_LDT_entry: could not find procinfo for %d:%ld."),
PIDGET (ptid), TIDGET (ptid));
return NULL;
}
/* get its general registers. */
if ((gregs = proc_get_gregs (pi)) == NULL)
{
- warning (_("procfs_find_LDT_entry: could not read gregs for %d:%d."),
+ warning (_("procfs_find_LDT_entry: could not read gregs for %d:%ld."),
PIDGET (ptid), TIDGET (ptid));
return NULL;
}
}
static void
-procfs_attach (char *args, int from_tty)
+procfs_attach (struct target_ops *ops, char *args, int from_tty)
{
char *exec_file;
int pid;
}
static void
-procfs_detach (char *args, int from_tty)
+procfs_detach (struct target_ops *ops, char *args, int from_tty)
{
int sig = 0;
int pid = PIDGET (inferior_ptid);
do_attach (ptid_t ptid)
{
procinfo *pi;
+ struct inferior *inf;
int fail;
int lwpid;
if ((fail = procfs_debug_inferior (pi)) != 0)
dead_procinfo (pi, "do_attach: failed in procfs_debug_inferior", NOKILL);
- add_inferior (pi->pid);
+ inf = add_inferior (pi->pid);
/* Let GDB know that the inferior was attached. */
- attach_flag = 1;
+ inf->attach_flag = 1;
/* Create a procinfo for the current lwp. */
lwpid = proc_get_current_thread (pi);
proc_warn (pi, "do_detach, set_rlc", __LINE__);
}
- attach_flag = 0;
destroy_procinfo (pi);
}
}
else if (syscall_is_exit (pi, what))
{
+ struct inferior *inf;
+
/* Handle SYS_exit call only */
/* Stopped at entry to SYS_exit.
Make it runnable, resume it, then use
TARGET_WAITKIND_SPURIOUS. */
if (!proc_run_process (pi, 0, 0))
proc_error (pi, "target_wait, run_process", __LINE__);
- if (attach_flag)
+
+ inf = find_inferior_pid (pi->pid);
+ if (inf->attach_flag)
{
/* Don't call wait: simulate waiting for exit,
return a "success" exit code. Bogus: what if
static LONGEST
procfs_xfer_partial (struct target_ops *ops, enum target_object object,
- const char *annex, void *readbuf,
- const void *writebuf, ULONGEST offset, LONGEST len)
+ const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
{
switch (object)
{
case TARGET_OBJECT_MEMORY:
if (readbuf)
- return (*ops->deprecated_xfer_memory) (offset, readbuf, len,
- 0/*read*/, NULL, ops);
+ return (*ops->deprecated_xfer_memory) (offset, readbuf,
+ len, 0/*read*/, NULL, ops);
if (writebuf)
- return (*ops->deprecated_xfer_memory) (offset, writebuf, len,
- 1/*write*/, NULL, ops);
+ return (*ops->deprecated_xfer_memory) (offset, (gdb_byte *) writebuf,
+ len, 1/*write*/, NULL, ops);
return -1;
#ifdef NEW_PROC_API
negative values, but this capability isn't implemented here.) */
static int
-procfs_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int dowrite,
+procfs_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int dowrite,
struct mem_attrib *attrib, struct target_ops *target)
{
procinfo *pi;
static void
procfs_files_info (struct target_ops *ignore)
{
+ struct inferior *inf = current_inferior ();
printf_filtered (_("\tUsing the running image of %s %s via /proc.\n"),
- attach_flag? "attached": "child",
+ inf->attach_flag? "attached": "child",
target_pid_to_str (inferior_ptid));
}
*/
static void
-procfs_mourn_inferior (void)
+procfs_mourn_inferior (struct target_ops *ops)
{
procinfo *pi;
*/
static void
-procfs_create_inferior (char *exec_file, char *allargs, char **env,
- int from_tty)
+procfs_create_inferior (struct target_ops *ops, char *exec_file,
+ char *allargs, char **env, int from_tty)
{
char *shell_file = getenv ("SHELL");
char *tryname;
static int
info_mappings_callback (struct prmap *map, int (*ignore) (), void *unused)
{
- char *data_fmt_string;
-
- if (gdbarch_addr_bit (current_gdbarch) == 32)
- data_fmt_string = "\t%#10lx %#10lx %#10x %#10x %7s\n";
- else
- data_fmt_string = " %#18lx %#18lx %#10x %#10x %7s\n";
+ unsigned int pr_off;
- printf_filtered (data_fmt_string,
- (unsigned long) map->pr_vaddr,
- (unsigned long) map->pr_vaddr + map->pr_size - 1,
- map->pr_size,
#ifdef PCAGENT /* Horrible hack: only defined on Solaris 2.6+ */
- (unsigned int) map->pr_offset,
+ pr_off = (unsigned int) map->pr_offset;
#else
- map->pr_off,
+ pr_off = map->pr_off;
#endif
- mappingflags (map->pr_mflags));
+
+ if (gdbarch_addr_bit (current_gdbarch) == 32)
+ printf_filtered ("\t%#10lx %#10lx %#10x %#10x %7s\n",
+ (unsigned long) map->pr_vaddr,
+ (unsigned long) map->pr_vaddr + map->pr_size - 1,
+ map->pr_size,
+ pr_off,
+ mappingflags (map->pr_mflags));
+ else
+ printf_filtered (" %#18lx %#18lx %#10x %#10x %7s\n",
+ (unsigned long) map->pr_vaddr,
+ (unsigned long) map->pr_vaddr + map->pr_size - 1,
+ map->pr_size,
+ pr_off,
+ mappingflags (map->pr_mflags));
return 0;
}
static void
info_proc_mappings (procinfo *pi, int summary)
{
- char *header_fmt_string;
-
- if (gdbarch_ptr_bit (current_gdbarch) == 32)
- header_fmt_string = "\t%10s %10s %10s %10s %7s\n";
- else
- header_fmt_string = " %18s %18s %10s %10s %7s\n";
-
if (summary)
return; /* No output for summary mode. */
printf_filtered (_("Mapped address spaces:\n\n"));
- printf_filtered (header_fmt_string,
- "Start Addr",
- " End Addr",
- " Size",
- " Offset",
- "Flags");
+ if (gdbarch_ptr_bit (current_gdbarch) == 32)
+ printf_filtered ("\t%10s %10s %10s %10s %7s\n",
+ "Start Addr",
+ " End Addr",
+ " Size",
+ " Offset",
+ "Flags");
+ else
+ printf_filtered (" %18s %18s %10s %10s %7s\n",
+ "Start Addr",
+ " End Addr",
+ " Size",
+ " Offset",
+ "Flags");
iterate_over_mappings (pi, NULL, NULL, info_mappings_callback);
printf_filtered ("\n");
old_chain = make_cleanup (null_cleanup, 0);
if (args)
{
- if ((argv = buildargv (args)) == NULL)
- nomem (0);
- else
- make_cleanup_freeargv (argv);
+ argv = gdb_buildargv (args);
+ make_cleanup_freeargv (argv);
}
while (argv != NULL && *argv != NULL)
{
char *note_data = NULL;
char *inf_args;
struct procfs_corefile_thread_data thread_args;
- char *auxv;
+ gdb_byte *auxv;
int auxv_len;
if (get_exec_file (0))