/* GNU/Linux native-dependent code common to multiple platforms.
- Copyright (C) 2001-2012 Free Software Foundation, Inc.
+ Copyright (C) 2001-2013 Free Software Foundation, Inc.
This file is part of GDB.
#include "exceptions.h"
#include "linux-ptrace.h"
#include "buffer.h"
+#include "target-descriptions.h"
#ifndef SPUFS_MAGIC
#define SPUFS_MAGIC 0x23c9b64e
const gdb_byte *,
ULONGEST, LONGEST);
-static int debug_linux_nat;
+static unsigned int debug_linux_nat;
static void
show_debug_linux_nat (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
parent_inf = current_inferior ();
child_inf->attach_flag = parent_inf->attach_flag;
copy_terminal_info (child_inf, parent_inf);
+ child_inf->gdbarch = parent_inf->gdbarch;
+ copy_inferior_target_desc_info (child_inf, parent_inf);
old_chain = save_inferior_ptid ();
save_current_program_space ();
parent_inf = current_inferior ();
child_inf->attach_flag = parent_inf->attach_flag;
copy_terminal_info (child_inf, parent_inf);
+ child_inf->gdbarch = parent_inf->gdbarch;
+ copy_inferior_target_desc_info (child_inf, parent_inf);
parent_pspace = parent_inf->pspace;
pid_t child_pid = GET_PID (inferior_ptid);
ptid_t child_ptid = ptid_build (child_pid, child_pid, 0);
- gdb_assert (!is_lwp (inferior_ptid));
gdb_assert (find_lwp_pid (child_ptid) == NULL);
child_lp = add_lwp (child_ptid);
child_lp->stopped = 1;
pid = GET_PID (inferior_ptid);
- if (target_can_async_p ())
- linux_nat_async (NULL, 0);
+ /* Don't unregister from the event loop, as there may be other
+ inferiors running. */
/* Stop all threads before detaching. ptrace requires that the
thread is stopped to sucessfully detach. */
the current fork, and context-switch to the first
available. */
linux_fork_detach (args, from_tty);
-
- if (non_stop && target_can_async_p ())
- target_async (inferior_event_handler, 0);
}
else
linux_ops->to_detach (ops, args, from_tty);
/* This won't actually modify the breakpoint list, but will
physically remove the breakpoints from the child. */
- detach_breakpoints (new_pid);
+ detach_breakpoints (ptid_build (new_pid, new_pid, 0));
/* Retain child fork in ptrace (stopped) state. */
if (!find_fork_pid (new_pid))
ptid_t event_ptid;
if (debug_linux_nat)
- fprintf_unfiltered (gdb_stdlog,
- "linux_nat_wait: [%s]\n", target_pid_to_str (ptid));
+ {
+ char *options_string;
+
+ options_string = target_options_to_string (target_options);
+ fprintf_unfiltered (gdb_stdlog,
+ "linux_nat_wait: [%s], [%s]\n",
+ target_pid_to_str (ptid),
+ options_string);
+ xfree (options_string);
+ }
/* Flush the async file first. */
if (target_can_async_p ())
memset (name2, 0, MAXPATHLEN);
sprintf (name1, "/proc/%d/exe", pid);
- if (readlink (name1, name2, MAXPATHLEN) > 0)
+ if (readlink (name1, name2, MAXPATHLEN - 1) > 0)
return name2;
else
return name1;
{
/* FIXME: uweigand/2011-10-06: Once all GNU/Linux architectures have been
converted to gdbarch_core_regset_sections, this function can go away. */
- return linux_make_corefile_notes (target_gdbarch, obfd, note_size,
+ return linux_make_corefile_notes (target_gdbarch (), obfd, note_size,
linux_nat_collect_thread_registers);
}
static LONGEST
spu_enumerate_spu_ids (int pid, gdb_byte *buf, ULONGEST offset, LONGEST len)
{
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
LONGEST pos = 0;
LONGEST written = 0;
char path[128];
if (object == TARGET_OBJECT_MEMORY)
{
- int addr_bit = gdbarch_addr_bit (target_gdbarch);
+ int addr_bit = gdbarch_addr_bit (target_gdbarch ());
if (addr_bit < (sizeof (ULONGEST) * HOST_CHAR_BIT))
offset &= ((ULONGEST) 1 << addr_bit) - 1;
{
if (!lwp->stopped)
{
- ptid_t ptid = lwp->ptid;
-
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
"LNSL: running -> suspending %s\n",
void
_initialize_linux_nat (void)
{
- add_setshow_zinteger_cmd ("lin-lwp", class_maintenance,
- &debug_linux_nat, _("\
+ add_setshow_zuinteger_cmd ("lin-lwp", class_maintenance,
+ &debug_linux_nat, _("\
Set debugging of GNU/Linux lwp module."), _("\
Show debugging of GNU/Linux lwp module."), _("\
Enables printf debugging output."),
- NULL,
- show_debug_linux_nat,
- &setdebuglist, &showdebuglist);
+ NULL,
+ show_debug_linux_nat,
+ &setdebuglist, &showdebuglist);
/* Save this mask as the default. */
sigprocmask (SIG_SETMASK, NULL, &normal_mask);