2003-06-15 22:56:48 +02:00
|
|
|
|
/* GNU/Linux native-dependent code common to multiple platforms.
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
|
2018-01-01 05:43:02 +01:00
|
|
|
|
Copyright (C) 2001-2018 Free Software Foundation, Inc.
|
2003-06-15 22:56:48 +02:00
|
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-23 20:08:50 +02:00
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2003-06-15 22:56:48 +02:00
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 20:08:50 +02:00
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2003-06-15 22:56:48 +02:00
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
#include "inferior.h"
|
Add new infrun.h header.
Move infrun.c declarations out of inferior.h to a new infrun.h file.
Tested by building on:
i686-w64-mingw32, enable-targets=all
x86_64-linux, enable-targets=all
i586-pc-msdosdjgpp
And also grepped the whole tree for each symbol moved to find where
infrun.h might be necessary.
gdb/
2014-05-22 Pedro Alves <palves@redhat.com>
* inferior.h (debug_infrun, debug_displaced, stop_on_solib_events)
(sync_execution, sched_multi, step_stop_if_no_debug, non_stop)
(disable_randomization, enum exec_direction_kind)
(execution_direction, stop_registers, start_remote)
(clear_proceed_status, proceed, resume, user_visible_resume_ptid)
(wait_for_inferior, normal_stop, get_last_target_status)
(prepare_for_detach, fetch_inferior_event, init_wait_for_inferior)
(insert_step_resume_breakpoint_at_sal)
(follow_inferior_reset_breakpoints, stepping_past_instruction_at)
(set_step_info, print_stop_event, signal_stop_state)
(signal_print_state, signal_pass_state, signal_stop_update)
(signal_print_update, signal_pass_update)
(update_signals_program_target, clear_exit_convenience_vars)
(displaced_step_dump_bytes, update_observer_mode)
(signal_catch_update, gdb_signal_from_command): Move
declarations ...
* infrun.h: ... to this new file.
* amd64-tdep.c: Include infrun.h.
* annotate.c: Include infrun.h.
* arch-utils.c: Include infrun.h.
* arm-linux-tdep.c: Include infrun.h.
* arm-tdep.c: Include infrun.h.
* break-catch-sig.c: Include infrun.h.
* breakpoint.c: Include infrun.h.
* common/agent.c: Include infrun.h instead of inferior.h.
* corelow.c: Include infrun.h.
* event-top.c: Include infrun.h.
* go32-nat.c: Include infrun.h.
* i386-tdep.c: Include infrun.h.
* inf-loop.c: Include infrun.h.
* infcall.c: Include infrun.h.
* infcmd.c: Include infrun.h.
* infrun.c: Include infrun.h.
* linux-fork.c: Include infrun.h.
* linux-nat.c: Include infrun.h.
* linux-thread-db.c: Include infrun.h.
* monitor.c: Include infrun.h.
* nto-tdep.c: Include infrun.h.
* procfs.c: Include infrun.h.
* record-btrace.c: Include infrun.h.
* record-full.c: Include infrun.h.
* remote-m32r-sdi.c: Include infrun.h.
* remote-mips.c: Include infrun.h.
* remote-notif.c: Include infrun.h.
* remote-sim.c: Include infrun.h.
* remote.c: Include infrun.h.
* reverse.c: Include infrun.h.
* rs6000-tdep.c: Include infrun.h.
* s390-linux-tdep.c: Include infrun.h.
* solib-irix.c: Include infrun.h.
* solib-osf.c: Include infrun.h.
* solib-svr4.c: Include infrun.h.
* target.c: Include infrun.h.
* top.c: Include infrun.h.
* windows-nat.c: Include infrun.h.
* mi/mi-interp.c: Include infrun.h.
* mi/mi-main.c: Include infrun.h.
* python/py-threadevent.c: Include infrun.h.
2014-05-22 13:29:11 +02:00
|
|
|
|
#include "infrun.h"
|
2003-06-15 22:56:48 +02:00
|
|
|
|
#include "target.h"
|
2013-08-23 01:46:30 +02:00
|
|
|
|
#include "nat/linux-nat.h"
|
|
|
|
|
#include "nat/linux-waitpid.h"
|
2003-06-15 22:56:48 +02:00
|
|
|
|
#include "gdb_wait.h"
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <sys/syscall.h>
|
2015-07-24 15:57:20 +02:00
|
|
|
|
#include "nat/gdb_ptrace.h"
|
2003-06-20 00:52:04 +02:00
|
|
|
|
#include "linux-nat.h"
|
2014-06-19 15:46:38 +02:00
|
|
|
|
#include "nat/linux-ptrace.h"
|
|
|
|
|
#include "nat/linux-procfs.h"
|
2015-01-15 21:10:49 +01:00
|
|
|
|
#include "nat/linux-personality.h"
|
2006-01-04 20:34:58 +01:00
|
|
|
|
#include "linux-fork.h"
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
#include "gdbthread.h"
|
|
|
|
|
#include "gdbcmd.h"
|
|
|
|
|
#include "regcache.h"
|
2006-05-06 00:39:12 +02:00
|
|
|
|
#include "regset.h"
|
2012-05-22 17:04:57 +02:00
|
|
|
|
#include "inf-child.h"
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
#include "inf-ptrace.h"
|
|
|
|
|
#include "auxv.h"
|
2011-01-09 04:08:57 +01:00
|
|
|
|
#include <sys/procfs.h> /* for elf_gregset etc. */
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
#include "elf-bfd.h" /* for elfcore_write_* */
|
|
|
|
|
#include "gregset.h" /* for gregset */
|
|
|
|
|
#include "gdbcore.h" /* for get_exec_file */
|
|
|
|
|
#include <ctype.h> /* for isdigit */
|
remove gdb_stat.h
This patch is purely mechanical. It removes gdb_stat.h and changes
the code to use sys/stat.h.
2013-11-18 Tom Tromey <tromey@redhat.com>
* common/gdb_stat.h: Remove.
* ada-lang.c: Use sys/stat.h, not gdb_stat.h.
* common/filestuff.c: Use sys/stat.h, not gdb_stat.h.
* common/linux-osdata.c: Use sys/stat.h, not gdb_stat.h.
* corefile.c: Use sys/stat.h, not gdb_stat.h.
* ctf.c: Use sys/stat.h, not gdb_stat.h.
* darwin-nat.c: Use sys/stat.h, not gdb_stat.h.
* dbxread.c: Use sys/stat.h, not gdb_stat.h.
* dwarf2read.c: Use sys/stat.h, not gdb_stat.h.
* exec.c: Use sys/stat.h, not gdb_stat.h.
* gdbserver/linux-low.c: Use sys/stat.h, not gdb_stat.h.
* gdbserver/remote-utils.c: Use sys/stat.h, not gdb_stat.h.
* inf-child.c: Use sys/stat.h, not gdb_stat.h.
* jit.c: Use sys/stat.h, not gdb_stat.h.
* linux-nat.c: Use sys/stat.h, not gdb_stat.h.
* m68klinux-nat.c: Use sys/stat.h, not gdb_stat.h.
* main.c: Use sys/stat.h, not gdb_stat.h.
* mdebugread.c: Use sys/stat.h, not gdb_stat.h.
* mi/mi-cmd-env.c: Use sys/stat.h, not gdb_stat.h.
* nto-tdep.c: Use sys/stat.h, not gdb_stat.h.
* objfiles.c: Use sys/stat.h, not gdb_stat.h.
* procfs.c: Use sys/stat.h, not gdb_stat.h.
* remote-fileio.c: Use sys/stat.h, not gdb_stat.h.
* remote-mips.c: Use sys/stat.h, not gdb_stat.h.
* remote.c: Use sys/stat.h, not gdb_stat.h.
* rs6000-nat.c: Use sys/stat.h, not gdb_stat.h.
* sol-thread.c: Use sys/stat.h, not gdb_stat.h.
* solib-spu.c: Use sys/stat.h, not gdb_stat.h.
* source.c: Use sys/stat.h, not gdb_stat.h.
* symfile.c: Use sys/stat.h, not gdb_stat.h.
* symmisc.c: Use sys/stat.h, not gdb_stat.h.
* symtab.c: Use sys/stat.h, not gdb_stat.h.
* top.c: Use sys/stat.h, not gdb_stat.h.
* xcoffread.c: Use sys/stat.h, not gdb_stat.h.
2013-11-06 15:55:51 +01:00
|
|
|
|
#include <sys/stat.h> /* for struct stat */
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
#include <fcntl.h> /* for O_RDONLY */
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
#include "inf-loop.h"
|
|
|
|
|
#include "event-loop.h"
|
|
|
|
|
#include "event-top.h"
|
2008-12-02 08:57:38 +01:00
|
|
|
|
#include <pwd.h>
|
|
|
|
|
#include <sys/types.h>
|
2013-11-06 15:28:57 +01:00
|
|
|
|
#include <dirent.h>
|
2008-12-02 08:57:38 +01:00
|
|
|
|
#include "xml-support.h"
|
2009-07-31 17:25:22 +02:00
|
|
|
|
#include <sys/vfs.h>
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
#include "solib.h"
|
2014-06-19 15:46:38 +02:00
|
|
|
|
#include "nat/linux-osdata.h"
|
2012-01-20 10:56:56 +01:00
|
|
|
|
#include "linux-tdep.h"
|
2012-02-16 22:07:20 +01:00
|
|
|
|
#include "symfile.h"
|
2012-03-03 10:51:29 +01:00
|
|
|
|
#include "agent.h"
|
|
|
|
|
#include "tracepoint.h"
|
2012-03-13 16:02:25 +01:00
|
|
|
|
#include "buffer.h"
|
2012-11-09 02:47:20 +01:00
|
|
|
|
#include "target-descriptions.h"
|
PR gdb/7912:
* Makefile.in (SFILES): Add filestuff.c
(COMMON_OBS): Add filestuff.o.
(filestuff.o): New target.
* auto-load.c (auto_load_objfile_script_1): Use
gdb_fopen_cloexec.
* auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec.
* cli/cli-cmds.c (shell_escape): Call close_most_fds.
* cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec.
* common/agent.c (gdb_connect_sync_socket): Use
gdb_socket_cloexec.
* common/filestuff.c: New file.
* common/filestuff.h: New file.
* common/linux-osdata.c (linux_common_core_of_thread)
(command_from_pid, commandline_from_pid, print_source_lines)
(linux_xfer_osdata_shm, linux_xfer_osdata_sem)
(linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use
gdb_fopen_cloexec.
* common/linux-procfs.c (linux_proc_get_int)
(linux_proc_pid_has_state): Use gdb_fopen_cloexec.
* config.in, configure: Rebuild.
* configure.ac: Don't check for sys/socket.h. Check for
fdwalk, pipe2.
* corelow.c (core_open): Use gdb_open_cloexec.
* dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec.
* fork-child.c (fork_inferior): Call close_most_fds.
* gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec.
* inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec.
* linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals):
Use gdb_fopen_cloexec.
(linux_proc_xfer_partial, linux_proc_xfer_spu): Use
gdb_open_cloexec.
(linux_async_pipe): Use gdb_pipe_cloexec.
* remote-fileio.c (remote_fileio_func_open): Use
gdb_open_cloexec.
* remote.c (remote_file_put, remote_file_get): Use
gdb_fopen_cloexec.
* ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec,
close_most_fds.
* ser-tcp.c (net_open): Use gdb_socket_cloexec.
* ser-unix.c (hardwire_open): Use gdb_open_cloexec.
* solib.c (solib_find): Use gdb_open_cloexec.
* source.c (openp, find_and_open_source): Use gdb_open_cloexec.
* tracepoint.c (tfile_start): Use gdb_fopen_cloexec.
(tfile_open): Use gdb_open_cloexec.
* tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec.
* ui-file.c (gdb_fopen): Use gdb_fopen_cloexec.
* xml-support.c (xml_fetch_content_from_file): Use
gdb_fopen_cloexec.
* main.c (captured_main): Call notice_open_fds.
gdbserver
* Makefile.in (SFILES): Add filestuff.c.
(OBS): Add filestuff.o.
(filestuff.o): New target.
* config.in, configure: Rebuild.
* configure.ac: Check for fdwalk, pipe2.
2013-04-22 18:46:15 +02:00
|
|
|
|
#include "filestuff.h"
|
start change to progspace independence
This patch starts changing minimal symbols to be independent of the
program space.
Specifically, it adds a new objfile parameter to MSYMBOL_VALUE_ADDRESS
and changes all the code to use it. This is needed so we can change
gdb to apply the section offset when a minsym's address is computed,
as opposed to baking the offsets into the symbol itself.
A few spots still need the unrelocated address. For these, we
introduce MSYMBOL_VALUE_RAW_ADDRESS.
As a convenience, we also add the new macro BMSYMBOL_VALUE_ADDRESS,
which computes the address of a bound minimal symbol. This just does
the obvious thing with the fields.
Note that this change does not actually enable program space
independence. That requires more changes to gdb. However, to ensure
that these changes compile properly, this patch does add the needed
section lookup code to MSYMBOL_VALUE_ADDRESS -- it just ensures it has
no effect at runtime by multiplying the offset by 0.
2014-02-26 Tom Tromey <tromey@redhat.com>
* ada-lang.c (ada_main_name): Update.
(ada_add_standard_exceptions): Update.
* ada-tasks.c (ada_tasks_inferior_data_sniffer): Update.
* aix-thread.c (pdc_symbol_addrs, pd_enable): Update.
* arm-tdep.c (skip_prologue_function, arm_skip_stub): Update.
* auxv.c (ld_so_xfer_auxv): Update.
* avr-tdep.c (avr_scan_prologue): Update.
* ax-gdb.c (gen_var_ref): Update.
* blockframe.c (get_pc_function_start)
(find_pc_partial_function_gnu_ifunc): Update.
* breakpoint.c (create_overlay_event_breakpoint)
(create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint)
(create_exception_master_breakpoint): Update.
* bsd-uthread.c (bsd_uthread_lookup_address): Update.
* c-valprint.c (c_val_print): Update.
* coff-pe-read.c (add_pe_forwarded_sym): Update.
* common/agent.c (agent_look_up_symbols): Update.
* dbxread.c (find_stab_function_addr, end_psymtab): Update.
* dwarf2loc.c (call_site_to_target_addr): Update.
* dwarf2read.c (dw2_find_pc_sect_symtab): Update.
* elfread.c (elf_gnu_ifunc_record_cache)
(elf_gnu_ifunc_resolve_by_got): Update.
* findvar.c (default_read_var_value): Update.
* frame.c (inside_main_func): Update.
* frv-tdep.c (frv_frame_this_id): Update.
* glibc-tdep.c (glibc_skip_solib_resolver): Update.
* gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline):
Update.
* hppa-hpux-tdep.c (hppa64_hpux_search_dummy_call_sequence)
(hppa_hpux_find_dummy_bpaddr): Update.
* hppa-tdep.c (hppa_symbol_address): Update.
* infcmd.c (until_next_command): Update.
* jit.c (jit_read_descriptor, jit_breakpoint_re_set_internal):
Update.
* linespec.c (minsym_found, add_minsym): Update.
* linux-nat.c (get_signo): Update.
* linux-thread-db.c (inferior_has_bug): Update.
* m32c-tdep.c (m32c_return_value)
(m32c_m16c_address_to_pointer): Update.
* m32r-tdep.c (m32r_frame_this_id): Update.
* m68hc11-tdep.c (m68hc11_get_register_info): Update.
* machoread.c (macho_resolve_oso_sym_with_minsym): Update.
* maint.c (maintenance_translate_address): Update.
* minsyms.c (lookup_minimal_symbol_by_pc_name): Update.
(frob_address): New function.
(lookup_minimal_symbol_by_pc_section_1): Use raw addresses,
frob_address. Rename parameter to "pc_in".
(compare_minimal_symbols, compact_minimal_symbols): Use raw
addresses.
(find_solib_trampoline_target, minimal_symbol_upper_bound):
Update.
* mips-linux-tdep.c (mips_linux_skip_resolver): Update.
* mips-tdep.c (mips_skip_pic_trampoline_code): Update.
* objc-lang.c (find_objc_msgsend): Update.
* objfiles.c (objfile_relocate1): Update.
* obsd-tdep.c (obsd_skip_solib_resolver): Update.
* p-valprint.c (pascal_val_print): Update.
* parse.c (write_exp_msymbol): Update.
* ppc-linux-tdep.c (ppc_linux_spe_context_lookup)
(ppc_elfv2_skip_entrypoint): Update.
* ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update.
* printcmd.c (build_address_symbolic, msym_info)
(address_info): Update.
* proc-service.c (ps_pglobal_lookup): Update.
* psymtab.c (find_pc_sect_psymtab_closer)
(find_pc_sect_psymtab, find_pc_sect_symtab_from_partial):
Change msymbol parameter to bound_minimal_symbol.
* ravenscar-thread.c (get_running_thread_id): Update.
* remote.c (remote_check_symbols): Update.
* sh64-tdep.c (sh64_elf_make_msymbol_special): Use raw
address.
* sol2-tdep.c (sol2_skip_solib_resolver): Update.
* solib-dsbt.c (lm_base): Update.
* solib-frv.c (lm_base, main_got): Update.
* solib-irix.c (locate_base): Update.
* solib-som.c (som_solib_create_inferior_hook)
(link_map_start): Update.
* solib-spu.c (spu_enable_break, ocl_enable_break): Update.
* solib-svr4.c (elf_locate_base, enable_break): Update.
* spu-tdep.c (spu_get_overlay_table, spu_catch_start)
(flush_ea_cache): Update.
* stabsread.c (define_symbol, scan_file_globals): Update.
* stack.c (find_frame_funname): Update.
* symfile-debug.c (debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_symtab): Update.
* symfile.c (simple_read_overlay_table)
(simple_overlay_update): Update.
* symfile.h (struct quick_symbol_functions)
<find_pc_sect_symtab>: Change type of msymbol to
bound_minimal_symbol.
* symmisc.c (dump_msymbols): Update.
* symtab.c (find_pc_sect_symtab_via_partial)
(find_pc_sect_psymtab, find_pc_sect_line, skip_prologue_sal)
(search_symbols, print_msymbol_info): Update.
* symtab.h (MSYMBOL_VALUE_RAW_ADDRESS): New macro.
(MSYMBOL_VALUE_ADDRESS): Redefine.
(BMSYMBOL_VALUE_ADDRESS): New macro.
* tracepoint.c (scope_info): Update.
* tui/tui-disasm.c (tui_find_disassembly_address)
(tui_get_begin_asm_address): Update.
* valops.c (find_function_in_inferior): Update.
* value.c (value_static_field, value_fn_field): Update.
2013-08-15 16:46:35 +02:00
|
|
|
|
#include "objfiles.h"
|
2015-06-10 15:28:43 +02:00
|
|
|
|
#include "nat/linux-namespaces.h"
|
|
|
|
|
#include "fileio.h"
|
2009-07-31 17:25:22 +02:00
|
|
|
|
|
|
|
|
|
#ifndef SPUFS_MAGIC
|
|
|
|
|
#define SPUFS_MAGIC 0x23c9b64e
|
|
|
|
|
#endif
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
|
2011-01-09 04:08:57 +01:00
|
|
|
|
/* This comment documents high-level logic of this file.
|
2008-06-26 19:40:23 +02:00
|
|
|
|
|
|
|
|
|
Waiting for events in sync mode
|
|
|
|
|
===============================
|
|
|
|
|
|
2015-12-17 15:20:51 +01:00
|
|
|
|
When waiting for an event in a specific thread, we just use waitpid,
|
|
|
|
|
passing the specific pid, and not passing WNOHANG.
|
|
|
|
|
|
|
|
|
|
When waiting for an event in all threads, waitpid is not quite good:
|
|
|
|
|
|
|
|
|
|
- If the thread group leader exits while other threads in the thread
|
|
|
|
|
group still exist, waitpid(TGID, ...) hangs. That waitpid won't
|
|
|
|
|
return an exit status until the other threads in the group are
|
|
|
|
|
reaped.
|
|
|
|
|
|
|
|
|
|
- When a non-leader thread execs, that thread just vanishes without
|
|
|
|
|
reporting an exit (so we'd hang if we waited for it explicitly in
|
|
|
|
|
that case). The exec event is instead reported to the TGID pid.
|
|
|
|
|
|
|
|
|
|
The solution is to always use -1 and WNOHANG, together with
|
|
|
|
|
sigsuspend.
|
|
|
|
|
|
|
|
|
|
First, we use non-blocking waitpid to check for events. If nothing is
|
|
|
|
|
found, we use sigsuspend to wait for SIGCHLD. When SIGCHLD arrives,
|
|
|
|
|
it means something happened to a child process. As soon as we know
|
|
|
|
|
there's an event, we get back to calling nonblocking waitpid.
|
|
|
|
|
|
|
|
|
|
Note that SIGCHLD should be blocked between waitpid and sigsuspend
|
|
|
|
|
calls, so that we don't miss a signal. If SIGCHLD arrives in between,
|
|
|
|
|
when it's blocked, the signal becomes pending and sigsuspend
|
|
|
|
|
immediately notices it and returns.
|
|
|
|
|
|
|
|
|
|
Waiting for events in async mode (TARGET_WNOHANG)
|
|
|
|
|
=================================================
|
2008-06-26 19:40:23 +02:00
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
In async mode, GDB should always be ready to handle both user input
|
|
|
|
|
and target events, so neither blocking waitpid nor sigsuspend are
|
|
|
|
|
viable options. Instead, we should asynchronously notify the GDB main
|
|
|
|
|
event loop whenever there's an unprocessed event from the target. We
|
|
|
|
|
detect asynchronous target events by handling SIGCHLD signals. To
|
|
|
|
|
notify the event loop about target events, the self-pipe trick is used
|
|
|
|
|
--- a pipe is registered as waitable event source in the event loop,
|
|
|
|
|
the event loop select/poll's on the read end of this pipe (as well on
|
|
|
|
|
other event sources, e.g., stdin), and the SIGCHLD handler writes a
|
|
|
|
|
byte to this pipe. This is more portable than relying on
|
|
|
|
|
pselect/ppoll, since on kernels that lack those syscalls, libc
|
|
|
|
|
emulates them with select/poll+sigprocmask, and that is racy
|
|
|
|
|
(a.k.a. plain broken).
|
|
|
|
|
|
|
|
|
|
Obviously, if we fail to notify the event loop if there's a target
|
|
|
|
|
event, it's bad. OTOH, if we notify the event loop when there's no
|
|
|
|
|
event from the target, linux_nat_wait will detect that there's no real
|
|
|
|
|
event to report, and return event of type TARGET_WAITKIND_IGNORE.
|
|
|
|
|
This is mostly harmless, but it will waste time and is better avoided.
|
|
|
|
|
|
|
|
|
|
The main design point is that every time GDB is outside linux-nat.c,
|
|
|
|
|
we have a SIGCHLD handler installed that is called when something
|
|
|
|
|
happens to the target and notifies the GDB event loop. Whenever GDB
|
|
|
|
|
core decides to handle the event, and calls into linux-nat.c, we
|
|
|
|
|
process things as in sync mode, except that the we never block in
|
|
|
|
|
sigsuspend.
|
|
|
|
|
|
|
|
|
|
While processing an event, we may end up momentarily blocked in
|
|
|
|
|
waitpid calls. Those waitpid calls, while blocking, are guarantied to
|
|
|
|
|
return quickly. E.g., in all-stop mode, before reporting to the core
|
|
|
|
|
that an LWP hit a breakpoint, all LWPs are stopped by sending them
|
|
|
|
|
SIGSTOP, and synchronously waiting for the SIGSTOP to be reported.
|
|
|
|
|
Note that this is different from blocking indefinitely waiting for the
|
|
|
|
|
next event --- here, we're already handling an event.
|
2008-06-26 19:40:23 +02:00
|
|
|
|
|
|
|
|
|
Use of signals
|
|
|
|
|
==============
|
|
|
|
|
|
|
|
|
|
We stop threads by sending a SIGSTOP. The use of SIGSTOP instead of another
|
|
|
|
|
signal is not entirely significant; we just need for a signal to be delivered,
|
|
|
|
|
so that we can intercept it. SIGSTOP's advantage is that it can not be
|
|
|
|
|
blocked. A disadvantage is that it is not a real-time signal, so it can only
|
|
|
|
|
be queued once; we do not keep track of other sources of SIGSTOP.
|
|
|
|
|
|
|
|
|
|
Two other signals that can't be blocked are SIGCONT and SIGKILL. But we can't
|
|
|
|
|
use them, because they have special behavior when the signal is generated -
|
|
|
|
|
not when it is delivered. SIGCONT resumes the entire thread group and SIGKILL
|
|
|
|
|
kills the entire thread group.
|
|
|
|
|
|
|
|
|
|
A delivered SIGSTOP would stop the entire thread group, not just the thread we
|
|
|
|
|
tkill'd. But we never let the SIGSTOP be delivered; we always intercept and
|
|
|
|
|
cancel it (by PTRACE_CONT without passing SIGSTOP).
|
|
|
|
|
|
|
|
|
|
We could use a real-time signal instead. This would solve those problems; we
|
|
|
|
|
could use PTRACE_GETSIGINFO to locate the specific stop signals sent by GDB.
|
|
|
|
|
But we would still have to have some support for SIGSTOP, since PTRACE_ATTACH
|
|
|
|
|
generates it, and there are races with trying to find a signal that is not
|
2015-12-17 15:20:51 +01:00
|
|
|
|
blocked.
|
|
|
|
|
|
|
|
|
|
Exec events
|
|
|
|
|
===========
|
|
|
|
|
|
|
|
|
|
The case of a thread group (process) with 3 or more threads, and a
|
|
|
|
|
thread other than the leader execs is worth detailing:
|
|
|
|
|
|
|
|
|
|
On an exec, the Linux kernel destroys all threads except the execing
|
|
|
|
|
one in the thread group, and resets the execing thread's tid to the
|
|
|
|
|
tgid. No exit notification is sent for the execing thread -- from the
|
|
|
|
|
ptracer's perspective, it appears as though the execing thread just
|
|
|
|
|
vanishes. Until we reap all other threads except the leader and the
|
|
|
|
|
execing thread, the leader will be zombie, and the execing thread will
|
|
|
|
|
be in `D (disc sleep)' state. As soon as all other threads are
|
|
|
|
|
reaped, the execing thread changes its tid to the tgid, and the
|
|
|
|
|
previous (zombie) leader vanishes, giving place to the "new"
|
|
|
|
|
leader. */
|
2008-05-01 20:50:14 +02:00
|
|
|
|
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
#ifndef O_LARGEFILE
|
|
|
|
|
#define O_LARGEFILE 0
|
|
|
|
|
#endif
|
2003-06-20 00:52:04 +02:00
|
|
|
|
|
2015-06-01 13:13:02 +02:00
|
|
|
|
/* Does the current host support PTRACE_GETREGSET? */
|
Convert have_ptrace_getregset to a tri-state boolean
have_ptrace_getregset is a tri-state variable (-1, 0, 1), and we have
some conditions like "if (have_ptrace_getregset)", which is not correct.
I'll explain why it is not correct in the following example. This fix
to this problem to replace the test (have_ptrace_getregset) to test
(have_ptrace_getregset == 1) or (have_ptrace_getregset == -1) etc.
However Doug thinks it hinders readability
https://sourceware.org/ml/gdb-patches/2015-05/msg00692.html so I decide
to add a new enum tribool and change have_ptrace_getregset to it, in
order to make these tests more readable.
have_ptrace_getregset is initialised to -1, and is adjusted to 0 or 1 in
$ARCH_linux_read_description according to the capability of the kernel.
However, it is possible that have_ptrace_getregset is used before it is
set to 0 or 1, which means it is still -1. This is shown below.
(gdb) run
Starting program: gdb/testsuite/gdb.base/break
Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128
128 {
top?p have_ptrace_getregset
$1 = TRIBOOL_UNKNOWN
top?c
Continuing.
Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128
128 {
top?c
Continuing.
Breakpoint 1, x86_linux_read_description (ops=0xceaa80) at git/gdb/x86-linux-nat.c:117
117 {
PTRACE_GETREGSET command is used even GDB doesn't know whether
PTRACE_GETREGSET is supported or not. It is wrong, but works on x86.
However it doesn't work on arm-linux if the kernel doesn't support
PTRACE_GETREGSET at all. We'll get:
(gdb) run
Starting program: gdb/testsuite/gdb.base/break
warning: Unable to fetch general register.
PC register is not available
gdb:
2015-06-23 Yao Qi <yao.qi@linaro.org>
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers):
Check whether have_ptrace_getregset is TRIBOOL_TRUE explicitly.
(amd64_linux_store_inferior_registers): Likewise.
* arm-linux-nat.c (fetch_fpregister): Likewise.
(fetch_fpregs, store_fpregister): Likewise.
(store_fpregister, store_fpregs): Likewise.
(fetch_register, fetch_regs): Likewise.
(store_register, store_regs): Likewise.
(fetch_vfp_regs, store_vfp_regs): Likewise.
(arm_linux_read_description): Check have_ptrace_getregset is
TRIBOOL_UNKNOWN. Set have_ptrace_getregset to TRIBOOL_TRUE
or TRIBOOL_FALSE.
* i386-linux-nat.c (fetch_xstateregs): Check
have_ptrace_getregset is not TRIBOOL_TRUE.
(store_xstateregs): Likewise.
* linux-nat.c (have_ptrace_getregset): Change its type to
enum tribool.
* linux-nat.h (tribool): New enum.
* x86-linux-nat.c (x86_linux_read_description): Use enum tribool.
Check whether have_ptrace_getregset is TRIBOOL_TRUE.
2015-06-23 15:03:11 +02:00
|
|
|
|
enum tribool have_ptrace_getregset = TRIBOOL_UNKNOWN;
|
2015-06-01 13:13:02 +02:00
|
|
|
|
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
/* The single-threaded native GNU/Linux target_ops. We save a pointer for
|
|
|
|
|
the use of the multi-threaded target. */
|
|
|
|
|
static struct target_ops *linux_ops;
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
static struct target_ops linux_ops_saved;
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
/* The method to call, if any, when a new thread is attached. */
|
gdb/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* linux-nat.c (linux_nat_new_thread): Change parameter to an lwp
pointer.
(linux_nat_prepare_to_resume): New global.
(lwp_free): New.
(purge_lwp_list): Use it.
(add_lwp): Call linux_nat_new_thread even on the first LWP.
Adjust to interface change.
(delete_lwp): Call lwp_free instead of xfree.
(detach_callback, linux_nat_detach, resume_lwp, linux_nat_resume)
(linux_handle_syscall_trap, linux_handle_extended_wait)
(linux_nat_filter_event, resume_stopped_resumed_lwps): Call
linux_nat_prepare_to_resume before resuming.
(linux_stop_lwp): New.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* linux-nat.h (struct arch_lwp_info): Forward declare.
(struct lwp_info) <arch_private>: New field.
(linux_stop_lwp): Declare.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* i386-nat.c (DR_NADDR, DR_STATUS, DR_CONTROL)
(struct i386_debug_reg_state): Move to i386-nat.h.
(dr_mirror): Comment.
(i386_debug_reg_state): New.
(i386_update_inferior_debug_regs): Simplify.
(i386_stopped_data_address): Use the debug register state from the
inferior, not from the local cache.
* i386-nat.h (struct i386_dr_low_type): Delete reset_addr and
unset_status fields. New get_addr and get_control fields.
(DR_FIRSTADDR, DR_LASTADDR, DR_CONTROL): Moved from i386-nat.c.
(DR_NADDR, DR_STATUS): New.
(struct i386_debug_reg_state): Moved from i386-nat.c.
* amd64-linux-nat.c (struct arch_lwp_info): New.
(amd64_linux_dr): Delete global.
(amd64_linux_dr_get_addr): New.
(amd64_linux_dr_get_control): New.
(amd64_linux_dr_unset_status): Delete.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_dr_reset_addr): Delete.
(update_debug_registers_callback): New.
(amd64_linux_dr_set_control): Reimplement.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_prepare_to_resume): New.
(amd64_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_amd64_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
amd64_linux_dr_get_control as i386_dr_low.get_control. Install
amd64_linux_dr_get_addr as i386_dr_low.get_addr. Install
amd64_linux_prepare_to_resume.
* i386-linux-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(struct arch_lwp_info): New.
(i386_linux_dr): Delete global.
(i386_linux_dr_set_control): Reimplement.
(i386_linux_dr_get_addr): New.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_dr_get_control): New.
(update_debug_registers_callback): New.
(i386_linux_dr_unset_status): Delete.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_prepare_to_resume): New.
(i386_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_i386_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386_linux_dr_get_control as i386_dr_low.get_control. Install
i386_linux_dr_get_addr as i386_dr_low.get_addr. Install
i386_linux_prepare_to_resume.
* arm-linux-nat.c (arm_linux_new_thread): Change parameter to an
lwp pointer. Adjust.
* ia64-linux-nat.c (ia64_linux_new_thread): Likewise.
* mips-linux-nat.c (mips_linux_new_thread): Likewise.
* ppc-linux-nat.c (ppc_linux_new_thread): Likewise.
* s390-nat.c (s390_fix_watch_points): Likewise.
* i386-darwin-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(i386_darwin_dr_reset_addr): Delete.
(i386_darwin_dr_get_addr): New.
(i386_darwin_dr_get_control): New.
* go32-nat.c
(go32_get_dr7, go32_get_dr): New.
(init_go32_ops): No longer install i386_dr_low.reset_addr.
Install go32_get_dr7 as i386_dr_low.get_control. Install
go32_get_dr as i386_dr_low.get_addr.
* i386bsd-nat.c (i386bsd_dr_get): New.
(i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_status): Use i386bsd_dr_get.
(i386bsd_dr_get_control): New.
* i386bsd-nat.h (i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_control): New.
* i386fbsd-nat.c (_initialize_i386fbsd_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386bsd_dr_get_control as i386_dr_low.get_control. Install
i386bsd_dr_get_addr as i386_dr_low.get_addr.
* windows-nat.c (init_windows_ops): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
cygwin_get_dr7 as i386_dr_low.get_control. Install cygwin_get_dr
as i386_dr_low.get_addr.
(cygwin_get_dr): New.
(cygwin_get_dr7): New.
gdb/testsuite/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* gdb.mi/watch-nonstop.c: New file.
* gdb.mi/mi-watch-nonstop.exp: New file.
2011-12-14 18:20:32 +01:00
|
|
|
|
static void (*linux_nat_new_thread) (struct lwp_info *);
|
|
|
|
|
|
lwp_info: Make the arch code free arch_lwp_info
I have the goal of "poisoning" the XNEW/xfree-family of functions, so
that we catch their usages with non-POD types. A few things need to be
fixed in the mean time, this is one.
The common lwp code in linux-nat.c and gdbserver/linux-low.c xfrees the
private lwp data of type arch_lwp_info. However, that type is opaque
from its point of view, as its defined differently in each arch-specific
implementation. This trips on the std::is_pod<T> check, since the
compiler can't tell whether the type is POD or not if it doesn't know
about it.
My initial patch [1] made a class hierarchy with a virtual destructor.
However, as Pedro pointed out, we only have one native architecture at
the time built in gdb and gdbserver, so that's overkill. Instead, we
can move the responsibility of free'ing arch_lwp_info to the arch code
(which is also the one that allocated it in the first place). This is
what this patch does.
Also, I had the concern that if we wanted to use C++ features in these
structures, we would have a problem with the one-definition rule.
However, since a build will only have one version of arch_lwp_info,
that's not a problem.
There are changes in arch-specific files, I was only able to built-test
this patch with the following cross-compilers:
aarch64-linux-gnu
alpha-linux-gnu
arm-linux-gnueabihf
hppa-linux-gnu
m68k-linux-gnu
mips64el-linux-gnuabi64
powerpc64-linux-gnu
s390x-linux-gnu
sh4-linux-gnu
sparc64-linux-gnu
x86_64-linux-gnu
x86_64-w64-mingw32
A buildbot run didn't find any regression.
[1] https://sourceware.org/ml/gdb-patches/2017-08/msg00255.html
gdb/ChangeLog:
* linux-nat.h (linux_nat_set_delete_thread): New declaration.
* linux-nat.c (linux_nat_delete_thread): New variable.
(lwp_free): Invoke linux_nat_delete_thread if set.
(linux_nat_set_delete_thread): New function.
* aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Assign
thread delete callback.
* arm-linux-nat.c (arm_linux_delete_thread): New function.
(_initialize_arm_linux_nat): Assign thread delete callback.
* s390-linux-nat.c (s390_delete_thread): New function.
(_initialize_s390_nat): Assign thread delete callback.
* x86-linux-nat.c (x86_linux_add_target): Likewise.
* nat/aarch64-linux.c (aarch64_linux_delete_thread): New
function.
* nat/aarch64-linux.h (aarch64_linux_delete_thread): New
declaration.
* nat/x86-linux.c (x86_linux_delete_thread): New function.
* nat/x86-linux.h (x86_linux_delete_thread): New declaration.
gdb/gdbserver/ChangeLog:
* linux-aarch64-low.c (the_low_target): Add thread delete
callback.
* linux-arm-low.c (arm_delete_thread): New function.
(the_low_target): Add thread delete callback.
* linux-bfin-low.c (the_low_target): Likewise.
* linux-crisv32-low.c (the_low_target): Likewise.
* linux-low.c (delete_lwp): Invoke delete_thread callback if
set.
* linux-low.h (struct linux_target_ops) <delete_thread>: New
field.
* linux-m32r-low.c (the_low_target): Add thread delete callback.
* linux-mips-low.c (mips_linux_delete_thread): New function.
(the_low_target): Add thread delete callback.
* linux-ppc-low.c (the_low_target): Likewise.
* linux-s390-low.c (the_low_target): Likewise.
* linux-sh-low.c (the_low_target): Likewise.
* linux-tic6x-low.c (the_low_target): Likewise.
* linux-tile-low.c (the_low_target): Likewise.
* linux-x86-low.c (the_low_target): Likewise.
* linux-xtensa-low.c (the_low_target): Likewise.
2017-10-12 22:48:22 +02:00
|
|
|
|
/* The method to call, if any, when a thread is destroyed. */
|
|
|
|
|
static void (*linux_nat_delete_thread) (struct arch_lwp_info *);
|
|
|
|
|
|
[native x86 GNU/Linux] Access debug register mirror from the corresponding process.
While reviewing the native AArch64 patch, I noticed a problem:
On 02/06/2013 08:46 PM, Pedro Alves wrote:
>
>> > +static void
>> > +aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
>> > +{
>> > + struct arch_lwp_info *info = lwp->arch_private;
>> > +
>> > + /* NULL means this is the main thread still going through the shell,
>> > + or, no watchpoint has been set yet. In that case, there's
>> > + nothing to do. */
>> > + if (info == NULL)
>> > + return;
>> > +
>> > + if (DR_HAS_CHANGED (info->dr_changed_bp)
>> > + || DR_HAS_CHANGED (info->dr_changed_wp))
>> > + {
>> > + int tid = GET_LWP (lwp->ptid);
>> > + struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
> Hmm. This is always fetching the debug_reg_state of
> the current inferior, but may not be the inferior of lwp.
> I see the same bug on x86. Sorry about that. I'll fix it.
A natural fix would be to make xxx_get_debug_reg_state take an
inferior argument, but that doesn't work because of the case where we
detach breakpoints/watchpoints from the child fork, at a time there's
no inferior for the child fork at all. We do a nasty hack in
i386_inferior_data_get, but that relies on all callers pointing the
current inferior to the correct inferior, which isn't actually being
done by all callers, and I don't think we want to enforce that -- deep
in the bowls of linux-nat.c, there are many cases we resume lwps
behind the scenes, and it's be better to not have that code rely on
global state (as it doesn't today).
The fix is to decouple the watchpoints code from inferiors, making it
track target processes instead. This way, we can freely keep track of
the watchpoint mirrors for these processes behind the core's back.
Checkpoints also play dirty tricks with swapping the process behind
the inferior, so they get special treatment too in the patch (which
just amounts to calling a new hook). Instead of the old hack in
i386_inferior_data_get, where we returned a copy of the current
inferior's debug registers mirror, as soon as we detect a fork in the
target, we copy the debug register mirror from the parent to the child
process.
I don't have an old kernel handy to test, but I stepped through gdb doing
the watchpoint removal in the fork child in the watchpoint-fork test
seeing that the debug registers end up cleared in the child.
I didn't find the need for linux_nat_iterate_watchpoint_lwps. If
we use plain iterate_over_lwps instead, what happens is that
when removing watchpoints, that iterate_over_lwps doesn't actually
iterate over anything, since the fork child is not added to the
lwp list until later, at detach time, in linux_child_follow_fork.
And if we don't iterate over that lwp, we don't mark its debug
registers as needing update. But linux_child_follow_fork takes
care of doing that explicitly:
child_lp = add_lwp (inferior_ptid);
child_lp->stopped = 1;
child_lp->last_resume_kind = resume_stop;
make_cleanup (delete_lwp_cleanup, child_lp);
/* CHILD_LP has new PID, therefore linux_nat_new_thread is not called for it.
See i386_inferior_data_get for the Linux kernel specifics.
Ensure linux_nat_prepare_to_resume will reset the hardware debug
registers. It is done by the linux_nat_new_thread call, which is
being skipped in add_lwp above for the first lwp of a pid. */
gdb_assert (num_lwps (GET_PID (child_lp->ptid)) == 1);
if (linux_nat_new_thread != NULL)
linux_nat_new_thread (child_lp);
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (child_lp);
ptrace (PTRACE_DETACH, child_pid, 0, 0);
so unless I'm missing something (quite possible) it ends up all
the same. But, the !detach-on-fork, and the "follow-fork child" paths
should also call linux_nat_new_thread, and they don't presently. It
seems to me in those cases we're not clearing debug regs correctly
when that's needed. Instead of copying that bit that works around
add_lwp bypassing the linux_nat_new_thread call, I thought it'd
be better to add an add_initial_lwp call to be used in the case we
really need to bypass linux_nat_new_thread, and make
add_lwp always call linux_nat_new_thread.
i386_cleanup_dregs is rewritten to forget about the current process
debug mirrors, which takes cares of other i386 ports. Only a couple
of extra tweaks here and there were needed, as some targets wheren't
actually calling i386_cleanup_dregs.
Tested on Fedora 17 x86_64 -m64/-m32.
GDBserver already fetches the i386_debug_reg_state from the right
process, and, it doesn't handle forks at all, so no fix is needed over
there.
gdb/
2013-02-13 Pedro Alves <palves@redhat.com>
* amd64-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(amd64_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(amd64_linux_new_fork): New function.
(_initialize_amd64_linux_nat): Install amd64_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(i386_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(i386_linux_new_fork): New function.
(_initialize_i386_linux_nat): Install i386_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-nat.c (i386_init_dregs): Delete.
(i386_inferior_data, struct i386_inferior_data):
Delete.
(struct i386_process_info): New.
(i386_process_list): New global.
(i386_find_process_pid, i386_add_process, i386_process_info_get):
New functions.
(i386_inferior_data_get): Delete.
(i386_process_info_get): New function.
(i386_debug_reg_state): New parameter 'pid'. Reimplement.
(i386_forget_process): New function.
(i386_cleanup_dregs): Rewrite.
(i386_update_inferior_debug_regs, i386_insert_watchpoint)
(i386_remove_watchpoint, i386_region_ok_for_watchpoint)
(i386_stopped_data_address, i386_insert_hw_breakpoint)
(i386_remove_hw_breakpoint): Adjust to pass the current process id
to i386_debug_reg_state.
(i386_use_watchpoints): Don't register inferior data.
* i386-nat.h (i386_debug_reg_state): Add new 'pid' parameter, and
adjust comment.
(i386_forget_process): Declare.
* linux-fork.c (delete_fork): Call linux_nat_forget_process.
* linux-nat.c (linux_nat_new_fork, linux_nat_forget_process_hook):
New static globals.
(linux_child_follow_fork): Don't call linux_nat_new_thread here.
(add_initial_lwp): New, factored out from ...
(add_lwp): ... this. Don't check the number of lwps before
calling linux_nat_new_thread.
(linux_nat_iterate_watchpoint_lwps): Delete.
(linux_nat_attach): Use add_initial_lwp instead of add_lwp.
(linux_handle_extended_wait): Call the linux_nat_new_fork hook on
forks and vforks.
(linux_nat_wait_1): Use add_initial_lwp instead of add_lwp for the
initial lwp.
(linux_nat_kill, linux_nat_mourn_inferior): Call
linux_nat_forget_process.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New functions.
* linux-nat.h (linux_nat_iterate_watchpoint_lwps_ftype): Delete
type.
(linux_nat_iterate_watchpoint_lwps): Delete declaration.
(linux_nat_new_fork_ftype, linux_nat_forget_process_ftype): New
types.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New declarations.
* amd64fbsd-nat.c (super_mourn_inferior): New global.
(amd64fbsd_mourn_inferior): New function.
(_initialize_amd64fbsd_nat): Override to_mourn_inferior.
* windows-nat.c (windows_detach): Call i386_cleanup_dregs.
2013-02-13 15:59:49 +01:00
|
|
|
|
/* The method to call, if any, when a new fork is attached. */
|
|
|
|
|
static linux_nat_new_fork_ftype *linux_nat_new_fork;
|
|
|
|
|
|
|
|
|
|
/* The method to call, if any, when a process is no longer
|
|
|
|
|
attached. */
|
|
|
|
|
static linux_nat_forget_process_ftype *linux_nat_forget_process_hook;
|
|
|
|
|
|
gdb/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* linux-nat.c (linux_nat_new_thread): Change parameter to an lwp
pointer.
(linux_nat_prepare_to_resume): New global.
(lwp_free): New.
(purge_lwp_list): Use it.
(add_lwp): Call linux_nat_new_thread even on the first LWP.
Adjust to interface change.
(delete_lwp): Call lwp_free instead of xfree.
(detach_callback, linux_nat_detach, resume_lwp, linux_nat_resume)
(linux_handle_syscall_trap, linux_handle_extended_wait)
(linux_nat_filter_event, resume_stopped_resumed_lwps): Call
linux_nat_prepare_to_resume before resuming.
(linux_stop_lwp): New.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* linux-nat.h (struct arch_lwp_info): Forward declare.
(struct lwp_info) <arch_private>: New field.
(linux_stop_lwp): Declare.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* i386-nat.c (DR_NADDR, DR_STATUS, DR_CONTROL)
(struct i386_debug_reg_state): Move to i386-nat.h.
(dr_mirror): Comment.
(i386_debug_reg_state): New.
(i386_update_inferior_debug_regs): Simplify.
(i386_stopped_data_address): Use the debug register state from the
inferior, not from the local cache.
* i386-nat.h (struct i386_dr_low_type): Delete reset_addr and
unset_status fields. New get_addr and get_control fields.
(DR_FIRSTADDR, DR_LASTADDR, DR_CONTROL): Moved from i386-nat.c.
(DR_NADDR, DR_STATUS): New.
(struct i386_debug_reg_state): Moved from i386-nat.c.
* amd64-linux-nat.c (struct arch_lwp_info): New.
(amd64_linux_dr): Delete global.
(amd64_linux_dr_get_addr): New.
(amd64_linux_dr_get_control): New.
(amd64_linux_dr_unset_status): Delete.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_dr_reset_addr): Delete.
(update_debug_registers_callback): New.
(amd64_linux_dr_set_control): Reimplement.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_prepare_to_resume): New.
(amd64_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_amd64_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
amd64_linux_dr_get_control as i386_dr_low.get_control. Install
amd64_linux_dr_get_addr as i386_dr_low.get_addr. Install
amd64_linux_prepare_to_resume.
* i386-linux-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(struct arch_lwp_info): New.
(i386_linux_dr): Delete global.
(i386_linux_dr_set_control): Reimplement.
(i386_linux_dr_get_addr): New.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_dr_get_control): New.
(update_debug_registers_callback): New.
(i386_linux_dr_unset_status): Delete.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_prepare_to_resume): New.
(i386_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_i386_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386_linux_dr_get_control as i386_dr_low.get_control. Install
i386_linux_dr_get_addr as i386_dr_low.get_addr. Install
i386_linux_prepare_to_resume.
* arm-linux-nat.c (arm_linux_new_thread): Change parameter to an
lwp pointer. Adjust.
* ia64-linux-nat.c (ia64_linux_new_thread): Likewise.
* mips-linux-nat.c (mips_linux_new_thread): Likewise.
* ppc-linux-nat.c (ppc_linux_new_thread): Likewise.
* s390-nat.c (s390_fix_watch_points): Likewise.
* i386-darwin-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(i386_darwin_dr_reset_addr): Delete.
(i386_darwin_dr_get_addr): New.
(i386_darwin_dr_get_control): New.
* go32-nat.c
(go32_get_dr7, go32_get_dr): New.
(init_go32_ops): No longer install i386_dr_low.reset_addr.
Install go32_get_dr7 as i386_dr_low.get_control. Install
go32_get_dr as i386_dr_low.get_addr.
* i386bsd-nat.c (i386bsd_dr_get): New.
(i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_status): Use i386bsd_dr_get.
(i386bsd_dr_get_control): New.
* i386bsd-nat.h (i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_control): New.
* i386fbsd-nat.c (_initialize_i386fbsd_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386bsd_dr_get_control as i386_dr_low.get_control. Install
i386bsd_dr_get_addr as i386_dr_low.get_addr.
* windows-nat.c (init_windows_ops): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
cygwin_get_dr7 as i386_dr_low.get_control. Install cygwin_get_dr
as i386_dr_low.get_addr.
(cygwin_get_dr): New.
(cygwin_get_dr7): New.
gdb/testsuite/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* gdb.mi/watch-nonstop.c: New file.
* gdb.mi/mi-watch-nonstop.exp: New file.
2011-12-14 18:20:32 +01:00
|
|
|
|
/* Hook to call prior to resuming a thread. */
|
|
|
|
|
static void (*linux_nat_prepare_to_resume) (struct lwp_info *);
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
|
* amd64-linux-nat.c (compat_int_t, compat_uptr_t, compat_time_t)
(compat_timer_t, compat_clock_t, struct compat_timeval)
(compat_sigval_t, compat_siginfo_t): New types.
(cpt_si_pid, cpt_si_uid, cpt_si_timerid, cpt_si_overrun)
(cpt_si_status, cpt_si_utime, cpt_si_stime, cpt_si_ptr)
(cpt_si_addr, cpt_si_band, cpt_si_fd): New defines.
(compat_siginfo_from_siginfo, siginfo_from_compat_siginfo)
(amd64_linux_siginfo_fixup): New.
* linux-nat.c (linux_nat_siginfo_fixup): New.
(siginfo_fixup): New.
(linux_xfer_siginfo): Use siginfo_fixup to convert between the
siginfo layout expected by ptrace and the siginfo layout of the
inferior.
(linux_nat_set_siginfo_fixup): New.
* linux-nat.h (linux_nat_set_siginfo_fixup): Declare.
2009-02-07 00:06:58 +01:00
|
|
|
|
/* The method to call, if any, when the siginfo object needs to be
|
|
|
|
|
converted between the layout returned by ptrace, and the layout in
|
|
|
|
|
the architecture of the inferior. */
|
2012-03-21 14:43:55 +01:00
|
|
|
|
static int (*linux_nat_siginfo_fixup) (siginfo_t *,
|
* amd64-linux-nat.c (compat_int_t, compat_uptr_t, compat_time_t)
(compat_timer_t, compat_clock_t, struct compat_timeval)
(compat_sigval_t, compat_siginfo_t): New types.
(cpt_si_pid, cpt_si_uid, cpt_si_timerid, cpt_si_overrun)
(cpt_si_status, cpt_si_utime, cpt_si_stime, cpt_si_ptr)
(cpt_si_addr, cpt_si_band, cpt_si_fd): New defines.
(compat_siginfo_from_siginfo, siginfo_from_compat_siginfo)
(amd64_linux_siginfo_fixup): New.
* linux-nat.c (linux_nat_siginfo_fixup): New.
(siginfo_fixup): New.
(linux_xfer_siginfo): Use siginfo_fixup to convert between the
siginfo layout expected by ptrace and the siginfo layout of the
inferior.
(linux_nat_set_siginfo_fixup): New.
* linux-nat.h (linux_nat_set_siginfo_fixup): Declare.
2009-02-07 00:06:58 +01:00
|
|
|
|
gdb_byte *,
|
|
|
|
|
int);
|
|
|
|
|
|
2006-01-04 20:34:58 +01:00
|
|
|
|
/* The saved to_xfer_partial method, inherited from inf-ptrace.c.
|
|
|
|
|
Called by our to_xfer_partial. */
|
2013-11-04 10:53:56 +01:00
|
|
|
|
static target_xfer_partial_ftype *super_xfer_partial;
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
|
Allow making GDB not automatically connect to the native target.
Sometimes it's useful to be able to disable the automatic connection
to the native target. E.g., sometimes GDB disconnects from the
extended-remote target I was debugging, without me noticing it, and
then I do "run". That starts the program locally, and only after a
little head scratch session do I figure out the program is running
locally instead of remotely as intended. Same thing with "attach",
"info os", etc.
With the patch, we now can have this instead:
(gdb) set auto-connect-native-target off
(gdb) target extended-remote :9999
...
*gdb disconnects*
(gdb) run
Don't know how to run. Try "help target".
To still be able to connect to the native target with
auto-connect-native-target set to off, I've made "target native" work
instead of erroring out as today.
Before:
(gdb) target native
Use the "run" command to start a native process.
After:
(gdb) target native
Done. Use the "run" command to start a process.
(gdb) maint print target-stack
The current target stack is:
- native (Native process)
- exec (Local exec file)
- None (None)
(gdb) run
Starting program: ./a.out
...
I've also wanted this for the testsuite, when running against the
native-extended-gdbserver.exp board (runs against gdbserver in
extended-remote mode). With a non-native-target board, it's always a
bug to launch a program with the native target. Turns out we still
have one such case this patch catches:
(gdb) break main
Breakpoint 1 at 0x4009e5: file ../../../src/gdb/testsuite/gdb.base/coremaker.c, line 138.
(gdb) run
Don't know how to run. Try "help target".
(gdb) FAIL: gdb.base/corefile.exp: run: with core
On the patch itself, probably the least obvious bit is the need to go
through all targets, and move the unpush_target call to after the
generic_mourn_inferior call instead of before. This is what
inf-ptrace.c does too, ever since multi-process support was added.
The reason inf-ptrace.c does things in that order is that in the
current multi-process/single-target model, we shouldn't unpush the
target if there are still other live inferiors being debugged. The
check for that is "have_inferiors ()" (a misnomer nowadays...), which
does:
have_inferiors (void)
{
for (inf = inferior_list; inf; inf = inf->next)
if (inf->pid != 0)
return 1;
It's generic_mourn_inferior that ends up clearing inf->pid, so we need
to call it before the have_inferiors check. To make all native
targets behave the same WRT to explicit "target native", I've added an
inf_child_maybe_unpush_target function that targets call instead of
calling unpush_target directly, and as that includes the
have_inferiors check, I needed to adjust the targets.
Tested on x86_64 Fedora 20, native, and also with the
extended-gdbserver board.
Confirmed a cross build of djgpp gdb still builds.
Smoke tested a cross build of Windows gdb under Wine.
Untested otherwise.
gdb/
2014-05-21 Pedro Alves <palves@redhat.com>
* inf-child.c (inf_child_ops, inf_child_explicitly_opened): New
globals.
(inf_child_open_target): New function.
(inf_child_open): Use inf_child_open_target to push the target
instead of erroring out.
(inf_child_disconnect, inf_child_close)
(inf_child_maybe_unpush_target): New functions.
(inf_child_target): Install inf_child_disconnect and
inf_child_close. Store a pointer to the returned object.
* inf-child.h (inf_child_open_target, inf_child_maybe_unpush): New
declarations.
* target.c (auto_connect_native_target): New global.
(show_default_run_target): New function.
(find_default_run_target): Return NULL if automatically connecting
to the native target is disabled.
(_initialize_target): Install set/show auto-connect-native-target.
* NEWS: Mention "set auto-connect-native-target", and "target
native".
* linux-nat.c (super_close): New global.
(linux_nat_close): Call super_close.
(linux_nat_add_target): Store a pointer to the base class's
to_close method.
* inf-ptrace.c (inf_ptrace_mourn_inferior, inf_ptrace_detach): Use
inf_child_maybe_unpush.
* inf-ttrace.c (inf_ttrace_him): Don't push the target if it is
already pushed.
(inf_ttrace_mourn_inferior): Only unpush the target after mourning
the inferior. Use inf_child_maybe_unpush_target.
(inf_ttrace_attach): Don't push the target if it is already
pushed.
(inf_ttrace_detach): Use inf_child_maybe_unpush_target.
* darwin-nat.c (darwin_mourn_inferior): Only unpush the target
after mourning the inferior. Use inf_child_maybe_unpush_target.
(darwin_attach_pid): Don't push the target if it is already
pushed.
* gnu-nat.c (gnu_mourn_inferior): Only unpush the target after
mourning the inferior. Use inf_child_maybe_unpush_target.
(gnu_detach): Use inf_child_maybe_unpush_target.
* go32-nat.c (go32_create_inferior): Don't push the target if it
is already pushed.
(go32_mourn_inferior): Use inf_child_maybe_unpush_target.
* nto-procfs.c (procfs_is_nto_target): Adjust comment.
(procfs_open): Rename to ...
(procfs_open_1): ... this. Add target_ops parameter. Adjust
comments. Can target_preopen before changing node. Call
inf_child_open_target to push the target explicitly.
(procfs_attach): Don't push the target if it is already pushed.
(procfs_detach): Use inf_child_maybe_unpush_target.
(procfs_create_inferior): Don't push the target if it is already
pushed.
(nto_native_ops): New global.
(procfs_open): Reimplement.
(procfs_native_open): New function.
(init_procfs_targets): Install procfs_native_open as to_open of
"target native". Store a pointer to the "native" target in
nto_native_ops.
* procfs.c (procfs_attach): Don't push the target if it is already
pushed.
(procfs_detach): Use inf_child_maybe_unpush_target.
(procfs_mourn_inferior): Only unpush the target after mourning the
inferior. Use inf_child_maybe_unpush_target.
(procfs_init_inferior): Don't push the target if it is already
pushed.
* windows-nat.c (do_initial_windows_stuff): Don't push the target
if it is already pushed.
(windows_detach): Use inf_child_maybe_unpush_target.
(windows_mourn_inferior): Only unpush the target after mourning
the inferior. Use inf_child_maybe_unpush_target.
gdb/doc/
2014-05-21 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Starting): Document "set/show
auto-connect-native-target".
(Target Commands): Document "target native".
gdb/testsuite/
2014-05-21 Pedro Alves <palves@redhat.com>
* boards/gdbserver-base.exp (GDBFLAGS): Set to "set
auto-connect-native-target off".
* gdb.base/auto-connect-native-target.c: New file.
* gdb.base/auto-connect-native-target.exp: New file.
2014-05-21 19:30:47 +02:00
|
|
|
|
/* The saved to_close method, inherited from inf-ptrace.c.
|
|
|
|
|
Called by our to_close. */
|
|
|
|
|
static void (*super_close) (struct target_ops *);
|
|
|
|
|
|
2012-08-02 11:36:40 +02:00
|
|
|
|
static unsigned int debug_linux_nat;
|
2005-02-24 Andrew Cagney <cagney@gnu.org>
Add show_VARIABLE functions, update add_setshow call.
* varobj.c (_initialize_varobj, show_varobjdebug): Add and update.
* valprint.c (_initialize_valprint, show_print_max)
(show_stop_print_at_null, show_repeat_count_threshold)
(show_prettyprint_structs, show_unionprint)
(show_prettyprint_arrays, show_addressprint, show_input_radix)
(show_output_radix): Ditto.
* valops.c (_initialize_valops, show_overload_resolution): Ditto.
* utils.c (initialize_utils, show_chars_per_line)
(show_lines_per_page, show_demangle, show_pagination_enabled)
(show_sevenbit_strings, show_asm_demangle): Ditto
* tui/tui-win.c (_initialize_tui_win, show_tui_border_kind)
(show_tui_border_mode, show_tui_active_border_mode): Ditto.
* top.c (init_main, show_new_async_prompt)
(show_async_command_editing_p, show_write_history_p)
(show_history_size, show_history_filename, show_caution)
(show_annotation_level, init_main): Ditto.
* target.c (initialize_targets, show_targetdebug)
(show_trust_readonly): Ditto.
* symfile.c (_initialize_symfile, show_symbol_reloading)
(show_ext_args, show_download_write_size)
(show_debug_file_directory): Ditto.
* source.c (_initialize_source, show_lines_to_list): Ditto.
* solib.c (_initialize_solib, show_auto_solib_add)
(show_solib_search_path): Ditto.
* p-valprint.c (_initialize_pascal_valprint)
(show_pascal_static_field_print): Ditto.
* printcmd.c (_initialize_printcmd, show_max_symbolic_offset)
(show_print_symbol_filename): Add and update.
* parse.c (_initialize_parse, show_expressiondebug): Dito.
* observer.c (_initialize_observer, show_observer_debug): Dito.
* maint.c (_initialize_maint_cmds, show_watchdog)
(show_maintenance_profile_p): Dito.
* linux-nat.c (_initialize_linux_nat, show_debug_linux_nat): Dito.
* infrun.c (_initialize_infrun, show_debug_infrun)
(show_stop_on_solib_events, show_follow_fork_mode_string)
(show_scheduler_mode, show_step_stop_if_no_debug): Ditto.
* infcall.c (_initialize_infcall, show_coerce_float_to_double_p)
(show_unwind_on_signal_p): Ditto.
* gdbtypes.c (build_gdbtypes, show_opaque_type_resolution)
(_initialize_gdbtypes, show_overload_debug): Ditto.
* gdb-events.c, gdb-events.sh (_initialize_gdb_events)
(show_gdb_events_debug): Ditto.
* gdbarch.c, gdbarch.sh (show_gdbarch_debug)
(_initialize_gdbarch): Ditto.
* frame.c (_initialize_frame, show_backtrace_past_main)
(show_backtrace_past_entry, show_backtrace_limit)
(show_frame_debug): Ditto.
* exec.c (_initialize_exec, show_write_files): Ditto.
* dwarf2read.c (_initialize_dwarf2_read)
(show_dwarf2_max_cache_age): Ditto.
* demangle.c (_initialize_demangler)
(show_demangling_style_names): Ditto.
* dcache.c (_initialize_dcache, show_dcache_enabled_p): Ditto.
* cp-valprint.c (show_static_field_print)
(_initialize_cp_valprint, show_vtblprint, show_objectprint): Ditto.
* corefile.c (_initialize_core, show_gnutarget_string): Ditto.
* cli/cli-logging.c (_initialize_cli_logging)
(show_logging_overwrite, show_logging_redirect)
(show_logging_filename): Ditto.
* cli/cli-cmds.c (show_info_verbose, show_history_expansion_p)
(init_cli_cmds, show_baud_rate, show_remote_debug)
(show_remote_timeout, show_max_user_call_depth): Ditto.
* charset.c (show_host_charset_name, show_target_charset_name)
(initialize_charset): Ditto.
* breakpoint.c (show_can_use_hw_watchpoints)
(show_pending_break_support, _initialize_breakpoint): Ditto.
2005-02-24 14:51:36 +01:00
|
|
|
|
static void
|
|
|
|
|
show_debug_linux_nat (struct ui_file *file, int from_tty,
|
|
|
|
|
struct cmd_list_element *c, const char *value)
|
|
|
|
|
{
|
|
|
|
|
fprintf_filtered (file, _("Debugging of GNU/Linux lwp module is %s.\n"),
|
|
|
|
|
value);
|
|
|
|
|
}
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
2003-06-19 01:33:31 +02:00
|
|
|
|
struct simple_pid_list
|
|
|
|
|
{
|
|
|
|
|
int pid;
|
2007-01-08 22:09:47 +01:00
|
|
|
|
int status;
|
2003-06-19 01:33:31 +02:00
|
|
|
|
struct simple_pid_list *next;
|
|
|
|
|
};
|
|
|
|
|
struct simple_pid_list *stopped_pids;
|
|
|
|
|
|
2016-05-24 15:47:56 +02:00
|
|
|
|
/* Whether target_thread_events is in effect. */
|
|
|
|
|
static int report_thread_events;
|
|
|
|
|
|
2011-06-06 14:47:07 +02:00
|
|
|
|
/* Async mode support. */
|
|
|
|
|
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
/* The read/write ends of the pipe registered as waitable file in the
|
|
|
|
|
event loop. */
|
|
|
|
|
static int linux_nat_event_pipe[2] = { -1, -1 };
|
|
|
|
|
|
2015-01-23 12:12:39 +01:00
|
|
|
|
/* True if we're currently in async mode. */
|
|
|
|
|
#define linux_is_async_p() (linux_nat_event_pipe[0] != -1)
|
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
/* Flush the event pipe. */
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
static void
|
|
|
|
|
async_file_flush (void)
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
{
|
2009-05-11 14:08:03 +02:00
|
|
|
|
int ret;
|
|
|
|
|
char buf;
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
do
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
{
|
2009-05-11 14:08:03 +02:00
|
|
|
|
ret = read (linux_nat_event_pipe[0], &buf, 1);
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
}
|
2009-05-11 14:08:03 +02:00
|
|
|
|
while (ret >= 0 || (ret == -1 && errno == EINTR));
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
/* Put something (anything, doesn't matter what, or how much) in event
|
|
|
|
|
pipe, so that the select/poll in the event-loop realizes we have
|
|
|
|
|
something to process. */
|
2008-10-24 01:11:21 +02:00
|
|
|
|
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
static void
|
2009-05-11 14:08:03 +02:00
|
|
|
|
async_file_mark (void)
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
{
|
2009-05-11 14:08:03 +02:00
|
|
|
|
int ret;
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
/* It doesn't really matter what the pipe contains, as long we end
|
|
|
|
|
up with something in it. Might as well flush the previous
|
|
|
|
|
left-overs. */
|
|
|
|
|
async_file_flush ();
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
do
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
{
|
2009-05-11 14:08:03 +02:00
|
|
|
|
ret = write (linux_nat_event_pipe[1], "+", 1);
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
}
|
2009-05-11 14:08:03 +02:00
|
|
|
|
while (ret == -1 && errno == EINTR);
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
/* Ignore EAGAIN. If the pipe is full, the event loop will already
|
|
|
|
|
be awakened anyway. */
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
static int kill_lwp (int lwpid, int signo);
|
|
|
|
|
|
|
|
|
|
static int stop_callback (struct lwp_info *lp, void *data);
|
GNU/Linux: Stop using libthread_db/td_ta_thr_iter
TL;DR - GDB can hang if something refreshes the thread list out of the
target while the target is running. GDB hangs inside td_ta_thr_iter.
The fix is to not use that libthread_db function anymore.
Long version:
Running the testsuite against my all-stop-on-top-of-non-stop series is
still exposing latent non-stop bugs.
I was originally seeing this with the multi-create.exp test, back when
we were still using libthread_db thread event breakpoints. The
all-stop-on-top-of-non-stop series forces a thread list refresh each
time GDB needs to start stepping over a breakpoint (to pause all
threads). That test hits the thread event breakpoint often, resulting
in a bunch of step-over operations, thus a bunch of thread list
refreshes while some threads in the target are running.
The commit adds a real non-stop mode test that triggers the issue,
based on multi-create.exp, that does an explicit "info threads" when a
breakpoint is hit. IOW, it does the same things the as-ns series was
doing when testing multi-create.exp.
The bug is a race, so it unfortunately takes several runs for the test
to trigger it. In fact, even when setting the test running in a loop,
it sometimes takes several minutes for it to trigger for me.
The race is related to libthread_db's td_ta_thr_iter. This is
libthread_db's entry point for walking the thread list of the
inferior.
Sometimes, when GDB refreshes the thread list from the target,
libthread_db's td_ta_thr_iter can somehow see glibc's thread list as a
cycle, and get stuck in an infinite loop.
The issue is that when a thread exits, its thread control structure in
glibc is moved from a "used" list to a "cache" list. These lists are
simply circular linked lists where the "next/prev" pointers are
embedded in the thread control structure itself. The "next" pointer
of the last element of the list points back to the list's sentinel
"head". There's only one set of "next/prev" pointers for both lists;
thus a thread can only be in one of the lists at a time, not in both
simultaneously.
So when thread C exits, simplifying, the following happens. A-C are
threads. stack_used and stack_cache are the list's heads.
Before:
stack_used -> A -> B -> C -> (&stack_used)
stack_cache -> (&stack_cache)
After:
stack_used -> A -> B -> (&stack_used)
stack_cache -> C -> (&stack_cache)
td_ta_thr_iter starts by iterating at the list's head's next, and
iterates until it sees a thread whose next pointer points to the
list's head again. Thus in the before case above, C's next points to
stack_used, indicating end of list. In the same case, the stack_cache
list is empty.
For each thread being iterated, td_ta_thr_iter reads the whole thread
object out of the inferior. This includes the thread's "next"
pointer.
In the scenario above, it may happen that td_ta_thr_iter is iterating
thread B and has already read B's thread structure just before thread
C exits and its control structure moves to the cached list.
Now, recall that td_ta_thr_iter is running in the context of GDB, and
there's no locking between GDB and the inferior. From it's local copy
of B, td_ta_thr_iter believes that the next thread after B is thread
C, so it happilly continues iterating to C, a thread that has already
exited, and is now in the stack cache list.
After iterating C, td_ta_thr_iter finds the stack_cache head, which
because it is not stack_used, td_ta_thr_iter assumes it's just another
thread. After this, unless the reverse race triggers, GDB gets stuck
in td_ta_thr_iter forever walking the stack_cache list, as no thread
in thatlist has a next pointer that points back to stack_used (the
terminating condition).
Before fully understanding the issue, I tried adding cycle detection
to GDB's td_ta_thr_iter callback. However, td_ta_thr_iter skips
calling the callback in some cases, which means that it's possible
that the callback isn't called at all, making it impossible for GDB to
break the loop. I did manage to get GDB stuck in that state more than
once.
Fortunately, we can avoid the issue altogether. We don't really need
td_ta_thr_iter for live debugging nowadays, given PTRACE_EVENT_CLONE.
We already know how to map and lwp id to a thread id without iterating
(thread_from_lwp), so use that more.
gdb/ChangeLog:
2015-02-20 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_handle_extended_wait): Call
thread_db_notice_clone whenever a new clone LWP is detected.
(linux_stop_and_wait_all_lwps, linux_unstop_all_lwps): New
functions.
* linux-nat.h (thread_db_attach_lwp): Delete declaration.
(thread_db_notice_clone, linux_stop_and_wait_all_lwps)
(linux_unstop_all_lwps): Declare.
* linux-thread-db.c (struct thread_get_info_inout): Delete.
(thread_get_info_callback): Delete.
(thread_from_lwp): Use td_thr_get_info and record_thread.
(thread_db_attach_lwp): Delete.
(thread_db_notice_clone): New function.
(try_thread_db_load_1): If /proc is mounted and shows the
process'es task list, walk over all LWPs and call thread_from_lwp
instead of relying on td_ta_thr_iter.
(attach_thread): Don't call check_thread_signals here. Split the
tail part of the function (which adds the thread to the core GDB
thread list) to ...
(record_thread): ... this function. Call check_thread_signals
here.
(thread_db_wait): Don't call thread_db_find_new_threads_1. Always
call thread_from_lwp.
(thread_db_update_thread_list): Rename to ...
(thread_db_update_thread_list_org): ... this.
(thread_db_update_thread_list): New function.
(thread_db_find_thread_from_tid): Delete.
(thread_db_get_ada_task_ptid): Simplify.
* nat/linux-procfs.c: Include <sys/stat.h>.
(linux_proc_task_list_dir_exists): New function.
* nat/linux-procfs.h (linux_proc_task_list_dir_exists): Declare.
gdb/gdbserver/ChangeLog:
2015-02-20 Pedro Alves <palves@redhat.com>
* thread-db.c: Include "nat/linux-procfs.h".
(thread_db_init): Skip listing new threads if the kernel supports
PTRACE_EVENT_CLONE and /proc/PID/task/ is accessible.
gdb/testsuite/ChangeLog:
2015-02-20 Pedro Alves <palves@redhat.com>
* gdb.threads/multi-create-ns-info-thr.exp: New file.
2015-02-20 21:21:59 +01:00
|
|
|
|
static int resume_stopped_resumed_lwps (struct lwp_info *lp, void *data);
|
2009-05-11 14:08:03 +02:00
|
|
|
|
|
|
|
|
|
static void block_child_signals (sigset_t *prev_mask);
|
|
|
|
|
static void restore_child_signals_mask (sigset_t *prev_mask);
|
gdb/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* linux-nat.c (linux_child_follow_fork): If we're staying attached
to the child process, enable event reporting on it. Don't handle
checkpoints here. Instead, add the child fork to the lwp thread
and inferior lists without clobbering the previous inferior. Let
the thread_db layer learn about a new child process, even if
following the parent.
(linux_nat_switch_fork): Delete lwps of the current inferior only,
instead of clearing the whole list. Use thread_change_ptid to
give the core the illusion the new checkpoint is still the same
inferior. Clear the register cache.
(linux_handle_extended_wait): Handle checkpoints here.
(linux_multi_process): Turn on.
* linux-fork.c (struct fork_info) <pc>: Remove field.
(init_fork_list): Do not delete the checkpoint from the inferior
list (it is not there).
(fork_load_infrun_state): Don't switch inferior_ptid here. Pass
the new checkpoint's ptid to linux_nat_switch_fork.
(fork_save_infrun_state): Make static. Don't stop the pc field of
fork_info, it's gone.
(linux_fork_mourn_inferior): Don't delete the checkpoint from the
inferior list, it's not there.
(linux_fork_detach): Ditto.
(delete_fork_command): Replace mention of fork/checkpoint by
checkpoint only.
(detach_fork_command): Likewise. Don't delete the checkpoint from
the inferior list.
(info_forks_command): Adjust.
(restore_detach_fork): Delete.
(checkpointing_pid): New.
(linux_fork_checkpointing_p): New.
(save_detach_fork): Delete.
(checkpoint_command): Delete temp_detach_fork. Don't remove
breakpoints, that's a nop. Store the pid of the process we're
checkpointing, and use make_cleanup_restore_integer to restore it.
Don't reinsert breakpoints here.
(process_command, fork_command): Delete.
(restart_command): Update comments to only mention checkpoints,
not forks.
(_initialize_linux_fork): Delete "fork", "process", "info forks"
commands.
* linux-fork.h (fork_save_infrun_state, fork_list): Delete
declarations.
(linux_fork_checkpointing_p): Declare.
* cli/cli-cmds.c (killlist): New.
* cli/cli-cmds.h (killlist): Declare.
* gdbcmd.h (killlist): Declare.
* inferior.c: Include "gdbthread.h".
(detach_inferior_command, kill_inferior_command)
(inferior_command): New.
(info_inferiors_command): Allow specifying a specific inferior id.
(_initialize_inferiors): Register "inferior", "kill inferior" and
"detach inferior" commands.
* infcmd.c (_initialize_infcmd): Make "kill" a prefix command.
* gdbthread.h (any_thread_of_process): Declare.
* thread.c (any_thread_of_process): New.
* NEWS: Mention multi-inferior debugging. Mention 'info
inferiors', 'inferior', 'detach inferior' and 'kill inferior' as
new commands.
(Removed commands): New section, mentioning that 'info forks',
'fork', 'process', 'delete fork' and 'detach fork' are now gone.
gdb/testsuite/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.base/multi-forks.exp: Only run detach-on-fork tests on
linux. Adjust to use "inferior", "info inferiors", "detach
inferior" and "kill inferior" instead of "restart", "info fork",
"detach fork" and "delete fork".
* gdb.base/ending-run.exp: Spell out "info".
* gdb.base/help.exp: Adjust to use test_prefix_command_help for
the "kill" command.
gdb/doc/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (Debugging multiple inferiors): Document the
"inferior", "detach inferior" and "kill inferior" commands.
(Debugging Programs with Multiple Processes): Adjust to mention
generic "inferior" commands. Delete mention of "detach fork" and
"delete fork". Cross reference to "Debugging multiple inferiors"
section.
2009-07-02 23:57:28 +02:00
|
|
|
|
|
|
|
|
|
struct lwp_info;
|
|
|
|
|
static struct lwp_info *add_lwp (ptid_t ptid);
|
|
|
|
|
static void purge_lwp_list (int pid);
|
2012-01-24 14:46:55 +01:00
|
|
|
|
static void delete_lwp (ptid_t ptid);
|
gdb/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* linux-nat.c (linux_child_follow_fork): If we're staying attached
to the child process, enable event reporting on it. Don't handle
checkpoints here. Instead, add the child fork to the lwp thread
and inferior lists without clobbering the previous inferior. Let
the thread_db layer learn about a new child process, even if
following the parent.
(linux_nat_switch_fork): Delete lwps of the current inferior only,
instead of clearing the whole list. Use thread_change_ptid to
give the core the illusion the new checkpoint is still the same
inferior. Clear the register cache.
(linux_handle_extended_wait): Handle checkpoints here.
(linux_multi_process): Turn on.
* linux-fork.c (struct fork_info) <pc>: Remove field.
(init_fork_list): Do not delete the checkpoint from the inferior
list (it is not there).
(fork_load_infrun_state): Don't switch inferior_ptid here. Pass
the new checkpoint's ptid to linux_nat_switch_fork.
(fork_save_infrun_state): Make static. Don't stop the pc field of
fork_info, it's gone.
(linux_fork_mourn_inferior): Don't delete the checkpoint from the
inferior list, it's not there.
(linux_fork_detach): Ditto.
(delete_fork_command): Replace mention of fork/checkpoint by
checkpoint only.
(detach_fork_command): Likewise. Don't delete the checkpoint from
the inferior list.
(info_forks_command): Adjust.
(restore_detach_fork): Delete.
(checkpointing_pid): New.
(linux_fork_checkpointing_p): New.
(save_detach_fork): Delete.
(checkpoint_command): Delete temp_detach_fork. Don't remove
breakpoints, that's a nop. Store the pid of the process we're
checkpointing, and use make_cleanup_restore_integer to restore it.
Don't reinsert breakpoints here.
(process_command, fork_command): Delete.
(restart_command): Update comments to only mention checkpoints,
not forks.
(_initialize_linux_fork): Delete "fork", "process", "info forks"
commands.
* linux-fork.h (fork_save_infrun_state, fork_list): Delete
declarations.
(linux_fork_checkpointing_p): Declare.
* cli/cli-cmds.c (killlist): New.
* cli/cli-cmds.h (killlist): Declare.
* gdbcmd.h (killlist): Declare.
* inferior.c: Include "gdbthread.h".
(detach_inferior_command, kill_inferior_command)
(inferior_command): New.
(info_inferiors_command): Allow specifying a specific inferior id.
(_initialize_inferiors): Register "inferior", "kill inferior" and
"detach inferior" commands.
* infcmd.c (_initialize_infcmd): Make "kill" a prefix command.
* gdbthread.h (any_thread_of_process): Declare.
* thread.c (any_thread_of_process): New.
* NEWS: Mention multi-inferior debugging. Mention 'info
inferiors', 'inferior', 'detach inferior' and 'kill inferior' as
new commands.
(Removed commands): New section, mentioning that 'info forks',
'fork', 'process', 'delete fork' and 'detach fork' are now gone.
gdb/testsuite/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.base/multi-forks.exp: Only run detach-on-fork tests on
linux. Adjust to use "inferior", "info inferiors", "detach
inferior" and "kill inferior" instead of "restart", "info fork",
"detach fork" and "delete fork".
* gdb.base/ending-run.exp: Spell out "info".
* gdb.base/help.exp: Adjust to use test_prefix_command_help for
the "kill" command.
gdb/doc/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (Debugging multiple inferiors): Document the
"inferior", "detach inferior" and "kill inferior" commands.
(Debugging Programs with Multiple Processes): Adjust to mention
generic "inferior" commands. Delete mention of "detach fork" and
"delete fork". Cross reference to "Debugging multiple inferiors"
section.
2009-07-02 23:57:28 +02:00
|
|
|
|
static struct lwp_info *find_lwp_pid (ptid_t ptid);
|
|
|
|
|
|
2015-01-07 20:41:06 +01:00
|
|
|
|
static int lwp_status_pending_p (struct lwp_info *lp);
|
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
static int sigtrap_is_event (int status);
|
|
|
|
|
static int (*linux_nat_status_is_event) (int status) = sigtrap_is_event;
|
|
|
|
|
|
2016-02-24 23:52:06 +01:00
|
|
|
|
static void save_stop_reason (struct lwp_info *lp);
|
|
|
|
|
|
2015-03-24 15:05:44 +01:00
|
|
|
|
|
|
|
|
|
/* LWP accessors. */
|
|
|
|
|
|
|
|
|
|
/* See nat/linux-nat.h. */
|
|
|
|
|
|
|
|
|
|
ptid_t
|
|
|
|
|
ptid_of_lwp (struct lwp_info *lwp)
|
|
|
|
|
{
|
|
|
|
|
return lwp->ptid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See nat/linux-nat.h. */
|
|
|
|
|
|
2015-03-24 15:05:44 +01:00
|
|
|
|
void
|
|
|
|
|
lwp_set_arch_private_info (struct lwp_info *lwp,
|
|
|
|
|
struct arch_lwp_info *info)
|
|
|
|
|
{
|
|
|
|
|
lwp->arch_private = info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See nat/linux-nat.h. */
|
|
|
|
|
|
|
|
|
|
struct arch_lwp_info *
|
|
|
|
|
lwp_arch_private_info (struct lwp_info *lwp)
|
|
|
|
|
{
|
|
|
|
|
return lwp->arch_private;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See nat/linux-nat.h. */
|
|
|
|
|
|
2015-03-24 15:05:44 +01:00
|
|
|
|
int
|
|
|
|
|
lwp_is_stopped (struct lwp_info *lwp)
|
|
|
|
|
{
|
|
|
|
|
return lwp->stopped;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See nat/linux-nat.h. */
|
|
|
|
|
|
|
|
|
|
enum target_stop_reason
|
|
|
|
|
lwp_stop_reason (struct lwp_info *lwp)
|
|
|
|
|
{
|
|
|
|
|
return lwp->stop_reason;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-16 19:25:55 +02:00
|
|
|
|
/* See nat/linux-nat.h. */
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
lwp_is_stepping (struct lwp_info *lwp)
|
|
|
|
|
{
|
|
|
|
|
return lwp->step;
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-19 01:33:31 +02:00
|
|
|
|
|
|
|
|
|
/* Trivial list manipulation functions to keep track of a list of
|
|
|
|
|
new stopped processes. */
|
|
|
|
|
static void
|
2007-01-08 22:09:47 +01:00
|
|
|
|
add_to_pid_list (struct simple_pid_list **listp, int pid, int status)
|
2003-06-19 01:33:31 +02:00
|
|
|
|
{
|
Replace some xmalloc-family functions with XNEW-family ones
This patch is part of the make-gdb-buildable-in-C++ effort. The idea is
to change some calls to the xmalloc family of functions to calls to the
equivalents in the XNEW family. This avoids adding an explicit cast, so
it keeps the code a bit more readable. Some of them also map relatively
well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be
possible to do scripted replacements if needed.
I only changed calls that were obviously allocating memory for one or
multiple "objects". Allocation of variable sizes (such as strings or
buffer handling) will be for later (and won't use XNEW).
- xmalloc (sizeof (struct foo)) -> XNEW (struct foo)
- xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num)
- xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo)
- xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num)
- xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num)
- obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo)
- obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num)
- alloca (sizeof (struct foo)) -> XALLOCA (struct foo)
- alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num)
Some instances of xmalloc followed by memset to zero the buffer were
replaced by XCNEW or XCNEWVEC.
I regtested on x86-64, Ubuntu 14.04, but the patch touches many
architecture-specific files. For those I'll have to rely on the
buildbot or people complaining that I broke their gdb.
gdb/ChangeLog:
* aarch64-linux-nat.c (aarch64_add_process): Likewise.
* aarch64-tdep.c (aarch64_gdbarch_init): Likewise.
* ada-exp.y (write_ambiguous_var): Likewise.
* ada-lang.c (resolve_subexp): Likewise.
(user_select_syms): Likewise.
(assign_aggregate): Likewise.
(ada_evaluate_subexp): Likewise.
(cache_symbol): Likewise.
* addrmap.c (allocate_key): Likewise.
(addrmap_create_mutable): Likewise.
* aix-thread.c (sync_threadlists): Likewise.
* alpha-tdep.c (alpha_push_dummy_call): Likewise.
(alpha_gdbarch_init): Likewise.
* amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise.
* arm-linux-nat.c (arm_linux_add_process): Likewise.
* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
* arm-tdep.c (push_stack_item): Likewise.
(arm_displaced_step_copy_insn): Likewise.
(arm_gdbarch_init): Likewise.
(_initialize_arm_tdep): Likewise.
* avr-tdep.c (push_stack_item): Likewise.
* ax-general.c (new_agent_expr): Likewise.
* block.c (block_initialize_namespace): Likewise.
* breakpoint.c (alloc_counted_command_line): Likewise.
(update_dprintf_command_list): Likewise.
(parse_breakpoint_sals): Likewise.
(decode_static_tracepoint_spec): Likewise.
(until_break_command): Likewise.
(clear_command): Likewise.
(update_global_location_list): Likewise.
(get_breakpoint_objfile_data) Likewise.
* btrace.c (ftrace_new_function): Likewise.
(btrace_set_insn_history): Likewise.
(btrace_set_call_history): Likewise.
* buildsym.c (add_symbol_to_list): Likewise.
(record_pending_block): Likewise.
(start_subfile): Likewise.
(start_buildsym_compunit): Likewise.
(push_subfile): Likewise.
(end_symtab_get_static_block): Likewise.
(buildsym_init): Likewise.
* cli/cli-cmds.c (source_command): Likewise.
* cli/cli-decode.c (add_cmd): Likewise.
* cli/cli-script.c (build_command_line): Likewise.
(setup_user_args): Likewise.
(realloc_body_list): Likewise.
(process_next_line): Likewise.
(copy_command_lines): Likewise.
* cli/cli-setshow.c (do_set_command): Likewise.
* coff-pe-read.c (read_pe_exported_syms): Likewise.
* coffread.c (coff_locate_sections): Likewise.
(coff_symtab_read): Likewise.
(coff_read_struct_type): Likewise.
* common/cleanups.c (make_my_cleanup2): Likewise.
* common/common-exceptions.c (throw_it): Likewise.
* common/filestuff.c (make_cleanup_close): Likewise.
* common/format.c (parse_format_string): Likewise.
* common/queue.h (DEFINE_QUEUE_P): Likewise.
* compile/compile-object-load.c (munmap_list_add): Likewise.
(compile_object_load): Likewise.
* compile/compile-object-run.c (compile_object_run): Likewise.
* compile/compile.c (append_args): Likewise.
* corefile.c (specify_exec_file_hook): Likewise.
* cp-support.c (make_symbol_overload_list): Likewise.
* cris-tdep.c (push_stack_item): Likewise.
(cris_gdbarch_init): Likewise.
* ctf.c (ctf_trace_file_writer_new): Likewise.
* dbxread.c (init_header_files): Likewise.
(add_new_header_file): Likewise.
(init_bincl_list): Likewise.
(dbx_end_psymtab): Likewise.
(start_psymtab): Likewise.
(dbx_end_psymtab): Likewise.
* dcache.c (dcache_init): Likewise.
* dictionary.c (dict_create_hashed): Likewise.
(dict_create_hashed_expandable): Likewise.
(dict_create_linear): Likewise.
(dict_create_linear_expandable): Likewise.
* dtrace-probe.c (dtrace_process_dof_probe): Likewise.
* dummy-frame.c (register_dummy_frame_dtor): Likewise.
* dwarf2-frame-tailcall.c (cache_new_ref1): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
(decode_frame_entry_1): Likewise.
* dwarf2expr.c (new_dwarf_expr_context): Likewise.
* dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise.
* dwarf2read.c (dwarf2_has_info): Likewise.
(create_signatured_type_table_from_index): Likewise.
(dwarf2_read_index): Likewise.
(dw2_get_file_names_reader): Likewise.
(create_all_type_units): Likewise.
(read_cutu_die_from_dwo): Likewise.
(init_tu_and_read_dwo_dies): Likewise.
(init_cutu_and_read_dies): Likewise.
(create_all_comp_units): Likewise.
(queue_comp_unit): Likewise.
(inherit_abstract_dies): Likewise.
(read_call_site_scope): Likewise.
(dwarf2_add_field): Likewise.
(dwarf2_add_typedef): Likewise.
(dwarf2_add_member_fn): Likewise.
(attr_to_dynamic_prop): Likewise.
(abbrev_table_alloc_abbrev): Likewise.
(abbrev_table_read_table): Likewise.
(add_include_dir): Likewise.
(add_file_name): Likewise.
(dwarf_decode_line_header): Likewise.
(dwarf2_const_value_attr): Likewise.
(dwarf_alloc_block): Likewise.
(parse_macro_definition): Likewise.
(set_die_type): Likewise.
(write_psymtabs_to_index): Likewise.
(create_cus_from_index): Likewise.
(dwarf2_create_include_psymtab): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(build_type_psymtab_dependencies): Likewise.
(read_comp_units_from_section): Likewise.
(compute_compunit_symtab_includes): Likewise.
(create_dwo_unit_in_dwp_v1): Likewise.
(create_dwo_unit_in_dwp_v2): Likewise.
(read_func_scope): Likewise.
(process_structure_scope): Likewise.
(mark_common_block_symbol_computed): Likewise.
(load_partial_dies): Likewise.
(dwarf2_symbol_mark_computed): Likewise.
* elfread.c (elf_symfile_segments): Likewise.
(elf_read_minimal_symbols): Likewise.
* environ.c (make_environ): Likewise.
* eval.c (evaluate_subexp_standard): Likewise.
* event-loop.c (create_file_handler): Likewise.
(create_async_signal_handler): Likewise.
(create_async_event_handler): Likewise.
(create_timer): Likewise.
* exec.c (build_section_table): Likewise.
* fbsd-nat.c (fbsd_remember_child): Likewise.
* fork-child.c (fork_inferior): Likewise.
* frv-tdep.c (new_variant): Likewise.
* gdbarch.sh (gdbarch_alloc): Likewise.
(append_name): Likewise.
* gdbtypes.c (rank_function): Likewise.
(copy_type_recursive): Likewise.
(add_dyn_prop): Likewise.
* gnu-nat.c (make_proc): Likewise.
(make_inf): Likewise.
(gnu_write_inferior): Likewise.
* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
(build_std_type_info_type): Likewise.
* guile/scm-param.c (compute_enum_list): Likewise.
* guile/scm-utils.c (gdbscm_parse_function_args): Likewise.
* guile/scm-value.c (gdbscm_value_call): Likewise.
* h8300-tdep.c (h8300_gdbarch_init): Likewise.
* hppa-tdep.c (hppa_init_objfile_priv_data): Likewise.
(read_unwind_info): Likewise.
* ia64-tdep.c (ia64_gdbarch_init): Likewise.
* infcall.c (dummy_frame_context_saver_setup): Likewise.
(call_function_by_hand_dummy): Likewise.
* infcmd.c (step_once): Likewise.
(finish_forward): Likewise.
(attach_command): Likewise.
(notice_new_inferior): Likewise.
* inferior.c (add_inferior_silent): Likewise.
* infrun.c (add_displaced_stepping_state): Likewise.
(save_infcall_control_state): Likewise.
(save_inferior_ptid): Likewise.
(_initialize_infrun): Likewise.
* jit.c (bfd_open_from_target_memory): Likewise.
(jit_gdbarch_data_init): Likewise.
* language.c (add_language): Likewise.
* linespec.c (decode_line_2): Likewise.
* linux-nat.c (add_to_pid_list): Likewise.
(add_initial_lwp): Likewise.
* linux-thread-db.c (add_thread_db_info): Likewise.
(record_thread): Likewise.
(info_auto_load_libthread_db): Likewise.
* m32c-tdep.c (m32c_gdbarch_init): Likewise.
* m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise.
* m68k-tdep.c (m68k_gdbarch_init): Likewise.
* m88k-tdep.c (m88k_analyze_prologue): Likewise.
* macrocmd.c (macro_define_command): Likewise.
* macroexp.c (gather_arguments): Likewise.
* macroscope.c (sal_macro_scope): Likewise.
* macrotab.c (new_macro_table): Likewise.
* mdebugread.c (push_parse_stack): Likewise.
(parse_partial_symbols): Likewise.
(parse_symbol): Likewise.
(psymtab_to_symtab_1): Likewise.
(new_block): Likewise.
(new_psymtab): Likewise.
(mdebug_build_psymtabs): Likewise.
(add_pending): Likewise.
(elfmdebug_build_psymtabs): Likewise.
* mep-tdep.c (mep_gdbarch_init): Likewise.
* mi/mi-main.c (mi_execute_command): Likewise.
* mi/mi-parse.c (mi_parse_argv): Likewise.
* minidebug.c (lzma_open): Likewise.
* minsyms.c (terminate_minimal_symbol_table): Likewise.
* mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* mn10300-tdep.c (mn10300_gdbarch_init): Likewise.
* msp430-tdep.c (msp430_gdbarch_init): Likewise.
* mt-tdep.c (mt_registers_info): Likewise.
* nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise.
* nat/linux-btrace.c (linux_enable_bts): Likewise.
(linux_enable_pt): Likewise.
* nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise.
(linux_xfer_osdata_processgroups): Likewise.
* nios2-tdep.c (nios2_gdbarch_init): Likewise.
* nto-procfs.c (procfs_meminfo): Likewise.
* objc-lang.c (start_msglist): Likewise.
(selectors_info): Likewise.
(classes_info): Likewise.
(find_methods): Likewise.
* objfiles.c (allocate_objfile): Likewise.
(update_section_map): Likewise.
* osabi.c (gdbarch_register_osabi): Likewise.
(gdbarch_register_osabi_sniffer): Likewise.
* parse.c (start_arglist): Likewise.
* ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise.
(hwdebug_insert_point): Likewise.
* printcmd.c (display_command): Likewise.
(ui_printf): Likewise.
* procfs.c (create_procinfo): Likewise.
(load_syscalls): Likewise.
(proc_get_LDT_entry): Likewise.
(proc_update_threads): Likewise.
* prologue-value.c (make_pv_area): Likewise.
(pv_area_store): Likewise.
* psymtab.c (extend_psymbol_list): Likewise.
(init_psymbol_list): Likewise.
(allocate_psymtab): Likewise.
* python/py-inferior.c (add_thread_object): Likewise.
* python/py-param.c (compute_enum_values): Likewise.
* python/py-value.c (valpy_call): Likewise.
* python/py-varobj.c (py_varobj_iter_next): Likewise.
* python/python.c (ensure_python_env): Likewise.
* record-btrace.c (record_btrace_start_replaying): Likewise.
* record-full.c (record_full_reg_alloc): Likewise.
(record_full_mem_alloc): Likewise.
(record_full_end_alloc): Likewise.
(record_full_core_xfer_partial): Likewise.
* regcache.c (get_thread_arch_aspace_regcache): Likewise.
* remote-fileio.c (remote_fileio_init_fd_map): Likewise.
* remote-notif.c (remote_notif_state_allocate): Likewise.
* remote.c (demand_private_info): Likewise.
(remote_notif_stop_alloc_reply): Likewise.
(remote_enable_btrace): Likewise.
* reverse.c (save_bookmark_command): Likewise.
* rl78-tdep.c (rl78_gdbarch_init): Likewise.
* rx-tdep.c (rx_gdbarch_init): Likewise.
* s390-linux-nat.c (s390_insert_watchpoint): Likewise.
* ser-go32.c (dos_get_tty_state): Likewise.
(dos_copy_tty_state): Likewise.
* ser-mingw.c (ser_windows_open): Likewise.
(ser_console_wait_handle): Likewise.
(ser_console_get_tty_state): Likewise.
(make_pipe_state): Likewise.
(net_windows_open): Likewise.
* ser-unix.c (hardwire_get_tty_state): Likewise.
(hardwire_copy_tty_state): Likewise.
* solib-aix.c (solib_aix_new_lm_info): Likewise.
* solib-dsbt.c (dsbt_current_sos): Likewise.
(dsbt_relocate_main_executable): Likewise.
* solib-frv.c (frv_current_sos): Likewise.
(frv_relocate_main_executable): Likewise.
* solib-spu.c (spu_bfd_fopen): Likewise.
* solib-svr4.c (lm_info_read): Likewise.
(svr4_copy_library_list): Likewise.
(svr4_default_sos): Likewise.
* source.c (find_source_lines): Likewise.
(line_info): Likewise.
(add_substitute_path_rule): Likewise.
* spu-linux-nat.c (spu_bfd_open): Likewise.
* spu-tdep.c (info_spu_dma_cmdlist): Likewise.
* stabsread.c (dbx_lookup_type): Likewise.
(read_type): Likewise.
(read_member_functions): Likewise.
(read_struct_fields): Likewise.
(read_baseclasses): Likewise.
(read_args): Likewise.
(_initialize_stabsread): Likewise.
* stack.c (func_command): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (addrs_section_sort): Likewise.
(addr_info_make_relative): Likewise.
(load_section_callback): Likewise.
(add_symbol_file_command): Likewise.
(init_filename_language_table): Likewise.
* symtab.c (create_filename_seen_cache): Likewise.
(sort_search_symbols_remove_dups): Likewise.
(search_symbols): Likewise.
* target.c (make_cleanup_restore_target_terminal): Likewise.
* thread.c (new_thread): Likewise.
(enable_thread_stack_temporaries): Likewise.
(make_cleanup_restore_current_thread): Likewise.
(thread_apply_all_command): Likewise.
* tic6x-tdep.c (tic6x_gdbarch_init): Likewise.
* top.c (gdb_readline_wrapper): Likewise.
* tracefile-tfile.c (tfile_trace_file_writer_new): Likewise.
* tracepoint.c (trace_find_line_command): Likewise.
(all_tracepoint_actions_and_cleanup): Likewise.
(make_cleanup_restore_current_traceframe): Likewise.
(get_uploaded_tp): Likewise.
(get_uploaded_tsv): Likewise.
* tui/tui-data.c (tui_alloc_generic_win_info): Likewise.
(tui_alloc_win_info): Likewise.
(tui_alloc_content): Likewise.
(tui_add_content_elements): Likewise.
* tui/tui-disasm.c (tui_find_disassembly_address): Likewise.
(tui_set_disassem_content): Likewise.
* ui-file.c (ui_file_new): Likewise.
(stdio_file_new): Likewise.
(tee_file_new): Likewise.
* utils.c (make_cleanup_restore_integer): Likewise.
(add_internal_problem_command): Likewise.
* v850-tdep.c (v850_gdbarch_init): Likewise.
* valops.c (find_oload_champ): Likewise.
* value.c (allocate_value_lazy): Likewise.
(record_latest_value): Likewise.
(create_internalvar): Likewise.
* varobj.c (install_variable): Likewise.
(new_variable): Likewise.
(new_root_variable): Likewise.
(cppush): Likewise.
(_initialize_varobj): Likewise.
* windows-nat.c (windows_make_so): Likewise.
* x86-nat.c (x86_add_process): Likewise.
* xcoffread.c (arrange_linetable): Likewise.
(allocate_include_entry): Likewise.
(process_linenos): Likewise.
(SYMBOL_DUP): Likewise.
(xcoff_start_psymtab): Likewise.
(xcoff_end_psymtab): Likewise.
* xml-support.c (gdb_xml_parse_attr_ulongest): Likewise.
* xtensa-tdep.c (xtensa_register_type): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
gdb/gdbserver/ChangeLog:
* ax.c (gdb_parse_agent_expr): Likewise.
(compile_bytecodes): Likewise.
* dll.c (loaded_dll): Likewise.
* event-loop.c (append_callback_event): Likewise.
(create_file_handler): Likewise.
(create_file_event): Likewise.
* hostio.c (handle_open): Likewise.
* inferiors.c (add_thread): Likewise.
(add_process): Likewise.
* linux-aarch64-low.c (aarch64_linux_new_process): Likewise.
* linux-arm-low.c (arm_new_process): Likewise.
(arm_new_thread): Likewise.
* linux-low.c (add_to_pid_list): Likewise.
(linux_add_process): Likewise.
(handle_extended_wait): Likewise.
(add_lwp): Likewise.
(enqueue_one_deferred_signal): Likewise.
(enqueue_pending_signal): Likewise.
(linux_resume_one_lwp_throw): Likewise.
(linux_resume_one_thread): Likewise.
(linux_read_memory): Likewise.
(linux_write_memory): Likewise.
* linux-mips-low.c (mips_linux_new_process): Likewise.
(mips_linux_new_thread): Likewise.
(mips_add_watchpoint): Likewise.
* linux-x86-low.c (initialize_low_arch): Likewise.
* lynx-low.c (lynx_add_process): Likewise.
* mem-break.c (set_raw_breakpoint_at): Likewise.
(set_breakpoint): Likewise.
(add_condition_to_breakpoint): Likewise.
(add_commands_to_breakpoint): Likewise.
(clone_agent_expr): Likewise.
(clone_one_breakpoint): Likewise.
* regcache.c (new_register_cache): Likewise.
* remote-utils.c (look_up_one_symbol): Likewise.
* server.c (queue_stop_reply): Likewise.
(start_inferior): Likewise.
(queue_stop_reply_callback): Likewise.
(handle_target_event): Likewise.
* spu-low.c (fetch_ppc_memory): Likewise.
(store_ppc_memory): Likewise.
* target.c (set_target_ops): Likewise.
* thread-db.c (thread_db_load_search): Likewise.
(try_thread_db_load_1): Likewise.
* tracepoint.c (add_tracepoint): Likewise.
(add_tracepoint_action): Likewise.
(create_trace_state_variable): Likewise.
(cmd_qtdpsrc): Likewise.
(cmd_qtro): Likewise.
(add_while_stepping_state): Likewise.
* win32-low.c (child_add_thread): Likewise.
(get_image_name): Likewise.
2015-08-26 23:16:07 +02:00
|
|
|
|
struct simple_pid_list *new_pid = XNEW (struct simple_pid_list);
|
2010-05-15 01:41:05 +02:00
|
|
|
|
|
2003-06-19 01:33:31 +02:00
|
|
|
|
new_pid->pid = pid;
|
2007-01-08 22:09:47 +01:00
|
|
|
|
new_pid->status = status;
|
2003-06-19 01:33:31 +02:00
|
|
|
|
new_pid->next = *listp;
|
|
|
|
|
*listp = new_pid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2010-08-28 10:38:25 +02:00
|
|
|
|
pull_pid_from_list (struct simple_pid_list **listp, int pid, int *statusp)
|
2003-06-19 01:33:31 +02:00
|
|
|
|
{
|
|
|
|
|
struct simple_pid_list **p;
|
|
|
|
|
|
|
|
|
|
for (p = listp; *p != NULL; p = &(*p)->next)
|
|
|
|
|
if ((*p)->pid == pid)
|
|
|
|
|
{
|
|
|
|
|
struct simple_pid_list *next = (*p)->next;
|
2010-05-15 01:41:05 +02:00
|
|
|
|
|
2010-08-28 10:38:25 +02:00
|
|
|
|
*statusp = (*p)->status;
|
2003-06-19 01:33:31 +02:00
|
|
|
|
xfree (*p);
|
|
|
|
|
*p = next;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
Extended-remote Linux follow fork
This patch implements basic support for follow-fork and detach-on-fork on
extended-remote Linux targets. Only 'fork' is supported in this patch;
'vfork' support is added n a subsequent patch. This patch depends on
the previous patches in the patch series.
Sufficient extended-remote functionality has been implemented here to pass
gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the
catchpoint tests commented out. Some other fork tests fail with this
patch because it doesn't provide the architecture support needed for
watchpoint inheritance or fork catchpoints.
The implementation follows the same general structure as for the native
implementation as much as possible.
This implementation includes:
* enabling fork events in linux-low.c in initialize_low and
linux_enable_extended_features
* handling fork events in gdbserver/linux-low.c:handle_extended_wait
- when a fork event occurs in gdbserver, we must do the full creation
of the new process, thread, lwp, and breakpoint lists. This is
required whether or not the new child is destined to be
detached-on-fork, because GDB will make target calls that require all
the structures. In particular we need the breakpoint lists in order
to remove the breakpoints from a detaching child. If we are not
detaching the child we will need all these structures anyway.
- as part of this event handling we store the target_waitstatus in a new
member of the parent lwp_info structure, 'waitstatus'. This
is used to store extended event information for reporting to GDB.
- handle_extended_wait is given a return value, denoting whether the
handled event should be reported to GDB. Previously it had only
handled clone events, which were never reported.
* using a new predicate in gdbserver to control handling of the fork event
(and eventually all extended events) in linux_wait_1. The predicate,
extended_event_reported, checks a target_waitstatus.kind for an
extended ptrace event.
* implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in
gdbserver/remote-utils.c and remote.c.
* implementing new target and RSP support for target_follow_fork with
target extended-remote. (The RSP components were actually defined in
patch 1, but they see their first use here).
- remote target routine remote_follow_fork, which just sends the 'D;pid'
detach packet to detach the new fork child cleanly. We can't just
call target_detach because the data structures for the forked child
have not been allocated on the host side.
Tested on x64 Ubuntu Lucid, native, remote, extended-remote.
gdb/gdbserver/ChangeLog:
* linux-low.c (handle_extended_wait): Implement return value,
rename argument 'event_child' to 'event_lwp', handle
PTRACE_EVENT_FORK, call internal_error for unrecognized event.
(linux_low_ptrace_options): New function.
(linux_low_filter_event): Call linux_low_ptrace_options,
use different argument fo linux_enable_event_reporting,
use return value from handle_extended_wait.
(extended_event_reported): New function.
(linux_wait_1): Call extended_event_reported and set
status to report fork events.
(linux_write_memory): Add pid to debug message.
(reset_lwp_ptrace_options_callback): New function.
(linux_handle_new_gdb_connection): New function.
(linux_target_ops): Initialize new structure member.
* linux-low.h (struct lwp_info) <waitstatus>: New member.
* lynx-low.c: Initialize new structure member.
* remote-utils.c (prepare_resume_reply): Implement stop reason
"fork" for "T" stop message.
* server.c (handle_query): Call handle_new_gdb_connection.
* server.h (report_fork_events): Declare global flag.
* target.h (struct target_ops) <handle_new_gdb_connection>:
New member.
(target_handle_new_gdb_connection): New macro.
* win32-low.c: Initialize new structure member.
gdb/ChangeLog:
* linux-nat.c (linux_nat_ptrace_options): New function.
(linux_init_ptrace, wait_lwp, linux_nat_filter_event):
Call linux_nat_ptrace_options and use different argument to
linux_enable_event_reporting.
(_initialize_linux_nat): Delete call to
linux_ptrace_set_additional_flags.
* nat/linux-ptrace.c (current_ptrace_options): Rename to
supported_ptrace_options.
(additional_flags): Delete variable.
(linux_check_ptrace_features): Use supported_ptrace_options.
(linux_test_for_tracesysgood, linux_test_for_tracefork):
Likewise, and remove additional_flags check.
(linux_enable_event_reporting): Change 'attached' argument to
'options'. Use supported_ptrace_options.
(ptrace_supports_feature): Change comment. Use
supported_ptrace_options.
(linux_ptrace_set_additional_flags): Delete function.
* nat/linux-ptrace.h (linux_ptrace_set_additional_flags):
Delete function prototype.
* remote.c (remote_fork_event_p): New function.
(remote_detach_pid): New function.
(remote_detach_1): Call remote_detach_pid, don't mourn inferior
if doing detach-on-fork.
(remote_follow_fork): New function.
(remote_parse_stop_reply): Handle new "T" stop reason "fork".
(remote_pid_to_str): Print "process" strings for pid/0/0 ptids.
(init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
|
|
|
|
/* Return the ptrace options that we want to try to enable. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
linux_nat_ptrace_options (int attached)
|
|
|
|
|
{
|
|
|
|
|
int options = 0;
|
|
|
|
|
|
|
|
|
|
if (!attached)
|
|
|
|
|
options |= PTRACE_O_EXITKILL;
|
|
|
|
|
|
|
|
|
|
options |= (PTRACE_O_TRACESYSGOOD
|
|
|
|
|
| PTRACE_O_TRACEVFORKDONE
|
|
|
|
|
| PTRACE_O_TRACEVFORK
|
|
|
|
|
| PTRACE_O_TRACEFORK
|
|
|
|
|
| PTRACE_O_TRACEEXEC);
|
|
|
|
|
|
|
|
|
|
return options;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-23 01:46:30 +02:00
|
|
|
|
/* Initialize ptrace warnings and check for supported ptrace
|
2014-11-11 07:07:21 +01:00
|
|
|
|
features given PID.
|
|
|
|
|
|
|
|
|
|
ATTACHED should be nonzero iff we attached to the inferior. */
|
2003-06-15 22:56:48 +02:00
|
|
|
|
|
|
|
|
|
static void
|
2014-11-11 07:07:21 +01:00
|
|
|
|
linux_init_ptrace (pid_t pid, int attached)
|
2003-06-15 22:56:48 +02:00
|
|
|
|
{
|
Extended-remote Linux follow fork
This patch implements basic support for follow-fork and detach-on-fork on
extended-remote Linux targets. Only 'fork' is supported in this patch;
'vfork' support is added n a subsequent patch. This patch depends on
the previous patches in the patch series.
Sufficient extended-remote functionality has been implemented here to pass
gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the
catchpoint tests commented out. Some other fork tests fail with this
patch because it doesn't provide the architecture support needed for
watchpoint inheritance or fork catchpoints.
The implementation follows the same general structure as for the native
implementation as much as possible.
This implementation includes:
* enabling fork events in linux-low.c in initialize_low and
linux_enable_extended_features
* handling fork events in gdbserver/linux-low.c:handle_extended_wait
- when a fork event occurs in gdbserver, we must do the full creation
of the new process, thread, lwp, and breakpoint lists. This is
required whether or not the new child is destined to be
detached-on-fork, because GDB will make target calls that require all
the structures. In particular we need the breakpoint lists in order
to remove the breakpoints from a detaching child. If we are not
detaching the child we will need all these structures anyway.
- as part of this event handling we store the target_waitstatus in a new
member of the parent lwp_info structure, 'waitstatus'. This
is used to store extended event information for reporting to GDB.
- handle_extended_wait is given a return value, denoting whether the
handled event should be reported to GDB. Previously it had only
handled clone events, which were never reported.
* using a new predicate in gdbserver to control handling of the fork event
(and eventually all extended events) in linux_wait_1. The predicate,
extended_event_reported, checks a target_waitstatus.kind for an
extended ptrace event.
* implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in
gdbserver/remote-utils.c and remote.c.
* implementing new target and RSP support for target_follow_fork with
target extended-remote. (The RSP components were actually defined in
patch 1, but they see their first use here).
- remote target routine remote_follow_fork, which just sends the 'D;pid'
detach packet to detach the new fork child cleanly. We can't just
call target_detach because the data structures for the forked child
have not been allocated on the host side.
Tested on x64 Ubuntu Lucid, native, remote, extended-remote.
gdb/gdbserver/ChangeLog:
* linux-low.c (handle_extended_wait): Implement return value,
rename argument 'event_child' to 'event_lwp', handle
PTRACE_EVENT_FORK, call internal_error for unrecognized event.
(linux_low_ptrace_options): New function.
(linux_low_filter_event): Call linux_low_ptrace_options,
use different argument fo linux_enable_event_reporting,
use return value from handle_extended_wait.
(extended_event_reported): New function.
(linux_wait_1): Call extended_event_reported and set
status to report fork events.
(linux_write_memory): Add pid to debug message.
(reset_lwp_ptrace_options_callback): New function.
(linux_handle_new_gdb_connection): New function.
(linux_target_ops): Initialize new structure member.
* linux-low.h (struct lwp_info) <waitstatus>: New member.
* lynx-low.c: Initialize new structure member.
* remote-utils.c (prepare_resume_reply): Implement stop reason
"fork" for "T" stop message.
* server.c (handle_query): Call handle_new_gdb_connection.
* server.h (report_fork_events): Declare global flag.
* target.h (struct target_ops) <handle_new_gdb_connection>:
New member.
(target_handle_new_gdb_connection): New macro.
* win32-low.c: Initialize new structure member.
gdb/ChangeLog:
* linux-nat.c (linux_nat_ptrace_options): New function.
(linux_init_ptrace, wait_lwp, linux_nat_filter_event):
Call linux_nat_ptrace_options and use different argument to
linux_enable_event_reporting.
(_initialize_linux_nat): Delete call to
linux_ptrace_set_additional_flags.
* nat/linux-ptrace.c (current_ptrace_options): Rename to
supported_ptrace_options.
(additional_flags): Delete variable.
(linux_check_ptrace_features): Use supported_ptrace_options.
(linux_test_for_tracesysgood, linux_test_for_tracefork):
Likewise, and remove additional_flags check.
(linux_enable_event_reporting): Change 'attached' argument to
'options'. Use supported_ptrace_options.
(ptrace_supports_feature): Change comment. Use
supported_ptrace_options.
(linux_ptrace_set_additional_flags): Delete function.
* nat/linux-ptrace.h (linux_ptrace_set_additional_flags):
Delete function prototype.
* remote.c (remote_fork_event_p): New function.
(remote_detach_pid): New function.
(remote_detach_1): Call remote_detach_pid, don't mourn inferior
if doing detach-on-fork.
(remote_follow_fork): New function.
(remote_parse_stop_reply): Handle new "T" stop reason "fork".
(remote_pid_to_str): Print "process" strings for pid/0/0 ptids.
(init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
|
|
|
|
int options = linux_nat_ptrace_options (attached);
|
|
|
|
|
|
|
|
|
|
linux_enable_event_reporting (pid, options);
|
2013-08-23 01:46:30 +02:00
|
|
|
|
linux_ptrace_init_warnings ();
|
2003-08-17 20:22:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-07 02:18:39 +02:00
|
|
|
|
static void
|
2013-12-18 05:28:08 +01:00
|
|
|
|
linux_child_post_attach (struct target_ops *self, int pid)
|
2003-08-17 20:22:25 +02:00
|
|
|
|
{
|
2014-11-11 07:07:21 +01:00
|
|
|
|
linux_init_ptrace (pid, 1);
|
2003-08-17 20:22:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
static void
|
2013-12-18 05:31:40 +01:00
|
|
|
|
linux_child_post_startup_inferior (struct target_ops *self, ptid_t ptid)
|
2003-08-17 20:22:25 +02:00
|
|
|
|
{
|
2014-11-11 07:07:21 +01:00
|
|
|
|
linux_init_ptrace (ptid_get_pid (ptid), 0);
|
2003-08-17 20:22:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-01-24 14:46:55 +01:00
|
|
|
|
/* Return the number of known LWPs in the tgid given by PID. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
num_lwps (int pid)
|
|
|
|
|
{
|
|
|
|
|
int count = 0;
|
|
|
|
|
struct lwp_info *lp;
|
|
|
|
|
|
|
|
|
|
for (lp = lwp_list; lp; lp = lp->next)
|
|
|
|
|
if (ptid_get_pid (lp->ptid) == pid)
|
|
|
|
|
count++;
|
|
|
|
|
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Call delete_lwp with prototype compatible for make_cleanup. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
delete_lwp_cleanup (void *lp_voidp)
|
|
|
|
|
{
|
Add some more casts (1/2)
Note: I needed to split this patch in two, otherwise it's too big for
the mailing list.
This patch adds explicit casts to situations where a void pointer is
assigned to a pointer to the "real" type. Building in C++ mode requires
those assignments to use an explicit cast. This includes, for example:
- callback arguments (cleanups, comparison functions, ...)
- data attached to some object (objfile, program space, etc) in the form
of a void pointer
- "user data" passed to some function
This patch comes from the commit "(mostly) auto-generated patch to insert
casts needed for C++", taken from Pedro's C++ branch.
Only files built on x86 with --enable-targets=all are modified, so the
native files for other arches will need to be dealt with separately.
I built-tested this with --enable-targets=all and reg-tested. To my
surprise, a test case (selftest.exp) had to be adjusted.
Here's the ChangeLog entry. Again, this was relatively quick to make
despite the length, thanks to David Malcom's script, although I don't
believe it's very useful information in that particular case...
gdb/ChangeLog:
* aarch64-tdep.c (aarch64_make_prologue_cache): Add cast(s).
(aarch64_make_stub_cache): Likewise.
(value_of_aarch64_user_reg): Likewise.
* ada-lang.c (ada_inferior_data_cleanup): Likewise.
(get_ada_inferior_data): Likewise.
(get_ada_pspace_data): Likewise.
(ada_pspace_data_cleanup): Likewise.
(ada_complete_symbol_matcher): Likewise.
(ada_exc_search_name_matches): Likewise.
* ada-tasks.c (get_ada_tasks_pspace_data): Likewise.
(get_ada_tasks_inferior_data): Likewise.
* addrmap.c (addrmap_mutable_foreach_worker): Likewise.
(splay_obstack_alloc): Likewise.
(splay_obstack_free): Likewise.
* alpha-linux-tdep.c (alpha_linux_supply_gregset): Likewise.
(alpha_linux_collect_gregset): Likewise.
(alpha_linux_supply_fpregset): Likewise.
(alpha_linux_collect_fpregset): Likewise.
* alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind_cache): Likewise.
* alpha-tdep.c (alpha_lds): Likewise.
(alpha_sts): Likewise.
(alpha_sigtramp_frame_unwind_cache): Likewise.
(alpha_heuristic_frame_unwind_cache): Likewise.
(alpha_supply_int_regs): Likewise.
(alpha_fill_int_regs): Likewise.
(alpha_supply_fp_regs): Likewise.
(alpha_fill_fp_regs): Likewise.
* alphanbsd-tdep.c (alphanbsd_supply_fpregset): Likewise.
(alphanbsd_aout_supply_gregset): Likewise.
(alphanbsd_supply_gregset): Likewise.
* amd64-linux-tdep.c (amd64_linux_init_abi): Likewise.
(amd64_x32_linux_init_abi): Likewise.
* amd64-nat.c (amd64_supply_native_gregset): Likewise.
(amd64_collect_native_gregset): Likewise.
* amd64-tdep.c (amd64_frame_cache): Likewise.
(amd64_sigtramp_frame_cache): Likewise.
(amd64_epilogue_frame_cache): Likewise.
(amd64_supply_fxsave): Likewise.
(amd64_supply_xsave): Likewise.
(amd64_collect_fxsave): Likewise.
(amd64_collect_xsave): Likewise.
* amd64-windows-tdep.c (amd64_windows_frame_cache): Likewise.
* amd64obsd-tdep.c (amd64obsd_trapframe_cache): Likewise.
* arm-linux-tdep.c (arm_linux_supply_gregset): Likewise.
(arm_linux_collect_gregset): Likewise.
(arm_linux_supply_nwfpe): Likewise.
(arm_linux_collect_nwfpe): Likewise.
(arm_linux_supply_vfp): Likewise.
(arm_linux_collect_vfp): Likewise.
* arm-tdep.c (arm_find_mapping_symbol): Likewise.
(arm_prologue_unwind_stop_reason): Likewise.
(arm_prologue_this_id): Likewise.
(arm_prologue_prev_register): Likewise.
(arm_exidx_data_free): Likewise.
(arm_find_exidx_entry): Likewise.
(arm_stub_this_id): Likewise.
(arm_m_exception_this_id): Likewise.
(arm_m_exception_prev_register): Likewise.
(arm_normal_frame_base): Likewise.
(gdb_print_insn_arm): Likewise.
(arm_objfile_data_free): Likewise.
(arm_record_special_symbol): Likewise.
(value_of_arm_user_reg): Likewise.
* armbsd-tdep.c (armbsd_supply_fpregset): Likewise.
(armbsd_supply_gregset): Likewise.
* auto-load.c (auto_load_pspace_data_cleanup): Likewise.
(get_auto_load_pspace_data): Likewise.
(hash_loaded_script_entry): Likewise.
(eq_loaded_script_entry): Likewise.
(clear_section_scripts): Likewise.
(collect_matching_scripts): Likewise.
* auxv.c (auxv_inferior_data_cleanup): Likewise.
(get_auxv_inferior_data): Likewise.
* avr-tdep.c (avr_frame_unwind_cache): Likewise.
* ax-general.c (do_free_agent_expr_cleanup): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
(target_bfd_xclose): Likewise.
(target_bfd_get_section_table): Likewise.
* bfin-tdep.c (bfin_frame_cache): Likewise.
* block.c (find_block_in_blockvector): Likewise.
(call_site_for_pc): Likewise.
(block_find_non_opaque_type_preferred): Likewise.
* break-catch-sig.c (signal_catchpoint_insert_location): Likewise.
(signal_catchpoint_remove_location): Likewise.
(signal_catchpoint_breakpoint_hit): Likewise.
(signal_catchpoint_print_one): Likewise.
(signal_catchpoint_print_mention): Likewise.
(signal_catchpoint_print_recreate): Likewise.
* break-catch-syscall.c (get_catch_syscall_inferior_data): Likewise.
* breakpoint.c (do_cleanup_counted_command_line): Likewise.
(bp_location_compare_addrs): Likewise.
(get_first_locp_gte_addr): Likewise.
(check_tracepoint_command): Likewise.
(do_map_commands_command): Likewise.
(get_breakpoint_objfile_data): Likewise.
(free_breakpoint_probes): Likewise.
(do_captured_breakpoint_query): Likewise.
(compare_breakpoints): Likewise.
(bp_location_compare): Likewise.
(bpstat_remove_breakpoint_callback): Likewise.
(do_delete_breakpoint_cleanup): Likewise.
* bsd-uthread.c (bsd_uthread_set_supply_uthread): Likewise.
(bsd_uthread_set_collect_uthread): Likewise.
(bsd_uthread_activate): Likewise.
(bsd_uthread_fetch_registers): Likewise.
(bsd_uthread_store_registers): Likewise.
* btrace.c (check_xml_btrace_version): Likewise.
(parse_xml_btrace_block): Likewise.
(parse_xml_btrace_pt_config_cpu): Likewise.
(parse_xml_btrace_pt_raw): Likewise.
(parse_xml_btrace_pt): Likewise.
(parse_xml_btrace_conf_bts): Likewise.
(parse_xml_btrace_conf_pt): Likewise.
(do_btrace_data_cleanup): Likewise.
* c-typeprint.c (find_typedef_for_canonicalize): Likewise.
* charset.c (cleanup_iconv): Likewise.
(do_cleanup_iterator): Likewise.
* cli-out.c (cli_uiout_dtor): Likewise.
(cli_table_begin): Likewise.
(cli_table_body): Likewise.
(cli_table_end): Likewise.
(cli_table_header): Likewise.
(cli_begin): Likewise.
(cli_end): Likewise.
(cli_field_int): Likewise.
(cli_field_skip): Likewise.
(cli_field_string): Likewise.
(cli_field_fmt): Likewise.
(cli_spaces): Likewise.
(cli_text): Likewise.
(cli_message): Likewise.
(cli_wrap_hint): Likewise.
(cli_flush): Likewise.
(cli_redirect): Likewise.
(out_field_fmt): Likewise.
(field_separator): Likewise.
(cli_out_set_stream): Likewise.
* cli/cli-cmds.c (compare_symtabs): Likewise.
* cli/cli-dump.c (call_dump_func): Likewise.
(restore_section_callback): Likewise.
* cli/cli-script.c (clear_hook_in_cleanup): Likewise.
(do_restore_user_call_depth): Likewise.
(do_free_command_lines_cleanup): Likewise.
* coff-pe-read.c (get_section_vmas): Likewise.
(pe_as16): Likewise.
(pe_as32): Likewise.
* coffread.c (coff_symfile_read): Likewise.
* common/agent.c (agent_look_up_symbols): Likewise.
* common/filestuff.c (do_close_cleanup): Likewise.
* common/format.c (free_format_pieces_cleanup): Likewise.
* common/vec.c (vec_o_reserve): Likewise.
* compile/compile-c-support.c (print_one_macro): Likewise.
* compile/compile-c-symbols.c (hash_symbol_error): Likewise.
(eq_symbol_error): Likewise.
(del_symbol_error): Likewise.
(error_symbol_once): Likewise.
(gcc_convert_symbol): Likewise.
(gcc_symbol_address): Likewise.
(hash_symname): Likewise.
(eq_symname): Likewise.
* compile/compile-c-types.c (hash_type_map_instance): Likewise.
(eq_type_map_instance): Likewise.
(insert_type): Likewise.
(convert_type): Likewise.
* compile/compile-object-load.c (munmap_listp_free_cleanup): Likewise.
(setup_sections): Likewise.
(link_hash_table_free): Likewise.
(copy_sections): Likewise.
* compile/compile-object-run.c (do_module_cleanup): Likewise.
* compile/compile.c (compile_print_value): Likewise.
(do_rmdir): Likewise.
(cleanup_compile_instance): Likewise.
(cleanup_unlink_file): Likewise.
* completer.c (free_completion_tracker): Likewise.
* corelow.c (add_to_spuid_list): Likewise.
* cp-namespace.c (reset_directive_searched): Likewise.
* cp-support.c (reset_directive_searched): Likewise.
* cris-tdep.c (cris_sigtramp_frame_unwind_cache): Likewise.
(cris_frame_unwind_cache): Likewise.
* d-lang.c (builtin_d_type): Likewise.
* d-namespace.c (reset_directive_searched): Likewise.
* dbxread.c (dbx_free_symfile_info): Likewise.
(do_free_bincl_list_cleanup): Likewise.
* disasm.c (hash_dis_line_entry): Likewise.
(eq_dis_line_entry): Likewise.
(dis_asm_print_address): Likewise.
(fprintf_disasm): Likewise.
(do_ui_file_delete): Likewise.
* doublest.c (convert_floatformat_to_doublest): Likewise.
* dummy-frame.c (pop_dummy_frame_bpt): Likewise.
(dummy_frame_prev_register): Likewise.
(dummy_frame_this_id): Likewise.
* dwarf2-frame-tailcall.c (cache_hash): Likewise.
(cache_eq): Likewise.
(cache_find): Likewise.
(tailcall_frame_this_id): Likewise.
(dwarf2_tailcall_prev_register_first): Likewise.
(tailcall_frame_prev_register): Likewise.
(tailcall_frame_dealloc_cache): Likewise.
(tailcall_frame_prev_arch): Likewise.
* dwarf2-frame.c (dwarf2_frame_state_free): Likewise.
(dwarf2_frame_set_init_reg): Likewise.
(dwarf2_frame_init_reg): Likewise.
(dwarf2_frame_set_signal_frame_p): Likewise.
(dwarf2_frame_signal_frame_p): Likewise.
(dwarf2_frame_set_adjust_regnum): Likewise.
(dwarf2_frame_adjust_regnum): Likewise.
(clear_pointer_cleanup): Likewise.
(dwarf2_frame_cache): Likewise.
(find_cie): Likewise.
(dwarf2_frame_find_fde): Likewise.
* dwarf2expr.c (dwarf_expr_address_type): Likewise.
(free_dwarf_expr_context_cleanup): Likewise.
* dwarf2loc.c (locexpr_find_frame_base_location): Likewise.
(locexpr_get_frame_base): Likewise.
(loclist_find_frame_base_location): Likewise.
(loclist_get_frame_base): Likewise.
(dwarf_expr_dwarf_call): Likewise.
(dwarf_expr_get_base_type): Likewise.
(dwarf_expr_push_dwarf_reg_entry_value): Likewise.
(dwarf_expr_get_obj_addr): Likewise.
(entry_data_value_coerce_ref): Likewise.
(entry_data_value_copy_closure): Likewise.
(entry_data_value_free_closure): Likewise.
(get_frame_address_in_block_wrapper): Likewise.
(dwarf2_evaluate_property): Likewise.
(dwarf2_compile_property_to_c): Likewise.
(needs_frame_read_addr_from_reg): Likewise.
(needs_frame_get_reg_value): Likewise.
(needs_frame_frame_base): Likewise.
(needs_frame_frame_cfa): Likewise.
(needs_frame_tls_address): Likewise.
(needs_frame_dwarf_call): Likewise.
(needs_dwarf_reg_entry_value): Likewise.
(get_ax_pc): Likewise.
(locexpr_read_variable): Likewise.
(locexpr_read_variable_at_entry): Likewise.
(locexpr_read_needs_frame): Likewise.
(locexpr_describe_location): Likewise.
(locexpr_tracepoint_var_ref): Likewise.
(locexpr_generate_c_location): Likewise.
(loclist_read_variable): Likewise.
(loclist_read_variable_at_entry): Likewise.
(loclist_describe_location): Likewise.
(loclist_tracepoint_var_ref): Likewise.
(loclist_generate_c_location): Likewise.
* dwarf2read.c (line_header_hash_voidp): Likewise.
(line_header_eq_voidp): Likewise.
(dwarf2_has_info): Likewise.
(dwarf2_get_section_info): Likewise.
(locate_dwz_sections): Likewise.
(hash_file_name_entry): Likewise.
(eq_file_name_entry): Likewise.
(delete_file_name_entry): Likewise.
(dw2_setup): Likewise.
(dw2_get_file_names_reader): Likewise.
(dw2_find_pc_sect_compunit_symtab): Likewise.
(hash_signatured_type): Likewise.
(eq_signatured_type): Likewise.
(add_signatured_type_cu_to_table): Likewise.
(create_debug_types_hash_table): Likewise.
(lookup_dwo_signatured_type): Likewise.
(lookup_dwp_signatured_type): Likewise.
(lookup_signatured_type): Likewise.
(hash_type_unit_group): Likewise.
(eq_type_unit_group): Likewise.
(get_type_unit_group): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(sort_tu_by_abbrev_offset): Likewise.
(process_skeletonless_type_unit): Likewise.
(psymtabs_addrmap_cleanup): Likewise.
(dwarf2_read_symtab): Likewise.
(psymtab_to_symtab_1): Likewise.
(die_hash): Likewise.
(die_eq): Likewise.
(load_full_comp_unit_reader): Likewise.
(reset_die_in_process): Likewise.
(free_cu_line_header): Likewise.
(handle_DW_AT_stmt_list): Likewise.
(hash_dwo_file): Likewise.
(eq_dwo_file): Likewise.
(hash_dwo_unit): Likewise.
(eq_dwo_unit): Likewise.
(create_dwo_cu_reader): Likewise.
(create_dwo_unit_in_dwp_v1): Likewise.
(create_dwo_unit_in_dwp_v2): Likewise.
(lookup_dwo_unit_in_dwp): Likewise.
(dwarf2_locate_dwo_sections): Likewise.
(dwarf2_locate_common_dwp_sections): Likewise.
(dwarf2_locate_v2_dwp_sections): Likewise.
(hash_dwp_loaded_cutus): Likewise.
(eq_dwp_loaded_cutus): Likewise.
(lookup_dwo_cutu): Likewise.
(abbrev_table_free_cleanup): Likewise.
(dwarf2_free_abbrev_table): Likewise.
(find_partial_die_in_comp_unit): Likewise.
(free_line_header_voidp): Likewise.
(follow_die_offset): Likewise.
(follow_die_sig_1): Likewise.
(free_heap_comp_unit): Likewise.
(free_stack_comp_unit): Likewise.
(dwarf2_free_objfile): Likewise.
(per_cu_offset_and_type_hash): Likewise.
(per_cu_offset_and_type_eq): Likewise.
(get_die_type_at_offset): Likewise.
(partial_die_hash): Likewise.
(partial_die_eq): Likewise.
(dwarf2_per_objfile_free): Likewise.
(hash_strtab_entry): Likewise.
(eq_strtab_entry): Likewise.
(add_string): Likewise.
(hash_symtab_entry): Likewise.
(eq_symtab_entry): Likewise.
(delete_symtab_entry): Likewise.
(cleanup_mapped_symtab): Likewise.
(add_indices_to_cpool): Likewise.
(hash_psymtab_cu_index): Likewise.
(eq_psymtab_cu_index): Likewise.
(add_address_entry_worker): Likewise.
(unlink_if_set): Likewise.
(write_one_signatured_type): Likewise.
(save_gdb_index_command): Likewise.
* elfread.c (elf_symtab_read): Likewise.
(elf_gnu_ifunc_cache_hash): Likewise.
(elf_gnu_ifunc_cache_eq): Likewise.
(elf_gnu_ifunc_record_cache): Likewise.
(elf_gnu_ifunc_resolve_by_cache): Likewise.
(elf_get_probes): Likewise.
(probe_key_free): Likewise.
* f-lang.c (builtin_f_type): Likewise.
* frame-base.c (frame_base_append_sniffer): Likewise.
(frame_base_set_default): Likewise.
(frame_base_find_by_frame): Likewise.
* frame-unwind.c (frame_unwind_prepend_unwinder): Likewise.
(frame_unwind_append_unwinder): Likewise.
(frame_unwind_find_by_frame): Likewise.
* frame.c (frame_addr_hash): Likewise.
(frame_addr_hash_eq): Likewise.
(frame_stash_find): Likewise.
(do_frame_register_read): Likewise.
(unwind_to_current_frame): Likewise.
(frame_cleanup_after_sniffer): Likewise.
* frv-linux-tdep.c (frv_linux_sigtramp_frame_cache): Likewise.
* frv-tdep.c (frv_frame_unwind_cache): Likewise.
* ft32-tdep.c (ft32_frame_cache): Likewise.
* gcore.c (do_bfd_delete_cleanup): Likewise.
(gcore_create_callback): Likewise.
* gdb_bfd.c (hash_bfd): Likewise.
(eq_bfd): Likewise.
(gdb_bfd_open): Likewise.
(free_one_bfd_section): Likewise.
(gdb_bfd_ref): Likewise.
(gdb_bfd_unref): Likewise.
(get_section_descriptor): Likewise.
(gdb_bfd_map_section): Likewise.
(gdb_bfd_crc): Likewise.
(gdb_bfd_mark_parent): Likewise.
(gdb_bfd_record_inclusion): Likewise.
(gdb_bfd_requires_relocations): Likewise.
(print_one_bfd): Likewise.
* gdbtypes.c (type_pair_hash): Likewise.
(type_pair_eq): Likewise.
(builtin_type): Likewise.
(objfile_type): Likewise.
* gnu-v3-abi.c (vtable_ptrdiff_type): Likewise.
(vtable_address_point_offset): Likewise.
(gnuv3_get_vtable): Likewise.
(hash_value_and_voffset): Likewise.
(eq_value_and_voffset): Likewise.
(compare_value_and_voffset): Likewise.
(compute_vtable_size): Likewise.
(gnuv3_get_typeid_type): Likewise.
* go-lang.c (builtin_go_type): Likewise.
* guile/scm-block.c (bkscm_hash_block_smob): Likewise.
(bkscm_eq_block_smob): Likewise.
(bkscm_objfile_block_map): Likewise.
(bkscm_del_objfile_blocks): Likewise.
* guile/scm-breakpoint.c (bpscm_build_bp_list): Likewise.
* guile/scm-disasm.c (gdbscm_disasm_read_memory_worker): Likewise.
(gdbscm_disasm_print_address): Likewise.
* guile/scm-frame.c (frscm_hash_frame_smob): Likewise.
(frscm_eq_frame_smob): Likewise.
(frscm_inferior_frame_map): Likewise.
(frscm_del_inferior_frames): Likewise.
* guile/scm-gsmob.c (gdbscm_add_objfile_ref): Likewise.
* guile/scm-objfile.c (ofscm_handle_objfile_deleted): Likewise.
(ofscm_objfile_smob_from_objfile): Likewise.
* guile/scm-ports.c (ioscm_write): Likewise.
(ioscm_file_port_delete): Likewise.
(ioscm_file_port_rewind): Likewise.
(ioscm_file_port_put): Likewise.
(ioscm_file_port_write): Likewise.
* guile/scm-progspace.c (psscm_handle_pspace_deleted): Likewise.
(psscm_pspace_smob_from_pspace): Likewise.
* guile/scm-safe-call.c (scscm_recording_pre_unwind_handler): Likewise.
(scscm_recording_unwind_handler): Likewise.
(gdbscm_with_catch): Likewise.
(scscm_call_0_body): Likewise.
(scscm_call_1_body): Likewise.
(scscm_call_2_body): Likewise.
(scscm_call_3_body): Likewise.
(scscm_call_4_body): Likewise.
(scscm_apply_1_body): Likewise.
(scscm_eval_scheme_string): Likewise.
(gdbscm_safe_eval_string): Likewise.
(scscm_source_scheme_script): Likewise.
(gdbscm_safe_source_script): Likewise.
* guile/scm-string.c (gdbscm_call_scm_to_stringn): Likewise.
(gdbscm_call_scm_from_stringn): Likewise.
* guile/scm-symbol.c (syscm_hash_symbol_smob): Likewise.
(syscm_eq_symbol_smob): Likewise.
(syscm_get_symbol_map): Likewise.
(syscm_del_objfile_symbols): Likewise.
* guile/scm-symtab.c (stscm_hash_symtab_smob): Likewise.
(stscm_eq_symtab_smob): Likewise.
(stscm_objfile_symtab_map): Likewise.
(stscm_del_objfile_symtabs): Likewise.
* guile/scm-type.c (tyscm_hash_type_smob): Likewise.
(tyscm_eq_type_smob): Likewise.
(tyscm_type_map): Likewise.
(tyscm_copy_type_recursive): Likewise.
(save_objfile_types): Likewise.
* guile/scm-utils.c (extract_arg): Likewise.
* h8300-tdep.c (h8300_frame_cache): Likewise.
* hppa-linux-tdep.c (hppa_linux_sigtramp_frame_unwind_cache): Likewise.
* hppa-tdep.c (compare_unwind_entries): Likewise.
(find_unwind_entry): Likewise.
(hppa_frame_cache): Likewise.
(hppa_stub_frame_unwind_cache): Likewise.
* hppanbsd-tdep.c (hppanbsd_supply_gregset): Likewise.
* hppaobsd-tdep.c (hppaobsd_supply_gregset): Likewise.
(hppaobsd_supply_fpregset): Likewise.
* i386-cygwin-tdep.c (core_process_module_section): Likewise.
* i386-linux-tdep.c (i386_linux_init_abi): Likewise.
* i386-tdep.c (i386_frame_cache): Likewise.
(i386_epilogue_frame_cache): Likewise.
(i386_sigtramp_frame_cache): Likewise.
(i386_supply_gregset): Likewise.
(i386_collect_gregset): Likewise.
(i386_gdbarch_init): Likewise.
* i386obsd-tdep.c (i386obsd_aout_supply_regset): Likewise.
(i386obsd_trapframe_cache): Likewise.
* i387-tdep.c (i387_supply_fsave): Likewise.
(i387_collect_fsave): Likewise.
(i387_supply_fxsave): Likewise.
(i387_collect_fxsave): Likewise.
(i387_supply_xsave): Likewise.
(i387_collect_xsave): Likewise.
* ia64-tdep.c (ia64_frame_cache): Likewise.
(ia64_sigtramp_frame_cache): Likewise.
* infcmd.c (attach_command_continuation): Likewise.
(attach_command_continuation_free_args): Likewise.
* inferior.c (restore_inferior): Likewise.
(delete_thread_of_inferior): Likewise.
* inflow.c (inflow_inferior_data_cleanup): Likewise.
(get_inflow_inferior_data): Likewise.
(inflow_inferior_exit): Likewise.
* infrun.c (displaced_step_clear_cleanup): Likewise.
(restore_current_uiout_cleanup): Likewise.
(release_stop_context_cleanup): Likewise.
(do_restore_infcall_suspend_state_cleanup): Likewise.
(do_restore_infcall_control_state_cleanup): Likewise.
(restore_inferior_ptid): Likewise.
* inline-frame.c (block_starting_point_at): Likewise.
* iq2000-tdep.c (iq2000_frame_cache): Likewise.
* jit.c (get_jit_objfile_data): Likewise.
(get_jit_program_space_data): Likewise.
(jit_object_close_impl): Likewise.
(jit_find_objf_with_entry_addr): Likewise.
(jit_breakpoint_deleted): Likewise.
(jit_unwind_reg_set_impl): Likewise.
(jit_unwind_reg_get_impl): Likewise.
(jit_dealloc_cache): Likewise.
(jit_frame_sniffer): Likewise.
(jit_frame_prev_register): Likewise.
(jit_prepend_unwinder): Likewise.
(jit_inferior_exit_hook): Likewise.
(free_objfile_data): Likewise.
* jv-lang.c (jv_per_objfile_free): Likewise.
(get_dynamics_objfile): Likewise.
(get_java_class_symtab): Likewise.
(builtin_java_type): Likewise.
* language.c (language_string_char_type): Likewise.
(language_bool_type): Likewise.
(language_lookup_primitive_type): Likewise.
(language_lookup_primitive_type_as_symbol): Likewise.
* linespec.c (hash_address_entry): Likewise.
(eq_address_entry): Likewise.
(iterate_inline_only): Likewise.
(iterate_name_matcher): Likewise.
(decode_line_2_compare_items): Likewise.
(collect_one_symbol): Likewise.
(compare_symbols): Likewise.
(compare_msymbols): Likewise.
(add_symtabs_to_list): Likewise.
(collect_symbols): Likewise.
(compare_msyms): Likewise.
(add_minsym): Likewise.
(cleanup_linespec_result): Likewise.
* linux-fork.c (inferior_call_waitpid_cleanup): Likewise.
* linux-nat.c (delete_lwp_cleanup): Likewise.
(count_events_callback): Likewise.
(select_event_lwp_callback): Likewise.
(resume_stopped_resumed_lwps): Likewise.
* linux-tdep.c (get_linux_gdbarch_data): Likewise.
(invalidate_linux_cache_inf): Likewise.
(get_linux_inferior_data): Likewise.
(linux_find_memory_regions_thunk): Likewise.
(linux_make_mappings_callback): Likewise.
(linux_corefile_thread_callback): Likewise.
(find_mapping_size): Likewise.
* linux-thread-db.c (find_new_threads_callback): Likewise.
* lm32-tdep.c (lm32_frame_cache): Likewise.
* m2-lang.c (builtin_m2_type): Likewise.
* m32c-tdep.c (m32c_analyze_frame_prologue): Likewise.
* m32r-linux-tdep.c (m32r_linux_sigtramp_frame_cache): Likewise.
(m32r_linux_supply_gregset): Likewise.
(m32r_linux_collect_gregset): Likewise.
* m32r-tdep.c (m32r_frame_unwind_cache): Likewise.
* m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise.
* m68k-tdep.c (m68k_frame_cache): Likewise.
* m68kbsd-tdep.c (m68kbsd_supply_fpregset): Likewise.
(m68kbsd_supply_gregset): Likewise.
* m68klinux-tdep.c (m68k_linux_sigtramp_frame_cache): Likewise.
* m88k-tdep.c (m88k_frame_cache): Likewise.
(m88k_supply_gregset): Likewise.
gdb/gdbserver/ChangeLog:
* dll.c (match_dll): Add cast(s).
(unloaded_dll): Likewise.
* linux-low.c (second_thread_of_pid_p): Likewise.
(delete_lwp_callback): Likewise.
(count_events_callback): Likewise.
(select_event_lwp_callback): Likewise.
(linux_set_resume_request): Likewise.
* server.c (accumulate_file_name_length): Likewise.
(emit_dll_description): Likewise.
(handle_qxfer_threads_worker): Likewise.
(visit_actioned_threads): Likewise.
* thread-db.c (any_thread_of): Likewise.
* tracepoint.c (same_process_p): Likewise.
(match_blocktype): Likewise.
(build_traceframe_info_xml): Likewise.
gdb/testsuite/ChangeLog:
* gdb.gdb/selftest.exp (do_steps_and_nexts): Adjust expected
source line.
2015-09-25 20:08:07 +02:00
|
|
|
|
struct lwp_info *lp = (struct lwp_info *) lp_voidp;
|
2012-01-24 14:46:55 +01:00
|
|
|
|
|
|
|
|
|
delete_lwp (lp->ptid);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-30 20:01:57 +02:00
|
|
|
|
/* Target hook for follow_fork. On entry inferior_ptid must be the
|
|
|
|
|
ptid of the followed inferior. At return, inferior_ptid will be
|
|
|
|
|
unchanged. */
|
|
|
|
|
|
2007-05-07 02:18:39 +02:00
|
|
|
|
static int
|
2013-09-03 19:22:45 +02:00
|
|
|
|
linux_child_follow_fork (struct target_ops *ops, int follow_child,
|
|
|
|
|
int detach_fork)
|
2003-06-15 22:56:48 +02:00
|
|
|
|
{
|
2014-09-30 20:01:57 +02:00
|
|
|
|
if (!follow_child)
|
2003-08-17 20:22:25 +02:00
|
|
|
|
{
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
struct lwp_info *child_lp = NULL;
|
2014-09-30 20:01:57 +02:00
|
|
|
|
int status = W_STOPCODE (0);
|
|
|
|
|
int has_vforked;
|
2015-03-04 16:03:33 +01:00
|
|
|
|
ptid_t parent_ptid, child_ptid;
|
2014-09-30 20:01:57 +02:00
|
|
|
|
int parent_pid, child_pid;
|
|
|
|
|
|
|
|
|
|
has_vforked = (inferior_thread ()->pending_follow.kind
|
|
|
|
|
== TARGET_WAITKIND_VFORKED);
|
2015-03-04 16:03:33 +01:00
|
|
|
|
parent_ptid = inferior_ptid;
|
|
|
|
|
child_ptid = inferior_thread ()->pending_follow.value.related_pid;
|
|
|
|
|
parent_pid = ptid_get_lwp (parent_ptid);
|
|
|
|
|
child_pid = ptid_get_lwp (child_ptid);
|
2003-08-17 20:22:25 +02:00
|
|
|
|
|
2011-01-09 04:08:57 +01:00
|
|
|
|
/* We're already attached to the parent, by default. */
|
Remove save_inferior_ptid
This removes save_inferior_ptid, a cleanup function, in favor of
scoped_restore.
This also fixes a possible (it seems unlikely that it could happen in
practice) memory leak -- save_inferior_ptid should have used
make_cleanup_dtor, because it allocated memory.
I tested this on the buildbot. However, there are two caveats to
this. First, sometimes it seems I misread the results. Second, I
think this patch touches some platforms that can't be tested by the
buildbot. So, extra care seems warranted.
ChangeLog
2017-08-18 Tom Tromey <tom@tromey.com>
Pedro Alves <palves@redhat.com>
* spu-multiarch.c (parse_spufs_run): Use scoped_restore.
* sol-thread.c (sol_thread_resume, sol_thread_wait)
(sol_thread_xfer_partial, rw_common): Use scoped_restore.
* procfs.c (procfs_do_thread_registers): Use scoped_restore.
* proc-service.c (ps_xfer_memory): Use scoped_restore.
* linux-tdep.c (linux_corefile_thread): Remove a cleanup.
(linux_get_siginfo_data): Add "thread" argument. Use
scoped_restore.
* linux-nat.c (linux_child_follow_fork)
(check_stopped_by_watchpoint): Use scoped_restore.
* infrun.c (displaced_step_prepare_throw, write_memory_ptid)
(THREAD_STOPPED_BY, handle_signal_stop): Use scoped_restore.
(restore_inferior_ptid, save_inferior_ptid): Remove.
* btrace.c (btrace_fetch): Use scoped_restore.
* bsd-uthread.c (bsd_uthread_fetch_registers)
(bsd_uthread_store_registers): Use scoped_restore.
* breakpoint.c (reattach_breakpoints, detach_breakpoints): Use
scoped_restore.
* aix-thread.c (aix_thread_resume, aix_thread_wait)
(aix_thread_xfer_partial): Use scoped_restore.
* inferior.h (save_inferior_ptid): Remove.
2017-08-16 07:36:09 +02:00
|
|
|
|
child_lp = add_lwp (child_ptid);
|
2014-09-30 20:01:57 +02:00
|
|
|
|
child_lp->stopped = 1;
|
|
|
|
|
child_lp->last_resume_kind = resume_stop;
|
2003-08-17 20:22:25 +02:00
|
|
|
|
|
2006-01-04 20:34:58 +01:00
|
|
|
|
/* Detach new forked process? */
|
|
|
|
|
if (detach_fork)
|
2005-03-06 17:42:20 +01:00
|
|
|
|
{
|
Remove save_inferior_ptid
This removes save_inferior_ptid, a cleanup function, in favor of
scoped_restore.
This also fixes a possible (it seems unlikely that it could happen in
practice) memory leak -- save_inferior_ptid should have used
make_cleanup_dtor, because it allocated memory.
I tested this on the buildbot. However, there are two caveats to
this. First, sometimes it seems I misread the results. Second, I
think this patch touches some platforms that can't be tested by the
buildbot. So, extra care seems warranted.
ChangeLog
2017-08-18 Tom Tromey <tom@tromey.com>
Pedro Alves <palves@redhat.com>
* spu-multiarch.c (parse_spufs_run): Use scoped_restore.
* sol-thread.c (sol_thread_resume, sol_thread_wait)
(sol_thread_xfer_partial, rw_common): Use scoped_restore.
* procfs.c (procfs_do_thread_registers): Use scoped_restore.
* proc-service.c (ps_xfer_memory): Use scoped_restore.
* linux-tdep.c (linux_corefile_thread): Remove a cleanup.
(linux_get_siginfo_data): Add "thread" argument. Use
scoped_restore.
* linux-nat.c (linux_child_follow_fork)
(check_stopped_by_watchpoint): Use scoped_restore.
* infrun.c (displaced_step_prepare_throw, write_memory_ptid)
(THREAD_STOPPED_BY, handle_signal_stop): Use scoped_restore.
(restore_inferior_ptid, save_inferior_ptid): Remove.
* btrace.c (btrace_fetch): Use scoped_restore.
* bsd-uthread.c (bsd_uthread_fetch_registers)
(bsd_uthread_store_registers): Use scoped_restore.
* breakpoint.c (reattach_breakpoints, detach_breakpoints): Use
scoped_restore.
* aix-thread.c (aix_thread_resume, aix_thread_wait)
(aix_thread_xfer_partial): Use scoped_restore.
* inferior.h (save_inferior_ptid): Remove.
2017-08-16 07:36:09 +02:00
|
|
|
|
struct cleanup *old_chain = make_cleanup (delete_lwp_cleanup,
|
|
|
|
|
child_lp);
|
2012-01-24 14:46:55 +01:00
|
|
|
|
|
|
|
|
|
if (linux_nat_prepare_to_resume != NULL)
|
|
|
|
|
linux_nat_prepare_to_resume (child_lp);
|
2014-06-08 13:11:09 +02:00
|
|
|
|
|
|
|
|
|
/* When debugging an inferior in an architecture that supports
|
|
|
|
|
hardware single stepping on a kernel without commit
|
|
|
|
|
6580807da14c423f0d0a708108e6df6ebc8bc83d, the vfork child
|
|
|
|
|
process starts with the TIF_SINGLESTEP/X86_EFLAGS_TF bits
|
|
|
|
|
set if the parent process had them set.
|
|
|
|
|
To work around this, single step the child process
|
|
|
|
|
once before detaching to clear the flags. */
|
|
|
|
|
|
2017-10-05 19:33:22 +02:00
|
|
|
|
/* Note that we consult the parent's architecture instead of
|
|
|
|
|
the child's because there's no inferior for the child at
|
|
|
|
|
this point. */
|
2014-06-08 13:11:09 +02:00
|
|
|
|
if (!gdbarch_software_single_step_p (target_thread_architecture
|
2017-10-05 19:33:22 +02:00
|
|
|
|
(parent_ptid)))
|
2014-06-08 13:11:09 +02:00
|
|
|
|
{
|
|
|
|
|
linux_disable_event_reporting (child_pid);
|
|
|
|
|
if (ptrace (PTRACE_SINGLESTEP, child_pid, 0, 0) < 0)
|
|
|
|
|
perror_with_name (_("Couldn't do single step"));
|
|
|
|
|
if (my_waitpid (child_pid, &status, 0) < 0)
|
|
|
|
|
perror_with_name (_("Couldn't wait vfork process"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (WIFSTOPPED (status))
|
Fix a bunch of fork related regressions.
I'm seeing a ton of new FAILs in fork-related tests. Like, these and
many more:
+FAIL: gdb.base/disp-step-syscall.exp: vfork: continue to vfork (2nd time) (timeout)
+FAIL: gdb.base/disp-step-syscall.exp: vfork: display/i $pc (timeout)
...
-PASS: gdb.base/foll-vfork.exp: exec: vfork parent follow, through step: step
+FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, through step: step (timeout)
-PASS: gdb.base/foll-vfork.exp: exec: vfork parent follow, to bp: continue to bp
+FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, to bp: continue to bp (timeout)
...
FAIL: gdb.threads/watchpoint-fork.exp: parent: multithreaded: breakpoint (A) after the first fork (timeout)
FAIL: gdb.threads/watchpoint-fork.exp: parent: multithreaded: watchpoint A after the first fork (timeout)
FAIL: gdb.base/fileio.exp: System(3) call (timeout)
FAIL: gdb.threads/watchpoint-fork.exp: parent: multithreaded: watchpoint B after the first fork (timeout)
-PASS: gdb.base/multi-forks.exp: run to exit 2
+FAIL: gdb.base/multi-forks.exp: run to exit 2 (timeout)
...
PASS: gdb.base/watch-vfork.exp: Watchpoint on global variable (hw)
-PASS: gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (hw)
+FAIL: gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (hw) (timeout)
PASS: gdb.base/watch-vfork.exp: Watchpoint on global variable (sw)
-PASS: gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (sw)
+FAIL: gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (sw) (timeout)
Three issues with
https://sourceware.org/ml/gdb-patches/2014-06/msg00348.html
(c077881a).
- The inner 'status' local is shadowing the outer 'status' local,
thus PTRACE_DETACH is never seeing the status it intends to pass on
the inferior.
- With that fixed, we then try to pass down the SIGTRAP that results
from the step to the inferior. Need to filter out signals that are
in nopass state.
- For software single-step archs, the current code is equivalent to:
int status = 0;
if (WIFSTOPPED (status))
ptrace (PTRACE_DETACH, child_pid, 0, WSTOPSIG (status));
... and status == 0 is WIFEXITED, not WIFSTOPPED, so we're never
detaching.
gdb/
2014-06-09 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_child_follow_fork): Initialize status with
W_STOPCODE (0) instead of 0. Remove shodowing 'status' local from
inner block. Only pass the signal to PTRACE_DETACH if in pass
state.
2014-06-09 15:53:51 +02:00
|
|
|
|
{
|
|
|
|
|
int signo;
|
|
|
|
|
|
|
|
|
|
signo = WSTOPSIG (status);
|
|
|
|
|
if (signo != 0
|
|
|
|
|
&& !signal_pass_state (gdb_signal_from_host (signo)))
|
|
|
|
|
signo = 0;
|
|
|
|
|
ptrace (PTRACE_DETACH, child_pid, 0, signo);
|
|
|
|
|
}
|
2012-01-24 14:46:55 +01:00
|
|
|
|
|
|
|
|
|
do_cleanups (old_chain);
|
2006-01-04 20:34:58 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
Remove save_inferior_ptid
This removes save_inferior_ptid, a cleanup function, in favor of
scoped_restore.
This also fixes a possible (it seems unlikely that it could happen in
practice) memory leak -- save_inferior_ptid should have used
make_cleanup_dtor, because it allocated memory.
I tested this on the buildbot. However, there are two caveats to
this. First, sometimes it seems I misread the results. Second, I
think this patch touches some platforms that can't be tested by the
buildbot. So, extra care seems warranted.
ChangeLog
2017-08-18 Tom Tromey <tom@tromey.com>
Pedro Alves <palves@redhat.com>
* spu-multiarch.c (parse_spufs_run): Use scoped_restore.
* sol-thread.c (sol_thread_resume, sol_thread_wait)
(sol_thread_xfer_partial, rw_common): Use scoped_restore.
* procfs.c (procfs_do_thread_registers): Use scoped_restore.
* proc-service.c (ps_xfer_memory): Use scoped_restore.
* linux-tdep.c (linux_corefile_thread): Remove a cleanup.
(linux_get_siginfo_data): Add "thread" argument. Use
scoped_restore.
* linux-nat.c (linux_child_follow_fork)
(check_stopped_by_watchpoint): Use scoped_restore.
* infrun.c (displaced_step_prepare_throw, write_memory_ptid)
(THREAD_STOPPED_BY, handle_signal_stop): Use scoped_restore.
(restore_inferior_ptid, save_inferior_ptid): Remove.
* btrace.c (btrace_fetch): Use scoped_restore.
* bsd-uthread.c (bsd_uthread_fetch_registers)
(bsd_uthread_store_registers): Use scoped_restore.
* breakpoint.c (reattach_breakpoints, detach_breakpoints): Use
scoped_restore.
* aix-thread.c (aix_thread_resume, aix_thread_wait)
(aix_thread_xfer_partial): Use scoped_restore.
* inferior.h (save_inferior_ptid): Remove.
2017-08-16 07:36:09 +02:00
|
|
|
|
scoped_restore save_inferior_ptid
|
|
|
|
|
= make_scoped_restore (&inferior_ptid);
|
|
|
|
|
inferior_ptid = child_ptid;
|
|
|
|
|
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
/* Let the thread_db layer learn about this new process. */
|
gdb/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* linux-nat.c (linux_child_follow_fork): If we're staying attached
to the child process, enable event reporting on it. Don't handle
checkpoints here. Instead, add the child fork to the lwp thread
and inferior lists without clobbering the previous inferior. Let
the thread_db layer learn about a new child process, even if
following the parent.
(linux_nat_switch_fork): Delete lwps of the current inferior only,
instead of clearing the whole list. Use thread_change_ptid to
give the core the illusion the new checkpoint is still the same
inferior. Clear the register cache.
(linux_handle_extended_wait): Handle checkpoints here.
(linux_multi_process): Turn on.
* linux-fork.c (struct fork_info) <pc>: Remove field.
(init_fork_list): Do not delete the checkpoint from the inferior
list (it is not there).
(fork_load_infrun_state): Don't switch inferior_ptid here. Pass
the new checkpoint's ptid to linux_nat_switch_fork.
(fork_save_infrun_state): Make static. Don't stop the pc field of
fork_info, it's gone.
(linux_fork_mourn_inferior): Don't delete the checkpoint from the
inferior list, it's not there.
(linux_fork_detach): Ditto.
(delete_fork_command): Replace mention of fork/checkpoint by
checkpoint only.
(detach_fork_command): Likewise. Don't delete the checkpoint from
the inferior list.
(info_forks_command): Adjust.
(restore_detach_fork): Delete.
(checkpointing_pid): New.
(linux_fork_checkpointing_p): New.
(save_detach_fork): Delete.
(checkpoint_command): Delete temp_detach_fork. Don't remove
breakpoints, that's a nop. Store the pid of the process we're
checkpointing, and use make_cleanup_restore_integer to restore it.
Don't reinsert breakpoints here.
(process_command, fork_command): Delete.
(restart_command): Update comments to only mention checkpoints,
not forks.
(_initialize_linux_fork): Delete "fork", "process", "info forks"
commands.
* linux-fork.h (fork_save_infrun_state, fork_list): Delete
declarations.
(linux_fork_checkpointing_p): Declare.
* cli/cli-cmds.c (killlist): New.
* cli/cli-cmds.h (killlist): Declare.
* gdbcmd.h (killlist): Declare.
* inferior.c: Include "gdbthread.h".
(detach_inferior_command, kill_inferior_command)
(inferior_command): New.
(info_inferiors_command): Allow specifying a specific inferior id.
(_initialize_inferiors): Register "inferior", "kill inferior" and
"detach inferior" commands.
* infcmd.c (_initialize_infcmd): Make "kill" a prefix command.
* gdbthread.h (any_thread_of_process): Declare.
* thread.c (any_thread_of_process): New.
* NEWS: Mention multi-inferior debugging. Mention 'info
inferiors', 'inferior', 'detach inferior' and 'kill inferior' as
new commands.
(Removed commands): New section, mentioning that 'info forks',
'fork', 'process', 'delete fork' and 'detach fork' are now gone.
gdb/testsuite/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.base/multi-forks.exp: Only run detach-on-fork tests on
linux. Adjust to use "inferior", "info inferiors", "detach
inferior" and "kill inferior" instead of "restart", "info fork",
"detach fork" and "delete fork".
* gdb.base/ending-run.exp: Spell out "info".
* gdb.base/help.exp: Adjust to use test_prefix_command_help for
the "kill" command.
gdb/doc/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (Debugging multiple inferiors): Document the
"inferior", "detach inferior" and "kill inferior" commands.
(Debugging Programs with Multiple Processes): Adjust to mention
generic "inferior" commands. Delete mention of "detach fork" and
"delete fork". Cross reference to "Debugging multiple inferiors"
section.
2009-07-02 23:57:28 +02:00
|
|
|
|
check_for_thread_db ();
|
2006-01-04 20:34:58 +01:00
|
|
|
|
}
|
2003-08-17 22:17:02 +02:00
|
|
|
|
|
|
|
|
|
if (has_vforked)
|
|
|
|
|
{
|
2011-08-26 21:55:00 +02:00
|
|
|
|
struct lwp_info *parent_lp;
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
|
2015-03-04 16:03:33 +01:00
|
|
|
|
parent_lp = find_lwp_pid (parent_ptid);
|
2013-08-23 01:46:30 +02:00
|
|
|
|
gdb_assert (linux_supports_tracefork () >= 0);
|
2011-08-26 21:55:00 +02:00
|
|
|
|
|
2013-08-23 01:46:30 +02:00
|
|
|
|
if (linux_supports_tracevforkdone ())
|
2003-08-17 22:17:02 +02:00
|
|
|
|
{
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LCFF: waiting for VFORK_DONE on %d\n",
|
|
|
|
|
parent_pid);
|
2011-08-26 21:55:00 +02:00
|
|
|
|
parent_lp->stopped = 1;
|
2003-08-17 22:17:02 +02:00
|
|
|
|
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
/* We'll handle the VFORK_DONE event like any other
|
|
|
|
|
event, in target_wait. */
|
2003-08-17 22:17:02 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We can't insert breakpoints until the child has
|
|
|
|
|
finished with the shared memory region. We need to
|
|
|
|
|
wait until that happens. Ideal would be to just
|
|
|
|
|
call:
|
|
|
|
|
- ptrace (PTRACE_SYSCALL, parent_pid, 0, 0);
|
|
|
|
|
- waitpid (parent_pid, &status, __WALL);
|
|
|
|
|
However, most architectures can't handle a syscall
|
|
|
|
|
being traced on the way out if it wasn't traced on
|
|
|
|
|
the way in.
|
|
|
|
|
|
|
|
|
|
We might also think to loop, continuing the child
|
|
|
|
|
until it exits or gets a SIGTRAP. One problem is
|
|
|
|
|
that the child might call ptrace with PTRACE_TRACEME.
|
|
|
|
|
|
|
|
|
|
There's no simple and reliable way to figure out when
|
|
|
|
|
the vforked child will be done with its copy of the
|
|
|
|
|
shared memory. We could step it out of the syscall,
|
|
|
|
|
two instructions, let it go, and then single-step the
|
|
|
|
|
parent once. When we have hardware single-step, this
|
|
|
|
|
would work; with software single-step it could still
|
|
|
|
|
be made to work but we'd have to be able to insert
|
|
|
|
|
single-step breakpoints in the child, and we'd have
|
|
|
|
|
to insert -just- the single-step breakpoint in the
|
|
|
|
|
parent. Very awkward.
|
|
|
|
|
|
|
|
|
|
In the end, the best we can do is to make sure it
|
|
|
|
|
runs for a little while. Hopefully it will be out of
|
|
|
|
|
range of any breakpoints we reinsert. Usually this
|
|
|
|
|
is only the single-step breakpoint at vfork's return
|
|
|
|
|
point. */
|
|
|
|
|
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
2011-01-05 23:22:53 +01:00
|
|
|
|
"LCFF: no VFORK_DONE "
|
|
|
|
|
"support, sleeping a bit\n");
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
|
2003-08-17 22:17:02 +02:00
|
|
|
|
usleep (10000);
|
|
|
|
|
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
/* Pretend we've seen a PTRACE_EVENT_VFORK_DONE event,
|
|
|
|
|
and leave it pending. The next linux_nat_resume call
|
|
|
|
|
will notice a pending event, and bypasses actually
|
|
|
|
|
resuming the inferior. */
|
2011-08-26 21:55:00 +02:00
|
|
|
|
parent_lp->status = 0;
|
|
|
|
|
parent_lp->waitstatus.kind = TARGET_WAITKIND_VFORK_DONE;
|
|
|
|
|
parent_lp->stopped = 1;
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
|
|
|
|
|
/* If we're in async mode, need to tell the event loop
|
|
|
|
|
there's something here to process. */
|
2015-02-03 16:07:53 +01:00
|
|
|
|
if (target_is_async_p ())
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
async_file_mark ();
|
|
|
|
|
}
|
2003-08-17 22:17:02 +02:00
|
|
|
|
}
|
2003-08-17 20:22:25 +02:00
|
|
|
|
}
|
2003-06-15 22:56:48 +02:00
|
|
|
|
else
|
2003-08-17 20:22:25 +02:00
|
|
|
|
{
|
2011-08-26 21:55:00 +02:00
|
|
|
|
struct lwp_info *child_lp;
|
2003-08-17 20:22:25 +02:00
|
|
|
|
|
2011-08-26 21:55:00 +02:00
|
|
|
|
child_lp = add_lwp (inferior_ptid);
|
|
|
|
|
child_lp->stopped = 1;
|
2011-09-09 21:27:50 +02:00
|
|
|
|
child_lp->last_resume_kind = resume_stop;
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
|
|
|
|
|
/* Let the thread_db layer learn about this new process. */
|
2008-01-02 14:36:38 +01:00
|
|
|
|
check_for_thread_db ();
|
2003-08-17 20:22:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-01-11 Thiago Jung Bauermann <bauerman@br.ibm.com>
Convert hardware watchpoints to use breakpoint_ops.
gdb/
* breakpoint.h (breakpoint_ops) <insert>: Rename to...
<insert_location>: ... this. Return int instead of void.
Accept pointer to struct bp_location instead of pointer to
struct breakpoint. Adapt all implementations.
(breakpoint_ops) <remove>: Rename to...
<remove_location>: ... this. Accept pointer to struct bp_location
instead of pointer to struct breakpoint. Adapt all implementations.
* breakpoint.c (insert_catchpoint): Delete function.
(insert_bp_location): Call the watchpoint or catchpoint's
breakpoint_ops.insert method.
(remove_breakpoint_1): Call the watchpoint or catchpoint's
breakpoint_ops.remove method.
(insert_watchpoint, remove_watchpoint): New functions.
(watchpoint_breakpoint_ops): New structure.
(watch_command_1): Initialize the OPS field.
* inf-child.c (inf_child_insert_fork_catchpoint)
(inf_child_remove_fork_catchpoint, inf_child_insert_vfork_catchpoint)
(inf_child_remove_vfork_catchpoint, inf_child_insert_exec_catchpoint)
(inf_child_remove_exec_catchpoint, inf_child_set_syscall_catchpoint):
Delete functions.
(inf_child_target): Remove initialization of to_insert_fork_catchpoint,
to_remove_fork_catchpoint, to_insert_vfork_catchpoint,
to_remove_vfork_catchpoint, to_insert_exec_catchpoint,
to_remove_exec_catchpoint and to_set_syscall_catchpoint.
* target.c (update_current_target): Change default implementation of
to_insert_fork_catchpoint, to_remove_fork_catchpoint,
to_insert_vfork_catchpoint, to_remove_vfork_catchpoint,
to_insert_exec_catchpoint, to_remove_exec_catchpoint and
to_set_syscall_catchpoint to return_one.
(debug_to_insert_fork_catchpoint, debug_to_insert_vfork_catchpoint)
(debug_to_insert_exec_catchpoint): Report return value.
* target.h (to_insert_fork_catchpoint, to_insert_vfork_catchpoint)
(to_insert_exec_catchpoint): Change declaration to return int instead
of void.
gdb/testsuite/
* gdb.base/foll-exec.exp: Adapt to new error string when the catchpoint
type is not supported.
* gdb.base/foll-fork.exp: Likewise.
* gdb.base/foll-vfork.exp: Likewise.
2011-01-11 20:16:23 +01:00
|
|
|
|
static int
|
2013-12-18 05:31:52 +01:00
|
|
|
|
linux_child_insert_fork_catchpoint (struct target_ops *self, int pid)
|
2003-08-17 20:22:25 +02:00
|
|
|
|
{
|
2013-08-23 01:46:30 +02:00
|
|
|
|
return !linux_supports_tracefork ();
|
2003-06-15 22:56:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-29 17:54:12 +02:00
|
|
|
|
static int
|
2013-12-18 05:32:05 +01:00
|
|
|
|
linux_child_remove_fork_catchpoint (struct target_ops *self, int pid)
|
2011-04-29 17:54:12 +02:00
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-11 Thiago Jung Bauermann <bauerman@br.ibm.com>
Convert hardware watchpoints to use breakpoint_ops.
gdb/
* breakpoint.h (breakpoint_ops) <insert>: Rename to...
<insert_location>: ... this. Return int instead of void.
Accept pointer to struct bp_location instead of pointer to
struct breakpoint. Adapt all implementations.
(breakpoint_ops) <remove>: Rename to...
<remove_location>: ... this. Accept pointer to struct bp_location
instead of pointer to struct breakpoint. Adapt all implementations.
* breakpoint.c (insert_catchpoint): Delete function.
(insert_bp_location): Call the watchpoint or catchpoint's
breakpoint_ops.insert method.
(remove_breakpoint_1): Call the watchpoint or catchpoint's
breakpoint_ops.remove method.
(insert_watchpoint, remove_watchpoint): New functions.
(watchpoint_breakpoint_ops): New structure.
(watch_command_1): Initialize the OPS field.
* inf-child.c (inf_child_insert_fork_catchpoint)
(inf_child_remove_fork_catchpoint, inf_child_insert_vfork_catchpoint)
(inf_child_remove_vfork_catchpoint, inf_child_insert_exec_catchpoint)
(inf_child_remove_exec_catchpoint, inf_child_set_syscall_catchpoint):
Delete functions.
(inf_child_target): Remove initialization of to_insert_fork_catchpoint,
to_remove_fork_catchpoint, to_insert_vfork_catchpoint,
to_remove_vfork_catchpoint, to_insert_exec_catchpoint,
to_remove_exec_catchpoint and to_set_syscall_catchpoint.
* target.c (update_current_target): Change default implementation of
to_insert_fork_catchpoint, to_remove_fork_catchpoint,
to_insert_vfork_catchpoint, to_remove_vfork_catchpoint,
to_insert_exec_catchpoint, to_remove_exec_catchpoint and
to_set_syscall_catchpoint to return_one.
(debug_to_insert_fork_catchpoint, debug_to_insert_vfork_catchpoint)
(debug_to_insert_exec_catchpoint): Report return value.
* target.h (to_insert_fork_catchpoint, to_insert_vfork_catchpoint)
(to_insert_exec_catchpoint): Change declaration to return int instead
of void.
gdb/testsuite/
* gdb.base/foll-exec.exp: Adapt to new error string when the catchpoint
type is not supported.
* gdb.base/foll-fork.exp: Likewise.
* gdb.base/foll-vfork.exp: Likewise.
2011-01-11 20:16:23 +01:00
|
|
|
|
static int
|
2013-12-18 05:32:17 +01:00
|
|
|
|
linux_child_insert_vfork_catchpoint (struct target_ops *self, int pid)
|
2003-06-15 22:56:48 +02:00
|
|
|
|
{
|
2013-08-23 01:46:30 +02:00
|
|
|
|
return !linux_supports_tracefork ();
|
2003-06-15 22:56:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-29 17:54:12 +02:00
|
|
|
|
static int
|
2013-12-18 05:32:29 +01:00
|
|
|
|
linux_child_remove_vfork_catchpoint (struct target_ops *self, int pid)
|
2011-04-29 17:54:12 +02:00
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-11 Thiago Jung Bauermann <bauerman@br.ibm.com>
Convert hardware watchpoints to use breakpoint_ops.
gdb/
* breakpoint.h (breakpoint_ops) <insert>: Rename to...
<insert_location>: ... this. Return int instead of void.
Accept pointer to struct bp_location instead of pointer to
struct breakpoint. Adapt all implementations.
(breakpoint_ops) <remove>: Rename to...
<remove_location>: ... this. Accept pointer to struct bp_location
instead of pointer to struct breakpoint. Adapt all implementations.
* breakpoint.c (insert_catchpoint): Delete function.
(insert_bp_location): Call the watchpoint or catchpoint's
breakpoint_ops.insert method.
(remove_breakpoint_1): Call the watchpoint or catchpoint's
breakpoint_ops.remove method.
(insert_watchpoint, remove_watchpoint): New functions.
(watchpoint_breakpoint_ops): New structure.
(watch_command_1): Initialize the OPS field.
* inf-child.c (inf_child_insert_fork_catchpoint)
(inf_child_remove_fork_catchpoint, inf_child_insert_vfork_catchpoint)
(inf_child_remove_vfork_catchpoint, inf_child_insert_exec_catchpoint)
(inf_child_remove_exec_catchpoint, inf_child_set_syscall_catchpoint):
Delete functions.
(inf_child_target): Remove initialization of to_insert_fork_catchpoint,
to_remove_fork_catchpoint, to_insert_vfork_catchpoint,
to_remove_vfork_catchpoint, to_insert_exec_catchpoint,
to_remove_exec_catchpoint and to_set_syscall_catchpoint.
* target.c (update_current_target): Change default implementation of
to_insert_fork_catchpoint, to_remove_fork_catchpoint,
to_insert_vfork_catchpoint, to_remove_vfork_catchpoint,
to_insert_exec_catchpoint, to_remove_exec_catchpoint and
to_set_syscall_catchpoint to return_one.
(debug_to_insert_fork_catchpoint, debug_to_insert_vfork_catchpoint)
(debug_to_insert_exec_catchpoint): Report return value.
* target.h (to_insert_fork_catchpoint, to_insert_vfork_catchpoint)
(to_insert_exec_catchpoint): Change declaration to return int instead
of void.
gdb/testsuite/
* gdb.base/foll-exec.exp: Adapt to new error string when the catchpoint
type is not supported.
* gdb.base/foll-fork.exp: Likewise.
* gdb.base/foll-vfork.exp: Likewise.
2011-01-11 20:16:23 +01:00
|
|
|
|
static int
|
2013-12-18 05:32:41 +01:00
|
|
|
|
linux_child_insert_exec_catchpoint (struct target_ops *self, int pid)
|
2003-06-15 22:56:48 +02:00
|
|
|
|
{
|
2013-08-23 01:46:30 +02:00
|
|
|
|
return !linux_supports_tracefork ();
|
2003-06-15 22:56:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-29 17:54:12 +02:00
|
|
|
|
static int
|
2013-12-18 05:32:54 +01:00
|
|
|
|
linux_child_remove_exec_catchpoint (struct target_ops *self, int pid)
|
2011-04-29 17:54:12 +02:00
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-15 05:30:08 +02:00
|
|
|
|
static int
|
2013-12-18 05:33:06 +01:00
|
|
|
|
linux_child_set_syscall_catchpoint (struct target_ops *self,
|
2017-12-06 23:45:09 +01:00
|
|
|
|
int pid, bool needed, int any_count,
|
|
|
|
|
gdb::array_view<const int> syscall_counts)
|
2009-09-15 05:30:08 +02:00
|
|
|
|
{
|
2013-08-23 01:46:30 +02:00
|
|
|
|
if (!linux_supports_tracesysgood ())
|
2010-01-11 Thiago Jung Bauermann <bauerman@br.ibm.com>
Convert hardware watchpoints to use breakpoint_ops.
gdb/
* breakpoint.h (breakpoint_ops) <insert>: Rename to...
<insert_location>: ... this. Return int instead of void.
Accept pointer to struct bp_location instead of pointer to
struct breakpoint. Adapt all implementations.
(breakpoint_ops) <remove>: Rename to...
<remove_location>: ... this. Accept pointer to struct bp_location
instead of pointer to struct breakpoint. Adapt all implementations.
* breakpoint.c (insert_catchpoint): Delete function.
(insert_bp_location): Call the watchpoint or catchpoint's
breakpoint_ops.insert method.
(remove_breakpoint_1): Call the watchpoint or catchpoint's
breakpoint_ops.remove method.
(insert_watchpoint, remove_watchpoint): New functions.
(watchpoint_breakpoint_ops): New structure.
(watch_command_1): Initialize the OPS field.
* inf-child.c (inf_child_insert_fork_catchpoint)
(inf_child_remove_fork_catchpoint, inf_child_insert_vfork_catchpoint)
(inf_child_remove_vfork_catchpoint, inf_child_insert_exec_catchpoint)
(inf_child_remove_exec_catchpoint, inf_child_set_syscall_catchpoint):
Delete functions.
(inf_child_target): Remove initialization of to_insert_fork_catchpoint,
to_remove_fork_catchpoint, to_insert_vfork_catchpoint,
to_remove_vfork_catchpoint, to_insert_exec_catchpoint,
to_remove_exec_catchpoint and to_set_syscall_catchpoint.
* target.c (update_current_target): Change default implementation of
to_insert_fork_catchpoint, to_remove_fork_catchpoint,
to_insert_vfork_catchpoint, to_remove_vfork_catchpoint,
to_insert_exec_catchpoint, to_remove_exec_catchpoint and
to_set_syscall_catchpoint to return_one.
(debug_to_insert_fork_catchpoint, debug_to_insert_vfork_catchpoint)
(debug_to_insert_exec_catchpoint): Report return value.
* target.h (to_insert_fork_catchpoint, to_insert_vfork_catchpoint)
(to_insert_exec_catchpoint): Change declaration to return int instead
of void.
gdb/testsuite/
* gdb.base/foll-exec.exp: Adapt to new error string when the catchpoint
type is not supported.
* gdb.base/foll-fork.exp: Likewise.
* gdb.base/foll-vfork.exp: Likewise.
2011-01-11 20:16:23 +01:00
|
|
|
|
return 1;
|
|
|
|
|
|
2009-09-15 05:30:08 +02:00
|
|
|
|
/* On GNU/Linux, we ignore the arguments. It means that we only
|
|
|
|
|
enable the syscall catchpoints, but do not disable them.
|
2010-01-11 Thiago Jung Bauermann <bauerman@br.ibm.com>
Convert hardware watchpoints to use breakpoint_ops.
gdb/
* breakpoint.h (breakpoint_ops) <insert>: Rename to...
<insert_location>: ... this. Return int instead of void.
Accept pointer to struct bp_location instead of pointer to
struct breakpoint. Adapt all implementations.
(breakpoint_ops) <remove>: Rename to...
<remove_location>: ... this. Accept pointer to struct bp_location
instead of pointer to struct breakpoint. Adapt all implementations.
* breakpoint.c (insert_catchpoint): Delete function.
(insert_bp_location): Call the watchpoint or catchpoint's
breakpoint_ops.insert method.
(remove_breakpoint_1): Call the watchpoint or catchpoint's
breakpoint_ops.remove method.
(insert_watchpoint, remove_watchpoint): New functions.
(watchpoint_breakpoint_ops): New structure.
(watch_command_1): Initialize the OPS field.
* inf-child.c (inf_child_insert_fork_catchpoint)
(inf_child_remove_fork_catchpoint, inf_child_insert_vfork_catchpoint)
(inf_child_remove_vfork_catchpoint, inf_child_insert_exec_catchpoint)
(inf_child_remove_exec_catchpoint, inf_child_set_syscall_catchpoint):
Delete functions.
(inf_child_target): Remove initialization of to_insert_fork_catchpoint,
to_remove_fork_catchpoint, to_insert_vfork_catchpoint,
to_remove_vfork_catchpoint, to_insert_exec_catchpoint,
to_remove_exec_catchpoint and to_set_syscall_catchpoint.
* target.c (update_current_target): Change default implementation of
to_insert_fork_catchpoint, to_remove_fork_catchpoint,
to_insert_vfork_catchpoint, to_remove_vfork_catchpoint,
to_insert_exec_catchpoint, to_remove_exec_catchpoint and
to_set_syscall_catchpoint to return_one.
(debug_to_insert_fork_catchpoint, debug_to_insert_vfork_catchpoint)
(debug_to_insert_exec_catchpoint): Report return value.
* target.h (to_insert_fork_catchpoint, to_insert_vfork_catchpoint)
(to_insert_exec_catchpoint): Change declaration to return int instead
of void.
gdb/testsuite/
* gdb.base/foll-exec.exp: Adapt to new error string when the catchpoint
type is not supported.
* gdb.base/foll-fork.exp: Likewise.
* gdb.base/foll-vfork.exp: Likewise.
2011-01-11 20:16:23 +01:00
|
|
|
|
|
2017-12-06 23:45:09 +01:00
|
|
|
|
Also, we do not use the `syscall_counts' information because we do not
|
2009-09-15 05:30:08 +02:00
|
|
|
|
filter system calls here. We let GDB do the logic for us. */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
/* List of known LWPs, keyed by LWP PID. This speeds up the common
|
|
|
|
|
case of mapping a PID returned from the kernel to our corresponding
|
|
|
|
|
lwp_info data structure. */
|
|
|
|
|
static htab_t lwp_lwpid_htab;
|
|
|
|
|
|
|
|
|
|
/* Calculate a hash from a lwp_info's LWP PID. */
|
|
|
|
|
|
|
|
|
|
static hashval_t
|
|
|
|
|
lwp_info_hash (const void *ap)
|
|
|
|
|
{
|
|
|
|
|
const struct lwp_info *lp = (struct lwp_info *) ap;
|
|
|
|
|
pid_t pid = ptid_get_lwp (lp->ptid);
|
|
|
|
|
|
|
|
|
|
return iterative_hash_object (pid, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Equality function for the lwp_info hash table. Compares the LWP's
|
|
|
|
|
PID. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
lwp_lwpid_htab_eq (const void *a, const void *b)
|
|
|
|
|
{
|
|
|
|
|
const struct lwp_info *entry = (const struct lwp_info *) a;
|
|
|
|
|
const struct lwp_info *element = (const struct lwp_info *) b;
|
|
|
|
|
|
|
|
|
|
return ptid_get_lwp (entry->ptid) == ptid_get_lwp (element->ptid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create the lwp_lwpid_htab hash table. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
lwp_lwpid_htab_create (void)
|
|
|
|
|
{
|
|
|
|
|
lwp_lwpid_htab = htab_create (100, lwp_info_hash, lwp_lwpid_htab_eq, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Add LP to the hash table. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
lwp_lwpid_htab_add_lwp (struct lwp_info *lp)
|
|
|
|
|
{
|
|
|
|
|
void **slot;
|
|
|
|
|
|
|
|
|
|
slot = htab_find_slot (lwp_lwpid_htab, lp, INSERT);
|
|
|
|
|
gdb_assert (slot != NULL && *slot == NULL);
|
|
|
|
|
*slot = lp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Head of doubly-linked list of known LWPs. Sorted by reverse
|
|
|
|
|
creation order. This order is assumed in some cases. E.g.,
|
|
|
|
|
reaping status after killing alls lwps of a process: the leader LWP
|
|
|
|
|
must be reaped last. */
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
struct lwp_info *lwp_list;
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
|
|
|
|
|
/* Add LP to sorted-by-reverse-creation-order doubly-linked list. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
lwp_list_add (struct lwp_info *lp)
|
|
|
|
|
{
|
|
|
|
|
lp->next = lwp_list;
|
|
|
|
|
if (lwp_list != NULL)
|
|
|
|
|
lwp_list->prev = lp;
|
|
|
|
|
lwp_list = lp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Remove LP from sorted-by-reverse-creation-order doubly-linked
|
|
|
|
|
list. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
lwp_list_remove (struct lwp_info *lp)
|
|
|
|
|
{
|
|
|
|
|
/* Remove from sorted-by-creation-order list. */
|
|
|
|
|
if (lp->next != NULL)
|
|
|
|
|
lp->next->prev = lp->prev;
|
|
|
|
|
if (lp->prev != NULL)
|
|
|
|
|
lp->prev->next = lp->next;
|
|
|
|
|
if (lp == lwp_list)
|
|
|
|
|
lwp_list = lp->next;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Original signal mask. */
|
|
|
|
|
static sigset_t normal_mask;
|
|
|
|
|
|
|
|
|
|
/* Signal mask for use with sigsuspend in linux_nat_wait, initialized in
|
|
|
|
|
_initialize_linux_nat. */
|
|
|
|
|
static sigset_t suspend_mask;
|
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
/* Signals to block to make that sigsuspend work. */
|
|
|
|
|
static sigset_t blocked_mask;
|
|
|
|
|
|
|
|
|
|
/* SIGCHLD action. */
|
|
|
|
|
struct sigaction sigchld_action;
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
/* Block child signals (SIGCHLD and linux threads signals), and store
|
|
|
|
|
the previous mask in PREV_MASK. */
|
2008-06-28 13:15:34 +02:00
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
static void
|
|
|
|
|
block_child_signals (sigset_t *prev_mask)
|
|
|
|
|
{
|
|
|
|
|
/* Make sure SIGCHLD is blocked. */
|
|
|
|
|
if (!sigismember (&blocked_mask, SIGCHLD))
|
|
|
|
|
sigaddset (&blocked_mask, SIGCHLD);
|
|
|
|
|
|
|
|
|
|
sigprocmask (SIG_BLOCK, &blocked_mask, prev_mask);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Restore child signals mask, previously returned by
|
|
|
|
|
block_child_signals. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
restore_child_signals_mask (sigset_t *prev_mask)
|
|
|
|
|
{
|
|
|
|
|
sigprocmask (SIG_SETMASK, prev_mask, NULL);
|
|
|
|
|
}
|
2011-04-27 15:29:15 +02:00
|
|
|
|
|
|
|
|
|
/* Mask of signals to pass directly to the inferior. */
|
|
|
|
|
static sigset_t pass_mask;
|
|
|
|
|
|
|
|
|
|
/* Update signals to pass to the inferior. */
|
|
|
|
|
static void
|
2013-12-18 05:33:44 +01:00
|
|
|
|
linux_nat_pass_signals (struct target_ops *self,
|
|
|
|
|
int numsigs, unsigned char *pass_signals)
|
2011-04-27 15:29:15 +02:00
|
|
|
|
{
|
|
|
|
|
int signo;
|
|
|
|
|
|
|
|
|
|
sigemptyset (&pass_mask);
|
|
|
|
|
|
|
|
|
|
for (signo = 1; signo < NSIG; signo++)
|
|
|
|
|
{
|
2012-05-24 18:39:15 +02:00
|
|
|
|
int target_signo = gdb_signal_from_host (signo);
|
2011-04-27 15:29:15 +02:00
|
|
|
|
if (target_signo < numsigs && pass_signals[target_signo])
|
|
|
|
|
sigaddset (&pass_mask, signo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Prototypes for local functions. */
|
|
|
|
|
static int stop_wait_callback (struct lwp_info *lp, void *data);
|
2013-12-18 05:35:01 +01:00
|
|
|
|
static char *linux_child_pid_to_exec_file (struct target_ops *self, int pid);
|
2015-02-04 19:13:28 +01:00
|
|
|
|
static int resume_stopped_resumed_lwps (struct lwp_info *lp, void *data);
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
static int check_ptrace_stopped_lwp_gone (struct lwp_info *lp);
|
2008-03-25 13:20:10 +01:00
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
|
gdb/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* linux-nat.c (linux_nat_new_thread): Change parameter to an lwp
pointer.
(linux_nat_prepare_to_resume): New global.
(lwp_free): New.
(purge_lwp_list): Use it.
(add_lwp): Call linux_nat_new_thread even on the first LWP.
Adjust to interface change.
(delete_lwp): Call lwp_free instead of xfree.
(detach_callback, linux_nat_detach, resume_lwp, linux_nat_resume)
(linux_handle_syscall_trap, linux_handle_extended_wait)
(linux_nat_filter_event, resume_stopped_resumed_lwps): Call
linux_nat_prepare_to_resume before resuming.
(linux_stop_lwp): New.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* linux-nat.h (struct arch_lwp_info): Forward declare.
(struct lwp_info) <arch_private>: New field.
(linux_stop_lwp): Declare.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* i386-nat.c (DR_NADDR, DR_STATUS, DR_CONTROL)
(struct i386_debug_reg_state): Move to i386-nat.h.
(dr_mirror): Comment.
(i386_debug_reg_state): New.
(i386_update_inferior_debug_regs): Simplify.
(i386_stopped_data_address): Use the debug register state from the
inferior, not from the local cache.
* i386-nat.h (struct i386_dr_low_type): Delete reset_addr and
unset_status fields. New get_addr and get_control fields.
(DR_FIRSTADDR, DR_LASTADDR, DR_CONTROL): Moved from i386-nat.c.
(DR_NADDR, DR_STATUS): New.
(struct i386_debug_reg_state): Moved from i386-nat.c.
* amd64-linux-nat.c (struct arch_lwp_info): New.
(amd64_linux_dr): Delete global.
(amd64_linux_dr_get_addr): New.
(amd64_linux_dr_get_control): New.
(amd64_linux_dr_unset_status): Delete.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_dr_reset_addr): Delete.
(update_debug_registers_callback): New.
(amd64_linux_dr_set_control): Reimplement.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_prepare_to_resume): New.
(amd64_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_amd64_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
amd64_linux_dr_get_control as i386_dr_low.get_control. Install
amd64_linux_dr_get_addr as i386_dr_low.get_addr. Install
amd64_linux_prepare_to_resume.
* i386-linux-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(struct arch_lwp_info): New.
(i386_linux_dr): Delete global.
(i386_linux_dr_set_control): Reimplement.
(i386_linux_dr_get_addr): New.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_dr_get_control): New.
(update_debug_registers_callback): New.
(i386_linux_dr_unset_status): Delete.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_prepare_to_resume): New.
(i386_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_i386_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386_linux_dr_get_control as i386_dr_low.get_control. Install
i386_linux_dr_get_addr as i386_dr_low.get_addr. Install
i386_linux_prepare_to_resume.
* arm-linux-nat.c (arm_linux_new_thread): Change parameter to an
lwp pointer. Adjust.
* ia64-linux-nat.c (ia64_linux_new_thread): Likewise.
* mips-linux-nat.c (mips_linux_new_thread): Likewise.
* ppc-linux-nat.c (ppc_linux_new_thread): Likewise.
* s390-nat.c (s390_fix_watch_points): Likewise.
* i386-darwin-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(i386_darwin_dr_reset_addr): Delete.
(i386_darwin_dr_get_addr): New.
(i386_darwin_dr_get_control): New.
* go32-nat.c
(go32_get_dr7, go32_get_dr): New.
(init_go32_ops): No longer install i386_dr_low.reset_addr.
Install go32_get_dr7 as i386_dr_low.get_control. Install
go32_get_dr as i386_dr_low.get_addr.
* i386bsd-nat.c (i386bsd_dr_get): New.
(i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_status): Use i386bsd_dr_get.
(i386bsd_dr_get_control): New.
* i386bsd-nat.h (i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_control): New.
* i386fbsd-nat.c (_initialize_i386fbsd_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386bsd_dr_get_control as i386_dr_low.get_control. Install
i386bsd_dr_get_addr as i386_dr_low.get_addr.
* windows-nat.c (init_windows_ops): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
cygwin_get_dr7 as i386_dr_low.get_control. Install cygwin_get_dr
as i386_dr_low.get_addr.
(cygwin_get_dr): New.
(cygwin_get_dr7): New.
gdb/testsuite/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* gdb.mi/watch-nonstop.c: New file.
* gdb.mi/mi-watch-nonstop.exp: New file.
2011-12-14 18:20:32 +01:00
|
|
|
|
/* Destroy and free LP. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
lwp_free (struct lwp_info *lp)
|
|
|
|
|
{
|
lwp_info: Make the arch code free arch_lwp_info
I have the goal of "poisoning" the XNEW/xfree-family of functions, so
that we catch their usages with non-POD types. A few things need to be
fixed in the mean time, this is one.
The common lwp code in linux-nat.c and gdbserver/linux-low.c xfrees the
private lwp data of type arch_lwp_info. However, that type is opaque
from its point of view, as its defined differently in each arch-specific
implementation. This trips on the std::is_pod<T> check, since the
compiler can't tell whether the type is POD or not if it doesn't know
about it.
My initial patch [1] made a class hierarchy with a virtual destructor.
However, as Pedro pointed out, we only have one native architecture at
the time built in gdb and gdbserver, so that's overkill. Instead, we
can move the responsibility of free'ing arch_lwp_info to the arch code
(which is also the one that allocated it in the first place). This is
what this patch does.
Also, I had the concern that if we wanted to use C++ features in these
structures, we would have a problem with the one-definition rule.
However, since a build will only have one version of arch_lwp_info,
that's not a problem.
There are changes in arch-specific files, I was only able to built-test
this patch with the following cross-compilers:
aarch64-linux-gnu
alpha-linux-gnu
arm-linux-gnueabihf
hppa-linux-gnu
m68k-linux-gnu
mips64el-linux-gnuabi64
powerpc64-linux-gnu
s390x-linux-gnu
sh4-linux-gnu
sparc64-linux-gnu
x86_64-linux-gnu
x86_64-w64-mingw32
A buildbot run didn't find any regression.
[1] https://sourceware.org/ml/gdb-patches/2017-08/msg00255.html
gdb/ChangeLog:
* linux-nat.h (linux_nat_set_delete_thread): New declaration.
* linux-nat.c (linux_nat_delete_thread): New variable.
(lwp_free): Invoke linux_nat_delete_thread if set.
(linux_nat_set_delete_thread): New function.
* aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Assign
thread delete callback.
* arm-linux-nat.c (arm_linux_delete_thread): New function.
(_initialize_arm_linux_nat): Assign thread delete callback.
* s390-linux-nat.c (s390_delete_thread): New function.
(_initialize_s390_nat): Assign thread delete callback.
* x86-linux-nat.c (x86_linux_add_target): Likewise.
* nat/aarch64-linux.c (aarch64_linux_delete_thread): New
function.
* nat/aarch64-linux.h (aarch64_linux_delete_thread): New
declaration.
* nat/x86-linux.c (x86_linux_delete_thread): New function.
* nat/x86-linux.h (x86_linux_delete_thread): New declaration.
gdb/gdbserver/ChangeLog:
* linux-aarch64-low.c (the_low_target): Add thread delete
callback.
* linux-arm-low.c (arm_delete_thread): New function.
(the_low_target): Add thread delete callback.
* linux-bfin-low.c (the_low_target): Likewise.
* linux-crisv32-low.c (the_low_target): Likewise.
* linux-low.c (delete_lwp): Invoke delete_thread callback if
set.
* linux-low.h (struct linux_target_ops) <delete_thread>: New
field.
* linux-m32r-low.c (the_low_target): Add thread delete callback.
* linux-mips-low.c (mips_linux_delete_thread): New function.
(the_low_target): Add thread delete callback.
* linux-ppc-low.c (the_low_target): Likewise.
* linux-s390-low.c (the_low_target): Likewise.
* linux-sh-low.c (the_low_target): Likewise.
* linux-tic6x-low.c (the_low_target): Likewise.
* linux-tile-low.c (the_low_target): Likewise.
* linux-x86-low.c (the_low_target): Likewise.
* linux-xtensa-low.c (the_low_target): Likewise.
2017-10-12 22:48:22 +02:00
|
|
|
|
/* Let the arch specific bits release arch_lwp_info. */
|
|
|
|
|
if (linux_nat_delete_thread != NULL)
|
|
|
|
|
linux_nat_delete_thread (lp->arch_private);
|
|
|
|
|
else
|
|
|
|
|
gdb_assert (lp->arch_private == NULL);
|
|
|
|
|
|
gdb/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* linux-nat.c (linux_nat_new_thread): Change parameter to an lwp
pointer.
(linux_nat_prepare_to_resume): New global.
(lwp_free): New.
(purge_lwp_list): Use it.
(add_lwp): Call linux_nat_new_thread even on the first LWP.
Adjust to interface change.
(delete_lwp): Call lwp_free instead of xfree.
(detach_callback, linux_nat_detach, resume_lwp, linux_nat_resume)
(linux_handle_syscall_trap, linux_handle_extended_wait)
(linux_nat_filter_event, resume_stopped_resumed_lwps): Call
linux_nat_prepare_to_resume before resuming.
(linux_stop_lwp): New.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* linux-nat.h (struct arch_lwp_info): Forward declare.
(struct lwp_info) <arch_private>: New field.
(linux_stop_lwp): Declare.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* i386-nat.c (DR_NADDR, DR_STATUS, DR_CONTROL)
(struct i386_debug_reg_state): Move to i386-nat.h.
(dr_mirror): Comment.
(i386_debug_reg_state): New.
(i386_update_inferior_debug_regs): Simplify.
(i386_stopped_data_address): Use the debug register state from the
inferior, not from the local cache.
* i386-nat.h (struct i386_dr_low_type): Delete reset_addr and
unset_status fields. New get_addr and get_control fields.
(DR_FIRSTADDR, DR_LASTADDR, DR_CONTROL): Moved from i386-nat.c.
(DR_NADDR, DR_STATUS): New.
(struct i386_debug_reg_state): Moved from i386-nat.c.
* amd64-linux-nat.c (struct arch_lwp_info): New.
(amd64_linux_dr): Delete global.
(amd64_linux_dr_get_addr): New.
(amd64_linux_dr_get_control): New.
(amd64_linux_dr_unset_status): Delete.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_dr_reset_addr): Delete.
(update_debug_registers_callback): New.
(amd64_linux_dr_set_control): Reimplement.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_prepare_to_resume): New.
(amd64_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_amd64_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
amd64_linux_dr_get_control as i386_dr_low.get_control. Install
amd64_linux_dr_get_addr as i386_dr_low.get_addr. Install
amd64_linux_prepare_to_resume.
* i386-linux-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(struct arch_lwp_info): New.
(i386_linux_dr): Delete global.
(i386_linux_dr_set_control): Reimplement.
(i386_linux_dr_get_addr): New.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_dr_get_control): New.
(update_debug_registers_callback): New.
(i386_linux_dr_unset_status): Delete.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_prepare_to_resume): New.
(i386_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_i386_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386_linux_dr_get_control as i386_dr_low.get_control. Install
i386_linux_dr_get_addr as i386_dr_low.get_addr. Install
i386_linux_prepare_to_resume.
* arm-linux-nat.c (arm_linux_new_thread): Change parameter to an
lwp pointer. Adjust.
* ia64-linux-nat.c (ia64_linux_new_thread): Likewise.
* mips-linux-nat.c (mips_linux_new_thread): Likewise.
* ppc-linux-nat.c (ppc_linux_new_thread): Likewise.
* s390-nat.c (s390_fix_watch_points): Likewise.
* i386-darwin-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(i386_darwin_dr_reset_addr): Delete.
(i386_darwin_dr_get_addr): New.
(i386_darwin_dr_get_control): New.
* go32-nat.c
(go32_get_dr7, go32_get_dr): New.
(init_go32_ops): No longer install i386_dr_low.reset_addr.
Install go32_get_dr7 as i386_dr_low.get_control. Install
go32_get_dr as i386_dr_low.get_addr.
* i386bsd-nat.c (i386bsd_dr_get): New.
(i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_status): Use i386bsd_dr_get.
(i386bsd_dr_get_control): New.
* i386bsd-nat.h (i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_control): New.
* i386fbsd-nat.c (_initialize_i386fbsd_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386bsd_dr_get_control as i386_dr_low.get_control. Install
i386bsd_dr_get_addr as i386_dr_low.get_addr.
* windows-nat.c (init_windows_ops): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
cygwin_get_dr7 as i386_dr_low.get_control. Install cygwin_get_dr
as i386_dr_low.get_addr.
(cygwin_get_dr): New.
(cygwin_get_dr7): New.
gdb/testsuite/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* gdb.mi/watch-nonstop.c: New file.
* gdb.mi/mi-watch-nonstop.exp: New file.
2011-12-14 18:20:32 +01:00
|
|
|
|
xfree (lp);
|
|
|
|
|
}
|
|
|
|
|
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
/* Traversal function for purge_lwp_list. */
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
static int
|
|
|
|
|
lwp_lwpid_htab_remove_pid (void **slot, void *info)
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
{
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
struct lwp_info *lp = (struct lwp_info *) *slot;
|
|
|
|
|
int pid = *(int *) info;
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
if (ptid_get_pid (lp->ptid) == pid)
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
{
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
htab_clear_slot (lwp_lwpid_htab, slot);
|
|
|
|
|
lwp_list_remove (lp);
|
|
|
|
|
lwp_free (lp);
|
|
|
|
|
}
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
/* Remove all LWPs belong to PID from the lwp list. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
purge_lwp_list (int pid)
|
|
|
|
|
{
|
|
|
|
|
htab_traverse_noresize (lwp_lwpid_htab, lwp_lwpid_htab_remove_pid, &pid);
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
[native x86 GNU/Linux] Access debug register mirror from the corresponding process.
While reviewing the native AArch64 patch, I noticed a problem:
On 02/06/2013 08:46 PM, Pedro Alves wrote:
>
>> > +static void
>> > +aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
>> > +{
>> > + struct arch_lwp_info *info = lwp->arch_private;
>> > +
>> > + /* NULL means this is the main thread still going through the shell,
>> > + or, no watchpoint has been set yet. In that case, there's
>> > + nothing to do. */
>> > + if (info == NULL)
>> > + return;
>> > +
>> > + if (DR_HAS_CHANGED (info->dr_changed_bp)
>> > + || DR_HAS_CHANGED (info->dr_changed_wp))
>> > + {
>> > + int tid = GET_LWP (lwp->ptid);
>> > + struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
> Hmm. This is always fetching the debug_reg_state of
> the current inferior, but may not be the inferior of lwp.
> I see the same bug on x86. Sorry about that. I'll fix it.
A natural fix would be to make xxx_get_debug_reg_state take an
inferior argument, but that doesn't work because of the case where we
detach breakpoints/watchpoints from the child fork, at a time there's
no inferior for the child fork at all. We do a nasty hack in
i386_inferior_data_get, but that relies on all callers pointing the
current inferior to the correct inferior, which isn't actually being
done by all callers, and I don't think we want to enforce that -- deep
in the bowls of linux-nat.c, there are many cases we resume lwps
behind the scenes, and it's be better to not have that code rely on
global state (as it doesn't today).
The fix is to decouple the watchpoints code from inferiors, making it
track target processes instead. This way, we can freely keep track of
the watchpoint mirrors for these processes behind the core's back.
Checkpoints also play dirty tricks with swapping the process behind
the inferior, so they get special treatment too in the patch (which
just amounts to calling a new hook). Instead of the old hack in
i386_inferior_data_get, where we returned a copy of the current
inferior's debug registers mirror, as soon as we detect a fork in the
target, we copy the debug register mirror from the parent to the child
process.
I don't have an old kernel handy to test, but I stepped through gdb doing
the watchpoint removal in the fork child in the watchpoint-fork test
seeing that the debug registers end up cleared in the child.
I didn't find the need for linux_nat_iterate_watchpoint_lwps. If
we use plain iterate_over_lwps instead, what happens is that
when removing watchpoints, that iterate_over_lwps doesn't actually
iterate over anything, since the fork child is not added to the
lwp list until later, at detach time, in linux_child_follow_fork.
And if we don't iterate over that lwp, we don't mark its debug
registers as needing update. But linux_child_follow_fork takes
care of doing that explicitly:
child_lp = add_lwp (inferior_ptid);
child_lp->stopped = 1;
child_lp->last_resume_kind = resume_stop;
make_cleanup (delete_lwp_cleanup, child_lp);
/* CHILD_LP has new PID, therefore linux_nat_new_thread is not called for it.
See i386_inferior_data_get for the Linux kernel specifics.
Ensure linux_nat_prepare_to_resume will reset the hardware debug
registers. It is done by the linux_nat_new_thread call, which is
being skipped in add_lwp above for the first lwp of a pid. */
gdb_assert (num_lwps (GET_PID (child_lp->ptid)) == 1);
if (linux_nat_new_thread != NULL)
linux_nat_new_thread (child_lp);
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (child_lp);
ptrace (PTRACE_DETACH, child_pid, 0, 0);
so unless I'm missing something (quite possible) it ends up all
the same. But, the !detach-on-fork, and the "follow-fork child" paths
should also call linux_nat_new_thread, and they don't presently. It
seems to me in those cases we're not clearing debug regs correctly
when that's needed. Instead of copying that bit that works around
add_lwp bypassing the linux_nat_new_thread call, I thought it'd
be better to add an add_initial_lwp call to be used in the case we
really need to bypass linux_nat_new_thread, and make
add_lwp always call linux_nat_new_thread.
i386_cleanup_dregs is rewritten to forget about the current process
debug mirrors, which takes cares of other i386 ports. Only a couple
of extra tweaks here and there were needed, as some targets wheren't
actually calling i386_cleanup_dregs.
Tested on Fedora 17 x86_64 -m64/-m32.
GDBserver already fetches the i386_debug_reg_state from the right
process, and, it doesn't handle forks at all, so no fix is needed over
there.
gdb/
2013-02-13 Pedro Alves <palves@redhat.com>
* amd64-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(amd64_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(amd64_linux_new_fork): New function.
(_initialize_amd64_linux_nat): Install amd64_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(i386_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(i386_linux_new_fork): New function.
(_initialize_i386_linux_nat): Install i386_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-nat.c (i386_init_dregs): Delete.
(i386_inferior_data, struct i386_inferior_data):
Delete.
(struct i386_process_info): New.
(i386_process_list): New global.
(i386_find_process_pid, i386_add_process, i386_process_info_get):
New functions.
(i386_inferior_data_get): Delete.
(i386_process_info_get): New function.
(i386_debug_reg_state): New parameter 'pid'. Reimplement.
(i386_forget_process): New function.
(i386_cleanup_dregs): Rewrite.
(i386_update_inferior_debug_regs, i386_insert_watchpoint)
(i386_remove_watchpoint, i386_region_ok_for_watchpoint)
(i386_stopped_data_address, i386_insert_hw_breakpoint)
(i386_remove_hw_breakpoint): Adjust to pass the current process id
to i386_debug_reg_state.
(i386_use_watchpoints): Don't register inferior data.
* i386-nat.h (i386_debug_reg_state): Add new 'pid' parameter, and
adjust comment.
(i386_forget_process): Declare.
* linux-fork.c (delete_fork): Call linux_nat_forget_process.
* linux-nat.c (linux_nat_new_fork, linux_nat_forget_process_hook):
New static globals.
(linux_child_follow_fork): Don't call linux_nat_new_thread here.
(add_initial_lwp): New, factored out from ...
(add_lwp): ... this. Don't check the number of lwps before
calling linux_nat_new_thread.
(linux_nat_iterate_watchpoint_lwps): Delete.
(linux_nat_attach): Use add_initial_lwp instead of add_lwp.
(linux_handle_extended_wait): Call the linux_nat_new_fork hook on
forks and vforks.
(linux_nat_wait_1): Use add_initial_lwp instead of add_lwp for the
initial lwp.
(linux_nat_kill, linux_nat_mourn_inferior): Call
linux_nat_forget_process.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New functions.
* linux-nat.h (linux_nat_iterate_watchpoint_lwps_ftype): Delete
type.
(linux_nat_iterate_watchpoint_lwps): Delete declaration.
(linux_nat_new_fork_ftype, linux_nat_forget_process_ftype): New
types.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New declarations.
* amd64fbsd-nat.c (super_mourn_inferior): New global.
(amd64fbsd_mourn_inferior): New function.
(_initialize_amd64fbsd_nat): Override to_mourn_inferior.
* windows-nat.c (windows_detach): Call i386_cleanup_dregs.
2013-02-13 15:59:49 +01:00
|
|
|
|
/* Add the LWP specified by PTID to the list. PTID is the first LWP
|
|
|
|
|
in the process. Return a pointer to the structure describing the
|
|
|
|
|
new LWP.
|
|
|
|
|
|
|
|
|
|
This differs from add_lwp in that we don't let the arch specific
|
|
|
|
|
bits know about this new thread. Current clients of this callback
|
|
|
|
|
take the opportunity to install watchpoints in the new thread, and
|
|
|
|
|
we shouldn't do that for the first thread. If we're spawning a
|
|
|
|
|
child ("run"), the thread executes the shell wrapper first, and we
|
|
|
|
|
shouldn't touch it until it execs the program we want to debug.
|
|
|
|
|
For "attach", it'd be okay to call the callback, but it's not
|
|
|
|
|
necessary, because watchpoints can't yet have been inserted into
|
|
|
|
|
the inferior. */
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
static struct lwp_info *
|
[native x86 GNU/Linux] Access debug register mirror from the corresponding process.
While reviewing the native AArch64 patch, I noticed a problem:
On 02/06/2013 08:46 PM, Pedro Alves wrote:
>
>> > +static void
>> > +aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
>> > +{
>> > + struct arch_lwp_info *info = lwp->arch_private;
>> > +
>> > + /* NULL means this is the main thread still going through the shell,
>> > + or, no watchpoint has been set yet. In that case, there's
>> > + nothing to do. */
>> > + if (info == NULL)
>> > + return;
>> > +
>> > + if (DR_HAS_CHANGED (info->dr_changed_bp)
>> > + || DR_HAS_CHANGED (info->dr_changed_wp))
>> > + {
>> > + int tid = GET_LWP (lwp->ptid);
>> > + struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
> Hmm. This is always fetching the debug_reg_state of
> the current inferior, but may not be the inferior of lwp.
> I see the same bug on x86. Sorry about that. I'll fix it.
A natural fix would be to make xxx_get_debug_reg_state take an
inferior argument, but that doesn't work because of the case where we
detach breakpoints/watchpoints from the child fork, at a time there's
no inferior for the child fork at all. We do a nasty hack in
i386_inferior_data_get, but that relies on all callers pointing the
current inferior to the correct inferior, which isn't actually being
done by all callers, and I don't think we want to enforce that -- deep
in the bowls of linux-nat.c, there are many cases we resume lwps
behind the scenes, and it's be better to not have that code rely on
global state (as it doesn't today).
The fix is to decouple the watchpoints code from inferiors, making it
track target processes instead. This way, we can freely keep track of
the watchpoint mirrors for these processes behind the core's back.
Checkpoints also play dirty tricks with swapping the process behind
the inferior, so they get special treatment too in the patch (which
just amounts to calling a new hook). Instead of the old hack in
i386_inferior_data_get, where we returned a copy of the current
inferior's debug registers mirror, as soon as we detect a fork in the
target, we copy the debug register mirror from the parent to the child
process.
I don't have an old kernel handy to test, but I stepped through gdb doing
the watchpoint removal in the fork child in the watchpoint-fork test
seeing that the debug registers end up cleared in the child.
I didn't find the need for linux_nat_iterate_watchpoint_lwps. If
we use plain iterate_over_lwps instead, what happens is that
when removing watchpoints, that iterate_over_lwps doesn't actually
iterate over anything, since the fork child is not added to the
lwp list until later, at detach time, in linux_child_follow_fork.
And if we don't iterate over that lwp, we don't mark its debug
registers as needing update. But linux_child_follow_fork takes
care of doing that explicitly:
child_lp = add_lwp (inferior_ptid);
child_lp->stopped = 1;
child_lp->last_resume_kind = resume_stop;
make_cleanup (delete_lwp_cleanup, child_lp);
/* CHILD_LP has new PID, therefore linux_nat_new_thread is not called for it.
See i386_inferior_data_get for the Linux kernel specifics.
Ensure linux_nat_prepare_to_resume will reset the hardware debug
registers. It is done by the linux_nat_new_thread call, which is
being skipped in add_lwp above for the first lwp of a pid. */
gdb_assert (num_lwps (GET_PID (child_lp->ptid)) == 1);
if (linux_nat_new_thread != NULL)
linux_nat_new_thread (child_lp);
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (child_lp);
ptrace (PTRACE_DETACH, child_pid, 0, 0);
so unless I'm missing something (quite possible) it ends up all
the same. But, the !detach-on-fork, and the "follow-fork child" paths
should also call linux_nat_new_thread, and they don't presently. It
seems to me in those cases we're not clearing debug regs correctly
when that's needed. Instead of copying that bit that works around
add_lwp bypassing the linux_nat_new_thread call, I thought it'd
be better to add an add_initial_lwp call to be used in the case we
really need to bypass linux_nat_new_thread, and make
add_lwp always call linux_nat_new_thread.
i386_cleanup_dregs is rewritten to forget about the current process
debug mirrors, which takes cares of other i386 ports. Only a couple
of extra tweaks here and there were needed, as some targets wheren't
actually calling i386_cleanup_dregs.
Tested on Fedora 17 x86_64 -m64/-m32.
GDBserver already fetches the i386_debug_reg_state from the right
process, and, it doesn't handle forks at all, so no fix is needed over
there.
gdb/
2013-02-13 Pedro Alves <palves@redhat.com>
* amd64-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(amd64_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(amd64_linux_new_fork): New function.
(_initialize_amd64_linux_nat): Install amd64_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(i386_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(i386_linux_new_fork): New function.
(_initialize_i386_linux_nat): Install i386_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-nat.c (i386_init_dregs): Delete.
(i386_inferior_data, struct i386_inferior_data):
Delete.
(struct i386_process_info): New.
(i386_process_list): New global.
(i386_find_process_pid, i386_add_process, i386_process_info_get):
New functions.
(i386_inferior_data_get): Delete.
(i386_process_info_get): New function.
(i386_debug_reg_state): New parameter 'pid'. Reimplement.
(i386_forget_process): New function.
(i386_cleanup_dregs): Rewrite.
(i386_update_inferior_debug_regs, i386_insert_watchpoint)
(i386_remove_watchpoint, i386_region_ok_for_watchpoint)
(i386_stopped_data_address, i386_insert_hw_breakpoint)
(i386_remove_hw_breakpoint): Adjust to pass the current process id
to i386_debug_reg_state.
(i386_use_watchpoints): Don't register inferior data.
* i386-nat.h (i386_debug_reg_state): Add new 'pid' parameter, and
adjust comment.
(i386_forget_process): Declare.
* linux-fork.c (delete_fork): Call linux_nat_forget_process.
* linux-nat.c (linux_nat_new_fork, linux_nat_forget_process_hook):
New static globals.
(linux_child_follow_fork): Don't call linux_nat_new_thread here.
(add_initial_lwp): New, factored out from ...
(add_lwp): ... this. Don't check the number of lwps before
calling linux_nat_new_thread.
(linux_nat_iterate_watchpoint_lwps): Delete.
(linux_nat_attach): Use add_initial_lwp instead of add_lwp.
(linux_handle_extended_wait): Call the linux_nat_new_fork hook on
forks and vforks.
(linux_nat_wait_1): Use add_initial_lwp instead of add_lwp for the
initial lwp.
(linux_nat_kill, linux_nat_mourn_inferior): Call
linux_nat_forget_process.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New functions.
* linux-nat.h (linux_nat_iterate_watchpoint_lwps_ftype): Delete
type.
(linux_nat_iterate_watchpoint_lwps): Delete declaration.
(linux_nat_new_fork_ftype, linux_nat_forget_process_ftype): New
types.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New declarations.
* amd64fbsd-nat.c (super_mourn_inferior): New global.
(amd64fbsd_mourn_inferior): New function.
(_initialize_amd64fbsd_nat): Override to_mourn_inferior.
* windows-nat.c (windows_detach): Call i386_cleanup_dregs.
2013-02-13 15:59:49 +01:00
|
|
|
|
add_initial_lwp (ptid_t ptid)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
|
|
|
|
struct lwp_info *lp;
|
|
|
|
|
|
2013-09-30 13:50:12 +02:00
|
|
|
|
gdb_assert (ptid_lwp_p (ptid));
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
Replace some xmalloc-family functions with XNEW-family ones
This patch is part of the make-gdb-buildable-in-C++ effort. The idea is
to change some calls to the xmalloc family of functions to calls to the
equivalents in the XNEW family. This avoids adding an explicit cast, so
it keeps the code a bit more readable. Some of them also map relatively
well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be
possible to do scripted replacements if needed.
I only changed calls that were obviously allocating memory for one or
multiple "objects". Allocation of variable sizes (such as strings or
buffer handling) will be for later (and won't use XNEW).
- xmalloc (sizeof (struct foo)) -> XNEW (struct foo)
- xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num)
- xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo)
- xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num)
- xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num)
- obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo)
- obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num)
- alloca (sizeof (struct foo)) -> XALLOCA (struct foo)
- alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num)
Some instances of xmalloc followed by memset to zero the buffer were
replaced by XCNEW or XCNEWVEC.
I regtested on x86-64, Ubuntu 14.04, but the patch touches many
architecture-specific files. For those I'll have to rely on the
buildbot or people complaining that I broke their gdb.
gdb/ChangeLog:
* aarch64-linux-nat.c (aarch64_add_process): Likewise.
* aarch64-tdep.c (aarch64_gdbarch_init): Likewise.
* ada-exp.y (write_ambiguous_var): Likewise.
* ada-lang.c (resolve_subexp): Likewise.
(user_select_syms): Likewise.
(assign_aggregate): Likewise.
(ada_evaluate_subexp): Likewise.
(cache_symbol): Likewise.
* addrmap.c (allocate_key): Likewise.
(addrmap_create_mutable): Likewise.
* aix-thread.c (sync_threadlists): Likewise.
* alpha-tdep.c (alpha_push_dummy_call): Likewise.
(alpha_gdbarch_init): Likewise.
* amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise.
* arm-linux-nat.c (arm_linux_add_process): Likewise.
* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
* arm-tdep.c (push_stack_item): Likewise.
(arm_displaced_step_copy_insn): Likewise.
(arm_gdbarch_init): Likewise.
(_initialize_arm_tdep): Likewise.
* avr-tdep.c (push_stack_item): Likewise.
* ax-general.c (new_agent_expr): Likewise.
* block.c (block_initialize_namespace): Likewise.
* breakpoint.c (alloc_counted_command_line): Likewise.
(update_dprintf_command_list): Likewise.
(parse_breakpoint_sals): Likewise.
(decode_static_tracepoint_spec): Likewise.
(until_break_command): Likewise.
(clear_command): Likewise.
(update_global_location_list): Likewise.
(get_breakpoint_objfile_data) Likewise.
* btrace.c (ftrace_new_function): Likewise.
(btrace_set_insn_history): Likewise.
(btrace_set_call_history): Likewise.
* buildsym.c (add_symbol_to_list): Likewise.
(record_pending_block): Likewise.
(start_subfile): Likewise.
(start_buildsym_compunit): Likewise.
(push_subfile): Likewise.
(end_symtab_get_static_block): Likewise.
(buildsym_init): Likewise.
* cli/cli-cmds.c (source_command): Likewise.
* cli/cli-decode.c (add_cmd): Likewise.
* cli/cli-script.c (build_command_line): Likewise.
(setup_user_args): Likewise.
(realloc_body_list): Likewise.
(process_next_line): Likewise.
(copy_command_lines): Likewise.
* cli/cli-setshow.c (do_set_command): Likewise.
* coff-pe-read.c (read_pe_exported_syms): Likewise.
* coffread.c (coff_locate_sections): Likewise.
(coff_symtab_read): Likewise.
(coff_read_struct_type): Likewise.
* common/cleanups.c (make_my_cleanup2): Likewise.
* common/common-exceptions.c (throw_it): Likewise.
* common/filestuff.c (make_cleanup_close): Likewise.
* common/format.c (parse_format_string): Likewise.
* common/queue.h (DEFINE_QUEUE_P): Likewise.
* compile/compile-object-load.c (munmap_list_add): Likewise.
(compile_object_load): Likewise.
* compile/compile-object-run.c (compile_object_run): Likewise.
* compile/compile.c (append_args): Likewise.
* corefile.c (specify_exec_file_hook): Likewise.
* cp-support.c (make_symbol_overload_list): Likewise.
* cris-tdep.c (push_stack_item): Likewise.
(cris_gdbarch_init): Likewise.
* ctf.c (ctf_trace_file_writer_new): Likewise.
* dbxread.c (init_header_files): Likewise.
(add_new_header_file): Likewise.
(init_bincl_list): Likewise.
(dbx_end_psymtab): Likewise.
(start_psymtab): Likewise.
(dbx_end_psymtab): Likewise.
* dcache.c (dcache_init): Likewise.
* dictionary.c (dict_create_hashed): Likewise.
(dict_create_hashed_expandable): Likewise.
(dict_create_linear): Likewise.
(dict_create_linear_expandable): Likewise.
* dtrace-probe.c (dtrace_process_dof_probe): Likewise.
* dummy-frame.c (register_dummy_frame_dtor): Likewise.
* dwarf2-frame-tailcall.c (cache_new_ref1): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
(decode_frame_entry_1): Likewise.
* dwarf2expr.c (new_dwarf_expr_context): Likewise.
* dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise.
* dwarf2read.c (dwarf2_has_info): Likewise.
(create_signatured_type_table_from_index): Likewise.
(dwarf2_read_index): Likewise.
(dw2_get_file_names_reader): Likewise.
(create_all_type_units): Likewise.
(read_cutu_die_from_dwo): Likewise.
(init_tu_and_read_dwo_dies): Likewise.
(init_cutu_and_read_dies): Likewise.
(create_all_comp_units): Likewise.
(queue_comp_unit): Likewise.
(inherit_abstract_dies): Likewise.
(read_call_site_scope): Likewise.
(dwarf2_add_field): Likewise.
(dwarf2_add_typedef): Likewise.
(dwarf2_add_member_fn): Likewise.
(attr_to_dynamic_prop): Likewise.
(abbrev_table_alloc_abbrev): Likewise.
(abbrev_table_read_table): Likewise.
(add_include_dir): Likewise.
(add_file_name): Likewise.
(dwarf_decode_line_header): Likewise.
(dwarf2_const_value_attr): Likewise.
(dwarf_alloc_block): Likewise.
(parse_macro_definition): Likewise.
(set_die_type): Likewise.
(write_psymtabs_to_index): Likewise.
(create_cus_from_index): Likewise.
(dwarf2_create_include_psymtab): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(build_type_psymtab_dependencies): Likewise.
(read_comp_units_from_section): Likewise.
(compute_compunit_symtab_includes): Likewise.
(create_dwo_unit_in_dwp_v1): Likewise.
(create_dwo_unit_in_dwp_v2): Likewise.
(read_func_scope): Likewise.
(process_structure_scope): Likewise.
(mark_common_block_symbol_computed): Likewise.
(load_partial_dies): Likewise.
(dwarf2_symbol_mark_computed): Likewise.
* elfread.c (elf_symfile_segments): Likewise.
(elf_read_minimal_symbols): Likewise.
* environ.c (make_environ): Likewise.
* eval.c (evaluate_subexp_standard): Likewise.
* event-loop.c (create_file_handler): Likewise.
(create_async_signal_handler): Likewise.
(create_async_event_handler): Likewise.
(create_timer): Likewise.
* exec.c (build_section_table): Likewise.
* fbsd-nat.c (fbsd_remember_child): Likewise.
* fork-child.c (fork_inferior): Likewise.
* frv-tdep.c (new_variant): Likewise.
* gdbarch.sh (gdbarch_alloc): Likewise.
(append_name): Likewise.
* gdbtypes.c (rank_function): Likewise.
(copy_type_recursive): Likewise.
(add_dyn_prop): Likewise.
* gnu-nat.c (make_proc): Likewise.
(make_inf): Likewise.
(gnu_write_inferior): Likewise.
* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
(build_std_type_info_type): Likewise.
* guile/scm-param.c (compute_enum_list): Likewise.
* guile/scm-utils.c (gdbscm_parse_function_args): Likewise.
* guile/scm-value.c (gdbscm_value_call): Likewise.
* h8300-tdep.c (h8300_gdbarch_init): Likewise.
* hppa-tdep.c (hppa_init_objfile_priv_data): Likewise.
(read_unwind_info): Likewise.
* ia64-tdep.c (ia64_gdbarch_init): Likewise.
* infcall.c (dummy_frame_context_saver_setup): Likewise.
(call_function_by_hand_dummy): Likewise.
* infcmd.c (step_once): Likewise.
(finish_forward): Likewise.
(attach_command): Likewise.
(notice_new_inferior): Likewise.
* inferior.c (add_inferior_silent): Likewise.
* infrun.c (add_displaced_stepping_state): Likewise.
(save_infcall_control_state): Likewise.
(save_inferior_ptid): Likewise.
(_initialize_infrun): Likewise.
* jit.c (bfd_open_from_target_memory): Likewise.
(jit_gdbarch_data_init): Likewise.
* language.c (add_language): Likewise.
* linespec.c (decode_line_2): Likewise.
* linux-nat.c (add_to_pid_list): Likewise.
(add_initial_lwp): Likewise.
* linux-thread-db.c (add_thread_db_info): Likewise.
(record_thread): Likewise.
(info_auto_load_libthread_db): Likewise.
* m32c-tdep.c (m32c_gdbarch_init): Likewise.
* m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise.
* m68k-tdep.c (m68k_gdbarch_init): Likewise.
* m88k-tdep.c (m88k_analyze_prologue): Likewise.
* macrocmd.c (macro_define_command): Likewise.
* macroexp.c (gather_arguments): Likewise.
* macroscope.c (sal_macro_scope): Likewise.
* macrotab.c (new_macro_table): Likewise.
* mdebugread.c (push_parse_stack): Likewise.
(parse_partial_symbols): Likewise.
(parse_symbol): Likewise.
(psymtab_to_symtab_1): Likewise.
(new_block): Likewise.
(new_psymtab): Likewise.
(mdebug_build_psymtabs): Likewise.
(add_pending): Likewise.
(elfmdebug_build_psymtabs): Likewise.
* mep-tdep.c (mep_gdbarch_init): Likewise.
* mi/mi-main.c (mi_execute_command): Likewise.
* mi/mi-parse.c (mi_parse_argv): Likewise.
* minidebug.c (lzma_open): Likewise.
* minsyms.c (terminate_minimal_symbol_table): Likewise.
* mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* mn10300-tdep.c (mn10300_gdbarch_init): Likewise.
* msp430-tdep.c (msp430_gdbarch_init): Likewise.
* mt-tdep.c (mt_registers_info): Likewise.
* nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise.
* nat/linux-btrace.c (linux_enable_bts): Likewise.
(linux_enable_pt): Likewise.
* nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise.
(linux_xfer_osdata_processgroups): Likewise.
* nios2-tdep.c (nios2_gdbarch_init): Likewise.
* nto-procfs.c (procfs_meminfo): Likewise.
* objc-lang.c (start_msglist): Likewise.
(selectors_info): Likewise.
(classes_info): Likewise.
(find_methods): Likewise.
* objfiles.c (allocate_objfile): Likewise.
(update_section_map): Likewise.
* osabi.c (gdbarch_register_osabi): Likewise.
(gdbarch_register_osabi_sniffer): Likewise.
* parse.c (start_arglist): Likewise.
* ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise.
(hwdebug_insert_point): Likewise.
* printcmd.c (display_command): Likewise.
(ui_printf): Likewise.
* procfs.c (create_procinfo): Likewise.
(load_syscalls): Likewise.
(proc_get_LDT_entry): Likewise.
(proc_update_threads): Likewise.
* prologue-value.c (make_pv_area): Likewise.
(pv_area_store): Likewise.
* psymtab.c (extend_psymbol_list): Likewise.
(init_psymbol_list): Likewise.
(allocate_psymtab): Likewise.
* python/py-inferior.c (add_thread_object): Likewise.
* python/py-param.c (compute_enum_values): Likewise.
* python/py-value.c (valpy_call): Likewise.
* python/py-varobj.c (py_varobj_iter_next): Likewise.
* python/python.c (ensure_python_env): Likewise.
* record-btrace.c (record_btrace_start_replaying): Likewise.
* record-full.c (record_full_reg_alloc): Likewise.
(record_full_mem_alloc): Likewise.
(record_full_end_alloc): Likewise.
(record_full_core_xfer_partial): Likewise.
* regcache.c (get_thread_arch_aspace_regcache): Likewise.
* remote-fileio.c (remote_fileio_init_fd_map): Likewise.
* remote-notif.c (remote_notif_state_allocate): Likewise.
* remote.c (demand_private_info): Likewise.
(remote_notif_stop_alloc_reply): Likewise.
(remote_enable_btrace): Likewise.
* reverse.c (save_bookmark_command): Likewise.
* rl78-tdep.c (rl78_gdbarch_init): Likewise.
* rx-tdep.c (rx_gdbarch_init): Likewise.
* s390-linux-nat.c (s390_insert_watchpoint): Likewise.
* ser-go32.c (dos_get_tty_state): Likewise.
(dos_copy_tty_state): Likewise.
* ser-mingw.c (ser_windows_open): Likewise.
(ser_console_wait_handle): Likewise.
(ser_console_get_tty_state): Likewise.
(make_pipe_state): Likewise.
(net_windows_open): Likewise.
* ser-unix.c (hardwire_get_tty_state): Likewise.
(hardwire_copy_tty_state): Likewise.
* solib-aix.c (solib_aix_new_lm_info): Likewise.
* solib-dsbt.c (dsbt_current_sos): Likewise.
(dsbt_relocate_main_executable): Likewise.
* solib-frv.c (frv_current_sos): Likewise.
(frv_relocate_main_executable): Likewise.
* solib-spu.c (spu_bfd_fopen): Likewise.
* solib-svr4.c (lm_info_read): Likewise.
(svr4_copy_library_list): Likewise.
(svr4_default_sos): Likewise.
* source.c (find_source_lines): Likewise.
(line_info): Likewise.
(add_substitute_path_rule): Likewise.
* spu-linux-nat.c (spu_bfd_open): Likewise.
* spu-tdep.c (info_spu_dma_cmdlist): Likewise.
* stabsread.c (dbx_lookup_type): Likewise.
(read_type): Likewise.
(read_member_functions): Likewise.
(read_struct_fields): Likewise.
(read_baseclasses): Likewise.
(read_args): Likewise.
(_initialize_stabsread): Likewise.
* stack.c (func_command): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (addrs_section_sort): Likewise.
(addr_info_make_relative): Likewise.
(load_section_callback): Likewise.
(add_symbol_file_command): Likewise.
(init_filename_language_table): Likewise.
* symtab.c (create_filename_seen_cache): Likewise.
(sort_search_symbols_remove_dups): Likewise.
(search_symbols): Likewise.
* target.c (make_cleanup_restore_target_terminal): Likewise.
* thread.c (new_thread): Likewise.
(enable_thread_stack_temporaries): Likewise.
(make_cleanup_restore_current_thread): Likewise.
(thread_apply_all_command): Likewise.
* tic6x-tdep.c (tic6x_gdbarch_init): Likewise.
* top.c (gdb_readline_wrapper): Likewise.
* tracefile-tfile.c (tfile_trace_file_writer_new): Likewise.
* tracepoint.c (trace_find_line_command): Likewise.
(all_tracepoint_actions_and_cleanup): Likewise.
(make_cleanup_restore_current_traceframe): Likewise.
(get_uploaded_tp): Likewise.
(get_uploaded_tsv): Likewise.
* tui/tui-data.c (tui_alloc_generic_win_info): Likewise.
(tui_alloc_win_info): Likewise.
(tui_alloc_content): Likewise.
(tui_add_content_elements): Likewise.
* tui/tui-disasm.c (tui_find_disassembly_address): Likewise.
(tui_set_disassem_content): Likewise.
* ui-file.c (ui_file_new): Likewise.
(stdio_file_new): Likewise.
(tee_file_new): Likewise.
* utils.c (make_cleanup_restore_integer): Likewise.
(add_internal_problem_command): Likewise.
* v850-tdep.c (v850_gdbarch_init): Likewise.
* valops.c (find_oload_champ): Likewise.
* value.c (allocate_value_lazy): Likewise.
(record_latest_value): Likewise.
(create_internalvar): Likewise.
* varobj.c (install_variable): Likewise.
(new_variable): Likewise.
(new_root_variable): Likewise.
(cppush): Likewise.
(_initialize_varobj): Likewise.
* windows-nat.c (windows_make_so): Likewise.
* x86-nat.c (x86_add_process): Likewise.
* xcoffread.c (arrange_linetable): Likewise.
(allocate_include_entry): Likewise.
(process_linenos): Likewise.
(SYMBOL_DUP): Likewise.
(xcoff_start_psymtab): Likewise.
(xcoff_end_psymtab): Likewise.
* xml-support.c (gdb_xml_parse_attr_ulongest): Likewise.
* xtensa-tdep.c (xtensa_register_type): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
gdb/gdbserver/ChangeLog:
* ax.c (gdb_parse_agent_expr): Likewise.
(compile_bytecodes): Likewise.
* dll.c (loaded_dll): Likewise.
* event-loop.c (append_callback_event): Likewise.
(create_file_handler): Likewise.
(create_file_event): Likewise.
* hostio.c (handle_open): Likewise.
* inferiors.c (add_thread): Likewise.
(add_process): Likewise.
* linux-aarch64-low.c (aarch64_linux_new_process): Likewise.
* linux-arm-low.c (arm_new_process): Likewise.
(arm_new_thread): Likewise.
* linux-low.c (add_to_pid_list): Likewise.
(linux_add_process): Likewise.
(handle_extended_wait): Likewise.
(add_lwp): Likewise.
(enqueue_one_deferred_signal): Likewise.
(enqueue_pending_signal): Likewise.
(linux_resume_one_lwp_throw): Likewise.
(linux_resume_one_thread): Likewise.
(linux_read_memory): Likewise.
(linux_write_memory): Likewise.
* linux-mips-low.c (mips_linux_new_process): Likewise.
(mips_linux_new_thread): Likewise.
(mips_add_watchpoint): Likewise.
* linux-x86-low.c (initialize_low_arch): Likewise.
* lynx-low.c (lynx_add_process): Likewise.
* mem-break.c (set_raw_breakpoint_at): Likewise.
(set_breakpoint): Likewise.
(add_condition_to_breakpoint): Likewise.
(add_commands_to_breakpoint): Likewise.
(clone_agent_expr): Likewise.
(clone_one_breakpoint): Likewise.
* regcache.c (new_register_cache): Likewise.
* remote-utils.c (look_up_one_symbol): Likewise.
* server.c (queue_stop_reply): Likewise.
(start_inferior): Likewise.
(queue_stop_reply_callback): Likewise.
(handle_target_event): Likewise.
* spu-low.c (fetch_ppc_memory): Likewise.
(store_ppc_memory): Likewise.
* target.c (set_target_ops): Likewise.
* thread-db.c (thread_db_load_search): Likewise.
(try_thread_db_load_1): Likewise.
* tracepoint.c (add_tracepoint): Likewise.
(add_tracepoint_action): Likewise.
(create_trace_state_variable): Likewise.
(cmd_qtdpsrc): Likewise.
(cmd_qtro): Likewise.
(add_while_stepping_state): Likewise.
* win32-low.c (child_add_thread): Likewise.
(get_image_name): Likewise.
2015-08-26 23:16:07 +02:00
|
|
|
|
lp = XNEW (struct lwp_info);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
memset (lp, 0, sizeof (struct lwp_info));
|
|
|
|
|
|
2011-09-09 21:27:50 +02:00
|
|
|
|
lp->last_resume_kind = resume_continue;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
lp->waitstatus.kind = TARGET_WAITKIND_IGNORE;
|
|
|
|
|
|
|
|
|
|
lp->ptid = ptid;
|
Implement core awareness.
* bcache.c (compare_ints): Remove
(print_percentage): Use compare_positive_ints.
* defs.h (compare_positive_ints): Declare.
* linux-nat.h (struct lin_lwp): New field core.
(linux_nat_core_of_thread_1): Declare.
* linux-nat.c (add_lwp): Init the 'core' field.
(linux_nat_wait_1): Record the core.
(linux_nat_core_of_thread_1, linux_nat_core_of_thread): New.
(linux_nat_add_target): Register the above.
* linux-thread-db.c (update_thread_core): New.
(thread_db_find_new_threads): Update core information for
every thread.
* remote.c (struct private_thread_info): New.
(free_private_thread_info, demand_private_info): New.
(PACKET_qXfer_threads, use_osdata_threads): New.
(struct thread_item, threads_parsing_context
(start_thread, end_thread, thread_attributes)
(thread_children, threads_children, threads_elements): New.
(remote_threads_info): Try qXfer:threads before anything
else.
(remote_protocol_packets): Register qXfer:threads.
(remote_open_1): Init use_osdata_threads.
(struct stop_reply): New field 'core'.
(remote_parse_stop_reply): Parse core number.
(process_stop_reply): Record core number.
(remote_xfer_partial): Handle qXfer:threads.
(remote_core_of_thread): New.
(init_remote_ops): Register remote_core_of_thread.
(_initialize_remote): Register qXfer:read.
* target.c (target_core_of_thread): New
* target.h (enum target_object): New value TARGET_OBJECT_THREADS.
(struct target_ops): New field to_core_of_threads.
(target_core_of_thread): Declare.
* gdbthread.h (struct thread_info): New field private_dtor.
* thread.c (print_thread_info): Report the core.
* ui-out.c (MAX_UI_OUT_LEVELS): Increase.
* utils.c (compare_positive_ints): New.
* features/threads.dtd: New.
* mi/mi-interp.c (mi_on_normal_stop): Report the core.
* mi/mi-main.c (struct collect_cores_data, collect_cores)
(do_nothing, free_vector_of_osdata_items)
(splay_tree_int_comparator, free_splay_tree): New.
(print_one_inferior_data): Implemented printing of selected
inferiors. Collect and print cores.
(output_cores): New.
(mi_cmd_list_thread_groups): Support --recurse. Permit specifying
thread groups together with --available.
2010-01-12 22:40:25 +01:00
|
|
|
|
lp->core = -1;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
/* Add to sorted-by-reverse-creation-order list. */
|
|
|
|
|
lwp_list_add (lp);
|
|
|
|
|
|
|
|
|
|
/* Add to keyed-by-pid htab. */
|
|
|
|
|
lwp_lwpid_htab_add_lwp (lp);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
[native x86 GNU/Linux] Access debug register mirror from the corresponding process.
While reviewing the native AArch64 patch, I noticed a problem:
On 02/06/2013 08:46 PM, Pedro Alves wrote:
>
>> > +static void
>> > +aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
>> > +{
>> > + struct arch_lwp_info *info = lwp->arch_private;
>> > +
>> > + /* NULL means this is the main thread still going through the shell,
>> > + or, no watchpoint has been set yet. In that case, there's
>> > + nothing to do. */
>> > + if (info == NULL)
>> > + return;
>> > +
>> > + if (DR_HAS_CHANGED (info->dr_changed_bp)
>> > + || DR_HAS_CHANGED (info->dr_changed_wp))
>> > + {
>> > + int tid = GET_LWP (lwp->ptid);
>> > + struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
> Hmm. This is always fetching the debug_reg_state of
> the current inferior, but may not be the inferior of lwp.
> I see the same bug on x86. Sorry about that. I'll fix it.
A natural fix would be to make xxx_get_debug_reg_state take an
inferior argument, but that doesn't work because of the case where we
detach breakpoints/watchpoints from the child fork, at a time there's
no inferior for the child fork at all. We do a nasty hack in
i386_inferior_data_get, but that relies on all callers pointing the
current inferior to the correct inferior, which isn't actually being
done by all callers, and I don't think we want to enforce that -- deep
in the bowls of linux-nat.c, there are many cases we resume lwps
behind the scenes, and it's be better to not have that code rely on
global state (as it doesn't today).
The fix is to decouple the watchpoints code from inferiors, making it
track target processes instead. This way, we can freely keep track of
the watchpoint mirrors for these processes behind the core's back.
Checkpoints also play dirty tricks with swapping the process behind
the inferior, so they get special treatment too in the patch (which
just amounts to calling a new hook). Instead of the old hack in
i386_inferior_data_get, where we returned a copy of the current
inferior's debug registers mirror, as soon as we detect a fork in the
target, we copy the debug register mirror from the parent to the child
process.
I don't have an old kernel handy to test, but I stepped through gdb doing
the watchpoint removal in the fork child in the watchpoint-fork test
seeing that the debug registers end up cleared in the child.
I didn't find the need for linux_nat_iterate_watchpoint_lwps. If
we use plain iterate_over_lwps instead, what happens is that
when removing watchpoints, that iterate_over_lwps doesn't actually
iterate over anything, since the fork child is not added to the
lwp list until later, at detach time, in linux_child_follow_fork.
And if we don't iterate over that lwp, we don't mark its debug
registers as needing update. But linux_child_follow_fork takes
care of doing that explicitly:
child_lp = add_lwp (inferior_ptid);
child_lp->stopped = 1;
child_lp->last_resume_kind = resume_stop;
make_cleanup (delete_lwp_cleanup, child_lp);
/* CHILD_LP has new PID, therefore linux_nat_new_thread is not called for it.
See i386_inferior_data_get for the Linux kernel specifics.
Ensure linux_nat_prepare_to_resume will reset the hardware debug
registers. It is done by the linux_nat_new_thread call, which is
being skipped in add_lwp above for the first lwp of a pid. */
gdb_assert (num_lwps (GET_PID (child_lp->ptid)) == 1);
if (linux_nat_new_thread != NULL)
linux_nat_new_thread (child_lp);
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (child_lp);
ptrace (PTRACE_DETACH, child_pid, 0, 0);
so unless I'm missing something (quite possible) it ends up all
the same. But, the !detach-on-fork, and the "follow-fork child" paths
should also call linux_nat_new_thread, and they don't presently. It
seems to me in those cases we're not clearing debug regs correctly
when that's needed. Instead of copying that bit that works around
add_lwp bypassing the linux_nat_new_thread call, I thought it'd
be better to add an add_initial_lwp call to be used in the case we
really need to bypass linux_nat_new_thread, and make
add_lwp always call linux_nat_new_thread.
i386_cleanup_dregs is rewritten to forget about the current process
debug mirrors, which takes cares of other i386 ports. Only a couple
of extra tweaks here and there were needed, as some targets wheren't
actually calling i386_cleanup_dregs.
Tested on Fedora 17 x86_64 -m64/-m32.
GDBserver already fetches the i386_debug_reg_state from the right
process, and, it doesn't handle forks at all, so no fix is needed over
there.
gdb/
2013-02-13 Pedro Alves <palves@redhat.com>
* amd64-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(amd64_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(amd64_linux_new_fork): New function.
(_initialize_amd64_linux_nat): Install amd64_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(i386_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(i386_linux_new_fork): New function.
(_initialize_i386_linux_nat): Install i386_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-nat.c (i386_init_dregs): Delete.
(i386_inferior_data, struct i386_inferior_data):
Delete.
(struct i386_process_info): New.
(i386_process_list): New global.
(i386_find_process_pid, i386_add_process, i386_process_info_get):
New functions.
(i386_inferior_data_get): Delete.
(i386_process_info_get): New function.
(i386_debug_reg_state): New parameter 'pid'. Reimplement.
(i386_forget_process): New function.
(i386_cleanup_dregs): Rewrite.
(i386_update_inferior_debug_regs, i386_insert_watchpoint)
(i386_remove_watchpoint, i386_region_ok_for_watchpoint)
(i386_stopped_data_address, i386_insert_hw_breakpoint)
(i386_remove_hw_breakpoint): Adjust to pass the current process id
to i386_debug_reg_state.
(i386_use_watchpoints): Don't register inferior data.
* i386-nat.h (i386_debug_reg_state): Add new 'pid' parameter, and
adjust comment.
(i386_forget_process): Declare.
* linux-fork.c (delete_fork): Call linux_nat_forget_process.
* linux-nat.c (linux_nat_new_fork, linux_nat_forget_process_hook):
New static globals.
(linux_child_follow_fork): Don't call linux_nat_new_thread here.
(add_initial_lwp): New, factored out from ...
(add_lwp): ... this. Don't check the number of lwps before
calling linux_nat_new_thread.
(linux_nat_iterate_watchpoint_lwps): Delete.
(linux_nat_attach): Use add_initial_lwp instead of add_lwp.
(linux_handle_extended_wait): Call the linux_nat_new_fork hook on
forks and vforks.
(linux_nat_wait_1): Use add_initial_lwp instead of add_lwp for the
initial lwp.
(linux_nat_kill, linux_nat_mourn_inferior): Call
linux_nat_forget_process.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New functions.
* linux-nat.h (linux_nat_iterate_watchpoint_lwps_ftype): Delete
type.
(linux_nat_iterate_watchpoint_lwps): Delete declaration.
(linux_nat_new_fork_ftype, linux_nat_forget_process_ftype): New
types.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New declarations.
* amd64fbsd-nat.c (super_mourn_inferior): New global.
(amd64fbsd_mourn_inferior): New function.
(_initialize_amd64fbsd_nat): Override to_mourn_inferior.
* windows-nat.c (windows_detach): Call i386_cleanup_dregs.
2013-02-13 15:59:49 +01:00
|
|
|
|
return lp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Add the LWP specified by PID to the list. Return a pointer to the
|
|
|
|
|
structure describing the new LWP. The LWP should already be
|
|
|
|
|
stopped. */
|
|
|
|
|
|
|
|
|
|
static struct lwp_info *
|
|
|
|
|
add_lwp (ptid_t ptid)
|
|
|
|
|
{
|
|
|
|
|
struct lwp_info *lp;
|
|
|
|
|
|
|
|
|
|
lp = add_initial_lwp (ptid);
|
|
|
|
|
|
2011-12-20 11:40:15 +01:00
|
|
|
|
/* Let the arch specific bits know about this new thread. Current
|
|
|
|
|
clients of this callback take the opportunity to install
|
[native x86 GNU/Linux] Access debug register mirror from the corresponding process.
While reviewing the native AArch64 patch, I noticed a problem:
On 02/06/2013 08:46 PM, Pedro Alves wrote:
>
>> > +static void
>> > +aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
>> > +{
>> > + struct arch_lwp_info *info = lwp->arch_private;
>> > +
>> > + /* NULL means this is the main thread still going through the shell,
>> > + or, no watchpoint has been set yet. In that case, there's
>> > + nothing to do. */
>> > + if (info == NULL)
>> > + return;
>> > +
>> > + if (DR_HAS_CHANGED (info->dr_changed_bp)
>> > + || DR_HAS_CHANGED (info->dr_changed_wp))
>> > + {
>> > + int tid = GET_LWP (lwp->ptid);
>> > + struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
> Hmm. This is always fetching the debug_reg_state of
> the current inferior, but may not be the inferior of lwp.
> I see the same bug on x86. Sorry about that. I'll fix it.
A natural fix would be to make xxx_get_debug_reg_state take an
inferior argument, but that doesn't work because of the case where we
detach breakpoints/watchpoints from the child fork, at a time there's
no inferior for the child fork at all. We do a nasty hack in
i386_inferior_data_get, but that relies on all callers pointing the
current inferior to the correct inferior, which isn't actually being
done by all callers, and I don't think we want to enforce that -- deep
in the bowls of linux-nat.c, there are many cases we resume lwps
behind the scenes, and it's be better to not have that code rely on
global state (as it doesn't today).
The fix is to decouple the watchpoints code from inferiors, making it
track target processes instead. This way, we can freely keep track of
the watchpoint mirrors for these processes behind the core's back.
Checkpoints also play dirty tricks with swapping the process behind
the inferior, so they get special treatment too in the patch (which
just amounts to calling a new hook). Instead of the old hack in
i386_inferior_data_get, where we returned a copy of the current
inferior's debug registers mirror, as soon as we detect a fork in the
target, we copy the debug register mirror from the parent to the child
process.
I don't have an old kernel handy to test, but I stepped through gdb doing
the watchpoint removal in the fork child in the watchpoint-fork test
seeing that the debug registers end up cleared in the child.
I didn't find the need for linux_nat_iterate_watchpoint_lwps. If
we use plain iterate_over_lwps instead, what happens is that
when removing watchpoints, that iterate_over_lwps doesn't actually
iterate over anything, since the fork child is not added to the
lwp list until later, at detach time, in linux_child_follow_fork.
And if we don't iterate over that lwp, we don't mark its debug
registers as needing update. But linux_child_follow_fork takes
care of doing that explicitly:
child_lp = add_lwp (inferior_ptid);
child_lp->stopped = 1;
child_lp->last_resume_kind = resume_stop;
make_cleanup (delete_lwp_cleanup, child_lp);
/* CHILD_LP has new PID, therefore linux_nat_new_thread is not called for it.
See i386_inferior_data_get for the Linux kernel specifics.
Ensure linux_nat_prepare_to_resume will reset the hardware debug
registers. It is done by the linux_nat_new_thread call, which is
being skipped in add_lwp above for the first lwp of a pid. */
gdb_assert (num_lwps (GET_PID (child_lp->ptid)) == 1);
if (linux_nat_new_thread != NULL)
linux_nat_new_thread (child_lp);
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (child_lp);
ptrace (PTRACE_DETACH, child_pid, 0, 0);
so unless I'm missing something (quite possible) it ends up all
the same. But, the !detach-on-fork, and the "follow-fork child" paths
should also call linux_nat_new_thread, and they don't presently. It
seems to me in those cases we're not clearing debug regs correctly
when that's needed. Instead of copying that bit that works around
add_lwp bypassing the linux_nat_new_thread call, I thought it'd
be better to add an add_initial_lwp call to be used in the case we
really need to bypass linux_nat_new_thread, and make
add_lwp always call linux_nat_new_thread.
i386_cleanup_dregs is rewritten to forget about the current process
debug mirrors, which takes cares of other i386 ports. Only a couple
of extra tweaks here and there were needed, as some targets wheren't
actually calling i386_cleanup_dregs.
Tested on Fedora 17 x86_64 -m64/-m32.
GDBserver already fetches the i386_debug_reg_state from the right
process, and, it doesn't handle forks at all, so no fix is needed over
there.
gdb/
2013-02-13 Pedro Alves <palves@redhat.com>
* amd64-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(amd64_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(amd64_linux_new_fork): New function.
(_initialize_amd64_linux_nat): Install amd64_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(i386_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(i386_linux_new_fork): New function.
(_initialize_i386_linux_nat): Install i386_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-nat.c (i386_init_dregs): Delete.
(i386_inferior_data, struct i386_inferior_data):
Delete.
(struct i386_process_info): New.
(i386_process_list): New global.
(i386_find_process_pid, i386_add_process, i386_process_info_get):
New functions.
(i386_inferior_data_get): Delete.
(i386_process_info_get): New function.
(i386_debug_reg_state): New parameter 'pid'. Reimplement.
(i386_forget_process): New function.
(i386_cleanup_dregs): Rewrite.
(i386_update_inferior_debug_regs, i386_insert_watchpoint)
(i386_remove_watchpoint, i386_region_ok_for_watchpoint)
(i386_stopped_data_address, i386_insert_hw_breakpoint)
(i386_remove_hw_breakpoint): Adjust to pass the current process id
to i386_debug_reg_state.
(i386_use_watchpoints): Don't register inferior data.
* i386-nat.h (i386_debug_reg_state): Add new 'pid' parameter, and
adjust comment.
(i386_forget_process): Declare.
* linux-fork.c (delete_fork): Call linux_nat_forget_process.
* linux-nat.c (linux_nat_new_fork, linux_nat_forget_process_hook):
New static globals.
(linux_child_follow_fork): Don't call linux_nat_new_thread here.
(add_initial_lwp): New, factored out from ...
(add_lwp): ... this. Don't check the number of lwps before
calling linux_nat_new_thread.
(linux_nat_iterate_watchpoint_lwps): Delete.
(linux_nat_attach): Use add_initial_lwp instead of add_lwp.
(linux_handle_extended_wait): Call the linux_nat_new_fork hook on
forks and vforks.
(linux_nat_wait_1): Use add_initial_lwp instead of add_lwp for the
initial lwp.
(linux_nat_kill, linux_nat_mourn_inferior): Call
linux_nat_forget_process.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New functions.
* linux-nat.h (linux_nat_iterate_watchpoint_lwps_ftype): Delete
type.
(linux_nat_iterate_watchpoint_lwps): Delete declaration.
(linux_nat_new_fork_ftype, linux_nat_forget_process_ftype): New
types.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New declarations.
* amd64fbsd-nat.c (super_mourn_inferior): New global.
(amd64fbsd_mourn_inferior): New function.
(_initialize_amd64fbsd_nat): Override to_mourn_inferior.
* windows-nat.c (windows_detach): Call i386_cleanup_dregs.
2013-02-13 15:59:49 +01:00
|
|
|
|
watchpoints in the new thread. We don't do this for the first
|
|
|
|
|
thread though. See add_initial_lwp. */
|
|
|
|
|
if (linux_nat_new_thread != NULL)
|
gdb/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* linux-nat.c (linux_nat_new_thread): Change parameter to an lwp
pointer.
(linux_nat_prepare_to_resume): New global.
(lwp_free): New.
(purge_lwp_list): Use it.
(add_lwp): Call linux_nat_new_thread even on the first LWP.
Adjust to interface change.
(delete_lwp): Call lwp_free instead of xfree.
(detach_callback, linux_nat_detach, resume_lwp, linux_nat_resume)
(linux_handle_syscall_trap, linux_handle_extended_wait)
(linux_nat_filter_event, resume_stopped_resumed_lwps): Call
linux_nat_prepare_to_resume before resuming.
(linux_stop_lwp): New.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* linux-nat.h (struct arch_lwp_info): Forward declare.
(struct lwp_info) <arch_private>: New field.
(linux_stop_lwp): Declare.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* i386-nat.c (DR_NADDR, DR_STATUS, DR_CONTROL)
(struct i386_debug_reg_state): Move to i386-nat.h.
(dr_mirror): Comment.
(i386_debug_reg_state): New.
(i386_update_inferior_debug_regs): Simplify.
(i386_stopped_data_address): Use the debug register state from the
inferior, not from the local cache.
* i386-nat.h (struct i386_dr_low_type): Delete reset_addr and
unset_status fields. New get_addr and get_control fields.
(DR_FIRSTADDR, DR_LASTADDR, DR_CONTROL): Moved from i386-nat.c.
(DR_NADDR, DR_STATUS): New.
(struct i386_debug_reg_state): Moved from i386-nat.c.
* amd64-linux-nat.c (struct arch_lwp_info): New.
(amd64_linux_dr): Delete global.
(amd64_linux_dr_get_addr): New.
(amd64_linux_dr_get_control): New.
(amd64_linux_dr_unset_status): Delete.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_dr_reset_addr): Delete.
(update_debug_registers_callback): New.
(amd64_linux_dr_set_control): Reimplement.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_prepare_to_resume): New.
(amd64_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_amd64_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
amd64_linux_dr_get_control as i386_dr_low.get_control. Install
amd64_linux_dr_get_addr as i386_dr_low.get_addr. Install
amd64_linux_prepare_to_resume.
* i386-linux-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(struct arch_lwp_info): New.
(i386_linux_dr): Delete global.
(i386_linux_dr_set_control): Reimplement.
(i386_linux_dr_get_addr): New.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_dr_get_control): New.
(update_debug_registers_callback): New.
(i386_linux_dr_unset_status): Delete.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_prepare_to_resume): New.
(i386_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_i386_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386_linux_dr_get_control as i386_dr_low.get_control. Install
i386_linux_dr_get_addr as i386_dr_low.get_addr. Install
i386_linux_prepare_to_resume.
* arm-linux-nat.c (arm_linux_new_thread): Change parameter to an
lwp pointer. Adjust.
* ia64-linux-nat.c (ia64_linux_new_thread): Likewise.
* mips-linux-nat.c (mips_linux_new_thread): Likewise.
* ppc-linux-nat.c (ppc_linux_new_thread): Likewise.
* s390-nat.c (s390_fix_watch_points): Likewise.
* i386-darwin-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(i386_darwin_dr_reset_addr): Delete.
(i386_darwin_dr_get_addr): New.
(i386_darwin_dr_get_control): New.
* go32-nat.c
(go32_get_dr7, go32_get_dr): New.
(init_go32_ops): No longer install i386_dr_low.reset_addr.
Install go32_get_dr7 as i386_dr_low.get_control. Install
go32_get_dr as i386_dr_low.get_addr.
* i386bsd-nat.c (i386bsd_dr_get): New.
(i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_status): Use i386bsd_dr_get.
(i386bsd_dr_get_control): New.
* i386bsd-nat.h (i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_control): New.
* i386fbsd-nat.c (_initialize_i386fbsd_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386bsd_dr_get_control as i386_dr_low.get_control. Install
i386bsd_dr_get_addr as i386_dr_low.get_addr.
* windows-nat.c (init_windows_ops): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
cygwin_get_dr7 as i386_dr_low.get_control. Install cygwin_get_dr
as i386_dr_low.get_addr.
(cygwin_get_dr): New.
(cygwin_get_dr7): New.
gdb/testsuite/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* gdb.mi/watch-nonstop.c: New file.
* gdb.mi/mi-watch-nonstop.exp: New file.
2011-12-14 18:20:32 +01:00
|
|
|
|
linux_nat_new_thread (lp);
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
return lp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Remove the LWP specified by PID from the list. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
delete_lwp (ptid_t ptid)
|
|
|
|
|
{
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
struct lwp_info *lp;
|
|
|
|
|
void **slot;
|
|
|
|
|
struct lwp_info dummy;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
dummy.ptid = ptid;
|
|
|
|
|
slot = htab_find_slot (lwp_lwpid_htab, &dummy, NO_INSERT);
|
|
|
|
|
if (slot == NULL)
|
|
|
|
|
return;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
lp = *(struct lwp_info **) slot;
|
|
|
|
|
gdb_assert (lp != NULL);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
htab_clear_slot (lwp_lwpid_htab, slot);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
/* Remove from sorted-by-creation-order list. */
|
|
|
|
|
lwp_list_remove (lp);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
/* Release. */
|
gdb/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* linux-nat.c (linux_nat_new_thread): Change parameter to an lwp
pointer.
(linux_nat_prepare_to_resume): New global.
(lwp_free): New.
(purge_lwp_list): Use it.
(add_lwp): Call linux_nat_new_thread even on the first LWP.
Adjust to interface change.
(delete_lwp): Call lwp_free instead of xfree.
(detach_callback, linux_nat_detach, resume_lwp, linux_nat_resume)
(linux_handle_syscall_trap, linux_handle_extended_wait)
(linux_nat_filter_event, resume_stopped_resumed_lwps): Call
linux_nat_prepare_to_resume before resuming.
(linux_stop_lwp): New.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* linux-nat.h (struct arch_lwp_info): Forward declare.
(struct lwp_info) <arch_private>: New field.
(linux_stop_lwp): Declare.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* i386-nat.c (DR_NADDR, DR_STATUS, DR_CONTROL)
(struct i386_debug_reg_state): Move to i386-nat.h.
(dr_mirror): Comment.
(i386_debug_reg_state): New.
(i386_update_inferior_debug_regs): Simplify.
(i386_stopped_data_address): Use the debug register state from the
inferior, not from the local cache.
* i386-nat.h (struct i386_dr_low_type): Delete reset_addr and
unset_status fields. New get_addr and get_control fields.
(DR_FIRSTADDR, DR_LASTADDR, DR_CONTROL): Moved from i386-nat.c.
(DR_NADDR, DR_STATUS): New.
(struct i386_debug_reg_state): Moved from i386-nat.c.
* amd64-linux-nat.c (struct arch_lwp_info): New.
(amd64_linux_dr): Delete global.
(amd64_linux_dr_get_addr): New.
(amd64_linux_dr_get_control): New.
(amd64_linux_dr_unset_status): Delete.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_dr_reset_addr): Delete.
(update_debug_registers_callback): New.
(amd64_linux_dr_set_control): Reimplement.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_prepare_to_resume): New.
(amd64_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_amd64_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
amd64_linux_dr_get_control as i386_dr_low.get_control. Install
amd64_linux_dr_get_addr as i386_dr_low.get_addr. Install
amd64_linux_prepare_to_resume.
* i386-linux-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(struct arch_lwp_info): New.
(i386_linux_dr): Delete global.
(i386_linux_dr_set_control): Reimplement.
(i386_linux_dr_get_addr): New.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_dr_get_control): New.
(update_debug_registers_callback): New.
(i386_linux_dr_unset_status): Delete.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_prepare_to_resume): New.
(i386_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_i386_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386_linux_dr_get_control as i386_dr_low.get_control. Install
i386_linux_dr_get_addr as i386_dr_low.get_addr. Install
i386_linux_prepare_to_resume.
* arm-linux-nat.c (arm_linux_new_thread): Change parameter to an
lwp pointer. Adjust.
* ia64-linux-nat.c (ia64_linux_new_thread): Likewise.
* mips-linux-nat.c (mips_linux_new_thread): Likewise.
* ppc-linux-nat.c (ppc_linux_new_thread): Likewise.
* s390-nat.c (s390_fix_watch_points): Likewise.
* i386-darwin-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(i386_darwin_dr_reset_addr): Delete.
(i386_darwin_dr_get_addr): New.
(i386_darwin_dr_get_control): New.
* go32-nat.c
(go32_get_dr7, go32_get_dr): New.
(init_go32_ops): No longer install i386_dr_low.reset_addr.
Install go32_get_dr7 as i386_dr_low.get_control. Install
go32_get_dr as i386_dr_low.get_addr.
* i386bsd-nat.c (i386bsd_dr_get): New.
(i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_status): Use i386bsd_dr_get.
(i386bsd_dr_get_control): New.
* i386bsd-nat.h (i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_control): New.
* i386fbsd-nat.c (_initialize_i386fbsd_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386bsd_dr_get_control as i386_dr_low.get_control. Install
i386bsd_dr_get_addr as i386_dr_low.get_addr.
* windows-nat.c (init_windows_ops): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
cygwin_get_dr7 as i386_dr_low.get_control. Install cygwin_get_dr
as i386_dr_low.get_addr.
(cygwin_get_dr): New.
(cygwin_get_dr7): New.
gdb/testsuite/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* gdb.mi/watch-nonstop.c: New file.
* gdb.mi/mi-watch-nonstop.exp: New file.
2011-12-14 18:20:32 +01:00
|
|
|
|
lwp_free (lp);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return a pointer to the structure describing the LWP corresponding
|
|
|
|
|
to PID. If no corresponding LWP could be found, return NULL. */
|
|
|
|
|
|
|
|
|
|
static struct lwp_info *
|
|
|
|
|
find_lwp_pid (ptid_t ptid)
|
|
|
|
|
{
|
|
|
|
|
struct lwp_info *lp;
|
|
|
|
|
int lwp;
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
struct lwp_info dummy;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
2013-09-30 13:50:12 +02:00
|
|
|
|
if (ptid_lwp_p (ptid))
|
|
|
|
|
lwp = ptid_get_lwp (ptid);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
else
|
2013-09-30 13:50:12 +02:00
|
|
|
|
lwp = ptid_get_pid (ptid);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
dummy.ptid = ptid_build (0, lwp, 0);
|
|
|
|
|
lp = (struct lwp_info *) htab_find (lwp_lwpid_htab, &dummy);
|
|
|
|
|
return lp;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-24 15:05:43 +01:00
|
|
|
|
/* See nat/linux-nat.h. */
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
struct lwp_info *
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
iterate_over_lwps (ptid_t filter,
|
2015-03-24 15:05:43 +01:00
|
|
|
|
iterate_over_lwps_ftype callback,
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
void *data)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
|
|
|
|
struct lwp_info *lp, *lpnext;
|
|
|
|
|
|
|
|
|
|
for (lp = lwp_list; lp; lp = lpnext)
|
|
|
|
|
{
|
|
|
|
|
lpnext = lp->next;
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
|
|
|
|
|
if (ptid_match (lp->ptid, filter))
|
|
|
|
|
{
|
2015-03-24 15:05:43 +01:00
|
|
|
|
if ((*callback) (lp, data) != 0)
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
return lp;
|
|
|
|
|
}
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
gdb/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* linux-nat.c (linux_child_follow_fork): If we're staying attached
to the child process, enable event reporting on it. Don't handle
checkpoints here. Instead, add the child fork to the lwp thread
and inferior lists without clobbering the previous inferior. Let
the thread_db layer learn about a new child process, even if
following the parent.
(linux_nat_switch_fork): Delete lwps of the current inferior only,
instead of clearing the whole list. Use thread_change_ptid to
give the core the illusion the new checkpoint is still the same
inferior. Clear the register cache.
(linux_handle_extended_wait): Handle checkpoints here.
(linux_multi_process): Turn on.
* linux-fork.c (struct fork_info) <pc>: Remove field.
(init_fork_list): Do not delete the checkpoint from the inferior
list (it is not there).
(fork_load_infrun_state): Don't switch inferior_ptid here. Pass
the new checkpoint's ptid to linux_nat_switch_fork.
(fork_save_infrun_state): Make static. Don't stop the pc field of
fork_info, it's gone.
(linux_fork_mourn_inferior): Don't delete the checkpoint from the
inferior list, it's not there.
(linux_fork_detach): Ditto.
(delete_fork_command): Replace mention of fork/checkpoint by
checkpoint only.
(detach_fork_command): Likewise. Don't delete the checkpoint from
the inferior list.
(info_forks_command): Adjust.
(restore_detach_fork): Delete.
(checkpointing_pid): New.
(linux_fork_checkpointing_p): New.
(save_detach_fork): Delete.
(checkpoint_command): Delete temp_detach_fork. Don't remove
breakpoints, that's a nop. Store the pid of the process we're
checkpointing, and use make_cleanup_restore_integer to restore it.
Don't reinsert breakpoints here.
(process_command, fork_command): Delete.
(restart_command): Update comments to only mention checkpoints,
not forks.
(_initialize_linux_fork): Delete "fork", "process", "info forks"
commands.
* linux-fork.h (fork_save_infrun_state, fork_list): Delete
declarations.
(linux_fork_checkpointing_p): Declare.
* cli/cli-cmds.c (killlist): New.
* cli/cli-cmds.h (killlist): Declare.
* gdbcmd.h (killlist): Declare.
* inferior.c: Include "gdbthread.h".
(detach_inferior_command, kill_inferior_command)
(inferior_command): New.
(info_inferiors_command): Allow specifying a specific inferior id.
(_initialize_inferiors): Register "inferior", "kill inferior" and
"detach inferior" commands.
* infcmd.c (_initialize_infcmd): Make "kill" a prefix command.
* gdbthread.h (any_thread_of_process): Declare.
* thread.c (any_thread_of_process): New.
* NEWS: Mention multi-inferior debugging. Mention 'info
inferiors', 'inferior', 'detach inferior' and 'kill inferior' as
new commands.
(Removed commands): New section, mentioning that 'info forks',
'fork', 'process', 'delete fork' and 'detach fork' are now gone.
gdb/testsuite/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.base/multi-forks.exp: Only run detach-on-fork tests on
linux. Adjust to use "inferior", "info inferiors", "detach
inferior" and "kill inferior" instead of "restart", "info fork",
"detach fork" and "delete fork".
* gdb.base/ending-run.exp: Spell out "info".
* gdb.base/help.exp: Adjust to use test_prefix_command_help for
the "kill" command.
gdb/doc/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (Debugging multiple inferiors): Document the
"inferior", "detach inferior" and "kill inferior" commands.
(Debugging Programs with Multiple Processes): Adjust to mention
generic "inferior" commands. Delete mention of "detach fork" and
"delete fork". Cross reference to "Debugging multiple inferiors"
section.
2009-07-02 23:57:28 +02:00
|
|
|
|
/* Update our internal state when changing from one checkpoint to
|
|
|
|
|
another indicated by NEW_PTID. We can only switch single-threaded
|
|
|
|
|
applications, so we only create one new LWP, and the previous list
|
|
|
|
|
is discarded. */
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
linux_nat_switch_fork (ptid_t new_ptid)
|
|
|
|
|
{
|
|
|
|
|
struct lwp_info *lp;
|
|
|
|
|
|
2013-09-30 13:50:12 +02:00
|
|
|
|
purge_lwp_list (ptid_get_pid (inferior_ptid));
|
gdb/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* linux-nat.c (linux_child_follow_fork): If we're staying attached
to the child process, enable event reporting on it. Don't handle
checkpoints here. Instead, add the child fork to the lwp thread
and inferior lists without clobbering the previous inferior. Let
the thread_db layer learn about a new child process, even if
following the parent.
(linux_nat_switch_fork): Delete lwps of the current inferior only,
instead of clearing the whole list. Use thread_change_ptid to
give the core the illusion the new checkpoint is still the same
inferior. Clear the register cache.
(linux_handle_extended_wait): Handle checkpoints here.
(linux_multi_process): Turn on.
* linux-fork.c (struct fork_info) <pc>: Remove field.
(init_fork_list): Do not delete the checkpoint from the inferior
list (it is not there).
(fork_load_infrun_state): Don't switch inferior_ptid here. Pass
the new checkpoint's ptid to linux_nat_switch_fork.
(fork_save_infrun_state): Make static. Don't stop the pc field of
fork_info, it's gone.
(linux_fork_mourn_inferior): Don't delete the checkpoint from the
inferior list, it's not there.
(linux_fork_detach): Ditto.
(delete_fork_command): Replace mention of fork/checkpoint by
checkpoint only.
(detach_fork_command): Likewise. Don't delete the checkpoint from
the inferior list.
(info_forks_command): Adjust.
(restore_detach_fork): Delete.
(checkpointing_pid): New.
(linux_fork_checkpointing_p): New.
(save_detach_fork): Delete.
(checkpoint_command): Delete temp_detach_fork. Don't remove
breakpoints, that's a nop. Store the pid of the process we're
checkpointing, and use make_cleanup_restore_integer to restore it.
Don't reinsert breakpoints here.
(process_command, fork_command): Delete.
(restart_command): Update comments to only mention checkpoints,
not forks.
(_initialize_linux_fork): Delete "fork", "process", "info forks"
commands.
* linux-fork.h (fork_save_infrun_state, fork_list): Delete
declarations.
(linux_fork_checkpointing_p): Declare.
* cli/cli-cmds.c (killlist): New.
* cli/cli-cmds.h (killlist): Declare.
* gdbcmd.h (killlist): Declare.
* inferior.c: Include "gdbthread.h".
(detach_inferior_command, kill_inferior_command)
(inferior_command): New.
(info_inferiors_command): Allow specifying a specific inferior id.
(_initialize_inferiors): Register "inferior", "kill inferior" and
"detach inferior" commands.
* infcmd.c (_initialize_infcmd): Make "kill" a prefix command.
* gdbthread.h (any_thread_of_process): Declare.
* thread.c (any_thread_of_process): New.
* NEWS: Mention multi-inferior debugging. Mention 'info
inferiors', 'inferior', 'detach inferior' and 'kill inferior' as
new commands.
(Removed commands): New section, mentioning that 'info forks',
'fork', 'process', 'delete fork' and 'detach fork' are now gone.
gdb/testsuite/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.base/multi-forks.exp: Only run detach-on-fork tests on
linux. Adjust to use "inferior", "info inferiors", "detach
inferior" and "kill inferior" instead of "restart", "info fork",
"detach fork" and "delete fork".
* gdb.base/ending-run.exp: Spell out "info".
* gdb.base/help.exp: Adjust to use test_prefix_command_help for
the "kill" command.
gdb/doc/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (Debugging multiple inferiors): Document the
"inferior", "detach inferior" and "kill inferior" commands.
(Debugging Programs with Multiple Processes): Adjust to mention
generic "inferior" commands. Delete mention of "detach fork" and
"delete fork". Cross reference to "Debugging multiple inferiors"
section.
2009-07-02 23:57:28 +02:00
|
|
|
|
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
lp = add_lwp (new_ptid);
|
|
|
|
|
lp->stopped = 1;
|
2006-02-02 03:29:29 +01:00
|
|
|
|
|
gdb/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* linux-nat.c (linux_child_follow_fork): If we're staying attached
to the child process, enable event reporting on it. Don't handle
checkpoints here. Instead, add the child fork to the lwp thread
and inferior lists without clobbering the previous inferior. Let
the thread_db layer learn about a new child process, even if
following the parent.
(linux_nat_switch_fork): Delete lwps of the current inferior only,
instead of clearing the whole list. Use thread_change_ptid to
give the core the illusion the new checkpoint is still the same
inferior. Clear the register cache.
(linux_handle_extended_wait): Handle checkpoints here.
(linux_multi_process): Turn on.
* linux-fork.c (struct fork_info) <pc>: Remove field.
(init_fork_list): Do not delete the checkpoint from the inferior
list (it is not there).
(fork_load_infrun_state): Don't switch inferior_ptid here. Pass
the new checkpoint's ptid to linux_nat_switch_fork.
(fork_save_infrun_state): Make static. Don't stop the pc field of
fork_info, it's gone.
(linux_fork_mourn_inferior): Don't delete the checkpoint from the
inferior list, it's not there.
(linux_fork_detach): Ditto.
(delete_fork_command): Replace mention of fork/checkpoint by
checkpoint only.
(detach_fork_command): Likewise. Don't delete the checkpoint from
the inferior list.
(info_forks_command): Adjust.
(restore_detach_fork): Delete.
(checkpointing_pid): New.
(linux_fork_checkpointing_p): New.
(save_detach_fork): Delete.
(checkpoint_command): Delete temp_detach_fork. Don't remove
breakpoints, that's a nop. Store the pid of the process we're
checkpointing, and use make_cleanup_restore_integer to restore it.
Don't reinsert breakpoints here.
(process_command, fork_command): Delete.
(restart_command): Update comments to only mention checkpoints,
not forks.
(_initialize_linux_fork): Delete "fork", "process", "info forks"
commands.
* linux-fork.h (fork_save_infrun_state, fork_list): Delete
declarations.
(linux_fork_checkpointing_p): Declare.
* cli/cli-cmds.c (killlist): New.
* cli/cli-cmds.h (killlist): Declare.
* gdbcmd.h (killlist): Declare.
* inferior.c: Include "gdbthread.h".
(detach_inferior_command, kill_inferior_command)
(inferior_command): New.
(info_inferiors_command): Allow specifying a specific inferior id.
(_initialize_inferiors): Register "inferior", "kill inferior" and
"detach inferior" commands.
* infcmd.c (_initialize_infcmd): Make "kill" a prefix command.
* gdbthread.h (any_thread_of_process): Declare.
* thread.c (any_thread_of_process): New.
* NEWS: Mention multi-inferior debugging. Mention 'info
inferiors', 'inferior', 'detach inferior' and 'kill inferior' as
new commands.
(Removed commands): New section, mentioning that 'info forks',
'fork', 'process', 'delete fork' and 'detach fork' are now gone.
gdb/testsuite/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.base/multi-forks.exp: Only run detach-on-fork tests on
linux. Adjust to use "inferior", "info inferiors", "detach
inferior" and "kill inferior" instead of "restart", "info fork",
"detach fork" and "delete fork".
* gdb.base/ending-run.exp: Spell out "info".
* gdb.base/help.exp: Adjust to use test_prefix_command_help for
the "kill" command.
gdb/doc/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (Debugging multiple inferiors): Document the
"inferior", "detach inferior" and "kill inferior" commands.
(Debugging Programs with Multiple Processes): Adjust to mention
generic "inferior" commands. Delete mention of "detach fork" and
"delete fork". Cross reference to "Debugging multiple inferiors"
section.
2009-07-02 23:57:28 +02:00
|
|
|
|
/* This changes the thread's ptid while preserving the gdb thread
|
|
|
|
|
num. Also changes the inferior pid, while preserving the
|
|
|
|
|
inferior num. */
|
|
|
|
|
thread_change_ptid (inferior_ptid, new_ptid);
|
|
|
|
|
|
|
|
|
|
/* We've just told GDB core that the thread changed target id, but,
|
|
|
|
|
in fact, it really is a different thread, with different register
|
|
|
|
|
contents. */
|
|
|
|
|
registers_changed ();
|
2006-02-02 03:29:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Handle the exit of a single thread LP. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
exit_lwp (struct lwp_info *lp)
|
|
|
|
|
{
|
2009-05-24 23:06:53 +02:00
|
|
|
|
struct thread_info *th = find_thread_ptid (lp->ptid);
|
2008-05-03 17:10:42 +02:00
|
|
|
|
|
|
|
|
|
if (th)
|
2006-02-02 03:29:29 +01:00
|
|
|
|
{
|
2008-03-21 Daniel Jacobowitz <dan@codesourcery.com>
* gdbthread.h (add_thread_with_info): New.
* linux-thread-db.c: Add some documentation.
(GET_LWP, GET_PID, GET_THREAD, is_lwp, is_thread, BUILD_LWP): Delete.
(struct private_thread_info): Remove th_valid and ti_valid.
Replace ti with tid.
(thread_get_info_callback): Do not add TID to the new ptid. Do
not cache th or ti.
(thread_db_map_id2thr, lwp_from_thread): Delete functions.
(thread_from_lwp): Assert that the LWP is set. Do not add TID to the
new PTID.
(attach_thread): Handle an already-existing thread. Use
add_thread_with_info. Cache the th and tid.
(detach_thread): Verify that private was set. Remove verbose
argument and printing. Update caller.
(thread_db_detach): Do not adjust inferior_ptid.
(clear_lwpid_callback, thread_db_resume, thread_db_kill): Delete.
(check_event, find_new_threads_callback): Do not add TID to the new PTID.
(thread_db_wait): Do not use lwp_from_thread.
(thread_db_pid_to_str): Use the cached TID.
(thread_db_extra_thread_info): Check that private is set.
(same_ptid_callback): Delete.
(thread_db_get_thread_local_address): Do not use it or check
is_thread. Check that private is set. Assume that the thread
handle is already cached.
(init_thread_db_ops): Remove to_resume and to_kill.
* thread.c (add_thread_with_info): New.
(add_thread): Use it.
* linux-nat.c (find_thread_from_lwp): Delete.
(exit_lwp): Do not use it. Check print_thread_events. Print before
deleting the thread.
(GET_PID, GET_LWP, BUILD_LWP, is_lwp): Move to...
* linux-nat.h (GET_PID, GET_LWP, BUILD_LWP, is_lwp): ...here.
* inf-ttrace.c (inf_ttrace_wait): Use print_thread_events and
printf_unfiltered for thread exits.
* procfs.c (procfs_wait): Likewise.
2008-03-21 Pedro Alves <pedro@codesourcery.com>
* gdb.threads/fork-child-threads.exp: Test next over fork.
2008-03-21 16:44:53 +01:00
|
|
|
|
if (print_thread_events)
|
|
|
|
|
printf_unfiltered (_("[%s exited]\n"), target_pid_to_str (lp->ptid));
|
|
|
|
|
|
Exited threads.
* thread.c (enum thread_state): New.
(thread_state main_thread_running): Delete, in favor of...
(thread_state main_thread_state): ... this. Update throughout.
(clear_thread_inferior_resources): New, split from free_thread.
(free_thread): Call clear_thread_inferior_resources.
(init_thread_list): Set main thread to stopped state.
(add_thread_silent): Take care of PTID reuses.
(delete_thread): If deleting inferior_ptid or a thread with
refcount > 0, mark it as exited, but still keep it in the list.
Only notify of thread exits, if we haven't done so yet.
(iterate_over_threads): Make it safe to delete threads while
iterating over them.
(do_captured_list_thread_ids): Don't account for exited threads.
(thread_alive): Check for the THREAD_EXITED state, and don't set
ptid to -1 on exited threads.
(set_running): Update to account for extra possible states.
(is_thread_state): New.
(is_stopped, is_exited): New.
(is_running): Implement in terms of is_thread_state.
(any_running): Update.
(print_thread_info): Update. Account for exited threads. Don't
warn about missed frame restoring here, its done in the cleanup.
(switch_to_thread): Don't read from a thread that has gone.
(restore_current_thread): In non-stop mode, do a full context
switch.
(restore_selected_frame): Add a frame_level argument. Rewrite.
(struct current_thread_cleanup): Add selected_frame_level and
was_stopped members.
(do_restore_current_thread_cleanup): Check if thread was stopped
and still is, and if the target has registers, stack and memory
before restoring the selected frame. Don't delete the cleanup
argument here.
(restore_current_thread_cleanup_dtor): New.
(make_cleanup_restore_current_thread): Remove all arguments.
Rewrite.
(thread_apply_all_command): Update. Prune threads.
(thread_apply_command): Update.
(thread_command): Account for currently selected exited thread.
(do_captured_thread_select): Check for a running thread. Prune
threads.
(_initialize_thread): Make "info threads", "thread", "thread
apply", and "thread apply all" appliable without a selected thread.
* gdbthread.h (struct thread_info): Replace running_ by state_.
Add refcount.
(is_exited, is_stopped): Declare.
(make_cleanup_restore_current_thread): Remove all arguments.
* infrun.c: Include "event-top.h".
(fetch_inferior_event): In non-stop mode, restore selected thread
and frame after handling the event and running breakpoint
commands. Display GDB prompt if needed.
(normal_stop): In non-stop mode, don't print thread switching
notice.
* cli/cli-decode.c (set_cmd_no_selected_thread_ok)
(get_cmd_no_selected_thread_ok): New.
* cli/cli-decode.h (CMD_NO_SELECTED_THREAD_OK): New.
(set_cmd_no_selected_thread_ok, get_cmd_no_selected_thread_ok):
Declare.
* cli/cli-cmds.c: Set "pwd", "help", "info", "show" as
no-selected-thread ok.
* top.c (execute_command): Check for non no-selected-thread-ok
commands.
* linux-nat.c (struct saved_ptids, threads_to_delete)
(record_dead_thread, prune_lwps): Delete.
(exit_lwp): Unconditionally delete thread.
(linux_nat_resume): Remove prune_lwps call.
* infcmd.c (proceed_thread_callback): Check if !is_stopped instead
of is_running. Adjust to make_cleanup_restore_current_thread
interface change.
* mi/mi-main.c (mi_cmd_execute): Only allow a few commands if the
selected thread has exited.
* inf-loop.c (inferior_event_handler): Don't display the prompt
here.
* varobj.c (c_value_of_root): Update.
* defs.h (make_cleanup_dtor): Declare.
* utils.c (make_cleanup_dtor): New.
* Makefile.in (infrun.o): Depend on $(event_top_h).
2008-07-11 13:07:39 +02:00
|
|
|
|
delete_thread (lp->ptid);
|
2006-02-02 03:29:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete_lwp (lp->ptid);
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-01 20:50:14 +02:00
|
|
|
|
/* Wait for the LWP specified by LP, which we have just attached to.
|
|
|
|
|
Returns a wait status for that LWP, to cache. */
|
|
|
|
|
|
|
|
|
|
static int
|
2017-06-03 21:24:00 +02:00
|
|
|
|
linux_nat_post_attach_wait (ptid_t ptid, int *signalled)
|
2008-05-01 20:50:14 +02:00
|
|
|
|
{
|
2013-09-30 13:50:12 +02:00
|
|
|
|
pid_t new_pid, pid = ptid_get_lwp (ptid);
|
2008-05-01 20:50:14 +02:00
|
|
|
|
int status;
|
|
|
|
|
|
2012-02-27 17:22:16 +01:00
|
|
|
|
if (linux_proc_pid_is_stopped (pid))
|
2008-05-01 20:50:14 +02:00
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LNPAW: Attaching to a stopped process\n");
|
|
|
|
|
|
|
|
|
|
/* The process is definitely stopped. It is in a job control
|
|
|
|
|
stop, unless the kernel predates the TASK_STOPPED /
|
|
|
|
|
TASK_TRACED distinction, in which case it might be in a
|
|
|
|
|
ptrace stop. Make sure it is in a ptrace stop; from there we
|
|
|
|
|
can kill it, signal it, et cetera.
|
|
|
|
|
|
|
|
|
|
First make sure there is a pending SIGSTOP. Since we are
|
|
|
|
|
already attached, the process can not transition from stopped
|
|
|
|
|
to running without a PTRACE_CONT; so we know this signal will
|
|
|
|
|
go into the queue. The SIGSTOP generated by PTRACE_ATTACH is
|
|
|
|
|
probably already in the queue (unless this kernel is old
|
|
|
|
|
enough to use TASK_STOPPED for ptrace stops); but since SIGSTOP
|
|
|
|
|
is not an RT signal, it can only be queued once. */
|
|
|
|
|
kill_lwp (pid, SIGSTOP);
|
|
|
|
|
|
|
|
|
|
/* Finally, resume the stopped process. This will deliver the SIGSTOP
|
|
|
|
|
(or a higher priority signal, just like normal PTRACE_ATTACH). */
|
|
|
|
|
ptrace (PTRACE_CONT, pid, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make sure the initial process is stopped. The user-level threads
|
|
|
|
|
layer might want to poke around in the inferior, and that won't
|
|
|
|
|
work if things haven't stabilized yet. */
|
2015-12-17 15:20:51 +01:00
|
|
|
|
new_pid = my_waitpid (pid, &status, __WALL);
|
2009-10-15 20:06:15 +02:00
|
|
|
|
gdb_assert (pid == new_pid);
|
|
|
|
|
|
|
|
|
|
if (!WIFSTOPPED (status))
|
|
|
|
|
{
|
|
|
|
|
/* The pid we tried to attach has apparently just exited. */
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "LNPAW: Failed to stop %d: %s",
|
|
|
|
|
pid, status_to_str (status));
|
|
|
|
|
return status;
|
|
|
|
|
}
|
2008-05-01 20:50:14 +02:00
|
|
|
|
|
|
|
|
|
if (WSTOPSIG (status) != SIGSTOP)
|
|
|
|
|
{
|
|
|
|
|
*signalled = 1;
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LNPAW: Received %s after attaching\n",
|
|
|
|
|
status_to_str (status));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
static void
|
Kill pthread_ops_hack
* target.h (struct target_ops): Make to_attach, to_detach,
to_create_inferior and to_mourn_inferior accept a pointer
to struct target_ops.
(target_attach, target_create_inferior, target_create_inferior):
Convert from macros to function. Find the right target to
invoke a method of.
(find_default_attach, find_default_create_inferior): New parameter
ops.
* corefile.c (core_file_command): Pass target to to_detach.
* corelow.c (core_detach): Add 'ops' parameter.
* fork-child.c (fork_inferior): Return the pid. Allow
init_trace_fun to be NULL.
* inf-ptrace (ptrace_ops_hack): Remove.
(inf_ptrace_him): Remove, moving all logic into....
(inf_ptrace_create_inferior): ... here. Push the target
passed as parameter.
(inf_ptrace_mourn_inferior, inf_ptrace_attach, inf_ptrace_detach):
Push/pop target passed as parameter, no ptrace_ops_hack.
(inf_ptrace_target): Don't remember result.
* inferior.h (fork_inferior): Adjust prototype.
* linux-nat.c (linux_nat_create_inferior, linux_nat_attach)
(linux_nat_detach, linux_nat_mourn_inferior): New parameter ops.
Pass it to linux_ops target.
* linux-thread-db.c (thread_db_detach, thread_db_mourn_inferior):
New parameter ops. Pass it to the target beneath.
* remote.c (remote_mourn, extended_remote_mourn, remote_detach)
(extended_remote_create_inferior): New parameter ops. Pass it
further.
* target.c (debug_to_attach, debug_to_detach)
(debug_to_mourn_inferior): New parameter ops.
(target_create_inferior): New.
(update_current_target): Do not inherit to_attach, to_detach,
to_create_inferiour, to_mourn_inferior. Do not default
to_detach and to_mourn_inferior.
(target_detach): Find the right target to use.
(target_mourn_inferior): New.
(find_default_attach, find_default_create_inferior): New parameter
ops. Pass the found target when calling its method.
(init_dummy_target): Provide fallback definition of to_detach.
(target_attach): New.
(debug_to_attach, debug_to_detach, debug_to_create_inferior)
(debug_to_mourn_inferiour): New parameter ops.
* aix-thread.c: Adjust.
* bsd-uthread.c: Adjust.
* gnu-nat.c: Adjust.
* go32-nat.c: Adjust.
* hpux-thread.c: Adjust.
* inf-ttrace.c: Ajust.
* monitor.c: Adjust.
* nto-procfs.c: Adjust.
* procfs.c: Adjust.
* remote-m32r-sdi.c: Adjust.
* remote-mips.c: Adjust.
* remote-sim.c: Adjust.
* rs6000-nat.c: Adjust.
* sol-thread.c: Adjust.
* win32-nat.c: Adjust.
* dec-thread.c: Adjust.
2008-11-09 12:27:18 +01:00
|
|
|
|
linux_nat_create_inferior (struct target_ops *ops,
|
C++-fy and prepare for sharing fork_inferior
As a preparation for the next patch, which will move fork_inferior
from GDB to common/ (and therefore share it with gdbserver), it is
interesting to convert a few functions to C++.
This patch touches functions related to parsing command-line arguments
to the inferior (see gdb/fork-child.c:breakup_args), the way the
arguments are stored on fork_inferior (using std::vector instead of
char **), and the code responsible for dealing with argv also on
gdbserver.
I've taken this opportunity and decided to constify a few arguments to
fork_inferior/create_inferior as well, in order to make the code
cleaner. And now, on gdbserver, we're using xstrdup everywhere and
aren't checking for memory allocation failures anymore, as requested
by Pedro:
<https://sourceware.org/ml/gdb-patches/2017-03/msg00191.html>
Message-Id: <025ebdb9-90d9-d54a-c055-57ed2406b812@redhat.com>
Pedro Alves wrote:
> On the "== NULL" check: IIUC, the old NULL check was there to
> handle strdup returning NULL due to out-of-memory.
> See NULL checks and comments further above in this function.
> Now that you're using a std::vector, that doesn't work or make
> sense any longer, since if push_back fails to allocate space for
> its internal buffer (with operator new), our operator new replacement
> (common/new-op.c) calls malloc_failure, which aborts gdbserver.
>
> Not sure it makes sense to handle out-of-memory specially in
> the gdb/rsp-facing functions nowadays (maybe git blame/log/patch
> submission for that code shows some guidelines). Maybe (or, probably)
> it's OK to stop caring about it, but then we should consistently remove
> left over code, by using xstrdup instead and remove the NULL checks.
IMO this refactoring was very good to increase the readability of the
code as well, because some parts of the argument handling were
unnecessarily confusing before.
gdb/ChangeLog:
2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com>
* common/common-utils.c (free_vector_argv): New function.
* common/common-utils.h: Include <vector>.
(free_vector_argv): New prototype.
* darwin-nat.c (darwin_create_inferior): Rewrite function
prototype in order to constify "exec_file" and accept a
"std::string" for "allargs".
* fork-child.c: Include <vector>.
(breakup_args): Rewrite function, using C++.
(fork_inferior): Rewrite function header, constify "exec_file_arg"
and accept "std::string" for "allargs". Update the code to
calculate "argv" based on "allargs". Update calls to "exec_fun"
and "execvp".
* gnu-nat.c (gnu_create_inferior): Rewrite function prototype in
order to constify "exec_file" and accept a "std::string" for
"allargs".
* go32-nat.c (go32_create_inferior): Likewise.
* inf-ptrace.c (inf_ptrace_create_inferior): Likewise.
* infcmd.c (run_command_1): Constify "exec_file". Use
"std::string" for inferior arguments.
* inferior.h (fork_inferior): Update prototype.
* linux-nat.c (linux_nat_create_inferior): Rewrite function
prototype in order to constify "exec_file" and accept a
"std::string" for "allargs".
* nto-procfs.c (procfs_create_inferior): Likewise.
* procfs.c (procfs_create_inferior): Likewise.
* remote-sim.c (gdbsim_create_inferior): Likewise.
* remote.c (extended_remote_run): Update code to accept
"std::string" as argument.
(extended_remote_create_inferior): Rewrite function prototype in
order to constify "exec_file" and accept a "std::string" for
"allargs".
* rs6000-nat.c (super_create_inferior): Likewise.
(rs6000_create_inferior): Likewise.
* target.h (struct target_ops) <to_create_inferior>: Likewise.
* windows-nat.c (windows_create_inferior): Likewise.
gdb/gdbserver/ChangeLog:
2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com>
* server.c: Include <vector>.
<program_argv, wrapper_argv>: Convert to std::vector.
(start_inferior): Rewrite function to use C++.
(handle_v_run): Likewise. Update code that calculates the argv
based on the vRun packet; use C++.
(captured_main): Likewise.
2017-03-23 02:54:49 +01:00
|
|
|
|
const char *exec_file, const std::string &allargs,
|
|
|
|
|
char **env, int from_tty)
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
{
|
2017-11-22 17:30:21 +01:00
|
|
|
|
maybe_disable_address_space_randomization restore_personality
|
|
|
|
|
(disable_randomization);
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
|
|
|
|
|
/* The fork_child mechanism is synchronous and calls target_wait, so
|
|
|
|
|
we have to mask the async mode. */
|
|
|
|
|
|
2011-04-27 15:29:15 +02:00
|
|
|
|
/* Make sure we report all signals during startup. */
|
2013-12-18 05:33:44 +01:00
|
|
|
|
linux_nat_pass_signals (ops, 0, NULL);
|
2011-04-27 15:29:15 +02:00
|
|
|
|
|
Kill pthread_ops_hack
* target.h (struct target_ops): Make to_attach, to_detach,
to_create_inferior and to_mourn_inferior accept a pointer
to struct target_ops.
(target_attach, target_create_inferior, target_create_inferior):
Convert from macros to function. Find the right target to
invoke a method of.
(find_default_attach, find_default_create_inferior): New parameter
ops.
* corefile.c (core_file_command): Pass target to to_detach.
* corelow.c (core_detach): Add 'ops' parameter.
* fork-child.c (fork_inferior): Return the pid. Allow
init_trace_fun to be NULL.
* inf-ptrace (ptrace_ops_hack): Remove.
(inf_ptrace_him): Remove, moving all logic into....
(inf_ptrace_create_inferior): ... here. Push the target
passed as parameter.
(inf_ptrace_mourn_inferior, inf_ptrace_attach, inf_ptrace_detach):
Push/pop target passed as parameter, no ptrace_ops_hack.
(inf_ptrace_target): Don't remember result.
* inferior.h (fork_inferior): Adjust prototype.
* linux-nat.c (linux_nat_create_inferior, linux_nat_attach)
(linux_nat_detach, linux_nat_mourn_inferior): New parameter ops.
Pass it to linux_ops target.
* linux-thread-db.c (thread_db_detach, thread_db_mourn_inferior):
New parameter ops. Pass it to the target beneath.
* remote.c (remote_mourn, extended_remote_mourn, remote_detach)
(extended_remote_create_inferior): New parameter ops. Pass it
further.
* target.c (debug_to_attach, debug_to_detach)
(debug_to_mourn_inferior): New parameter ops.
(target_create_inferior): New.
(update_current_target): Do not inherit to_attach, to_detach,
to_create_inferiour, to_mourn_inferior. Do not default
to_detach and to_mourn_inferior.
(target_detach): Find the right target to use.
(target_mourn_inferior): New.
(find_default_attach, find_default_create_inferior): New parameter
ops. Pass the found target when calling its method.
(init_dummy_target): Provide fallback definition of to_detach.
(target_attach): New.
(debug_to_attach, debug_to_detach, debug_to_create_inferior)
(debug_to_mourn_inferiour): New parameter ops.
* aix-thread.c: Adjust.
* bsd-uthread.c: Adjust.
* gnu-nat.c: Adjust.
* go32-nat.c: Adjust.
* hpux-thread.c: Adjust.
* inf-ttrace.c: Ajust.
* monitor.c: Adjust.
* nto-procfs.c: Adjust.
* procfs.c: Adjust.
* remote-m32r-sdi.c: Adjust.
* remote-mips.c: Adjust.
* remote-sim.c: Adjust.
* rs6000-nat.c: Adjust.
* sol-thread.c: Adjust.
* win32-nat.c: Adjust.
* dec-thread.c: Adjust.
2008-11-09 12:27:18 +01:00
|
|
|
|
linux_ops->to_create_inferior (ops, exec_file, allargs, env, from_tty);
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
Linux: on attach, attach to lwps listed under /proc/$pid/task/
... instead of relying on libthread_db.
I wrote a test that attaches to a program that constantly spawns
short-lived threads, which exposed several issues. This is one of
them.
On Linux, we need to attach to all threads of a process (thread group)
individually. We currently rely on libthread_db to list the threads,
but that is problematic, because libthread_db relies on reading data
structures out of the inferior (which may well be corrupted). If
threads are being created or exiting just while we try to attach, we
may trip on inconsistencies in the inferior's thread list. To work
around that, when we see a seemingly corrupt list, we currently retry
a few times:
static void
thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new)
{
...
if (until_no_new)
{
/* Require 4 successive iterations which do not find any new threads.
The 4 is a heuristic: there is an inherent race here, and I have
seen that 2 iterations in a row are not always sufficient to
"capture" all threads. */
...
That heuristic may well fail, and when it does, we end up with threads
in the program that aren't under GDB's control. That's obviously bad
and results in quite mistifying failures, like e.g., the process dying
for seeminly no reason when a thread that wasn't attached trips on a
breakpoint.
There's really no reason to rely on libthread_db for this nowadays
when we have /proc mounted. In that case, which is the usual case, we
can list the LWPs from /proc/PID/task/. In fact, GDBserver is already
doing this. The patch factors out that code that knows to walk the
task/ directory out of GDBserver, and makes GDB use it too.
Like GDBserver, the patch makes GDB attach to LWPs and _not_ wait for
them to stop immediately. Instead, we just tag the LWP as having an
expected stop. Because we can only set the ptrace options when the
thread stops, we need a new flag in the lwp structure to keep track of
whether we've already set the ptrace options, just like in GDBserver.
Note that nothing issues any ptrace command to the threads between the
PTRACE_ATTACH and the stop, so this is safe (unlike one scenario
described in gdbserver's linux-low.c).
When we attach to a program that has threads exiting while we attach,
it's easy to race with a thread just exiting as we try to attach to
it, like:
#1 - get current list of threads
#2 - attach to each listed thread
#3 - ooops, attach failed, thread is already gone
As this is pretty normal, we shouldn't be issuing a scary warning in
step #3.
When #3 happens, PTRACE_ATTACH usually fails with ESRCH, but sometimes
we'll see EPERM as well. That happens when the kernel still has the
thread in its task list, but the thread is marked as dead.
Unfortunately, EPERM is ambiguous and we'll get it also on other
scenarios where the thread isn't dead, and in those cases, it's useful
to get a warning. To distiguish the cases, when we get an EPERM
failure, we open /proc/PID/status, and check the thread's state -- if
the /proc file no longer exists, or the state is "Z (Zombie)" or "X
(Dead)", we ignore the EPERM error silently; otherwise, we'll warn.
Unfortunately, there seems to be a kernel race here. Sometimes I get
EPERM, and then the /proc state still indicates "R (Running)"... If
we wait a bit and retry, we do end up seeing X or Z state, or get an
ESRCH. I thought of making GDB retry the attach a few times, but even
with a 500ms wait and 4 retries, I still see the warning sometimes. I
haven't been able to identify the kernel path that causes this yet,
but in any case, it looks like a kernel bug to me. As this just
results failure to suppress a warning that we've been printing since
about forever anyway, I'm just making the test cope with it, and issue
an XFAIL.
gdb/gdbserver/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_attach_fail_reason_string): Move to
nat/linux-ptrace.c, and rename.
(linux_attach_lwp): Update comment.
(attach_proc_task_lwp_callback): New function.
(linux_attach): Adjust to rename and use
linux_proc_attach_tgid_threads.
(linux_attach_fail_reason_string): Delete declaration.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-nat.c (attach_proc_task_lwp_callback): New function.
(linux_nat_attach): Use linux_proc_attach_tgid_threads.
(wait_lwp, linux_nat_filter_event): If not set yet, set the lwp's
ptrace option flags.
* linux-nat.h (struct lwp_info) <must_set_ptrace_flags>: New
field.
* nat/linux-procfs.c: Include <dirent.h>.
(linux_proc_get_int): New parameter "warn". Handle it.
(linux_proc_get_tgid): Adjust.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this.
(linux_proc_pid_get_state): New function, factored out from
(linux_proc_pid_has_state): ... this. Add new parameter "warn"
and handle it.
(linux_proc_pid_is_gone): New function.
(linux_proc_pid_is_stopped): Adjust.
(linux_proc_pid_is_zombie_maybe_warn)
(linux_proc_pid_is_zombie_nowarn): New functions.
(linux_proc_pid_is_zombie): Use
linux_proc_pid_is_zombie_maybe_warn.
(linux_proc_attach_tgid_threads): New function.
* nat/linux-procfs.h (linux_proc_get_tgid): Update comment.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this, and update comment.
(linux_proc_pid_is_gone): New declaration.
(linux_proc_pid_is_zombie): Update comment.
(linux_proc_pid_is_zombie_nowarn): New declaration.
(linux_proc_attach_lwp_func): New typedef.
(linux_proc_attach_tgid_threads): New declaration.
* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason): Adjust to
use nowarn functions.
(linux_ptrace_attach_fail_reason_string): Move here from
gdbserver/linux-low.c and rename.
(ptrace_supports_feature): If the current ptrace options are not
known yet, check them now, instead of asserting.
* nat/linux-ptrace.h (linux_ptrace_attach_fail_reason_string):
Declare.
2014-12-16 17:12:24 +01:00
|
|
|
|
/* Callback for linux_proc_attach_tgid_threads. Attach to PTID if not
|
|
|
|
|
already attached. Returns true if a new LWP is found, false
|
|
|
|
|
otherwise. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
attach_proc_task_lwp_callback (ptid_t ptid)
|
|
|
|
|
{
|
|
|
|
|
struct lwp_info *lp;
|
|
|
|
|
|
|
|
|
|
/* Ignore LWPs we're already attached to. */
|
|
|
|
|
lp = find_lwp_pid (ptid);
|
|
|
|
|
if (lp == NULL)
|
|
|
|
|
{
|
|
|
|
|
int lwpid = ptid_get_lwp (ptid);
|
|
|
|
|
|
|
|
|
|
if (ptrace (PTRACE_ATTACH, lwpid, 0, 0) < 0)
|
|
|
|
|
{
|
|
|
|
|
int err = errno;
|
|
|
|
|
|
|
|
|
|
/* Be quiet if we simply raced with the thread exiting.
|
|
|
|
|
EPERM is returned if the thread's task still exists, and
|
|
|
|
|
is marked as exited or zombie, as well as other
|
|
|
|
|
conditions, so in that case, confirm the status in
|
|
|
|
|
/proc/PID/status. */
|
|
|
|
|
if (err == ESRCH
|
|
|
|
|
|| (err == EPERM && linux_proc_pid_is_gone (lwpid)))
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
{
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"Cannot attach to lwp %d: "
|
|
|
|
|
"thread is gone (%d: %s)\n",
|
|
|
|
|
lwpid, err, safe_strerror (err));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-01-17 18:33:57 +01:00
|
|
|
|
std::string reason
|
|
|
|
|
= linux_ptrace_attach_fail_reason_string (ptid, err);
|
|
|
|
|
|
2015-01-13 11:35:49 +01:00
|
|
|
|
warning (_("Cannot attach to lwp %d: %s"),
|
2018-01-17 18:33:57 +01:00
|
|
|
|
lwpid, reason.c_str ());
|
Linux: on attach, attach to lwps listed under /proc/$pid/task/
... instead of relying on libthread_db.
I wrote a test that attaches to a program that constantly spawns
short-lived threads, which exposed several issues. This is one of
them.
On Linux, we need to attach to all threads of a process (thread group)
individually. We currently rely on libthread_db to list the threads,
but that is problematic, because libthread_db relies on reading data
structures out of the inferior (which may well be corrupted). If
threads are being created or exiting just while we try to attach, we
may trip on inconsistencies in the inferior's thread list. To work
around that, when we see a seemingly corrupt list, we currently retry
a few times:
static void
thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new)
{
...
if (until_no_new)
{
/* Require 4 successive iterations which do not find any new threads.
The 4 is a heuristic: there is an inherent race here, and I have
seen that 2 iterations in a row are not always sufficient to
"capture" all threads. */
...
That heuristic may well fail, and when it does, we end up with threads
in the program that aren't under GDB's control. That's obviously bad
and results in quite mistifying failures, like e.g., the process dying
for seeminly no reason when a thread that wasn't attached trips on a
breakpoint.
There's really no reason to rely on libthread_db for this nowadays
when we have /proc mounted. In that case, which is the usual case, we
can list the LWPs from /proc/PID/task/. In fact, GDBserver is already
doing this. The patch factors out that code that knows to walk the
task/ directory out of GDBserver, and makes GDB use it too.
Like GDBserver, the patch makes GDB attach to LWPs and _not_ wait for
them to stop immediately. Instead, we just tag the LWP as having an
expected stop. Because we can only set the ptrace options when the
thread stops, we need a new flag in the lwp structure to keep track of
whether we've already set the ptrace options, just like in GDBserver.
Note that nothing issues any ptrace command to the threads between the
PTRACE_ATTACH and the stop, so this is safe (unlike one scenario
described in gdbserver's linux-low.c).
When we attach to a program that has threads exiting while we attach,
it's easy to race with a thread just exiting as we try to attach to
it, like:
#1 - get current list of threads
#2 - attach to each listed thread
#3 - ooops, attach failed, thread is already gone
As this is pretty normal, we shouldn't be issuing a scary warning in
step #3.
When #3 happens, PTRACE_ATTACH usually fails with ESRCH, but sometimes
we'll see EPERM as well. That happens when the kernel still has the
thread in its task list, but the thread is marked as dead.
Unfortunately, EPERM is ambiguous and we'll get it also on other
scenarios where the thread isn't dead, and in those cases, it's useful
to get a warning. To distiguish the cases, when we get an EPERM
failure, we open /proc/PID/status, and check the thread's state -- if
the /proc file no longer exists, or the state is "Z (Zombie)" or "X
(Dead)", we ignore the EPERM error silently; otherwise, we'll warn.
Unfortunately, there seems to be a kernel race here. Sometimes I get
EPERM, and then the /proc state still indicates "R (Running)"... If
we wait a bit and retry, we do end up seeing X or Z state, or get an
ESRCH. I thought of making GDB retry the attach a few times, but even
with a 500ms wait and 4 retries, I still see the warning sometimes. I
haven't been able to identify the kernel path that causes this yet,
but in any case, it looks like a kernel bug to me. As this just
results failure to suppress a warning that we've been printing since
about forever anyway, I'm just making the test cope with it, and issue
an XFAIL.
gdb/gdbserver/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_attach_fail_reason_string): Move to
nat/linux-ptrace.c, and rename.
(linux_attach_lwp): Update comment.
(attach_proc_task_lwp_callback): New function.
(linux_attach): Adjust to rename and use
linux_proc_attach_tgid_threads.
(linux_attach_fail_reason_string): Delete declaration.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-nat.c (attach_proc_task_lwp_callback): New function.
(linux_nat_attach): Use linux_proc_attach_tgid_threads.
(wait_lwp, linux_nat_filter_event): If not set yet, set the lwp's
ptrace option flags.
* linux-nat.h (struct lwp_info) <must_set_ptrace_flags>: New
field.
* nat/linux-procfs.c: Include <dirent.h>.
(linux_proc_get_int): New parameter "warn". Handle it.
(linux_proc_get_tgid): Adjust.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this.
(linux_proc_pid_get_state): New function, factored out from
(linux_proc_pid_has_state): ... this. Add new parameter "warn"
and handle it.
(linux_proc_pid_is_gone): New function.
(linux_proc_pid_is_stopped): Adjust.
(linux_proc_pid_is_zombie_maybe_warn)
(linux_proc_pid_is_zombie_nowarn): New functions.
(linux_proc_pid_is_zombie): Use
linux_proc_pid_is_zombie_maybe_warn.
(linux_proc_attach_tgid_threads): New function.
* nat/linux-procfs.h (linux_proc_get_tgid): Update comment.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this, and update comment.
(linux_proc_pid_is_gone): New declaration.
(linux_proc_pid_is_zombie): Update comment.
(linux_proc_pid_is_zombie_nowarn): New declaration.
(linux_proc_attach_lwp_func): New typedef.
(linux_proc_attach_tgid_threads): New declaration.
* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason): Adjust to
use nowarn functions.
(linux_ptrace_attach_fail_reason_string): Move here from
gdbserver/linux-low.c and rename.
(ptrace_supports_feature): If the current ptrace options are not
known yet, check them now, instead of asserting.
* nat/linux-ptrace.h (linux_ptrace_attach_fail_reason_string):
Declare.
2014-12-16 17:12:24 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"PTRACE_ATTACH %s, 0, 0 (OK)\n",
|
|
|
|
|
target_pid_to_str (ptid));
|
|
|
|
|
|
|
|
|
|
lp = add_lwp (ptid);
|
|
|
|
|
|
|
|
|
|
/* The next time we wait for this LWP we'll see a SIGSTOP as
|
|
|
|
|
PTRACE_ATTACH brings it to a halt. */
|
|
|
|
|
lp->signalled = 1;
|
|
|
|
|
|
|
|
|
|
/* We need to wait for a stop before being able to make the
|
|
|
|
|
next ptrace call on this LWP. */
|
|
|
|
|
lp->must_set_ptrace_flags = 1;
|
Fix PR gdb/19828: gdb -p <process from a container>: internal error
When GDB attaches to a process, it looks at the /proc/PID/task/ dir
for all clone threads of that process, and attaches to each of them.
Usually, if there is more than one clone thread, it means the program
is multi threaded and linked with pthreads. Thus when GDB soon after
attaching finds and loads a libthread_db matching the process, it'll
add a thread to the thread list for each of the initially found
lower-level LWPs.
If, however, GDB fails to find/load a matching libthread_db, nothing
is adding the LWPs to the thread list. And because of that, "detach"
hits an internal error:
(gdb) PASS: gdb.threads/clone-attach-detach.exp: fg attach 1: attach
info threads
Id Target Id Frame
* 1 LWP 6891 "clone-attach-de" 0x00007f87e5fd0790 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:84
(gdb) FAIL: gdb.threads/clone-attach-detach.exp: fg attach 1: info threads shows two LWPs
detach
.../src/gdb/thread.c:1010: internal-error: is_executing: Assertion `tp' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
FAIL: gdb.threads/clone-attach-detach.exp: fg attach 1: detach (GDB internal error)
From here:
...
#8 0x00000000007ba7cc in internal_error (file=0x98ea68 ".../src/gdb/thread.c", line=1010, fmt=0x98ea30 "%s: Assertion `%s' failed.")
at .../src/gdb/common/errors.c:55
#9 0x000000000064bb83 in is_executing (ptid=...) at .../src/gdb/thread.c:1010
#10 0x00000000004c23bb in get_pending_status (lp=0x12c5cc0, status=0x7fffffffdc0c) at .../src/gdb/linux-nat.c:1235
#11 0x00000000004c2738 in detach_callback (lp=0x12c5cc0, data=0x0) at .../src/gdb/linux-nat.c:1317
#12 0x00000000004c1a2a in iterate_over_lwps (filter=..., callback=0x4c2599 <detach_callback>, data=0x0) at .../src/gdb/linux-nat.c:899
#13 0x00000000004c295c in linux_nat_detach (ops=0xe7bd30, args=0x0, from_tty=1) at .../src/gdb/linux-nat.c:1358
#14 0x000000000068284d in delegate_detach (self=0xe7bd30, arg1=0x0, arg2=1) at .../src/gdb/target-delegates.c:34
#15 0x0000000000694141 in target_detach (args=0x0, from_tty=1) at .../src/gdb/target.c:2241
#16 0x0000000000630582 in detach_command (args=0x0, from_tty=1) at .../src/gdb/infcmd.c:2975
...
Tested on x86-64 Fedora 23. Also confirmed the test passes against
gdbserver with "maint set target-non-stop".
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (attach_proc_task_lwp_callback): Mark the lwp
resumed, and add the thread to GDB's thread list.
testsuite/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* gdb.threads/clone-attach-detach.c: New file.
* gdb.threads/clone-attach-detach.exp: New file.
2016-05-24 15:47:57 +02:00
|
|
|
|
|
|
|
|
|
/* So that wait collects the SIGSTOP. */
|
|
|
|
|
lp->resumed = 1;
|
|
|
|
|
|
|
|
|
|
/* Also add the LWP to gdb's thread list, in case a
|
|
|
|
|
matching libthread_db is not found (or the process uses
|
|
|
|
|
raw clone). */
|
|
|
|
|
add_thread (lp->ptid);
|
|
|
|
|
set_running (lp->ptid, 1);
|
|
|
|
|
set_executing (lp->ptid, 1);
|
Linux: on attach, attach to lwps listed under /proc/$pid/task/
... instead of relying on libthread_db.
I wrote a test that attaches to a program that constantly spawns
short-lived threads, which exposed several issues. This is one of
them.
On Linux, we need to attach to all threads of a process (thread group)
individually. We currently rely on libthread_db to list the threads,
but that is problematic, because libthread_db relies on reading data
structures out of the inferior (which may well be corrupted). If
threads are being created or exiting just while we try to attach, we
may trip on inconsistencies in the inferior's thread list. To work
around that, when we see a seemingly corrupt list, we currently retry
a few times:
static void
thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new)
{
...
if (until_no_new)
{
/* Require 4 successive iterations which do not find any new threads.
The 4 is a heuristic: there is an inherent race here, and I have
seen that 2 iterations in a row are not always sufficient to
"capture" all threads. */
...
That heuristic may well fail, and when it does, we end up with threads
in the program that aren't under GDB's control. That's obviously bad
and results in quite mistifying failures, like e.g., the process dying
for seeminly no reason when a thread that wasn't attached trips on a
breakpoint.
There's really no reason to rely on libthread_db for this nowadays
when we have /proc mounted. In that case, which is the usual case, we
can list the LWPs from /proc/PID/task/. In fact, GDBserver is already
doing this. The patch factors out that code that knows to walk the
task/ directory out of GDBserver, and makes GDB use it too.
Like GDBserver, the patch makes GDB attach to LWPs and _not_ wait for
them to stop immediately. Instead, we just tag the LWP as having an
expected stop. Because we can only set the ptrace options when the
thread stops, we need a new flag in the lwp structure to keep track of
whether we've already set the ptrace options, just like in GDBserver.
Note that nothing issues any ptrace command to the threads between the
PTRACE_ATTACH and the stop, so this is safe (unlike one scenario
described in gdbserver's linux-low.c).
When we attach to a program that has threads exiting while we attach,
it's easy to race with a thread just exiting as we try to attach to
it, like:
#1 - get current list of threads
#2 - attach to each listed thread
#3 - ooops, attach failed, thread is already gone
As this is pretty normal, we shouldn't be issuing a scary warning in
step #3.
When #3 happens, PTRACE_ATTACH usually fails with ESRCH, but sometimes
we'll see EPERM as well. That happens when the kernel still has the
thread in its task list, but the thread is marked as dead.
Unfortunately, EPERM is ambiguous and we'll get it also on other
scenarios where the thread isn't dead, and in those cases, it's useful
to get a warning. To distiguish the cases, when we get an EPERM
failure, we open /proc/PID/status, and check the thread's state -- if
the /proc file no longer exists, or the state is "Z (Zombie)" or "X
(Dead)", we ignore the EPERM error silently; otherwise, we'll warn.
Unfortunately, there seems to be a kernel race here. Sometimes I get
EPERM, and then the /proc state still indicates "R (Running)"... If
we wait a bit and retry, we do end up seeing X or Z state, or get an
ESRCH. I thought of making GDB retry the attach a few times, but even
with a 500ms wait and 4 retries, I still see the warning sometimes. I
haven't been able to identify the kernel path that causes this yet,
but in any case, it looks like a kernel bug to me. As this just
results failure to suppress a warning that we've been printing since
about forever anyway, I'm just making the test cope with it, and issue
an XFAIL.
gdb/gdbserver/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_attach_fail_reason_string): Move to
nat/linux-ptrace.c, and rename.
(linux_attach_lwp): Update comment.
(attach_proc_task_lwp_callback): New function.
(linux_attach): Adjust to rename and use
linux_proc_attach_tgid_threads.
(linux_attach_fail_reason_string): Delete declaration.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-nat.c (attach_proc_task_lwp_callback): New function.
(linux_nat_attach): Use linux_proc_attach_tgid_threads.
(wait_lwp, linux_nat_filter_event): If not set yet, set the lwp's
ptrace option flags.
* linux-nat.h (struct lwp_info) <must_set_ptrace_flags>: New
field.
* nat/linux-procfs.c: Include <dirent.h>.
(linux_proc_get_int): New parameter "warn". Handle it.
(linux_proc_get_tgid): Adjust.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this.
(linux_proc_pid_get_state): New function, factored out from
(linux_proc_pid_has_state): ... this. Add new parameter "warn"
and handle it.
(linux_proc_pid_is_gone): New function.
(linux_proc_pid_is_stopped): Adjust.
(linux_proc_pid_is_zombie_maybe_warn)
(linux_proc_pid_is_zombie_nowarn): New functions.
(linux_proc_pid_is_zombie): Use
linux_proc_pid_is_zombie_maybe_warn.
(linux_proc_attach_tgid_threads): New function.
* nat/linux-procfs.h (linux_proc_get_tgid): Update comment.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this, and update comment.
(linux_proc_pid_is_gone): New declaration.
(linux_proc_pid_is_zombie): Update comment.
(linux_proc_pid_is_zombie_nowarn): New declaration.
(linux_proc_attach_lwp_func): New typedef.
(linux_proc_attach_tgid_threads): New declaration.
* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason): Adjust to
use nowarn functions.
(linux_ptrace_attach_fail_reason_string): Move here from
gdbserver/linux-low.c and rename.
(ptrace_supports_feature): If the current ptrace options are not
known yet, check them now, instead of asserting.
* nat/linux-ptrace.h (linux_ptrace_attach_fail_reason_string):
Declare.
2014-12-16 17:12:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
static void
|
2013-04-15 17:40:57 +02:00
|
|
|
|
linux_nat_attach (struct target_ops *ops, const char *args, int from_tty)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
|
|
|
|
struct lwp_info *lp;
|
|
|
|
|
int status;
|
2008-09-08 23:25:05 +02:00
|
|
|
|
ptid_t ptid;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
2011-04-27 15:29:15 +02:00
|
|
|
|
/* Make sure we report all signals during attach. */
|
2013-12-18 05:33:44 +01:00
|
|
|
|
linux_nat_pass_signals (ops, 0, NULL);
|
2011-04-27 15:29:15 +02:00
|
|
|
|
|
Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 16:14:14 +01:00
|
|
|
|
TRY
|
2012-03-13 16:02:25 +01:00
|
|
|
|
{
|
|
|
|
|
linux_ops->to_attach (ops, args, from_tty);
|
|
|
|
|
}
|
Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 16:14:14 +01:00
|
|
|
|
CATCH (ex, RETURN_MASK_ERROR)
|
2012-03-13 16:02:25 +01:00
|
|
|
|
{
|
|
|
|
|
pid_t pid = parse_pid_to_attach (args);
|
2018-01-17 18:33:57 +01:00
|
|
|
|
std::string reason = linux_ptrace_attach_fail_reason (pid);
|
2012-03-13 16:02:25 +01:00
|
|
|
|
|
2018-01-17 18:33:57 +01:00
|
|
|
|
if (!reason.empty ())
|
|
|
|
|
throw_error (ex.error, "warning: %s\n%s", reason.c_str (), ex.message);
|
PR server/16255: gdbserver cannot attach to a second inferior that is multi-threaded.
On Linux, we need to explicitly ptrace attach to all lwps of a
process. Because GDB might not be connected yet when an attach is
requested, and thus it may not be possible to activate thread_db, as
that requires access to symbols (IOW, gdbserver --attach), a while ago
we make linux_attach loop over the lwps as listed by /proc/PID/task to
find the lwps to attach to.
linux_attach_lwp_1 has:
...
if (initial)
/* If lwp is the tgid, we handle adding existing threads later.
Otherwise we just add lwp without bothering about any other
threads. */
ptid = ptid_build (lwpid, lwpid, 0);
else
{
/* Note that extracting the pid from the current inferior is
safe, since we're always called in the context of the same
process as this new thread. */
int pid = pid_of (current_inferior);
ptid = ptid_build (pid, lwpid, 0);
}
That "safe" comment referred to linux_attach_lwp being called by
thread-db.c. But this was clearly missed when a new call to
linux_attach_lwp_1 was added to linux_attach. As a result,
current_inferior will be set to some random process, and non-initial
lwps of the second inferior get assigned the pid of the wrong
inferior. E.g., in the case of attaching to two inferiors, for the
second inferior (and so on), non-initial lwps of the second inferior
get assigned the pid of the first inferior. This doesn't trigger on
the first inferior, when current_inferior is NULL, add_thread switches
the current inferior to the newly added thread.
Rather than making linux_attach switch current_inferior temporarily
(thus avoiding further reliance on global state), or making
linux_attach_lwp_1 get the tgid from /proc, which add extra syscalls,
and will be wrong in case of the user having originally attached
directly to a non-tgid lwp, and then that lwp spawning new clones (the
ptid.pid field of further new clones should be the same as the
original lwp's pid, which is not the tgid), we note that callers of
linux_attach_lwp/linux_attach_lwp_1 always have the right pid handy
already, so they can pass it down along with the lwpid.
The only other reason for the "initial" parameter is to error out
instead of warn in case of attach failure, when we're first attaching
to a process. There are only three callers of
linux_attach_lwp/linux_attach_lwp_1, and each wants to print a
different warn/error string, so we can just move the error/warn out of
linux_attach_lwp_1 to the callers, thus getting rid of the "initial"
parameter.
There really nothing gdbserver-specific about attaching to two
threaded processes, so this adds a new test under gdb.multi/. The
test passes cleanly against the native GNU/Linux target, but
fails/triggers the bug against GDBserver (before the patch), with the
native-extended-remote board (as plain remote doesn't support
multi-process).
Tested on x86_64 Fedora 17, with the native-extended-gdbserver board.
gdb/gdbserver/
2014-04-25 Pedro Alves <palves@redhat.com>
PR server/16255
* linux-low.c (linux_attach_fail_reason_string): New function.
(linux_attach_lwp): Delete.
(linux_attach_lwp_1): Rename to ...
(linux_attach_lwp): ... this. Take a ptid instead of a pid as
argument. Remove "initial" parameter. Return int instead of
void. Don't error or warn here.
(linux_attach): Adjust to call linux_attach_lwp. Call error on
failure to attach to the tgid. Call warning when failing to
attach to an lwp.
* linux-low.h (linux_attach_lwp): Take a ptid instead of a pid as
argument. Remove "initial" parameter. Return int instead of
void. Don't error or warn here.
(linux_attach_fail_reason_string): New declaration.
* thread-db.c (attach_thread): Adjust to linux_attach_lwp's
interface change. Use linux_attach_fail_reason_string.
gdb/
2014-04-25 Pedro Alves <palves@redhat.com>
PR server/16255
* common/linux-ptrace.c (linux_ptrace_attach_warnings): Rename to ...
(linux_ptrace_attach_fail_reason): ... this. Remove "warning: "
and newline from built string.
* common/linux-ptrace.h (linux_ptrace_attach_warnings): Rename to ...
(linux_ptrace_attach_fail_reason): ... this.
* linux-nat.c (linux_nat_attach): Adjust to use
linux_ptrace_attach_fail_reason.
gdb/testsuite/
2014-04-25 Simon Marchi <simon.marchi@ericsson.com>
Pedro Alves <palves@redhat.com>
PR server/16255
* gdb.multi/multi-attach.c: New file.
* gdb.multi/multi-attach.exp: New file.
2014-04-25 20:07:33 +02:00
|
|
|
|
else
|
2018-01-17 18:33:45 +01:00
|
|
|
|
throw_error (ex.error, "%s", ex.message);
|
2012-03-13 16:02:25 +01:00
|
|
|
|
}
|
Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 16:14:14 +01:00
|
|
|
|
END_CATCH
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
2008-09-08 23:25:05 +02:00
|
|
|
|
/* The ptrace base target adds the main thread with (pid,0,0)
|
|
|
|
|
format. Decorate it with lwp info. */
|
2013-09-30 13:50:12 +02:00
|
|
|
|
ptid = ptid_build (ptid_get_pid (inferior_ptid),
|
|
|
|
|
ptid_get_pid (inferior_ptid),
|
|
|
|
|
0);
|
2008-09-08 23:25:05 +02:00
|
|
|
|
thread_change_ptid (inferior_ptid, ptid);
|
|
|
|
|
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
/* Add the initial process as the first LWP to the list. */
|
[native x86 GNU/Linux] Access debug register mirror from the corresponding process.
While reviewing the native AArch64 patch, I noticed a problem:
On 02/06/2013 08:46 PM, Pedro Alves wrote:
>
>> > +static void
>> > +aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
>> > +{
>> > + struct arch_lwp_info *info = lwp->arch_private;
>> > +
>> > + /* NULL means this is the main thread still going through the shell,
>> > + or, no watchpoint has been set yet. In that case, there's
>> > + nothing to do. */
>> > + if (info == NULL)
>> > + return;
>> > +
>> > + if (DR_HAS_CHANGED (info->dr_changed_bp)
>> > + || DR_HAS_CHANGED (info->dr_changed_wp))
>> > + {
>> > + int tid = GET_LWP (lwp->ptid);
>> > + struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
> Hmm. This is always fetching the debug_reg_state of
> the current inferior, but may not be the inferior of lwp.
> I see the same bug on x86. Sorry about that. I'll fix it.
A natural fix would be to make xxx_get_debug_reg_state take an
inferior argument, but that doesn't work because of the case where we
detach breakpoints/watchpoints from the child fork, at a time there's
no inferior for the child fork at all. We do a nasty hack in
i386_inferior_data_get, but that relies on all callers pointing the
current inferior to the correct inferior, which isn't actually being
done by all callers, and I don't think we want to enforce that -- deep
in the bowls of linux-nat.c, there are many cases we resume lwps
behind the scenes, and it's be better to not have that code rely on
global state (as it doesn't today).
The fix is to decouple the watchpoints code from inferiors, making it
track target processes instead. This way, we can freely keep track of
the watchpoint mirrors for these processes behind the core's back.
Checkpoints also play dirty tricks with swapping the process behind
the inferior, so they get special treatment too in the patch (which
just amounts to calling a new hook). Instead of the old hack in
i386_inferior_data_get, where we returned a copy of the current
inferior's debug registers mirror, as soon as we detect a fork in the
target, we copy the debug register mirror from the parent to the child
process.
I don't have an old kernel handy to test, but I stepped through gdb doing
the watchpoint removal in the fork child in the watchpoint-fork test
seeing that the debug registers end up cleared in the child.
I didn't find the need for linux_nat_iterate_watchpoint_lwps. If
we use plain iterate_over_lwps instead, what happens is that
when removing watchpoints, that iterate_over_lwps doesn't actually
iterate over anything, since the fork child is not added to the
lwp list until later, at detach time, in linux_child_follow_fork.
And if we don't iterate over that lwp, we don't mark its debug
registers as needing update. But linux_child_follow_fork takes
care of doing that explicitly:
child_lp = add_lwp (inferior_ptid);
child_lp->stopped = 1;
child_lp->last_resume_kind = resume_stop;
make_cleanup (delete_lwp_cleanup, child_lp);
/* CHILD_LP has new PID, therefore linux_nat_new_thread is not called for it.
See i386_inferior_data_get for the Linux kernel specifics.
Ensure linux_nat_prepare_to_resume will reset the hardware debug
registers. It is done by the linux_nat_new_thread call, which is
being skipped in add_lwp above for the first lwp of a pid. */
gdb_assert (num_lwps (GET_PID (child_lp->ptid)) == 1);
if (linux_nat_new_thread != NULL)
linux_nat_new_thread (child_lp);
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (child_lp);
ptrace (PTRACE_DETACH, child_pid, 0, 0);
so unless I'm missing something (quite possible) it ends up all
the same. But, the !detach-on-fork, and the "follow-fork child" paths
should also call linux_nat_new_thread, and they don't presently. It
seems to me in those cases we're not clearing debug regs correctly
when that's needed. Instead of copying that bit that works around
add_lwp bypassing the linux_nat_new_thread call, I thought it'd
be better to add an add_initial_lwp call to be used in the case we
really need to bypass linux_nat_new_thread, and make
add_lwp always call linux_nat_new_thread.
i386_cleanup_dregs is rewritten to forget about the current process
debug mirrors, which takes cares of other i386 ports. Only a couple
of extra tweaks here and there were needed, as some targets wheren't
actually calling i386_cleanup_dregs.
Tested on Fedora 17 x86_64 -m64/-m32.
GDBserver already fetches the i386_debug_reg_state from the right
process, and, it doesn't handle forks at all, so no fix is needed over
there.
gdb/
2013-02-13 Pedro Alves <palves@redhat.com>
* amd64-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(amd64_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(amd64_linux_new_fork): New function.
(_initialize_amd64_linux_nat): Install amd64_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(i386_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(i386_linux_new_fork): New function.
(_initialize_i386_linux_nat): Install i386_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-nat.c (i386_init_dregs): Delete.
(i386_inferior_data, struct i386_inferior_data):
Delete.
(struct i386_process_info): New.
(i386_process_list): New global.
(i386_find_process_pid, i386_add_process, i386_process_info_get):
New functions.
(i386_inferior_data_get): Delete.
(i386_process_info_get): New function.
(i386_debug_reg_state): New parameter 'pid'. Reimplement.
(i386_forget_process): New function.
(i386_cleanup_dregs): Rewrite.
(i386_update_inferior_debug_regs, i386_insert_watchpoint)
(i386_remove_watchpoint, i386_region_ok_for_watchpoint)
(i386_stopped_data_address, i386_insert_hw_breakpoint)
(i386_remove_hw_breakpoint): Adjust to pass the current process id
to i386_debug_reg_state.
(i386_use_watchpoints): Don't register inferior data.
* i386-nat.h (i386_debug_reg_state): Add new 'pid' parameter, and
adjust comment.
(i386_forget_process): Declare.
* linux-fork.c (delete_fork): Call linux_nat_forget_process.
* linux-nat.c (linux_nat_new_fork, linux_nat_forget_process_hook):
New static globals.
(linux_child_follow_fork): Don't call linux_nat_new_thread here.
(add_initial_lwp): New, factored out from ...
(add_lwp): ... this. Don't check the number of lwps before
calling linux_nat_new_thread.
(linux_nat_iterate_watchpoint_lwps): Delete.
(linux_nat_attach): Use add_initial_lwp instead of add_lwp.
(linux_handle_extended_wait): Call the linux_nat_new_fork hook on
forks and vforks.
(linux_nat_wait_1): Use add_initial_lwp instead of add_lwp for the
initial lwp.
(linux_nat_kill, linux_nat_mourn_inferior): Call
linux_nat_forget_process.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New functions.
* linux-nat.h (linux_nat_iterate_watchpoint_lwps_ftype): Delete
type.
(linux_nat_iterate_watchpoint_lwps): Delete declaration.
(linux_nat_new_fork_ftype, linux_nat_forget_process_ftype): New
types.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New declarations.
* amd64fbsd-nat.c (super_mourn_inferior): New global.
(amd64fbsd_mourn_inferior): New function.
(_initialize_amd64fbsd_nat): Override to_mourn_inferior.
* windows-nat.c (windows_detach): Call i386_cleanup_dregs.
2013-02-13 15:59:49 +01:00
|
|
|
|
lp = add_initial_lwp (ptid);
|
2008-05-01 20:50:14 +02:00
|
|
|
|
|
2017-06-03 21:24:00 +02:00
|
|
|
|
status = linux_nat_post_attach_wait (lp->ptid, &lp->signalled);
|
2009-10-15 20:06:15 +02:00
|
|
|
|
if (!WIFSTOPPED (status))
|
|
|
|
|
{
|
|
|
|
|
if (WIFEXITED (status))
|
|
|
|
|
{
|
|
|
|
|
int exit_code = WEXITSTATUS (status);
|
|
|
|
|
|
Remove make_cleanup_restore_target_terminal
This removes make_cleanup_restore_target_terminal and generally
C++-ifies target terminal handling. It changes all target_terminal_*
functions to be static members of a new target_terminal class and
changes the cleanup to be a scoped_* class.
make_cleanup_override_quit_handler is also removed in favor of simply
using scoped_restore.
Note that there are some files in this patch that I could not compile.
Considering that some of the rewrites were automated, and that none of
these files involed cleanups, I feel that this is relatively safe.
Regression tested by the buildbot.
gdb/ChangeLog
2017-09-20 Tom Tromey <tom@tromey.com>
* windows-nat.c (get_windows_debug_event, windows_wait)
(do_initial_windows_stuff, windows_attach): Update.
* utils.c (vwarning, internal_vproblem): Update.
(ui_unregister_input_event_handler_cleanup)
(prepare_to_handle_input): Remove.
(class scoped_input_handler): New.
(defaulted_query, prompt_for_continue): Update.
* tui/tui-hooks.c (tui_refresh_frame_and_register_information):
Update.
* top.c (undo_terminal_modifications_before_exit): Update.
* target/target.h (target_terminal_init, target_terminal_inferior)
(target_terminal_ours): Don't declare.
(class target_terminal): New.
* target.h (target_terminal_is_inferior, target_terminal_is_ours)
(target_terminal_ours_for_output)
(make_cleanup_restore_target_terminal): Don't declare.
(target_terminal_info): Remove.
* target.c (enum terminal_state, terminal_state): Remove.
(target_terminal::terminal_state): Define.
(target_terminal::init): Rename from target_terminal_init.
(target_terminal::inferior): Rename from
target_terminal_inferior.
(target_terminal::ours): Rename from target_terminal_ours.
(target_terminal::ours_for_output): Rename from
target_terminal_ours_for_output.
(target_terminal::info): New method.
(cleanup_restore_target_terminal)
(make_cleanup_restore_target_terminal): Remove.
* solib.c (handle_solib_event): Update.
* remote.c (remote_serial_quit_handler): Update.
(remote_terminal_inferior, remote_wait_as): Update.
* record-full.c (record_full_wait_1): Update.
* nto-procfs.c (procfs_create_inferior): Update.
* nat/fork-inferior.c (startup_inferior): Update.
* mi/mi-interp.c (mi_new_thread, mi_thread_exit)
(mi_record_changed, mi_inferior_added, mi_inferior_appeared)
(mi_inferior_exit, mi_inferior_removed, mi_traceframe_changed)
(mi_tsv_created, mi_tsv_deleted, mi_tsv_modified)
(mi_breakpoint_created, mi_breakpoint_deleted)
(mi_breakpoint_modified, mi_on_resume, mi_solib_loaded)
(mi_solib_unloaded, mi_command_param_changed, mi_memory_changed)
(mi_user_selected_context_changed, report_initial_inferior):
Update.
* linux-nat.c (linux_nat_attach, linux_nat_terminal_ours)
(linux_nat_terminal_inferior): Update.
* infrun.c (follow_fork_inferior)
(handle_vfork_child_exec_or_exit, do_target_resume)
(check_curr_ui_sync_execution_done, handle_inferior_event_1)
(handle_signal_stop, maybe_remove_breakpoints, normal_stop):
Update.
* inflow.c (child_terminal_init, info_terminal_command): Update.
* infcmd.c (post_create_inferior, continue_1, prepare_one_step)
(attach_command): Update.
* infcall.c (call_thread_fsm_should_stop): Update.
* gnu-nat.c (gnu_attach): Update.
* extension.c (struct active_ext_lang_state)
(restore_active_ext_lang): Update.
* exceptions.c (print_flush): Update.
* event-top.c (async_enable_stdin, default_quit_handler): Update.
(struct quit_handler_cleanup_data, restore_quit_handler)
(restore_quit_handler_dtor, make_cleanup_override_quit_handler):
Remove.
* cp-support.c (gdb_demangle): Update.
* breakpoint.c (update_inserted_breakpoint_locations)
(insert_breakpoint_locations, handle_jit_event)
(disable_breakpoints_in_unloaded_shlib): Update.
* annotate.c (annotate_breakpoints_invalid)
(annotate_frames_invalid): Update.
gdb/gdbserver/ChangeLog
2017-09-20 Tom Tromey <tom@tromey.com>
* target.c (target_terminal::terminal_state): Define.
(target_terminal::init): Rename from target_terminal_init.
(target_terminal::inferior): Rename from
target_terminal_inferior.
(target_terminal::ours): Rename from target_terminal_ours.
(target_terminal::ours_for_output, target_terminal::info): New.
2017-09-20 05:56:36 +02:00
|
|
|
|
target_terminal::ours ();
|
Consolidate target_mourn_inferior between GDB and gdbserver
This patch consolidates the API of target_mourn_inferior between GDB
and gdbserver, in my continuing efforts to make sharing the
fork_inferior function possible between both.
GDB's version of the function did not care about the inferior's ptid
being mourned, but gdbserver's needed to know this information. Since
it actually makes sense to pass the ptid as an argument, instead of
depending on a global value directly (which GDB's version did), I
decided to make the generic API to accept it. I then went on and
extended all calls being made on GDB to include a ptid argument (which
ended up being inferior_ptid most of the times, anyway), and now we
have a more sane interface.
On GDB's side, after talking to Pedro a bit about it, we decided that
just an assertion to make sure that the ptid being passed is equal to
inferior_ptid would be enough for now, on the GDB side. We can remove
the assertion and perform more operations later if we ever pass
anything different than inferior_ptid.
Regression tested on our BuildBot, everything OK.
I'd appreciate a special look at gdb/windows-nat.c's modification
because I wasn't really sure what to do there. It seemed to me that
maybe I should build a ptid out of the process information there, but
then I am almost sure the assertion on GDB's side would trigger.
gdb/ChangeLog:
2016-09-19 Sergio Durigan Junior <sergiodj@redhat.com>
* darwin-nat.c (darwin_kill_inferior): Adjusting call to
target_mourn_inferior to include ptid_t argument.
* fork-child.c (startup_inferior): Likewise.
* gnu-nat.c (gnu_kill_inferior): Likewise.
* inf-ptrace.c (inf_ptrace_kill): Likewise.
* infrun.c (handle_inferior_event_1): Likewise.
* linux-nat.c (linux_nat_attach): Likewise.
(linux_nat_kill): Likewise.
* nto-procfs.c (interrupt_query): Likewise.
(procfs_interrupt): Likewise.
(procfs_kill_inferior): Likewise.
* procfs.c (procfs_kill_inferior): Likewise.
* record.c (record_mourn_inferior): Likewise.
* remote-sim.c (gdbsim_kill): Likewise.
* remote.c (remote_detach_1): Likewise.
(remote_kill): Likewise.
* target.c (target_mourn_inferior): Change declaration to accept
new ptid_t argument; use gdb_assert on it.
* target.h (target_mourn_inferior): Move function prototype from
here...
* target/target.h (target_mourn_inferior): ... to here. Adjust it
to accept new ptid_t argument.
* windows-nat.c (get_windows_debug_event): Adjusting call to
target_mourn_inferior to include ptid_t argument.
gdb/gdbserver/ChangeLog:
2016-09-19 Sergio Durigan Junior <sergiodj@redhat.com>
* server.c (start_inferior): Call target_mourn_inferior instead of
mourn_inferior; pass ptid_t argument to it.
(resume): Likewise.
(handle_target_event): Likewise.
* target.c (target_mourn_inferior): New function.
* target.h (mourn_inferior): Delete macro.
2016-09-12 05:45:31 +02:00
|
|
|
|
target_mourn_inferior (inferior_ptid);
|
2009-10-15 20:06:15 +02:00
|
|
|
|
if (exit_code == 0)
|
|
|
|
|
error (_("Unable to attach: program exited normally."));
|
|
|
|
|
else
|
|
|
|
|
error (_("Unable to attach: program exited with code %d."),
|
|
|
|
|
exit_code);
|
|
|
|
|
}
|
|
|
|
|
else if (WIFSIGNALED (status))
|
|
|
|
|
{
|
2012-05-24 18:39:15 +02:00
|
|
|
|
enum gdb_signal signo;
|
2009-10-15 20:06:15 +02:00
|
|
|
|
|
Remove make_cleanup_restore_target_terminal
This removes make_cleanup_restore_target_terminal and generally
C++-ifies target terminal handling. It changes all target_terminal_*
functions to be static members of a new target_terminal class and
changes the cleanup to be a scoped_* class.
make_cleanup_override_quit_handler is also removed in favor of simply
using scoped_restore.
Note that there are some files in this patch that I could not compile.
Considering that some of the rewrites were automated, and that none of
these files involed cleanups, I feel that this is relatively safe.
Regression tested by the buildbot.
gdb/ChangeLog
2017-09-20 Tom Tromey <tom@tromey.com>
* windows-nat.c (get_windows_debug_event, windows_wait)
(do_initial_windows_stuff, windows_attach): Update.
* utils.c (vwarning, internal_vproblem): Update.
(ui_unregister_input_event_handler_cleanup)
(prepare_to_handle_input): Remove.
(class scoped_input_handler): New.
(defaulted_query, prompt_for_continue): Update.
* tui/tui-hooks.c (tui_refresh_frame_and_register_information):
Update.
* top.c (undo_terminal_modifications_before_exit): Update.
* target/target.h (target_terminal_init, target_terminal_inferior)
(target_terminal_ours): Don't declare.
(class target_terminal): New.
* target.h (target_terminal_is_inferior, target_terminal_is_ours)
(target_terminal_ours_for_output)
(make_cleanup_restore_target_terminal): Don't declare.
(target_terminal_info): Remove.
* target.c (enum terminal_state, terminal_state): Remove.
(target_terminal::terminal_state): Define.
(target_terminal::init): Rename from target_terminal_init.
(target_terminal::inferior): Rename from
target_terminal_inferior.
(target_terminal::ours): Rename from target_terminal_ours.
(target_terminal::ours_for_output): Rename from
target_terminal_ours_for_output.
(target_terminal::info): New method.
(cleanup_restore_target_terminal)
(make_cleanup_restore_target_terminal): Remove.
* solib.c (handle_solib_event): Update.
* remote.c (remote_serial_quit_handler): Update.
(remote_terminal_inferior, remote_wait_as): Update.
* record-full.c (record_full_wait_1): Update.
* nto-procfs.c (procfs_create_inferior): Update.
* nat/fork-inferior.c (startup_inferior): Update.
* mi/mi-interp.c (mi_new_thread, mi_thread_exit)
(mi_record_changed, mi_inferior_added, mi_inferior_appeared)
(mi_inferior_exit, mi_inferior_removed, mi_traceframe_changed)
(mi_tsv_created, mi_tsv_deleted, mi_tsv_modified)
(mi_breakpoint_created, mi_breakpoint_deleted)
(mi_breakpoint_modified, mi_on_resume, mi_solib_loaded)
(mi_solib_unloaded, mi_command_param_changed, mi_memory_changed)
(mi_user_selected_context_changed, report_initial_inferior):
Update.
* linux-nat.c (linux_nat_attach, linux_nat_terminal_ours)
(linux_nat_terminal_inferior): Update.
* infrun.c (follow_fork_inferior)
(handle_vfork_child_exec_or_exit, do_target_resume)
(check_curr_ui_sync_execution_done, handle_inferior_event_1)
(handle_signal_stop, maybe_remove_breakpoints, normal_stop):
Update.
* inflow.c (child_terminal_init, info_terminal_command): Update.
* infcmd.c (post_create_inferior, continue_1, prepare_one_step)
(attach_command): Update.
* infcall.c (call_thread_fsm_should_stop): Update.
* gnu-nat.c (gnu_attach): Update.
* extension.c (struct active_ext_lang_state)
(restore_active_ext_lang): Update.
* exceptions.c (print_flush): Update.
* event-top.c (async_enable_stdin, default_quit_handler): Update.
(struct quit_handler_cleanup_data, restore_quit_handler)
(restore_quit_handler_dtor, make_cleanup_override_quit_handler):
Remove.
* cp-support.c (gdb_demangle): Update.
* breakpoint.c (update_inserted_breakpoint_locations)
(insert_breakpoint_locations, handle_jit_event)
(disable_breakpoints_in_unloaded_shlib): Update.
* annotate.c (annotate_breakpoints_invalid)
(annotate_frames_invalid): Update.
gdb/gdbserver/ChangeLog
2017-09-20 Tom Tromey <tom@tromey.com>
* target.c (target_terminal::terminal_state): Define.
(target_terminal::init): Rename from target_terminal_init.
(target_terminal::inferior): Rename from
target_terminal_inferior.
(target_terminal::ours): Rename from target_terminal_ours.
(target_terminal::ours_for_output, target_terminal::info): New.
2017-09-20 05:56:36 +02:00
|
|
|
|
target_terminal::ours ();
|
Consolidate target_mourn_inferior between GDB and gdbserver
This patch consolidates the API of target_mourn_inferior between GDB
and gdbserver, in my continuing efforts to make sharing the
fork_inferior function possible between both.
GDB's version of the function did not care about the inferior's ptid
being mourned, but gdbserver's needed to know this information. Since
it actually makes sense to pass the ptid as an argument, instead of
depending on a global value directly (which GDB's version did), I
decided to make the generic API to accept it. I then went on and
extended all calls being made on GDB to include a ptid argument (which
ended up being inferior_ptid most of the times, anyway), and now we
have a more sane interface.
On GDB's side, after talking to Pedro a bit about it, we decided that
just an assertion to make sure that the ptid being passed is equal to
inferior_ptid would be enough for now, on the GDB side. We can remove
the assertion and perform more operations later if we ever pass
anything different than inferior_ptid.
Regression tested on our BuildBot, everything OK.
I'd appreciate a special look at gdb/windows-nat.c's modification
because I wasn't really sure what to do there. It seemed to me that
maybe I should build a ptid out of the process information there, but
then I am almost sure the assertion on GDB's side would trigger.
gdb/ChangeLog:
2016-09-19 Sergio Durigan Junior <sergiodj@redhat.com>
* darwin-nat.c (darwin_kill_inferior): Adjusting call to
target_mourn_inferior to include ptid_t argument.
* fork-child.c (startup_inferior): Likewise.
* gnu-nat.c (gnu_kill_inferior): Likewise.
* inf-ptrace.c (inf_ptrace_kill): Likewise.
* infrun.c (handle_inferior_event_1): Likewise.
* linux-nat.c (linux_nat_attach): Likewise.
(linux_nat_kill): Likewise.
* nto-procfs.c (interrupt_query): Likewise.
(procfs_interrupt): Likewise.
(procfs_kill_inferior): Likewise.
* procfs.c (procfs_kill_inferior): Likewise.
* record.c (record_mourn_inferior): Likewise.
* remote-sim.c (gdbsim_kill): Likewise.
* remote.c (remote_detach_1): Likewise.
(remote_kill): Likewise.
* target.c (target_mourn_inferior): Change declaration to accept
new ptid_t argument; use gdb_assert on it.
* target.h (target_mourn_inferior): Move function prototype from
here...
* target/target.h (target_mourn_inferior): ... to here. Adjust it
to accept new ptid_t argument.
* windows-nat.c (get_windows_debug_event): Adjusting call to
target_mourn_inferior to include ptid_t argument.
gdb/gdbserver/ChangeLog:
2016-09-19 Sergio Durigan Junior <sergiodj@redhat.com>
* server.c (start_inferior): Call target_mourn_inferior instead of
mourn_inferior; pass ptid_t argument to it.
(resume): Likewise.
(handle_target_event): Likewise.
* target.c (target_mourn_inferior): New function.
* target.h (mourn_inferior): Delete macro.
2016-09-12 05:45:31 +02:00
|
|
|
|
target_mourn_inferior (inferior_ptid);
|
2009-10-15 20:06:15 +02:00
|
|
|
|
|
2012-05-24 18:39:15 +02:00
|
|
|
|
signo = gdb_signal_from_host (WTERMSIG (status));
|
2009-10-15 20:06:15 +02:00
|
|
|
|
error (_("Unable to attach: program terminated with signal "
|
|
|
|
|
"%s, %s."),
|
2012-05-24 18:39:15 +02:00
|
|
|
|
gdb_signal_to_name (signo),
|
|
|
|
|
gdb_signal_to_string (signo));
|
2009-10-15 20:06:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal_error (__FILE__, __LINE__,
|
|
|
|
|
_("unexpected status %d for PID %ld"),
|
2013-09-30 13:50:12 +02:00
|
|
|
|
status, (long) ptid_get_lwp (ptid));
|
2009-10-15 20:06:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-05-01 20:50:14 +02:00
|
|
|
|
lp->stopped = 1;
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
|
2008-05-01 20:50:14 +02:00
|
|
|
|
/* Save the wait status to report later. */
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
lp->resumed = 1;
|
2008-05-01 20:50:14 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LNA: waitpid %ld, saving status %s\n",
|
2013-09-30 13:50:12 +02:00
|
|
|
|
(long) ptid_get_pid (lp->ptid), status_to_str (status));
|
2008-03-25 13:20:10 +01:00
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
lp->status = status;
|
|
|
|
|
|
Linux: on attach, attach to lwps listed under /proc/$pid/task/
... instead of relying on libthread_db.
I wrote a test that attaches to a program that constantly spawns
short-lived threads, which exposed several issues. This is one of
them.
On Linux, we need to attach to all threads of a process (thread group)
individually. We currently rely on libthread_db to list the threads,
but that is problematic, because libthread_db relies on reading data
structures out of the inferior (which may well be corrupted). If
threads are being created or exiting just while we try to attach, we
may trip on inconsistencies in the inferior's thread list. To work
around that, when we see a seemingly corrupt list, we currently retry
a few times:
static void
thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new)
{
...
if (until_no_new)
{
/* Require 4 successive iterations which do not find any new threads.
The 4 is a heuristic: there is an inherent race here, and I have
seen that 2 iterations in a row are not always sufficient to
"capture" all threads. */
...
That heuristic may well fail, and when it does, we end up with threads
in the program that aren't under GDB's control. That's obviously bad
and results in quite mistifying failures, like e.g., the process dying
for seeminly no reason when a thread that wasn't attached trips on a
breakpoint.
There's really no reason to rely on libthread_db for this nowadays
when we have /proc mounted. In that case, which is the usual case, we
can list the LWPs from /proc/PID/task/. In fact, GDBserver is already
doing this. The patch factors out that code that knows to walk the
task/ directory out of GDBserver, and makes GDB use it too.
Like GDBserver, the patch makes GDB attach to LWPs and _not_ wait for
them to stop immediately. Instead, we just tag the LWP as having an
expected stop. Because we can only set the ptrace options when the
thread stops, we need a new flag in the lwp structure to keep track of
whether we've already set the ptrace options, just like in GDBserver.
Note that nothing issues any ptrace command to the threads between the
PTRACE_ATTACH and the stop, so this is safe (unlike one scenario
described in gdbserver's linux-low.c).
When we attach to a program that has threads exiting while we attach,
it's easy to race with a thread just exiting as we try to attach to
it, like:
#1 - get current list of threads
#2 - attach to each listed thread
#3 - ooops, attach failed, thread is already gone
As this is pretty normal, we shouldn't be issuing a scary warning in
step #3.
When #3 happens, PTRACE_ATTACH usually fails with ESRCH, but sometimes
we'll see EPERM as well. That happens when the kernel still has the
thread in its task list, but the thread is marked as dead.
Unfortunately, EPERM is ambiguous and we'll get it also on other
scenarios where the thread isn't dead, and in those cases, it's useful
to get a warning. To distiguish the cases, when we get an EPERM
failure, we open /proc/PID/status, and check the thread's state -- if
the /proc file no longer exists, or the state is "Z (Zombie)" or "X
(Dead)", we ignore the EPERM error silently; otherwise, we'll warn.
Unfortunately, there seems to be a kernel race here. Sometimes I get
EPERM, and then the /proc state still indicates "R (Running)"... If
we wait a bit and retry, we do end up seeing X or Z state, or get an
ESRCH. I thought of making GDB retry the attach a few times, but even
with a 500ms wait and 4 retries, I still see the warning sometimes. I
haven't been able to identify the kernel path that causes this yet,
but in any case, it looks like a kernel bug to me. As this just
results failure to suppress a warning that we've been printing since
about forever anyway, I'm just making the test cope with it, and issue
an XFAIL.
gdb/gdbserver/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_attach_fail_reason_string): Move to
nat/linux-ptrace.c, and rename.
(linux_attach_lwp): Update comment.
(attach_proc_task_lwp_callback): New function.
(linux_attach): Adjust to rename and use
linux_proc_attach_tgid_threads.
(linux_attach_fail_reason_string): Delete declaration.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-nat.c (attach_proc_task_lwp_callback): New function.
(linux_nat_attach): Use linux_proc_attach_tgid_threads.
(wait_lwp, linux_nat_filter_event): If not set yet, set the lwp's
ptrace option flags.
* linux-nat.h (struct lwp_info) <must_set_ptrace_flags>: New
field.
* nat/linux-procfs.c: Include <dirent.h>.
(linux_proc_get_int): New parameter "warn". Handle it.
(linux_proc_get_tgid): Adjust.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this.
(linux_proc_pid_get_state): New function, factored out from
(linux_proc_pid_has_state): ... this. Add new parameter "warn"
and handle it.
(linux_proc_pid_is_gone): New function.
(linux_proc_pid_is_stopped): Adjust.
(linux_proc_pid_is_zombie_maybe_warn)
(linux_proc_pid_is_zombie_nowarn): New functions.
(linux_proc_pid_is_zombie): Use
linux_proc_pid_is_zombie_maybe_warn.
(linux_proc_attach_tgid_threads): New function.
* nat/linux-procfs.h (linux_proc_get_tgid): Update comment.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this, and update comment.
(linux_proc_pid_is_gone): New declaration.
(linux_proc_pid_is_zombie): Update comment.
(linux_proc_pid_is_zombie_nowarn): New declaration.
(linux_proc_attach_lwp_func): New typedef.
(linux_proc_attach_tgid_threads): New declaration.
* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason): Adjust to
use nowarn functions.
(linux_ptrace_attach_fail_reason_string): Move here from
gdbserver/linux-low.c and rename.
(ptrace_supports_feature): If the current ptrace options are not
known yet, check them now, instead of asserting.
* nat/linux-ptrace.h (linux_ptrace_attach_fail_reason_string):
Declare.
2014-12-16 17:12:24 +01:00
|
|
|
|
/* We must attach to every LWP. If /proc is mounted, use that to
|
|
|
|
|
find them now. The inferior may be using raw clone instead of
|
|
|
|
|
using pthreads. But even if it is using pthreads, thread_db
|
|
|
|
|
walks structures in the inferior's address space to find the list
|
|
|
|
|
of threads/LWPs, and those structures may well be corrupted.
|
|
|
|
|
Note that once thread_db is loaded, we'll still use it to list
|
|
|
|
|
threads and associate pthread info with each LWP. */
|
|
|
|
|
linux_proc_attach_tgid_threads (ptid_get_pid (lp->ptid),
|
|
|
|
|
attach_proc_task_lwp_callback);
|
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
if (target_can_async_p ())
|
Simplify target_async hook interface
All callers of target_async pass it the same callback
(inferior_event_handler). Since both common code and target backends
need to be able to put the target in and out of target async mode at
any given time, there's really no way that a different callback could
be passed. This commit simplifies things, and removes the indirection
altogether. Bonus: with this, gdb's target_async method ends up with
the same signature as gdbserver's.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog:
2015-03-25 Pedro Alves <palves@redhat.com>
* target.h <to_async>: Replace 'callback' and 'context' parameters
with boolean 'enable' parameter.
(target_async): Replace CALLBACK and CONTEXT parameters with
boolean ENABLE parameter.
* inf-loop.c (inferior_event_handler): Adjust.
* linux-nat.c (linux_nat_attach, linux_nat_resume)
(linux_nat_resume): Adjust.
(async_client_callback, async_client_context): Delete.
(handle_target_event): Call inferior_event_handler directly.
(linux_nat_async): Replace 'callback' and 'context' parameters
with boolean 'enable' parameter. Adjust. Remove references to
async_client_callback and async_client_context.
(linux_nat_close): Adjust.
* record-btrace.c (record_btrace_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_btrace_resume): Adjust.
* record-full.c (record_full_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_full_resume, record_full_core_resume): Adjust.
* remote.c (struct remote_state) <async_client_callback,
async_client_context>: Delete fields.
(remote_start_remote, extended_remote_attach_1, remote_resume)
(extended_remote_create_inferior): Adjust.
(remote_async_serial_handler): Call inferior_event_handler
directly.
(remote_async): Replace 'callback' and 'context' parameters with
boolean 'enable' parameter. Adjust.
* top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper):
Adjust.
* target-delegates.c: Regenerate.
2015-03-25 12:28:31 +01:00
|
|
|
|
target_async (1);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
/* Get pending signal of THREAD as a host signal number, for detaching
|
|
|
|
|
purposes. This is the signal the thread last stopped for, which we
|
|
|
|
|
need to deliver to the thread when detaching, otherwise, it'd be
|
|
|
|
|
suppressed/lost. */
|
|
|
|
|
|
2008-05-01 20:50:14 +02:00
|
|
|
|
static int
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
get_detach_signal (struct lwp_info *lp)
|
2008-05-01 20:50:14 +02:00
|
|
|
|
{
|
2012-05-24 18:51:47 +02:00
|
|
|
|
enum gdb_signal signo = GDB_SIGNAL_0;
|
2009-10-02 18:51:04 +02:00
|
|
|
|
|
|
|
|
|
/* If we paused threads momentarily, we may have stored pending
|
|
|
|
|
events in lp->status or lp->waitstatus (see stop_wait_callback),
|
|
|
|
|
and GDB core hasn't seen any signal for those threads.
|
|
|
|
|
Otherwise, the last signal reported to the core is found in the
|
|
|
|
|
thread object's stop_signal.
|
|
|
|
|
|
|
|
|
|
There's a corner case that isn't handled here at present. Only
|
|
|
|
|
if the thread stopped with a TARGET_WAITKIND_STOPPED does
|
|
|
|
|
stop_signal make sense as a real signal to pass to the inferior.
|
|
|
|
|
Some catchpoint related events, like
|
|
|
|
|
TARGET_WAITKIND_(V)FORK|EXEC|SYSCALL, have their stop_signal set
|
2012-05-24 18:51:47 +02:00
|
|
|
|
to GDB_SIGNAL_SIGTRAP when the catchpoint triggers. But,
|
2009-10-02 18:51:04 +02:00
|
|
|
|
those traps are debug API (ptrace in our case) related and
|
|
|
|
|
induced; the inferior wouldn't see them if it wasn't being
|
|
|
|
|
traced. Hence, we should never pass them to the inferior, even
|
|
|
|
|
when set to pass state. Since this corner case isn't handled by
|
|
|
|
|
infrun.c when proceeding with a signal, for consistency, neither
|
|
|
|
|
do we handle it here (or elsewhere in the file we check for
|
|
|
|
|
signal pass state). Normally SIGTRAP isn't set to pass state, so
|
|
|
|
|
this is really a corner case. */
|
|
|
|
|
|
|
|
|
|
if (lp->waitstatus.kind != TARGET_WAITKIND_IGNORE)
|
2012-05-24 18:51:47 +02:00
|
|
|
|
signo = GDB_SIGNAL_0; /* a pending ptrace event, not a real signal. */
|
2009-10-02 18:51:04 +02:00
|
|
|
|
else if (lp->status)
|
2012-05-24 18:39:15 +02:00
|
|
|
|
signo = gdb_signal_from_host (WSTOPSIG (lp->status));
|
Implement all-stop on top of a target running non-stop mode
This finally implements user-visible all-stop mode running with the
target_ops backend always in non-stop mode. This is a stepping stone
towards finer-grained control of threads, being able to do interesting
things like thread groups, associating groups with breakpoints, etc.
From the user's perspective, all-stop mode is really just a special
case of being able to stop and resume specific sets of threads, so it
makes sense to do this step first.
With this, even in all-stop, the target is no longer in charge of
stopping all threads before reporting an event to the core -- the core
takes care of it when it sees fit. For example, when "next"- or
"step"-ing, we can avoid stopping and resuming all threads at each
internal single-step, and instead only stop all threads when we're
about to present the stop to the user.
The implementation is almost straight forward, as the heavy lifting
has been done already in previous patches. Basically, we replace
checks for "set non-stop on/off" (the non_stop global), with calls to
a new target_is_non_stop_p function. In a few places, if "set
non-stop off", we stop all threads explicitly, and in a few other
places we resume all threads explicitly, making use of existing
methods that were added for teaching non-stop to step over breakpoints
without displaced stepping.
This adds a new "maint set target-non-stop on/off/auto" knob that
allows both disabling the feature if we find problems, and
force-enable it for development (useful when teaching a target about
this. The default is "auto", which means the feature is enabled if a
new target method says it should be enabled. The patch implements the
method in linux-nat.c, just for illustration, because it still returns
false. We'll need a few follow up fixes before turning it on by
default. This is a separate target method from indicating regular
non-stop support, because e.g., while e.g., native linux-nat.c is
close to regression free with all-stop-non-stop (with following
patches will fixing the remaining regressions), remote.c+gdbserver
will still need more fixing, even though it supports "set non-stop
on".
Tested on x86_64 Fedora 20, native, with and without "set displaced
off", and with and without "maint set target-non-stop on"; and also
against gdbserver.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* NEWS: Mention "maint set/show target-non-stop".
* breakpoint.c (update_global_location_list): Check
target_is_non_stop_p instead of non_stop.
* infcmd.c (attach_command_post_wait, attach_command): Likewise.
* infrun.c (show_can_use_displaced_stepping)
(can_use_displaced_stepping_p, start_step_over_inferior):
Likewise.
(internal_resume_ptid): New function.
(resume): Use it.
(proceed): Check target_is_non_stop_p instead of non_stop. If in
all-stop mode but the target is always in non-stop mode, start all
the other threads that are implicitly resumed too.
(for_each_just_stopped_thread, fetch_inferior_event)
(adjust_pc_after_break, stop_all_threads): Check
target_is_non_stop_p instead of non_stop.
(handle_inferior_event): Likewise. Handle detach-fork in all-stop
with the target always in non-stop mode.
(handle_signal_stop) <random signal>: Check target_is_non_stop_p
instead of non_stop.
(switch_back_to_stepped_thread): Check target_is_non_stop_p
instead of non_stop.
(keep_going_stepped_thread): Use internal_resume_ptid.
(stop_waiting): If in all-stop mode, and the target is in non-stop
mode, stop all threads.
(keep_going_pass): Likewise, when starting a new in-line step-over
sequence.
* linux-nat.c (get_pending_status, select_event_lwp)
(linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check
target_is_non_stop_p instead of non_stop.
(linux_nat_always_non_stop_p): New function.
(linux_nat_stop): Check target_is_non_stop_p instead of non_stop.
(linux_nat_add_target): Install linux_nat_always_non_stop_p.
* target-delegates.c: Regenerate.
* target.c (target_is_non_stop_p): New function.
(target_non_stop_enabled, target_non_stop_enabled_1): New globals.
(maint_set_target_non_stop_command)
(maint_show_target_non_stop_command): New functions.
(_initilize_target): Install "maint set/show target-non-stop"
commands.
* target.h (struct target_ops) <to_always_non_stop_p>: New field.
(target_non_stop_enabled): New declaration.
(target_is_non_stop_p): New declaration.
gdb/doc/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
target-non-stop".
2015-08-07 18:24:01 +02:00
|
|
|
|
else if (target_is_non_stop_p () && !is_executing (lp->ptid))
|
2009-10-02 18:51:04 +02:00
|
|
|
|
{
|
|
|
|
|
struct thread_info *tp = find_thread_ptid (lp->ptid);
|
2010-05-15 01:41:05 +02:00
|
|
|
|
|
2016-05-24 15:47:57 +02:00
|
|
|
|
if (tp->suspend.waitstatus_pending_p)
|
|
|
|
|
signo = tp->suspend.waitstatus.value.sig;
|
|
|
|
|
else
|
|
|
|
|
signo = tp->suspend.stop_signal;
|
2009-10-02 18:51:04 +02:00
|
|
|
|
}
|
Implement all-stop on top of a target running non-stop mode
This finally implements user-visible all-stop mode running with the
target_ops backend always in non-stop mode. This is a stepping stone
towards finer-grained control of threads, being able to do interesting
things like thread groups, associating groups with breakpoints, etc.
From the user's perspective, all-stop mode is really just a special
case of being able to stop and resume specific sets of threads, so it
makes sense to do this step first.
With this, even in all-stop, the target is no longer in charge of
stopping all threads before reporting an event to the core -- the core
takes care of it when it sees fit. For example, when "next"- or
"step"-ing, we can avoid stopping and resuming all threads at each
internal single-step, and instead only stop all threads when we're
about to present the stop to the user.
The implementation is almost straight forward, as the heavy lifting
has been done already in previous patches. Basically, we replace
checks for "set non-stop on/off" (the non_stop global), with calls to
a new target_is_non_stop_p function. In a few places, if "set
non-stop off", we stop all threads explicitly, and in a few other
places we resume all threads explicitly, making use of existing
methods that were added for teaching non-stop to step over breakpoints
without displaced stepping.
This adds a new "maint set target-non-stop on/off/auto" knob that
allows both disabling the feature if we find problems, and
force-enable it for development (useful when teaching a target about
this. The default is "auto", which means the feature is enabled if a
new target method says it should be enabled. The patch implements the
method in linux-nat.c, just for illustration, because it still returns
false. We'll need a few follow up fixes before turning it on by
default. This is a separate target method from indicating regular
non-stop support, because e.g., while e.g., native linux-nat.c is
close to regression free with all-stop-non-stop (with following
patches will fixing the remaining regressions), remote.c+gdbserver
will still need more fixing, even though it supports "set non-stop
on".
Tested on x86_64 Fedora 20, native, with and without "set displaced
off", and with and without "maint set target-non-stop on"; and also
against gdbserver.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* NEWS: Mention "maint set/show target-non-stop".
* breakpoint.c (update_global_location_list): Check
target_is_non_stop_p instead of non_stop.
* infcmd.c (attach_command_post_wait, attach_command): Likewise.
* infrun.c (show_can_use_displaced_stepping)
(can_use_displaced_stepping_p, start_step_over_inferior):
Likewise.
(internal_resume_ptid): New function.
(resume): Use it.
(proceed): Check target_is_non_stop_p instead of non_stop. If in
all-stop mode but the target is always in non-stop mode, start all
the other threads that are implicitly resumed too.
(for_each_just_stopped_thread, fetch_inferior_event)
(adjust_pc_after_break, stop_all_threads): Check
target_is_non_stop_p instead of non_stop.
(handle_inferior_event): Likewise. Handle detach-fork in all-stop
with the target always in non-stop mode.
(handle_signal_stop) <random signal>: Check target_is_non_stop_p
instead of non_stop.
(switch_back_to_stepped_thread): Check target_is_non_stop_p
instead of non_stop.
(keep_going_stepped_thread): Use internal_resume_ptid.
(stop_waiting): If in all-stop mode, and the target is in non-stop
mode, stop all threads.
(keep_going_pass): Likewise, when starting a new in-line step-over
sequence.
* linux-nat.c (get_pending_status, select_event_lwp)
(linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check
target_is_non_stop_p instead of non_stop.
(linux_nat_always_non_stop_p): New function.
(linux_nat_stop): Check target_is_non_stop_p instead of non_stop.
(linux_nat_add_target): Install linux_nat_always_non_stop_p.
* target-delegates.c: Regenerate.
* target.c (target_is_non_stop_p): New function.
(target_non_stop_enabled, target_non_stop_enabled_1): New globals.
(maint_set_target_non_stop_command)
(maint_show_target_non_stop_command): New functions.
(_initilize_target): Install "maint set/show target-non-stop"
commands.
* target.h (struct target_ops) <to_always_non_stop_p>: New field.
(target_non_stop_enabled): New declaration.
(target_is_non_stop_p): New declaration.
gdb/doc/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
target-non-stop".
2015-08-07 18:24:01 +02:00
|
|
|
|
else if (!target_is_non_stop_p ())
|
2008-05-01 20:50:14 +02:00
|
|
|
|
{
|
2009-10-02 18:51:04 +02:00
|
|
|
|
struct target_waitstatus last;
|
|
|
|
|
ptid_t last_ptid;
|
2008-07-11 00:58:37 +02:00
|
|
|
|
|
2009-10-02 18:51:04 +02:00
|
|
|
|
get_last_target_status (&last_ptid, &last);
|
2008-07-11 00:58:37 +02:00
|
|
|
|
|
2013-09-30 13:50:12 +02:00
|
|
|
|
if (ptid_get_lwp (lp->ptid) == ptid_get_lwp (last_ptid))
|
2009-10-02 18:51:04 +02:00
|
|
|
|
{
|
2009-05-24 23:06:53 +02:00
|
|
|
|
struct thread_info *tp = find_thread_ptid (lp->ptid);
|
2010-05-15 01:41:05 +02:00
|
|
|
|
|
gdb/
Rename and move inferior_thread_state and inferior_status.
* gdbthread.h (struct thread_control_state): New struct, move fields
step_range_start, step_range_end, step_frame_id, step_stack_frame_id,
trap_expected, proceed_to_finish, in_infcall, step_over_calls,
stop_step and stop_bpstat here from struct thread_info.
(struct thread_suspend_state): New struct, move field stop_signal here
from struct thread_info.
(struct thread_info): Move the fields above from this struct.
* inferior.h: Move the inferior_thread_state and inferior_status
declarations comment to their definitions at infrun.c.
(struct inferior_control_state): New struct, move field stop_soon from
struct inferior here.
(struct inferior_suspend_state): New empty struct.
(struct inferior): New fields control and suspend. Move out field
stop_soon.
* infrun.c (struct inferior_thread_state): Rename to ...
(infcall_suspend_state): ... here. Replace field stop_signal by
fields thread_suspend and inferior_suspend.
(save_inferior_thread_state): Rename to ...
(save_infcall_suspend_state): ... here. New variable inf. Update the
code for new fields.
(restore_inferior_thread_state): Rename to ...
(restore_infcall_suspend_state): ... here. New variable inf. Update
the code for new fields.
(do_restore_inferior_thread_state_cleanup): Rename to ...
(do_restore_infcall_suspend_state_cleanup): ... here.
(make_cleanup_restore_inferior_thread_state): Rename to ...
(make_cleanup_restore_infcall_suspend_state): ... here.
(discard_inferior_thread_state): Rename to ...
(discard_infcall_suspend_state): ... here.
(get_inferior_thread_state_regcache): Rename to ...
(get_infcall_suspend_state_regcache): ... here.
(struct inferior_status): Rename to ...
(struct infcall_control_state): ... here. Replace fields
step_range_start, step_range_end, step_frame_id, step_stack_frame_id,
trap_expected, proceed_to_finish, in_infcall, step_over_calls,
stop_step, stop_bpstat and stop_soon by fields thread_control and
inferior_control.
(save_inferior_status): Rename to ...
(save_infcall_control_state): ... here. Update the code for new
fields.
(restore_inferior_status): Rename to ...
(restore_infcall_control_state): ... here. Update the code for new
fields.
(do_restore_inferior_status_cleanup): Rename to ...
(do_restore_infcall_control_state_cleanup): ... here.
(make_cleanup_restore_inferior_status): Rename to ...
(make_cleanup_restore_infcall_control_state): ... here.
(discard_inferior_status): Rename to ...
(discard_infcall_control_state): ... here.
* alpha-tdep.c, breakpoint.c, dummy-frame.c, dummy-frame.h,
exceptions.c, fbsd-nat.c, gdbthread.h, infcall.c, infcmd.c,
inferior.c, inferior.h, infrun.c, linux-nat.c, mi/mi-interp.c,
mips-tdep.c, procfs.c, solib-irix.c, solib-osf.c, solib-spu.c,
solib-sunos.c, solib-svr4.c, thread.c, windows-nat.c: Update all the
references to the moved fields and renamed functions.
2010-11-28 05:31:25 +01:00
|
|
|
|
signo = tp->suspend.stop_signal;
|
2008-07-11 00:58:37 +02:00
|
|
|
|
}
|
2009-10-02 18:51:04 +02:00
|
|
|
|
}
|
2008-07-11 00:58:37 +02:00
|
|
|
|
|
2012-05-24 18:51:47 +02:00
|
|
|
|
if (signo == GDB_SIGNAL_0)
|
2009-10-02 18:51:04 +02:00
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"GPT: lwp %s has no pending signal\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
}
|
|
|
|
|
else if (!signal_pass_state (signo))
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
2011-01-05 23:22:53 +01:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"GPT: lwp %s had signal %s, "
|
|
|
|
|
"but it is in no pass state\n",
|
2009-10-02 18:51:04 +02:00
|
|
|
|
target_pid_to_str (lp->ptid),
|
2012-05-24 18:39:15 +02:00
|
|
|
|
gdb_signal_to_string (signo));
|
2008-05-01 20:50:14 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
2008-07-11 00:58:37 +02:00
|
|
|
|
{
|
2009-10-02 18:51:04 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"GPT: lwp %s has pending signal %s\n",
|
|
|
|
|
target_pid_to_str (lp->ptid),
|
2012-05-24 18:39:15 +02:00
|
|
|
|
gdb_signal_to_string (signo));
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
|
|
|
|
|
return gdb_signal_to_host (signo);
|
2008-07-11 00:58:37 +02:00
|
|
|
|
}
|
2008-05-01 20:50:14 +02:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
/* Detach from LP. If SIGNO_P is non-NULL, then it points to the
|
|
|
|
|
signal number that should be passed to the LWP when detaching.
|
|
|
|
|
Otherwise pass any pending signal the LWP may have, if any. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
detach_one_lwp (struct lwp_info *lp, int *signo_p)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
int lwpid = ptid_get_lwp (lp->ptid);
|
|
|
|
|
int signo;
|
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
gdb_assert (lp->status == 0 || WIFSTOPPED (lp->status));
|
|
|
|
|
|
|
|
|
|
if (debug_linux_nat && lp->status)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "DC: Pending %s for %s on detach.\n",
|
|
|
|
|
strsignal (WSTOPSIG (lp->status)),
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
|
2008-05-01 20:50:14 +02:00
|
|
|
|
/* If there is a pending SIGSTOP, get rid of it. */
|
|
|
|
|
if (lp->signalled)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
2008-05-01 20:50:14 +02:00
|
|
|
|
"DC: Sending SIGCONT to %s\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
kill_lwp (lwpid, SIGCONT);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
lp->signalled = 0;
|
|
|
|
|
}
|
|
|
|
|
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
if (signo_p == NULL)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
2008-05-01 20:50:14 +02:00
|
|
|
|
/* Pass on any pending signal for this LWP. */
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
signo = get_detach_signal (lp);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
signo = *signo_p;
|
2008-05-01 20:50:14 +02:00
|
|
|
|
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
/* Preparing to resume may try to write registers, and fail if the
|
|
|
|
|
lwp is zombie. If that happens, ignore the error. We'll handle
|
|
|
|
|
it below, when detach fails with ESRCH. */
|
|
|
|
|
TRY
|
|
|
|
|
{
|
gdb/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* linux-nat.c (linux_nat_new_thread): Change parameter to an lwp
pointer.
(linux_nat_prepare_to_resume): New global.
(lwp_free): New.
(purge_lwp_list): Use it.
(add_lwp): Call linux_nat_new_thread even on the first LWP.
Adjust to interface change.
(delete_lwp): Call lwp_free instead of xfree.
(detach_callback, linux_nat_detach, resume_lwp, linux_nat_resume)
(linux_handle_syscall_trap, linux_handle_extended_wait)
(linux_nat_filter_event, resume_stopped_resumed_lwps): Call
linux_nat_prepare_to_resume before resuming.
(linux_stop_lwp): New.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* linux-nat.h (struct arch_lwp_info): Forward declare.
(struct lwp_info) <arch_private>: New field.
(linux_stop_lwp): Declare.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* i386-nat.c (DR_NADDR, DR_STATUS, DR_CONTROL)
(struct i386_debug_reg_state): Move to i386-nat.h.
(dr_mirror): Comment.
(i386_debug_reg_state): New.
(i386_update_inferior_debug_regs): Simplify.
(i386_stopped_data_address): Use the debug register state from the
inferior, not from the local cache.
* i386-nat.h (struct i386_dr_low_type): Delete reset_addr and
unset_status fields. New get_addr and get_control fields.
(DR_FIRSTADDR, DR_LASTADDR, DR_CONTROL): Moved from i386-nat.c.
(DR_NADDR, DR_STATUS): New.
(struct i386_debug_reg_state): Moved from i386-nat.c.
* amd64-linux-nat.c (struct arch_lwp_info): New.
(amd64_linux_dr): Delete global.
(amd64_linux_dr_get_addr): New.
(amd64_linux_dr_get_control): New.
(amd64_linux_dr_unset_status): Delete.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_dr_reset_addr): Delete.
(update_debug_registers_callback): New.
(amd64_linux_dr_set_control): Reimplement.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_prepare_to_resume): New.
(amd64_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_amd64_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
amd64_linux_dr_get_control as i386_dr_low.get_control. Install
amd64_linux_dr_get_addr as i386_dr_low.get_addr. Install
amd64_linux_prepare_to_resume.
* i386-linux-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(struct arch_lwp_info): New.
(i386_linux_dr): Delete global.
(i386_linux_dr_set_control): Reimplement.
(i386_linux_dr_get_addr): New.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_dr_get_control): New.
(update_debug_registers_callback): New.
(i386_linux_dr_unset_status): Delete.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_prepare_to_resume): New.
(i386_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_i386_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386_linux_dr_get_control as i386_dr_low.get_control. Install
i386_linux_dr_get_addr as i386_dr_low.get_addr. Install
i386_linux_prepare_to_resume.
* arm-linux-nat.c (arm_linux_new_thread): Change parameter to an
lwp pointer. Adjust.
* ia64-linux-nat.c (ia64_linux_new_thread): Likewise.
* mips-linux-nat.c (mips_linux_new_thread): Likewise.
* ppc-linux-nat.c (ppc_linux_new_thread): Likewise.
* s390-nat.c (s390_fix_watch_points): Likewise.
* i386-darwin-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(i386_darwin_dr_reset_addr): Delete.
(i386_darwin_dr_get_addr): New.
(i386_darwin_dr_get_control): New.
* go32-nat.c
(go32_get_dr7, go32_get_dr): New.
(init_go32_ops): No longer install i386_dr_low.reset_addr.
Install go32_get_dr7 as i386_dr_low.get_control. Install
go32_get_dr as i386_dr_low.get_addr.
* i386bsd-nat.c (i386bsd_dr_get): New.
(i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_status): Use i386bsd_dr_get.
(i386bsd_dr_get_control): New.
* i386bsd-nat.h (i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_control): New.
* i386fbsd-nat.c (_initialize_i386fbsd_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386bsd_dr_get_control as i386_dr_low.get_control. Install
i386bsd_dr_get_addr as i386_dr_low.get_addr.
* windows-nat.c (init_windows_ops): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
cygwin_get_dr7 as i386_dr_low.get_control. Install cygwin_get_dr
as i386_dr_low.get_addr.
(cygwin_get_dr): New.
(cygwin_get_dr7): New.
gdb/testsuite/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* gdb.mi/watch-nonstop.c: New file.
* gdb.mi/mi-watch-nonstop.exp: New file.
2011-12-14 18:20:32 +01:00
|
|
|
|
if (linux_nat_prepare_to_resume != NULL)
|
|
|
|
|
linux_nat_prepare_to_resume (lp);
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
}
|
|
|
|
|
CATCH (ex, RETURN_MASK_ERROR)
|
|
|
|
|
{
|
|
|
|
|
if (!check_ptrace_stopped_lwp_gone (lp))
|
|
|
|
|
throw_exception (ex);
|
|
|
|
|
}
|
|
|
|
|
END_CATCH
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
if (ptrace (PTRACE_DETACH, lwpid, 0, signo) < 0)
|
|
|
|
|
{
|
|
|
|
|
int save_errno = errno;
|
|
|
|
|
|
|
|
|
|
/* We know the thread exists, so ESRCH must mean the lwp is
|
|
|
|
|
zombie. This can happen if one of the already-detached
|
|
|
|
|
threads exits the whole thread group. In that case we're
|
|
|
|
|
still attached, and must reap the lwp. */
|
|
|
|
|
if (save_errno == ESRCH)
|
|
|
|
|
{
|
|
|
|
|
int ret, status;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
ret = my_waitpid (lwpid, &status, __WALL);
|
|
|
|
|
if (ret == -1)
|
|
|
|
|
{
|
|
|
|
|
warning (_("Couldn't reap LWP %d while detaching: %s"),
|
|
|
|
|
lwpid, strerror (errno));
|
|
|
|
|
}
|
|
|
|
|
else if (!WIFEXITED (status) && !WIFSIGNALED (status))
|
|
|
|
|
{
|
|
|
|
|
warning (_("Reaping LWP %d while detaching "
|
|
|
|
|
"returned unexpected status 0x%x"),
|
|
|
|
|
lwpid, status);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
error (_("Can't detach %s: %s"), target_pid_to_str (lp->ptid),
|
|
|
|
|
safe_strerror (save_errno));
|
|
|
|
|
}
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
else if (debug_linux_nat)
|
|
|
|
|
{
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"PTRACE_DETACH (%s, %s, 0) (OK)\n",
|
|
|
|
|
target_pid_to_str (lp->ptid),
|
|
|
|
|
strsignal (signo));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete_lwp (lp->ptid);
|
|
|
|
|
}
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
static int
|
|
|
|
|
detach_callback (struct lwp_info *lp, void *data)
|
|
|
|
|
{
|
|
|
|
|
/* We don't actually detach from the thread group leader just yet.
|
|
|
|
|
If the thread group exits, we must reap the zombie clone lwps
|
|
|
|
|
before we're able to reap the leader. */
|
|
|
|
|
if (ptid_get_lwp (lp->ptid) != ptid_get_pid (lp->ptid))
|
|
|
|
|
detach_one_lwp (lp, NULL);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-01-19 17:47:57 +01:00
|
|
|
|
linux_nat_detach (struct target_ops *ops, inferior *inf, int from_tty)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
struct lwp_info *main_lwp;
|
Make linux_nat_detach/thread_db_detach use the inferior parameter
This patch makes these two functions actually use the inferior parameter
added by the previous patch, instead of reading inferior_ptid. I chose
these two, because they are the one actually used when I detach on my
GNU/Linux system, so they were easy to test.
I took the opportunity to pass the inferior being detached to
inf_ptrace_detach_success, so it could use it too. From there, it made
sense to add an overload of detach_inferior that takes the inferior
directly rather than the pid, to avoid having to pass inf->pid only for
the callee to look up the inferior structure by pid.
gdb/ChangeLog:
* inf-ptrace.c (inf_ptrace_detach): Adjust call to
inf_ptrace_detach_success.
(inf_ptrace_detach_success): Add inferior parameter, use it
instead of inferior_ptid, pass it to detach_inferior.
* inf-ptrace.h (inf_ptrace_detach_success): Add inferior
parameter.
* inferior.c (detach_inferior): Add overload that takes an
inferior object.
* inferior.h (detach_inferior): Likewise.
* linux-nat.c (linux_nat_detach): Use the inf parameter, don't
use inferior_ptid, adjust call to inf_ptrace_detach_success.
* linux-thread-db.c (thread_db_detach): Use inf parameter.
2018-01-19 17:48:11 +01:00
|
|
|
|
int pid = inf->pid;
|
2008-05-01 20:50:14 +02:00
|
|
|
|
|
2012-07-16 21:07:16 +02:00
|
|
|
|
/* Don't unregister from the event loop, as there may be other
|
|
|
|
|
inferiors running. */
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
|
2008-07-11 00:58:37 +02:00
|
|
|
|
/* Stop all threads before detaching. ptrace requires that the
|
|
|
|
|
thread is stopped to sucessfully detach. */
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
iterate_over_lwps (pid_to_ptid (pid), stop_callback, NULL);
|
2008-07-11 00:58:37 +02:00
|
|
|
|
/* ... and wait until all of them have reported back that
|
|
|
|
|
they're no longer running. */
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
iterate_over_lwps (pid_to_ptid (pid), stop_wait_callback, NULL);
|
2008-07-11 00:58:37 +02:00
|
|
|
|
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
iterate_over_lwps (pid_to_ptid (pid), detach_callback, NULL);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
/* Only the initial process should be left right now. */
|
Make linux_nat_detach/thread_db_detach use the inferior parameter
This patch makes these two functions actually use the inferior parameter
added by the previous patch, instead of reading inferior_ptid. I chose
these two, because they are the one actually used when I detach on my
GNU/Linux system, so they were easy to test.
I took the opportunity to pass the inferior being detached to
inf_ptrace_detach_success, so it could use it too. From there, it made
sense to add an overload of detach_inferior that takes the inferior
directly rather than the pid, to avoid having to pass inf->pid only for
the callee to look up the inferior structure by pid.
gdb/ChangeLog:
* inf-ptrace.c (inf_ptrace_detach): Adjust call to
inf_ptrace_detach_success.
(inf_ptrace_detach_success): Add inferior parameter, use it
instead of inferior_ptid, pass it to detach_inferior.
* inf-ptrace.h (inf_ptrace_detach_success): Add inferior
parameter.
* inferior.c (detach_inferior): Add overload that takes an
inferior object.
* inferior.h (detach_inferior): Likewise.
* linux-nat.c (linux_nat_detach): Use the inf parameter, don't
use inferior_ptid, adjust call to inf_ptrace_detach_success.
* linux-thread-db.c (thread_db_detach): Use inf parameter.
2018-01-19 17:48:11 +01:00
|
|
|
|
gdb_assert (num_lwps (pid) == 1);
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
|
|
|
|
|
main_lwp = find_lwp_pid (pid_to_ptid (pid));
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
2008-12-28 17:14:57 +01:00
|
|
|
|
if (forks_exist_p ())
|
|
|
|
|
{
|
|
|
|
|
/* Multi-fork case. The current inferior_ptid is being detached
|
|
|
|
|
from, but there are other viable forks to debug. Detach from
|
|
|
|
|
the current fork, and context-switch to the first
|
|
|
|
|
available. */
|
Remove args from target detach
I was looking into adding a parameter to target_detach, and was
wondering what the args parameter was. It seems like in the distant
past, it was possible to specify a signal number when detaching. That
signal was injected in the process before it was detached. There is an
example of code handling this in linux_nat_detach. With today's GDB, I
can't get this to work. Doing "detach 15" (15 == SIGTERM) doesn't work,
because detach is a prefix command and doesn't recognize the sub-command
15. Doing "detach inferiors 15" doesn't work because it expects a list
of inferior id to detach. Therefore, I don't think there's a way of
invoking detach_command with a non-NULL args. I also didn't find any
documentation related to this feature.
I assume that this feature stopped working when detach was made a prefix
command, which is in f73adfeb8bae36885e6ea248d12223ab0d5eb9cb (sorry,
there's no commit title) from 2006. Given that this feature was broken
for such a long time and we haven't heard anything (AFAIK, I did not
find any related bug), I think it's safe to remove it, as well as the
args parameter to target_detach. If someone wants to re-introduce it, I
would suggest rethinking the user interface, and in particular would
suggest using signal name instead of numbers.
I tried to fix all the impacted code, but I might have forgotten some
spots. It shouldn't be hard to fix if that's the case. I also couldn't
build-test everything I changed, especially the nto and solaris stuff.
gdb/ChangeLog:
* target.h (struct target_ops) <to_detach>: Remove args
parameter.
(target_detach): Likewise.
* target.c (dispose_inferior): Adjust.
(target_detach): Remove args parameter, adjust.
* aix-thread.c (aix_thread_detach): Adjust.
* corefile.c (core_file_command): Adjust.
* corelow.c (core_detach): Adjust.
* darwin-nat.c (darwin_detach): Adjust.
* gnu-nat.c (gnu_detach): Adjust.
* inf-ptrace.c (inf_ptrace_detach): Adjust.
* infcmd.c (detach_command): Adjust
* infrun.c (follow_fork_inferior): Adjust.
(handle_vfork_child_exec_or_exit): Adjust.
* linux-fork.c (linux_fork_detach): Remove args parameter.
* linux-fork.h (linux_fork_detach): Likewise.
* linux-nat.c (linux_nat_detach): Likewise, and adjust.
* linux-thread-db.c (thread_db_detach): Likewise.
* nto-procfs.c (procfs_detach): Likewise.
* procfs.c (procfs_detach): Likewise.
(do_detach): Remove signo parameter.
* record.c (record_detach): Remove args parameter.
* record.h (record_detach): Likewise.
* remote-sim.c (gdbsim_detach): Likewise.
* remote.c (remote_detach_1): Likewise.
(remote_detach): Likewise.
(extended_remote_detach): Likewise.
* sol-thread.c (sol_thread_detach): Likewise.
* target-delegates.c: Re-generate.
* top.c (struct qt_args) <args>: Remove field.
(kill_or_detach): Don't pass args.
(quit_force): Don't set args.
* windows-nat.c (windows_detach): Remove args parameter.
2018-01-19 17:47:24 +01:00
|
|
|
|
linux_fork_detach (from_tty);
|
2008-12-28 17:14:57 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
{
|
|
|
|
|
target_announce_detach (from_tty);
|
|
|
|
|
|
Remove args from target detach
I was looking into adding a parameter to target_detach, and was
wondering what the args parameter was. It seems like in the distant
past, it was possible to specify a signal number when detaching. That
signal was injected in the process before it was detached. There is an
example of code handling this in linux_nat_detach. With today's GDB, I
can't get this to work. Doing "detach 15" (15 == SIGTERM) doesn't work,
because detach is a prefix command and doesn't recognize the sub-command
15. Doing "detach inferiors 15" doesn't work because it expects a list
of inferior id to detach. Therefore, I don't think there's a way of
invoking detach_command with a non-NULL args. I also didn't find any
documentation related to this feature.
I assume that this feature stopped working when detach was made a prefix
command, which is in f73adfeb8bae36885e6ea248d12223ab0d5eb9cb (sorry,
there's no commit title) from 2006. Given that this feature was broken
for such a long time and we haven't heard anything (AFAIK, I did not
find any related bug), I think it's safe to remove it, as well as the
args parameter to target_detach. If someone wants to re-introduce it, I
would suggest rethinking the user interface, and in particular would
suggest using signal name instead of numbers.
I tried to fix all the impacted code, but I might have forgotten some
spots. It shouldn't be hard to fix if that's the case. I also couldn't
build-test everything I changed, especially the nto and solaris stuff.
gdb/ChangeLog:
* target.h (struct target_ops) <to_detach>: Remove args
parameter.
(target_detach): Likewise.
* target.c (dispose_inferior): Adjust.
(target_detach): Remove args parameter, adjust.
* aix-thread.c (aix_thread_detach): Adjust.
* corefile.c (core_file_command): Adjust.
* corelow.c (core_detach): Adjust.
* darwin-nat.c (darwin_detach): Adjust.
* gnu-nat.c (gnu_detach): Adjust.
* inf-ptrace.c (inf_ptrace_detach): Adjust.
* infcmd.c (detach_command): Adjust
* infrun.c (follow_fork_inferior): Adjust.
(handle_vfork_child_exec_or_exit): Adjust.
* linux-fork.c (linux_fork_detach): Remove args parameter.
* linux-fork.h (linux_fork_detach): Likewise.
* linux-nat.c (linux_nat_detach): Likewise, and adjust.
* linux-thread-db.c (thread_db_detach): Likewise.
* nto-procfs.c (procfs_detach): Likewise.
* procfs.c (procfs_detach): Likewise.
(do_detach): Remove signo parameter.
* record.c (record_detach): Remove args parameter.
* record.h (record_detach): Likewise.
* remote-sim.c (gdbsim_detach): Likewise.
* remote.c (remote_detach_1): Likewise.
(remote_detach): Likewise.
(extended_remote_detach): Likewise.
* sol-thread.c (sol_thread_detach): Likewise.
* target-delegates.c: Re-generate.
* top.c (struct qt_args) <args>: Remove field.
(kill_or_detach): Don't pass args.
(quit_force): Don't set args.
* windows-nat.c (windows_detach): Remove args parameter.
2018-01-19 17:47:24 +01:00
|
|
|
|
/* Pass on any pending signal for the last LWP. */
|
|
|
|
|
int signo = get_detach_signal (main_lwp);
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
|
|
|
|
|
detach_one_lwp (main_lwp, &signo);
|
|
|
|
|
|
Make linux_nat_detach/thread_db_detach use the inferior parameter
This patch makes these two functions actually use the inferior parameter
added by the previous patch, instead of reading inferior_ptid. I chose
these two, because they are the one actually used when I detach on my
GNU/Linux system, so they were easy to test.
I took the opportunity to pass the inferior being detached to
inf_ptrace_detach_success, so it could use it too. From there, it made
sense to add an overload of detach_inferior that takes the inferior
directly rather than the pid, to avoid having to pass inf->pid only for
the callee to look up the inferior structure by pid.
gdb/ChangeLog:
* inf-ptrace.c (inf_ptrace_detach): Adjust call to
inf_ptrace_detach_success.
(inf_ptrace_detach_success): Add inferior parameter, use it
instead of inferior_ptid, pass it to detach_inferior.
* inf-ptrace.h (inf_ptrace_detach_success): Add inferior
parameter.
* inferior.c (detach_inferior): Add overload that takes an
inferior object.
* inferior.h (detach_inferior): Likewise.
* linux-nat.c (linux_nat_detach): Use the inf parameter, don't
use inferior_ptid, adjust call to inf_ptrace_detach_success.
* linux-thread-db.c (thread_db_detach): Use inf parameter.
2018-01-19 17:48:11 +01:00
|
|
|
|
inf_ptrace_detach_success (ops, inf);
|
Fix failure to detach if process exits while detaching on Linux
This commit fixes detaching on Linux when some thread exits the whole
thread group (process) just while we're detaching.
On Linux, a ptracer must detach from each LWP individually, with
PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if
one of the already-detached threads causes the whole thread group to
exit (e.g., simply calls exit), the kernel force-kills the other
threads in the group, making them zombie, just as we're still
detaching them. Since PTRACE_DETACH against a zombie thread fails
with ESRCH, and gdb/gdbserver are not expecting this, the detach fails
with an error like: "Can't detach process: No such process.".
This patch detects this detach failure as normal, and instead of
erroring out, reaps the now-dead thread.
New test included, that exercises several different scenarios that
cause GDB/GDBserver to error out when it should not.
Tested on x86-64 GNU/Linux with {unix, native-gdbserver,
native-extended-gdbserver}
Note: without the previous fix, the "single-process + continue"
variant of the new test would fail with:
(gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent
continue
Continuing.
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
(gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue
gdb/gdbserver/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-low.c: Change interface to take the target lwp_info
pointer directly and return void. Handle detaching from a zombie
thread.
(linux_detach_lwp_callback): New function.
(linux_detach): Detach from the leader thread after detaching from
the clone threads.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* inf-ptrace.c (inf_ptrace_detach_success): New function, factored
out from ...
(inf_ptrace_detach): ... here.
* inf-ptrace.h (inf_ptrace_detach_success): New declaration.
* linux-nat.c (get_pending_status): Rename to ...
(get_detach_signal): ... this, and return a host signal instead of
filling in a wait status.
(detach_one_lwp): New function, factored out from detach_callback
and adjusted to handle detaching from a zombie thread.
(detach_callback): Skip the leader thread.
(linux_nat_detach): No longer defer to inf_ptrace_detach to detach
the leader thread, nor build a signal string to pass down.
Instead, use target_announce_detach, detach_one_lwp and
inf_ptrace_detach_success.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Antoine Tremblay <antoine.tremblay@ericsson.com>
* gdb.threads/process-dies-while-detaching.c: New file.
* gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
|
|
|
|
}
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-07 20:41:06 +01:00
|
|
|
|
/* Resume execution of the inferior process. If STEP is nonzero,
|
|
|
|
|
single-step it. If SIGNAL is nonzero, give it that signal. */
|
|
|
|
|
|
|
|
|
|
static void
|
Fix race exposed by gdb.threads/killed.exp
On GNU/Linux, this test sometimes FAILs like this:
(gdb) run
Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
ptrace: No such process.
(gdb)
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
Note the suspicious "No such process" line (that's errno==ESRCH).
Adding debug output we see:
linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Stopped (signal) (stopped)
LNW: waitpid(-1, ...) returned 18461, ERRNO-OK
LLW: waitpid 18461 received Trace/breakpoint trap (stopped)
LLW: Handling extended status 0x03057f
LHEW: Got clone event from LWP 18461, new child is LWP 18465
LNW: waitpid(-1, ...) returned 0, ERRNO-OK
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
sigchld
ptrace: No such process.
(gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Killed (terminated)
LLW: LWP 18465 exited.
LNW: waitpid(-1, ...) returned 18461, No child processes
LLW: waitpid 18461 received Killed (terminated)
Process 18461 exited
LNW: waitpid(-1, ...) returned -1, No child processes
LLW: exit
sigchld
infrun: target_wait (-1, status) =
infrun: 18461 [process 18461],
infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL
infrun: TARGET_WAITKIND_SIGNALLED
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
infrun: stop_waiting
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
The issue is that here:
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
The first line shows we had just resumed LWP 18465, which does:
void *
child_func (void *dummy)
{
kill (pid, SIGKILL);
exit (1);
}
So if the kernel manages to schedule that thread fast enough, the
process may be killed before GDB has a chance to resume LWP 18461.
GDBserver has code at the tail end of linux_resume_one_lwp to cope
with this:
~~~
ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread),
(PTRACE_TYPE_ARG3) 0,
/* Coerce to a uintptr_t first to avoid potential gcc warning
of coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG4) (uintptr_t) signal);
current_thread = saved_thread;
if (errno)
{
/* ESRCH from ptrace either means that the thread was already
running (an error) or that it is gone (a race condition). If
it's gone, we will get a notification the next time we wait,
so we can ignore the error. We could differentiate these
two, but it's tricky without waiting; the thread still exists
as a zombie, so sending it signal 0 would succeed. So just
ignore ESRCH. */
if (errno == ESRCH)
return;
perror_with_name ("ptrace");
}
~~~
However, that's not a complete fix, because between starting to handle
the resume request and getting that PTRACE_CONTINUE, we run other
ptrace calls that can also fail with ESRCH, and that end up throwing
an error (with perror_with_name).
In the case above, I indeed sometimes see resume_stopped_resumed_lwps
fail in the registers read:
resume_stopped_resumed_lwps (struct lwp_info *lp, void *data)
{
...
CORE_ADDR pc = regcache_read_pc (regcache);
Or e.g., in 32-bit mode, i386_linux_resume has several calls that can
throw too.
Whether to ignore ptrace errors or not depends on context that is only
available somewhere up the call chain. So the fix is to let ptrace
errors throw as they do today, and wrap the resume request in a
TRY/CATCH that swallows it iff the lwp that we were trying to resume
is no longer ptrace-stopped.
gdb/gdbserver/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
gdb/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
(resume_stopped_resumed_lwps): Try register reads in TRY/CATCH and
swallows errors if the LWP is gone. Use
linux_resume_one_lwp_throw instead of linux_resume_one_lwp.
2015-03-19 16:12:33 +01:00
|
|
|
|
linux_resume_one_lwp_throw (struct lwp_info *lp, int step,
|
|
|
|
|
enum gdb_signal signo)
|
2015-01-07 20:41:06 +01:00
|
|
|
|
{
|
|
|
|
|
lp->step = step;
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
|
|
|
|
|
/* stop_pc doubles as the PC the LWP had when it was last resumed.
|
|
|
|
|
We only presently need that if the LWP is stepped though (to
|
|
|
|
|
handle the case of stepping a breakpoint instruction). */
|
|
|
|
|
if (step)
|
|
|
|
|
{
|
|
|
|
|
struct regcache *regcache = get_thread_regcache (lp->ptid);
|
|
|
|
|
|
|
|
|
|
lp->stop_pc = regcache_read_pc (regcache);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
lp->stop_pc = 0;
|
|
|
|
|
|
2015-01-07 20:41:06 +01:00
|
|
|
|
if (linux_nat_prepare_to_resume != NULL)
|
|
|
|
|
linux_nat_prepare_to_resume (lp);
|
Linux/ptrace: don't convert ptids when asking inf-ptrace layer to resume LWP
Ref: https://sourceware.org/ml/gdb-patches/2015-03/msg00060.html
The record-btrace target can hit an assertion here:
Breakpoint 1, record_btrace_fetch_registers (ops=0x974bfc0 <record_btrace_ops>,
regcache=0x9a0a798, regno=8) at gdb/record-btrace.c:1202
1202 gdb_assert (tp != NULL);
(gdb) p regcache->ptid
$3 = {pid = 23856, lwp = 0, tid = 0}
The problem is that the linux-nat layer converts the ptid to a
single-process ptid before passing the request down to the inf-ptrace
layer, which loses information, and then record-btrace can't find the
corresponding thread in GDB's thread list:
(gdb) bt
#0 record_btrace_fetch_registers (ops=0x974bfc0 <record_btrace_ops>, regcache=0x9a0a798, regno=8)
at gdb/record-btrace.c:1202
#1 0x083f4ee2 in delegate_fetch_registers (self=0x974bfc0 <record_btrace_ops>, arg1=0x9a0a798,
arg2=8) at gdb/target-delegates.c:149
#2 0x08406562 in target_fetch_registers (regcache=0x9a0a798, regno=8)
at gdb/target.c:3279
#3 0x08355255 in regcache_raw_read (regcache=0x9a0a798, regnum=8,
buf=0xbfffe6c0 "¨\003\222\tÀ8kIøæÿ¿HO5\b\035]")
at gdb/regcache.c:643
#4 0x083558a7 in regcache_cooked_read (regcache=0x9a0a798, regnum=8,
buf=0xbfffe6c0 "¨\003\222\tÀ8kIøæÿ¿HO5\b\035]")
at gdb/regcache.c:734
#5 0x08355de3 in regcache_cooked_read_unsigned (regcache=0x9a0a798, regnum=8, val=0xbfffe738)
at gdb/regcache.c:838
#6 0x0827a106 in i386_linux_resume (ops=0x9737ca0 <linux_ops_saved>, ptid=..., step=1,
signal=GDB_SIGNAL_0) at gdb/i386-linux-nat.c:670
#7 0x08280c12 in linux_resume_one_lwp (lp=0x9a0a5b8, step=1, signo=GDB_SIGNAL_0)
at gdb/linux-nat.c:1529
#8 0x08281281 in linux_nat_resume (ops=0x98da608, ptid=..., step=1, signo=GDB_SIGNAL_0)
at gdb/linux-nat.c:1708
#9 0x0850738e in record_btrace_resume (ops=0x98da608, ptid=..., step=1, signal=GDB_SIGNAL_0)
at gdb/record-btrace.c:1760
...
The fix is just to not lose information, and let the intact ptid reach
record-btrace.c.
Tested on x86-64 Fedora 20, -m32.
gdb/ChangeLog:
2015-03-03 Pedro Alves <palves@redhat.com>
* i386-linux-nat.c (i386_linux_resume): Get the ptrace PID out of
the lwp field of ptid. Pass the full ptid to get_thread_regcache.
* inf-ptrace.c (get_ptrace_pid): New function.
(inf_ptrace_resume): Use it.
* linux-nat.c (linux_resume_one_lwp): Pass the LWP's ptid ummodified
to the lower layer.
2015-03-03 14:33:44 +01:00
|
|
|
|
linux_ops->to_resume (linux_ops, lp->ptid, step, signo);
|
Fix race exposed by gdb.threads/killed.exp
On GNU/Linux, this test sometimes FAILs like this:
(gdb) run
Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
ptrace: No such process.
(gdb)
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
Note the suspicious "No such process" line (that's errno==ESRCH).
Adding debug output we see:
linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Stopped (signal) (stopped)
LNW: waitpid(-1, ...) returned 18461, ERRNO-OK
LLW: waitpid 18461 received Trace/breakpoint trap (stopped)
LLW: Handling extended status 0x03057f
LHEW: Got clone event from LWP 18461, new child is LWP 18465
LNW: waitpid(-1, ...) returned 0, ERRNO-OK
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
sigchld
ptrace: No such process.
(gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Killed (terminated)
LLW: LWP 18465 exited.
LNW: waitpid(-1, ...) returned 18461, No child processes
LLW: waitpid 18461 received Killed (terminated)
Process 18461 exited
LNW: waitpid(-1, ...) returned -1, No child processes
LLW: exit
sigchld
infrun: target_wait (-1, status) =
infrun: 18461 [process 18461],
infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL
infrun: TARGET_WAITKIND_SIGNALLED
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
infrun: stop_waiting
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
The issue is that here:
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
The first line shows we had just resumed LWP 18465, which does:
void *
child_func (void *dummy)
{
kill (pid, SIGKILL);
exit (1);
}
So if the kernel manages to schedule that thread fast enough, the
process may be killed before GDB has a chance to resume LWP 18461.
GDBserver has code at the tail end of linux_resume_one_lwp to cope
with this:
~~~
ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread),
(PTRACE_TYPE_ARG3) 0,
/* Coerce to a uintptr_t first to avoid potential gcc warning
of coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG4) (uintptr_t) signal);
current_thread = saved_thread;
if (errno)
{
/* ESRCH from ptrace either means that the thread was already
running (an error) or that it is gone (a race condition). If
it's gone, we will get a notification the next time we wait,
so we can ignore the error. We could differentiate these
two, but it's tricky without waiting; the thread still exists
as a zombie, so sending it signal 0 would succeed. So just
ignore ESRCH. */
if (errno == ESRCH)
return;
perror_with_name ("ptrace");
}
~~~
However, that's not a complete fix, because between starting to handle
the resume request and getting that PTRACE_CONTINUE, we run other
ptrace calls that can also fail with ESRCH, and that end up throwing
an error (with perror_with_name).
In the case above, I indeed sometimes see resume_stopped_resumed_lwps
fail in the registers read:
resume_stopped_resumed_lwps (struct lwp_info *lp, void *data)
{
...
CORE_ADDR pc = regcache_read_pc (regcache);
Or e.g., in 32-bit mode, i386_linux_resume has several calls that can
throw too.
Whether to ignore ptrace errors or not depends on context that is only
available somewhere up the call chain. So the fix is to let ptrace
errors throw as they do today, and wrap the resume request in a
TRY/CATCH that swallows it iff the lwp that we were trying to resume
is no longer ptrace-stopped.
gdb/gdbserver/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
gdb/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
(resume_stopped_resumed_lwps): Try register reads in TRY/CATCH and
swallows errors if the LWP is gone. Use
linux_resume_one_lwp_throw instead of linux_resume_one_lwp.
2015-03-19 16:12:33 +01:00
|
|
|
|
|
|
|
|
|
/* Successfully resumed. Clear state that no longer makes sense,
|
|
|
|
|
and mark the LWP as running. Must not do this before resuming
|
|
|
|
|
otherwise if that fails other code will be confused. E.g., we'd
|
|
|
|
|
later try to stop the LWP and hang forever waiting for a stop
|
|
|
|
|
status. Note that we must not throw after this is cleared,
|
|
|
|
|
otherwise handle_zombie_lwp_error would get confused. */
|
2015-01-07 20:41:06 +01:00
|
|
|
|
lp->stopped = 0;
|
2016-05-24 15:47:57 +02:00
|
|
|
|
lp->core = -1;
|
Fix race exposed by gdb.threads/killed.exp
On GNU/Linux, this test sometimes FAILs like this:
(gdb) run
Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
ptrace: No such process.
(gdb)
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
Note the suspicious "No such process" line (that's errno==ESRCH).
Adding debug output we see:
linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Stopped (signal) (stopped)
LNW: waitpid(-1, ...) returned 18461, ERRNO-OK
LLW: waitpid 18461 received Trace/breakpoint trap (stopped)
LLW: Handling extended status 0x03057f
LHEW: Got clone event from LWP 18461, new child is LWP 18465
LNW: waitpid(-1, ...) returned 0, ERRNO-OK
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
sigchld
ptrace: No such process.
(gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Killed (terminated)
LLW: LWP 18465 exited.
LNW: waitpid(-1, ...) returned 18461, No child processes
LLW: waitpid 18461 received Killed (terminated)
Process 18461 exited
LNW: waitpid(-1, ...) returned -1, No child processes
LLW: exit
sigchld
infrun: target_wait (-1, status) =
infrun: 18461 [process 18461],
infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL
infrun: TARGET_WAITKIND_SIGNALLED
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
infrun: stop_waiting
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
The issue is that here:
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
The first line shows we had just resumed LWP 18465, which does:
void *
child_func (void *dummy)
{
kill (pid, SIGKILL);
exit (1);
}
So if the kernel manages to schedule that thread fast enough, the
process may be killed before GDB has a chance to resume LWP 18461.
GDBserver has code at the tail end of linux_resume_one_lwp to cope
with this:
~~~
ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread),
(PTRACE_TYPE_ARG3) 0,
/* Coerce to a uintptr_t first to avoid potential gcc warning
of coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG4) (uintptr_t) signal);
current_thread = saved_thread;
if (errno)
{
/* ESRCH from ptrace either means that the thread was already
running (an error) or that it is gone (a race condition). If
it's gone, we will get a notification the next time we wait,
so we can ignore the error. We could differentiate these
two, but it's tricky without waiting; the thread still exists
as a zombie, so sending it signal 0 would succeed. So just
ignore ESRCH. */
if (errno == ESRCH)
return;
perror_with_name ("ptrace");
}
~~~
However, that's not a complete fix, because between starting to handle
the resume request and getting that PTRACE_CONTINUE, we run other
ptrace calls that can also fail with ESRCH, and that end up throwing
an error (with perror_with_name).
In the case above, I indeed sometimes see resume_stopped_resumed_lwps
fail in the registers read:
resume_stopped_resumed_lwps (struct lwp_info *lp, void *data)
{
...
CORE_ADDR pc = regcache_read_pc (regcache);
Or e.g., in 32-bit mode, i386_linux_resume has several calls that can
throw too.
Whether to ignore ptrace errors or not depends on context that is only
available somewhere up the call chain. So the fix is to let ptrace
errors throw as they do today, and wrap the resume request in a
TRY/CATCH that swallows it iff the lwp that we were trying to resume
is no longer ptrace-stopped.
gdb/gdbserver/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
gdb/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
(resume_stopped_resumed_lwps): Try register reads in TRY/CATCH and
swallows errors if the LWP is gone. Use
linux_resume_one_lwp_throw instead of linux_resume_one_lwp.
2015-03-19 16:12:33 +01:00
|
|
|
|
lp->stop_reason = TARGET_STOPPED_BY_NO_REASON;
|
2015-01-07 20:41:06 +01:00
|
|
|
|
registers_changed_ptid (lp->ptid);
|
|
|
|
|
}
|
|
|
|
|
|
Fix race exposed by gdb.threads/killed.exp
On GNU/Linux, this test sometimes FAILs like this:
(gdb) run
Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
ptrace: No such process.
(gdb)
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
Note the suspicious "No such process" line (that's errno==ESRCH).
Adding debug output we see:
linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Stopped (signal) (stopped)
LNW: waitpid(-1, ...) returned 18461, ERRNO-OK
LLW: waitpid 18461 received Trace/breakpoint trap (stopped)
LLW: Handling extended status 0x03057f
LHEW: Got clone event from LWP 18461, new child is LWP 18465
LNW: waitpid(-1, ...) returned 0, ERRNO-OK
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
sigchld
ptrace: No such process.
(gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Killed (terminated)
LLW: LWP 18465 exited.
LNW: waitpid(-1, ...) returned 18461, No child processes
LLW: waitpid 18461 received Killed (terminated)
Process 18461 exited
LNW: waitpid(-1, ...) returned -1, No child processes
LLW: exit
sigchld
infrun: target_wait (-1, status) =
infrun: 18461 [process 18461],
infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL
infrun: TARGET_WAITKIND_SIGNALLED
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
infrun: stop_waiting
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
The issue is that here:
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
The first line shows we had just resumed LWP 18465, which does:
void *
child_func (void *dummy)
{
kill (pid, SIGKILL);
exit (1);
}
So if the kernel manages to schedule that thread fast enough, the
process may be killed before GDB has a chance to resume LWP 18461.
GDBserver has code at the tail end of linux_resume_one_lwp to cope
with this:
~~~
ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread),
(PTRACE_TYPE_ARG3) 0,
/* Coerce to a uintptr_t first to avoid potential gcc warning
of coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG4) (uintptr_t) signal);
current_thread = saved_thread;
if (errno)
{
/* ESRCH from ptrace either means that the thread was already
running (an error) or that it is gone (a race condition). If
it's gone, we will get a notification the next time we wait,
so we can ignore the error. We could differentiate these
two, but it's tricky without waiting; the thread still exists
as a zombie, so sending it signal 0 would succeed. So just
ignore ESRCH. */
if (errno == ESRCH)
return;
perror_with_name ("ptrace");
}
~~~
However, that's not a complete fix, because between starting to handle
the resume request and getting that PTRACE_CONTINUE, we run other
ptrace calls that can also fail with ESRCH, and that end up throwing
an error (with perror_with_name).
In the case above, I indeed sometimes see resume_stopped_resumed_lwps
fail in the registers read:
resume_stopped_resumed_lwps (struct lwp_info *lp, void *data)
{
...
CORE_ADDR pc = regcache_read_pc (regcache);
Or e.g., in 32-bit mode, i386_linux_resume has several calls that can
throw too.
Whether to ignore ptrace errors or not depends on context that is only
available somewhere up the call chain. So the fix is to let ptrace
errors throw as they do today, and wrap the resume request in a
TRY/CATCH that swallows it iff the lwp that we were trying to resume
is no longer ptrace-stopped.
gdb/gdbserver/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
gdb/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
(resume_stopped_resumed_lwps): Try register reads in TRY/CATCH and
swallows errors if the LWP is gone. Use
linux_resume_one_lwp_throw instead of linux_resume_one_lwp.
2015-03-19 16:12:33 +01:00
|
|
|
|
/* Called when we try to resume a stopped LWP and that errors out. If
|
|
|
|
|
the LWP is no longer in ptrace-stopped state (meaning it's zombie,
|
|
|
|
|
or about to become), discard the error, clear any pending status
|
|
|
|
|
the LWP may have, and return true (we'll collect the exit status
|
|
|
|
|
soon enough). Otherwise, return false. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
check_ptrace_stopped_lwp_gone (struct lwp_info *lp)
|
|
|
|
|
{
|
|
|
|
|
/* If we get an error after resuming the LWP successfully, we'd
|
|
|
|
|
confuse !T state for the LWP being gone. */
|
|
|
|
|
gdb_assert (lp->stopped);
|
|
|
|
|
|
|
|
|
|
/* We can't just check whether the LWP is in 'Z (Zombie)' state,
|
|
|
|
|
because even if ptrace failed with ESRCH, the tracee may be "not
|
|
|
|
|
yet fully dead", but already refusing ptrace requests. In that
|
|
|
|
|
case the tracee has 'R (Running)' state for a little bit
|
|
|
|
|
(observed in Linux 3.18). See also the note on ESRCH in the
|
|
|
|
|
ptrace(2) man page. Instead, check whether the LWP has any state
|
|
|
|
|
other than ptrace-stopped. */
|
|
|
|
|
|
|
|
|
|
/* Don't assume anything if /proc/PID/status can't be read. */
|
|
|
|
|
if (linux_proc_pid_is_trace_stopped_nowarn (ptid_get_lwp (lp->ptid)) == 0)
|
|
|
|
|
{
|
|
|
|
|
lp->stop_reason = TARGET_STOPPED_BY_NO_REASON;
|
|
|
|
|
lp->status = 0;
|
|
|
|
|
lp->waitstatus.kind = TARGET_WAITKIND_IGNORE;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Like linux_resume_one_lwp_throw, but no error is thrown if the LWP
|
|
|
|
|
disappears while we try to resume it. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
linux_resume_one_lwp (struct lwp_info *lp, int step, enum gdb_signal signo)
|
|
|
|
|
{
|
|
|
|
|
TRY
|
|
|
|
|
{
|
|
|
|
|
linux_resume_one_lwp_throw (lp, step, signo);
|
|
|
|
|
}
|
|
|
|
|
CATCH (ex, RETURN_MASK_ERROR)
|
|
|
|
|
{
|
|
|
|
|
if (!check_ptrace_stopped_lwp_gone (lp))
|
|
|
|
|
throw_exception (ex);
|
|
|
|
|
}
|
|
|
|
|
END_CATCH
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
/* Resume LP. */
|
|
|
|
|
|
2011-09-09 21:27:50 +02:00
|
|
|
|
static void
|
2012-06-28 18:34:04 +02:00
|
|
|
|
resume_lwp (struct lwp_info *lp, int step, enum gdb_signal signo)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
2011-09-09 21:27:50 +02:00
|
|
|
|
if (lp->stopped)
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
{
|
2014-12-15 18:00:55 +01:00
|
|
|
|
struct inferior *inf = find_inferior_ptid (lp->ptid);
|
2011-09-09 21:27:50 +02:00
|
|
|
|
|
|
|
|
|
if (inf->vfork_child != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"RC: Not resuming %s (vfork parent)\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
}
|
2015-01-07 20:41:06 +01:00
|
|
|
|
else if (!lwp_status_pending_p (lp))
|
2011-09-09 21:27:50 +02:00
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
2012-06-28 18:34:04 +02:00
|
|
|
|
"RC: Resuming sibling %s, %s, %s\n",
|
|
|
|
|
target_pid_to_str (lp->ptid),
|
|
|
|
|
(signo != GDB_SIGNAL_0
|
|
|
|
|
? strsignal (gdb_signal_to_host (signo))
|
|
|
|
|
: "0"),
|
|
|
|
|
step ? "step" : "resume");
|
2011-09-09 21:27:50 +02:00
|
|
|
|
|
2015-01-07 20:41:06 +01:00
|
|
|
|
linux_resume_one_lwp (lp, step, signo);
|
2011-09-09 21:27:50 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"RC: Not resuming sibling %s (has pending)\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
}
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
}
|
2011-09-09 21:27:50 +02:00
|
|
|
|
else
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
2011-09-09 21:27:50 +02:00
|
|
|
|
"RC: Not resuming sibling %s (not stopped)\n",
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
}
|
2011-09-09 21:27:50 +02:00
|
|
|
|
}
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
PR gdb/15713 - errors from i386_linux_resume lead to lock-up
linux_nat_resume is not considering that linux_ops->to_resume may throw:
/* Mark LWP as not stopped to prevent it from being continued by
linux_nat_resume_callback. */
lp->stopped = 0;
if (resume_many)
iterate_over_lwps (ptid, linux_nat_resume_callback, NULL);
If something within linux_nat_resume_callback throws, GDB leaves the
lwp_info as if the inferior was resumed, while it actually wasn't.
A couple examples, there are possibly others:
- i386_linux_resume calls target_read which calls QUIT.
- if the actual ptrace resumption fails in inf_ptrace_resume,
perror_with_name is called.
If the user tries to kill the inferior at this point (or quit, which
offers to kill), GDB locks up trying to stop the lwp -- if it is
already stopped no new waitpid event gets generated for it.
Fix this by setting the stopped flag earlier, as soon as we collect a
stop event with waitpid, and clearing it always only after resuming
the lwp successfully.
Tested on x86_64 Fedora 20. Confirmed the lock-up disappears using a
local hack that forces an error in inf_ptrace_resume.
Also fixes a little "set debug lin-lwp" annoyance. Currently we always see:
Continuing.
LLR: Preparing to resume process 6802, 0, inferior_ptid Thread 0x7ffff7fc7740 (LWP 6802)
^^^^^^^^
RC: Resuming sibling Thread 0x7ffff77c5700 (LWP 6807), 0, resume
RC: Resuming sibling Thread 0x7ffff7fc6700 (LWP 6806), 0, resume
RC: Not resuming sibling Thread 0x7ffff7fc7740 (LWP 6802) (not stopped)
^^^^^^^^^^^^^^^^^^^^^^^
LLR: PTRACE_CONT process 6802, 0 (resume event thread)
This patch gets rid of the "Not resuming sibling" line.
2014-05-29 Pedro Alves <palves@redhat.com>
PR gdb/15713
* linux-nat.c (linux_nat_resume_callback): Rename the second
parameter to 'except'. Skip LP if it points to EXCEPT.
(linux_nat_resume): Don't mark the event lwp as not stopped
before resuming sibling lwps. Instead ask
linux_nat_resume_callback to skip the event lwp. Mark it as not
stopped after actually resuming it.
(linux_handle_syscall_trap): Mark the lwp as not stopped after
resuming it.
(wait_lwp): Mark the lwp as stopped here.
(stop_wait_callback): Mark the lwp as not stopped right after
resuming it. Don't mark lwps as stopped here.
(linux_nat_filter_event): Mark the lwp as stopped earlier.
(linux_nat_wait_1): Don't mark dead lwps as stopped here.
2014-05-29 13:50:48 +02:00
|
|
|
|
/* Callback for iterate_over_lwps. If LWP is EXCEPT, do nothing.
|
|
|
|
|
Resume LWP with the last stop signal, if it is in pass state. */
|
2012-06-28 18:34:04 +02:00
|
|
|
|
|
2011-09-09 21:27:50 +02:00
|
|
|
|
static int
|
PR gdb/15713 - errors from i386_linux_resume lead to lock-up
linux_nat_resume is not considering that linux_ops->to_resume may throw:
/* Mark LWP as not stopped to prevent it from being continued by
linux_nat_resume_callback. */
lp->stopped = 0;
if (resume_many)
iterate_over_lwps (ptid, linux_nat_resume_callback, NULL);
If something within linux_nat_resume_callback throws, GDB leaves the
lwp_info as if the inferior was resumed, while it actually wasn't.
A couple examples, there are possibly others:
- i386_linux_resume calls target_read which calls QUIT.
- if the actual ptrace resumption fails in inf_ptrace_resume,
perror_with_name is called.
If the user tries to kill the inferior at this point (or quit, which
offers to kill), GDB locks up trying to stop the lwp -- if it is
already stopped no new waitpid event gets generated for it.
Fix this by setting the stopped flag earlier, as soon as we collect a
stop event with waitpid, and clearing it always only after resuming
the lwp successfully.
Tested on x86_64 Fedora 20. Confirmed the lock-up disappears using a
local hack that forces an error in inf_ptrace_resume.
Also fixes a little "set debug lin-lwp" annoyance. Currently we always see:
Continuing.
LLR: Preparing to resume process 6802, 0, inferior_ptid Thread 0x7ffff7fc7740 (LWP 6802)
^^^^^^^^
RC: Resuming sibling Thread 0x7ffff77c5700 (LWP 6807), 0, resume
RC: Resuming sibling Thread 0x7ffff7fc6700 (LWP 6806), 0, resume
RC: Not resuming sibling Thread 0x7ffff7fc7740 (LWP 6802) (not stopped)
^^^^^^^^^^^^^^^^^^^^^^^
LLR: PTRACE_CONT process 6802, 0 (resume event thread)
This patch gets rid of the "Not resuming sibling" line.
2014-05-29 Pedro Alves <palves@redhat.com>
PR gdb/15713
* linux-nat.c (linux_nat_resume_callback): Rename the second
parameter to 'except'. Skip LP if it points to EXCEPT.
(linux_nat_resume): Don't mark the event lwp as not stopped
before resuming sibling lwps. Instead ask
linux_nat_resume_callback to skip the event lwp. Mark it as not
stopped after actually resuming it.
(linux_handle_syscall_trap): Mark the lwp as not stopped after
resuming it.
(wait_lwp): Mark the lwp as stopped here.
(stop_wait_callback): Mark the lwp as not stopped right after
resuming it. Don't mark lwps as stopped here.
(linux_nat_filter_event): Mark the lwp as stopped earlier.
(linux_nat_wait_1): Don't mark dead lwps as stopped here.
2014-05-29 13:50:48 +02:00
|
|
|
|
linux_nat_resume_callback (struct lwp_info *lp, void *except)
|
2011-09-09 21:27:50 +02:00
|
|
|
|
{
|
2012-06-28 18:34:04 +02:00
|
|
|
|
enum gdb_signal signo = GDB_SIGNAL_0;
|
|
|
|
|
|
PR gdb/15713 - errors from i386_linux_resume lead to lock-up
linux_nat_resume is not considering that linux_ops->to_resume may throw:
/* Mark LWP as not stopped to prevent it from being continued by
linux_nat_resume_callback. */
lp->stopped = 0;
if (resume_many)
iterate_over_lwps (ptid, linux_nat_resume_callback, NULL);
If something within linux_nat_resume_callback throws, GDB leaves the
lwp_info as if the inferior was resumed, while it actually wasn't.
A couple examples, there are possibly others:
- i386_linux_resume calls target_read which calls QUIT.
- if the actual ptrace resumption fails in inf_ptrace_resume,
perror_with_name is called.
If the user tries to kill the inferior at this point (or quit, which
offers to kill), GDB locks up trying to stop the lwp -- if it is
already stopped no new waitpid event gets generated for it.
Fix this by setting the stopped flag earlier, as soon as we collect a
stop event with waitpid, and clearing it always only after resuming
the lwp successfully.
Tested on x86_64 Fedora 20. Confirmed the lock-up disappears using a
local hack that forces an error in inf_ptrace_resume.
Also fixes a little "set debug lin-lwp" annoyance. Currently we always see:
Continuing.
LLR: Preparing to resume process 6802, 0, inferior_ptid Thread 0x7ffff7fc7740 (LWP 6802)
^^^^^^^^
RC: Resuming sibling Thread 0x7ffff77c5700 (LWP 6807), 0, resume
RC: Resuming sibling Thread 0x7ffff7fc6700 (LWP 6806), 0, resume
RC: Not resuming sibling Thread 0x7ffff7fc7740 (LWP 6802) (not stopped)
^^^^^^^^^^^^^^^^^^^^^^^
LLR: PTRACE_CONT process 6802, 0 (resume event thread)
This patch gets rid of the "Not resuming sibling" line.
2014-05-29 Pedro Alves <palves@redhat.com>
PR gdb/15713
* linux-nat.c (linux_nat_resume_callback): Rename the second
parameter to 'except'. Skip LP if it points to EXCEPT.
(linux_nat_resume): Don't mark the event lwp as not stopped
before resuming sibling lwps. Instead ask
linux_nat_resume_callback to skip the event lwp. Mark it as not
stopped after actually resuming it.
(linux_handle_syscall_trap): Mark the lwp as not stopped after
resuming it.
(wait_lwp): Mark the lwp as stopped here.
(stop_wait_callback): Mark the lwp as not stopped right after
resuming it. Don't mark lwps as stopped here.
(linux_nat_filter_event): Mark the lwp as stopped earlier.
(linux_nat_wait_1): Don't mark dead lwps as stopped here.
2014-05-29 13:50:48 +02:00
|
|
|
|
if (lp == except)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2012-06-28 18:34:04 +02:00
|
|
|
|
if (lp->stopped)
|
|
|
|
|
{
|
|
|
|
|
struct thread_info *thread;
|
|
|
|
|
|
|
|
|
|
thread = find_thread_ptid (lp->ptid);
|
|
|
|
|
if (thread != NULL)
|
|
|
|
|
{
|
Always pass signals to the right thread
Currently, GDB can pass a signal to the wrong thread in several
different but related scenarios.
E.g., if thread 1 stops for signal SIGFOO, the user switches to thread
2, and then issues "continue", SIGFOO is actually delivered to thread
2, not thread 1. This obviously messes up programs that use
pthread_kill to send signals to specific threads.
This has been a known issue for a long while. Back in 2008 when I
made stop_signal be per-thread (2020b7ab), I kept the behavior -- see
code in 'proceed' being removed -- wanting to come back to it later.
The time has finally come now.
The patch fixes this -- on resumption, intercepted signals are always
delivered to the thread that had intercepted them.
Another example: if thread 1 stops for a breakpoint, the user switches
to thread 2, and then issues "signal SIGFOO", SIGFOO is actually
delivered to thread 1, not thread 2, because 'proceed' first switches
to thread 1 to step over its breakpoint... If the user deletes the
breakpoint before issuing "signal FOO", then the signal is delivered
to thread 2 (the current thread).
"signal SIGFOO" can be used for two things: inject a signal in the
program while the program/thread had stopped for none, bypassing
"handle nopass"; or changing/suppressing a signal the program had
stopped for. These scenarios are really two faces of the same coin,
and GDB can't really guess what the user is trying to do. GDB might
have intercepted signals in more than one thread even (see the new
signal-command-multiple-signals-pending.exp test). At least in the
inject case, it's obviously clear to me that the user means to deliver
the signal to the currently selected thread, so best is to make the
command's behavior consistent and easy to explain.
Then, if the user is trying to suppress/change a signal the program
had stopped for instead of injecting a new signal, but, the user had
changed threads meanwhile, then she will be surprised that with:
(gdb) continue
Thread 1 stopped for signal SIGFOO.
(gdb) thread 2
(gdb) signal SIGBAR
... GDB actually delivers SIGFOO to thread 1, and SIGBAR to thread 2
(with scheduler-locking off, which is the default, because then
"signal" or any other resumption command resumes all threads).
So the patch makes GDB detect that, and ask for confirmation:
(gdb) thread 1
[Switching to thread 1 (Thread 10979)]
(gdb) signal SIGUSR2
Note:
Thread 3 previously stopped with signal SIGUSR2, User defined signal 2.
Thread 2 previously stopped with signal SIGUSR1, User defined signal 1.
Continuing thread 1 (the current thread) with specified signal will
still deliver the signals noted above to their respective threads.
Continue anyway? (y or n)
All these scenarios are covered by the new tests.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2014-07-25 Pedro Alves <palves@redhat.com>
* NEWS: Mention signal passing and "signal" command changes.
* gdbthread.h (struct thread_suspend_state) <stop_signal>: Extend
comment.
* breakpoint.c (until_break_command): Adjust clear_proceed_status
call.
* infcall.c (run_inferior_call): Adjust clear_proceed_status call.
* infcmd.c (proceed_thread_callback, continue_1, step_once)
(jump_command): Adjust clear_proceed_status call.
(signal_command): Warn if other thread that are resumed have
signals that will be delivered. Adjust clear_proceed_status call.
(until_next_command, finish_command)
(proceed_after_attach_callback, attach_command_post_wait)
(attach_command): Adjust clear_proceed_status call.
* infrun.c (proceed_after_vfork_done): Likewise.
(proceed_after_attach_callback): Adjust comment.
(clear_proceed_status_thread): Clear stop_signal if not in pass
state.
(clear_proceed_status_callback): Delete.
(clear_proceed_status): New 'step' parameter. Only clear the
proceed status of threads the command being prepared is about to
resume.
(proceed): If passed in an explicit signal, override stop_signal
with it. Don't pass the last stop signal to the thread we're
resuming.
(init_wait_for_inferior): Adjust clear_proceed_status call.
(switch_back_to_stepped_thread): Clear the signal if it should not
be passed.
* infrun.h (clear_proceed_status): New 'step' parameter.
(user_visible_resume_ptid): Add comment.
* linux-nat.c (linux_nat_resume_callback): Don't check whether the
signal is in pass state.
* remote.c (append_pending_thread_resumptions): Likewise.
* mi/mi-main.c (proceed_thread): Adjust clear_proceed_status call.
gdb/doc/
2014-07-25 Pedro Alves <palves@redhat.com>
Eli Zaretskii <eliz@gnu.org>
* gdb.texinfo (Signaling) <signal command>: Explain what happens
with multi-threaded programs.
gdb/testsuite/
2014-07-25 Pedro Alves <palves@redhat.com>
* gdb.threads/signal-command-handle-nopass.c: New file.
* gdb.threads/signal-command-handle-nopass.exp: New file.
* gdb.threads/signal-command-multiple-signals-pending.c: New file.
* gdb.threads/signal-command-multiple-signals-pending.exp: New file.
* gdb.threads/signal-delivered-right-thread.c: New file.
* gdb.threads/signal-delivered-right-thread.exp: New file.
2014-07-25 17:57:31 +02:00
|
|
|
|
signo = thread->suspend.stop_signal;
|
2012-06-28 18:34:04 +02:00
|
|
|
|
thread->suspend.stop_signal = GDB_SIGNAL_0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resume_lwp (lp, 0, signo);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
resume_clear_callback (struct lwp_info *lp, void *data)
|
|
|
|
|
{
|
|
|
|
|
lp->resumed = 0;
|
2011-09-09 21:27:50 +02:00
|
|
|
|
lp->last_resume_kind = resume_stop;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
resume_set_callback (struct lwp_info *lp, void *data)
|
|
|
|
|
{
|
|
|
|
|
lp->resumed = 1;
|
2011-09-09 21:27:50 +02:00
|
|
|
|
lp->last_resume_kind = resume_continue;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
* corelow.c (get_core_registers): Adjust.
(core_file_thread_alive): Rename to...
(core_thread_alive): ... this.
(core_pid_to_str): Try gdbarch_core_pid_to_str first.
(init_core_ops): Adjust.
(coreops_suppress_target): Delete.
(_initialize_corelow): Unconditionally add core_ops.
* procfs.c: Include "inf-child.h".
(procfs_ops): Delete.
(init_procfs_ops): Delete. Reimplement as...
(procfs_target): ... this, inheriting from inf-child.
(procfs_attach, procfs_detach, procfs_fetch_registers): Adjust.
(procfs_prepare_to_store): Delete.
(procfs_store_registers, procfs_resume): Adjust.
(procfs_open): Delete.
(procfs_suppress_run): Delete.
(procfs_can_run): Delete.
(procfs_mourn_inferior): Adjust.
(procfs_init_inferior): Add target_ops parameter. Adjust.
(procfs_create_inferior): Don't pass procfs_init_inferior to
fork_inferior. Instead call it after fork_inferior returns.
(procfs_find_new_threads): Adjust.
(_initialize_procfs): Adjust to use procfs_target instead of
init_procfs_ops.
* sol-thread.c (orig_core_ops, sol_core_ops): Delete.
(lwp_to_thread): Use target_thread_alive.
(sol_thread_open): Delete.
(sol_thread_attach): Delete.
(sol_thread_detach, sol_thread_resume, sol_thread_wait)
(sol_thread_fetch_registers, sol_thread_store_registers): Adjust
to use find_target_beneath.
(sol_thread_prepare_to_store, sol_thread_xfer_memory): Delete.
(sol_thread_xfer_partial): Adjust to use find_target_beneath.
(sol_thread_files_info, sol_thread_kill_inferior): Delete.
(check_for_thread_db): New.
(sol_thread_notice_signals, sol_thread_create_inferior): Delete.
(sol_thread_new_objfile): Call check_for_thread_db.
(sol_thread_mourn_inferior): Adjust to use find_target_beneath.
(sol_thread_can_run): Delete.
(sol_thread_alive): Adjust to use find_target_beneath.
(sol_thread_stop): Delete.
(rw_common): Use target_write_memory or target_read_memory.
(ps_lgetregs, ps_lgetfpregs): Use target_fetch_registers.
(ps_lsetregs, ps_lsetfpregs): Use target_store_registers.
(solaris_pid_to_str): Remove check for libthread_db initialization
failing.
(sol_find_new_threads): Remove check for libthread_db
initialization failing, or for an invalid inferior_ptid. Adjust
to use find_target_beneath.
(sol_core_open, sol_core_close, sol_core_detach,
sol_core_files_info, sol_find_memory_regions,
sol_make_note_section, ignore): Delete.
(init_sol_thread_ops): Make it a thread_stratum target. Remove
unneeded callback settings.
(init_sol_core_ops): Delete.
(_initialize_sol_thread): No longer call init_sol_core_ops, set
procfs_suppress_run, or hack with core_ops.
* target.h (struct target_ops): Add a target_ops * parameter to
to_resume, to_fetch_registers, to_store_registers, to_thread_alive
and to_find_new_threads.
(target_fetch_registers, target_store_registers)
(target_thread_alive, target_find_new_threads): Redeclare as
function.
* target.c (update_current_target): Do not inherit or de_fault
to_resume, to_fetch_registers, to_store_registers,
to_thread_alive, to_find_new_threads.
(target_resume): Adjust.
(target_thread_alive, target_find_new_threads): New.
(debug_to_resume, debug_to_fetch_registers): Delete.
(target_fetch_registers): New.
(debug_to_store_registers): Delete.
(target_store_registers): New.
(debug_to_thread_alive, debug_to_find_new_threads): Delete.
(setup_target_debug): Adjust.
* gdbcore.h (core_ops): Delete declaration.
* inf-ptrace.c, linux-nat.c, remote.c, amd64-linux-nat.c,
inf-child.c, linux-thread-db.c, bsd-uthread.c, inf-ttrace.c,
i386-sol2-tdep.c, darwin-nat.c, gnu-nat.c, go32-nat.c,
hpux-thread.c, i386-linux-nat.c, i386fbsd-nat.c, monitor.c,
nto-procfs.c, remote-m32r-sdi.c, remote-mips.c, windows-nat.c,
alphabsd-nat.c, amd64bsd-nat.c, arm-linux-nat.c, armnbsd-nat.c,
bsd-kvm.c, hppa-hpux-nat.c, hppa-linux-nat.c, hppabsd-nat.c,
hppanbsd-nat.c, i386-darwin-nat.c, i386bsd-nat.c,
ia64-linux-nat.c, m32r-linux-nat.c, m68kbsd-nat.c,
m68klinux-nat.c, m88kbsd-nat.c, mips-linux-nat.c,
mips64obsd-nat.c, mipsnbsd-nat.c, ppc-linux-nat.c, ppcnbsd-nat.c,
ppcobsd-nat.c, remote-sim.c, rs6000-nat.c, s390-nat.c,
shnbsd-nat.c, sparc-nat.c, sparc-nat.h, spu-linux-nat.c,
vaxbsd-nat.c, xtensa-linux-nat.c: Adjust to target_ops changes.
* gdbarch.sh (core_pid_to_str): New gdbarch callback.
* gdbarch.h, gdbarch.c: Regenerate.
* sol2-tdep.c: Include "inferior.h".
(sol2_core_pid_to_str): New.
* sol2-tdep.h (sol2_core_pid_to_str): Declare.
* amd64-sol2-tdep.c (amd64_sol2_init_abi): Set it.
* sparc-sol2-tdep.c (sparc32_sol2_init_abi): Set it.
* sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Set it.
* i386-sol2-tdep.c (i386_sol2_init_abi): Set it.
2009-02-23 01:03:50 +01:00
|
|
|
|
linux_nat_resume (struct target_ops *ops,
|
2012-05-24 18:39:15 +02:00
|
|
|
|
ptid_t ptid, int step, enum gdb_signal signo)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
|
|
|
|
struct lwp_info *lp;
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
int resume_many;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
2005-11-03 20:31:38 +01:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LLR: Preparing to %s %s, %s, inferior_ptid %s\n",
|
|
|
|
|
step ? "step" : "resume",
|
|
|
|
|
target_pid_to_str (ptid),
|
2012-05-24 18:51:47 +02:00
|
|
|
|
(signo != GDB_SIGNAL_0
|
2012-05-24 18:39:15 +02:00
|
|
|
|
? strsignal (gdb_signal_to_host (signo)) : "0"),
|
2005-11-03 20:31:38 +01:00
|
|
|
|
target_pid_to_str (inferior_ptid));
|
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
/* A specific PTID means `step only this process id'. */
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
resume_many = (ptid_equal (minus_one_ptid, ptid)
|
|
|
|
|
|| ptid_is_pid (ptid));
|
2008-07-11 00:58:37 +02:00
|
|
|
|
|
2010-02-08 16:44:09 +01:00
|
|
|
|
/* Mark the lwps we're resuming as resumed. */
|
|
|
|
|
iterate_over_lwps (ptid, resume_set_callback, NULL);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
/* See if it's the current inferior that should be handled
|
|
|
|
|
specially. */
|
|
|
|
|
if (resume_many)
|
|
|
|
|
lp = find_lwp_pid (inferior_ptid);
|
|
|
|
|
else
|
|
|
|
|
lp = find_lwp_pid (ptid);
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
gdb_assert (lp != NULL);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
/* Remember if we're stepping. */
|
2011-09-09 21:27:50 +02:00
|
|
|
|
lp->last_resume_kind = step ? resume_step : resume_continue;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
/* If we have a pending wait status for this thread, there is no
|
|
|
|
|
point in resuming the process. But first make sure that
|
|
|
|
|
linux_nat_wait won't preemptively handle the event - we
|
|
|
|
|
should never take this short-circuit if we are going to
|
|
|
|
|
leave LP running, since we have skipped resuming all the
|
|
|
|
|
other threads. This bit of code needs to be synchronized
|
|
|
|
|
with linux_nat_wait. */
|
2005-11-03 20:31:38 +01:00
|
|
|
|
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
if (lp->status && WIFSTOPPED (lp->status))
|
|
|
|
|
{
|
2011-04-27 15:29:15 +02:00
|
|
|
|
if (!lp->step
|
|
|
|
|
&& WSTOPSIG (lp->status)
|
|
|
|
|
&& sigismember (&pass_mask, WSTOPSIG (lp->status)))
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LLR: Not short circuiting for ignored "
|
|
|
|
|
"status 0x%x\n", lp->status);
|
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
/* FIXME: What should we do if we are supposed to continue
|
|
|
|
|
this thread with a signal? */
|
2012-05-24 18:51:47 +02:00
|
|
|
|
gdb_assert (signo == GDB_SIGNAL_0);
|
2012-05-24 18:39:15 +02:00
|
|
|
|
signo = gdb_signal_from_host (WSTOPSIG (lp->status));
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
lp->status = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-11-03 20:31:38 +01:00
|
|
|
|
|
2015-01-07 20:41:06 +01:00
|
|
|
|
if (lwp_status_pending_p (lp))
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
{
|
|
|
|
|
/* FIXME: What should we do if we are supposed to continue
|
|
|
|
|
this thread with a signal? */
|
2012-05-24 18:51:47 +02:00
|
|
|
|
gdb_assert (signo == GDB_SIGNAL_0);
|
2005-11-03 20:31:38 +01:00
|
|
|
|
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LLR: Short circuiting for status 0x%x\n",
|
|
|
|
|
lp->status);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
if (target_can_async_p ())
|
|
|
|
|
{
|
Simplify target_async hook interface
All callers of target_async pass it the same callback
(inferior_event_handler). Since both common code and target backends
need to be able to put the target in and out of target async mode at
any given time, there's really no way that a different callback could
be passed. This commit simplifies things, and removes the indirection
altogether. Bonus: with this, gdb's target_async method ends up with
the same signature as gdbserver's.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog:
2015-03-25 Pedro Alves <palves@redhat.com>
* target.h <to_async>: Replace 'callback' and 'context' parameters
with boolean 'enable' parameter.
(target_async): Replace CALLBACK and CONTEXT parameters with
boolean ENABLE parameter.
* inf-loop.c (inferior_event_handler): Adjust.
* linux-nat.c (linux_nat_attach, linux_nat_resume)
(linux_nat_resume): Adjust.
(async_client_callback, async_client_context): Delete.
(handle_target_event): Call inferior_event_handler directly.
(linux_nat_async): Replace 'callback' and 'context' parameters
with boolean 'enable' parameter. Adjust. Remove references to
async_client_callback and async_client_context.
(linux_nat_close): Adjust.
* record-btrace.c (record_btrace_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_btrace_resume): Adjust.
* record-full.c (record_full_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_full_resume, record_full_core_resume): Adjust.
* remote.c (struct remote_state) <async_client_callback,
async_client_context>: Delete fields.
(remote_start_remote, extended_remote_attach_1, remote_resume)
(extended_remote_create_inferior): Adjust.
(remote_async_serial_handler): Call inferior_event_handler
directly.
(remote_async): Replace 'callback' and 'context' parameters with
boolean 'enable' parameter. Adjust.
* top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper):
Adjust.
* target-delegates.c: Regenerate.
2015-03-25 12:28:31 +01:00
|
|
|
|
target_async (1);
|
2009-05-11 14:08:03 +02:00
|
|
|
|
/* Tell the event loop we have something to process. */
|
|
|
|
|
async_file_mark ();
|
|
|
|
|
}
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
return;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
if (resume_many)
|
PR gdb/15713 - errors from i386_linux_resume lead to lock-up
linux_nat_resume is not considering that linux_ops->to_resume may throw:
/* Mark LWP as not stopped to prevent it from being continued by
linux_nat_resume_callback. */
lp->stopped = 0;
if (resume_many)
iterate_over_lwps (ptid, linux_nat_resume_callback, NULL);
If something within linux_nat_resume_callback throws, GDB leaves the
lwp_info as if the inferior was resumed, while it actually wasn't.
A couple examples, there are possibly others:
- i386_linux_resume calls target_read which calls QUIT.
- if the actual ptrace resumption fails in inf_ptrace_resume,
perror_with_name is called.
If the user tries to kill the inferior at this point (or quit, which
offers to kill), GDB locks up trying to stop the lwp -- if it is
already stopped no new waitpid event gets generated for it.
Fix this by setting the stopped flag earlier, as soon as we collect a
stop event with waitpid, and clearing it always only after resuming
the lwp successfully.
Tested on x86_64 Fedora 20. Confirmed the lock-up disappears using a
local hack that forces an error in inf_ptrace_resume.
Also fixes a little "set debug lin-lwp" annoyance. Currently we always see:
Continuing.
LLR: Preparing to resume process 6802, 0, inferior_ptid Thread 0x7ffff7fc7740 (LWP 6802)
^^^^^^^^
RC: Resuming sibling Thread 0x7ffff77c5700 (LWP 6807), 0, resume
RC: Resuming sibling Thread 0x7ffff7fc6700 (LWP 6806), 0, resume
RC: Not resuming sibling Thread 0x7ffff7fc7740 (LWP 6802) (not stopped)
^^^^^^^^^^^^^^^^^^^^^^^
LLR: PTRACE_CONT process 6802, 0 (resume event thread)
This patch gets rid of the "Not resuming sibling" line.
2014-05-29 Pedro Alves <palves@redhat.com>
PR gdb/15713
* linux-nat.c (linux_nat_resume_callback): Rename the second
parameter to 'except'. Skip LP if it points to EXCEPT.
(linux_nat_resume): Don't mark the event lwp as not stopped
before resuming sibling lwps. Instead ask
linux_nat_resume_callback to skip the event lwp. Mark it as not
stopped after actually resuming it.
(linux_handle_syscall_trap): Mark the lwp as not stopped after
resuming it.
(wait_lwp): Mark the lwp as stopped here.
(stop_wait_callback): Mark the lwp as not stopped right after
resuming it. Don't mark lwps as stopped here.
(linux_nat_filter_event): Mark the lwp as stopped earlier.
(linux_nat_wait_1): Don't mark dead lwps as stopped here.
2014-05-29 13:50:48 +02:00
|
|
|
|
iterate_over_lwps (ptid, linux_nat_resume_callback, lp);
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LLR: %s %s, %s (resume event thread)\n",
|
|
|
|
|
step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
|
2015-03-24 19:31:51 +01:00
|
|
|
|
target_pid_to_str (lp->ptid),
|
2012-05-24 18:51:47 +02:00
|
|
|
|
(signo != GDB_SIGNAL_0
|
2012-05-24 18:39:15 +02:00
|
|
|
|
? strsignal (gdb_signal_to_host (signo)) : "0"));
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
|
2015-03-24 19:31:51 +01:00
|
|
|
|
linux_resume_one_lwp (lp, step, signo);
|
|
|
|
|
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
if (target_can_async_p ())
|
Simplify target_async hook interface
All callers of target_async pass it the same callback
(inferior_event_handler). Since both common code and target backends
need to be able to put the target in and out of target async mode at
any given time, there's really no way that a different callback could
be passed. This commit simplifies things, and removes the indirection
altogether. Bonus: with this, gdb's target_async method ends up with
the same signature as gdbserver's.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog:
2015-03-25 Pedro Alves <palves@redhat.com>
* target.h <to_async>: Replace 'callback' and 'context' parameters
with boolean 'enable' parameter.
(target_async): Replace CALLBACK and CONTEXT parameters with
boolean ENABLE parameter.
* inf-loop.c (inferior_event_handler): Adjust.
* linux-nat.c (linux_nat_attach, linux_nat_resume)
(linux_nat_resume): Adjust.
(async_client_callback, async_client_context): Delete.
(handle_target_event): Call inferior_event_handler directly.
(linux_nat_async): Replace 'callback' and 'context' parameters
with boolean 'enable' parameter. Adjust. Remove references to
async_client_callback and async_client_context.
(linux_nat_close): Adjust.
* record-btrace.c (record_btrace_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_btrace_resume): Adjust.
* record-full.c (record_full_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_full_resume, record_full_core_resume): Adjust.
* remote.c (struct remote_state) <async_client_callback,
async_client_context>: Delete fields.
(remote_start_remote, extended_remote_attach_1, remote_resume)
(extended_remote_create_inferior): Adjust.
(remote_async_serial_handler): Call inferior_event_handler
directly.
(remote_async): Replace 'callback' and 'context' parameters with
boolean 'enable' parameter. Adjust.
* top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper):
Adjust.
* target-delegates.c: Regenerate.
2015-03-25 12:28:31 +01:00
|
|
|
|
target_async (1);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-21 22:23:43 +01:00
|
|
|
|
/* Send a signal to an LWP. */
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
kill_lwp (int lwpid, int signo)
|
|
|
|
|
{
|
2015-12-17 15:20:51 +01:00
|
|
|
|
int ret;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
2015-12-17 15:20:51 +01:00
|
|
|
|
errno = 0;
|
|
|
|
|
ret = syscall (__NR_tkill, lwpid, signo);
|
|
|
|
|
if (errno == ENOSYS)
|
|
|
|
|
{
|
|
|
|
|
/* If tkill fails, then we are not using nptl threads, a
|
|
|
|
|
configuration we no longer support. */
|
|
|
|
|
perror_with_name (("tkill"));
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-02 18:51:04 +02:00
|
|
|
|
/* Handle a GNU/Linux syscall trap wait response. If we see a syscall
|
|
|
|
|
event, check if the core is interested in it: if not, ignore the
|
|
|
|
|
event, and keep waiting; otherwise, we need to toggle the LWP's
|
|
|
|
|
syscall entry/exit status, since the ptrace event itself doesn't
|
|
|
|
|
indicate it, and report the trap to higher layers. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
linux_handle_syscall_trap (struct lwp_info *lp, int stopping)
|
|
|
|
|
{
|
|
|
|
|
struct target_waitstatus *ourstatus = &lp->waitstatus;
|
|
|
|
|
struct gdbarch *gdbarch = target_thread_architecture (lp->ptid);
|
|
|
|
|
int syscall_number = (int) gdbarch_get_syscall_number (gdbarch, lp->ptid);
|
|
|
|
|
|
|
|
|
|
if (stopping)
|
|
|
|
|
{
|
|
|
|
|
/* If we're stopping threads, there's a SIGSTOP pending, which
|
|
|
|
|
makes it so that the LWP reports an immediate syscall return,
|
|
|
|
|
followed by the SIGSTOP. Skip seeing that "return" using
|
|
|
|
|
PTRACE_CONT directly, and let stop_wait_callback collect the
|
|
|
|
|
SIGSTOP. Later when the thread is resumed, a new syscall
|
|
|
|
|
entry event. If we didn't do this (and returned 0), we'd
|
|
|
|
|
leave a syscall entry pending, and our caller, by using
|
|
|
|
|
PTRACE_CONT to collect the SIGSTOP, skips the syscall return
|
|
|
|
|
itself. Later, when the user re-resumes this LWP, we'd see
|
|
|
|
|
another syscall entry event and we'd mistake it for a return.
|
|
|
|
|
|
|
|
|
|
If stop_wait_callback didn't force the SIGSTOP out of the LWP
|
|
|
|
|
(leaving immediately with LWP->signalled set, without issuing
|
|
|
|
|
a PTRACE_CONT), it would still be problematic to leave this
|
|
|
|
|
syscall enter pending, as later when the thread is resumed,
|
|
|
|
|
it would then see the same syscall exit mentioned above,
|
|
|
|
|
followed by the delayed SIGSTOP, while the syscall didn't
|
|
|
|
|
actually get to execute. It seems it would be even more
|
|
|
|
|
confusing to the user. */
|
|
|
|
|
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LHST: ignoring syscall %d "
|
|
|
|
|
"for LWP %ld (stopping threads), "
|
|
|
|
|
"resuming with PTRACE_CONT for SIGSTOP\n",
|
|
|
|
|
syscall_number,
|
2013-09-30 13:50:12 +02:00
|
|
|
|
ptid_get_lwp (lp->ptid));
|
2009-10-02 18:51:04 +02:00
|
|
|
|
|
|
|
|
|
lp->syscall_state = TARGET_WAITKIND_IGNORE;
|
2013-09-30 13:50:12 +02:00
|
|
|
|
ptrace (PTRACE_CONT, ptid_get_lwp (lp->ptid), 0, 0);
|
PR gdb/15713 - errors from i386_linux_resume lead to lock-up
linux_nat_resume is not considering that linux_ops->to_resume may throw:
/* Mark LWP as not stopped to prevent it from being continued by
linux_nat_resume_callback. */
lp->stopped = 0;
if (resume_many)
iterate_over_lwps (ptid, linux_nat_resume_callback, NULL);
If something within linux_nat_resume_callback throws, GDB leaves the
lwp_info as if the inferior was resumed, while it actually wasn't.
A couple examples, there are possibly others:
- i386_linux_resume calls target_read which calls QUIT.
- if the actual ptrace resumption fails in inf_ptrace_resume,
perror_with_name is called.
If the user tries to kill the inferior at this point (or quit, which
offers to kill), GDB locks up trying to stop the lwp -- if it is
already stopped no new waitpid event gets generated for it.
Fix this by setting the stopped flag earlier, as soon as we collect a
stop event with waitpid, and clearing it always only after resuming
the lwp successfully.
Tested on x86_64 Fedora 20. Confirmed the lock-up disappears using a
local hack that forces an error in inf_ptrace_resume.
Also fixes a little "set debug lin-lwp" annoyance. Currently we always see:
Continuing.
LLR: Preparing to resume process 6802, 0, inferior_ptid Thread 0x7ffff7fc7740 (LWP 6802)
^^^^^^^^
RC: Resuming sibling Thread 0x7ffff77c5700 (LWP 6807), 0, resume
RC: Resuming sibling Thread 0x7ffff7fc6700 (LWP 6806), 0, resume
RC: Not resuming sibling Thread 0x7ffff7fc7740 (LWP 6802) (not stopped)
^^^^^^^^^^^^^^^^^^^^^^^
LLR: PTRACE_CONT process 6802, 0 (resume event thread)
This patch gets rid of the "Not resuming sibling" line.
2014-05-29 Pedro Alves <palves@redhat.com>
PR gdb/15713
* linux-nat.c (linux_nat_resume_callback): Rename the second
parameter to 'except'. Skip LP if it points to EXCEPT.
(linux_nat_resume): Don't mark the event lwp as not stopped
before resuming sibling lwps. Instead ask
linux_nat_resume_callback to skip the event lwp. Mark it as not
stopped after actually resuming it.
(linux_handle_syscall_trap): Mark the lwp as not stopped after
resuming it.
(wait_lwp): Mark the lwp as stopped here.
(stop_wait_callback): Mark the lwp as not stopped right after
resuming it. Don't mark lwps as stopped here.
(linux_nat_filter_event): Mark the lwp as stopped earlier.
(linux_nat_wait_1): Don't mark dead lwps as stopped here.
2014-05-29 13:50:48 +02:00
|
|
|
|
lp->stopped = 0;
|
2009-10-02 18:51:04 +02:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
gdb: Improve syscall entry/return tracking on Linux
The existing logic was simply to flip syscall entry/return state when a
syscall trap was seen, and even then only with active 'catch syscall'.
That can get out of sync if 'catch syscall' is toggled at odd times.
This patch updates the entry/return state for all syscall traps,
regardless of catching state, and also updates known syscall state for
other kinds of traps. Almost all PTRACE_EVENT stops are delivered from
the middle of a syscall, so this can act like an entry. Every other
kind of ptrace stop is only delivered outside of syscall event pairs, so
marking them ignored ensures the next syscall trap looks like an entry.
Three new test scenarios are added to catch-syscall.exp:
- Disable 'catch syscall' from an entry to deliberately miss the return
event, then re-enable to make sure a new entry is recognized.
- Enable 'catch syscall' for the first time from a vfork event, which is
a PTRACE_EVENT_VFORK in the middle of the syscall. Make sure the next
syscall event is recognized as the return.
- Make sure entry and return are recognized for an ENOSYS syscall. This
is to defeat a common x86 hack that uses the pre-filled ENOSYS return
value as a sign of being on the entry side.
gdb/ChangeLog:
2015-10-19 Josh Stone <jistone@redhat.com>
* linux-nat.c (linux_handle_syscall_trap): Always update entry/
return state, even when not actively catching syscalls at all.
(linux_handle_extended_wait): Mark syscall_state like an entry.
(wait_lwp): Set syscall_state ignored for other traps.
(linux_nat_filter_event): Likewise.
gdb/testsuite/ChangeLog:
2015-10-19 Josh Stone <jistone@redhat.com>
* gdb.base/catch-syscall.c: Include <sched.h>.
(unknown_syscall): New variable.
(main): Trigger a vfork and an unknown syscall.
* gdb.base/catch-syscall.exp (vfork_syscalls): New variable.
(unknown_syscall_number): Likewise.
(check_call_to_syscall): Accept an optional syscall pattern.
(check_return_from_syscall): Likewise.
(check_continue): Likewise.
(test_catch_syscall_without_args): Check for vfork and ENOSYS.
(test_catch_syscall_skipping_return): New test toggling off 'catch
syscall' to step over the syscall return, then toggling back on.
(test_catch_syscall_mid_vfork): New test turning on 'catch syscall'
during a PTRACE_EVENT_VFORK stop, in the middle of a vfork syscall.
(do_syscall_tests): Call test_catch_syscall_without_args and
test_catch_syscall_mid_vfork.
(test_catch_syscall_without_args_noxml): Check for vfork and ENOSYS.
(fill_all_syscalls_numbers): Initialize unknown_syscall_number.
2015-10-20 02:59:38 +02:00
|
|
|
|
/* Always update the entry/return state, even if this particular
|
|
|
|
|
syscall isn't interesting to the core now. In async mode,
|
|
|
|
|
the user could install a new catchpoint for this syscall
|
|
|
|
|
between syscall enter/return, and we'll need to know to
|
|
|
|
|
report a syscall return if that happens. */
|
|
|
|
|
lp->syscall_state = (lp->syscall_state == TARGET_WAITKIND_SYSCALL_ENTRY
|
|
|
|
|
? TARGET_WAITKIND_SYSCALL_RETURN
|
|
|
|
|
: TARGET_WAITKIND_SYSCALL_ENTRY);
|
|
|
|
|
|
2009-10-02 18:51:04 +02:00
|
|
|
|
if (catch_syscall_enabled ())
|
|
|
|
|
{
|
|
|
|
|
if (catching_syscall_number (syscall_number))
|
|
|
|
|
{
|
|
|
|
|
/* Alright, an event to report. */
|
|
|
|
|
ourstatus->kind = lp->syscall_state;
|
|
|
|
|
ourstatus->value.syscall_number = syscall_number;
|
|
|
|
|
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LHST: stopping for %s of syscall %d"
|
|
|
|
|
" for LWP %ld\n",
|
2011-01-05 23:22:53 +01:00
|
|
|
|
lp->syscall_state
|
|
|
|
|
== TARGET_WAITKIND_SYSCALL_ENTRY
|
2009-10-02 18:51:04 +02:00
|
|
|
|
? "entry" : "return",
|
|
|
|
|
syscall_number,
|
2013-09-30 13:50:12 +02:00
|
|
|
|
ptid_get_lwp (lp->ptid));
|
2009-10-02 18:51:04 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LHST: ignoring %s of syscall %d "
|
|
|
|
|
"for LWP %ld\n",
|
|
|
|
|
lp->syscall_state == TARGET_WAITKIND_SYSCALL_ENTRY
|
|
|
|
|
? "entry" : "return",
|
|
|
|
|
syscall_number,
|
2013-09-30 13:50:12 +02:00
|
|
|
|
ptid_get_lwp (lp->ptid));
|
2009-10-02 18:51:04 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* If we had been syscall tracing, and hence used PT_SYSCALL
|
|
|
|
|
before on this LWP, it could happen that the user removes all
|
|
|
|
|
syscall catchpoints before we get to process this event.
|
|
|
|
|
There are two noteworthy issues here:
|
|
|
|
|
|
|
|
|
|
- When stopped at a syscall entry event, resuming with
|
|
|
|
|
PT_STEP still resumes executing the syscall and reports a
|
|
|
|
|
syscall return.
|
|
|
|
|
|
|
|
|
|
- Only PT_SYSCALL catches syscall enters. If we last
|
|
|
|
|
single-stepped this thread, then this event can't be a
|
|
|
|
|
syscall enter. If we last single-stepped this thread, this
|
|
|
|
|
has to be a syscall exit.
|
|
|
|
|
|
|
|
|
|
The points above mean that the next resume, be it PT_STEP or
|
|
|
|
|
PT_CONTINUE, can not trigger a syscall trace event. */
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
2011-01-05 23:22:53 +01:00
|
|
|
|
"LHST: caught syscall event "
|
|
|
|
|
"with no syscall catchpoints."
|
2009-10-02 18:51:04 +02:00
|
|
|
|
" %d for LWP %ld, ignoring\n",
|
|
|
|
|
syscall_number,
|
2013-09-30 13:50:12 +02:00
|
|
|
|
ptid_get_lwp (lp->ptid));
|
2009-10-02 18:51:04 +02:00
|
|
|
|
lp->syscall_state = TARGET_WAITKIND_IGNORE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The core isn't interested in this event. For efficiency, avoid
|
|
|
|
|
stopping all threads only to have the core resume them all again.
|
|
|
|
|
Since we're not stopping threads, if we're still syscall tracing
|
|
|
|
|
and not stepping, we can't use PTRACE_CONT here, as we'd miss any
|
|
|
|
|
subsequent syscall. Simply resume using the inf-ptrace layer,
|
|
|
|
|
which knows when to use PT_SYSCALL or PT_CONTINUE. */
|
|
|
|
|
|
2015-01-07 20:41:06 +01:00
|
|
|
|
linux_resume_one_lwp (lp, lp->step, GDB_SIGNAL_0);
|
2009-10-02 18:51:04 +02:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-08 22:09:47 +01:00
|
|
|
|
/* Handle a GNU/Linux extended wait response. If we see a clone
|
|
|
|
|
event, we need to add the new LWP to our list (and not report the
|
|
|
|
|
trap to higher layers). This function returns non-zero if the
|
|
|
|
|
event should be ignored and we should wait again. If STOPPING is
|
|
|
|
|
true, the new LWP remains stopped, otherwise it is continued. */
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
static int
|
PR threads/18600: Threads left stopped after fork+thread spawn
When a program forks and another process start threads while gdb is
handling the fork event, newly created threads are left stuck stopped
by gdb, even though gdb presents them as "running", to the user.
This can be seen with the test added by this patch. The test has the
inferior fork a certain number of times and waits for all children to
exit. Each fork child spawns a number of threads that do nothing and
joins them immediately. Normally, the program should run unimpeded
(from the point of view of the user) and exit very quickly. Without
this fix, it doesn't because of some threads left stopped by gdb, so
inferior 1 never exits.
The program triggers when a new clone thread is found while inside the
linux_stop_and_wait_all_lwps call in linux-thread-db.c:
linux_stop_and_wait_all_lwps ();
ALL_LWPS (lp)
if (ptid_get_pid (lp->ptid) == pid)
thread_from_lwp (lp->ptid);
linux_unstop_all_lwps ();
Within linux_stop_and_wait_all_lwps, we reach
linux_handle_extended_wait with the "stopping" parameter set to 1, and
because of that we don't mark the new lwp as resumed. As consequence,
the subsequent resume_stopped_resumed_lwps, called from
linux_unstop_all_lwps, never resumes the new LWP.
There's lots of cruft in linux_handle_extended_wait that no longer
makes sense. On systems with CLONE events support, we don't rely on
libthread_db for thread listing anymore, so the code that preserves
stop_requested and the handling of last_resume_kind is all dead.
So the fix is to remove all that, and simply always mark the new LWP
as resumed, so that resume_stopped_resumed_lwps re-resumes it.
gdb/ChangeLog:
2015-07-30 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
PR threads/18600
* linux-nat.c (linux_handle_extended_wait): On CLONE event, always
mark the new thread as resumed. Remove STOPPING parameter.
(wait_lwp): Adjust call to linux_handle_extended_wait.
(linux_nat_filter_event): Adjust call to
linux_handle_extended_wait.
(resume_stopped_resumed_lwps): Add debug output.
gdb/testsuite/ChangeLog:
2015-07-30 Simon Marchi <simon.marchi@ericsson.com>
Pedro Alves <palves@redhat.com>
PR threads/18600
* gdb.threads/fork-plus-threads.c: New file.
* gdb.threads/fork-plus-threads.exp: New file.
2015-07-30 19:50:29 +02:00
|
|
|
|
linux_handle_extended_wait (struct lwp_info *lp, int status)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
2013-09-30 13:50:12 +02:00
|
|
|
|
int pid = ptid_get_lwp (lp->ptid);
|
2007-01-08 22:09:47 +01:00
|
|
|
|
struct target_waitstatus *ourstatus = &lp->waitstatus;
|
2014-09-19 19:54:34 +02:00
|
|
|
|
int event = linux_ptrace_get_extended_event (status);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
gdb: Improve syscall entry/return tracking on Linux
The existing logic was simply to flip syscall entry/return state when a
syscall trap was seen, and even then only with active 'catch syscall'.
That can get out of sync if 'catch syscall' is toggled at odd times.
This patch updates the entry/return state for all syscall traps,
regardless of catching state, and also updates known syscall state for
other kinds of traps. Almost all PTRACE_EVENT stops are delivered from
the middle of a syscall, so this can act like an entry. Every other
kind of ptrace stop is only delivered outside of syscall event pairs, so
marking them ignored ensures the next syscall trap looks like an entry.
Three new test scenarios are added to catch-syscall.exp:
- Disable 'catch syscall' from an entry to deliberately miss the return
event, then re-enable to make sure a new entry is recognized.
- Enable 'catch syscall' for the first time from a vfork event, which is
a PTRACE_EVENT_VFORK in the middle of the syscall. Make sure the next
syscall event is recognized as the return.
- Make sure entry and return are recognized for an ENOSYS syscall. This
is to defeat a common x86 hack that uses the pre-filled ENOSYS return
value as a sign of being on the entry side.
gdb/ChangeLog:
2015-10-19 Josh Stone <jistone@redhat.com>
* linux-nat.c (linux_handle_syscall_trap): Always update entry/
return state, even when not actively catching syscalls at all.
(linux_handle_extended_wait): Mark syscall_state like an entry.
(wait_lwp): Set syscall_state ignored for other traps.
(linux_nat_filter_event): Likewise.
gdb/testsuite/ChangeLog:
2015-10-19 Josh Stone <jistone@redhat.com>
* gdb.base/catch-syscall.c: Include <sched.h>.
(unknown_syscall): New variable.
(main): Trigger a vfork and an unknown syscall.
* gdb.base/catch-syscall.exp (vfork_syscalls): New variable.
(unknown_syscall_number): Likewise.
(check_call_to_syscall): Accept an optional syscall pattern.
(check_return_from_syscall): Likewise.
(check_continue): Likewise.
(test_catch_syscall_without_args): Check for vfork and ENOSYS.
(test_catch_syscall_skipping_return): New test toggling off 'catch
syscall' to step over the syscall return, then toggling back on.
(test_catch_syscall_mid_vfork): New test turning on 'catch syscall'
during a PTRACE_EVENT_VFORK stop, in the middle of a vfork syscall.
(do_syscall_tests): Call test_catch_syscall_without_args and
test_catch_syscall_mid_vfork.
(test_catch_syscall_without_args_noxml): Check for vfork and ENOSYS.
(fill_all_syscalls_numbers): Initialize unknown_syscall_number.
2015-10-20 02:59:38 +02:00
|
|
|
|
/* All extended events we currently use are mid-syscall. Only
|
|
|
|
|
PTRACE_EVENT_STOP is delivered more like a signal-stop, but
|
|
|
|
|
you have to be using PTRACE_SEIZE to get that. */
|
|
|
|
|
lp->syscall_state = TARGET_WAITKIND_SYSCALL_ENTRY;
|
|
|
|
|
|
2007-01-08 22:09:47 +01:00
|
|
|
|
if (event == PTRACE_EVENT_FORK || event == PTRACE_EVENT_VFORK
|
|
|
|
|
|| event == PTRACE_EVENT_CLONE)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
2007-01-08 22:09:47 +01:00
|
|
|
|
unsigned long new_pid;
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
ptrace (PTRACE_GETEVENTMSG, pid, 0, &new_pid);
|
2006-05-06 01:48:28 +02:00
|
|
|
|
|
2007-01-08 22:09:47 +01:00
|
|
|
|
/* If we haven't already seen the new PID stop, wait for it now. */
|
|
|
|
|
if (! pull_pid_from_list (&stopped_pids, new_pid, &status))
|
|
|
|
|
{
|
|
|
|
|
/* The new child has a pending SIGSTOP. We can't affect it until it
|
|
|
|
|
hits the SIGSTOP, but we're already attached. */
|
2015-12-17 15:20:51 +01:00
|
|
|
|
ret = my_waitpid (new_pid, &status, __WALL);
|
2007-01-08 22:09:47 +01:00
|
|
|
|
if (ret == -1)
|
|
|
|
|
perror_with_name (_("waiting for new child"));
|
|
|
|
|
else if (ret != new_pid)
|
|
|
|
|
internal_error (__FILE__, __LINE__,
|
|
|
|
|
_("wait returned unexpected PID %d"), ret);
|
|
|
|
|
else if (!WIFSTOPPED (status))
|
|
|
|
|
internal_error (__FILE__, __LINE__,
|
|
|
|
|
_("wait returned unexpected status 0x%x"), status);
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-10 00:23:05 +02:00
|
|
|
|
ourstatus->value.related_pid = ptid_build (new_pid, new_pid, 0);
|
2007-01-08 22:09:47 +01:00
|
|
|
|
|
[native x86 GNU/Linux] Access debug register mirror from the corresponding process.
While reviewing the native AArch64 patch, I noticed a problem:
On 02/06/2013 08:46 PM, Pedro Alves wrote:
>
>> > +static void
>> > +aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
>> > +{
>> > + struct arch_lwp_info *info = lwp->arch_private;
>> > +
>> > + /* NULL means this is the main thread still going through the shell,
>> > + or, no watchpoint has been set yet. In that case, there's
>> > + nothing to do. */
>> > + if (info == NULL)
>> > + return;
>> > +
>> > + if (DR_HAS_CHANGED (info->dr_changed_bp)
>> > + || DR_HAS_CHANGED (info->dr_changed_wp))
>> > + {
>> > + int tid = GET_LWP (lwp->ptid);
>> > + struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
> Hmm. This is always fetching the debug_reg_state of
> the current inferior, but may not be the inferior of lwp.
> I see the same bug on x86. Sorry about that. I'll fix it.
A natural fix would be to make xxx_get_debug_reg_state take an
inferior argument, but that doesn't work because of the case where we
detach breakpoints/watchpoints from the child fork, at a time there's
no inferior for the child fork at all. We do a nasty hack in
i386_inferior_data_get, but that relies on all callers pointing the
current inferior to the correct inferior, which isn't actually being
done by all callers, and I don't think we want to enforce that -- deep
in the bowls of linux-nat.c, there are many cases we resume lwps
behind the scenes, and it's be better to not have that code rely on
global state (as it doesn't today).
The fix is to decouple the watchpoints code from inferiors, making it
track target processes instead. This way, we can freely keep track of
the watchpoint mirrors for these processes behind the core's back.
Checkpoints also play dirty tricks with swapping the process behind
the inferior, so they get special treatment too in the patch (which
just amounts to calling a new hook). Instead of the old hack in
i386_inferior_data_get, where we returned a copy of the current
inferior's debug registers mirror, as soon as we detect a fork in the
target, we copy the debug register mirror from the parent to the child
process.
I don't have an old kernel handy to test, but I stepped through gdb doing
the watchpoint removal in the fork child in the watchpoint-fork test
seeing that the debug registers end up cleared in the child.
I didn't find the need for linux_nat_iterate_watchpoint_lwps. If
we use plain iterate_over_lwps instead, what happens is that
when removing watchpoints, that iterate_over_lwps doesn't actually
iterate over anything, since the fork child is not added to the
lwp list until later, at detach time, in linux_child_follow_fork.
And if we don't iterate over that lwp, we don't mark its debug
registers as needing update. But linux_child_follow_fork takes
care of doing that explicitly:
child_lp = add_lwp (inferior_ptid);
child_lp->stopped = 1;
child_lp->last_resume_kind = resume_stop;
make_cleanup (delete_lwp_cleanup, child_lp);
/* CHILD_LP has new PID, therefore linux_nat_new_thread is not called for it.
See i386_inferior_data_get for the Linux kernel specifics.
Ensure linux_nat_prepare_to_resume will reset the hardware debug
registers. It is done by the linux_nat_new_thread call, which is
being skipped in add_lwp above for the first lwp of a pid. */
gdb_assert (num_lwps (GET_PID (child_lp->ptid)) == 1);
if (linux_nat_new_thread != NULL)
linux_nat_new_thread (child_lp);
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (child_lp);
ptrace (PTRACE_DETACH, child_pid, 0, 0);
so unless I'm missing something (quite possible) it ends up all
the same. But, the !detach-on-fork, and the "follow-fork child" paths
should also call linux_nat_new_thread, and they don't presently. It
seems to me in those cases we're not clearing debug regs correctly
when that's needed. Instead of copying that bit that works around
add_lwp bypassing the linux_nat_new_thread call, I thought it'd
be better to add an add_initial_lwp call to be used in the case we
really need to bypass linux_nat_new_thread, and make
add_lwp always call linux_nat_new_thread.
i386_cleanup_dregs is rewritten to forget about the current process
debug mirrors, which takes cares of other i386 ports. Only a couple
of extra tweaks here and there were needed, as some targets wheren't
actually calling i386_cleanup_dregs.
Tested on Fedora 17 x86_64 -m64/-m32.
GDBserver already fetches the i386_debug_reg_state from the right
process, and, it doesn't handle forks at all, so no fix is needed over
there.
gdb/
2013-02-13 Pedro Alves <palves@redhat.com>
* amd64-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(amd64_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(amd64_linux_new_fork): New function.
(_initialize_amd64_linux_nat): Install amd64_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(i386_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(i386_linux_new_fork): New function.
(_initialize_i386_linux_nat): Install i386_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-nat.c (i386_init_dregs): Delete.
(i386_inferior_data, struct i386_inferior_data):
Delete.
(struct i386_process_info): New.
(i386_process_list): New global.
(i386_find_process_pid, i386_add_process, i386_process_info_get):
New functions.
(i386_inferior_data_get): Delete.
(i386_process_info_get): New function.
(i386_debug_reg_state): New parameter 'pid'. Reimplement.
(i386_forget_process): New function.
(i386_cleanup_dregs): Rewrite.
(i386_update_inferior_debug_regs, i386_insert_watchpoint)
(i386_remove_watchpoint, i386_region_ok_for_watchpoint)
(i386_stopped_data_address, i386_insert_hw_breakpoint)
(i386_remove_hw_breakpoint): Adjust to pass the current process id
to i386_debug_reg_state.
(i386_use_watchpoints): Don't register inferior data.
* i386-nat.h (i386_debug_reg_state): Add new 'pid' parameter, and
adjust comment.
(i386_forget_process): Declare.
* linux-fork.c (delete_fork): Call linux_nat_forget_process.
* linux-nat.c (linux_nat_new_fork, linux_nat_forget_process_hook):
New static globals.
(linux_child_follow_fork): Don't call linux_nat_new_thread here.
(add_initial_lwp): New, factored out from ...
(add_lwp): ... this. Don't check the number of lwps before
calling linux_nat_new_thread.
(linux_nat_iterate_watchpoint_lwps): Delete.
(linux_nat_attach): Use add_initial_lwp instead of add_lwp.
(linux_handle_extended_wait): Call the linux_nat_new_fork hook on
forks and vforks.
(linux_nat_wait_1): Use add_initial_lwp instead of add_lwp for the
initial lwp.
(linux_nat_kill, linux_nat_mourn_inferior): Call
linux_nat_forget_process.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New functions.
* linux-nat.h (linux_nat_iterate_watchpoint_lwps_ftype): Delete
type.
(linux_nat_iterate_watchpoint_lwps): Delete declaration.
(linux_nat_new_fork_ftype, linux_nat_forget_process_ftype): New
types.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New declarations.
* amd64fbsd-nat.c (super_mourn_inferior): New global.
(amd64fbsd_mourn_inferior): New function.
(_initialize_amd64fbsd_nat): Override to_mourn_inferior.
* windows-nat.c (windows_detach): Call i386_cleanup_dregs.
2013-02-13 15:59:49 +01:00
|
|
|
|
if (event == PTRACE_EVENT_FORK || event == PTRACE_EVENT_VFORK)
|
|
|
|
|
{
|
|
|
|
|
/* The arch-specific native code may need to know about new
|
|
|
|
|
forks even if those end up never mapped to an
|
|
|
|
|
inferior. */
|
|
|
|
|
if (linux_nat_new_fork != NULL)
|
|
|
|
|
linux_nat_new_fork (lp, new_pid);
|
|
|
|
|
}
|
|
|
|
|
|
gdb/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* linux-nat.c (linux_child_follow_fork): If we're staying attached
to the child process, enable event reporting on it. Don't handle
checkpoints here. Instead, add the child fork to the lwp thread
and inferior lists without clobbering the previous inferior. Let
the thread_db layer learn about a new child process, even if
following the parent.
(linux_nat_switch_fork): Delete lwps of the current inferior only,
instead of clearing the whole list. Use thread_change_ptid to
give the core the illusion the new checkpoint is still the same
inferior. Clear the register cache.
(linux_handle_extended_wait): Handle checkpoints here.
(linux_multi_process): Turn on.
* linux-fork.c (struct fork_info) <pc>: Remove field.
(init_fork_list): Do not delete the checkpoint from the inferior
list (it is not there).
(fork_load_infrun_state): Don't switch inferior_ptid here. Pass
the new checkpoint's ptid to linux_nat_switch_fork.
(fork_save_infrun_state): Make static. Don't stop the pc field of
fork_info, it's gone.
(linux_fork_mourn_inferior): Don't delete the checkpoint from the
inferior list, it's not there.
(linux_fork_detach): Ditto.
(delete_fork_command): Replace mention of fork/checkpoint by
checkpoint only.
(detach_fork_command): Likewise. Don't delete the checkpoint from
the inferior list.
(info_forks_command): Adjust.
(restore_detach_fork): Delete.
(checkpointing_pid): New.
(linux_fork_checkpointing_p): New.
(save_detach_fork): Delete.
(checkpoint_command): Delete temp_detach_fork. Don't remove
breakpoints, that's a nop. Store the pid of the process we're
checkpointing, and use make_cleanup_restore_integer to restore it.
Don't reinsert breakpoints here.
(process_command, fork_command): Delete.
(restart_command): Update comments to only mention checkpoints,
not forks.
(_initialize_linux_fork): Delete "fork", "process", "info forks"
commands.
* linux-fork.h (fork_save_infrun_state, fork_list): Delete
declarations.
(linux_fork_checkpointing_p): Declare.
* cli/cli-cmds.c (killlist): New.
* cli/cli-cmds.h (killlist): Declare.
* gdbcmd.h (killlist): Declare.
* inferior.c: Include "gdbthread.h".
(detach_inferior_command, kill_inferior_command)
(inferior_command): New.
(info_inferiors_command): Allow specifying a specific inferior id.
(_initialize_inferiors): Register "inferior", "kill inferior" and
"detach inferior" commands.
* infcmd.c (_initialize_infcmd): Make "kill" a prefix command.
* gdbthread.h (any_thread_of_process): Declare.
* thread.c (any_thread_of_process): New.
* NEWS: Mention multi-inferior debugging. Mention 'info
inferiors', 'inferior', 'detach inferior' and 'kill inferior' as
new commands.
(Removed commands): New section, mentioning that 'info forks',
'fork', 'process', 'delete fork' and 'detach fork' are now gone.
gdb/testsuite/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.base/multi-forks.exp: Only run detach-on-fork tests on
linux. Adjust to use "inferior", "info inferiors", "detach
inferior" and "kill inferior" instead of "restart", "info fork",
"detach fork" and "delete fork".
* gdb.base/ending-run.exp: Spell out "info".
* gdb.base/help.exp: Adjust to use test_prefix_command_help for
the "kill" command.
gdb/doc/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (Debugging multiple inferiors): Document the
"inferior", "detach inferior" and "kill inferior" commands.
(Debugging Programs with Multiple Processes): Adjust to mention
generic "inferior" commands. Delete mention of "detach fork" and
"delete fork". Cross reference to "Debugging multiple inferiors"
section.
2009-07-02 23:57:28 +02:00
|
|
|
|
if (event == PTRACE_EVENT_FORK
|
2013-09-30 13:50:12 +02:00
|
|
|
|
&& linux_fork_checkpointing_p (ptid_get_pid (lp->ptid)))
|
gdb/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* linux-nat.c (linux_child_follow_fork): If we're staying attached
to the child process, enable event reporting on it. Don't handle
checkpoints here. Instead, add the child fork to the lwp thread
and inferior lists without clobbering the previous inferior. Let
the thread_db layer learn about a new child process, even if
following the parent.
(linux_nat_switch_fork): Delete lwps of the current inferior only,
instead of clearing the whole list. Use thread_change_ptid to
give the core the illusion the new checkpoint is still the same
inferior. Clear the register cache.
(linux_handle_extended_wait): Handle checkpoints here.
(linux_multi_process): Turn on.
* linux-fork.c (struct fork_info) <pc>: Remove field.
(init_fork_list): Do not delete the checkpoint from the inferior
list (it is not there).
(fork_load_infrun_state): Don't switch inferior_ptid here. Pass
the new checkpoint's ptid to linux_nat_switch_fork.
(fork_save_infrun_state): Make static. Don't stop the pc field of
fork_info, it's gone.
(linux_fork_mourn_inferior): Don't delete the checkpoint from the
inferior list, it's not there.
(linux_fork_detach): Ditto.
(delete_fork_command): Replace mention of fork/checkpoint by
checkpoint only.
(detach_fork_command): Likewise. Don't delete the checkpoint from
the inferior list.
(info_forks_command): Adjust.
(restore_detach_fork): Delete.
(checkpointing_pid): New.
(linux_fork_checkpointing_p): New.
(save_detach_fork): Delete.
(checkpoint_command): Delete temp_detach_fork. Don't remove
breakpoints, that's a nop. Store the pid of the process we're
checkpointing, and use make_cleanup_restore_integer to restore it.
Don't reinsert breakpoints here.
(process_command, fork_command): Delete.
(restart_command): Update comments to only mention checkpoints,
not forks.
(_initialize_linux_fork): Delete "fork", "process", "info forks"
commands.
* linux-fork.h (fork_save_infrun_state, fork_list): Delete
declarations.
(linux_fork_checkpointing_p): Declare.
* cli/cli-cmds.c (killlist): New.
* cli/cli-cmds.h (killlist): Declare.
* gdbcmd.h (killlist): Declare.
* inferior.c: Include "gdbthread.h".
(detach_inferior_command, kill_inferior_command)
(inferior_command): New.
(info_inferiors_command): Allow specifying a specific inferior id.
(_initialize_inferiors): Register "inferior", "kill inferior" and
"detach inferior" commands.
* infcmd.c (_initialize_infcmd): Make "kill" a prefix command.
* gdbthread.h (any_thread_of_process): Declare.
* thread.c (any_thread_of_process): New.
* NEWS: Mention multi-inferior debugging. Mention 'info
inferiors', 'inferior', 'detach inferior' and 'kill inferior' as
new commands.
(Removed commands): New section, mentioning that 'info forks',
'fork', 'process', 'delete fork' and 'detach fork' are now gone.
gdb/testsuite/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.base/multi-forks.exp: Only run detach-on-fork tests on
linux. Adjust to use "inferior", "info inferiors", "detach
inferior" and "kill inferior" instead of "restart", "info fork",
"detach fork" and "delete fork".
* gdb.base/ending-run.exp: Spell out "info".
* gdb.base/help.exp: Adjust to use test_prefix_command_help for
the "kill" command.
gdb/doc/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (Debugging multiple inferiors): Document the
"inferior", "detach inferior" and "kill inferior" commands.
(Debugging Programs with Multiple Processes): Adjust to mention
generic "inferior" commands. Delete mention of "detach fork" and
"delete fork". Cross reference to "Debugging multiple inferiors"
section.
2009-07-02 23:57:28 +02:00
|
|
|
|
{
|
|
|
|
|
/* Handle checkpointing by linux-fork.c here as a special
|
|
|
|
|
case. We don't want the follow-fork-mode or 'catch fork'
|
|
|
|
|
to interfere with this. */
|
|
|
|
|
|
|
|
|
|
/* This won't actually modify the breakpoint list, but will
|
|
|
|
|
physically remove the breakpoints from the child. */
|
Change detach_breakpoints to take a ptid instead of a pid
Before this change, detach_breakpoints would take a pid, and then
set inferior_ptid to a ptid that it constructs using pid_to_ptid (pid).
Unfortunately, this ptid is not necessarily valid. Consider for
instance the case of ia64-hpux, where ttrace refuses a register-read
operation if the LWP is not provided.
This problems shows up when GDB is trying to handle fork events.
Assuming GDB is configured to follow the parent, GDB will try to
detach from the child. But before doing so, it needs to remove
all breakpoints inside that child. On ia64, this involves reading
inferior (the child's) memory. And on ia64-hpux, reading memory
requires us to read the bsp and bspstore registers, in order to
determine where that memory is relative to the value of those
registers, and thus to determine which ttrace operation to use in
order to fetch that memory (see ia64_hpux_xfer_memory).
This patch therefore changes detach_breakpoints to take a ptid instead
of a pid, and then updates all callers.
One of the consequences of this patch is that it trips an assert
on GNU/Linux targets. But this assert appears to have not actual
purpose, and is thus removed.
gdb/ChangeLog:
* breakpoint.h (detach_breakpoints): pid parameter is now a ptid.
* breakpoint.c (detach_breakpoints): Change pid parameter into
a ptid. Adjust code accordingly.
* infrun.c (handle_inferior_event): Delete variable child_pid.
Update call to detach_breakpoints to pass the child ptid for
fork events.
* linux-nat.c (linux_nat_iterate_watchpoint_lwps): Remove
assert that inferior_ptid's lwp is zero.
(linux_handle_extended_wait): Update call to detach_breakpoints.
* inf-ttrace.c (inf_ttrace_follow_fork): Update call to
detach_breakpoints.
2012-08-17 01:54:50 +02:00
|
|
|
|
detach_breakpoints (ptid_build (new_pid, new_pid, 0));
|
gdb/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* linux-nat.c (linux_child_follow_fork): If we're staying attached
to the child process, enable event reporting on it. Don't handle
checkpoints here. Instead, add the child fork to the lwp thread
and inferior lists without clobbering the previous inferior. Let
the thread_db layer learn about a new child process, even if
following the parent.
(linux_nat_switch_fork): Delete lwps of the current inferior only,
instead of clearing the whole list. Use thread_change_ptid to
give the core the illusion the new checkpoint is still the same
inferior. Clear the register cache.
(linux_handle_extended_wait): Handle checkpoints here.
(linux_multi_process): Turn on.
* linux-fork.c (struct fork_info) <pc>: Remove field.
(init_fork_list): Do not delete the checkpoint from the inferior
list (it is not there).
(fork_load_infrun_state): Don't switch inferior_ptid here. Pass
the new checkpoint's ptid to linux_nat_switch_fork.
(fork_save_infrun_state): Make static. Don't stop the pc field of
fork_info, it's gone.
(linux_fork_mourn_inferior): Don't delete the checkpoint from the
inferior list, it's not there.
(linux_fork_detach): Ditto.
(delete_fork_command): Replace mention of fork/checkpoint by
checkpoint only.
(detach_fork_command): Likewise. Don't delete the checkpoint from
the inferior list.
(info_forks_command): Adjust.
(restore_detach_fork): Delete.
(checkpointing_pid): New.
(linux_fork_checkpointing_p): New.
(save_detach_fork): Delete.
(checkpoint_command): Delete temp_detach_fork. Don't remove
breakpoints, that's a nop. Store the pid of the process we're
checkpointing, and use make_cleanup_restore_integer to restore it.
Don't reinsert breakpoints here.
(process_command, fork_command): Delete.
(restart_command): Update comments to only mention checkpoints,
not forks.
(_initialize_linux_fork): Delete "fork", "process", "info forks"
commands.
* linux-fork.h (fork_save_infrun_state, fork_list): Delete
declarations.
(linux_fork_checkpointing_p): Declare.
* cli/cli-cmds.c (killlist): New.
* cli/cli-cmds.h (killlist): Declare.
* gdbcmd.h (killlist): Declare.
* inferior.c: Include "gdbthread.h".
(detach_inferior_command, kill_inferior_command)
(inferior_command): New.
(info_inferiors_command): Allow specifying a specific inferior id.
(_initialize_inferiors): Register "inferior", "kill inferior" and
"detach inferior" commands.
* infcmd.c (_initialize_infcmd): Make "kill" a prefix command.
* gdbthread.h (any_thread_of_process): Declare.
* thread.c (any_thread_of_process): New.
* NEWS: Mention multi-inferior debugging. Mention 'info
inferiors', 'inferior', 'detach inferior' and 'kill inferior' as
new commands.
(Removed commands): New section, mentioning that 'info forks',
'fork', 'process', 'delete fork' and 'detach fork' are now gone.
gdb/testsuite/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.base/multi-forks.exp: Only run detach-on-fork tests on
linux. Adjust to use "inferior", "info inferiors", "detach
inferior" and "kill inferior" instead of "restart", "info fork",
"detach fork" and "delete fork".
* gdb.base/ending-run.exp: Spell out "info".
* gdb.base/help.exp: Adjust to use test_prefix_command_help for
the "kill" command.
gdb/doc/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (Debugging multiple inferiors): Document the
"inferior", "detach inferior" and "kill inferior" commands.
(Debugging Programs with Multiple Processes): Adjust to mention
generic "inferior" commands. Delete mention of "detach fork" and
"delete fork". Cross reference to "Debugging multiple inferiors"
section.
2009-07-02 23:57:28 +02:00
|
|
|
|
|
|
|
|
|
/* Retain child fork in ptrace (stopped) state. */
|
2011-03-01 01:40:22 +01:00
|
|
|
|
if (!find_fork_pid (new_pid))
|
|
|
|
|
add_fork (new_pid);
|
gdb/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* linux-nat.c (linux_child_follow_fork): If we're staying attached
to the child process, enable event reporting on it. Don't handle
checkpoints here. Instead, add the child fork to the lwp thread
and inferior lists without clobbering the previous inferior. Let
the thread_db layer learn about a new child process, even if
following the parent.
(linux_nat_switch_fork): Delete lwps of the current inferior only,
instead of clearing the whole list. Use thread_change_ptid to
give the core the illusion the new checkpoint is still the same
inferior. Clear the register cache.
(linux_handle_extended_wait): Handle checkpoints here.
(linux_multi_process): Turn on.
* linux-fork.c (struct fork_info) <pc>: Remove field.
(init_fork_list): Do not delete the checkpoint from the inferior
list (it is not there).
(fork_load_infrun_state): Don't switch inferior_ptid here. Pass
the new checkpoint's ptid to linux_nat_switch_fork.
(fork_save_infrun_state): Make static. Don't stop the pc field of
fork_info, it's gone.
(linux_fork_mourn_inferior): Don't delete the checkpoint from the
inferior list, it's not there.
(linux_fork_detach): Ditto.
(delete_fork_command): Replace mention of fork/checkpoint by
checkpoint only.
(detach_fork_command): Likewise. Don't delete the checkpoint from
the inferior list.
(info_forks_command): Adjust.
(restore_detach_fork): Delete.
(checkpointing_pid): New.
(linux_fork_checkpointing_p): New.
(save_detach_fork): Delete.
(checkpoint_command): Delete temp_detach_fork. Don't remove
breakpoints, that's a nop. Store the pid of the process we're
checkpointing, and use make_cleanup_restore_integer to restore it.
Don't reinsert breakpoints here.
(process_command, fork_command): Delete.
(restart_command): Update comments to only mention checkpoints,
not forks.
(_initialize_linux_fork): Delete "fork", "process", "info forks"
commands.
* linux-fork.h (fork_save_infrun_state, fork_list): Delete
declarations.
(linux_fork_checkpointing_p): Declare.
* cli/cli-cmds.c (killlist): New.
* cli/cli-cmds.h (killlist): Declare.
* gdbcmd.h (killlist): Declare.
* inferior.c: Include "gdbthread.h".
(detach_inferior_command, kill_inferior_command)
(inferior_command): New.
(info_inferiors_command): Allow specifying a specific inferior id.
(_initialize_inferiors): Register "inferior", "kill inferior" and
"detach inferior" commands.
* infcmd.c (_initialize_infcmd): Make "kill" a prefix command.
* gdbthread.h (any_thread_of_process): Declare.
* thread.c (any_thread_of_process): New.
* NEWS: Mention multi-inferior debugging. Mention 'info
inferiors', 'inferior', 'detach inferior' and 'kill inferior' as
new commands.
(Removed commands): New section, mentioning that 'info forks',
'fork', 'process', 'delete fork' and 'detach fork' are now gone.
gdb/testsuite/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.base/multi-forks.exp: Only run detach-on-fork tests on
linux. Adjust to use "inferior", "info inferiors", "detach
inferior" and "kill inferior" instead of "restart", "info fork",
"detach fork" and "delete fork".
* gdb.base/ending-run.exp: Spell out "info".
* gdb.base/help.exp: Adjust to use test_prefix_command_help for
the "kill" command.
gdb/doc/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (Debugging multiple inferiors): Document the
"inferior", "detach inferior" and "kill inferior" commands.
(Debugging Programs with Multiple Processes): Adjust to mention
generic "inferior" commands. Delete mention of "detach fork" and
"delete fork". Cross reference to "Debugging multiple inferiors"
section.
2009-07-02 23:57:28 +02:00
|
|
|
|
|
|
|
|
|
/* Report as spurious, so that infrun doesn't want to follow
|
|
|
|
|
this fork. We're actually doing an infcall in
|
|
|
|
|
linux-fork.c. */
|
|
|
|
|
ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
|
|
|
|
|
|
|
|
|
|
/* Report the stop to the core. */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-08 22:09:47 +01:00
|
|
|
|
if (event == PTRACE_EVENT_FORK)
|
|
|
|
|
ourstatus->kind = TARGET_WAITKIND_FORKED;
|
|
|
|
|
else if (event == PTRACE_EVENT_VFORK)
|
|
|
|
|
ourstatus->kind = TARGET_WAITKIND_VFORKED;
|
PR threads/18600: Threads left stopped after fork+thread spawn
When a program forks and another process start threads while gdb is
handling the fork event, newly created threads are left stuck stopped
by gdb, even though gdb presents them as "running", to the user.
This can be seen with the test added by this patch. The test has the
inferior fork a certain number of times and waits for all children to
exit. Each fork child spawns a number of threads that do nothing and
joins them immediately. Normally, the program should run unimpeded
(from the point of view of the user) and exit very quickly. Without
this fix, it doesn't because of some threads left stopped by gdb, so
inferior 1 never exits.
The program triggers when a new clone thread is found while inside the
linux_stop_and_wait_all_lwps call in linux-thread-db.c:
linux_stop_and_wait_all_lwps ();
ALL_LWPS (lp)
if (ptid_get_pid (lp->ptid) == pid)
thread_from_lwp (lp->ptid);
linux_unstop_all_lwps ();
Within linux_stop_and_wait_all_lwps, we reach
linux_handle_extended_wait with the "stopping" parameter set to 1, and
because of that we don't mark the new lwp as resumed. As consequence,
the subsequent resume_stopped_resumed_lwps, called from
linux_unstop_all_lwps, never resumes the new LWP.
There's lots of cruft in linux_handle_extended_wait that no longer
makes sense. On systems with CLONE events support, we don't rely on
libthread_db for thread listing anymore, so the code that preserves
stop_requested and the handling of last_resume_kind is all dead.
So the fix is to remove all that, and simply always mark the new LWP
as resumed, so that resume_stopped_resumed_lwps re-resumes it.
gdb/ChangeLog:
2015-07-30 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
PR threads/18600
* linux-nat.c (linux_handle_extended_wait): On CLONE event, always
mark the new thread as resumed. Remove STOPPING parameter.
(wait_lwp): Adjust call to linux_handle_extended_wait.
(linux_nat_filter_event): Adjust call to
linux_handle_extended_wait.
(resume_stopped_resumed_lwps): Add debug output.
gdb/testsuite/ChangeLog:
2015-07-30 Simon Marchi <simon.marchi@ericsson.com>
Pedro Alves <palves@redhat.com>
PR threads/18600
* gdb.threads/fork-plus-threads.c: New file.
* gdb.threads/fork-plus-threads.exp: New file.
2015-07-30 19:50:29 +02:00
|
|
|
|
else if (event == PTRACE_EVENT_CLONE)
|
2007-01-08 22:09:47 +01:00
|
|
|
|
{
|
2010-07-18 23:21:53 +02:00
|
|
|
|
struct lwp_info *new_lp;
|
|
|
|
|
|
2007-01-08 22:09:47 +01:00
|
|
|
|
ourstatus->kind = TARGET_WAITKIND_IGNORE;
|
2010-07-18 23:21:53 +02:00
|
|
|
|
|
2011-10-11 16:58:21 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LHEW: Got clone event "
|
|
|
|
|
"from LWP %d, new child is LWP %ld\n",
|
|
|
|
|
pid, new_pid);
|
|
|
|
|
|
2013-09-30 13:50:12 +02:00
|
|
|
|
new_lp = add_lwp (ptid_build (ptid_get_pid (lp->ptid), new_pid, 0));
|
2008-07-11 00:58:37 +02:00
|
|
|
|
new_lp->stopped = 1;
|
PR threads/18600: Threads left stopped after fork+thread spawn
When a program forks and another process start threads while gdb is
handling the fork event, newly created threads are left stuck stopped
by gdb, even though gdb presents them as "running", to the user.
This can be seen with the test added by this patch. The test has the
inferior fork a certain number of times and waits for all children to
exit. Each fork child spawns a number of threads that do nothing and
joins them immediately. Normally, the program should run unimpeded
(from the point of view of the user) and exit very quickly. Without
this fix, it doesn't because of some threads left stopped by gdb, so
inferior 1 never exits.
The program triggers when a new clone thread is found while inside the
linux_stop_and_wait_all_lwps call in linux-thread-db.c:
linux_stop_and_wait_all_lwps ();
ALL_LWPS (lp)
if (ptid_get_pid (lp->ptid) == pid)
thread_from_lwp (lp->ptid);
linux_unstop_all_lwps ();
Within linux_stop_and_wait_all_lwps, we reach
linux_handle_extended_wait with the "stopping" parameter set to 1, and
because of that we don't mark the new lwp as resumed. As consequence,
the subsequent resume_stopped_resumed_lwps, called from
linux_unstop_all_lwps, never resumes the new LWP.
There's lots of cruft in linux_handle_extended_wait that no longer
makes sense. On systems with CLONE events support, we don't rely on
libthread_db for thread listing anymore, so the code that preserves
stop_requested and the handling of last_resume_kind is all dead.
So the fix is to remove all that, and simply always mark the new LWP
as resumed, so that resume_stopped_resumed_lwps re-resumes it.
gdb/ChangeLog:
2015-07-30 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
PR threads/18600
* linux-nat.c (linux_handle_extended_wait): On CLONE event, always
mark the new thread as resumed. Remove STOPPING parameter.
(wait_lwp): Adjust call to linux_handle_extended_wait.
(linux_nat_filter_event): Adjust call to
linux_handle_extended_wait.
(resume_stopped_resumed_lwps): Add debug output.
gdb/testsuite/ChangeLog:
2015-07-30 Simon Marchi <simon.marchi@ericsson.com>
Pedro Alves <palves@redhat.com>
PR threads/18600
* gdb.threads/fork-plus-threads.c: New file.
* gdb.threads/fork-plus-threads.exp: New file.
2015-07-30 19:50:29 +02:00
|
|
|
|
new_lp->resumed = 1;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
GNU/Linux: Stop using libthread_db/td_ta_thr_iter
TL;DR - GDB can hang if something refreshes the thread list out of the
target while the target is running. GDB hangs inside td_ta_thr_iter.
The fix is to not use that libthread_db function anymore.
Long version:
Running the testsuite against my all-stop-on-top-of-non-stop series is
still exposing latent non-stop bugs.
I was originally seeing this with the multi-create.exp test, back when
we were still using libthread_db thread event breakpoints. The
all-stop-on-top-of-non-stop series forces a thread list refresh each
time GDB needs to start stepping over a breakpoint (to pause all
threads). That test hits the thread event breakpoint often, resulting
in a bunch of step-over operations, thus a bunch of thread list
refreshes while some threads in the target are running.
The commit adds a real non-stop mode test that triggers the issue,
based on multi-create.exp, that does an explicit "info threads" when a
breakpoint is hit. IOW, it does the same things the as-ns series was
doing when testing multi-create.exp.
The bug is a race, so it unfortunately takes several runs for the test
to trigger it. In fact, even when setting the test running in a loop,
it sometimes takes several minutes for it to trigger for me.
The race is related to libthread_db's td_ta_thr_iter. This is
libthread_db's entry point for walking the thread list of the
inferior.
Sometimes, when GDB refreshes the thread list from the target,
libthread_db's td_ta_thr_iter can somehow see glibc's thread list as a
cycle, and get stuck in an infinite loop.
The issue is that when a thread exits, its thread control structure in
glibc is moved from a "used" list to a "cache" list. These lists are
simply circular linked lists where the "next/prev" pointers are
embedded in the thread control structure itself. The "next" pointer
of the last element of the list points back to the list's sentinel
"head". There's only one set of "next/prev" pointers for both lists;
thus a thread can only be in one of the lists at a time, not in both
simultaneously.
So when thread C exits, simplifying, the following happens. A-C are
threads. stack_used and stack_cache are the list's heads.
Before:
stack_used -> A -> B -> C -> (&stack_used)
stack_cache -> (&stack_cache)
After:
stack_used -> A -> B -> (&stack_used)
stack_cache -> C -> (&stack_cache)
td_ta_thr_iter starts by iterating at the list's head's next, and
iterates until it sees a thread whose next pointer points to the
list's head again. Thus in the before case above, C's next points to
stack_used, indicating end of list. In the same case, the stack_cache
list is empty.
For each thread being iterated, td_ta_thr_iter reads the whole thread
object out of the inferior. This includes the thread's "next"
pointer.
In the scenario above, it may happen that td_ta_thr_iter is iterating
thread B and has already read B's thread structure just before thread
C exits and its control structure moves to the cached list.
Now, recall that td_ta_thr_iter is running in the context of GDB, and
there's no locking between GDB and the inferior. From it's local copy
of B, td_ta_thr_iter believes that the next thread after B is thread
C, so it happilly continues iterating to C, a thread that has already
exited, and is now in the stack cache list.
After iterating C, td_ta_thr_iter finds the stack_cache head, which
because it is not stack_used, td_ta_thr_iter assumes it's just another
thread. After this, unless the reverse race triggers, GDB gets stuck
in td_ta_thr_iter forever walking the stack_cache list, as no thread
in thatlist has a next pointer that points back to stack_used (the
terminating condition).
Before fully understanding the issue, I tried adding cycle detection
to GDB's td_ta_thr_iter callback. However, td_ta_thr_iter skips
calling the callback in some cases, which means that it's possible
that the callback isn't called at all, making it impossible for GDB to
break the loop. I did manage to get GDB stuck in that state more than
once.
Fortunately, we can avoid the issue altogether. We don't really need
td_ta_thr_iter for live debugging nowadays, given PTRACE_EVENT_CLONE.
We already know how to map and lwp id to a thread id without iterating
(thread_from_lwp), so use that more.
gdb/ChangeLog:
2015-02-20 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_handle_extended_wait): Call
thread_db_notice_clone whenever a new clone LWP is detected.
(linux_stop_and_wait_all_lwps, linux_unstop_all_lwps): New
functions.
* linux-nat.h (thread_db_attach_lwp): Delete declaration.
(thread_db_notice_clone, linux_stop_and_wait_all_lwps)
(linux_unstop_all_lwps): Declare.
* linux-thread-db.c (struct thread_get_info_inout): Delete.
(thread_get_info_callback): Delete.
(thread_from_lwp): Use td_thr_get_info and record_thread.
(thread_db_attach_lwp): Delete.
(thread_db_notice_clone): New function.
(try_thread_db_load_1): If /proc is mounted and shows the
process'es task list, walk over all LWPs and call thread_from_lwp
instead of relying on td_ta_thr_iter.
(attach_thread): Don't call check_thread_signals here. Split the
tail part of the function (which adds the thread to the core GDB
thread list) to ...
(record_thread): ... this function. Call check_thread_signals
here.
(thread_db_wait): Don't call thread_db_find_new_threads_1. Always
call thread_from_lwp.
(thread_db_update_thread_list): Rename to ...
(thread_db_update_thread_list_org): ... this.
(thread_db_update_thread_list): New function.
(thread_db_find_thread_from_tid): Delete.
(thread_db_get_ada_task_ptid): Simplify.
* nat/linux-procfs.c: Include <sys/stat.h>.
(linux_proc_task_list_dir_exists): New function.
* nat/linux-procfs.h (linux_proc_task_list_dir_exists): Declare.
gdb/gdbserver/ChangeLog:
2015-02-20 Pedro Alves <palves@redhat.com>
* thread-db.c: Include "nat/linux-procfs.h".
(thread_db_init): Skip listing new threads if the kernel supports
PTRACE_EVENT_CLONE and /proc/PID/task/ is accessible.
gdb/testsuite/ChangeLog:
2015-02-20 Pedro Alves <palves@redhat.com>
* gdb.threads/multi-create-ns-info-thr.exp: New file.
2015-02-20 21:21:59 +01:00
|
|
|
|
/* If the thread_db layer is active, let it record the user
|
|
|
|
|
level thread id and status, and add the thread to GDB's
|
|
|
|
|
list. */
|
|
|
|
|
if (!thread_db_notice_clone (lp->ptid, new_lp->ptid))
|
2007-01-08 22:09:47 +01:00
|
|
|
|
{
|
GNU/Linux: Stop using libthread_db/td_ta_thr_iter
TL;DR - GDB can hang if something refreshes the thread list out of the
target while the target is running. GDB hangs inside td_ta_thr_iter.
The fix is to not use that libthread_db function anymore.
Long version:
Running the testsuite against my all-stop-on-top-of-non-stop series is
still exposing latent non-stop bugs.
I was originally seeing this with the multi-create.exp test, back when
we were still using libthread_db thread event breakpoints. The
all-stop-on-top-of-non-stop series forces a thread list refresh each
time GDB needs to start stepping over a breakpoint (to pause all
threads). That test hits the thread event breakpoint often, resulting
in a bunch of step-over operations, thus a bunch of thread list
refreshes while some threads in the target are running.
The commit adds a real non-stop mode test that triggers the issue,
based on multi-create.exp, that does an explicit "info threads" when a
breakpoint is hit. IOW, it does the same things the as-ns series was
doing when testing multi-create.exp.
The bug is a race, so it unfortunately takes several runs for the test
to trigger it. In fact, even when setting the test running in a loop,
it sometimes takes several minutes for it to trigger for me.
The race is related to libthread_db's td_ta_thr_iter. This is
libthread_db's entry point for walking the thread list of the
inferior.
Sometimes, when GDB refreshes the thread list from the target,
libthread_db's td_ta_thr_iter can somehow see glibc's thread list as a
cycle, and get stuck in an infinite loop.
The issue is that when a thread exits, its thread control structure in
glibc is moved from a "used" list to a "cache" list. These lists are
simply circular linked lists where the "next/prev" pointers are
embedded in the thread control structure itself. The "next" pointer
of the last element of the list points back to the list's sentinel
"head". There's only one set of "next/prev" pointers for both lists;
thus a thread can only be in one of the lists at a time, not in both
simultaneously.
So when thread C exits, simplifying, the following happens. A-C are
threads. stack_used and stack_cache are the list's heads.
Before:
stack_used -> A -> B -> C -> (&stack_used)
stack_cache -> (&stack_cache)
After:
stack_used -> A -> B -> (&stack_used)
stack_cache -> C -> (&stack_cache)
td_ta_thr_iter starts by iterating at the list's head's next, and
iterates until it sees a thread whose next pointer points to the
list's head again. Thus in the before case above, C's next points to
stack_used, indicating end of list. In the same case, the stack_cache
list is empty.
For each thread being iterated, td_ta_thr_iter reads the whole thread
object out of the inferior. This includes the thread's "next"
pointer.
In the scenario above, it may happen that td_ta_thr_iter is iterating
thread B and has already read B's thread structure just before thread
C exits and its control structure moves to the cached list.
Now, recall that td_ta_thr_iter is running in the context of GDB, and
there's no locking between GDB and the inferior. From it's local copy
of B, td_ta_thr_iter believes that the next thread after B is thread
C, so it happilly continues iterating to C, a thread that has already
exited, and is now in the stack cache list.
After iterating C, td_ta_thr_iter finds the stack_cache head, which
because it is not stack_used, td_ta_thr_iter assumes it's just another
thread. After this, unless the reverse race triggers, GDB gets stuck
in td_ta_thr_iter forever walking the stack_cache list, as no thread
in thatlist has a next pointer that points back to stack_used (the
terminating condition).
Before fully understanding the issue, I tried adding cycle detection
to GDB's td_ta_thr_iter callback. However, td_ta_thr_iter skips
calling the callback in some cases, which means that it's possible
that the callback isn't called at all, making it impossible for GDB to
break the loop. I did manage to get GDB stuck in that state more than
once.
Fortunately, we can avoid the issue altogether. We don't really need
td_ta_thr_iter for live debugging nowadays, given PTRACE_EVENT_CLONE.
We already know how to map and lwp id to a thread id without iterating
(thread_from_lwp), so use that more.
gdb/ChangeLog:
2015-02-20 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_handle_extended_wait): Call
thread_db_notice_clone whenever a new clone LWP is detected.
(linux_stop_and_wait_all_lwps, linux_unstop_all_lwps): New
functions.
* linux-nat.h (thread_db_attach_lwp): Delete declaration.
(thread_db_notice_clone, linux_stop_and_wait_all_lwps)
(linux_unstop_all_lwps): Declare.
* linux-thread-db.c (struct thread_get_info_inout): Delete.
(thread_get_info_callback): Delete.
(thread_from_lwp): Use td_thr_get_info and record_thread.
(thread_db_attach_lwp): Delete.
(thread_db_notice_clone): New function.
(try_thread_db_load_1): If /proc is mounted and shows the
process'es task list, walk over all LWPs and call thread_from_lwp
instead of relying on td_ta_thr_iter.
(attach_thread): Don't call check_thread_signals here. Split the
tail part of the function (which adds the thread to the core GDB
thread list) to ...
(record_thread): ... this function. Call check_thread_signals
here.
(thread_db_wait): Don't call thread_db_find_new_threads_1. Always
call thread_from_lwp.
(thread_db_update_thread_list): Rename to ...
(thread_db_update_thread_list_org): ... this.
(thread_db_update_thread_list): New function.
(thread_db_find_thread_from_tid): Delete.
(thread_db_get_ada_task_ptid): Simplify.
* nat/linux-procfs.c: Include <sys/stat.h>.
(linux_proc_task_list_dir_exists): New function.
* nat/linux-procfs.h (linux_proc_task_list_dir_exists): Declare.
gdb/gdbserver/ChangeLog:
2015-02-20 Pedro Alves <palves@redhat.com>
* thread-db.c: Include "nat/linux-procfs.h".
(thread_db_init): Skip listing new threads if the kernel supports
PTRACE_EVENT_CLONE and /proc/PID/task/ is accessible.
gdb/testsuite/ChangeLog:
2015-02-20 Pedro Alves <palves@redhat.com>
* gdb.threads/multi-create-ns-info-thr.exp: New file.
2015-02-20 21:21:59 +01:00
|
|
|
|
/* The process is not using thread_db. Add the LWP to
|
|
|
|
|
GDB's list. */
|
|
|
|
|
target_post_attach (ptid_get_lwp (new_lp->ptid));
|
|
|
|
|
add_thread (new_lp->ptid);
|
|
|
|
|
}
|
2008-07-11 00:58:37 +02:00
|
|
|
|
|
2015-03-24 15:24:53 +01:00
|
|
|
|
/* Even if we're stopping the thread for some reason
|
PR threads/18600: Threads left stopped after fork+thread spawn
When a program forks and another process start threads while gdb is
handling the fork event, newly created threads are left stuck stopped
by gdb, even though gdb presents them as "running", to the user.
This can be seen with the test added by this patch. The test has the
inferior fork a certain number of times and waits for all children to
exit. Each fork child spawns a number of threads that do nothing and
joins them immediately. Normally, the program should run unimpeded
(from the point of view of the user) and exit very quickly. Without
this fix, it doesn't because of some threads left stopped by gdb, so
inferior 1 never exits.
The program triggers when a new clone thread is found while inside the
linux_stop_and_wait_all_lwps call in linux-thread-db.c:
linux_stop_and_wait_all_lwps ();
ALL_LWPS (lp)
if (ptid_get_pid (lp->ptid) == pid)
thread_from_lwp (lp->ptid);
linux_unstop_all_lwps ();
Within linux_stop_and_wait_all_lwps, we reach
linux_handle_extended_wait with the "stopping" parameter set to 1, and
because of that we don't mark the new lwp as resumed. As consequence,
the subsequent resume_stopped_resumed_lwps, called from
linux_unstop_all_lwps, never resumes the new LWP.
There's lots of cruft in linux_handle_extended_wait that no longer
makes sense. On systems with CLONE events support, we don't rely on
libthread_db for thread listing anymore, so the code that preserves
stop_requested and the handling of last_resume_kind is all dead.
So the fix is to remove all that, and simply always mark the new LWP
as resumed, so that resume_stopped_resumed_lwps re-resumes it.
gdb/ChangeLog:
2015-07-30 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
PR threads/18600
* linux-nat.c (linux_handle_extended_wait): On CLONE event, always
mark the new thread as resumed. Remove STOPPING parameter.
(wait_lwp): Adjust call to linux_handle_extended_wait.
(linux_nat_filter_event): Adjust call to
linux_handle_extended_wait.
(resume_stopped_resumed_lwps): Add debug output.
gdb/testsuite/ChangeLog:
2015-07-30 Simon Marchi <simon.marchi@ericsson.com>
Pedro Alves <palves@redhat.com>
PR threads/18600
* gdb.threads/fork-plus-threads.c: New file.
* gdb.threads/fork-plus-threads.exp: New file.
2015-07-30 19:50:29 +02:00
|
|
|
|
internal to this module, from the perspective of infrun
|
|
|
|
|
and the user/frontend, this new thread is running until
|
|
|
|
|
it next reports a stop. */
|
2015-03-24 15:24:53 +01:00
|
|
|
|
set_running (new_lp->ptid, 1);
|
PR threads/18600: Threads left stopped after fork+thread spawn
When a program forks and another process start threads while gdb is
handling the fork event, newly created threads are left stuck stopped
by gdb, even though gdb presents them as "running", to the user.
This can be seen with the test added by this patch. The test has the
inferior fork a certain number of times and waits for all children to
exit. Each fork child spawns a number of threads that do nothing and
joins them immediately. Normally, the program should run unimpeded
(from the point of view of the user) and exit very quickly. Without
this fix, it doesn't because of some threads left stopped by gdb, so
inferior 1 never exits.
The program triggers when a new clone thread is found while inside the
linux_stop_and_wait_all_lwps call in linux-thread-db.c:
linux_stop_and_wait_all_lwps ();
ALL_LWPS (lp)
if (ptid_get_pid (lp->ptid) == pid)
thread_from_lwp (lp->ptid);
linux_unstop_all_lwps ();
Within linux_stop_and_wait_all_lwps, we reach
linux_handle_extended_wait with the "stopping" parameter set to 1, and
because of that we don't mark the new lwp as resumed. As consequence,
the subsequent resume_stopped_resumed_lwps, called from
linux_unstop_all_lwps, never resumes the new LWP.
There's lots of cruft in linux_handle_extended_wait that no longer
makes sense. On systems with CLONE events support, we don't rely on
libthread_db for thread listing anymore, so the code that preserves
stop_requested and the handling of last_resume_kind is all dead.
So the fix is to remove all that, and simply always mark the new LWP
as resumed, so that resume_stopped_resumed_lwps re-resumes it.
gdb/ChangeLog:
2015-07-30 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
PR threads/18600
* linux-nat.c (linux_handle_extended_wait): On CLONE event, always
mark the new thread as resumed. Remove STOPPING parameter.
(wait_lwp): Adjust call to linux_handle_extended_wait.
(linux_nat_filter_event): Adjust call to
linux_handle_extended_wait.
(resume_stopped_resumed_lwps): Add debug output.
gdb/testsuite/ChangeLog:
2015-07-30 Simon Marchi <simon.marchi@ericsson.com>
Pedro Alves <palves@redhat.com>
PR threads/18600
* gdb.threads/fork-plus-threads.c: New file.
* gdb.threads/fork-plus-threads.exp: New file.
2015-07-30 19:50:29 +02:00
|
|
|
|
set_executing (new_lp->ptid, 1);
|
2008-07-11 00:58:37 +02:00
|
|
|
|
|
PR threads/18600: Threads left stopped after fork+thread spawn
When a program forks and another process start threads while gdb is
handling the fork event, newly created threads are left stuck stopped
by gdb, even though gdb presents them as "running", to the user.
This can be seen with the test added by this patch. The test has the
inferior fork a certain number of times and waits for all children to
exit. Each fork child spawns a number of threads that do nothing and
joins them immediately. Normally, the program should run unimpeded
(from the point of view of the user) and exit very quickly. Without
this fix, it doesn't because of some threads left stopped by gdb, so
inferior 1 never exits.
The program triggers when a new clone thread is found while inside the
linux_stop_and_wait_all_lwps call in linux-thread-db.c:
linux_stop_and_wait_all_lwps ();
ALL_LWPS (lp)
if (ptid_get_pid (lp->ptid) == pid)
thread_from_lwp (lp->ptid);
linux_unstop_all_lwps ();
Within linux_stop_and_wait_all_lwps, we reach
linux_handle_extended_wait with the "stopping" parameter set to 1, and
because of that we don't mark the new lwp as resumed. As consequence,
the subsequent resume_stopped_resumed_lwps, called from
linux_unstop_all_lwps, never resumes the new LWP.
There's lots of cruft in linux_handle_extended_wait that no longer
makes sense. On systems with CLONE events support, we don't rely on
libthread_db for thread listing anymore, so the code that preserves
stop_requested and the handling of last_resume_kind is all dead.
So the fix is to remove all that, and simply always mark the new LWP
as resumed, so that resume_stopped_resumed_lwps re-resumes it.
gdb/ChangeLog:
2015-07-30 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
PR threads/18600
* linux-nat.c (linux_handle_extended_wait): On CLONE event, always
mark the new thread as resumed. Remove STOPPING parameter.
(wait_lwp): Adjust call to linux_handle_extended_wait.
(linux_nat_filter_event): Adjust call to
linux_handle_extended_wait.
(resume_stopped_resumed_lwps): Add debug output.
gdb/testsuite/ChangeLog:
2015-07-30 Simon Marchi <simon.marchi@ericsson.com>
Pedro Alves <palves@redhat.com>
PR threads/18600
* gdb.threads/fork-plus-threads.c: New file.
* gdb.threads/fork-plus-threads.exp: New file.
2015-07-30 19:50:29 +02:00
|
|
|
|
if (WSTOPSIG (status) != SIGSTOP)
|
2011-10-10 18:40:02 +02:00
|
|
|
|
{
|
PR threads/18600: Threads left stopped after fork+thread spawn
When a program forks and another process start threads while gdb is
handling the fork event, newly created threads are left stuck stopped
by gdb, even though gdb presents them as "running", to the user.
This can be seen with the test added by this patch. The test has the
inferior fork a certain number of times and waits for all children to
exit. Each fork child spawns a number of threads that do nothing and
joins them immediately. Normally, the program should run unimpeded
(from the point of view of the user) and exit very quickly. Without
this fix, it doesn't because of some threads left stopped by gdb, so
inferior 1 never exits.
The program triggers when a new clone thread is found while inside the
linux_stop_and_wait_all_lwps call in linux-thread-db.c:
linux_stop_and_wait_all_lwps ();
ALL_LWPS (lp)
if (ptid_get_pid (lp->ptid) == pid)
thread_from_lwp (lp->ptid);
linux_unstop_all_lwps ();
Within linux_stop_and_wait_all_lwps, we reach
linux_handle_extended_wait with the "stopping" parameter set to 1, and
because of that we don't mark the new lwp as resumed. As consequence,
the subsequent resume_stopped_resumed_lwps, called from
linux_unstop_all_lwps, never resumes the new LWP.
There's lots of cruft in linux_handle_extended_wait that no longer
makes sense. On systems with CLONE events support, we don't rely on
libthread_db for thread listing anymore, so the code that preserves
stop_requested and the handling of last_resume_kind is all dead.
So the fix is to remove all that, and simply always mark the new LWP
as resumed, so that resume_stopped_resumed_lwps re-resumes it.
gdb/ChangeLog:
2015-07-30 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
PR threads/18600
* linux-nat.c (linux_handle_extended_wait): On CLONE event, always
mark the new thread as resumed. Remove STOPPING parameter.
(wait_lwp): Adjust call to linux_handle_extended_wait.
(linux_nat_filter_event): Adjust call to
linux_handle_extended_wait.
(resume_stopped_resumed_lwps): Add debug output.
gdb/testsuite/ChangeLog:
2015-07-30 Simon Marchi <simon.marchi@ericsson.com>
Pedro Alves <palves@redhat.com>
PR threads/18600
* gdb.threads/fork-plus-threads.c: New file.
* gdb.threads/fork-plus-threads.exp: New file.
2015-07-30 19:50:29 +02:00
|
|
|
|
/* This can happen if someone starts sending signals to
|
|
|
|
|
the new thread before it gets a chance to run, which
|
|
|
|
|
have a lower number than SIGSTOP (e.g. SIGUSR1).
|
|
|
|
|
This is an unlikely case, and harder to handle for
|
|
|
|
|
fork / vfork than for clone, so we do not try - but
|
|
|
|
|
we handle it for clone events here. */
|
|
|
|
|
|
|
|
|
|
new_lp->signalled = 1;
|
|
|
|
|
|
2011-10-10 18:40:02 +02:00
|
|
|
|
/* We created NEW_LP so it cannot yet contain STATUS. */
|
|
|
|
|
gdb_assert (new_lp->status == 0);
|
|
|
|
|
|
|
|
|
|
/* Save the wait status to report later. */
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LHEW: waitpid of new LWP %ld, "
|
|
|
|
|
"saving status %s\n",
|
2013-09-30 13:50:12 +02:00
|
|
|
|
(long) ptid_get_lwp (new_lp->ptid),
|
2011-10-10 18:40:02 +02:00
|
|
|
|
status_to_str (status));
|
|
|
|
|
new_lp->status = status;
|
|
|
|
|
}
|
2016-05-24 15:47:56 +02:00
|
|
|
|
else if (report_thread_events)
|
|
|
|
|
{
|
|
|
|
|
new_lp->waitstatus.kind = TARGET_WAITKIND_THREAD_CREATED;
|
|
|
|
|
new_lp->status = status;
|
|
|
|
|
}
|
2011-10-10 18:40:02 +02:00
|
|
|
|
|
2007-01-08 22:09:47 +01:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-08 22:09:47 +01:00
|
|
|
|
if (event == PTRACE_EVENT_EXEC)
|
|
|
|
|
{
|
2009-05-27 21:44:53 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LHEW: Got exec event from LWP %ld\n",
|
2013-09-30 13:50:12 +02:00
|
|
|
|
ptid_get_lwp (lp->ptid));
|
2009-05-27 21:44:53 +02:00
|
|
|
|
|
2007-01-08 22:09:47 +01:00
|
|
|
|
ourstatus->kind = TARGET_WAITKIND_EXECD;
|
|
|
|
|
ourstatus->value.execd_pathname
|
2013-12-18 05:35:01 +01:00
|
|
|
|
= xstrdup (linux_child_pid_to_exec_file (NULL, pid));
|
2007-01-08 22:09:47 +01:00
|
|
|
|
|
linux-nat.c: always mark execing LWP as resumed
A subsequent patch will make the Linux backend's target_wait method
pull all events out of the kernel (with waitpid) and store them as
pending status in the LWP structure if no pending status was already
available. Then, the backend goes over the pending statuses and pick
one to report to the core.
With that, the existing thread-execl.exp test exposes a bug, like:
(gdb) set scheduler-locking on
(gdb) PASS: gdb.threads/thread-execl.exp: schedlock on: set scheduler-locking on
next
FAIL: gdb.threads/thread-execl.exp: schedlock on: get to main in new image (timeout)
Recall that when the non-leader thread execs, all threads in the
process die, the execing thread changes its pid to the tgid, and then
waitpid returns an exec event to the tgid. If GDB didn't resume the
leader LWP, then GDB sees an event for an LWP that was supposedly
stopped, and thus not marked as resumed. Because the code that picks
a pending event to report to the core ignores not-resumed LWPs:
/* Return non-zero if LP has a wait status pending. */
static int
status_callback (struct lwp_info *lp, void *data)
{
/* Only report a pending wait status if we pretend that this has
indeed been resumed. */
if (!lp->resumed)
return 0;
the event ends up pending forever, thus the timeout.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_handle_extended_wait) <PTRACE_EVENT_EXEC>:
Set the LWP's 'resumed' flag.
2014-12-29 20:41:06 +01:00
|
|
|
|
/* The thread that execed must have been resumed, but, when a
|
|
|
|
|
thread execs, it changes its tid to the tgid, and the old
|
|
|
|
|
tgid thread might have not been resumed. */
|
|
|
|
|
lp->resumed = 1;
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (event == PTRACE_EVENT_VFORK_DONE)
|
|
|
|
|
{
|
|
|
|
|
if (current_inferior ()->waiting_for_vfork_done)
|
2007-01-08 22:09:47 +01:00
|
|
|
|
{
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
if (debug_linux_nat)
|
2011-01-05 23:22:53 +01:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LHEW: Got expected PTRACE_EVENT_"
|
|
|
|
|
"VFORK_DONE from LWP %ld: stopping\n",
|
2013-09-30 13:50:12 +02:00
|
|
|
|
ptid_get_lwp (lp->ptid));
|
2007-01-08 22:09:47 +01:00
|
|
|
|
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
ourstatus->kind = TARGET_WAITKIND_VFORK_DONE;
|
|
|
|
|
return 0;
|
2007-01-08 22:09:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
if (debug_linux_nat)
|
2011-01-05 23:22:53 +01:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LHEW: Got PTRACE_EVENT_VFORK_DONE "
|
2015-02-04 19:13:28 +01:00
|
|
|
|
"from LWP %ld: ignoring\n",
|
2013-09-30 13:50:12 +02:00
|
|
|
|
ptid_get_lwp (lp->ptid));
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
return 1;
|
2007-01-08 22:09:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal_error (__FILE__, __LINE__,
|
|
|
|
|
_("unknown ptrace event %d"), event);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-30 15:23:51 +01:00
|
|
|
|
/* Suspend waiting for a signal. We're mostly interested in
|
|
|
|
|
SIGCHLD/SIGINT. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
wait_for_signal ()
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "linux-nat: about to sigsuspend\n");
|
|
|
|
|
sigsuspend (&suspend_mask);
|
|
|
|
|
|
|
|
|
|
/* If the quit flag is set, it means that the user pressed Ctrl-C
|
|
|
|
|
and we're debugging a process that is running on a separate
|
|
|
|
|
terminal, so we must forward the Ctrl-C to the inferior. (If the
|
|
|
|
|
inferior is sharing GDB's terminal, then the Ctrl-C reaches the
|
|
|
|
|
inferior directly.) We must do this here because functions that
|
|
|
|
|
need to block waiting for a signal loop forever until there's an
|
|
|
|
|
event to report before returning back to the event loop. */
|
|
|
|
|
if (!target_terminal::is_ours ())
|
|
|
|
|
{
|
|
|
|
|
if (check_quit_flag ())
|
|
|
|
|
target_pass_ctrlc ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
/* Wait for LP to stop. Returns the wait status, or 0 if the LWP has
|
|
|
|
|
exited. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
wait_lwp (struct lwp_info *lp)
|
|
|
|
|
{
|
|
|
|
|
pid_t pid;
|
2011-05-27 18:55:39 +02:00
|
|
|
|
int status = 0;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
int thread_dead = 0;
|
2011-05-27 18:55:39 +02:00
|
|
|
|
sigset_t prev_mask;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
gdb_assert (!lp->stopped);
|
|
|
|
|
gdb_assert (lp->status == 0);
|
|
|
|
|
|
2011-05-27 18:55:39 +02:00
|
|
|
|
/* Make sure SIGCHLD is blocked for sigsuspend avoiding a race below. */
|
|
|
|
|
block_child_signals (&prev_mask);
|
|
|
|
|
|
|
|
|
|
for (;;)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
2015-12-17 15:20:51 +01:00
|
|
|
|
pid = my_waitpid (ptid_get_lwp (lp->ptid), &status, __WALL | WNOHANG);
|
2011-08-26 21:26:40 +02:00
|
|
|
|
if (pid == -1 && errno == ECHILD)
|
|
|
|
|
{
|
|
|
|
|
/* The thread has previously exited. We need to delete it
|
2015-12-17 15:20:51 +01:00
|
|
|
|
now because if this was a non-leader thread execing, we
|
|
|
|
|
won't get an exit event. See comments on exec events at
|
|
|
|
|
the top of the file. */
|
2011-08-26 21:26:40 +02:00
|
|
|
|
thread_dead = 1;
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "WL: %s vanished.\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
}
|
2011-05-27 18:55:39 +02:00
|
|
|
|
if (pid != 0)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* Bugs 10970, 12702.
|
|
|
|
|
Thread group leader may have exited in which case we'll lock up in
|
|
|
|
|
waitpid if there are other threads, even if they are all zombies too.
|
|
|
|
|
Basically, we're not supposed to use waitpid this way.
|
2015-12-17 15:20:51 +01:00
|
|
|
|
tkill(pid,0) cannot be used here as it gets ESRCH for both
|
|
|
|
|
for zombie and running processes.
|
2011-05-27 18:55:39 +02:00
|
|
|
|
|
|
|
|
|
As a workaround, check if we're waiting for the thread group leader and
|
|
|
|
|
if it's a zombie, and avoid calling waitpid if it is.
|
|
|
|
|
|
|
|
|
|
This is racy, what if the tgl becomes a zombie right after we check?
|
|
|
|
|
Therefore always use WNOHANG with sigsuspend - it is equivalent to
|
gdb/
* Makefile.in (linux-ptrace.o): New.
* common/linux-procfs.c (linux_proc_pid_is_zombie): New,
from linux-nat.c.
* common/linux-procfs.h (linux_proc_pid_is_zombie): New declaration.
* common/linux-ptrace.c: New file.
* config/alpha/alpha-linux.mh (NATDEPFILES): Add linux-ptrace.o.
* config/arm/linux.mh: Likewise.
* config/i386/linux.mh: Likewise.
* config/i386/linux64.mh: Likewise.
* config/ia64/linux.mh: Likewise.
* config/m32r/linux.mh: Likewise.
* config/m68k/linux.mh: Likewise.
* config/mips/linux.mh: Likewise.
* config/pa/linux.mh: Likewise.
* config/powerpc/linux.mh: Likewise.
* config/powerpc/ppc64-linux.mh: Likewise.
* config/powerpc/spu-linux.mh: Likewise.
* config/s390/s390.mh: Likewise.
* config/sparc/linux.mh: Likewise.
* config/sparc/linux64.mh: Likewise.
* config/xtensa/linux.mh: Likewise.
* linux-nat.c (linux_lwp_is_zombie): Remove, move it to
common/linux-procfs.c.
(wait_lwp): Rename linux_lwp_is_zombie to linux_proc_pid_is_zombie.
gdb/gdbserver/
* Makefile.in (linux-ptrace.o): New.
* configure.srv (arm*-*-linux*, bfin-*-*linux*, crisv32-*-linux*)
(cris-*-linux*, i[34567]86-*-linux*, ia64-*-linux*, m32r*-*-linux*)
(m68*-*-linux*, m68*-*-uclinux*, mips*-*-linux*, powerpc*-*-linux*)
(s390*-*-linux*, sh*-*-linux*, sparc*-*-linux*, tic6x-*-uclinux)
(x86_64-*-linux*, xtensa*-*-linux*): Add linux-ptrace.o to SRV_TGTOBJ
of these targets.
* linux-low.c (linux_attach_lwp_1): Remove redundent else clause.
2012-03-13 16:00:37 +01:00
|
|
|
|
waiting waitpid but linux_proc_pid_is_zombie is safe this way. */
|
2011-05-27 18:55:39 +02:00
|
|
|
|
|
2013-09-30 13:50:12 +02:00
|
|
|
|
if (ptid_get_pid (lp->ptid) == ptid_get_lwp (lp->ptid)
|
|
|
|
|
&& linux_proc_pid_is_zombie (ptid_get_lwp (lp->ptid)))
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
|
|
|
|
thread_dead = 1;
|
|
|
|
|
if (debug_linux_nat)
|
2011-05-27 18:55:39 +02:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"WL: Thread group leader %s vanished.\n",
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
target_pid_to_str (lp->ptid));
|
2011-05-27 18:55:39 +02:00
|
|
|
|
break;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
2011-05-27 18:55:39 +02:00
|
|
|
|
|
|
|
|
|
/* Wait for next SIGCHLD and try again. This may let SIGCHLD handlers
|
|
|
|
|
get invoked despite our caller had them intentionally blocked by
|
|
|
|
|
block_child_signals. This is sensitive only to the loop of
|
|
|
|
|
linux_nat_wait_1 and there if we get called my_waitpid gets called
|
|
|
|
|
again before it gets to sigsuspend so we can safely let the handlers
|
|
|
|
|
get executed here. */
|
2018-01-30 15:23:51 +01:00
|
|
|
|
wait_for_signal ();
|
2011-05-27 18:55:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
restore_child_signals_mask (&prev_mask);
|
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
if (!thread_dead)
|
|
|
|
|
{
|
2013-09-30 13:50:12 +02:00
|
|
|
|
gdb_assert (pid == ptid_get_lwp (lp->ptid));
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
{
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"WL: waitpid %s received %s\n",
|
|
|
|
|
target_pid_to_str (lp->ptid),
|
|
|
|
|
status_to_str (status));
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-26 21:26:40 +02:00
|
|
|
|
/* Check if the thread has exited. */
|
|
|
|
|
if (WIFEXITED (status) || WIFSIGNALED (status))
|
|
|
|
|
{
|
2016-05-24 15:47:56 +02:00
|
|
|
|
if (report_thread_events
|
|
|
|
|
|| ptid_get_pid (lp->ptid) == ptid_get_lwp (lp->ptid))
|
2015-07-22 19:01:46 +02:00
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
2016-05-24 15:47:56 +02:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "WL: LWP %d exited.\n",
|
2015-07-22 19:01:46 +02:00
|
|
|
|
ptid_get_pid (lp->ptid));
|
|
|
|
|
|
2016-05-24 15:47:56 +02:00
|
|
|
|
/* If this is the leader exiting, it means the whole
|
2015-07-22 19:01:46 +02:00
|
|
|
|
process is gone. Store the status to report to the
|
|
|
|
|
core. Store it in lp->waitstatus, because lp->status
|
|
|
|
|
would be ambiguous (W_EXITCODE(0,0) == 0). */
|
|
|
|
|
store_waitstatus (&lp->waitstatus, status);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-26 21:26:40 +02:00
|
|
|
|
thread_dead = 1;
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "WL: %s exited.\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
}
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (thread_dead)
|
|
|
|
|
{
|
2006-02-02 03:29:29 +01:00
|
|
|
|
exit_lwp (lp);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gdb_assert (WIFSTOPPED (status));
|
PR gdb/15713 - errors from i386_linux_resume lead to lock-up
linux_nat_resume is not considering that linux_ops->to_resume may throw:
/* Mark LWP as not stopped to prevent it from being continued by
linux_nat_resume_callback. */
lp->stopped = 0;
if (resume_many)
iterate_over_lwps (ptid, linux_nat_resume_callback, NULL);
If something within linux_nat_resume_callback throws, GDB leaves the
lwp_info as if the inferior was resumed, while it actually wasn't.
A couple examples, there are possibly others:
- i386_linux_resume calls target_read which calls QUIT.
- if the actual ptrace resumption fails in inf_ptrace_resume,
perror_with_name is called.
If the user tries to kill the inferior at this point (or quit, which
offers to kill), GDB locks up trying to stop the lwp -- if it is
already stopped no new waitpid event gets generated for it.
Fix this by setting the stopped flag earlier, as soon as we collect a
stop event with waitpid, and clearing it always only after resuming
the lwp successfully.
Tested on x86_64 Fedora 20. Confirmed the lock-up disappears using a
local hack that forces an error in inf_ptrace_resume.
Also fixes a little "set debug lin-lwp" annoyance. Currently we always see:
Continuing.
LLR: Preparing to resume process 6802, 0, inferior_ptid Thread 0x7ffff7fc7740 (LWP 6802)
^^^^^^^^
RC: Resuming sibling Thread 0x7ffff77c5700 (LWP 6807), 0, resume
RC: Resuming sibling Thread 0x7ffff7fc6700 (LWP 6806), 0, resume
RC: Not resuming sibling Thread 0x7ffff7fc7740 (LWP 6802) (not stopped)
^^^^^^^^^^^^^^^^^^^^^^^
LLR: PTRACE_CONT process 6802, 0 (resume event thread)
This patch gets rid of the "Not resuming sibling" line.
2014-05-29 Pedro Alves <palves@redhat.com>
PR gdb/15713
* linux-nat.c (linux_nat_resume_callback): Rename the second
parameter to 'except'. Skip LP if it points to EXCEPT.
(linux_nat_resume): Don't mark the event lwp as not stopped
before resuming sibling lwps. Instead ask
linux_nat_resume_callback to skip the event lwp. Mark it as not
stopped after actually resuming it.
(linux_handle_syscall_trap): Mark the lwp as not stopped after
resuming it.
(wait_lwp): Mark the lwp as stopped here.
(stop_wait_callback): Mark the lwp as not stopped right after
resuming it. Don't mark lwps as stopped here.
(linux_nat_filter_event): Mark the lwp as stopped earlier.
(linux_nat_wait_1): Don't mark dead lwps as stopped here.
2014-05-29 13:50:48 +02:00
|
|
|
|
lp->stopped = 1;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
Linux: on attach, attach to lwps listed under /proc/$pid/task/
... instead of relying on libthread_db.
I wrote a test that attaches to a program that constantly spawns
short-lived threads, which exposed several issues. This is one of
them.
On Linux, we need to attach to all threads of a process (thread group)
individually. We currently rely on libthread_db to list the threads,
but that is problematic, because libthread_db relies on reading data
structures out of the inferior (which may well be corrupted). If
threads are being created or exiting just while we try to attach, we
may trip on inconsistencies in the inferior's thread list. To work
around that, when we see a seemingly corrupt list, we currently retry
a few times:
static void
thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new)
{
...
if (until_no_new)
{
/* Require 4 successive iterations which do not find any new threads.
The 4 is a heuristic: there is an inherent race here, and I have
seen that 2 iterations in a row are not always sufficient to
"capture" all threads. */
...
That heuristic may well fail, and when it does, we end up with threads
in the program that aren't under GDB's control. That's obviously bad
and results in quite mistifying failures, like e.g., the process dying
for seeminly no reason when a thread that wasn't attached trips on a
breakpoint.
There's really no reason to rely on libthread_db for this nowadays
when we have /proc mounted. In that case, which is the usual case, we
can list the LWPs from /proc/PID/task/. In fact, GDBserver is already
doing this. The patch factors out that code that knows to walk the
task/ directory out of GDBserver, and makes GDB use it too.
Like GDBserver, the patch makes GDB attach to LWPs and _not_ wait for
them to stop immediately. Instead, we just tag the LWP as having an
expected stop. Because we can only set the ptrace options when the
thread stops, we need a new flag in the lwp structure to keep track of
whether we've already set the ptrace options, just like in GDBserver.
Note that nothing issues any ptrace command to the threads between the
PTRACE_ATTACH and the stop, so this is safe (unlike one scenario
described in gdbserver's linux-low.c).
When we attach to a program that has threads exiting while we attach,
it's easy to race with a thread just exiting as we try to attach to
it, like:
#1 - get current list of threads
#2 - attach to each listed thread
#3 - ooops, attach failed, thread is already gone
As this is pretty normal, we shouldn't be issuing a scary warning in
step #3.
When #3 happens, PTRACE_ATTACH usually fails with ESRCH, but sometimes
we'll see EPERM as well. That happens when the kernel still has the
thread in its task list, but the thread is marked as dead.
Unfortunately, EPERM is ambiguous and we'll get it also on other
scenarios where the thread isn't dead, and in those cases, it's useful
to get a warning. To distiguish the cases, when we get an EPERM
failure, we open /proc/PID/status, and check the thread's state -- if
the /proc file no longer exists, or the state is "Z (Zombie)" or "X
(Dead)", we ignore the EPERM error silently; otherwise, we'll warn.
Unfortunately, there seems to be a kernel race here. Sometimes I get
EPERM, and then the /proc state still indicates "R (Running)"... If
we wait a bit and retry, we do end up seeing X or Z state, or get an
ESRCH. I thought of making GDB retry the attach a few times, but even
with a 500ms wait and 4 retries, I still see the warning sometimes. I
haven't been able to identify the kernel path that causes this yet,
but in any case, it looks like a kernel bug to me. As this just
results failure to suppress a warning that we've been printing since
about forever anyway, I'm just making the test cope with it, and issue
an XFAIL.
gdb/gdbserver/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_attach_fail_reason_string): Move to
nat/linux-ptrace.c, and rename.
(linux_attach_lwp): Update comment.
(attach_proc_task_lwp_callback): New function.
(linux_attach): Adjust to rename and use
linux_proc_attach_tgid_threads.
(linux_attach_fail_reason_string): Delete declaration.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-nat.c (attach_proc_task_lwp_callback): New function.
(linux_nat_attach): Use linux_proc_attach_tgid_threads.
(wait_lwp, linux_nat_filter_event): If not set yet, set the lwp's
ptrace option flags.
* linux-nat.h (struct lwp_info) <must_set_ptrace_flags>: New
field.
* nat/linux-procfs.c: Include <dirent.h>.
(linux_proc_get_int): New parameter "warn". Handle it.
(linux_proc_get_tgid): Adjust.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this.
(linux_proc_pid_get_state): New function, factored out from
(linux_proc_pid_has_state): ... this. Add new parameter "warn"
and handle it.
(linux_proc_pid_is_gone): New function.
(linux_proc_pid_is_stopped): Adjust.
(linux_proc_pid_is_zombie_maybe_warn)
(linux_proc_pid_is_zombie_nowarn): New functions.
(linux_proc_pid_is_zombie): Use
linux_proc_pid_is_zombie_maybe_warn.
(linux_proc_attach_tgid_threads): New function.
* nat/linux-procfs.h (linux_proc_get_tgid): Update comment.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this, and update comment.
(linux_proc_pid_is_gone): New declaration.
(linux_proc_pid_is_zombie): Update comment.
(linux_proc_pid_is_zombie_nowarn): New declaration.
(linux_proc_attach_lwp_func): New typedef.
(linux_proc_attach_tgid_threads): New declaration.
* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason): Adjust to
use nowarn functions.
(linux_ptrace_attach_fail_reason_string): Move here from
gdbserver/linux-low.c and rename.
(ptrace_supports_feature): If the current ptrace options are not
known yet, check them now, instead of asserting.
* nat/linux-ptrace.h (linux_ptrace_attach_fail_reason_string):
Declare.
2014-12-16 17:12:24 +01:00
|
|
|
|
if (lp->must_set_ptrace_flags)
|
|
|
|
|
{
|
|
|
|
|
struct inferior *inf = find_inferior_pid (ptid_get_pid (lp->ptid));
|
Extended-remote Linux follow fork
This patch implements basic support for follow-fork and detach-on-fork on
extended-remote Linux targets. Only 'fork' is supported in this patch;
'vfork' support is added n a subsequent patch. This patch depends on
the previous patches in the patch series.
Sufficient extended-remote functionality has been implemented here to pass
gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the
catchpoint tests commented out. Some other fork tests fail with this
patch because it doesn't provide the architecture support needed for
watchpoint inheritance or fork catchpoints.
The implementation follows the same general structure as for the native
implementation as much as possible.
This implementation includes:
* enabling fork events in linux-low.c in initialize_low and
linux_enable_extended_features
* handling fork events in gdbserver/linux-low.c:handle_extended_wait
- when a fork event occurs in gdbserver, we must do the full creation
of the new process, thread, lwp, and breakpoint lists. This is
required whether or not the new child is destined to be
detached-on-fork, because GDB will make target calls that require all
the structures. In particular we need the breakpoint lists in order
to remove the breakpoints from a detaching child. If we are not
detaching the child we will need all these structures anyway.
- as part of this event handling we store the target_waitstatus in a new
member of the parent lwp_info structure, 'waitstatus'. This
is used to store extended event information for reporting to GDB.
- handle_extended_wait is given a return value, denoting whether the
handled event should be reported to GDB. Previously it had only
handled clone events, which were never reported.
* using a new predicate in gdbserver to control handling of the fork event
(and eventually all extended events) in linux_wait_1. The predicate,
extended_event_reported, checks a target_waitstatus.kind for an
extended ptrace event.
* implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in
gdbserver/remote-utils.c and remote.c.
* implementing new target and RSP support for target_follow_fork with
target extended-remote. (The RSP components were actually defined in
patch 1, but they see their first use here).
- remote target routine remote_follow_fork, which just sends the 'D;pid'
detach packet to detach the new fork child cleanly. We can't just
call target_detach because the data structures for the forked child
have not been allocated on the host side.
Tested on x64 Ubuntu Lucid, native, remote, extended-remote.
gdb/gdbserver/ChangeLog:
* linux-low.c (handle_extended_wait): Implement return value,
rename argument 'event_child' to 'event_lwp', handle
PTRACE_EVENT_FORK, call internal_error for unrecognized event.
(linux_low_ptrace_options): New function.
(linux_low_filter_event): Call linux_low_ptrace_options,
use different argument fo linux_enable_event_reporting,
use return value from handle_extended_wait.
(extended_event_reported): New function.
(linux_wait_1): Call extended_event_reported and set
status to report fork events.
(linux_write_memory): Add pid to debug message.
(reset_lwp_ptrace_options_callback): New function.
(linux_handle_new_gdb_connection): New function.
(linux_target_ops): Initialize new structure member.
* linux-low.h (struct lwp_info) <waitstatus>: New member.
* lynx-low.c: Initialize new structure member.
* remote-utils.c (prepare_resume_reply): Implement stop reason
"fork" for "T" stop message.
* server.c (handle_query): Call handle_new_gdb_connection.
* server.h (report_fork_events): Declare global flag.
* target.h (struct target_ops) <handle_new_gdb_connection>:
New member.
(target_handle_new_gdb_connection): New macro.
* win32-low.c: Initialize new structure member.
gdb/ChangeLog:
* linux-nat.c (linux_nat_ptrace_options): New function.
(linux_init_ptrace, wait_lwp, linux_nat_filter_event):
Call linux_nat_ptrace_options and use different argument to
linux_enable_event_reporting.
(_initialize_linux_nat): Delete call to
linux_ptrace_set_additional_flags.
* nat/linux-ptrace.c (current_ptrace_options): Rename to
supported_ptrace_options.
(additional_flags): Delete variable.
(linux_check_ptrace_features): Use supported_ptrace_options.
(linux_test_for_tracesysgood, linux_test_for_tracefork):
Likewise, and remove additional_flags check.
(linux_enable_event_reporting): Change 'attached' argument to
'options'. Use supported_ptrace_options.
(ptrace_supports_feature): Change comment. Use
supported_ptrace_options.
(linux_ptrace_set_additional_flags): Delete function.
* nat/linux-ptrace.h (linux_ptrace_set_additional_flags):
Delete function prototype.
* remote.c (remote_fork_event_p): New function.
(remote_detach_pid): New function.
(remote_detach_1): Call remote_detach_pid, don't mourn inferior
if doing detach-on-fork.
(remote_follow_fork): New function.
(remote_parse_stop_reply): Handle new "T" stop reason "fork".
(remote_pid_to_str): Print "process" strings for pid/0/0 ptids.
(init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
|
|
|
|
int options = linux_nat_ptrace_options (inf->attach_flag);
|
Linux: on attach, attach to lwps listed under /proc/$pid/task/
... instead of relying on libthread_db.
I wrote a test that attaches to a program that constantly spawns
short-lived threads, which exposed several issues. This is one of
them.
On Linux, we need to attach to all threads of a process (thread group)
individually. We currently rely on libthread_db to list the threads,
but that is problematic, because libthread_db relies on reading data
structures out of the inferior (which may well be corrupted). If
threads are being created or exiting just while we try to attach, we
may trip on inconsistencies in the inferior's thread list. To work
around that, when we see a seemingly corrupt list, we currently retry
a few times:
static void
thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new)
{
...
if (until_no_new)
{
/* Require 4 successive iterations which do not find any new threads.
The 4 is a heuristic: there is an inherent race here, and I have
seen that 2 iterations in a row are not always sufficient to
"capture" all threads. */
...
That heuristic may well fail, and when it does, we end up with threads
in the program that aren't under GDB's control. That's obviously bad
and results in quite mistifying failures, like e.g., the process dying
for seeminly no reason when a thread that wasn't attached trips on a
breakpoint.
There's really no reason to rely on libthread_db for this nowadays
when we have /proc mounted. In that case, which is the usual case, we
can list the LWPs from /proc/PID/task/. In fact, GDBserver is already
doing this. The patch factors out that code that knows to walk the
task/ directory out of GDBserver, and makes GDB use it too.
Like GDBserver, the patch makes GDB attach to LWPs and _not_ wait for
them to stop immediately. Instead, we just tag the LWP as having an
expected stop. Because we can only set the ptrace options when the
thread stops, we need a new flag in the lwp structure to keep track of
whether we've already set the ptrace options, just like in GDBserver.
Note that nothing issues any ptrace command to the threads between the
PTRACE_ATTACH and the stop, so this is safe (unlike one scenario
described in gdbserver's linux-low.c).
When we attach to a program that has threads exiting while we attach,
it's easy to race with a thread just exiting as we try to attach to
it, like:
#1 - get current list of threads
#2 - attach to each listed thread
#3 - ooops, attach failed, thread is already gone
As this is pretty normal, we shouldn't be issuing a scary warning in
step #3.
When #3 happens, PTRACE_ATTACH usually fails with ESRCH, but sometimes
we'll see EPERM as well. That happens when the kernel still has the
thread in its task list, but the thread is marked as dead.
Unfortunately, EPERM is ambiguous and we'll get it also on other
scenarios where the thread isn't dead, and in those cases, it's useful
to get a warning. To distiguish the cases, when we get an EPERM
failure, we open /proc/PID/status, and check the thread's state -- if
the /proc file no longer exists, or the state is "Z (Zombie)" or "X
(Dead)", we ignore the EPERM error silently; otherwise, we'll warn.
Unfortunately, there seems to be a kernel race here. Sometimes I get
EPERM, and then the /proc state still indicates "R (Running)"... If
we wait a bit and retry, we do end up seeing X or Z state, or get an
ESRCH. I thought of making GDB retry the attach a few times, but even
with a 500ms wait and 4 retries, I still see the warning sometimes. I
haven't been able to identify the kernel path that causes this yet,
but in any case, it looks like a kernel bug to me. As this just
results failure to suppress a warning that we've been printing since
about forever anyway, I'm just making the test cope with it, and issue
an XFAIL.
gdb/gdbserver/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_attach_fail_reason_string): Move to
nat/linux-ptrace.c, and rename.
(linux_attach_lwp): Update comment.
(attach_proc_task_lwp_callback): New function.
(linux_attach): Adjust to rename and use
linux_proc_attach_tgid_threads.
(linux_attach_fail_reason_string): Delete declaration.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-nat.c (attach_proc_task_lwp_callback): New function.
(linux_nat_attach): Use linux_proc_attach_tgid_threads.
(wait_lwp, linux_nat_filter_event): If not set yet, set the lwp's
ptrace option flags.
* linux-nat.h (struct lwp_info) <must_set_ptrace_flags>: New
field.
* nat/linux-procfs.c: Include <dirent.h>.
(linux_proc_get_int): New parameter "warn". Handle it.
(linux_proc_get_tgid): Adjust.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this.
(linux_proc_pid_get_state): New function, factored out from
(linux_proc_pid_has_state): ... this. Add new parameter "warn"
and handle it.
(linux_proc_pid_is_gone): New function.
(linux_proc_pid_is_stopped): Adjust.
(linux_proc_pid_is_zombie_maybe_warn)
(linux_proc_pid_is_zombie_nowarn): New functions.
(linux_proc_pid_is_zombie): Use
linux_proc_pid_is_zombie_maybe_warn.
(linux_proc_attach_tgid_threads): New function.
* nat/linux-procfs.h (linux_proc_get_tgid): Update comment.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this, and update comment.
(linux_proc_pid_is_gone): New declaration.
(linux_proc_pid_is_zombie): Update comment.
(linux_proc_pid_is_zombie_nowarn): New declaration.
(linux_proc_attach_lwp_func): New typedef.
(linux_proc_attach_tgid_threads): New declaration.
* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason): Adjust to
use nowarn functions.
(linux_ptrace_attach_fail_reason_string): Move here from
gdbserver/linux-low.c and rename.
(ptrace_supports_feature): If the current ptrace options are not
known yet, check them now, instead of asserting.
* nat/linux-ptrace.h (linux_ptrace_attach_fail_reason_string):
Declare.
2014-12-16 17:12:24 +01:00
|
|
|
|
|
Extended-remote Linux follow fork
This patch implements basic support for follow-fork and detach-on-fork on
extended-remote Linux targets. Only 'fork' is supported in this patch;
'vfork' support is added n a subsequent patch. This patch depends on
the previous patches in the patch series.
Sufficient extended-remote functionality has been implemented here to pass
gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the
catchpoint tests commented out. Some other fork tests fail with this
patch because it doesn't provide the architecture support needed for
watchpoint inheritance or fork catchpoints.
The implementation follows the same general structure as for the native
implementation as much as possible.
This implementation includes:
* enabling fork events in linux-low.c in initialize_low and
linux_enable_extended_features
* handling fork events in gdbserver/linux-low.c:handle_extended_wait
- when a fork event occurs in gdbserver, we must do the full creation
of the new process, thread, lwp, and breakpoint lists. This is
required whether or not the new child is destined to be
detached-on-fork, because GDB will make target calls that require all
the structures. In particular we need the breakpoint lists in order
to remove the breakpoints from a detaching child. If we are not
detaching the child we will need all these structures anyway.
- as part of this event handling we store the target_waitstatus in a new
member of the parent lwp_info structure, 'waitstatus'. This
is used to store extended event information for reporting to GDB.
- handle_extended_wait is given a return value, denoting whether the
handled event should be reported to GDB. Previously it had only
handled clone events, which were never reported.
* using a new predicate in gdbserver to control handling of the fork event
(and eventually all extended events) in linux_wait_1. The predicate,
extended_event_reported, checks a target_waitstatus.kind for an
extended ptrace event.
* implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in
gdbserver/remote-utils.c and remote.c.
* implementing new target and RSP support for target_follow_fork with
target extended-remote. (The RSP components were actually defined in
patch 1, but they see their first use here).
- remote target routine remote_follow_fork, which just sends the 'D;pid'
detach packet to detach the new fork child cleanly. We can't just
call target_detach because the data structures for the forked child
have not been allocated on the host side.
Tested on x64 Ubuntu Lucid, native, remote, extended-remote.
gdb/gdbserver/ChangeLog:
* linux-low.c (handle_extended_wait): Implement return value,
rename argument 'event_child' to 'event_lwp', handle
PTRACE_EVENT_FORK, call internal_error for unrecognized event.
(linux_low_ptrace_options): New function.
(linux_low_filter_event): Call linux_low_ptrace_options,
use different argument fo linux_enable_event_reporting,
use return value from handle_extended_wait.
(extended_event_reported): New function.
(linux_wait_1): Call extended_event_reported and set
status to report fork events.
(linux_write_memory): Add pid to debug message.
(reset_lwp_ptrace_options_callback): New function.
(linux_handle_new_gdb_connection): New function.
(linux_target_ops): Initialize new structure member.
* linux-low.h (struct lwp_info) <waitstatus>: New member.
* lynx-low.c: Initialize new structure member.
* remote-utils.c (prepare_resume_reply): Implement stop reason
"fork" for "T" stop message.
* server.c (handle_query): Call handle_new_gdb_connection.
* server.h (report_fork_events): Declare global flag.
* target.h (struct target_ops) <handle_new_gdb_connection>:
New member.
(target_handle_new_gdb_connection): New macro.
* win32-low.c: Initialize new structure member.
gdb/ChangeLog:
* linux-nat.c (linux_nat_ptrace_options): New function.
(linux_init_ptrace, wait_lwp, linux_nat_filter_event):
Call linux_nat_ptrace_options and use different argument to
linux_enable_event_reporting.
(_initialize_linux_nat): Delete call to
linux_ptrace_set_additional_flags.
* nat/linux-ptrace.c (current_ptrace_options): Rename to
supported_ptrace_options.
(additional_flags): Delete variable.
(linux_check_ptrace_features): Use supported_ptrace_options.
(linux_test_for_tracesysgood, linux_test_for_tracefork):
Likewise, and remove additional_flags check.
(linux_enable_event_reporting): Change 'attached' argument to
'options'. Use supported_ptrace_options.
(ptrace_supports_feature): Change comment. Use
supported_ptrace_options.
(linux_ptrace_set_additional_flags): Delete function.
* nat/linux-ptrace.h (linux_ptrace_set_additional_flags):
Delete function prototype.
* remote.c (remote_fork_event_p): New function.
(remote_detach_pid): New function.
(remote_detach_1): Call remote_detach_pid, don't mourn inferior
if doing detach-on-fork.
(remote_follow_fork): New function.
(remote_parse_stop_reply): Handle new "T" stop reason "fork".
(remote_pid_to_str): Print "process" strings for pid/0/0 ptids.
(init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
|
|
|
|
linux_enable_event_reporting (ptid_get_lwp (lp->ptid), options);
|
Linux: on attach, attach to lwps listed under /proc/$pid/task/
... instead of relying on libthread_db.
I wrote a test that attaches to a program that constantly spawns
short-lived threads, which exposed several issues. This is one of
them.
On Linux, we need to attach to all threads of a process (thread group)
individually. We currently rely on libthread_db to list the threads,
but that is problematic, because libthread_db relies on reading data
structures out of the inferior (which may well be corrupted). If
threads are being created or exiting just while we try to attach, we
may trip on inconsistencies in the inferior's thread list. To work
around that, when we see a seemingly corrupt list, we currently retry
a few times:
static void
thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new)
{
...
if (until_no_new)
{
/* Require 4 successive iterations which do not find any new threads.
The 4 is a heuristic: there is an inherent race here, and I have
seen that 2 iterations in a row are not always sufficient to
"capture" all threads. */
...
That heuristic may well fail, and when it does, we end up with threads
in the program that aren't under GDB's control. That's obviously bad
and results in quite mistifying failures, like e.g., the process dying
for seeminly no reason when a thread that wasn't attached trips on a
breakpoint.
There's really no reason to rely on libthread_db for this nowadays
when we have /proc mounted. In that case, which is the usual case, we
can list the LWPs from /proc/PID/task/. In fact, GDBserver is already
doing this. The patch factors out that code that knows to walk the
task/ directory out of GDBserver, and makes GDB use it too.
Like GDBserver, the patch makes GDB attach to LWPs and _not_ wait for
them to stop immediately. Instead, we just tag the LWP as having an
expected stop. Because we can only set the ptrace options when the
thread stops, we need a new flag in the lwp structure to keep track of
whether we've already set the ptrace options, just like in GDBserver.
Note that nothing issues any ptrace command to the threads between the
PTRACE_ATTACH and the stop, so this is safe (unlike one scenario
described in gdbserver's linux-low.c).
When we attach to a program that has threads exiting while we attach,
it's easy to race with a thread just exiting as we try to attach to
it, like:
#1 - get current list of threads
#2 - attach to each listed thread
#3 - ooops, attach failed, thread is already gone
As this is pretty normal, we shouldn't be issuing a scary warning in
step #3.
When #3 happens, PTRACE_ATTACH usually fails with ESRCH, but sometimes
we'll see EPERM as well. That happens when the kernel still has the
thread in its task list, but the thread is marked as dead.
Unfortunately, EPERM is ambiguous and we'll get it also on other
scenarios where the thread isn't dead, and in those cases, it's useful
to get a warning. To distiguish the cases, when we get an EPERM
failure, we open /proc/PID/status, and check the thread's state -- if
the /proc file no longer exists, or the state is "Z (Zombie)" or "X
(Dead)", we ignore the EPERM error silently; otherwise, we'll warn.
Unfortunately, there seems to be a kernel race here. Sometimes I get
EPERM, and then the /proc state still indicates "R (Running)"... If
we wait a bit and retry, we do end up seeing X or Z state, or get an
ESRCH. I thought of making GDB retry the attach a few times, but even
with a 500ms wait and 4 retries, I still see the warning sometimes. I
haven't been able to identify the kernel path that causes this yet,
but in any case, it looks like a kernel bug to me. As this just
results failure to suppress a warning that we've been printing since
about forever anyway, I'm just making the test cope with it, and issue
an XFAIL.
gdb/gdbserver/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_attach_fail_reason_string): Move to
nat/linux-ptrace.c, and rename.
(linux_attach_lwp): Update comment.
(attach_proc_task_lwp_callback): New function.
(linux_attach): Adjust to rename and use
linux_proc_attach_tgid_threads.
(linux_attach_fail_reason_string): Delete declaration.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-nat.c (attach_proc_task_lwp_callback): New function.
(linux_nat_attach): Use linux_proc_attach_tgid_threads.
(wait_lwp, linux_nat_filter_event): If not set yet, set the lwp's
ptrace option flags.
* linux-nat.h (struct lwp_info) <must_set_ptrace_flags>: New
field.
* nat/linux-procfs.c: Include <dirent.h>.
(linux_proc_get_int): New parameter "warn". Handle it.
(linux_proc_get_tgid): Adjust.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this.
(linux_proc_pid_get_state): New function, factored out from
(linux_proc_pid_has_state): ... this. Add new parameter "warn"
and handle it.
(linux_proc_pid_is_gone): New function.
(linux_proc_pid_is_stopped): Adjust.
(linux_proc_pid_is_zombie_maybe_warn)
(linux_proc_pid_is_zombie_nowarn): New functions.
(linux_proc_pid_is_zombie): Use
linux_proc_pid_is_zombie_maybe_warn.
(linux_proc_attach_tgid_threads): New function.
* nat/linux-procfs.h (linux_proc_get_tgid): Update comment.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this, and update comment.
(linux_proc_pid_is_gone): New declaration.
(linux_proc_pid_is_zombie): Update comment.
(linux_proc_pid_is_zombie_nowarn): New declaration.
(linux_proc_attach_lwp_func): New typedef.
(linux_proc_attach_tgid_threads): New declaration.
* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason): Adjust to
use nowarn functions.
(linux_ptrace_attach_fail_reason_string): Move here from
gdbserver/linux-low.c and rename.
(ptrace_supports_feature): If the current ptrace options are not
known yet, check them now, instead of asserting.
* nat/linux-ptrace.h (linux_ptrace_attach_fail_reason_string):
Declare.
2014-12-16 17:12:24 +01:00
|
|
|
|
lp->must_set_ptrace_flags = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-02 18:51:04 +02:00
|
|
|
|
/* Handle GNU/Linux's syscall SIGTRAPs. */
|
|
|
|
|
if (WIFSTOPPED (status) && WSTOPSIG (status) == SYSCALL_SIGTRAP)
|
|
|
|
|
{
|
|
|
|
|
/* No longer need the sysgood bit. The ptrace event ends up
|
|
|
|
|
recorded in lp->waitstatus if we care for it. We can carry
|
|
|
|
|
on handling the event like a regular SIGTRAP from here
|
|
|
|
|
on. */
|
|
|
|
|
status = W_STOPCODE (SIGTRAP);
|
|
|
|
|
if (linux_handle_syscall_trap (lp, 1))
|
|
|
|
|
return wait_lwp (lp);
|
|
|
|
|
}
|
gdb: Improve syscall entry/return tracking on Linux
The existing logic was simply to flip syscall entry/return state when a
syscall trap was seen, and even then only with active 'catch syscall'.
That can get out of sync if 'catch syscall' is toggled at odd times.
This patch updates the entry/return state for all syscall traps,
regardless of catching state, and also updates known syscall state for
other kinds of traps. Almost all PTRACE_EVENT stops are delivered from
the middle of a syscall, so this can act like an entry. Every other
kind of ptrace stop is only delivered outside of syscall event pairs, so
marking them ignored ensures the next syscall trap looks like an entry.
Three new test scenarios are added to catch-syscall.exp:
- Disable 'catch syscall' from an entry to deliberately miss the return
event, then re-enable to make sure a new entry is recognized.
- Enable 'catch syscall' for the first time from a vfork event, which is
a PTRACE_EVENT_VFORK in the middle of the syscall. Make sure the next
syscall event is recognized as the return.
- Make sure entry and return are recognized for an ENOSYS syscall. This
is to defeat a common x86 hack that uses the pre-filled ENOSYS return
value as a sign of being on the entry side.
gdb/ChangeLog:
2015-10-19 Josh Stone <jistone@redhat.com>
* linux-nat.c (linux_handle_syscall_trap): Always update entry/
return state, even when not actively catching syscalls at all.
(linux_handle_extended_wait): Mark syscall_state like an entry.
(wait_lwp): Set syscall_state ignored for other traps.
(linux_nat_filter_event): Likewise.
gdb/testsuite/ChangeLog:
2015-10-19 Josh Stone <jistone@redhat.com>
* gdb.base/catch-syscall.c: Include <sched.h>.
(unknown_syscall): New variable.
(main): Trigger a vfork and an unknown syscall.
* gdb.base/catch-syscall.exp (vfork_syscalls): New variable.
(unknown_syscall_number): Likewise.
(check_call_to_syscall): Accept an optional syscall pattern.
(check_return_from_syscall): Likewise.
(check_continue): Likewise.
(test_catch_syscall_without_args): Check for vfork and ENOSYS.
(test_catch_syscall_skipping_return): New test toggling off 'catch
syscall' to step over the syscall return, then toggling back on.
(test_catch_syscall_mid_vfork): New test turning on 'catch syscall'
during a PTRACE_EVENT_VFORK stop, in the middle of a vfork syscall.
(do_syscall_tests): Call test_catch_syscall_without_args and
test_catch_syscall_mid_vfork.
(test_catch_syscall_without_args_noxml): Check for vfork and ENOSYS.
(fill_all_syscalls_numbers): Initialize unknown_syscall_number.
2015-10-20 02:59:38 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Almost all other ptrace-stops are known to be outside of system
|
|
|
|
|
calls, with further exceptions in linux_handle_extended_wait. */
|
|
|
|
|
lp->syscall_state = TARGET_WAITKIND_IGNORE;
|
|
|
|
|
}
|
2009-10-02 18:51:04 +02:00
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
/* Handle GNU/Linux's extended waitstatus for trace events. */
|
2014-09-19 19:54:34 +02:00
|
|
|
|
if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP
|
|
|
|
|
&& linux_is_extended_waitstatus (status))
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"WL: Handling extended status 0x%06x\n",
|
|
|
|
|
status);
|
PR threads/18600: Threads left stopped after fork+thread spawn
When a program forks and another process start threads while gdb is
handling the fork event, newly created threads are left stuck stopped
by gdb, even though gdb presents them as "running", to the user.
This can be seen with the test added by this patch. The test has the
inferior fork a certain number of times and waits for all children to
exit. Each fork child spawns a number of threads that do nothing and
joins them immediately. Normally, the program should run unimpeded
(from the point of view of the user) and exit very quickly. Without
this fix, it doesn't because of some threads left stopped by gdb, so
inferior 1 never exits.
The program triggers when a new clone thread is found while inside the
linux_stop_and_wait_all_lwps call in linux-thread-db.c:
linux_stop_and_wait_all_lwps ();
ALL_LWPS (lp)
if (ptid_get_pid (lp->ptid) == pid)
thread_from_lwp (lp->ptid);
linux_unstop_all_lwps ();
Within linux_stop_and_wait_all_lwps, we reach
linux_handle_extended_wait with the "stopping" parameter set to 1, and
because of that we don't mark the new lwp as resumed. As consequence,
the subsequent resume_stopped_resumed_lwps, called from
linux_unstop_all_lwps, never resumes the new LWP.
There's lots of cruft in linux_handle_extended_wait that no longer
makes sense. On systems with CLONE events support, we don't rely on
libthread_db for thread listing anymore, so the code that preserves
stop_requested and the handling of last_resume_kind is all dead.
So the fix is to remove all that, and simply always mark the new LWP
as resumed, so that resume_stopped_resumed_lwps re-resumes it.
gdb/ChangeLog:
2015-07-30 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
PR threads/18600
* linux-nat.c (linux_handle_extended_wait): On CLONE event, always
mark the new thread as resumed. Remove STOPPING parameter.
(wait_lwp): Adjust call to linux_handle_extended_wait.
(linux_nat_filter_event): Adjust call to
linux_handle_extended_wait.
(resume_stopped_resumed_lwps): Add debug output.
gdb/testsuite/ChangeLog:
2015-07-30 Simon Marchi <simon.marchi@ericsson.com>
Pedro Alves <palves@redhat.com>
PR threads/18600
* gdb.threads/fork-plus-threads.c: New file.
* gdb.threads/fork-plus-threads.exp: New file.
2015-07-30 19:50:29 +02:00
|
|
|
|
linux_handle_extended_wait (lp, status);
|
2015-02-04 19:13:28 +01:00
|
|
|
|
return 0;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Send a SIGSTOP to LP. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
stop_callback (struct lwp_info *lp, void *data)
|
|
|
|
|
{
|
|
|
|
|
if (!lp->stopped && !lp->signalled)
|
|
|
|
|
{
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
{
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"SC: kill %s **<SIGSTOP>**\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
}
|
|
|
|
|
errno = 0;
|
2013-09-30 13:50:12 +02:00
|
|
|
|
ret = kill_lwp (ptid_get_lwp (lp->ptid), SIGSTOP);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
{
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"SC: lwp kill %d %s\n",
|
|
|
|
|
ret,
|
|
|
|
|
errno ? safe_strerror (errno) : "ERRNO-OK");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lp->signalled = 1;
|
|
|
|
|
gdb_assert (lp->status == 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
gdb/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* linux-nat.c (linux_nat_new_thread): Change parameter to an lwp
pointer.
(linux_nat_prepare_to_resume): New global.
(lwp_free): New.
(purge_lwp_list): Use it.
(add_lwp): Call linux_nat_new_thread even on the first LWP.
Adjust to interface change.
(delete_lwp): Call lwp_free instead of xfree.
(detach_callback, linux_nat_detach, resume_lwp, linux_nat_resume)
(linux_handle_syscall_trap, linux_handle_extended_wait)
(linux_nat_filter_event, resume_stopped_resumed_lwps): Call
linux_nat_prepare_to_resume before resuming.
(linux_stop_lwp): New.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* linux-nat.h (struct arch_lwp_info): Forward declare.
(struct lwp_info) <arch_private>: New field.
(linux_stop_lwp): Declare.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* i386-nat.c (DR_NADDR, DR_STATUS, DR_CONTROL)
(struct i386_debug_reg_state): Move to i386-nat.h.
(dr_mirror): Comment.
(i386_debug_reg_state): New.
(i386_update_inferior_debug_regs): Simplify.
(i386_stopped_data_address): Use the debug register state from the
inferior, not from the local cache.
* i386-nat.h (struct i386_dr_low_type): Delete reset_addr and
unset_status fields. New get_addr and get_control fields.
(DR_FIRSTADDR, DR_LASTADDR, DR_CONTROL): Moved from i386-nat.c.
(DR_NADDR, DR_STATUS): New.
(struct i386_debug_reg_state): Moved from i386-nat.c.
* amd64-linux-nat.c (struct arch_lwp_info): New.
(amd64_linux_dr): Delete global.
(amd64_linux_dr_get_addr): New.
(amd64_linux_dr_get_control): New.
(amd64_linux_dr_unset_status): Delete.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_dr_reset_addr): Delete.
(update_debug_registers_callback): New.
(amd64_linux_dr_set_control): Reimplement.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_prepare_to_resume): New.
(amd64_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_amd64_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
amd64_linux_dr_get_control as i386_dr_low.get_control. Install
amd64_linux_dr_get_addr as i386_dr_low.get_addr. Install
amd64_linux_prepare_to_resume.
* i386-linux-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(struct arch_lwp_info): New.
(i386_linux_dr): Delete global.
(i386_linux_dr_set_control): Reimplement.
(i386_linux_dr_get_addr): New.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_dr_get_control): New.
(update_debug_registers_callback): New.
(i386_linux_dr_unset_status): Delete.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_prepare_to_resume): New.
(i386_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_i386_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386_linux_dr_get_control as i386_dr_low.get_control. Install
i386_linux_dr_get_addr as i386_dr_low.get_addr. Install
i386_linux_prepare_to_resume.
* arm-linux-nat.c (arm_linux_new_thread): Change parameter to an
lwp pointer. Adjust.
* ia64-linux-nat.c (ia64_linux_new_thread): Likewise.
* mips-linux-nat.c (mips_linux_new_thread): Likewise.
* ppc-linux-nat.c (ppc_linux_new_thread): Likewise.
* s390-nat.c (s390_fix_watch_points): Likewise.
* i386-darwin-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(i386_darwin_dr_reset_addr): Delete.
(i386_darwin_dr_get_addr): New.
(i386_darwin_dr_get_control): New.
* go32-nat.c
(go32_get_dr7, go32_get_dr): New.
(init_go32_ops): No longer install i386_dr_low.reset_addr.
Install go32_get_dr7 as i386_dr_low.get_control. Install
go32_get_dr as i386_dr_low.get_addr.
* i386bsd-nat.c (i386bsd_dr_get): New.
(i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_status): Use i386bsd_dr_get.
(i386bsd_dr_get_control): New.
* i386bsd-nat.h (i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_control): New.
* i386fbsd-nat.c (_initialize_i386fbsd_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386bsd_dr_get_control as i386_dr_low.get_control. Install
i386bsd_dr_get_addr as i386_dr_low.get_addr.
* windows-nat.c (init_windows_ops): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
cygwin_get_dr7 as i386_dr_low.get_control. Install cygwin_get_dr
as i386_dr_low.get_addr.
(cygwin_get_dr): New.
(cygwin_get_dr7): New.
gdb/testsuite/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* gdb.mi/watch-nonstop.c: New file.
* gdb.mi/mi-watch-nonstop.exp: New file.
2011-12-14 18:20:32 +01:00
|
|
|
|
/* Request a stop on LWP. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
linux_stop_lwp (struct lwp_info *lwp)
|
|
|
|
|
{
|
|
|
|
|
stop_callback (lwp, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
GNU/Linux: Stop using libthread_db/td_ta_thr_iter
TL;DR - GDB can hang if something refreshes the thread list out of the
target while the target is running. GDB hangs inside td_ta_thr_iter.
The fix is to not use that libthread_db function anymore.
Long version:
Running the testsuite against my all-stop-on-top-of-non-stop series is
still exposing latent non-stop bugs.
I was originally seeing this with the multi-create.exp test, back when
we were still using libthread_db thread event breakpoints. The
all-stop-on-top-of-non-stop series forces a thread list refresh each
time GDB needs to start stepping over a breakpoint (to pause all
threads). That test hits the thread event breakpoint often, resulting
in a bunch of step-over operations, thus a bunch of thread list
refreshes while some threads in the target are running.
The commit adds a real non-stop mode test that triggers the issue,
based on multi-create.exp, that does an explicit "info threads" when a
breakpoint is hit. IOW, it does the same things the as-ns series was
doing when testing multi-create.exp.
The bug is a race, so it unfortunately takes several runs for the test
to trigger it. In fact, even when setting the test running in a loop,
it sometimes takes several minutes for it to trigger for me.
The race is related to libthread_db's td_ta_thr_iter. This is
libthread_db's entry point for walking the thread list of the
inferior.
Sometimes, when GDB refreshes the thread list from the target,
libthread_db's td_ta_thr_iter can somehow see glibc's thread list as a
cycle, and get stuck in an infinite loop.
The issue is that when a thread exits, its thread control structure in
glibc is moved from a "used" list to a "cache" list. These lists are
simply circular linked lists where the "next/prev" pointers are
embedded in the thread control structure itself. The "next" pointer
of the last element of the list points back to the list's sentinel
"head". There's only one set of "next/prev" pointers for both lists;
thus a thread can only be in one of the lists at a time, not in both
simultaneously.
So when thread C exits, simplifying, the following happens. A-C are
threads. stack_used and stack_cache are the list's heads.
Before:
stack_used -> A -> B -> C -> (&stack_used)
stack_cache -> (&stack_cache)
After:
stack_used -> A -> B -> (&stack_used)
stack_cache -> C -> (&stack_cache)
td_ta_thr_iter starts by iterating at the list's head's next, and
iterates until it sees a thread whose next pointer points to the
list's head again. Thus in the before case above, C's next points to
stack_used, indicating end of list. In the same case, the stack_cache
list is empty.
For each thread being iterated, td_ta_thr_iter reads the whole thread
object out of the inferior. This includes the thread's "next"
pointer.
In the scenario above, it may happen that td_ta_thr_iter is iterating
thread B and has already read B's thread structure just before thread
C exits and its control structure moves to the cached list.
Now, recall that td_ta_thr_iter is running in the context of GDB, and
there's no locking between GDB and the inferior. From it's local copy
of B, td_ta_thr_iter believes that the next thread after B is thread
C, so it happilly continues iterating to C, a thread that has already
exited, and is now in the stack cache list.
After iterating C, td_ta_thr_iter finds the stack_cache head, which
because it is not stack_used, td_ta_thr_iter assumes it's just another
thread. After this, unless the reverse race triggers, GDB gets stuck
in td_ta_thr_iter forever walking the stack_cache list, as no thread
in thatlist has a next pointer that points back to stack_used (the
terminating condition).
Before fully understanding the issue, I tried adding cycle detection
to GDB's td_ta_thr_iter callback. However, td_ta_thr_iter skips
calling the callback in some cases, which means that it's possible
that the callback isn't called at all, making it impossible for GDB to
break the loop. I did manage to get GDB stuck in that state more than
once.
Fortunately, we can avoid the issue altogether. We don't really need
td_ta_thr_iter for live debugging nowadays, given PTRACE_EVENT_CLONE.
We already know how to map and lwp id to a thread id without iterating
(thread_from_lwp), so use that more.
gdb/ChangeLog:
2015-02-20 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_handle_extended_wait): Call
thread_db_notice_clone whenever a new clone LWP is detected.
(linux_stop_and_wait_all_lwps, linux_unstop_all_lwps): New
functions.
* linux-nat.h (thread_db_attach_lwp): Delete declaration.
(thread_db_notice_clone, linux_stop_and_wait_all_lwps)
(linux_unstop_all_lwps): Declare.
* linux-thread-db.c (struct thread_get_info_inout): Delete.
(thread_get_info_callback): Delete.
(thread_from_lwp): Use td_thr_get_info and record_thread.
(thread_db_attach_lwp): Delete.
(thread_db_notice_clone): New function.
(try_thread_db_load_1): If /proc is mounted and shows the
process'es task list, walk over all LWPs and call thread_from_lwp
instead of relying on td_ta_thr_iter.
(attach_thread): Don't call check_thread_signals here. Split the
tail part of the function (which adds the thread to the core GDB
thread list) to ...
(record_thread): ... this function. Call check_thread_signals
here.
(thread_db_wait): Don't call thread_db_find_new_threads_1. Always
call thread_from_lwp.
(thread_db_update_thread_list): Rename to ...
(thread_db_update_thread_list_org): ... this.
(thread_db_update_thread_list): New function.
(thread_db_find_thread_from_tid): Delete.
(thread_db_get_ada_task_ptid): Simplify.
* nat/linux-procfs.c: Include <sys/stat.h>.
(linux_proc_task_list_dir_exists): New function.
* nat/linux-procfs.h (linux_proc_task_list_dir_exists): Declare.
gdb/gdbserver/ChangeLog:
2015-02-20 Pedro Alves <palves@redhat.com>
* thread-db.c: Include "nat/linux-procfs.h".
(thread_db_init): Skip listing new threads if the kernel supports
PTRACE_EVENT_CLONE and /proc/PID/task/ is accessible.
gdb/testsuite/ChangeLog:
2015-02-20 Pedro Alves <palves@redhat.com>
* gdb.threads/multi-create-ns-info-thr.exp: New file.
2015-02-20 21:21:59 +01:00
|
|
|
|
/* See linux-nat.h */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
linux_stop_and_wait_all_lwps (void)
|
|
|
|
|
{
|
|
|
|
|
/* Stop all LWP's ... */
|
|
|
|
|
iterate_over_lwps (minus_one_ptid, stop_callback, NULL);
|
|
|
|
|
|
|
|
|
|
/* ... and wait until all of them have reported back that
|
|
|
|
|
they're no longer running. */
|
|
|
|
|
iterate_over_lwps (minus_one_ptid, stop_wait_callback, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See linux-nat.h */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
linux_unstop_all_lwps (void)
|
|
|
|
|
{
|
|
|
|
|
iterate_over_lwps (minus_one_ptid,
|
|
|
|
|
resume_stopped_resumed_lwps, &minus_one_ptid);
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-27 23:12:40 +02:00
|
|
|
|
/* Return non-zero if LWP PID has a pending SIGINT. */
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
static int
|
2008-07-27 23:12:40 +02:00
|
|
|
|
linux_nat_has_pending_sigint (int pid)
|
|
|
|
|
{
|
|
|
|
|
sigset_t pending, blocked, ignored;
|
|
|
|
|
|
|
|
|
|
linux_proc_pending_signals (pid, &pending, &blocked, &ignored);
|
|
|
|
|
|
|
|
|
|
if (sigismember (&pending, SIGINT)
|
|
|
|
|
&& !sigismember (&ignored, SIGINT))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set a flag in LP indicating that we should ignore its next SIGINT. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
set_ignore_sigint (struct lwp_info *lp, void *data)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
2008-07-27 23:12:40 +02:00
|
|
|
|
/* If a thread has a pending SIGINT, consume it; otherwise, set a
|
|
|
|
|
flag to consume the next one. */
|
|
|
|
|
if (lp->stopped && lp->status != 0 && WIFSTOPPED (lp->status)
|
|
|
|
|
&& WSTOPSIG (lp->status) == SIGINT)
|
|
|
|
|
lp->status = 0;
|
|
|
|
|
else
|
|
|
|
|
lp->ignore_sigint = 1;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If LP does not have a SIGINT pending, then clear the ignore_sigint flag.
|
|
|
|
|
This function is called after we know the LWP has stopped; if the LWP
|
|
|
|
|
stopped before the expected SIGINT was delivered, then it will never have
|
|
|
|
|
arrived. Also, if the signal was delivered to a shared queue and consumed
|
|
|
|
|
by a different thread, it will never be delivered to this LWP. */
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
2008-07-27 23:12:40 +02:00
|
|
|
|
static void
|
|
|
|
|
maybe_clear_ignore_sigint (struct lwp_info *lp)
|
|
|
|
|
{
|
|
|
|
|
if (!lp->ignore_sigint)
|
|
|
|
|
return;
|
|
|
|
|
|
2013-09-30 13:50:12 +02:00
|
|
|
|
if (!linux_nat_has_pending_sigint (ptid_get_lwp (lp->ptid)))
|
2008-07-27 23:12:40 +02:00
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"MCIS: Clearing bogus flag for %s\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
lp->ignore_sigint = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-20 20:52:08 +01:00
|
|
|
|
/* Fetch the possible triggered data watchpoint info and store it in
|
|
|
|
|
LP.
|
|
|
|
|
|
|
|
|
|
On some archs, like x86, that use debug registers to set
|
|
|
|
|
watchpoints, it's possible that the way to know which watched
|
|
|
|
|
address trapped, is to check the register that is used to select
|
|
|
|
|
which address to watch. Problem is, between setting the watchpoint
|
|
|
|
|
and reading back which data address trapped, the user may change
|
|
|
|
|
the set of watchpoints, and, as a consequence, GDB changes the
|
|
|
|
|
debug registers in the inferior. To avoid reading back a stale
|
|
|
|
|
stopped-data-address when that happens, we cache in LP the fact
|
|
|
|
|
that a watchpoint trapped, and the corresponding data address, as
|
|
|
|
|
soon as we see LP stop with a SIGTRAP. If GDB changes the debug
|
|
|
|
|
registers meanwhile, we have the cached data we can rely on. */
|
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
static int
|
|
|
|
|
check_stopped_by_watchpoint (struct lwp_info *lp)
|
2009-11-20 20:52:08 +01:00
|
|
|
|
{
|
|
|
|
|
if (linux_ops->to_stopped_by_watchpoint == NULL)
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
return 0;
|
2009-11-20 20:52:08 +01:00
|
|
|
|
|
Remove save_inferior_ptid
This removes save_inferior_ptid, a cleanup function, in favor of
scoped_restore.
This also fixes a possible (it seems unlikely that it could happen in
practice) memory leak -- save_inferior_ptid should have used
make_cleanup_dtor, because it allocated memory.
I tested this on the buildbot. However, there are two caveats to
this. First, sometimes it seems I misread the results. Second, I
think this patch touches some platforms that can't be tested by the
buildbot. So, extra care seems warranted.
ChangeLog
2017-08-18 Tom Tromey <tom@tromey.com>
Pedro Alves <palves@redhat.com>
* spu-multiarch.c (parse_spufs_run): Use scoped_restore.
* sol-thread.c (sol_thread_resume, sol_thread_wait)
(sol_thread_xfer_partial, rw_common): Use scoped_restore.
* procfs.c (procfs_do_thread_registers): Use scoped_restore.
* proc-service.c (ps_xfer_memory): Use scoped_restore.
* linux-tdep.c (linux_corefile_thread): Remove a cleanup.
(linux_get_siginfo_data): Add "thread" argument. Use
scoped_restore.
* linux-nat.c (linux_child_follow_fork)
(check_stopped_by_watchpoint): Use scoped_restore.
* infrun.c (displaced_step_prepare_throw, write_memory_ptid)
(THREAD_STOPPED_BY, handle_signal_stop): Use scoped_restore.
(restore_inferior_ptid, save_inferior_ptid): Remove.
* btrace.c (btrace_fetch): Use scoped_restore.
* bsd-uthread.c (bsd_uthread_fetch_registers)
(bsd_uthread_store_registers): Use scoped_restore.
* breakpoint.c (reattach_breakpoints, detach_breakpoints): Use
scoped_restore.
* aix-thread.c (aix_thread_resume, aix_thread_wait)
(aix_thread_xfer_partial): Use scoped_restore.
* inferior.h (save_inferior_ptid): Remove.
2017-08-16 07:36:09 +02:00
|
|
|
|
scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
|
2009-11-20 20:52:08 +01:00
|
|
|
|
inferior_ptid = lp->ptid;
|
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
if (linux_ops->to_stopped_by_watchpoint (linux_ops))
|
2009-11-20 20:52:08 +01:00
|
|
|
|
{
|
2015-03-04 21:41:15 +01:00
|
|
|
|
lp->stop_reason = TARGET_STOPPED_BY_WATCHPOINT;
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
|
2009-11-20 20:52:08 +01:00
|
|
|
|
if (linux_ops->to_stopped_data_address != NULL)
|
|
|
|
|
lp->stopped_data_address_p =
|
|
|
|
|
linux_ops->to_stopped_data_address (¤t_target,
|
|
|
|
|
&lp->stopped_data_address);
|
|
|
|
|
else
|
|
|
|
|
lp->stopped_data_address_p = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-04 21:41:15 +01:00
|
|
|
|
return lp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT;
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns true if the LWP had stopped for a watchpoint. */
|
2009-11-20 20:52:08 +01:00
|
|
|
|
|
|
|
|
|
static int
|
add "this" pointers to more target APIs
A subsequent pass introduces delegation helper functions to the target
API. This delegation is much cleaner if the target_ops pointer is
directly available at delegation time.
This patch adds the "this" pointer to various to_* methods for this
purpose.
This updates a number of ports which I am unable to test. Please give
them a look-over. Any possible problem here is trivial, though, as
all that is required is adding an argument to a function.
2014-02-19 Tom Tromey <tromey@redhat.com>
* aarch64-linux-nat.c (aarch64_linux_stopped_by_watchpoint):
Add 'ops' argument.
* arm-linux-nat.c (arm_linux_stopped_by_watchpoint): Add
'ops' argument.
* i386-nat.c (i386_stopped_by_watchpoint): Add 'ops' argument.
* ia64-linux-nat.c (ia64_linux_stopped_by_watchpoint): Add
'ops' argument.
* inf-ttrace.c (inf_ttrace_stopped_by_watchpoint): Add 'ops'
argument.
* linux-nat.c (save_sigtrap): Update.
(linux_nat_stopped_by_watchpoint, linux_nat_is_async_p)
(linux_nat_can_async_p, linux_nat_async): Add 'ops' argument.
(linux_nat_close): Update.
* mips-linux-nat.c (mips_linux_stopped_by_watchpoint): Add 'ops'
argument.
* ppc-linux-nat.c (ppc_linux_stopped_by_watchpoint): Add 'ops'
argument.
* procfs.c (procfs_stopped_by_watchpoint): Add 'ops' argument.
* record-full.c (record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_async, tmp_to_stopped_by_watchpoint)
(tmp_to_async): Add 'ops' argument.
(record_full_stopped_by_watchpoint, record_full_async)
(record_full_can_async_p, record_full_is_async_p): Add 'ops'
argument.
* remote-m32r-sdi.c (m32r_insert_breakpoint, m32r_remove_breakpoint)
(m32r_stopped_by_watchpoint): Add 'ops' argument.
* remote-mips.c (mips_stopped_by_watchpoint): Add 'ops' argument.
* remote.c (remote_stopped_by_watchpoint_p, remote_can_async_p)
(remote_is_async_p, remote_async): Add 'ops' argument.
(remote_stopped_data_address): Update.
* s390-nat.c (s390_stopped_by_watchpoint): Add 'ops' argument.
* target.c (update_current_target)
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Update.
(debug_to_stopped_by_watchpoint): Add 'ops' argument.
* target.h (struct target_ops) <to_stopped_by_watchpoint,
to_can_async_p, to_is_async_p, to_async>: Add 'ops' argument.
(target_can_async_p, target_is_async_p, target_async)
(target_stopped_by_watchpoint): Update.
2013-07-30 18:36:07 +02:00
|
|
|
|
linux_nat_stopped_by_watchpoint (struct target_ops *ops)
|
2009-11-20 20:52:08 +01:00
|
|
|
|
{
|
|
|
|
|
struct lwp_info *lp = find_lwp_pid (inferior_ptid);
|
|
|
|
|
|
|
|
|
|
gdb_assert (lp != NULL);
|
|
|
|
|
|
2015-03-04 21:41:15 +01:00
|
|
|
|
return lp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT;
|
2009-11-20 20:52:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
linux_nat_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
|
|
|
|
|
{
|
|
|
|
|
struct lwp_info *lp = find_lwp_pid (inferior_ptid);
|
|
|
|
|
|
|
|
|
|
gdb_assert (lp != NULL);
|
|
|
|
|
|
|
|
|
|
*addr_p = lp->stopped_data_address;
|
|
|
|
|
|
|
|
|
|
return lp->stopped_data_address_p;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-27 22:51:40 +02:00
|
|
|
|
/* Commonly any breakpoint / watchpoint generate only SIGTRAP. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
sigtrap_is_event (int status)
|
|
|
|
|
{
|
|
|
|
|
return WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set alternative SIGTRAP-like events recognizer. If
|
|
|
|
|
breakpoint_inserted_here_p there then gdbarch_decr_pc_after_break will be
|
|
|
|
|
applied. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
linux_nat_set_status_is_event (struct target_ops *t,
|
|
|
|
|
int (*status_is_event) (int status))
|
|
|
|
|
{
|
|
|
|
|
linux_nat_status_is_event = status_is_event;
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-27 23:12:40 +02:00
|
|
|
|
/* Wait until LP is stopped. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
stop_wait_callback (struct lwp_info *lp, void *data)
|
|
|
|
|
{
|
2014-12-15 18:00:55 +01:00
|
|
|
|
struct inferior *inf = find_inferior_ptid (lp->ptid);
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
|
|
|
|
|
|
/* If this is a vfork parent, bail out, it is not going to report
|
|
|
|
|
any SIGSTOP until the vfork is done with. */
|
|
|
|
|
if (inf->vfork_child != NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
if (!lp->stopped)
|
|
|
|
|
{
|
|
|
|
|
int status;
|
|
|
|
|
|
|
|
|
|
status = wait_lwp (lp);
|
|
|
|
|
if (status == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2008-07-27 23:12:40 +02:00
|
|
|
|
if (lp->ignore_sigint && WIFSTOPPED (status)
|
|
|
|
|
&& WSTOPSIG (status) == SIGINT)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
2008-07-27 23:12:40 +02:00
|
|
|
|
lp->ignore_sigint = 0;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
errno = 0;
|
2013-09-30 13:50:12 +02:00
|
|
|
|
ptrace (PTRACE_CONT, ptid_get_lwp (lp->ptid), 0, 0);
|
PR gdb/15713 - errors from i386_linux_resume lead to lock-up
linux_nat_resume is not considering that linux_ops->to_resume may throw:
/* Mark LWP as not stopped to prevent it from being continued by
linux_nat_resume_callback. */
lp->stopped = 0;
if (resume_many)
iterate_over_lwps (ptid, linux_nat_resume_callback, NULL);
If something within linux_nat_resume_callback throws, GDB leaves the
lwp_info as if the inferior was resumed, while it actually wasn't.
A couple examples, there are possibly others:
- i386_linux_resume calls target_read which calls QUIT.
- if the actual ptrace resumption fails in inf_ptrace_resume,
perror_with_name is called.
If the user tries to kill the inferior at this point (or quit, which
offers to kill), GDB locks up trying to stop the lwp -- if it is
already stopped no new waitpid event gets generated for it.
Fix this by setting the stopped flag earlier, as soon as we collect a
stop event with waitpid, and clearing it always only after resuming
the lwp successfully.
Tested on x86_64 Fedora 20. Confirmed the lock-up disappears using a
local hack that forces an error in inf_ptrace_resume.
Also fixes a little "set debug lin-lwp" annoyance. Currently we always see:
Continuing.
LLR: Preparing to resume process 6802, 0, inferior_ptid Thread 0x7ffff7fc7740 (LWP 6802)
^^^^^^^^
RC: Resuming sibling Thread 0x7ffff77c5700 (LWP 6807), 0, resume
RC: Resuming sibling Thread 0x7ffff7fc6700 (LWP 6806), 0, resume
RC: Not resuming sibling Thread 0x7ffff7fc7740 (LWP 6802) (not stopped)
^^^^^^^^^^^^^^^^^^^^^^^
LLR: PTRACE_CONT process 6802, 0 (resume event thread)
This patch gets rid of the "Not resuming sibling" line.
2014-05-29 Pedro Alves <palves@redhat.com>
PR gdb/15713
* linux-nat.c (linux_nat_resume_callback): Rename the second
parameter to 'except'. Skip LP if it points to EXCEPT.
(linux_nat_resume): Don't mark the event lwp as not stopped
before resuming sibling lwps. Instead ask
linux_nat_resume_callback to skip the event lwp. Mark it as not
stopped after actually resuming it.
(linux_handle_syscall_trap): Mark the lwp as not stopped after
resuming it.
(wait_lwp): Mark the lwp as stopped here.
(stop_wait_callback): Mark the lwp as not stopped right after
resuming it. Don't mark lwps as stopped here.
(linux_nat_filter_event): Mark the lwp as stopped earlier.
(linux_nat_wait_1): Don't mark dead lwps as stopped here.
2014-05-29 13:50:48 +02:00
|
|
|
|
lp->stopped = 0;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
2011-01-05 23:22:53 +01:00
|
|
|
|
"PTRACE_CONT %s, 0, 0 (%s) "
|
|
|
|
|
"(discarding SIGINT)\n",
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
target_pid_to_str (lp->ptid),
|
|
|
|
|
errno ? safe_strerror (errno) : "OK");
|
|
|
|
|
|
2008-07-27 23:12:40 +02:00
|
|
|
|
return stop_wait_callback (lp, NULL);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-07-27 23:12:40 +02:00
|
|
|
|
maybe_clear_ignore_sigint (lp);
|
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
if (WSTOPSIG (status) != SIGSTOP)
|
|
|
|
|
{
|
2012-06-28 18:34:04 +02:00
|
|
|
|
/* The thread was stopped with a signal other than SIGSTOP. */
|
2009-05-11 14:08:03 +02:00
|
|
|
|
|
2012-06-28 18:34:04 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"SWC: Pending event %s in %s\n",
|
|
|
|
|
status_to_str ((int) status),
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
|
|
|
|
|
/* Save the sigtrap event. */
|
|
|
|
|
lp->status = status;
|
|
|
|
|
gdb_assert (lp->signalled);
|
2016-02-24 23:52:06 +01:00
|
|
|
|
save_stop_reason (lp);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We caught the SIGSTOP that we intended to catch, so
|
|
|
|
|
there's no SIGSTOP pending. */
|
2012-06-28 18:34:04 +02:00
|
|
|
|
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
2015-03-24 19:31:51 +01:00
|
|
|
|
"SWC: Expected SIGSTOP caught for %s.\n",
|
2012-06-28 18:34:04 +02:00
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
|
|
|
|
|
/* Reset SIGNALLED only after the stop_wait_callback call
|
|
|
|
|
above as it does gdb_assert on SIGNALLED. */
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
lp->signalled = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
/* Return non-zero if LP has a wait status pending. Discard the
|
|
|
|
|
pending event and resume the LWP if the event that originally
|
|
|
|
|
caused the stop became uninteresting. */
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
status_callback (struct lwp_info *lp, void *data)
|
|
|
|
|
{
|
|
|
|
|
/* Only report a pending wait status if we pretend that this has
|
|
|
|
|
indeed been resumed. */
|
2009-10-02 18:51:04 +02:00
|
|
|
|
if (!lp->resumed)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2015-03-19 13:20:25 +01:00
|
|
|
|
if (!lwp_status_pending_p (lp))
|
|
|
|
|
return 0;
|
|
|
|
|
|
2015-03-04 21:41:15 +01:00
|
|
|
|
if (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
|
|
|
|
|
|| lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT)
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
{
|
|
|
|
|
struct regcache *regcache = get_thread_regcache (lp->ptid);
|
|
|
|
|
CORE_ADDR pc;
|
|
|
|
|
int discard = 0;
|
|
|
|
|
|
|
|
|
|
pc = regcache_read_pc (regcache);
|
|
|
|
|
|
|
|
|
|
if (pc != lp->stop_pc)
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"SC: PC of %s changed. was=%s, now=%s\n",
|
|
|
|
|
target_pid_to_str (lp->ptid),
|
|
|
|
|
paddress (target_gdbarch (), lp->stop_pc),
|
|
|
|
|
paddress (target_gdbarch (), pc));
|
|
|
|
|
discard = 1;
|
|
|
|
|
}
|
2015-03-04 21:41:16 +01:00
|
|
|
|
|
|
|
|
|
#if !USE_SIGTRAP_SIGINFO
|
2017-11-02 16:15:41 +01:00
|
|
|
|
else if (!breakpoint_inserted_here_p (regcache->aspace (), pc))
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"SC: previous breakpoint of %s, at %s gone\n",
|
|
|
|
|
target_pid_to_str (lp->ptid),
|
|
|
|
|
paddress (target_gdbarch (), lp->stop_pc));
|
|
|
|
|
|
|
|
|
|
discard = 1;
|
|
|
|
|
}
|
2015-03-04 21:41:16 +01:00
|
|
|
|
#endif
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
|
|
|
|
|
if (discard)
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"SC: pending event of %s cancelled.\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
|
|
|
|
|
lp->status = 0;
|
|
|
|
|
linux_resume_one_lwp (lp, lp->step, GDB_SIGNAL_0);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-19 13:20:25 +01:00
|
|
|
|
return 1;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Count the LWP's that have had events. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
count_events_callback (struct lwp_info *lp, void *data)
|
|
|
|
|
{
|
Add some more casts (1/2)
Note: I needed to split this patch in two, otherwise it's too big for
the mailing list.
This patch adds explicit casts to situations where a void pointer is
assigned to a pointer to the "real" type. Building in C++ mode requires
those assignments to use an explicit cast. This includes, for example:
- callback arguments (cleanups, comparison functions, ...)
- data attached to some object (objfile, program space, etc) in the form
of a void pointer
- "user data" passed to some function
This patch comes from the commit "(mostly) auto-generated patch to insert
casts needed for C++", taken from Pedro's C++ branch.
Only files built on x86 with --enable-targets=all are modified, so the
native files for other arches will need to be dealt with separately.
I built-tested this with --enable-targets=all and reg-tested. To my
surprise, a test case (selftest.exp) had to be adjusted.
Here's the ChangeLog entry. Again, this was relatively quick to make
despite the length, thanks to David Malcom's script, although I don't
believe it's very useful information in that particular case...
gdb/ChangeLog:
* aarch64-tdep.c (aarch64_make_prologue_cache): Add cast(s).
(aarch64_make_stub_cache): Likewise.
(value_of_aarch64_user_reg): Likewise.
* ada-lang.c (ada_inferior_data_cleanup): Likewise.
(get_ada_inferior_data): Likewise.
(get_ada_pspace_data): Likewise.
(ada_pspace_data_cleanup): Likewise.
(ada_complete_symbol_matcher): Likewise.
(ada_exc_search_name_matches): Likewise.
* ada-tasks.c (get_ada_tasks_pspace_data): Likewise.
(get_ada_tasks_inferior_data): Likewise.
* addrmap.c (addrmap_mutable_foreach_worker): Likewise.
(splay_obstack_alloc): Likewise.
(splay_obstack_free): Likewise.
* alpha-linux-tdep.c (alpha_linux_supply_gregset): Likewise.
(alpha_linux_collect_gregset): Likewise.
(alpha_linux_supply_fpregset): Likewise.
(alpha_linux_collect_fpregset): Likewise.
* alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind_cache): Likewise.
* alpha-tdep.c (alpha_lds): Likewise.
(alpha_sts): Likewise.
(alpha_sigtramp_frame_unwind_cache): Likewise.
(alpha_heuristic_frame_unwind_cache): Likewise.
(alpha_supply_int_regs): Likewise.
(alpha_fill_int_regs): Likewise.
(alpha_supply_fp_regs): Likewise.
(alpha_fill_fp_regs): Likewise.
* alphanbsd-tdep.c (alphanbsd_supply_fpregset): Likewise.
(alphanbsd_aout_supply_gregset): Likewise.
(alphanbsd_supply_gregset): Likewise.
* amd64-linux-tdep.c (amd64_linux_init_abi): Likewise.
(amd64_x32_linux_init_abi): Likewise.
* amd64-nat.c (amd64_supply_native_gregset): Likewise.
(amd64_collect_native_gregset): Likewise.
* amd64-tdep.c (amd64_frame_cache): Likewise.
(amd64_sigtramp_frame_cache): Likewise.
(amd64_epilogue_frame_cache): Likewise.
(amd64_supply_fxsave): Likewise.
(amd64_supply_xsave): Likewise.
(amd64_collect_fxsave): Likewise.
(amd64_collect_xsave): Likewise.
* amd64-windows-tdep.c (amd64_windows_frame_cache): Likewise.
* amd64obsd-tdep.c (amd64obsd_trapframe_cache): Likewise.
* arm-linux-tdep.c (arm_linux_supply_gregset): Likewise.
(arm_linux_collect_gregset): Likewise.
(arm_linux_supply_nwfpe): Likewise.
(arm_linux_collect_nwfpe): Likewise.
(arm_linux_supply_vfp): Likewise.
(arm_linux_collect_vfp): Likewise.
* arm-tdep.c (arm_find_mapping_symbol): Likewise.
(arm_prologue_unwind_stop_reason): Likewise.
(arm_prologue_this_id): Likewise.
(arm_prologue_prev_register): Likewise.
(arm_exidx_data_free): Likewise.
(arm_find_exidx_entry): Likewise.
(arm_stub_this_id): Likewise.
(arm_m_exception_this_id): Likewise.
(arm_m_exception_prev_register): Likewise.
(arm_normal_frame_base): Likewise.
(gdb_print_insn_arm): Likewise.
(arm_objfile_data_free): Likewise.
(arm_record_special_symbol): Likewise.
(value_of_arm_user_reg): Likewise.
* armbsd-tdep.c (armbsd_supply_fpregset): Likewise.
(armbsd_supply_gregset): Likewise.
* auto-load.c (auto_load_pspace_data_cleanup): Likewise.
(get_auto_load_pspace_data): Likewise.
(hash_loaded_script_entry): Likewise.
(eq_loaded_script_entry): Likewise.
(clear_section_scripts): Likewise.
(collect_matching_scripts): Likewise.
* auxv.c (auxv_inferior_data_cleanup): Likewise.
(get_auxv_inferior_data): Likewise.
* avr-tdep.c (avr_frame_unwind_cache): Likewise.
* ax-general.c (do_free_agent_expr_cleanup): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
(target_bfd_xclose): Likewise.
(target_bfd_get_section_table): Likewise.
* bfin-tdep.c (bfin_frame_cache): Likewise.
* block.c (find_block_in_blockvector): Likewise.
(call_site_for_pc): Likewise.
(block_find_non_opaque_type_preferred): Likewise.
* break-catch-sig.c (signal_catchpoint_insert_location): Likewise.
(signal_catchpoint_remove_location): Likewise.
(signal_catchpoint_breakpoint_hit): Likewise.
(signal_catchpoint_print_one): Likewise.
(signal_catchpoint_print_mention): Likewise.
(signal_catchpoint_print_recreate): Likewise.
* break-catch-syscall.c (get_catch_syscall_inferior_data): Likewise.
* breakpoint.c (do_cleanup_counted_command_line): Likewise.
(bp_location_compare_addrs): Likewise.
(get_first_locp_gte_addr): Likewise.
(check_tracepoint_command): Likewise.
(do_map_commands_command): Likewise.
(get_breakpoint_objfile_data): Likewise.
(free_breakpoint_probes): Likewise.
(do_captured_breakpoint_query): Likewise.
(compare_breakpoints): Likewise.
(bp_location_compare): Likewise.
(bpstat_remove_breakpoint_callback): Likewise.
(do_delete_breakpoint_cleanup): Likewise.
* bsd-uthread.c (bsd_uthread_set_supply_uthread): Likewise.
(bsd_uthread_set_collect_uthread): Likewise.
(bsd_uthread_activate): Likewise.
(bsd_uthread_fetch_registers): Likewise.
(bsd_uthread_store_registers): Likewise.
* btrace.c (check_xml_btrace_version): Likewise.
(parse_xml_btrace_block): Likewise.
(parse_xml_btrace_pt_config_cpu): Likewise.
(parse_xml_btrace_pt_raw): Likewise.
(parse_xml_btrace_pt): Likewise.
(parse_xml_btrace_conf_bts): Likewise.
(parse_xml_btrace_conf_pt): Likewise.
(do_btrace_data_cleanup): Likewise.
* c-typeprint.c (find_typedef_for_canonicalize): Likewise.
* charset.c (cleanup_iconv): Likewise.
(do_cleanup_iterator): Likewise.
* cli-out.c (cli_uiout_dtor): Likewise.
(cli_table_begin): Likewise.
(cli_table_body): Likewise.
(cli_table_end): Likewise.
(cli_table_header): Likewise.
(cli_begin): Likewise.
(cli_end): Likewise.
(cli_field_int): Likewise.
(cli_field_skip): Likewise.
(cli_field_string): Likewise.
(cli_field_fmt): Likewise.
(cli_spaces): Likewise.
(cli_text): Likewise.
(cli_message): Likewise.
(cli_wrap_hint): Likewise.
(cli_flush): Likewise.
(cli_redirect): Likewise.
(out_field_fmt): Likewise.
(field_separator): Likewise.
(cli_out_set_stream): Likewise.
* cli/cli-cmds.c (compare_symtabs): Likewise.
* cli/cli-dump.c (call_dump_func): Likewise.
(restore_section_callback): Likewise.
* cli/cli-script.c (clear_hook_in_cleanup): Likewise.
(do_restore_user_call_depth): Likewise.
(do_free_command_lines_cleanup): Likewise.
* coff-pe-read.c (get_section_vmas): Likewise.
(pe_as16): Likewise.
(pe_as32): Likewise.
* coffread.c (coff_symfile_read): Likewise.
* common/agent.c (agent_look_up_symbols): Likewise.
* common/filestuff.c (do_close_cleanup): Likewise.
* common/format.c (free_format_pieces_cleanup): Likewise.
* common/vec.c (vec_o_reserve): Likewise.
* compile/compile-c-support.c (print_one_macro): Likewise.
* compile/compile-c-symbols.c (hash_symbol_error): Likewise.
(eq_symbol_error): Likewise.
(del_symbol_error): Likewise.
(error_symbol_once): Likewise.
(gcc_convert_symbol): Likewise.
(gcc_symbol_address): Likewise.
(hash_symname): Likewise.
(eq_symname): Likewise.
* compile/compile-c-types.c (hash_type_map_instance): Likewise.
(eq_type_map_instance): Likewise.
(insert_type): Likewise.
(convert_type): Likewise.
* compile/compile-object-load.c (munmap_listp_free_cleanup): Likewise.
(setup_sections): Likewise.
(link_hash_table_free): Likewise.
(copy_sections): Likewise.
* compile/compile-object-run.c (do_module_cleanup): Likewise.
* compile/compile.c (compile_print_value): Likewise.
(do_rmdir): Likewise.
(cleanup_compile_instance): Likewise.
(cleanup_unlink_file): Likewise.
* completer.c (free_completion_tracker): Likewise.
* corelow.c (add_to_spuid_list): Likewise.
* cp-namespace.c (reset_directive_searched): Likewise.
* cp-support.c (reset_directive_searched): Likewise.
* cris-tdep.c (cris_sigtramp_frame_unwind_cache): Likewise.
(cris_frame_unwind_cache): Likewise.
* d-lang.c (builtin_d_type): Likewise.
* d-namespace.c (reset_directive_searched): Likewise.
* dbxread.c (dbx_free_symfile_info): Likewise.
(do_free_bincl_list_cleanup): Likewise.
* disasm.c (hash_dis_line_entry): Likewise.
(eq_dis_line_entry): Likewise.
(dis_asm_print_address): Likewise.
(fprintf_disasm): Likewise.
(do_ui_file_delete): Likewise.
* doublest.c (convert_floatformat_to_doublest): Likewise.
* dummy-frame.c (pop_dummy_frame_bpt): Likewise.
(dummy_frame_prev_register): Likewise.
(dummy_frame_this_id): Likewise.
* dwarf2-frame-tailcall.c (cache_hash): Likewise.
(cache_eq): Likewise.
(cache_find): Likewise.
(tailcall_frame_this_id): Likewise.
(dwarf2_tailcall_prev_register_first): Likewise.
(tailcall_frame_prev_register): Likewise.
(tailcall_frame_dealloc_cache): Likewise.
(tailcall_frame_prev_arch): Likewise.
* dwarf2-frame.c (dwarf2_frame_state_free): Likewise.
(dwarf2_frame_set_init_reg): Likewise.
(dwarf2_frame_init_reg): Likewise.
(dwarf2_frame_set_signal_frame_p): Likewise.
(dwarf2_frame_signal_frame_p): Likewise.
(dwarf2_frame_set_adjust_regnum): Likewise.
(dwarf2_frame_adjust_regnum): Likewise.
(clear_pointer_cleanup): Likewise.
(dwarf2_frame_cache): Likewise.
(find_cie): Likewise.
(dwarf2_frame_find_fde): Likewise.
* dwarf2expr.c (dwarf_expr_address_type): Likewise.
(free_dwarf_expr_context_cleanup): Likewise.
* dwarf2loc.c (locexpr_find_frame_base_location): Likewise.
(locexpr_get_frame_base): Likewise.
(loclist_find_frame_base_location): Likewise.
(loclist_get_frame_base): Likewise.
(dwarf_expr_dwarf_call): Likewise.
(dwarf_expr_get_base_type): Likewise.
(dwarf_expr_push_dwarf_reg_entry_value): Likewise.
(dwarf_expr_get_obj_addr): Likewise.
(entry_data_value_coerce_ref): Likewise.
(entry_data_value_copy_closure): Likewise.
(entry_data_value_free_closure): Likewise.
(get_frame_address_in_block_wrapper): Likewise.
(dwarf2_evaluate_property): Likewise.
(dwarf2_compile_property_to_c): Likewise.
(needs_frame_read_addr_from_reg): Likewise.
(needs_frame_get_reg_value): Likewise.
(needs_frame_frame_base): Likewise.
(needs_frame_frame_cfa): Likewise.
(needs_frame_tls_address): Likewise.
(needs_frame_dwarf_call): Likewise.
(needs_dwarf_reg_entry_value): Likewise.
(get_ax_pc): Likewise.
(locexpr_read_variable): Likewise.
(locexpr_read_variable_at_entry): Likewise.
(locexpr_read_needs_frame): Likewise.
(locexpr_describe_location): Likewise.
(locexpr_tracepoint_var_ref): Likewise.
(locexpr_generate_c_location): Likewise.
(loclist_read_variable): Likewise.
(loclist_read_variable_at_entry): Likewise.
(loclist_describe_location): Likewise.
(loclist_tracepoint_var_ref): Likewise.
(loclist_generate_c_location): Likewise.
* dwarf2read.c (line_header_hash_voidp): Likewise.
(line_header_eq_voidp): Likewise.
(dwarf2_has_info): Likewise.
(dwarf2_get_section_info): Likewise.
(locate_dwz_sections): Likewise.
(hash_file_name_entry): Likewise.
(eq_file_name_entry): Likewise.
(delete_file_name_entry): Likewise.
(dw2_setup): Likewise.
(dw2_get_file_names_reader): Likewise.
(dw2_find_pc_sect_compunit_symtab): Likewise.
(hash_signatured_type): Likewise.
(eq_signatured_type): Likewise.
(add_signatured_type_cu_to_table): Likewise.
(create_debug_types_hash_table): Likewise.
(lookup_dwo_signatured_type): Likewise.
(lookup_dwp_signatured_type): Likewise.
(lookup_signatured_type): Likewise.
(hash_type_unit_group): Likewise.
(eq_type_unit_group): Likewise.
(get_type_unit_group): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(sort_tu_by_abbrev_offset): Likewise.
(process_skeletonless_type_unit): Likewise.
(psymtabs_addrmap_cleanup): Likewise.
(dwarf2_read_symtab): Likewise.
(psymtab_to_symtab_1): Likewise.
(die_hash): Likewise.
(die_eq): Likewise.
(load_full_comp_unit_reader): Likewise.
(reset_die_in_process): Likewise.
(free_cu_line_header): Likewise.
(handle_DW_AT_stmt_list): Likewise.
(hash_dwo_file): Likewise.
(eq_dwo_file): Likewise.
(hash_dwo_unit): Likewise.
(eq_dwo_unit): Likewise.
(create_dwo_cu_reader): Likewise.
(create_dwo_unit_in_dwp_v1): Likewise.
(create_dwo_unit_in_dwp_v2): Likewise.
(lookup_dwo_unit_in_dwp): Likewise.
(dwarf2_locate_dwo_sections): Likewise.
(dwarf2_locate_common_dwp_sections): Likewise.
(dwarf2_locate_v2_dwp_sections): Likewise.
(hash_dwp_loaded_cutus): Likewise.
(eq_dwp_loaded_cutus): Likewise.
(lookup_dwo_cutu): Likewise.
(abbrev_table_free_cleanup): Likewise.
(dwarf2_free_abbrev_table): Likewise.
(find_partial_die_in_comp_unit): Likewise.
(free_line_header_voidp): Likewise.
(follow_die_offset): Likewise.
(follow_die_sig_1): Likewise.
(free_heap_comp_unit): Likewise.
(free_stack_comp_unit): Likewise.
(dwarf2_free_objfile): Likewise.
(per_cu_offset_and_type_hash): Likewise.
(per_cu_offset_and_type_eq): Likewise.
(get_die_type_at_offset): Likewise.
(partial_die_hash): Likewise.
(partial_die_eq): Likewise.
(dwarf2_per_objfile_free): Likewise.
(hash_strtab_entry): Likewise.
(eq_strtab_entry): Likewise.
(add_string): Likewise.
(hash_symtab_entry): Likewise.
(eq_symtab_entry): Likewise.
(delete_symtab_entry): Likewise.
(cleanup_mapped_symtab): Likewise.
(add_indices_to_cpool): Likewise.
(hash_psymtab_cu_index): Likewise.
(eq_psymtab_cu_index): Likewise.
(add_address_entry_worker): Likewise.
(unlink_if_set): Likewise.
(write_one_signatured_type): Likewise.
(save_gdb_index_command): Likewise.
* elfread.c (elf_symtab_read): Likewise.
(elf_gnu_ifunc_cache_hash): Likewise.
(elf_gnu_ifunc_cache_eq): Likewise.
(elf_gnu_ifunc_record_cache): Likewise.
(elf_gnu_ifunc_resolve_by_cache): Likewise.
(elf_get_probes): Likewise.
(probe_key_free): Likewise.
* f-lang.c (builtin_f_type): Likewise.
* frame-base.c (frame_base_append_sniffer): Likewise.
(frame_base_set_default): Likewise.
(frame_base_find_by_frame): Likewise.
* frame-unwind.c (frame_unwind_prepend_unwinder): Likewise.
(frame_unwind_append_unwinder): Likewise.
(frame_unwind_find_by_frame): Likewise.
* frame.c (frame_addr_hash): Likewise.
(frame_addr_hash_eq): Likewise.
(frame_stash_find): Likewise.
(do_frame_register_read): Likewise.
(unwind_to_current_frame): Likewise.
(frame_cleanup_after_sniffer): Likewise.
* frv-linux-tdep.c (frv_linux_sigtramp_frame_cache): Likewise.
* frv-tdep.c (frv_frame_unwind_cache): Likewise.
* ft32-tdep.c (ft32_frame_cache): Likewise.
* gcore.c (do_bfd_delete_cleanup): Likewise.
(gcore_create_callback): Likewise.
* gdb_bfd.c (hash_bfd): Likewise.
(eq_bfd): Likewise.
(gdb_bfd_open): Likewise.
(free_one_bfd_section): Likewise.
(gdb_bfd_ref): Likewise.
(gdb_bfd_unref): Likewise.
(get_section_descriptor): Likewise.
(gdb_bfd_map_section): Likewise.
(gdb_bfd_crc): Likewise.
(gdb_bfd_mark_parent): Likewise.
(gdb_bfd_record_inclusion): Likewise.
(gdb_bfd_requires_relocations): Likewise.
(print_one_bfd): Likewise.
* gdbtypes.c (type_pair_hash): Likewise.
(type_pair_eq): Likewise.
(builtin_type): Likewise.
(objfile_type): Likewise.
* gnu-v3-abi.c (vtable_ptrdiff_type): Likewise.
(vtable_address_point_offset): Likewise.
(gnuv3_get_vtable): Likewise.
(hash_value_and_voffset): Likewise.
(eq_value_and_voffset): Likewise.
(compare_value_and_voffset): Likewise.
(compute_vtable_size): Likewise.
(gnuv3_get_typeid_type): Likewise.
* go-lang.c (builtin_go_type): Likewise.
* guile/scm-block.c (bkscm_hash_block_smob): Likewise.
(bkscm_eq_block_smob): Likewise.
(bkscm_objfile_block_map): Likewise.
(bkscm_del_objfile_blocks): Likewise.
* guile/scm-breakpoint.c (bpscm_build_bp_list): Likewise.
* guile/scm-disasm.c (gdbscm_disasm_read_memory_worker): Likewise.
(gdbscm_disasm_print_address): Likewise.
* guile/scm-frame.c (frscm_hash_frame_smob): Likewise.
(frscm_eq_frame_smob): Likewise.
(frscm_inferior_frame_map): Likewise.
(frscm_del_inferior_frames): Likewise.
* guile/scm-gsmob.c (gdbscm_add_objfile_ref): Likewise.
* guile/scm-objfile.c (ofscm_handle_objfile_deleted): Likewise.
(ofscm_objfile_smob_from_objfile): Likewise.
* guile/scm-ports.c (ioscm_write): Likewise.
(ioscm_file_port_delete): Likewise.
(ioscm_file_port_rewind): Likewise.
(ioscm_file_port_put): Likewise.
(ioscm_file_port_write): Likewise.
* guile/scm-progspace.c (psscm_handle_pspace_deleted): Likewise.
(psscm_pspace_smob_from_pspace): Likewise.
* guile/scm-safe-call.c (scscm_recording_pre_unwind_handler): Likewise.
(scscm_recording_unwind_handler): Likewise.
(gdbscm_with_catch): Likewise.
(scscm_call_0_body): Likewise.
(scscm_call_1_body): Likewise.
(scscm_call_2_body): Likewise.
(scscm_call_3_body): Likewise.
(scscm_call_4_body): Likewise.
(scscm_apply_1_body): Likewise.
(scscm_eval_scheme_string): Likewise.
(gdbscm_safe_eval_string): Likewise.
(scscm_source_scheme_script): Likewise.
(gdbscm_safe_source_script): Likewise.
* guile/scm-string.c (gdbscm_call_scm_to_stringn): Likewise.
(gdbscm_call_scm_from_stringn): Likewise.
* guile/scm-symbol.c (syscm_hash_symbol_smob): Likewise.
(syscm_eq_symbol_smob): Likewise.
(syscm_get_symbol_map): Likewise.
(syscm_del_objfile_symbols): Likewise.
* guile/scm-symtab.c (stscm_hash_symtab_smob): Likewise.
(stscm_eq_symtab_smob): Likewise.
(stscm_objfile_symtab_map): Likewise.
(stscm_del_objfile_symtabs): Likewise.
* guile/scm-type.c (tyscm_hash_type_smob): Likewise.
(tyscm_eq_type_smob): Likewise.
(tyscm_type_map): Likewise.
(tyscm_copy_type_recursive): Likewise.
(save_objfile_types): Likewise.
* guile/scm-utils.c (extract_arg): Likewise.
* h8300-tdep.c (h8300_frame_cache): Likewise.
* hppa-linux-tdep.c (hppa_linux_sigtramp_frame_unwind_cache): Likewise.
* hppa-tdep.c (compare_unwind_entries): Likewise.
(find_unwind_entry): Likewise.
(hppa_frame_cache): Likewise.
(hppa_stub_frame_unwind_cache): Likewise.
* hppanbsd-tdep.c (hppanbsd_supply_gregset): Likewise.
* hppaobsd-tdep.c (hppaobsd_supply_gregset): Likewise.
(hppaobsd_supply_fpregset): Likewise.
* i386-cygwin-tdep.c (core_process_module_section): Likewise.
* i386-linux-tdep.c (i386_linux_init_abi): Likewise.
* i386-tdep.c (i386_frame_cache): Likewise.
(i386_epilogue_frame_cache): Likewise.
(i386_sigtramp_frame_cache): Likewise.
(i386_supply_gregset): Likewise.
(i386_collect_gregset): Likewise.
(i386_gdbarch_init): Likewise.
* i386obsd-tdep.c (i386obsd_aout_supply_regset): Likewise.
(i386obsd_trapframe_cache): Likewise.
* i387-tdep.c (i387_supply_fsave): Likewise.
(i387_collect_fsave): Likewise.
(i387_supply_fxsave): Likewise.
(i387_collect_fxsave): Likewise.
(i387_supply_xsave): Likewise.
(i387_collect_xsave): Likewise.
* ia64-tdep.c (ia64_frame_cache): Likewise.
(ia64_sigtramp_frame_cache): Likewise.
* infcmd.c (attach_command_continuation): Likewise.
(attach_command_continuation_free_args): Likewise.
* inferior.c (restore_inferior): Likewise.
(delete_thread_of_inferior): Likewise.
* inflow.c (inflow_inferior_data_cleanup): Likewise.
(get_inflow_inferior_data): Likewise.
(inflow_inferior_exit): Likewise.
* infrun.c (displaced_step_clear_cleanup): Likewise.
(restore_current_uiout_cleanup): Likewise.
(release_stop_context_cleanup): Likewise.
(do_restore_infcall_suspend_state_cleanup): Likewise.
(do_restore_infcall_control_state_cleanup): Likewise.
(restore_inferior_ptid): Likewise.
* inline-frame.c (block_starting_point_at): Likewise.
* iq2000-tdep.c (iq2000_frame_cache): Likewise.
* jit.c (get_jit_objfile_data): Likewise.
(get_jit_program_space_data): Likewise.
(jit_object_close_impl): Likewise.
(jit_find_objf_with_entry_addr): Likewise.
(jit_breakpoint_deleted): Likewise.
(jit_unwind_reg_set_impl): Likewise.
(jit_unwind_reg_get_impl): Likewise.
(jit_dealloc_cache): Likewise.
(jit_frame_sniffer): Likewise.
(jit_frame_prev_register): Likewise.
(jit_prepend_unwinder): Likewise.
(jit_inferior_exit_hook): Likewise.
(free_objfile_data): Likewise.
* jv-lang.c (jv_per_objfile_free): Likewise.
(get_dynamics_objfile): Likewise.
(get_java_class_symtab): Likewise.
(builtin_java_type): Likewise.
* language.c (language_string_char_type): Likewise.
(language_bool_type): Likewise.
(language_lookup_primitive_type): Likewise.
(language_lookup_primitive_type_as_symbol): Likewise.
* linespec.c (hash_address_entry): Likewise.
(eq_address_entry): Likewise.
(iterate_inline_only): Likewise.
(iterate_name_matcher): Likewise.
(decode_line_2_compare_items): Likewise.
(collect_one_symbol): Likewise.
(compare_symbols): Likewise.
(compare_msymbols): Likewise.
(add_symtabs_to_list): Likewise.
(collect_symbols): Likewise.
(compare_msyms): Likewise.
(add_minsym): Likewise.
(cleanup_linespec_result): Likewise.
* linux-fork.c (inferior_call_waitpid_cleanup): Likewise.
* linux-nat.c (delete_lwp_cleanup): Likewise.
(count_events_callback): Likewise.
(select_event_lwp_callback): Likewise.
(resume_stopped_resumed_lwps): Likewise.
* linux-tdep.c (get_linux_gdbarch_data): Likewise.
(invalidate_linux_cache_inf): Likewise.
(get_linux_inferior_data): Likewise.
(linux_find_memory_regions_thunk): Likewise.
(linux_make_mappings_callback): Likewise.
(linux_corefile_thread_callback): Likewise.
(find_mapping_size): Likewise.
* linux-thread-db.c (find_new_threads_callback): Likewise.
* lm32-tdep.c (lm32_frame_cache): Likewise.
* m2-lang.c (builtin_m2_type): Likewise.
* m32c-tdep.c (m32c_analyze_frame_prologue): Likewise.
* m32r-linux-tdep.c (m32r_linux_sigtramp_frame_cache): Likewise.
(m32r_linux_supply_gregset): Likewise.
(m32r_linux_collect_gregset): Likewise.
* m32r-tdep.c (m32r_frame_unwind_cache): Likewise.
* m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise.
* m68k-tdep.c (m68k_frame_cache): Likewise.
* m68kbsd-tdep.c (m68kbsd_supply_fpregset): Likewise.
(m68kbsd_supply_gregset): Likewise.
* m68klinux-tdep.c (m68k_linux_sigtramp_frame_cache): Likewise.
* m88k-tdep.c (m88k_frame_cache): Likewise.
(m88k_supply_gregset): Likewise.
gdb/gdbserver/ChangeLog:
* dll.c (match_dll): Add cast(s).
(unloaded_dll): Likewise.
* linux-low.c (second_thread_of_pid_p): Likewise.
(delete_lwp_callback): Likewise.
(count_events_callback): Likewise.
(select_event_lwp_callback): Likewise.
(linux_set_resume_request): Likewise.
* server.c (accumulate_file_name_length): Likewise.
(emit_dll_description): Likewise.
(handle_qxfer_threads_worker): Likewise.
(visit_actioned_threads): Likewise.
* thread-db.c (any_thread_of): Likewise.
* tracepoint.c (same_process_p): Likewise.
(match_blocktype): Likewise.
(build_traceframe_info_xml): Likewise.
gdb/testsuite/ChangeLog:
* gdb.gdb/selftest.exp (do_steps_and_nexts): Adjust expected
source line.
2015-09-25 20:08:07 +02:00
|
|
|
|
int *count = (int *) data;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
gdb_assert (count != NULL);
|
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
/* Select only resumed LWPs that have an event pending. */
|
|
|
|
|
if (lp->resumed && lwp_status_pending_p (lp))
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
(*count)++;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Select the LWP (if any) that is currently being single-stepped. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
select_singlestep_lwp_callback (struct lwp_info *lp, void *data)
|
|
|
|
|
{
|
2011-09-09 21:27:50 +02:00
|
|
|
|
if (lp->last_resume_kind == resume_step
|
|
|
|
|
&& lp->status != 0)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
return 1;
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-07 20:41:06 +01:00
|
|
|
|
/* Returns true if LP has a status pending. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
lwp_status_pending_p (struct lwp_info *lp)
|
|
|
|
|
{
|
|
|
|
|
/* We check for lp->waitstatus in addition to lp->status, because we
|
|
|
|
|
can have pending process exits recorded in lp->status and
|
|
|
|
|
W_EXITCODE(0,0) happens to be 0. */
|
|
|
|
|
return lp->status != 0 || lp->waitstatus.kind != TARGET_WAITKIND_IGNORE;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-19 13:24:06 +01:00
|
|
|
|
/* Select the Nth LWP that has had an event. */
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
select_event_lwp_callback (struct lwp_info *lp, void *data)
|
|
|
|
|
{
|
Add some more casts (1/2)
Note: I needed to split this patch in two, otherwise it's too big for
the mailing list.
This patch adds explicit casts to situations where a void pointer is
assigned to a pointer to the "real" type. Building in C++ mode requires
those assignments to use an explicit cast. This includes, for example:
- callback arguments (cleanups, comparison functions, ...)
- data attached to some object (objfile, program space, etc) in the form
of a void pointer
- "user data" passed to some function
This patch comes from the commit "(mostly) auto-generated patch to insert
casts needed for C++", taken from Pedro's C++ branch.
Only files built on x86 with --enable-targets=all are modified, so the
native files for other arches will need to be dealt with separately.
I built-tested this with --enable-targets=all and reg-tested. To my
surprise, a test case (selftest.exp) had to be adjusted.
Here's the ChangeLog entry. Again, this was relatively quick to make
despite the length, thanks to David Malcom's script, although I don't
believe it's very useful information in that particular case...
gdb/ChangeLog:
* aarch64-tdep.c (aarch64_make_prologue_cache): Add cast(s).
(aarch64_make_stub_cache): Likewise.
(value_of_aarch64_user_reg): Likewise.
* ada-lang.c (ada_inferior_data_cleanup): Likewise.
(get_ada_inferior_data): Likewise.
(get_ada_pspace_data): Likewise.
(ada_pspace_data_cleanup): Likewise.
(ada_complete_symbol_matcher): Likewise.
(ada_exc_search_name_matches): Likewise.
* ada-tasks.c (get_ada_tasks_pspace_data): Likewise.
(get_ada_tasks_inferior_data): Likewise.
* addrmap.c (addrmap_mutable_foreach_worker): Likewise.
(splay_obstack_alloc): Likewise.
(splay_obstack_free): Likewise.
* alpha-linux-tdep.c (alpha_linux_supply_gregset): Likewise.
(alpha_linux_collect_gregset): Likewise.
(alpha_linux_supply_fpregset): Likewise.
(alpha_linux_collect_fpregset): Likewise.
* alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind_cache): Likewise.
* alpha-tdep.c (alpha_lds): Likewise.
(alpha_sts): Likewise.
(alpha_sigtramp_frame_unwind_cache): Likewise.
(alpha_heuristic_frame_unwind_cache): Likewise.
(alpha_supply_int_regs): Likewise.
(alpha_fill_int_regs): Likewise.
(alpha_supply_fp_regs): Likewise.
(alpha_fill_fp_regs): Likewise.
* alphanbsd-tdep.c (alphanbsd_supply_fpregset): Likewise.
(alphanbsd_aout_supply_gregset): Likewise.
(alphanbsd_supply_gregset): Likewise.
* amd64-linux-tdep.c (amd64_linux_init_abi): Likewise.
(amd64_x32_linux_init_abi): Likewise.
* amd64-nat.c (amd64_supply_native_gregset): Likewise.
(amd64_collect_native_gregset): Likewise.
* amd64-tdep.c (amd64_frame_cache): Likewise.
(amd64_sigtramp_frame_cache): Likewise.
(amd64_epilogue_frame_cache): Likewise.
(amd64_supply_fxsave): Likewise.
(amd64_supply_xsave): Likewise.
(amd64_collect_fxsave): Likewise.
(amd64_collect_xsave): Likewise.
* amd64-windows-tdep.c (amd64_windows_frame_cache): Likewise.
* amd64obsd-tdep.c (amd64obsd_trapframe_cache): Likewise.
* arm-linux-tdep.c (arm_linux_supply_gregset): Likewise.
(arm_linux_collect_gregset): Likewise.
(arm_linux_supply_nwfpe): Likewise.
(arm_linux_collect_nwfpe): Likewise.
(arm_linux_supply_vfp): Likewise.
(arm_linux_collect_vfp): Likewise.
* arm-tdep.c (arm_find_mapping_symbol): Likewise.
(arm_prologue_unwind_stop_reason): Likewise.
(arm_prologue_this_id): Likewise.
(arm_prologue_prev_register): Likewise.
(arm_exidx_data_free): Likewise.
(arm_find_exidx_entry): Likewise.
(arm_stub_this_id): Likewise.
(arm_m_exception_this_id): Likewise.
(arm_m_exception_prev_register): Likewise.
(arm_normal_frame_base): Likewise.
(gdb_print_insn_arm): Likewise.
(arm_objfile_data_free): Likewise.
(arm_record_special_symbol): Likewise.
(value_of_arm_user_reg): Likewise.
* armbsd-tdep.c (armbsd_supply_fpregset): Likewise.
(armbsd_supply_gregset): Likewise.
* auto-load.c (auto_load_pspace_data_cleanup): Likewise.
(get_auto_load_pspace_data): Likewise.
(hash_loaded_script_entry): Likewise.
(eq_loaded_script_entry): Likewise.
(clear_section_scripts): Likewise.
(collect_matching_scripts): Likewise.
* auxv.c (auxv_inferior_data_cleanup): Likewise.
(get_auxv_inferior_data): Likewise.
* avr-tdep.c (avr_frame_unwind_cache): Likewise.
* ax-general.c (do_free_agent_expr_cleanup): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
(target_bfd_xclose): Likewise.
(target_bfd_get_section_table): Likewise.
* bfin-tdep.c (bfin_frame_cache): Likewise.
* block.c (find_block_in_blockvector): Likewise.
(call_site_for_pc): Likewise.
(block_find_non_opaque_type_preferred): Likewise.
* break-catch-sig.c (signal_catchpoint_insert_location): Likewise.
(signal_catchpoint_remove_location): Likewise.
(signal_catchpoint_breakpoint_hit): Likewise.
(signal_catchpoint_print_one): Likewise.
(signal_catchpoint_print_mention): Likewise.
(signal_catchpoint_print_recreate): Likewise.
* break-catch-syscall.c (get_catch_syscall_inferior_data): Likewise.
* breakpoint.c (do_cleanup_counted_command_line): Likewise.
(bp_location_compare_addrs): Likewise.
(get_first_locp_gte_addr): Likewise.
(check_tracepoint_command): Likewise.
(do_map_commands_command): Likewise.
(get_breakpoint_objfile_data): Likewise.
(free_breakpoint_probes): Likewise.
(do_captured_breakpoint_query): Likewise.
(compare_breakpoints): Likewise.
(bp_location_compare): Likewise.
(bpstat_remove_breakpoint_callback): Likewise.
(do_delete_breakpoint_cleanup): Likewise.
* bsd-uthread.c (bsd_uthread_set_supply_uthread): Likewise.
(bsd_uthread_set_collect_uthread): Likewise.
(bsd_uthread_activate): Likewise.
(bsd_uthread_fetch_registers): Likewise.
(bsd_uthread_store_registers): Likewise.
* btrace.c (check_xml_btrace_version): Likewise.
(parse_xml_btrace_block): Likewise.
(parse_xml_btrace_pt_config_cpu): Likewise.
(parse_xml_btrace_pt_raw): Likewise.
(parse_xml_btrace_pt): Likewise.
(parse_xml_btrace_conf_bts): Likewise.
(parse_xml_btrace_conf_pt): Likewise.
(do_btrace_data_cleanup): Likewise.
* c-typeprint.c (find_typedef_for_canonicalize): Likewise.
* charset.c (cleanup_iconv): Likewise.
(do_cleanup_iterator): Likewise.
* cli-out.c (cli_uiout_dtor): Likewise.
(cli_table_begin): Likewise.
(cli_table_body): Likewise.
(cli_table_end): Likewise.
(cli_table_header): Likewise.
(cli_begin): Likewise.
(cli_end): Likewise.
(cli_field_int): Likewise.
(cli_field_skip): Likewise.
(cli_field_string): Likewise.
(cli_field_fmt): Likewise.
(cli_spaces): Likewise.
(cli_text): Likewise.
(cli_message): Likewise.
(cli_wrap_hint): Likewise.
(cli_flush): Likewise.
(cli_redirect): Likewise.
(out_field_fmt): Likewise.
(field_separator): Likewise.
(cli_out_set_stream): Likewise.
* cli/cli-cmds.c (compare_symtabs): Likewise.
* cli/cli-dump.c (call_dump_func): Likewise.
(restore_section_callback): Likewise.
* cli/cli-script.c (clear_hook_in_cleanup): Likewise.
(do_restore_user_call_depth): Likewise.
(do_free_command_lines_cleanup): Likewise.
* coff-pe-read.c (get_section_vmas): Likewise.
(pe_as16): Likewise.
(pe_as32): Likewise.
* coffread.c (coff_symfile_read): Likewise.
* common/agent.c (agent_look_up_symbols): Likewise.
* common/filestuff.c (do_close_cleanup): Likewise.
* common/format.c (free_format_pieces_cleanup): Likewise.
* common/vec.c (vec_o_reserve): Likewise.
* compile/compile-c-support.c (print_one_macro): Likewise.
* compile/compile-c-symbols.c (hash_symbol_error): Likewise.
(eq_symbol_error): Likewise.
(del_symbol_error): Likewise.
(error_symbol_once): Likewise.
(gcc_convert_symbol): Likewise.
(gcc_symbol_address): Likewise.
(hash_symname): Likewise.
(eq_symname): Likewise.
* compile/compile-c-types.c (hash_type_map_instance): Likewise.
(eq_type_map_instance): Likewise.
(insert_type): Likewise.
(convert_type): Likewise.
* compile/compile-object-load.c (munmap_listp_free_cleanup): Likewise.
(setup_sections): Likewise.
(link_hash_table_free): Likewise.
(copy_sections): Likewise.
* compile/compile-object-run.c (do_module_cleanup): Likewise.
* compile/compile.c (compile_print_value): Likewise.
(do_rmdir): Likewise.
(cleanup_compile_instance): Likewise.
(cleanup_unlink_file): Likewise.
* completer.c (free_completion_tracker): Likewise.
* corelow.c (add_to_spuid_list): Likewise.
* cp-namespace.c (reset_directive_searched): Likewise.
* cp-support.c (reset_directive_searched): Likewise.
* cris-tdep.c (cris_sigtramp_frame_unwind_cache): Likewise.
(cris_frame_unwind_cache): Likewise.
* d-lang.c (builtin_d_type): Likewise.
* d-namespace.c (reset_directive_searched): Likewise.
* dbxread.c (dbx_free_symfile_info): Likewise.
(do_free_bincl_list_cleanup): Likewise.
* disasm.c (hash_dis_line_entry): Likewise.
(eq_dis_line_entry): Likewise.
(dis_asm_print_address): Likewise.
(fprintf_disasm): Likewise.
(do_ui_file_delete): Likewise.
* doublest.c (convert_floatformat_to_doublest): Likewise.
* dummy-frame.c (pop_dummy_frame_bpt): Likewise.
(dummy_frame_prev_register): Likewise.
(dummy_frame_this_id): Likewise.
* dwarf2-frame-tailcall.c (cache_hash): Likewise.
(cache_eq): Likewise.
(cache_find): Likewise.
(tailcall_frame_this_id): Likewise.
(dwarf2_tailcall_prev_register_first): Likewise.
(tailcall_frame_prev_register): Likewise.
(tailcall_frame_dealloc_cache): Likewise.
(tailcall_frame_prev_arch): Likewise.
* dwarf2-frame.c (dwarf2_frame_state_free): Likewise.
(dwarf2_frame_set_init_reg): Likewise.
(dwarf2_frame_init_reg): Likewise.
(dwarf2_frame_set_signal_frame_p): Likewise.
(dwarf2_frame_signal_frame_p): Likewise.
(dwarf2_frame_set_adjust_regnum): Likewise.
(dwarf2_frame_adjust_regnum): Likewise.
(clear_pointer_cleanup): Likewise.
(dwarf2_frame_cache): Likewise.
(find_cie): Likewise.
(dwarf2_frame_find_fde): Likewise.
* dwarf2expr.c (dwarf_expr_address_type): Likewise.
(free_dwarf_expr_context_cleanup): Likewise.
* dwarf2loc.c (locexpr_find_frame_base_location): Likewise.
(locexpr_get_frame_base): Likewise.
(loclist_find_frame_base_location): Likewise.
(loclist_get_frame_base): Likewise.
(dwarf_expr_dwarf_call): Likewise.
(dwarf_expr_get_base_type): Likewise.
(dwarf_expr_push_dwarf_reg_entry_value): Likewise.
(dwarf_expr_get_obj_addr): Likewise.
(entry_data_value_coerce_ref): Likewise.
(entry_data_value_copy_closure): Likewise.
(entry_data_value_free_closure): Likewise.
(get_frame_address_in_block_wrapper): Likewise.
(dwarf2_evaluate_property): Likewise.
(dwarf2_compile_property_to_c): Likewise.
(needs_frame_read_addr_from_reg): Likewise.
(needs_frame_get_reg_value): Likewise.
(needs_frame_frame_base): Likewise.
(needs_frame_frame_cfa): Likewise.
(needs_frame_tls_address): Likewise.
(needs_frame_dwarf_call): Likewise.
(needs_dwarf_reg_entry_value): Likewise.
(get_ax_pc): Likewise.
(locexpr_read_variable): Likewise.
(locexpr_read_variable_at_entry): Likewise.
(locexpr_read_needs_frame): Likewise.
(locexpr_describe_location): Likewise.
(locexpr_tracepoint_var_ref): Likewise.
(locexpr_generate_c_location): Likewise.
(loclist_read_variable): Likewise.
(loclist_read_variable_at_entry): Likewise.
(loclist_describe_location): Likewise.
(loclist_tracepoint_var_ref): Likewise.
(loclist_generate_c_location): Likewise.
* dwarf2read.c (line_header_hash_voidp): Likewise.
(line_header_eq_voidp): Likewise.
(dwarf2_has_info): Likewise.
(dwarf2_get_section_info): Likewise.
(locate_dwz_sections): Likewise.
(hash_file_name_entry): Likewise.
(eq_file_name_entry): Likewise.
(delete_file_name_entry): Likewise.
(dw2_setup): Likewise.
(dw2_get_file_names_reader): Likewise.
(dw2_find_pc_sect_compunit_symtab): Likewise.
(hash_signatured_type): Likewise.
(eq_signatured_type): Likewise.
(add_signatured_type_cu_to_table): Likewise.
(create_debug_types_hash_table): Likewise.
(lookup_dwo_signatured_type): Likewise.
(lookup_dwp_signatured_type): Likewise.
(lookup_signatured_type): Likewise.
(hash_type_unit_group): Likewise.
(eq_type_unit_group): Likewise.
(get_type_unit_group): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(sort_tu_by_abbrev_offset): Likewise.
(process_skeletonless_type_unit): Likewise.
(psymtabs_addrmap_cleanup): Likewise.
(dwarf2_read_symtab): Likewise.
(psymtab_to_symtab_1): Likewise.
(die_hash): Likewise.
(die_eq): Likewise.
(load_full_comp_unit_reader): Likewise.
(reset_die_in_process): Likewise.
(free_cu_line_header): Likewise.
(handle_DW_AT_stmt_list): Likewise.
(hash_dwo_file): Likewise.
(eq_dwo_file): Likewise.
(hash_dwo_unit): Likewise.
(eq_dwo_unit): Likewise.
(create_dwo_cu_reader): Likewise.
(create_dwo_unit_in_dwp_v1): Likewise.
(create_dwo_unit_in_dwp_v2): Likewise.
(lookup_dwo_unit_in_dwp): Likewise.
(dwarf2_locate_dwo_sections): Likewise.
(dwarf2_locate_common_dwp_sections): Likewise.
(dwarf2_locate_v2_dwp_sections): Likewise.
(hash_dwp_loaded_cutus): Likewise.
(eq_dwp_loaded_cutus): Likewise.
(lookup_dwo_cutu): Likewise.
(abbrev_table_free_cleanup): Likewise.
(dwarf2_free_abbrev_table): Likewise.
(find_partial_die_in_comp_unit): Likewise.
(free_line_header_voidp): Likewise.
(follow_die_offset): Likewise.
(follow_die_sig_1): Likewise.
(free_heap_comp_unit): Likewise.
(free_stack_comp_unit): Likewise.
(dwarf2_free_objfile): Likewise.
(per_cu_offset_and_type_hash): Likewise.
(per_cu_offset_and_type_eq): Likewise.
(get_die_type_at_offset): Likewise.
(partial_die_hash): Likewise.
(partial_die_eq): Likewise.
(dwarf2_per_objfile_free): Likewise.
(hash_strtab_entry): Likewise.
(eq_strtab_entry): Likewise.
(add_string): Likewise.
(hash_symtab_entry): Likewise.
(eq_symtab_entry): Likewise.
(delete_symtab_entry): Likewise.
(cleanup_mapped_symtab): Likewise.
(add_indices_to_cpool): Likewise.
(hash_psymtab_cu_index): Likewise.
(eq_psymtab_cu_index): Likewise.
(add_address_entry_worker): Likewise.
(unlink_if_set): Likewise.
(write_one_signatured_type): Likewise.
(save_gdb_index_command): Likewise.
* elfread.c (elf_symtab_read): Likewise.
(elf_gnu_ifunc_cache_hash): Likewise.
(elf_gnu_ifunc_cache_eq): Likewise.
(elf_gnu_ifunc_record_cache): Likewise.
(elf_gnu_ifunc_resolve_by_cache): Likewise.
(elf_get_probes): Likewise.
(probe_key_free): Likewise.
* f-lang.c (builtin_f_type): Likewise.
* frame-base.c (frame_base_append_sniffer): Likewise.
(frame_base_set_default): Likewise.
(frame_base_find_by_frame): Likewise.
* frame-unwind.c (frame_unwind_prepend_unwinder): Likewise.
(frame_unwind_append_unwinder): Likewise.
(frame_unwind_find_by_frame): Likewise.
* frame.c (frame_addr_hash): Likewise.
(frame_addr_hash_eq): Likewise.
(frame_stash_find): Likewise.
(do_frame_register_read): Likewise.
(unwind_to_current_frame): Likewise.
(frame_cleanup_after_sniffer): Likewise.
* frv-linux-tdep.c (frv_linux_sigtramp_frame_cache): Likewise.
* frv-tdep.c (frv_frame_unwind_cache): Likewise.
* ft32-tdep.c (ft32_frame_cache): Likewise.
* gcore.c (do_bfd_delete_cleanup): Likewise.
(gcore_create_callback): Likewise.
* gdb_bfd.c (hash_bfd): Likewise.
(eq_bfd): Likewise.
(gdb_bfd_open): Likewise.
(free_one_bfd_section): Likewise.
(gdb_bfd_ref): Likewise.
(gdb_bfd_unref): Likewise.
(get_section_descriptor): Likewise.
(gdb_bfd_map_section): Likewise.
(gdb_bfd_crc): Likewise.
(gdb_bfd_mark_parent): Likewise.
(gdb_bfd_record_inclusion): Likewise.
(gdb_bfd_requires_relocations): Likewise.
(print_one_bfd): Likewise.
* gdbtypes.c (type_pair_hash): Likewise.
(type_pair_eq): Likewise.
(builtin_type): Likewise.
(objfile_type): Likewise.
* gnu-v3-abi.c (vtable_ptrdiff_type): Likewise.
(vtable_address_point_offset): Likewise.
(gnuv3_get_vtable): Likewise.
(hash_value_and_voffset): Likewise.
(eq_value_and_voffset): Likewise.
(compare_value_and_voffset): Likewise.
(compute_vtable_size): Likewise.
(gnuv3_get_typeid_type): Likewise.
* go-lang.c (builtin_go_type): Likewise.
* guile/scm-block.c (bkscm_hash_block_smob): Likewise.
(bkscm_eq_block_smob): Likewise.
(bkscm_objfile_block_map): Likewise.
(bkscm_del_objfile_blocks): Likewise.
* guile/scm-breakpoint.c (bpscm_build_bp_list): Likewise.
* guile/scm-disasm.c (gdbscm_disasm_read_memory_worker): Likewise.
(gdbscm_disasm_print_address): Likewise.
* guile/scm-frame.c (frscm_hash_frame_smob): Likewise.
(frscm_eq_frame_smob): Likewise.
(frscm_inferior_frame_map): Likewise.
(frscm_del_inferior_frames): Likewise.
* guile/scm-gsmob.c (gdbscm_add_objfile_ref): Likewise.
* guile/scm-objfile.c (ofscm_handle_objfile_deleted): Likewise.
(ofscm_objfile_smob_from_objfile): Likewise.
* guile/scm-ports.c (ioscm_write): Likewise.
(ioscm_file_port_delete): Likewise.
(ioscm_file_port_rewind): Likewise.
(ioscm_file_port_put): Likewise.
(ioscm_file_port_write): Likewise.
* guile/scm-progspace.c (psscm_handle_pspace_deleted): Likewise.
(psscm_pspace_smob_from_pspace): Likewise.
* guile/scm-safe-call.c (scscm_recording_pre_unwind_handler): Likewise.
(scscm_recording_unwind_handler): Likewise.
(gdbscm_with_catch): Likewise.
(scscm_call_0_body): Likewise.
(scscm_call_1_body): Likewise.
(scscm_call_2_body): Likewise.
(scscm_call_3_body): Likewise.
(scscm_call_4_body): Likewise.
(scscm_apply_1_body): Likewise.
(scscm_eval_scheme_string): Likewise.
(gdbscm_safe_eval_string): Likewise.
(scscm_source_scheme_script): Likewise.
(gdbscm_safe_source_script): Likewise.
* guile/scm-string.c (gdbscm_call_scm_to_stringn): Likewise.
(gdbscm_call_scm_from_stringn): Likewise.
* guile/scm-symbol.c (syscm_hash_symbol_smob): Likewise.
(syscm_eq_symbol_smob): Likewise.
(syscm_get_symbol_map): Likewise.
(syscm_del_objfile_symbols): Likewise.
* guile/scm-symtab.c (stscm_hash_symtab_smob): Likewise.
(stscm_eq_symtab_smob): Likewise.
(stscm_objfile_symtab_map): Likewise.
(stscm_del_objfile_symtabs): Likewise.
* guile/scm-type.c (tyscm_hash_type_smob): Likewise.
(tyscm_eq_type_smob): Likewise.
(tyscm_type_map): Likewise.
(tyscm_copy_type_recursive): Likewise.
(save_objfile_types): Likewise.
* guile/scm-utils.c (extract_arg): Likewise.
* h8300-tdep.c (h8300_frame_cache): Likewise.
* hppa-linux-tdep.c (hppa_linux_sigtramp_frame_unwind_cache): Likewise.
* hppa-tdep.c (compare_unwind_entries): Likewise.
(find_unwind_entry): Likewise.
(hppa_frame_cache): Likewise.
(hppa_stub_frame_unwind_cache): Likewise.
* hppanbsd-tdep.c (hppanbsd_supply_gregset): Likewise.
* hppaobsd-tdep.c (hppaobsd_supply_gregset): Likewise.
(hppaobsd_supply_fpregset): Likewise.
* i386-cygwin-tdep.c (core_process_module_section): Likewise.
* i386-linux-tdep.c (i386_linux_init_abi): Likewise.
* i386-tdep.c (i386_frame_cache): Likewise.
(i386_epilogue_frame_cache): Likewise.
(i386_sigtramp_frame_cache): Likewise.
(i386_supply_gregset): Likewise.
(i386_collect_gregset): Likewise.
(i386_gdbarch_init): Likewise.
* i386obsd-tdep.c (i386obsd_aout_supply_regset): Likewise.
(i386obsd_trapframe_cache): Likewise.
* i387-tdep.c (i387_supply_fsave): Likewise.
(i387_collect_fsave): Likewise.
(i387_supply_fxsave): Likewise.
(i387_collect_fxsave): Likewise.
(i387_supply_xsave): Likewise.
(i387_collect_xsave): Likewise.
* ia64-tdep.c (ia64_frame_cache): Likewise.
(ia64_sigtramp_frame_cache): Likewise.
* infcmd.c (attach_command_continuation): Likewise.
(attach_command_continuation_free_args): Likewise.
* inferior.c (restore_inferior): Likewise.
(delete_thread_of_inferior): Likewise.
* inflow.c (inflow_inferior_data_cleanup): Likewise.
(get_inflow_inferior_data): Likewise.
(inflow_inferior_exit): Likewise.
* infrun.c (displaced_step_clear_cleanup): Likewise.
(restore_current_uiout_cleanup): Likewise.
(release_stop_context_cleanup): Likewise.
(do_restore_infcall_suspend_state_cleanup): Likewise.
(do_restore_infcall_control_state_cleanup): Likewise.
(restore_inferior_ptid): Likewise.
* inline-frame.c (block_starting_point_at): Likewise.
* iq2000-tdep.c (iq2000_frame_cache): Likewise.
* jit.c (get_jit_objfile_data): Likewise.
(get_jit_program_space_data): Likewise.
(jit_object_close_impl): Likewise.
(jit_find_objf_with_entry_addr): Likewise.
(jit_breakpoint_deleted): Likewise.
(jit_unwind_reg_set_impl): Likewise.
(jit_unwind_reg_get_impl): Likewise.
(jit_dealloc_cache): Likewise.
(jit_frame_sniffer): Likewise.
(jit_frame_prev_register): Likewise.
(jit_prepend_unwinder): Likewise.
(jit_inferior_exit_hook): Likewise.
(free_objfile_data): Likewise.
* jv-lang.c (jv_per_objfile_free): Likewise.
(get_dynamics_objfile): Likewise.
(get_java_class_symtab): Likewise.
(builtin_java_type): Likewise.
* language.c (language_string_char_type): Likewise.
(language_bool_type): Likewise.
(language_lookup_primitive_type): Likewise.
(language_lookup_primitive_type_as_symbol): Likewise.
* linespec.c (hash_address_entry): Likewise.
(eq_address_entry): Likewise.
(iterate_inline_only): Likewise.
(iterate_name_matcher): Likewise.
(decode_line_2_compare_items): Likewise.
(collect_one_symbol): Likewise.
(compare_symbols): Likewise.
(compare_msymbols): Likewise.
(add_symtabs_to_list): Likewise.
(collect_symbols): Likewise.
(compare_msyms): Likewise.
(add_minsym): Likewise.
(cleanup_linespec_result): Likewise.
* linux-fork.c (inferior_call_waitpid_cleanup): Likewise.
* linux-nat.c (delete_lwp_cleanup): Likewise.
(count_events_callback): Likewise.
(select_event_lwp_callback): Likewise.
(resume_stopped_resumed_lwps): Likewise.
* linux-tdep.c (get_linux_gdbarch_data): Likewise.
(invalidate_linux_cache_inf): Likewise.
(get_linux_inferior_data): Likewise.
(linux_find_memory_regions_thunk): Likewise.
(linux_make_mappings_callback): Likewise.
(linux_corefile_thread_callback): Likewise.
(find_mapping_size): Likewise.
* linux-thread-db.c (find_new_threads_callback): Likewise.
* lm32-tdep.c (lm32_frame_cache): Likewise.
* m2-lang.c (builtin_m2_type): Likewise.
* m32c-tdep.c (m32c_analyze_frame_prologue): Likewise.
* m32r-linux-tdep.c (m32r_linux_sigtramp_frame_cache): Likewise.
(m32r_linux_supply_gregset): Likewise.
(m32r_linux_collect_gregset): Likewise.
* m32r-tdep.c (m32r_frame_unwind_cache): Likewise.
* m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise.
* m68k-tdep.c (m68k_frame_cache): Likewise.
* m68kbsd-tdep.c (m68kbsd_supply_fpregset): Likewise.
(m68kbsd_supply_gregset): Likewise.
* m68klinux-tdep.c (m68k_linux_sigtramp_frame_cache): Likewise.
* m88k-tdep.c (m88k_frame_cache): Likewise.
(m88k_supply_gregset): Likewise.
gdb/gdbserver/ChangeLog:
* dll.c (match_dll): Add cast(s).
(unloaded_dll): Likewise.
* linux-low.c (second_thread_of_pid_p): Likewise.
(delete_lwp_callback): Likewise.
(count_events_callback): Likewise.
(select_event_lwp_callback): Likewise.
(linux_set_resume_request): Likewise.
* server.c (accumulate_file_name_length): Likewise.
(emit_dll_description): Likewise.
(handle_qxfer_threads_worker): Likewise.
(visit_actioned_threads): Likewise.
* thread-db.c (any_thread_of): Likewise.
* tracepoint.c (same_process_p): Likewise.
(match_blocktype): Likewise.
(build_traceframe_info_xml): Likewise.
gdb/testsuite/ChangeLog:
* gdb.gdb/selftest.exp (do_steps_and_nexts): Adjust expected
source line.
2015-09-25 20:08:07 +02:00
|
|
|
|
int *selector = (int *) data;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
gdb_assert (selector != NULL);
|
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
/* Select only resumed LWPs that have an event pending. */
|
|
|
|
|
if (lp->resumed && lwp_status_pending_p (lp))
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
if ((*selector)-- == 0)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-24 23:52:06 +01:00
|
|
|
|
/* Called when the LWP stopped for a signal/trap. If it stopped for a
|
|
|
|
|
trap check what caused it (breakpoint, watchpoint, trace, etc.),
|
|
|
|
|
and save the result in the LWP's stop_reason field. If it stopped
|
|
|
|
|
for a breakpoint, decrement the PC if necessary on the lwp's
|
|
|
|
|
architecture. */
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
|
2016-02-24 23:52:06 +01:00
|
|
|
|
static void
|
|
|
|
|
save_stop_reason (struct lwp_info *lp)
|
2008-03-25 13:20:10 +01:00
|
|
|
|
{
|
2016-02-24 23:52:06 +01:00
|
|
|
|
struct regcache *regcache;
|
|
|
|
|
struct gdbarch *gdbarch;
|
2008-05-04 16:12:34 +02:00
|
|
|
|
CORE_ADDR pc;
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
CORE_ADDR sw_bp_pc;
|
2015-03-04 21:41:16 +01:00
|
|
|
|
#if USE_SIGTRAP_SIGINFO
|
|
|
|
|
siginfo_t siginfo;
|
|
|
|
|
#endif
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
|
2016-02-24 23:52:06 +01:00
|
|
|
|
gdb_assert (lp->stop_reason == TARGET_STOPPED_BY_NO_REASON);
|
|
|
|
|
gdb_assert (lp->status != 0);
|
|
|
|
|
|
|
|
|
|
if (!linux_nat_status_is_event (lp->status))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
regcache = get_thread_regcache (lp->ptid);
|
2017-10-25 17:37:03 +02:00
|
|
|
|
gdbarch = regcache->arch ();
|
2016-02-24 23:52:06 +01:00
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
pc = regcache_read_pc (regcache);
|
2015-03-04 21:41:17 +01:00
|
|
|
|
sw_bp_pc = pc - gdbarch_decr_pc_after_break (gdbarch);
|
2008-05-04 16:12:34 +02:00
|
|
|
|
|
2015-03-04 21:41:16 +01:00
|
|
|
|
#if USE_SIGTRAP_SIGINFO
|
|
|
|
|
if (linux_nat_get_siginfo (lp->ptid, &siginfo))
|
|
|
|
|
{
|
|
|
|
|
if (siginfo.si_signo == SIGTRAP)
|
|
|
|
|
{
|
2016-02-24 23:52:06 +01:00
|
|
|
|
if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code)
|
|
|
|
|
&& GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code))
|
2015-03-04 21:41:16 +01:00
|
|
|
|
{
|
2016-02-24 23:52:06 +01:00
|
|
|
|
/* The si_code is ambiguous on this arch -- check debug
|
|
|
|
|
registers. */
|
|
|
|
|
if (!check_stopped_by_watchpoint (lp))
|
|
|
|
|
lp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
|
|
|
|
|
}
|
|
|
|
|
else if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code))
|
|
|
|
|
{
|
|
|
|
|
/* If we determine the LWP stopped for a SW breakpoint,
|
|
|
|
|
trust it. Particularly don't check watchpoint
|
|
|
|
|
registers, because at least on s390, we'd find
|
|
|
|
|
stopped-by-watchpoint as long as there's a watchpoint
|
|
|
|
|
set. */
|
2015-03-04 21:41:16 +01:00
|
|
|
|
lp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
|
|
|
|
|
}
|
2016-02-24 23:52:06 +01:00
|
|
|
|
else if (GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code))
|
2015-03-04 21:41:16 +01:00
|
|
|
|
{
|
2016-02-24 23:52:06 +01:00
|
|
|
|
/* This can indicate either a hardware breakpoint or
|
|
|
|
|
hardware watchpoint. Check debug registers. */
|
|
|
|
|
if (!check_stopped_by_watchpoint (lp))
|
|
|
|
|
lp->stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
|
2015-03-04 21:41:16 +01:00
|
|
|
|
}
|
2015-03-24 19:31:51 +01:00
|
|
|
|
else if (siginfo.si_code == TRAP_TRACE)
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"CSBB: %s stopped by trace\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
2016-02-24 23:52:06 +01:00
|
|
|
|
|
|
|
|
|
/* We may have single stepped an instruction that
|
|
|
|
|
triggered a watchpoint. In that case, on some
|
|
|
|
|
architectures (such as x86), instead of TRAP_HWBKPT,
|
|
|
|
|
si_code indicates TRAP_TRACE, and we need to check
|
|
|
|
|
the debug registers separately. */
|
|
|
|
|
check_stopped_by_watchpoint (lp);
|
2015-03-24 19:31:51 +01:00
|
|
|
|
}
|
2015-03-04 21:41:16 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#else
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
if ((!lp->step || lp->stop_pc == sw_bp_pc)
|
2017-11-02 16:15:41 +01:00
|
|
|
|
&& software_breakpoint_inserted_here_p (regcache->aspace (),
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
sw_bp_pc))
|
2008-03-25 13:20:10 +01:00
|
|
|
|
{
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
/* The LWP was either continued, or stepped a software
|
|
|
|
|
breakpoint instruction. */
|
2016-02-24 23:52:06 +01:00
|
|
|
|
lp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-02 16:15:41 +01:00
|
|
|
|
if (hardware_breakpoint_inserted_here_p (regcache->aspace (), pc))
|
2016-02-24 23:52:06 +01:00
|
|
|
|
lp->stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
|
|
|
|
|
|
|
|
|
|
if (lp->stop_reason == TARGET_STOPPED_BY_NO_REASON)
|
|
|
|
|
check_stopped_by_watchpoint (lp);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT)
|
|
|
|
|
{
|
2008-03-25 13:20:10 +01:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
2015-03-24 19:31:51 +01:00
|
|
|
|
"CSBB: %s stopped by software breakpoint\n",
|
2008-03-25 13:20:10 +01:00
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
|
|
|
|
|
/* Back up the PC if necessary. */
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
if (pc != sw_bp_pc)
|
|
|
|
|
regcache_write_pc (regcache, sw_bp_pc);
|
2008-05-04 16:12:34 +02:00
|
|
|
|
|
2016-02-24 23:52:06 +01:00
|
|
|
|
/* Update this so we record the correct stop PC below. */
|
|
|
|
|
pc = sw_bp_pc;
|
2008-03-25 13:20:10 +01:00
|
|
|
|
}
|
2016-02-24 23:52:06 +01:00
|
|
|
|
else if (lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT)
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
2016-02-24 23:52:06 +01:00
|
|
|
|
"CSBB: %s stopped by hardware breakpoint\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
}
|
|
|
|
|
else if (lp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT)
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"CSBB: %s stopped by hardware watchpoint\n",
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
}
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
2016-02-24 23:52:06 +01:00
|
|
|
|
lp->stop_pc = pc;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-04 21:41:16 +01:00
|
|
|
|
|
|
|
|
|
/* Returns true if the LWP had stopped for a software breakpoint. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
linux_nat_stopped_by_sw_breakpoint (struct target_ops *ops)
|
|
|
|
|
{
|
|
|
|
|
struct lwp_info *lp = find_lwp_pid (inferior_ptid);
|
|
|
|
|
|
|
|
|
|
gdb_assert (lp != NULL);
|
|
|
|
|
|
|
|
|
|
return lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implement the supports_stopped_by_sw_breakpoint method. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
linux_nat_supports_stopped_by_sw_breakpoint (struct target_ops *ops)
|
|
|
|
|
{
|
|
|
|
|
return USE_SIGTRAP_SIGINFO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns true if the LWP had stopped for a hardware
|
|
|
|
|
breakpoint/watchpoint. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
linux_nat_stopped_by_hw_breakpoint (struct target_ops *ops)
|
|
|
|
|
{
|
|
|
|
|
struct lwp_info *lp = find_lwp_pid (inferior_ptid);
|
|
|
|
|
|
|
|
|
|
gdb_assert (lp != NULL);
|
|
|
|
|
|
|
|
|
|
return lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implement the supports_stopped_by_hw_breakpoint method. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
linux_nat_supports_stopped_by_hw_breakpoint (struct target_ops *ops)
|
|
|
|
|
{
|
|
|
|
|
return USE_SIGTRAP_SIGINFO;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
/* Select one LWP out of those that have events pending. */
|
|
|
|
|
|
|
|
|
|
static void
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
select_event_lwp (ptid_t filter, struct lwp_info **orig_lp, int *status)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
|
|
|
|
int num_events = 0;
|
|
|
|
|
int random_selector;
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
struct lwp_info *event_lp = NULL;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
2006-01-04 20:34:58 +01:00
|
|
|
|
/* Record the wait status for the original LWP. */
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
(*orig_lp)->status = *status;
|
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
/* In all-stop, give preference to the LWP that is being
|
|
|
|
|
single-stepped. There will be at most one, and it will be the
|
|
|
|
|
LWP that the core is most interested in. If we didn't do this,
|
|
|
|
|
then we'd have to handle pending step SIGTRAPs somehow in case
|
|
|
|
|
the core later continues the previously-stepped thread, as
|
|
|
|
|
otherwise we'd report the pending SIGTRAP then, and the core, not
|
|
|
|
|
having stepped the thread, wouldn't understand what the trap was
|
|
|
|
|
for, and therefore would report it to the user as a random
|
|
|
|
|
signal. */
|
Implement all-stop on top of a target running non-stop mode
This finally implements user-visible all-stop mode running with the
target_ops backend always in non-stop mode. This is a stepping stone
towards finer-grained control of threads, being able to do interesting
things like thread groups, associating groups with breakpoints, etc.
From the user's perspective, all-stop mode is really just a special
case of being able to stop and resume specific sets of threads, so it
makes sense to do this step first.
With this, even in all-stop, the target is no longer in charge of
stopping all threads before reporting an event to the core -- the core
takes care of it when it sees fit. For example, when "next"- or
"step"-ing, we can avoid stopping and resuming all threads at each
internal single-step, and instead only stop all threads when we're
about to present the stop to the user.
The implementation is almost straight forward, as the heavy lifting
has been done already in previous patches. Basically, we replace
checks for "set non-stop on/off" (the non_stop global), with calls to
a new target_is_non_stop_p function. In a few places, if "set
non-stop off", we stop all threads explicitly, and in a few other
places we resume all threads explicitly, making use of existing
methods that were added for teaching non-stop to step over breakpoints
without displaced stepping.
This adds a new "maint set target-non-stop on/off/auto" knob that
allows both disabling the feature if we find problems, and
force-enable it for development (useful when teaching a target about
this. The default is "auto", which means the feature is enabled if a
new target method says it should be enabled. The patch implements the
method in linux-nat.c, just for illustration, because it still returns
false. We'll need a few follow up fixes before turning it on by
default. This is a separate target method from indicating regular
non-stop support, because e.g., while e.g., native linux-nat.c is
close to regression free with all-stop-non-stop (with following
patches will fixing the remaining regressions), remote.c+gdbserver
will still need more fixing, even though it supports "set non-stop
on".
Tested on x86_64 Fedora 20, native, with and without "set displaced
off", and with and without "maint set target-non-stop on"; and also
against gdbserver.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* NEWS: Mention "maint set/show target-non-stop".
* breakpoint.c (update_global_location_list): Check
target_is_non_stop_p instead of non_stop.
* infcmd.c (attach_command_post_wait, attach_command): Likewise.
* infrun.c (show_can_use_displaced_stepping)
(can_use_displaced_stepping_p, start_step_over_inferior):
Likewise.
(internal_resume_ptid): New function.
(resume): Use it.
(proceed): Check target_is_non_stop_p instead of non_stop. If in
all-stop mode but the target is always in non-stop mode, start all
the other threads that are implicitly resumed too.
(for_each_just_stopped_thread, fetch_inferior_event)
(adjust_pc_after_break, stop_all_threads): Check
target_is_non_stop_p instead of non_stop.
(handle_inferior_event): Likewise. Handle detach-fork in all-stop
with the target always in non-stop mode.
(handle_signal_stop) <random signal>: Check target_is_non_stop_p
instead of non_stop.
(switch_back_to_stepped_thread): Check target_is_non_stop_p
instead of non_stop.
(keep_going_stepped_thread): Use internal_resume_ptid.
(stop_waiting): If in all-stop mode, and the target is in non-stop
mode, stop all threads.
(keep_going_pass): Likewise, when starting a new in-line step-over
sequence.
* linux-nat.c (get_pending_status, select_event_lwp)
(linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check
target_is_non_stop_p instead of non_stop.
(linux_nat_always_non_stop_p): New function.
(linux_nat_stop): Check target_is_non_stop_p instead of non_stop.
(linux_nat_add_target): Install linux_nat_always_non_stop_p.
* target-delegates.c: Regenerate.
* target.c (target_is_non_stop_p): New function.
(target_non_stop_enabled, target_non_stop_enabled_1): New globals.
(maint_set_target_non_stop_command)
(maint_show_target_non_stop_command): New functions.
(_initilize_target): Install "maint set/show target-non-stop"
commands.
* target.h (struct target_ops) <to_always_non_stop_p>: New field.
(target_non_stop_enabled): New declaration.
(target_is_non_stop_p): New declaration.
gdb/doc/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
target-non-stop".
2015-08-07 18:24:01 +02:00
|
|
|
|
if (!target_is_non_stop_p ())
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
event_lp = iterate_over_lwps (filter,
|
|
|
|
|
select_singlestep_lwp_callback, NULL);
|
|
|
|
|
if (event_lp != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"SEL: Select single-step %s\n",
|
|
|
|
|
target_pid_to_str (event_lp->ptid));
|
|
|
|
|
}
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
|
|
|
|
|
if (event_lp == NULL)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
/* Pick one at random, out of those which have had events. */
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
/* First see how many events we have. */
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
iterate_over_lwps (filter, count_events_callback, &num_events);
|
gdbserver/Linux: unbreak thread event randomization
Wanting to make sure the new continue-pending-status.exp test tests
both cases of threads 2 and 3 reporting an event, I added counters to
the test, to make it FAIL if events for both threads aren't seen.
Assuming a well behaved backend, and given a reasonable number of
iterations, it should PASS.
However, running that against GNU/Linux gdbserver, I found that
surprisingly, that FAILed. GDBserver always reported the breakpoint
hit for the same thread.
Turns out that I broke gdbserver's thread event randomization
recently, with git commit 582511be ([gdbserver] linux-low.c: better
starvation avoidance, handle non-stop mode too). In that commit I
missed that the thread structure also has a status_pending_p field...
The end result was that count_events_callback always returns 0, and
then if no thread is stepping, select_event_lwp always returns the
event thread. IOW, no randomization is happening at all. Quite
curious how all the other changes in that patch were sufficient to fix
non-stop-fair-events.exp anyway even with that broken.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/gdbserver/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-low.c (count_events_callback, select_event_lwp_callback):
Use the lwp's status_pending_p field, not the thread's.
gdb/testsuite/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* gdb.threads/continue-pending-status.exp (saw_thread_2)
(saw_thread_3): New globals.
(top level): Increment them when an event for the corresponding
thread is seen.
(no thread starvation): New test.
2015-03-15 20:35:26 +01:00
|
|
|
|
gdb_assert (num_events > 0);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
/* Now randomly pick a LWP out of those that have had
|
|
|
|
|
events. */
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
random_selector = (int)
|
|
|
|
|
((num_events * (double) rand ()) / (RAND_MAX + 1.0));
|
|
|
|
|
|
|
|
|
|
if (debug_linux_nat && num_events > 1)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
"SEL: Found %d events, selecting #%d\n",
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
num_events, random_selector);
|
|
|
|
|
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
event_lp = iterate_over_lwps (filter,
|
|
|
|
|
select_event_lwp_callback,
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
&random_selector);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (event_lp != NULL)
|
|
|
|
|
{
|
|
|
|
|
/* Switch the event LWP. */
|
|
|
|
|
*orig_lp = event_lp;
|
|
|
|
|
*status = event_lp->status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Flush the wait status for the event LWP. */
|
|
|
|
|
(*orig_lp)->status = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return non-zero if LP has been resumed. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
resumed_callback (struct lwp_info *lp, void *data)
|
|
|
|
|
{
|
|
|
|
|
return lp->resumed;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-17 15:49:06 +01:00
|
|
|
|
/* Check if we should go on and pass this event to common code.
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
Return the affected lwp if we are, or NULL otherwise. */
|
2011-10-12 14:11:26 +02:00
|
|
|
|
|
2008-03-17 15:49:06 +01:00
|
|
|
|
static struct lwp_info *
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
linux_nat_filter_event (int lwpid, int status)
|
2008-03-17 15:49:06 +01:00
|
|
|
|
{
|
|
|
|
|
struct lwp_info *lp;
|
2014-09-19 19:54:34 +02:00
|
|
|
|
int event = linux_ptrace_get_extended_event (status);
|
2008-03-17 15:49:06 +01:00
|
|
|
|
|
|
|
|
|
lp = find_lwp_pid (pid_to_ptid (lwpid));
|
|
|
|
|
|
|
|
|
|
/* Check for stop events reported by a process we didn't already
|
|
|
|
|
know about - anything not already in our LWP list.
|
|
|
|
|
|
|
|
|
|
If we're expecting to receive stopped processes after
|
|
|
|
|
fork, vfork, and clone events, then we'll just add the
|
|
|
|
|
new one to our list and go back to waiting for the event
|
|
|
|
|
to be reported - the stopped process might be returned
|
2011-10-28 20:30:00 +02:00
|
|
|
|
from waitpid before or after the event is.
|
|
|
|
|
|
|
|
|
|
But note the case of a non-leader thread exec'ing after the
|
|
|
|
|
leader having exited, and gone from our lists. The non-leader
|
|
|
|
|
thread changes its tid to the tgid. */
|
|
|
|
|
|
|
|
|
|
if (WIFSTOPPED (status) && lp == NULL
|
2014-09-19 19:54:34 +02:00
|
|
|
|
&& (WSTOPSIG (status) == SIGTRAP && event == PTRACE_EVENT_EXEC))
|
2011-10-28 20:30:00 +02:00
|
|
|
|
{
|
|
|
|
|
/* A multi-thread exec after we had seen the leader exiting. */
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LLW: Re-adding thread group leader LWP %d.\n",
|
|
|
|
|
lwpid);
|
|
|
|
|
|
2013-09-30 13:50:12 +02:00
|
|
|
|
lp = add_lwp (ptid_build (lwpid, lwpid, 0));
|
2011-10-28 20:30:00 +02:00
|
|
|
|
lp->stopped = 1;
|
|
|
|
|
lp->resumed = 1;
|
|
|
|
|
add_thread (lp->ptid);
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-17 15:49:06 +01:00
|
|
|
|
if (WIFSTOPPED (status) && !lp)
|
|
|
|
|
{
|
linux-nat.c: fix a few lin_lwp_attach_lwp issues
This function has a few latent bugs that are triggered by a non-stop
mode test that will be added in a subsequent patch.
First, as described in the function's intro comment, the function is
supposed to return 1 if we're already auto attached to the thread, but
haven't processed the PTRACE_EVENT_CLONE event of its parent thread
yet.
Then, we may find that we're trying to attach to a clone child that
hasn't yet stopped for its initial stop, and therefore 'waitpid(...,
WNOHANG)' returns 0. In that case, we're currently adding the LWP to
the stopped_pids list, which results in linux_handle_extended_wait
skipping the waitpid call on the child, and thus confusing things
later on when the child eventually reports the stop.
Then, the tail end of lin_lwp_attach_lwp always sets the
last_resume_kind of the LWP to resume_stop, which is wrong given that
the user may be doing "info threads" while some threads are running.
And then, the else branch of lin_lwp_attach_lwp always sets the
stopped flag of the LWP. This branch is reached if the LWP is the
main LWP, which may well be running at this point (to it's wrong to
set its 'stopped' flag).
AFAICS, there's no reason anymore for special-casing the main/leader
LWP here:
- For the "attach" case, linux_nat_attach already adds the main LWP to
the lwp list, and sets its 'stopped' flag.
- For the "run" case, after linux_nat_create_inferior, end up in
linux_nat_wait_1 here:
/* The first time we get here after starting a new inferior, we may
not have added it to the LWP list yet - this is the earliest
moment at which we know its PID. */
if (ptid_is_pid (inferior_ptid))
{
/* Upgrade the main thread's ptid. */
thread_change_ptid (inferior_ptid,
ptid_build (ptid_get_pid (inferior_ptid),
ptid_get_pid (inferior_ptid), 0));
lp = add_initial_lwp (inferior_ptid);
lp->resumed = 1;
}
... which adds the LWP to the LWP list already, before
lin_lwp_attach_lwp can ever be reached.
gdb/ChangeLog:
2015-02-20 Pedro Alves <palves@redhat.com>
* linux-nat.c (lin_lwp_attach_lwp): No longer special case the
main LWP. Handle the case of waitpid returning 0 if we're already
attached to the LWP. Don't set the LWP's last_resume_kind to
resume_stop if we already knew about the LWP.
(linux_nat_filter_event): Add debug logs.
2015-02-20 21:21:59 +01:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LHEW: saving LWP %ld status %s in stopped_pids list\n",
|
|
|
|
|
(long) lwpid, status_to_str (status));
|
2011-09-02 23:03:06 +02:00
|
|
|
|
add_to_pid_list (&stopped_pids, lwpid, status);
|
2008-03-17 15:49:06 +01:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make sure we don't report an event for the exit of an LWP not in
|
2011-01-09 04:08:57 +01:00
|
|
|
|
our list, i.e. not part of the current process. This can happen
|
2011-02-08 23:35:57 +01:00
|
|
|
|
if we detach from a program we originally forked and then it
|
2008-03-17 15:49:06 +01:00
|
|
|
|
exits. */
|
|
|
|
|
if (!WIFSTOPPED (status) && !lp)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
PR gdb/15713 - errors from i386_linux_resume lead to lock-up
linux_nat_resume is not considering that linux_ops->to_resume may throw:
/* Mark LWP as not stopped to prevent it from being continued by
linux_nat_resume_callback. */
lp->stopped = 0;
if (resume_many)
iterate_over_lwps (ptid, linux_nat_resume_callback, NULL);
If something within linux_nat_resume_callback throws, GDB leaves the
lwp_info as if the inferior was resumed, while it actually wasn't.
A couple examples, there are possibly others:
- i386_linux_resume calls target_read which calls QUIT.
- if the actual ptrace resumption fails in inf_ptrace_resume,
perror_with_name is called.
If the user tries to kill the inferior at this point (or quit, which
offers to kill), GDB locks up trying to stop the lwp -- if it is
already stopped no new waitpid event gets generated for it.
Fix this by setting the stopped flag earlier, as soon as we collect a
stop event with waitpid, and clearing it always only after resuming
the lwp successfully.
Tested on x86_64 Fedora 20. Confirmed the lock-up disappears using a
local hack that forces an error in inf_ptrace_resume.
Also fixes a little "set debug lin-lwp" annoyance. Currently we always see:
Continuing.
LLR: Preparing to resume process 6802, 0, inferior_ptid Thread 0x7ffff7fc7740 (LWP 6802)
^^^^^^^^
RC: Resuming sibling Thread 0x7ffff77c5700 (LWP 6807), 0, resume
RC: Resuming sibling Thread 0x7ffff7fc6700 (LWP 6806), 0, resume
RC: Not resuming sibling Thread 0x7ffff7fc7740 (LWP 6802) (not stopped)
^^^^^^^^^^^^^^^^^^^^^^^
LLR: PTRACE_CONT process 6802, 0 (resume event thread)
This patch gets rid of the "Not resuming sibling" line.
2014-05-29 Pedro Alves <palves@redhat.com>
PR gdb/15713
* linux-nat.c (linux_nat_resume_callback): Rename the second
parameter to 'except'. Skip LP if it points to EXCEPT.
(linux_nat_resume): Don't mark the event lwp as not stopped
before resuming sibling lwps. Instead ask
linux_nat_resume_callback to skip the event lwp. Mark it as not
stopped after actually resuming it.
(linux_handle_syscall_trap): Mark the lwp as not stopped after
resuming it.
(wait_lwp): Mark the lwp as stopped here.
(stop_wait_callback): Mark the lwp as not stopped right after
resuming it. Don't mark lwps as stopped here.
(linux_nat_filter_event): Mark the lwp as stopped earlier.
(linux_nat_wait_1): Don't mark dead lwps as stopped here.
2014-05-29 13:50:48 +02:00
|
|
|
|
/* This LWP is stopped now. (And if dead, this prevents it from
|
|
|
|
|
ever being continued.) */
|
|
|
|
|
lp->stopped = 1;
|
|
|
|
|
|
Linux: on attach, attach to lwps listed under /proc/$pid/task/
... instead of relying on libthread_db.
I wrote a test that attaches to a program that constantly spawns
short-lived threads, which exposed several issues. This is one of
them.
On Linux, we need to attach to all threads of a process (thread group)
individually. We currently rely on libthread_db to list the threads,
but that is problematic, because libthread_db relies on reading data
structures out of the inferior (which may well be corrupted). If
threads are being created or exiting just while we try to attach, we
may trip on inconsistencies in the inferior's thread list. To work
around that, when we see a seemingly corrupt list, we currently retry
a few times:
static void
thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new)
{
...
if (until_no_new)
{
/* Require 4 successive iterations which do not find any new threads.
The 4 is a heuristic: there is an inherent race here, and I have
seen that 2 iterations in a row are not always sufficient to
"capture" all threads. */
...
That heuristic may well fail, and when it does, we end up with threads
in the program that aren't under GDB's control. That's obviously bad
and results in quite mistifying failures, like e.g., the process dying
for seeminly no reason when a thread that wasn't attached trips on a
breakpoint.
There's really no reason to rely on libthread_db for this nowadays
when we have /proc mounted. In that case, which is the usual case, we
can list the LWPs from /proc/PID/task/. In fact, GDBserver is already
doing this. The patch factors out that code that knows to walk the
task/ directory out of GDBserver, and makes GDB use it too.
Like GDBserver, the patch makes GDB attach to LWPs and _not_ wait for
them to stop immediately. Instead, we just tag the LWP as having an
expected stop. Because we can only set the ptrace options when the
thread stops, we need a new flag in the lwp structure to keep track of
whether we've already set the ptrace options, just like in GDBserver.
Note that nothing issues any ptrace command to the threads between the
PTRACE_ATTACH and the stop, so this is safe (unlike one scenario
described in gdbserver's linux-low.c).
When we attach to a program that has threads exiting while we attach,
it's easy to race with a thread just exiting as we try to attach to
it, like:
#1 - get current list of threads
#2 - attach to each listed thread
#3 - ooops, attach failed, thread is already gone
As this is pretty normal, we shouldn't be issuing a scary warning in
step #3.
When #3 happens, PTRACE_ATTACH usually fails with ESRCH, but sometimes
we'll see EPERM as well. That happens when the kernel still has the
thread in its task list, but the thread is marked as dead.
Unfortunately, EPERM is ambiguous and we'll get it also on other
scenarios where the thread isn't dead, and in those cases, it's useful
to get a warning. To distiguish the cases, when we get an EPERM
failure, we open /proc/PID/status, and check the thread's state -- if
the /proc file no longer exists, or the state is "Z (Zombie)" or "X
(Dead)", we ignore the EPERM error silently; otherwise, we'll warn.
Unfortunately, there seems to be a kernel race here. Sometimes I get
EPERM, and then the /proc state still indicates "R (Running)"... If
we wait a bit and retry, we do end up seeing X or Z state, or get an
ESRCH. I thought of making GDB retry the attach a few times, but even
with a 500ms wait and 4 retries, I still see the warning sometimes. I
haven't been able to identify the kernel path that causes this yet,
but in any case, it looks like a kernel bug to me. As this just
results failure to suppress a warning that we've been printing since
about forever anyway, I'm just making the test cope with it, and issue
an XFAIL.
gdb/gdbserver/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_attach_fail_reason_string): Move to
nat/linux-ptrace.c, and rename.
(linux_attach_lwp): Update comment.
(attach_proc_task_lwp_callback): New function.
(linux_attach): Adjust to rename and use
linux_proc_attach_tgid_threads.
(linux_attach_fail_reason_string): Delete declaration.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-nat.c (attach_proc_task_lwp_callback): New function.
(linux_nat_attach): Use linux_proc_attach_tgid_threads.
(wait_lwp, linux_nat_filter_event): If not set yet, set the lwp's
ptrace option flags.
* linux-nat.h (struct lwp_info) <must_set_ptrace_flags>: New
field.
* nat/linux-procfs.c: Include <dirent.h>.
(linux_proc_get_int): New parameter "warn". Handle it.
(linux_proc_get_tgid): Adjust.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this.
(linux_proc_pid_get_state): New function, factored out from
(linux_proc_pid_has_state): ... this. Add new parameter "warn"
and handle it.
(linux_proc_pid_is_gone): New function.
(linux_proc_pid_is_stopped): Adjust.
(linux_proc_pid_is_zombie_maybe_warn)
(linux_proc_pid_is_zombie_nowarn): New functions.
(linux_proc_pid_is_zombie): Use
linux_proc_pid_is_zombie_maybe_warn.
(linux_proc_attach_tgid_threads): New function.
* nat/linux-procfs.h (linux_proc_get_tgid): Update comment.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this, and update comment.
(linux_proc_pid_is_gone): New declaration.
(linux_proc_pid_is_zombie): Update comment.
(linux_proc_pid_is_zombie_nowarn): New declaration.
(linux_proc_attach_lwp_func): New typedef.
(linux_proc_attach_tgid_threads): New declaration.
* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason): Adjust to
use nowarn functions.
(linux_ptrace_attach_fail_reason_string): Move here from
gdbserver/linux-low.c and rename.
(ptrace_supports_feature): If the current ptrace options are not
known yet, check them now, instead of asserting.
* nat/linux-ptrace.h (linux_ptrace_attach_fail_reason_string):
Declare.
2014-12-16 17:12:24 +01:00
|
|
|
|
if (WIFSTOPPED (status) && lp->must_set_ptrace_flags)
|
|
|
|
|
{
|
|
|
|
|
struct inferior *inf = find_inferior_pid (ptid_get_pid (lp->ptid));
|
Extended-remote Linux follow fork
This patch implements basic support for follow-fork and detach-on-fork on
extended-remote Linux targets. Only 'fork' is supported in this patch;
'vfork' support is added n a subsequent patch. This patch depends on
the previous patches in the patch series.
Sufficient extended-remote functionality has been implemented here to pass
gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the
catchpoint tests commented out. Some other fork tests fail with this
patch because it doesn't provide the architecture support needed for
watchpoint inheritance or fork catchpoints.
The implementation follows the same general structure as for the native
implementation as much as possible.
This implementation includes:
* enabling fork events in linux-low.c in initialize_low and
linux_enable_extended_features
* handling fork events in gdbserver/linux-low.c:handle_extended_wait
- when a fork event occurs in gdbserver, we must do the full creation
of the new process, thread, lwp, and breakpoint lists. This is
required whether or not the new child is destined to be
detached-on-fork, because GDB will make target calls that require all
the structures. In particular we need the breakpoint lists in order
to remove the breakpoints from a detaching child. If we are not
detaching the child we will need all these structures anyway.
- as part of this event handling we store the target_waitstatus in a new
member of the parent lwp_info structure, 'waitstatus'. This
is used to store extended event information for reporting to GDB.
- handle_extended_wait is given a return value, denoting whether the
handled event should be reported to GDB. Previously it had only
handled clone events, which were never reported.
* using a new predicate in gdbserver to control handling of the fork event
(and eventually all extended events) in linux_wait_1. The predicate,
extended_event_reported, checks a target_waitstatus.kind for an
extended ptrace event.
* implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in
gdbserver/remote-utils.c and remote.c.
* implementing new target and RSP support for target_follow_fork with
target extended-remote. (The RSP components were actually defined in
patch 1, but they see their first use here).
- remote target routine remote_follow_fork, which just sends the 'D;pid'
detach packet to detach the new fork child cleanly. We can't just
call target_detach because the data structures for the forked child
have not been allocated on the host side.
Tested on x64 Ubuntu Lucid, native, remote, extended-remote.
gdb/gdbserver/ChangeLog:
* linux-low.c (handle_extended_wait): Implement return value,
rename argument 'event_child' to 'event_lwp', handle
PTRACE_EVENT_FORK, call internal_error for unrecognized event.
(linux_low_ptrace_options): New function.
(linux_low_filter_event): Call linux_low_ptrace_options,
use different argument fo linux_enable_event_reporting,
use return value from handle_extended_wait.
(extended_event_reported): New function.
(linux_wait_1): Call extended_event_reported and set
status to report fork events.
(linux_write_memory): Add pid to debug message.
(reset_lwp_ptrace_options_callback): New function.
(linux_handle_new_gdb_connection): New function.
(linux_target_ops): Initialize new structure member.
* linux-low.h (struct lwp_info) <waitstatus>: New member.
* lynx-low.c: Initialize new structure member.
* remote-utils.c (prepare_resume_reply): Implement stop reason
"fork" for "T" stop message.
* server.c (handle_query): Call handle_new_gdb_connection.
* server.h (report_fork_events): Declare global flag.
* target.h (struct target_ops) <handle_new_gdb_connection>:
New member.
(target_handle_new_gdb_connection): New macro.
* win32-low.c: Initialize new structure member.
gdb/ChangeLog:
* linux-nat.c (linux_nat_ptrace_options): New function.
(linux_init_ptrace, wait_lwp, linux_nat_filter_event):
Call linux_nat_ptrace_options and use different argument to
linux_enable_event_reporting.
(_initialize_linux_nat): Delete call to
linux_ptrace_set_additional_flags.
* nat/linux-ptrace.c (current_ptrace_options): Rename to
supported_ptrace_options.
(additional_flags): Delete variable.
(linux_check_ptrace_features): Use supported_ptrace_options.
(linux_test_for_tracesysgood, linux_test_for_tracefork):
Likewise, and remove additional_flags check.
(linux_enable_event_reporting): Change 'attached' argument to
'options'. Use supported_ptrace_options.
(ptrace_supports_feature): Change comment. Use
supported_ptrace_options.
(linux_ptrace_set_additional_flags): Delete function.
* nat/linux-ptrace.h (linux_ptrace_set_additional_flags):
Delete function prototype.
* remote.c (remote_fork_event_p): New function.
(remote_detach_pid): New function.
(remote_detach_1): Call remote_detach_pid, don't mourn inferior
if doing detach-on-fork.
(remote_follow_fork): New function.
(remote_parse_stop_reply): Handle new "T" stop reason "fork".
(remote_pid_to_str): Print "process" strings for pid/0/0 ptids.
(init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
|
|
|
|
int options = linux_nat_ptrace_options (inf->attach_flag);
|
Linux: on attach, attach to lwps listed under /proc/$pid/task/
... instead of relying on libthread_db.
I wrote a test that attaches to a program that constantly spawns
short-lived threads, which exposed several issues. This is one of
them.
On Linux, we need to attach to all threads of a process (thread group)
individually. We currently rely on libthread_db to list the threads,
but that is problematic, because libthread_db relies on reading data
structures out of the inferior (which may well be corrupted). If
threads are being created or exiting just while we try to attach, we
may trip on inconsistencies in the inferior's thread list. To work
around that, when we see a seemingly corrupt list, we currently retry
a few times:
static void
thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new)
{
...
if (until_no_new)
{
/* Require 4 successive iterations which do not find any new threads.
The 4 is a heuristic: there is an inherent race here, and I have
seen that 2 iterations in a row are not always sufficient to
"capture" all threads. */
...
That heuristic may well fail, and when it does, we end up with threads
in the program that aren't under GDB's control. That's obviously bad
and results in quite mistifying failures, like e.g., the process dying
for seeminly no reason when a thread that wasn't attached trips on a
breakpoint.
There's really no reason to rely on libthread_db for this nowadays
when we have /proc mounted. In that case, which is the usual case, we
can list the LWPs from /proc/PID/task/. In fact, GDBserver is already
doing this. The patch factors out that code that knows to walk the
task/ directory out of GDBserver, and makes GDB use it too.
Like GDBserver, the patch makes GDB attach to LWPs and _not_ wait for
them to stop immediately. Instead, we just tag the LWP as having an
expected stop. Because we can only set the ptrace options when the
thread stops, we need a new flag in the lwp structure to keep track of
whether we've already set the ptrace options, just like in GDBserver.
Note that nothing issues any ptrace command to the threads between the
PTRACE_ATTACH and the stop, so this is safe (unlike one scenario
described in gdbserver's linux-low.c).
When we attach to a program that has threads exiting while we attach,
it's easy to race with a thread just exiting as we try to attach to
it, like:
#1 - get current list of threads
#2 - attach to each listed thread
#3 - ooops, attach failed, thread is already gone
As this is pretty normal, we shouldn't be issuing a scary warning in
step #3.
When #3 happens, PTRACE_ATTACH usually fails with ESRCH, but sometimes
we'll see EPERM as well. That happens when the kernel still has the
thread in its task list, but the thread is marked as dead.
Unfortunately, EPERM is ambiguous and we'll get it also on other
scenarios where the thread isn't dead, and in those cases, it's useful
to get a warning. To distiguish the cases, when we get an EPERM
failure, we open /proc/PID/status, and check the thread's state -- if
the /proc file no longer exists, or the state is "Z (Zombie)" or "X
(Dead)", we ignore the EPERM error silently; otherwise, we'll warn.
Unfortunately, there seems to be a kernel race here. Sometimes I get
EPERM, and then the /proc state still indicates "R (Running)"... If
we wait a bit and retry, we do end up seeing X or Z state, or get an
ESRCH. I thought of making GDB retry the attach a few times, but even
with a 500ms wait and 4 retries, I still see the warning sometimes. I
haven't been able to identify the kernel path that causes this yet,
but in any case, it looks like a kernel bug to me. As this just
results failure to suppress a warning that we've been printing since
about forever anyway, I'm just making the test cope with it, and issue
an XFAIL.
gdb/gdbserver/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_attach_fail_reason_string): Move to
nat/linux-ptrace.c, and rename.
(linux_attach_lwp): Update comment.
(attach_proc_task_lwp_callback): New function.
(linux_attach): Adjust to rename and use
linux_proc_attach_tgid_threads.
(linux_attach_fail_reason_string): Delete declaration.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-nat.c (attach_proc_task_lwp_callback): New function.
(linux_nat_attach): Use linux_proc_attach_tgid_threads.
(wait_lwp, linux_nat_filter_event): If not set yet, set the lwp's
ptrace option flags.
* linux-nat.h (struct lwp_info) <must_set_ptrace_flags>: New
field.
* nat/linux-procfs.c: Include <dirent.h>.
(linux_proc_get_int): New parameter "warn". Handle it.
(linux_proc_get_tgid): Adjust.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this.
(linux_proc_pid_get_state): New function, factored out from
(linux_proc_pid_has_state): ... this. Add new parameter "warn"
and handle it.
(linux_proc_pid_is_gone): New function.
(linux_proc_pid_is_stopped): Adjust.
(linux_proc_pid_is_zombie_maybe_warn)
(linux_proc_pid_is_zombie_nowarn): New functions.
(linux_proc_pid_is_zombie): Use
linux_proc_pid_is_zombie_maybe_warn.
(linux_proc_attach_tgid_threads): New function.
* nat/linux-procfs.h (linux_proc_get_tgid): Update comment.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this, and update comment.
(linux_proc_pid_is_gone): New declaration.
(linux_proc_pid_is_zombie): Update comment.
(linux_proc_pid_is_zombie_nowarn): New declaration.
(linux_proc_attach_lwp_func): New typedef.
(linux_proc_attach_tgid_threads): New declaration.
* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason): Adjust to
use nowarn functions.
(linux_ptrace_attach_fail_reason_string): Move here from
gdbserver/linux-low.c and rename.
(ptrace_supports_feature): If the current ptrace options are not
known yet, check them now, instead of asserting.
* nat/linux-ptrace.h (linux_ptrace_attach_fail_reason_string):
Declare.
2014-12-16 17:12:24 +01:00
|
|
|
|
|
Extended-remote Linux follow fork
This patch implements basic support for follow-fork and detach-on-fork on
extended-remote Linux targets. Only 'fork' is supported in this patch;
'vfork' support is added n a subsequent patch. This patch depends on
the previous patches in the patch series.
Sufficient extended-remote functionality has been implemented here to pass
gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the
catchpoint tests commented out. Some other fork tests fail with this
patch because it doesn't provide the architecture support needed for
watchpoint inheritance or fork catchpoints.
The implementation follows the same general structure as for the native
implementation as much as possible.
This implementation includes:
* enabling fork events in linux-low.c in initialize_low and
linux_enable_extended_features
* handling fork events in gdbserver/linux-low.c:handle_extended_wait
- when a fork event occurs in gdbserver, we must do the full creation
of the new process, thread, lwp, and breakpoint lists. This is
required whether or not the new child is destined to be
detached-on-fork, because GDB will make target calls that require all
the structures. In particular we need the breakpoint lists in order
to remove the breakpoints from a detaching child. If we are not
detaching the child we will need all these structures anyway.
- as part of this event handling we store the target_waitstatus in a new
member of the parent lwp_info structure, 'waitstatus'. This
is used to store extended event information for reporting to GDB.
- handle_extended_wait is given a return value, denoting whether the
handled event should be reported to GDB. Previously it had only
handled clone events, which were never reported.
* using a new predicate in gdbserver to control handling of the fork event
(and eventually all extended events) in linux_wait_1. The predicate,
extended_event_reported, checks a target_waitstatus.kind for an
extended ptrace event.
* implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in
gdbserver/remote-utils.c and remote.c.
* implementing new target and RSP support for target_follow_fork with
target extended-remote. (The RSP components were actually defined in
patch 1, but they see their first use here).
- remote target routine remote_follow_fork, which just sends the 'D;pid'
detach packet to detach the new fork child cleanly. We can't just
call target_detach because the data structures for the forked child
have not been allocated on the host side.
Tested on x64 Ubuntu Lucid, native, remote, extended-remote.
gdb/gdbserver/ChangeLog:
* linux-low.c (handle_extended_wait): Implement return value,
rename argument 'event_child' to 'event_lwp', handle
PTRACE_EVENT_FORK, call internal_error for unrecognized event.
(linux_low_ptrace_options): New function.
(linux_low_filter_event): Call linux_low_ptrace_options,
use different argument fo linux_enable_event_reporting,
use return value from handle_extended_wait.
(extended_event_reported): New function.
(linux_wait_1): Call extended_event_reported and set
status to report fork events.
(linux_write_memory): Add pid to debug message.
(reset_lwp_ptrace_options_callback): New function.
(linux_handle_new_gdb_connection): New function.
(linux_target_ops): Initialize new structure member.
* linux-low.h (struct lwp_info) <waitstatus>: New member.
* lynx-low.c: Initialize new structure member.
* remote-utils.c (prepare_resume_reply): Implement stop reason
"fork" for "T" stop message.
* server.c (handle_query): Call handle_new_gdb_connection.
* server.h (report_fork_events): Declare global flag.
* target.h (struct target_ops) <handle_new_gdb_connection>:
New member.
(target_handle_new_gdb_connection): New macro.
* win32-low.c: Initialize new structure member.
gdb/ChangeLog:
* linux-nat.c (linux_nat_ptrace_options): New function.
(linux_init_ptrace, wait_lwp, linux_nat_filter_event):
Call linux_nat_ptrace_options and use different argument to
linux_enable_event_reporting.
(_initialize_linux_nat): Delete call to
linux_ptrace_set_additional_flags.
* nat/linux-ptrace.c (current_ptrace_options): Rename to
supported_ptrace_options.
(additional_flags): Delete variable.
(linux_check_ptrace_features): Use supported_ptrace_options.
(linux_test_for_tracesysgood, linux_test_for_tracefork):
Likewise, and remove additional_flags check.
(linux_enable_event_reporting): Change 'attached' argument to
'options'. Use supported_ptrace_options.
(ptrace_supports_feature): Change comment. Use
supported_ptrace_options.
(linux_ptrace_set_additional_flags): Delete function.
* nat/linux-ptrace.h (linux_ptrace_set_additional_flags):
Delete function prototype.
* remote.c (remote_fork_event_p): New function.
(remote_detach_pid): New function.
(remote_detach_1): Call remote_detach_pid, don't mourn inferior
if doing detach-on-fork.
(remote_follow_fork): New function.
(remote_parse_stop_reply): Handle new "T" stop reason "fork".
(remote_pid_to_str): Print "process" strings for pid/0/0 ptids.
(init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
|
|
|
|
linux_enable_event_reporting (ptid_get_lwp (lp->ptid), options);
|
Linux: on attach, attach to lwps listed under /proc/$pid/task/
... instead of relying on libthread_db.
I wrote a test that attaches to a program that constantly spawns
short-lived threads, which exposed several issues. This is one of
them.
On Linux, we need to attach to all threads of a process (thread group)
individually. We currently rely on libthread_db to list the threads,
but that is problematic, because libthread_db relies on reading data
structures out of the inferior (which may well be corrupted). If
threads are being created or exiting just while we try to attach, we
may trip on inconsistencies in the inferior's thread list. To work
around that, when we see a seemingly corrupt list, we currently retry
a few times:
static void
thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new)
{
...
if (until_no_new)
{
/* Require 4 successive iterations which do not find any new threads.
The 4 is a heuristic: there is an inherent race here, and I have
seen that 2 iterations in a row are not always sufficient to
"capture" all threads. */
...
That heuristic may well fail, and when it does, we end up with threads
in the program that aren't under GDB's control. That's obviously bad
and results in quite mistifying failures, like e.g., the process dying
for seeminly no reason when a thread that wasn't attached trips on a
breakpoint.
There's really no reason to rely on libthread_db for this nowadays
when we have /proc mounted. In that case, which is the usual case, we
can list the LWPs from /proc/PID/task/. In fact, GDBserver is already
doing this. The patch factors out that code that knows to walk the
task/ directory out of GDBserver, and makes GDB use it too.
Like GDBserver, the patch makes GDB attach to LWPs and _not_ wait for
them to stop immediately. Instead, we just tag the LWP as having an
expected stop. Because we can only set the ptrace options when the
thread stops, we need a new flag in the lwp structure to keep track of
whether we've already set the ptrace options, just like in GDBserver.
Note that nothing issues any ptrace command to the threads between the
PTRACE_ATTACH and the stop, so this is safe (unlike one scenario
described in gdbserver's linux-low.c).
When we attach to a program that has threads exiting while we attach,
it's easy to race with a thread just exiting as we try to attach to
it, like:
#1 - get current list of threads
#2 - attach to each listed thread
#3 - ooops, attach failed, thread is already gone
As this is pretty normal, we shouldn't be issuing a scary warning in
step #3.
When #3 happens, PTRACE_ATTACH usually fails with ESRCH, but sometimes
we'll see EPERM as well. That happens when the kernel still has the
thread in its task list, but the thread is marked as dead.
Unfortunately, EPERM is ambiguous and we'll get it also on other
scenarios where the thread isn't dead, and in those cases, it's useful
to get a warning. To distiguish the cases, when we get an EPERM
failure, we open /proc/PID/status, and check the thread's state -- if
the /proc file no longer exists, or the state is "Z (Zombie)" or "X
(Dead)", we ignore the EPERM error silently; otherwise, we'll warn.
Unfortunately, there seems to be a kernel race here. Sometimes I get
EPERM, and then the /proc state still indicates "R (Running)"... If
we wait a bit and retry, we do end up seeing X or Z state, or get an
ESRCH. I thought of making GDB retry the attach a few times, but even
with a 500ms wait and 4 retries, I still see the warning sometimes. I
haven't been able to identify the kernel path that causes this yet,
but in any case, it looks like a kernel bug to me. As this just
results failure to suppress a warning that we've been printing since
about forever anyway, I'm just making the test cope with it, and issue
an XFAIL.
gdb/gdbserver/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_attach_fail_reason_string): Move to
nat/linux-ptrace.c, and rename.
(linux_attach_lwp): Update comment.
(attach_proc_task_lwp_callback): New function.
(linux_attach): Adjust to rename and use
linux_proc_attach_tgid_threads.
(linux_attach_fail_reason_string): Delete declaration.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-nat.c (attach_proc_task_lwp_callback): New function.
(linux_nat_attach): Use linux_proc_attach_tgid_threads.
(wait_lwp, linux_nat_filter_event): If not set yet, set the lwp's
ptrace option flags.
* linux-nat.h (struct lwp_info) <must_set_ptrace_flags>: New
field.
* nat/linux-procfs.c: Include <dirent.h>.
(linux_proc_get_int): New parameter "warn". Handle it.
(linux_proc_get_tgid): Adjust.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this.
(linux_proc_pid_get_state): New function, factored out from
(linux_proc_pid_has_state): ... this. Add new parameter "warn"
and handle it.
(linux_proc_pid_is_gone): New function.
(linux_proc_pid_is_stopped): Adjust.
(linux_proc_pid_is_zombie_maybe_warn)
(linux_proc_pid_is_zombie_nowarn): New functions.
(linux_proc_pid_is_zombie): Use
linux_proc_pid_is_zombie_maybe_warn.
(linux_proc_attach_tgid_threads): New function.
* nat/linux-procfs.h (linux_proc_get_tgid): Update comment.
(linux_proc_get_tracerpid): Rename to ...
(linux_proc_get_tracerpid_nowarn): ... this, and update comment.
(linux_proc_pid_is_gone): New declaration.
(linux_proc_pid_is_zombie): Update comment.
(linux_proc_pid_is_zombie_nowarn): New declaration.
(linux_proc_attach_lwp_func): New typedef.
(linux_proc_attach_tgid_threads): New declaration.
* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason): Adjust to
use nowarn functions.
(linux_ptrace_attach_fail_reason_string): Move here from
gdbserver/linux-low.c and rename.
(ptrace_supports_feature): If the current ptrace options are not
known yet, check them now, instead of asserting.
* nat/linux-ptrace.h (linux_ptrace_attach_fail_reason_string):
Declare.
2014-12-16 17:12:24 +01:00
|
|
|
|
lp->must_set_ptrace_flags = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-02 18:51:04 +02:00
|
|
|
|
/* Handle GNU/Linux's syscall SIGTRAPs. */
|
|
|
|
|
if (WIFSTOPPED (status) && WSTOPSIG (status) == SYSCALL_SIGTRAP)
|
|
|
|
|
{
|
|
|
|
|
/* No longer need the sysgood bit. The ptrace event ends up
|
|
|
|
|
recorded in lp->waitstatus if we care for it. We can carry
|
|
|
|
|
on handling the event like a regular SIGTRAP from here
|
|
|
|
|
on. */
|
|
|
|
|
status = W_STOPCODE (SIGTRAP);
|
|
|
|
|
if (linux_handle_syscall_trap (lp, 0))
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
gdb: Improve syscall entry/return tracking on Linux
The existing logic was simply to flip syscall entry/return state when a
syscall trap was seen, and even then only with active 'catch syscall'.
That can get out of sync if 'catch syscall' is toggled at odd times.
This patch updates the entry/return state for all syscall traps,
regardless of catching state, and also updates known syscall state for
other kinds of traps. Almost all PTRACE_EVENT stops are delivered from
the middle of a syscall, so this can act like an entry. Every other
kind of ptrace stop is only delivered outside of syscall event pairs, so
marking them ignored ensures the next syscall trap looks like an entry.
Three new test scenarios are added to catch-syscall.exp:
- Disable 'catch syscall' from an entry to deliberately miss the return
event, then re-enable to make sure a new entry is recognized.
- Enable 'catch syscall' for the first time from a vfork event, which is
a PTRACE_EVENT_VFORK in the middle of the syscall. Make sure the next
syscall event is recognized as the return.
- Make sure entry and return are recognized for an ENOSYS syscall. This
is to defeat a common x86 hack that uses the pre-filled ENOSYS return
value as a sign of being on the entry side.
gdb/ChangeLog:
2015-10-19 Josh Stone <jistone@redhat.com>
* linux-nat.c (linux_handle_syscall_trap): Always update entry/
return state, even when not actively catching syscalls at all.
(linux_handle_extended_wait): Mark syscall_state like an entry.
(wait_lwp): Set syscall_state ignored for other traps.
(linux_nat_filter_event): Likewise.
gdb/testsuite/ChangeLog:
2015-10-19 Josh Stone <jistone@redhat.com>
* gdb.base/catch-syscall.c: Include <sched.h>.
(unknown_syscall): New variable.
(main): Trigger a vfork and an unknown syscall.
* gdb.base/catch-syscall.exp (vfork_syscalls): New variable.
(unknown_syscall_number): Likewise.
(check_call_to_syscall): Accept an optional syscall pattern.
(check_return_from_syscall): Likewise.
(check_continue): Likewise.
(test_catch_syscall_without_args): Check for vfork and ENOSYS.
(test_catch_syscall_skipping_return): New test toggling off 'catch
syscall' to step over the syscall return, then toggling back on.
(test_catch_syscall_mid_vfork): New test turning on 'catch syscall'
during a PTRACE_EVENT_VFORK stop, in the middle of a vfork syscall.
(do_syscall_tests): Call test_catch_syscall_without_args and
test_catch_syscall_mid_vfork.
(test_catch_syscall_without_args_noxml): Check for vfork and ENOSYS.
(fill_all_syscalls_numbers): Initialize unknown_syscall_number.
2015-10-20 02:59:38 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Almost all other ptrace-stops are known to be outside of system
|
|
|
|
|
calls, with further exceptions in linux_handle_extended_wait. */
|
|
|
|
|
lp->syscall_state = TARGET_WAITKIND_IGNORE;
|
|
|
|
|
}
|
2008-03-17 15:49:06 +01:00
|
|
|
|
|
2009-10-02 18:51:04 +02:00
|
|
|
|
/* Handle GNU/Linux's extended waitstatus for trace events. */
|
2014-09-19 19:54:34 +02:00
|
|
|
|
if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP
|
|
|
|
|
&& linux_is_extended_waitstatus (status))
|
2008-03-17 15:49:06 +01:00
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LLW: Handling extended status 0x%06x\n",
|
|
|
|
|
status);
|
PR threads/18600: Threads left stopped after fork+thread spawn
When a program forks and another process start threads while gdb is
handling the fork event, newly created threads are left stuck stopped
by gdb, even though gdb presents them as "running", to the user.
This can be seen with the test added by this patch. The test has the
inferior fork a certain number of times and waits for all children to
exit. Each fork child spawns a number of threads that do nothing and
joins them immediately. Normally, the program should run unimpeded
(from the point of view of the user) and exit very quickly. Without
this fix, it doesn't because of some threads left stopped by gdb, so
inferior 1 never exits.
The program triggers when a new clone thread is found while inside the
linux_stop_and_wait_all_lwps call in linux-thread-db.c:
linux_stop_and_wait_all_lwps ();
ALL_LWPS (lp)
if (ptid_get_pid (lp->ptid) == pid)
thread_from_lwp (lp->ptid);
linux_unstop_all_lwps ();
Within linux_stop_and_wait_all_lwps, we reach
linux_handle_extended_wait with the "stopping" parameter set to 1, and
because of that we don't mark the new lwp as resumed. As consequence,
the subsequent resume_stopped_resumed_lwps, called from
linux_unstop_all_lwps, never resumes the new LWP.
There's lots of cruft in linux_handle_extended_wait that no longer
makes sense. On systems with CLONE events support, we don't rely on
libthread_db for thread listing anymore, so the code that preserves
stop_requested and the handling of last_resume_kind is all dead.
So the fix is to remove all that, and simply always mark the new LWP
as resumed, so that resume_stopped_resumed_lwps re-resumes it.
gdb/ChangeLog:
2015-07-30 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
PR threads/18600
* linux-nat.c (linux_handle_extended_wait): On CLONE event, always
mark the new thread as resumed. Remove STOPPING parameter.
(wait_lwp): Adjust call to linux_handle_extended_wait.
(linux_nat_filter_event): Adjust call to
linux_handle_extended_wait.
(resume_stopped_resumed_lwps): Add debug output.
gdb/testsuite/ChangeLog:
2015-07-30 Simon Marchi <simon.marchi@ericsson.com>
Pedro Alves <palves@redhat.com>
PR threads/18600
* gdb.threads/fork-plus-threads.c: New file.
* gdb.threads/fork-plus-threads.exp: New file.
2015-07-30 19:50:29 +02:00
|
|
|
|
if (linux_handle_extended_wait (lp, status))
|
2008-03-17 15:49:06 +01:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check if the thread has exited. */
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
if (WIFEXITED (status) || WIFSIGNALED (status))
|
|
|
|
|
{
|
2016-05-24 15:47:56 +02:00
|
|
|
|
if (!report_thread_events
|
|
|
|
|
&& num_lwps (ptid_get_pid (lp->ptid)) > 1)
|
2008-03-17 15:49:06 +01:00
|
|
|
|
{
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LLW: %s exited.\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
|
2015-12-17 15:20:51 +01:00
|
|
|
|
/* If there is at least one more LWP, then the exit signal
|
|
|
|
|
was not the end of the debugged application and should be
|
|
|
|
|
ignored. */
|
|
|
|
|
exit_lwp (lp);
|
|
|
|
|
return NULL;
|
2008-03-17 15:49:06 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-24 20:18:44 +02:00
|
|
|
|
/* Note that even if the leader was ptrace-stopped, it can still
|
|
|
|
|
exit, if e.g., some other thread brings down the whole
|
|
|
|
|
process (calls `exit'). So don't assert that the lwp is
|
|
|
|
|
resumed. */
|
2008-03-17 15:49:06 +01:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
2016-05-24 15:47:56 +02:00
|
|
|
|
"LWP %ld exited (resumed=%d)\n",
|
2015-07-24 20:18:44 +02:00
|
|
|
|
ptid_get_lwp (lp->ptid), lp->resumed);
|
2008-03-17 15:49:06 +01:00
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
/* Dead LWP's aren't expected to reported a pending sigstop. */
|
|
|
|
|
lp->signalled = 0;
|
|
|
|
|
|
|
|
|
|
/* Store the pending event in the waitstatus, because
|
|
|
|
|
W_EXITCODE(0,0) == 0. */
|
|
|
|
|
store_waitstatus (&lp->waitstatus, status);
|
|
|
|
|
return lp;
|
2008-03-17 15:49:06 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make sure we don't report a SIGSTOP that we sent ourselves in
|
|
|
|
|
an attempt to stop an LWP. */
|
|
|
|
|
if (lp->signalled
|
|
|
|
|
&& WIFSTOPPED (status) && WSTOPSIG (status) == SIGSTOP)
|
|
|
|
|
{
|
|
|
|
|
lp->signalled = 0;
|
|
|
|
|
|
2015-03-24 19:31:51 +01:00
|
|
|
|
if (lp->last_resume_kind == resume_stop)
|
2011-09-09 21:27:50 +02:00
|
|
|
|
{
|
2015-03-24 19:31:51 +01:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LLW: resume_stop SIGSTOP caught for %s.\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* This is a delayed SIGSTOP. Filter out the event. */
|
2008-03-17 15:49:06 +01:00
|
|
|
|
|
2011-09-09 21:27:50 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
2015-03-24 19:31:51 +01:00
|
|
|
|
"LLW: %s %s, 0, 0 (discard delayed SIGSTOP)\n",
|
2011-09-09 21:27:50 +02:00
|
|
|
|
lp->step ?
|
|
|
|
|
"PTRACE_SINGLESTEP" : "PTRACE_CONT",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
2008-03-17 15:49:06 +01:00
|
|
|
|
|
2015-03-24 19:31:51 +01:00
|
|
|
|
linux_resume_one_lwp (lp, lp->step, GDB_SIGNAL_0);
|
2011-09-09 21:27:50 +02:00
|
|
|
|
gdb_assert (lp->resumed);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2008-03-17 15:49:06 +01:00
|
|
|
|
}
|
|
|
|
|
|
2008-07-27 23:12:40 +02:00
|
|
|
|
/* Make sure we don't report a SIGINT that we have already displayed
|
|
|
|
|
for another thread. */
|
|
|
|
|
if (lp->ignore_sigint
|
|
|
|
|
&& WIFSTOPPED (status) && WSTOPSIG (status) == SIGINT)
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LLW: Delayed SIGINT caught for %s.\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
|
|
|
|
|
/* This is a delayed SIGINT. */
|
|
|
|
|
lp->ignore_sigint = 0;
|
|
|
|
|
|
2015-01-07 20:41:06 +01:00
|
|
|
|
linux_resume_one_lwp (lp, lp->step, GDB_SIGNAL_0);
|
2008-07-27 23:12:40 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LLW: %s %s, 0, 0 (discard SIGINT)\n",
|
|
|
|
|
lp->step ?
|
|
|
|
|
"PTRACE_SINGLESTEP" : "PTRACE_CONT",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
gdb_assert (lp->resumed);
|
|
|
|
|
|
|
|
|
|
/* Discard the event. */
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
/* Don't report signals that GDB isn't interested in, such as
|
|
|
|
|
signals that are neither printed nor stopped upon. Stopping all
|
|
|
|
|
threads can be a bit time-consuming so if we want decent
|
|
|
|
|
performance with heavily multi-threaded programs, especially when
|
|
|
|
|
they're using a high frequency timer, we'd better avoid it if we
|
|
|
|
|
can. */
|
|
|
|
|
if (WIFSTOPPED (status))
|
|
|
|
|
{
|
|
|
|
|
enum gdb_signal signo = gdb_signal_from_host (WSTOPSIG (status));
|
|
|
|
|
|
Implement all-stop on top of a target running non-stop mode
This finally implements user-visible all-stop mode running with the
target_ops backend always in non-stop mode. This is a stepping stone
towards finer-grained control of threads, being able to do interesting
things like thread groups, associating groups with breakpoints, etc.
From the user's perspective, all-stop mode is really just a special
case of being able to stop and resume specific sets of threads, so it
makes sense to do this step first.
With this, even in all-stop, the target is no longer in charge of
stopping all threads before reporting an event to the core -- the core
takes care of it when it sees fit. For example, when "next"- or
"step"-ing, we can avoid stopping and resuming all threads at each
internal single-step, and instead only stop all threads when we're
about to present the stop to the user.
The implementation is almost straight forward, as the heavy lifting
has been done already in previous patches. Basically, we replace
checks for "set non-stop on/off" (the non_stop global), with calls to
a new target_is_non_stop_p function. In a few places, if "set
non-stop off", we stop all threads explicitly, and in a few other
places we resume all threads explicitly, making use of existing
methods that were added for teaching non-stop to step over breakpoints
without displaced stepping.
This adds a new "maint set target-non-stop on/off/auto" knob that
allows both disabling the feature if we find problems, and
force-enable it for development (useful when teaching a target about
this. The default is "auto", which means the feature is enabled if a
new target method says it should be enabled. The patch implements the
method in linux-nat.c, just for illustration, because it still returns
false. We'll need a few follow up fixes before turning it on by
default. This is a separate target method from indicating regular
non-stop support, because e.g., while e.g., native linux-nat.c is
close to regression free with all-stop-non-stop (with following
patches will fixing the remaining regressions), remote.c+gdbserver
will still need more fixing, even though it supports "set non-stop
on".
Tested on x86_64 Fedora 20, native, with and without "set displaced
off", and with and without "maint set target-non-stop on"; and also
against gdbserver.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* NEWS: Mention "maint set/show target-non-stop".
* breakpoint.c (update_global_location_list): Check
target_is_non_stop_p instead of non_stop.
* infcmd.c (attach_command_post_wait, attach_command): Likewise.
* infrun.c (show_can_use_displaced_stepping)
(can_use_displaced_stepping_p, start_step_over_inferior):
Likewise.
(internal_resume_ptid): New function.
(resume): Use it.
(proceed): Check target_is_non_stop_p instead of non_stop. If in
all-stop mode but the target is always in non-stop mode, start all
the other threads that are implicitly resumed too.
(for_each_just_stopped_thread, fetch_inferior_event)
(adjust_pc_after_break, stop_all_threads): Check
target_is_non_stop_p instead of non_stop.
(handle_inferior_event): Likewise. Handle detach-fork in all-stop
with the target always in non-stop mode.
(handle_signal_stop) <random signal>: Check target_is_non_stop_p
instead of non_stop.
(switch_back_to_stepped_thread): Check target_is_non_stop_p
instead of non_stop.
(keep_going_stepped_thread): Use internal_resume_ptid.
(stop_waiting): If in all-stop mode, and the target is in non-stop
mode, stop all threads.
(keep_going_pass): Likewise, when starting a new in-line step-over
sequence.
* linux-nat.c (get_pending_status, select_event_lwp)
(linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check
target_is_non_stop_p instead of non_stop.
(linux_nat_always_non_stop_p): New function.
(linux_nat_stop): Check target_is_non_stop_p instead of non_stop.
(linux_nat_add_target): Install linux_nat_always_non_stop_p.
* target-delegates.c: Regenerate.
* target.c (target_is_non_stop_p): New function.
(target_non_stop_enabled, target_non_stop_enabled_1): New globals.
(maint_set_target_non_stop_command)
(maint_show_target_non_stop_command): New functions.
(_initilize_target): Install "maint set/show target-non-stop"
commands.
* target.h (struct target_ops) <to_always_non_stop_p>: New field.
(target_non_stop_enabled): New declaration.
(target_is_non_stop_p): New declaration.
gdb/doc/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
target-non-stop".
2015-08-07 18:24:01 +02:00
|
|
|
|
if (!target_is_non_stop_p ())
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
{
|
|
|
|
|
/* Only do the below in all-stop, as we currently use SIGSTOP
|
|
|
|
|
to implement target_stop (see linux_nat_stop) in
|
|
|
|
|
non-stop. */
|
|
|
|
|
if (signo == GDB_SIGNAL_INT && signal_pass_state (signo) == 0)
|
|
|
|
|
{
|
|
|
|
|
/* If ^C/BREAK is typed at the tty/console, SIGINT gets
|
|
|
|
|
forwarded to the entire process group, that is, all LWPs
|
|
|
|
|
will receive it - unless they're using CLONE_THREAD to
|
|
|
|
|
share signals. Since we only want to report it once, we
|
|
|
|
|
mark it as ignored for all LWPs except this one. */
|
|
|
|
|
iterate_over_lwps (pid_to_ptid (ptid_get_pid (lp->ptid)),
|
|
|
|
|
set_ignore_sigint, NULL);
|
|
|
|
|
lp->ignore_sigint = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
maybe_clear_ignore_sigint (lp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* When using hardware single-step, we need to report every signal.
|
2015-02-12 20:55:08 +01:00
|
|
|
|
Otherwise, signals in pass_mask may be short-circuited
|
|
|
|
|
except signals that might be caused by a breakpoint. */
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
if (!lp->step
|
2015-02-12 20:55:08 +01:00
|
|
|
|
&& WSTOPSIG (status) && sigismember (&pass_mask, WSTOPSIG (status))
|
|
|
|
|
&& !linux_wstatus_maybe_breakpoint (status))
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
{
|
|
|
|
|
linux_resume_one_lwp (lp, lp->step, signo);
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LLW: %s %s, %s (preempt 'handle')\n",
|
|
|
|
|
lp->step ?
|
|
|
|
|
"PTRACE_SINGLESTEP" : "PTRACE_CONT",
|
|
|
|
|
target_pid_to_str (lp->ptid),
|
|
|
|
|
(signo != GDB_SIGNAL_0
|
|
|
|
|
? strsignal (gdb_signal_to_host (signo))
|
|
|
|
|
: "0"));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-17 15:49:06 +01:00
|
|
|
|
/* An interesting event. */
|
|
|
|
|
gdb_assert (lp);
|
2009-10-02 18:51:04 +02:00
|
|
|
|
lp->status = status;
|
2016-02-24 23:52:06 +01:00
|
|
|
|
save_stop_reason (lp);
|
2008-03-17 15:49:06 +01:00
|
|
|
|
return lp;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-28 20:30:00 +02:00
|
|
|
|
/* Detect zombie thread group leaders, and "exit" them. We can't reap
|
|
|
|
|
their exits until all other threads in the group have exited. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
check_zombie_leaders (void)
|
|
|
|
|
{
|
|
|
|
|
struct inferior *inf;
|
|
|
|
|
|
|
|
|
|
ALL_INFERIORS (inf)
|
|
|
|
|
{
|
|
|
|
|
struct lwp_info *leader_lp;
|
|
|
|
|
|
|
|
|
|
if (inf->pid == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
leader_lp = find_lwp_pid (pid_to_ptid (inf->pid));
|
|
|
|
|
if (leader_lp != NULL
|
|
|
|
|
/* Check if there are other threads in the group, as we may
|
|
|
|
|
have raced with the inferior simply exiting. */
|
|
|
|
|
&& num_lwps (inf->pid) > 1
|
gdb/
* Makefile.in (linux-ptrace.o): New.
* common/linux-procfs.c (linux_proc_pid_is_zombie): New,
from linux-nat.c.
* common/linux-procfs.h (linux_proc_pid_is_zombie): New declaration.
* common/linux-ptrace.c: New file.
* config/alpha/alpha-linux.mh (NATDEPFILES): Add linux-ptrace.o.
* config/arm/linux.mh: Likewise.
* config/i386/linux.mh: Likewise.
* config/i386/linux64.mh: Likewise.
* config/ia64/linux.mh: Likewise.
* config/m32r/linux.mh: Likewise.
* config/m68k/linux.mh: Likewise.
* config/mips/linux.mh: Likewise.
* config/pa/linux.mh: Likewise.
* config/powerpc/linux.mh: Likewise.
* config/powerpc/ppc64-linux.mh: Likewise.
* config/powerpc/spu-linux.mh: Likewise.
* config/s390/s390.mh: Likewise.
* config/sparc/linux.mh: Likewise.
* config/sparc/linux64.mh: Likewise.
* config/xtensa/linux.mh: Likewise.
* linux-nat.c (linux_lwp_is_zombie): Remove, move it to
common/linux-procfs.c.
(wait_lwp): Rename linux_lwp_is_zombie to linux_proc_pid_is_zombie.
gdb/gdbserver/
* Makefile.in (linux-ptrace.o): New.
* configure.srv (arm*-*-linux*, bfin-*-*linux*, crisv32-*-linux*)
(cris-*-linux*, i[34567]86-*-linux*, ia64-*-linux*, m32r*-*-linux*)
(m68*-*-linux*, m68*-*-uclinux*, mips*-*-linux*, powerpc*-*-linux*)
(s390*-*-linux*, sh*-*-linux*, sparc*-*-linux*, tic6x-*-uclinux)
(x86_64-*-linux*, xtensa*-*-linux*): Add linux-ptrace.o to SRV_TGTOBJ
of these targets.
* linux-low.c (linux_attach_lwp_1): Remove redundent else clause.
2012-03-13 16:00:37 +01:00
|
|
|
|
&& linux_proc_pid_is_zombie (inf->pid))
|
2011-10-28 20:30:00 +02:00
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"CZL: Thread group leader %d zombie "
|
|
|
|
|
"(it exited, or another thread execd).\n",
|
|
|
|
|
inf->pid);
|
|
|
|
|
|
|
|
|
|
/* A leader zombie can mean one of two things:
|
|
|
|
|
|
|
|
|
|
- It exited, and there's an exit status pending
|
|
|
|
|
available, or only the leader exited (not the whole
|
|
|
|
|
program). In the latter case, we can't waitpid the
|
|
|
|
|
leader's exit status until all other threads are gone.
|
|
|
|
|
|
|
|
|
|
- There are 3 or more threads in the group, and a thread
|
2015-12-17 15:20:51 +01:00
|
|
|
|
other than the leader exec'd. See comments on exec
|
|
|
|
|
events at the top of the file. We could try
|
2011-10-28 20:30:00 +02:00
|
|
|
|
distinguishing the exit and exec cases, by waiting once
|
|
|
|
|
more, and seeing if something comes out, but it doesn't
|
|
|
|
|
sound useful. The previous leader _does_ go away, and
|
|
|
|
|
we'll re-add the new one once we see the exec event
|
|
|
|
|
(which is just the same as what would happen if the
|
|
|
|
|
previous leader did exit voluntarily before some other
|
|
|
|
|
thread execs). */
|
|
|
|
|
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"CZL: Thread group leader %d vanished.\n",
|
|
|
|
|
inf->pid);
|
|
|
|
|
exit_lwp (leader_lp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-24 15:47:56 +02:00
|
|
|
|
/* Convenience function that is called when the kernel reports an exit
|
|
|
|
|
event. This decides whether to report the event to GDB as a
|
|
|
|
|
process exit event, a thread exit event, or to suppress the
|
|
|
|
|
event. */
|
|
|
|
|
|
|
|
|
|
static ptid_t
|
|
|
|
|
filter_exit_event (struct lwp_info *event_child,
|
|
|
|
|
struct target_waitstatus *ourstatus)
|
|
|
|
|
{
|
|
|
|
|
ptid_t ptid = event_child->ptid;
|
|
|
|
|
|
|
|
|
|
if (num_lwps (ptid_get_pid (ptid)) > 1)
|
|
|
|
|
{
|
|
|
|
|
if (report_thread_events)
|
|
|
|
|
ourstatus->kind = TARGET_WAITKIND_THREAD_EXITED;
|
|
|
|
|
else
|
|
|
|
|
ourstatus->kind = TARGET_WAITKIND_IGNORE;
|
|
|
|
|
|
|
|
|
|
exit_lwp (event_child);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ptid;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
static ptid_t
|
2009-05-11 14:08:03 +02:00
|
|
|
|
linux_nat_wait_1 (struct target_ops *ops,
|
2009-05-21 17:48:42 +02:00
|
|
|
|
ptid_t ptid, struct target_waitstatus *ourstatus,
|
|
|
|
|
int target_options)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
2014-10-19 06:24:47 +02:00
|
|
|
|
sigset_t prev_mask;
|
2011-10-10 15:23:53 +02:00
|
|
|
|
enum resume_kind last_resume_kind;
|
2011-10-12 14:11:26 +02:00
|
|
|
|
struct lwp_info *lp;
|
|
|
|
|
int status;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
2011-05-13 19:31:07 +02:00
|
|
|
|
if (debug_linux_nat)
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "LLW: enter\n");
|
|
|
|
|
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
/* The first time we get here after starting a new inferior, we may
|
|
|
|
|
not have added it to the LWP list yet - this is the earliest
|
|
|
|
|
moment at which we know its PID. */
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
if (ptid_is_pid (inferior_ptid))
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
{
|
2008-09-08 23:22:49 +02:00
|
|
|
|
/* Upgrade the main thread's ptid. */
|
|
|
|
|
thread_change_ptid (inferior_ptid,
|
2013-09-30 13:50:12 +02:00
|
|
|
|
ptid_build (ptid_get_pid (inferior_ptid),
|
|
|
|
|
ptid_get_pid (inferior_ptid), 0));
|
2008-09-08 23:22:49 +02:00
|
|
|
|
|
[native x86 GNU/Linux] Access debug register mirror from the corresponding process.
While reviewing the native AArch64 patch, I noticed a problem:
On 02/06/2013 08:46 PM, Pedro Alves wrote:
>
>> > +static void
>> > +aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
>> > +{
>> > + struct arch_lwp_info *info = lwp->arch_private;
>> > +
>> > + /* NULL means this is the main thread still going through the shell,
>> > + or, no watchpoint has been set yet. In that case, there's
>> > + nothing to do. */
>> > + if (info == NULL)
>> > + return;
>> > +
>> > + if (DR_HAS_CHANGED (info->dr_changed_bp)
>> > + || DR_HAS_CHANGED (info->dr_changed_wp))
>> > + {
>> > + int tid = GET_LWP (lwp->ptid);
>> > + struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
> Hmm. This is always fetching the debug_reg_state of
> the current inferior, but may not be the inferior of lwp.
> I see the same bug on x86. Sorry about that. I'll fix it.
A natural fix would be to make xxx_get_debug_reg_state take an
inferior argument, but that doesn't work because of the case where we
detach breakpoints/watchpoints from the child fork, at a time there's
no inferior for the child fork at all. We do a nasty hack in
i386_inferior_data_get, but that relies on all callers pointing the
current inferior to the correct inferior, which isn't actually being
done by all callers, and I don't think we want to enforce that -- deep
in the bowls of linux-nat.c, there are many cases we resume lwps
behind the scenes, and it's be better to not have that code rely on
global state (as it doesn't today).
The fix is to decouple the watchpoints code from inferiors, making it
track target processes instead. This way, we can freely keep track of
the watchpoint mirrors for these processes behind the core's back.
Checkpoints also play dirty tricks with swapping the process behind
the inferior, so they get special treatment too in the patch (which
just amounts to calling a new hook). Instead of the old hack in
i386_inferior_data_get, where we returned a copy of the current
inferior's debug registers mirror, as soon as we detect a fork in the
target, we copy the debug register mirror from the parent to the child
process.
I don't have an old kernel handy to test, but I stepped through gdb doing
the watchpoint removal in the fork child in the watchpoint-fork test
seeing that the debug registers end up cleared in the child.
I didn't find the need for linux_nat_iterate_watchpoint_lwps. If
we use plain iterate_over_lwps instead, what happens is that
when removing watchpoints, that iterate_over_lwps doesn't actually
iterate over anything, since the fork child is not added to the
lwp list until later, at detach time, in linux_child_follow_fork.
And if we don't iterate over that lwp, we don't mark its debug
registers as needing update. But linux_child_follow_fork takes
care of doing that explicitly:
child_lp = add_lwp (inferior_ptid);
child_lp->stopped = 1;
child_lp->last_resume_kind = resume_stop;
make_cleanup (delete_lwp_cleanup, child_lp);
/* CHILD_LP has new PID, therefore linux_nat_new_thread is not called for it.
See i386_inferior_data_get for the Linux kernel specifics.
Ensure linux_nat_prepare_to_resume will reset the hardware debug
registers. It is done by the linux_nat_new_thread call, which is
being skipped in add_lwp above for the first lwp of a pid. */
gdb_assert (num_lwps (GET_PID (child_lp->ptid)) == 1);
if (linux_nat_new_thread != NULL)
linux_nat_new_thread (child_lp);
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (child_lp);
ptrace (PTRACE_DETACH, child_pid, 0, 0);
so unless I'm missing something (quite possible) it ends up all
the same. But, the !detach-on-fork, and the "follow-fork child" paths
should also call linux_nat_new_thread, and they don't presently. It
seems to me in those cases we're not clearing debug regs correctly
when that's needed. Instead of copying that bit that works around
add_lwp bypassing the linux_nat_new_thread call, I thought it'd
be better to add an add_initial_lwp call to be used in the case we
really need to bypass linux_nat_new_thread, and make
add_lwp always call linux_nat_new_thread.
i386_cleanup_dregs is rewritten to forget about the current process
debug mirrors, which takes cares of other i386 ports. Only a couple
of extra tweaks here and there were needed, as some targets wheren't
actually calling i386_cleanup_dregs.
Tested on Fedora 17 x86_64 -m64/-m32.
GDBserver already fetches the i386_debug_reg_state from the right
process, and, it doesn't handle forks at all, so no fix is needed over
there.
gdb/
2013-02-13 Pedro Alves <palves@redhat.com>
* amd64-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(amd64_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(amd64_linux_new_fork): New function.
(_initialize_amd64_linux_nat): Install amd64_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(i386_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(i386_linux_new_fork): New function.
(_initialize_i386_linux_nat): Install i386_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-nat.c (i386_init_dregs): Delete.
(i386_inferior_data, struct i386_inferior_data):
Delete.
(struct i386_process_info): New.
(i386_process_list): New global.
(i386_find_process_pid, i386_add_process, i386_process_info_get):
New functions.
(i386_inferior_data_get): Delete.
(i386_process_info_get): New function.
(i386_debug_reg_state): New parameter 'pid'. Reimplement.
(i386_forget_process): New function.
(i386_cleanup_dregs): Rewrite.
(i386_update_inferior_debug_regs, i386_insert_watchpoint)
(i386_remove_watchpoint, i386_region_ok_for_watchpoint)
(i386_stopped_data_address, i386_insert_hw_breakpoint)
(i386_remove_hw_breakpoint): Adjust to pass the current process id
to i386_debug_reg_state.
(i386_use_watchpoints): Don't register inferior data.
* i386-nat.h (i386_debug_reg_state): Add new 'pid' parameter, and
adjust comment.
(i386_forget_process): Declare.
* linux-fork.c (delete_fork): Call linux_nat_forget_process.
* linux-nat.c (linux_nat_new_fork, linux_nat_forget_process_hook):
New static globals.
(linux_child_follow_fork): Don't call linux_nat_new_thread here.
(add_initial_lwp): New, factored out from ...
(add_lwp): ... this. Don't check the number of lwps before
calling linux_nat_new_thread.
(linux_nat_iterate_watchpoint_lwps): Delete.
(linux_nat_attach): Use add_initial_lwp instead of add_lwp.
(linux_handle_extended_wait): Call the linux_nat_new_fork hook on
forks and vforks.
(linux_nat_wait_1): Use add_initial_lwp instead of add_lwp for the
initial lwp.
(linux_nat_kill, linux_nat_mourn_inferior): Call
linux_nat_forget_process.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New functions.
* linux-nat.h (linux_nat_iterate_watchpoint_lwps_ftype): Delete
type.
(linux_nat_iterate_watchpoint_lwps): Delete declaration.
(linux_nat_new_fork_ftype, linux_nat_forget_process_ftype): New
types.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New declarations.
* amd64fbsd-nat.c (super_mourn_inferior): New global.
(amd64fbsd_mourn_inferior): New function.
(_initialize_amd64fbsd_nat): Override to_mourn_inferior.
* windows-nat.c (windows_detach): Call i386_cleanup_dregs.
2013-02-13 15:59:49 +01:00
|
|
|
|
lp = add_initial_lwp (inferior_ptid);
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
lp->resumed = 1;
|
|
|
|
|
}
|
|
|
|
|
|
linux-nat.c: no need to block child signals so aggressively.
In http://sourceware.org/ml/gdb-patches/2013-08/msg00174.html , the
issue of child signal handling around ptrace option support discovery
being different between GDB and GDBserver came up.
I recalled adding these block_child_signals calls, and the "We don't
want those ptrace calls to be interrupted" comment, but not exactly
why. So I looked into it. My first guess is that I got confused.
The patch that added this
<http://sourceware.org/ml/gdb-patches/2009-04/msg00125.html> rewrote
the linux native async support completely, and the old async support
code had the SIGCHLD handler itself do waitpid, so in places that we'd
want a blocking waitpid, we'd have to have the signal handler blocked.
That was probably the mindset I had at the time. Anyway, whatever the
case, looks like I was wrong on the need for this blocking.
Given GDBserver doesn't block like this, I investigated why this is
currently needed on GDB but not on GDBserver.
I removed the block_child_signals (and restore) calls, and hacked
linux-nat.c to call linux_test_for_tracefork in a loop, like:
@@ -534,7 +534,10 @@ static int
linux_supports_tracefork (int pid)
{
if (linux_supports_tracefork_flag == -1)
- linux_test_for_tracefork (pid);
+ {
+ while (1)
+ linux_test_for_tracefork (pid);
+ }
return linux_supports_tracefork_flag;
}
Running the resulting GDB, I then saw bad things happening.
Specifically, I'd end up with a bunch of zombies, and eventually, the
machine would refuse to spawn new processes, claming insufficient
resources.
The issue is that linux_test_for_tracefork test forks, and has the
child fork again. If we don't block SIGCHLD on entry to the function,
the children will inherit SIGCHLD's action/disposition (meaning,
SIGCHLD will be unblocked in the child). When the first child forks
again a second child, and that child exits, the first child gets a
SIGCHLD. Now, when we try to wrap up for the whole options test, we
kill the first child, and collect the waitstatus. Here, when SIGCHLD
isn't blocked, GDB will first see the child reporting a stop with
SIGCHLD. gdbserver's ptrace options test does a PTRACE_KILL loop at
the end, which catches the SIGCHLD, and retries the kill. The GDB
version did not do that. So the GDB version would proceed, leaving
the child zombie (until GDB exists), as nothing collected its final
waitstatus.
So this patch makes the GDB version of linux_test_for_tracefork do the
exact same as the GDBserver version, removes all this unnecessary
blocking throughout, and adds a couple comments at places that do need
it -- namely: places where we'll use sleep with sigsuspend; and
linux_async_pipe, as that destroys the pipe the signal handler
touches.
Tested on x86_64 Fedora 17, sync and async.
gdb/
2013-08-19 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_test_for_tracefork)
(linux_test_for_tracesysgood, linux_child_follow_fork)
(lin_lwp_attach_lwp, linux_nat_resume): Don't block child signals.
(linux_nat_wait_1): Extend comment.
(linux_async_pipe): Add comment.
2013-08-19 15:44:41 +02:00
|
|
|
|
/* Make sure SIGCHLD is blocked until the sigsuspend below. */
|
2009-05-11 14:08:03 +02:00
|
|
|
|
block_child_signals (&prev_mask);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
/* First check if there is a LWP with a wait status pending. */
|
2015-01-07 20:41:06 +01:00
|
|
|
|
lp = iterate_over_lwps (ptid, status_callback, NULL);
|
|
|
|
|
if (lp != NULL)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LLW: Using pending wait status %s for %s.\n",
|
2009-10-02 18:51:04 +02:00
|
|
|
|
status_to_str (lp->status),
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
}
|
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
/* But if we don't find a pending event, we'll have to wait. Always
|
|
|
|
|
pull all events out of the kernel. We'll randomly select an
|
|
|
|
|
event LWP out of all that have events, to prevent starvation. */
|
2009-05-11 14:08:03 +02:00
|
|
|
|
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
while (lp == NULL)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
|
|
|
|
pid_t lwpid;
|
|
|
|
|
|
2011-10-28 20:30:00 +02:00
|
|
|
|
/* Always use -1 and WNOHANG, due to couple of a kernel/ptrace
|
|
|
|
|
quirks:
|
|
|
|
|
|
|
|
|
|
- If the thread group leader exits while other threads in the
|
|
|
|
|
thread group still exist, waitpid(TGID, ...) hangs. That
|
|
|
|
|
waitpid won't return an exit status until the other threads
|
|
|
|
|
in the group are reapped.
|
|
|
|
|
|
|
|
|
|
- When a non-leader thread execs, that thread just vanishes
|
|
|
|
|
without reporting an exit (so we'd hang if we waited for it
|
|
|
|
|
explicitly in that case). The exec event is reported to
|
|
|
|
|
the TGID pid. */
|
|
|
|
|
|
|
|
|
|
errno = 0;
|
2015-12-17 15:20:51 +01:00
|
|
|
|
lwpid = my_waitpid (-1, &status, __WALL | WNOHANG);
|
2011-10-28 20:30:00 +02:00
|
|
|
|
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LNW: waitpid(-1, ...) returned %d, %s\n",
|
|
|
|
|
lwpid, errno ? safe_strerror (errno) : "ERRNO-OK");
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
if (lwpid > 0)
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
{
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LLW: waitpid %ld received %s\n",
|
|
|
|
|
(long) lwpid, status_to_str (status));
|
|
|
|
|
}
|
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
linux_nat_filter_event (lwpid, status);
|
2011-10-28 20:30:00 +02:00
|
|
|
|
/* Retry until nothing comes out of waitpid. A single
|
|
|
|
|
SIGCHLD can indicate more than one child stopped. */
|
|
|
|
|
continue;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-04 19:13:28 +01:00
|
|
|
|
/* Now that we've pulled all events out of the kernel, resume
|
|
|
|
|
LWPs that don't have an interesting event to report. */
|
|
|
|
|
iterate_over_lwps (minus_one_ptid,
|
|
|
|
|
resume_stopped_resumed_lwps, &minus_one_ptid);
|
|
|
|
|
|
|
|
|
|
/* ... and find an LWP with a status to report to the core, if
|
|
|
|
|
any. */
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
lp = iterate_over_lwps (ptid, status_callback, NULL);
|
|
|
|
|
if (lp != NULL)
|
|
|
|
|
break;
|
|
|
|
|
|
2011-10-28 20:30:00 +02:00
|
|
|
|
/* Check for zombie thread group leaders. Those can't be reaped
|
|
|
|
|
until all other threads in the thread group are. */
|
|
|
|
|
check_zombie_leaders ();
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
2011-10-28 20:30:00 +02:00
|
|
|
|
/* If there are no resumed children left, bail. We'd be stuck
|
|
|
|
|
forever in the sigsuspend call below otherwise. */
|
|
|
|
|
if (iterate_over_lwps (ptid, resumed_callback, NULL) == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "LLW: exit (no resumed LWP)\n");
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
|
2011-10-28 20:30:00 +02:00
|
|
|
|
ourstatus->kind = TARGET_WAITKIND_NO_RESUMED;
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
|
2011-10-28 20:30:00 +02:00
|
|
|
|
restore_child_signals_mask (&prev_mask);
|
|
|
|
|
return minus_one_ptid;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
2009-10-09 03:57:12 +02:00
|
|
|
|
|
2011-10-28 20:30:00 +02:00
|
|
|
|
/* No interesting event to report to the core. */
|
|
|
|
|
|
|
|
|
|
if (target_options & TARGET_WNOHANG)
|
|
|
|
|
{
|
2011-05-13 19:31:07 +02:00
|
|
|
|
if (debug_linux_nat)
|
2009-10-09 03:57:12 +02:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "LLW: exit (ignore)\n");
|
|
|
|
|
|
2011-10-28 20:30:00 +02:00
|
|
|
|
ourstatus->kind = TARGET_WAITKIND_IGNORE;
|
2009-10-09 03:57:12 +02:00
|
|
|
|
restore_child_signals_mask (&prev_mask);
|
|
|
|
|
return minus_one_ptid;
|
|
|
|
|
}
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
/* We shouldn't end up here unless we want to try again. */
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
gdb_assert (lp == NULL);
|
2011-10-28 20:30:00 +02:00
|
|
|
|
|
|
|
|
|
/* Block until we get an event reported with SIGCHLD. */
|
2018-01-30 15:23:51 +01:00
|
|
|
|
wait_for_signal ();
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gdb_assert (lp);
|
|
|
|
|
|
2009-10-02 18:51:04 +02:00
|
|
|
|
status = lp->status;
|
|
|
|
|
lp->status = 0;
|
|
|
|
|
|
Implement all-stop on top of a target running non-stop mode
This finally implements user-visible all-stop mode running with the
target_ops backend always in non-stop mode. This is a stepping stone
towards finer-grained control of threads, being able to do interesting
things like thread groups, associating groups with breakpoints, etc.
From the user's perspective, all-stop mode is really just a special
case of being able to stop and resume specific sets of threads, so it
makes sense to do this step first.
With this, even in all-stop, the target is no longer in charge of
stopping all threads before reporting an event to the core -- the core
takes care of it when it sees fit. For example, when "next"- or
"step"-ing, we can avoid stopping and resuming all threads at each
internal single-step, and instead only stop all threads when we're
about to present the stop to the user.
The implementation is almost straight forward, as the heavy lifting
has been done already in previous patches. Basically, we replace
checks for "set non-stop on/off" (the non_stop global), with calls to
a new target_is_non_stop_p function. In a few places, if "set
non-stop off", we stop all threads explicitly, and in a few other
places we resume all threads explicitly, making use of existing
methods that were added for teaching non-stop to step over breakpoints
without displaced stepping.
This adds a new "maint set target-non-stop on/off/auto" knob that
allows both disabling the feature if we find problems, and
force-enable it for development (useful when teaching a target about
this. The default is "auto", which means the feature is enabled if a
new target method says it should be enabled. The patch implements the
method in linux-nat.c, just for illustration, because it still returns
false. We'll need a few follow up fixes before turning it on by
default. This is a separate target method from indicating regular
non-stop support, because e.g., while e.g., native linux-nat.c is
close to regression free with all-stop-non-stop (with following
patches will fixing the remaining regressions), remote.c+gdbserver
will still need more fixing, even though it supports "set non-stop
on".
Tested on x86_64 Fedora 20, native, with and without "set displaced
off", and with and without "maint set target-non-stop on"; and also
against gdbserver.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* NEWS: Mention "maint set/show target-non-stop".
* breakpoint.c (update_global_location_list): Check
target_is_non_stop_p instead of non_stop.
* infcmd.c (attach_command_post_wait, attach_command): Likewise.
* infrun.c (show_can_use_displaced_stepping)
(can_use_displaced_stepping_p, start_step_over_inferior):
Likewise.
(internal_resume_ptid): New function.
(resume): Use it.
(proceed): Check target_is_non_stop_p instead of non_stop. If in
all-stop mode but the target is always in non-stop mode, start all
the other threads that are implicitly resumed too.
(for_each_just_stopped_thread, fetch_inferior_event)
(adjust_pc_after_break, stop_all_threads): Check
target_is_non_stop_p instead of non_stop.
(handle_inferior_event): Likewise. Handle detach-fork in all-stop
with the target always in non-stop mode.
(handle_signal_stop) <random signal>: Check target_is_non_stop_p
instead of non_stop.
(switch_back_to_stepped_thread): Check target_is_non_stop_p
instead of non_stop.
(keep_going_stepped_thread): Use internal_resume_ptid.
(stop_waiting): If in all-stop mode, and the target is in non-stop
mode, stop all threads.
(keep_going_pass): Likewise, when starting a new in-line step-over
sequence.
* linux-nat.c (get_pending_status, select_event_lwp)
(linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check
target_is_non_stop_p instead of non_stop.
(linux_nat_always_non_stop_p): New function.
(linux_nat_stop): Check target_is_non_stop_p instead of non_stop.
(linux_nat_add_target): Install linux_nat_always_non_stop_p.
* target-delegates.c: Regenerate.
* target.c (target_is_non_stop_p): New function.
(target_non_stop_enabled, target_non_stop_enabled_1): New globals.
(maint_set_target_non_stop_command)
(maint_show_target_non_stop_command): New functions.
(_initilize_target): Install "maint set/show target-non-stop"
commands.
* target.h (struct target_ops) <to_always_non_stop_p>: New field.
(target_non_stop_enabled): New declaration.
(target_is_non_stop_p): New declaration.
gdb/doc/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
target-non-stop".
2015-08-07 18:24:01 +02:00
|
|
|
|
if (!target_is_non_stop_p ())
|
2008-07-11 00:58:37 +02:00
|
|
|
|
{
|
|
|
|
|
/* Now stop all other LWP's ... */
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
iterate_over_lwps (minus_one_ptid, stop_callback, NULL);
|
2008-07-11 00:58:37 +02:00
|
|
|
|
|
|
|
|
|
/* ... and wait until all of them have reported back that
|
|
|
|
|
they're no longer running. */
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
iterate_over_lwps (minus_one_ptid, stop_wait_callback, NULL);
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If we're not waiting for a specific LWP, choose an event LWP from
|
|
|
|
|
among those that have had events. Giving equal priority to all
|
|
|
|
|
LWPs that have had events helps prevent starvation. */
|
|
|
|
|
if (ptid_equal (ptid, minus_one_ptid) || ptid_is_pid (ptid))
|
|
|
|
|
select_event_lwp (ptid, &lp, &status);
|
|
|
|
|
|
|
|
|
|
gdb_assert (lp != NULL);
|
|
|
|
|
|
|
|
|
|
/* Now that we've selected our final event LWP, un-adjust its PC if
|
2015-03-04 21:41:16 +01:00
|
|
|
|
it was a software breakpoint, and we can't reliably support the
|
|
|
|
|
"stopped by software breakpoint" stop reason. */
|
|
|
|
|
if (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
|
|
|
|
|
&& !USE_SIGTRAP_SIGINFO)
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
{
|
|
|
|
|
struct regcache *regcache = get_thread_regcache (lp->ptid);
|
2017-10-25 17:37:03 +02:00
|
|
|
|
struct gdbarch *gdbarch = regcache->arch ();
|
2015-03-04 21:41:17 +01:00
|
|
|
|
int decr_pc = gdbarch_decr_pc_after_break (gdbarch);
|
2008-07-11 00:58:37 +02:00
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
if (decr_pc != 0)
|
|
|
|
|
{
|
|
|
|
|
CORE_ADDR pc;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
pc = regcache_read_pc (regcache);
|
|
|
|
|
regcache_write_pc (regcache, pc + decr_pc);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-08 16:44:09 +01:00
|
|
|
|
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
/* We'll need this to determine whether to report a SIGSTOP as
|
|
|
|
|
GDB_SIGNAL_0. Need to take a copy because resume_clear_callback
|
|
|
|
|
clears it. */
|
|
|
|
|
last_resume_kind = lp->last_resume_kind;
|
2011-10-10 15:23:53 +02:00
|
|
|
|
|
Implement all-stop on top of a target running non-stop mode
This finally implements user-visible all-stop mode running with the
target_ops backend always in non-stop mode. This is a stepping stone
towards finer-grained control of threads, being able to do interesting
things like thread groups, associating groups with breakpoints, etc.
From the user's perspective, all-stop mode is really just a special
case of being able to stop and resume specific sets of threads, so it
makes sense to do this step first.
With this, even in all-stop, the target is no longer in charge of
stopping all threads before reporting an event to the core -- the core
takes care of it when it sees fit. For example, when "next"- or
"step"-ing, we can avoid stopping and resuming all threads at each
internal single-step, and instead only stop all threads when we're
about to present the stop to the user.
The implementation is almost straight forward, as the heavy lifting
has been done already in previous patches. Basically, we replace
checks for "set non-stop on/off" (the non_stop global), with calls to
a new target_is_non_stop_p function. In a few places, if "set
non-stop off", we stop all threads explicitly, and in a few other
places we resume all threads explicitly, making use of existing
methods that were added for teaching non-stop to step over breakpoints
without displaced stepping.
This adds a new "maint set target-non-stop on/off/auto" knob that
allows both disabling the feature if we find problems, and
force-enable it for development (useful when teaching a target about
this. The default is "auto", which means the feature is enabled if a
new target method says it should be enabled. The patch implements the
method in linux-nat.c, just for illustration, because it still returns
false. We'll need a few follow up fixes before turning it on by
default. This is a separate target method from indicating regular
non-stop support, because e.g., while e.g., native linux-nat.c is
close to regression free with all-stop-non-stop (with following
patches will fixing the remaining regressions), remote.c+gdbserver
will still need more fixing, even though it supports "set non-stop
on".
Tested on x86_64 Fedora 20, native, with and without "set displaced
off", and with and without "maint set target-non-stop on"; and also
against gdbserver.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* NEWS: Mention "maint set/show target-non-stop".
* breakpoint.c (update_global_location_list): Check
target_is_non_stop_p instead of non_stop.
* infcmd.c (attach_command_post_wait, attach_command): Likewise.
* infrun.c (show_can_use_displaced_stepping)
(can_use_displaced_stepping_p, start_step_over_inferior):
Likewise.
(internal_resume_ptid): New function.
(resume): Use it.
(proceed): Check target_is_non_stop_p instead of non_stop. If in
all-stop mode but the target is always in non-stop mode, start all
the other threads that are implicitly resumed too.
(for_each_just_stopped_thread, fetch_inferior_event)
(adjust_pc_after_break, stop_all_threads): Check
target_is_non_stop_p instead of non_stop.
(handle_inferior_event): Likewise. Handle detach-fork in all-stop
with the target always in non-stop mode.
(handle_signal_stop) <random signal>: Check target_is_non_stop_p
instead of non_stop.
(switch_back_to_stepped_thread): Check target_is_non_stop_p
instead of non_stop.
(keep_going_stepped_thread): Use internal_resume_ptid.
(stop_waiting): If in all-stop mode, and the target is in non-stop
mode, stop all threads.
(keep_going_pass): Likewise, when starting a new in-line step-over
sequence.
* linux-nat.c (get_pending_status, select_event_lwp)
(linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check
target_is_non_stop_p instead of non_stop.
(linux_nat_always_non_stop_p): New function.
(linux_nat_stop): Check target_is_non_stop_p instead of non_stop.
(linux_nat_add_target): Install linux_nat_always_non_stop_p.
* target-delegates.c: Regenerate.
* target.c (target_is_non_stop_p): New function.
(target_non_stop_enabled, target_non_stop_enabled_1): New globals.
(maint_set_target_non_stop_command)
(maint_show_target_non_stop_command): New functions.
(_initilize_target): Install "maint set/show target-non-stop"
commands.
* target.h (struct target_ops) <to_always_non_stop_p>: New field.
(target_non_stop_enabled): New declaration.
(target_is_non_stop_p): New declaration.
gdb/doc/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
target-non-stop".
2015-08-07 18:24:01 +02:00
|
|
|
|
if (!target_is_non_stop_p ())
|
linux-nat.c: better starvation avoidance, handle non-stop mode too
Running the testsuite with a series that reimplements user-visible
all-stop behavior on top of a target running in non-stop mode revealed
problems related to event starvation avoidance.
For example, I see
gdb.threads/signal-while-stepping-over-bp-other-thread.exp failing.
What happens is that GDB core never gets to see the signal event. It
ends up processing the events for the same threads over an over,
because Linux's waitpid(-1, ...) returns that first task in the task
list that has an event, starving threads on the tail of the task list.
So I wrote a non-stop mode test originally inspired by
signal-while-stepping-over-bp-other-thread.exp, to stress this
independently of all-stop on top of non-stop. Fixing it required the
changes described below. The test will be added in a following
commit.
1) linux-nat.c has code in place that picks an event LWP at random out
of all that have had events. This is because on the kernel side,
"waitpid(-1, ...)" just walks the task list linearly looking for the
first that had an event. But, this code is currently only used in
all-stop mode. So with a multi-threaded program that has multiple
events triggering debug events in parallel, GDB ends up starving some
threads.
To make the event randomization work in non-stop mode too, the patch
makes us pull out all the already pending events on the kernel side,
with waitpid, before deciding which LWP to report to the core.
There's some code in linux_wait that takes care of leaving events
pending if they were for LWPs the caller is not interested in. The
patch moves that to linux_nat_filter_event, so that we only have one
place that leaves events pending. With that in place, conceptually,
the flow is simpler and more normalized:
#1 - walk the LWP list looking for an LWP with a pending event to report.
#2 - if no pending event, pull events out of the kernel, and store
them in the LWP structures as pending.
#3- goto #1.
2) Then, currently the event randomization code only considers SIGTRAP
(or trap-like) events. That means that if e.g., have have multiple
threads stepping in parallel that hit a breakpoint that needs stepping
over, and one gets a signal, the signal may end up never getting
processed, because GDB will always be giving priority to the SIGTRAPs.
The patch fixes this by making the randomization code consider all
kinds of pending events.
3) If multiple threads hit a breakpoint, we report one of those, and
"cancel" the others. Cancelling means decrementing the PC, and
discarding the event. If the next time the LWP is resumed the
breakpoint is still installed, the LWP should hit it again, and we'll
report the hit then. The problem I found is that this delays threads
from advancing too much, with the kernel potentially ending up
scheduling the same threads over and over, and others not advancing.
So the patch switches away from cancelling the breakpoints, and
instead remembering that the LWP had stopped for a breakpoint. If on
resume the breakpoint is still installed, we report it. If it's no
longer installed, we discard the pending event then. This is actually
how GDBserver used to handle this before d50171e4 (Teach linux
gdbserver to step-over-breakpoints), but with the difference that back
then we'd delay adjusting the PC until resuming, which made it so that
"info threads" could wrongly see threads with unadjusted PCs.
gdb/
2015-01-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (hardware_breakpoint_inserted_here_p): New
function.
* breakpoint.h (hardware_breakpoint_inserted_here_p): New
declaration.
* linux-nat.c (linux_nat_status_is_event): Move higher up in file.
(linux_resume_one_lwp): Store the thread's PC. Adjust to clear
stop_reason.
(check_stopped_by_watchpoint): New function.
(save_sigtrap): Reimplement.
(linux_nat_stopped_by_watchpoint): Adjust.
(linux_nat_lp_status_is_event): Delete.
(stop_wait_callback): Only call save_sigtrap after storing the
pending status.
(status_callback): If the thread had been stopped for a breakpoint
that has since been removed, discard the event and resume the LWP.
(count_events_callback, select_event_lwp_callback): Use
lwp_status_pending_p instead of linux_nat_lp_status_is_event.
(cancel_breakpoint): Rename to ...
(check_stopped_by_breakpoint): ... this. Record whether the LWP
stopped for a software breakpoint or hardware breakpoint.
(select_event_lwp): Only give preference to the stepping LWP in
all-stop mode. Adjust comments.
(stop_and_resume_callback): Remove references to new_pending_p.
(linux_nat_filter_event): Likewise. Leave exit events of the
leader thread pending here. Handle signal short circuiting here.
Only call save_sigtrap after storing the pending waitstatus.
(linux_nat_wait_1): Remove 'retry' label. Remove references to
new_pending. Don't handle leaving events the caller is not
interested in pending here, nor handle signal short-circuiting
here. Also give equal priority to all LWPs that have had events
in non-stop mode. If reporting a software breakpoint event,
unadjust the LWP's PC.
* linux-nat.h (enum lwp_stop_reason): New.
(struct lwp_info) <stop_pc>: New field.
(struct lwp_info) <stopped_by_watchpoint>: Delete field.
(struct lwp_info) <stop_reason>: New field.
* x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust.
2015-01-07 13:48:32 +01:00
|
|
|
|
{
|
2010-02-08 16:44:09 +01:00
|
|
|
|
/* In all-stop, from the core's perspective, all LWPs are now
|
|
|
|
|
stopped until a new resume action is sent over. */
|
|
|
|
|
iterate_over_lwps (minus_one_ptid, resume_clear_callback, NULL);
|
|
|
|
|
}
|
|
|
|
|
else
|
2011-09-09 21:27:50 +02:00
|
|
|
|
{
|
2011-10-10 15:23:53 +02:00
|
|
|
|
resume_clear_callback (lp, NULL);
|
2011-09-09 21:27:50 +02:00
|
|
|
|
}
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
2010-07-27 22:51:40 +02:00
|
|
|
|
if (linux_nat_status_is_event (status))
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
2008-05-15 22:11:48 +02:00
|
|
|
|
"LLW: trap ptid is %s.\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (lp->waitstatus.kind != TARGET_WAITKIND_IGNORE)
|
|
|
|
|
{
|
|
|
|
|
*ourstatus = lp->waitstatus;
|
|
|
|
|
lp->waitstatus.kind = TARGET_WAITKIND_IGNORE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
store_waitstatus (ourstatus, status);
|
|
|
|
|
|
2011-05-13 19:31:07 +02:00
|
|
|
|
if (debug_linux_nat)
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "LLW: exit\n");
|
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
restore_child_signals_mask (&prev_mask);
|
2010-05-28 20:00:46 +02:00
|
|
|
|
|
2011-10-10 15:23:53 +02:00
|
|
|
|
if (last_resume_kind == resume_stop
|
2011-09-09 21:27:50 +02:00
|
|
|
|
&& ourstatus->kind == TARGET_WAITKIND_STOPPED
|
|
|
|
|
&& WSTOPSIG (status) == SIGSTOP)
|
|
|
|
|
{
|
|
|
|
|
/* A thread that has been requested to stop by GDB with
|
|
|
|
|
target_stop, and it stopped cleanly, so report as SIG0. The
|
|
|
|
|
use of SIGSTOP is an implementation detail. */
|
2012-05-24 18:51:47 +02:00
|
|
|
|
ourstatus->value.sig = GDB_SIGNAL_0;
|
2011-09-09 21:27:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-05-28 20:00:46 +02:00
|
|
|
|
if (ourstatus->kind == TARGET_WAITKIND_EXITED
|
|
|
|
|
|| ourstatus->kind == TARGET_WAITKIND_SIGNALLED)
|
|
|
|
|
lp->core = -1;
|
|
|
|
|
else
|
2012-03-05 22:07:46 +01:00
|
|
|
|
lp->core = linux_common_core_of_thread (lp->ptid);
|
2010-05-28 20:00:46 +02:00
|
|
|
|
|
2016-05-24 15:47:56 +02:00
|
|
|
|
if (ourstatus->kind == TARGET_WAITKIND_EXITED)
|
|
|
|
|
return filter_exit_event (lp, ourstatus);
|
|
|
|
|
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
return lp->ptid;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 16:44:09 +01:00
|
|
|
|
/* Resume LWPs that are currently stopped without any pending status
|
|
|
|
|
to report, but are resumed from the core's perspective. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
resume_stopped_resumed_lwps (struct lwp_info *lp, void *data)
|
|
|
|
|
{
|
Add some more casts (1/2)
Note: I needed to split this patch in two, otherwise it's too big for
the mailing list.
This patch adds explicit casts to situations where a void pointer is
assigned to a pointer to the "real" type. Building in C++ mode requires
those assignments to use an explicit cast. This includes, for example:
- callback arguments (cleanups, comparison functions, ...)
- data attached to some object (objfile, program space, etc) in the form
of a void pointer
- "user data" passed to some function
This patch comes from the commit "(mostly) auto-generated patch to insert
casts needed for C++", taken from Pedro's C++ branch.
Only files built on x86 with --enable-targets=all are modified, so the
native files for other arches will need to be dealt with separately.
I built-tested this with --enable-targets=all and reg-tested. To my
surprise, a test case (selftest.exp) had to be adjusted.
Here's the ChangeLog entry. Again, this was relatively quick to make
despite the length, thanks to David Malcom's script, although I don't
believe it's very useful information in that particular case...
gdb/ChangeLog:
* aarch64-tdep.c (aarch64_make_prologue_cache): Add cast(s).
(aarch64_make_stub_cache): Likewise.
(value_of_aarch64_user_reg): Likewise.
* ada-lang.c (ada_inferior_data_cleanup): Likewise.
(get_ada_inferior_data): Likewise.
(get_ada_pspace_data): Likewise.
(ada_pspace_data_cleanup): Likewise.
(ada_complete_symbol_matcher): Likewise.
(ada_exc_search_name_matches): Likewise.
* ada-tasks.c (get_ada_tasks_pspace_data): Likewise.
(get_ada_tasks_inferior_data): Likewise.
* addrmap.c (addrmap_mutable_foreach_worker): Likewise.
(splay_obstack_alloc): Likewise.
(splay_obstack_free): Likewise.
* alpha-linux-tdep.c (alpha_linux_supply_gregset): Likewise.
(alpha_linux_collect_gregset): Likewise.
(alpha_linux_supply_fpregset): Likewise.
(alpha_linux_collect_fpregset): Likewise.
* alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind_cache): Likewise.
* alpha-tdep.c (alpha_lds): Likewise.
(alpha_sts): Likewise.
(alpha_sigtramp_frame_unwind_cache): Likewise.
(alpha_heuristic_frame_unwind_cache): Likewise.
(alpha_supply_int_regs): Likewise.
(alpha_fill_int_regs): Likewise.
(alpha_supply_fp_regs): Likewise.
(alpha_fill_fp_regs): Likewise.
* alphanbsd-tdep.c (alphanbsd_supply_fpregset): Likewise.
(alphanbsd_aout_supply_gregset): Likewise.
(alphanbsd_supply_gregset): Likewise.
* amd64-linux-tdep.c (amd64_linux_init_abi): Likewise.
(amd64_x32_linux_init_abi): Likewise.
* amd64-nat.c (amd64_supply_native_gregset): Likewise.
(amd64_collect_native_gregset): Likewise.
* amd64-tdep.c (amd64_frame_cache): Likewise.
(amd64_sigtramp_frame_cache): Likewise.
(amd64_epilogue_frame_cache): Likewise.
(amd64_supply_fxsave): Likewise.
(amd64_supply_xsave): Likewise.
(amd64_collect_fxsave): Likewise.
(amd64_collect_xsave): Likewise.
* amd64-windows-tdep.c (amd64_windows_frame_cache): Likewise.
* amd64obsd-tdep.c (amd64obsd_trapframe_cache): Likewise.
* arm-linux-tdep.c (arm_linux_supply_gregset): Likewise.
(arm_linux_collect_gregset): Likewise.
(arm_linux_supply_nwfpe): Likewise.
(arm_linux_collect_nwfpe): Likewise.
(arm_linux_supply_vfp): Likewise.
(arm_linux_collect_vfp): Likewise.
* arm-tdep.c (arm_find_mapping_symbol): Likewise.
(arm_prologue_unwind_stop_reason): Likewise.
(arm_prologue_this_id): Likewise.
(arm_prologue_prev_register): Likewise.
(arm_exidx_data_free): Likewise.
(arm_find_exidx_entry): Likewise.
(arm_stub_this_id): Likewise.
(arm_m_exception_this_id): Likewise.
(arm_m_exception_prev_register): Likewise.
(arm_normal_frame_base): Likewise.
(gdb_print_insn_arm): Likewise.
(arm_objfile_data_free): Likewise.
(arm_record_special_symbol): Likewise.
(value_of_arm_user_reg): Likewise.
* armbsd-tdep.c (armbsd_supply_fpregset): Likewise.
(armbsd_supply_gregset): Likewise.
* auto-load.c (auto_load_pspace_data_cleanup): Likewise.
(get_auto_load_pspace_data): Likewise.
(hash_loaded_script_entry): Likewise.
(eq_loaded_script_entry): Likewise.
(clear_section_scripts): Likewise.
(collect_matching_scripts): Likewise.
* auxv.c (auxv_inferior_data_cleanup): Likewise.
(get_auxv_inferior_data): Likewise.
* avr-tdep.c (avr_frame_unwind_cache): Likewise.
* ax-general.c (do_free_agent_expr_cleanup): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
(target_bfd_xclose): Likewise.
(target_bfd_get_section_table): Likewise.
* bfin-tdep.c (bfin_frame_cache): Likewise.
* block.c (find_block_in_blockvector): Likewise.
(call_site_for_pc): Likewise.
(block_find_non_opaque_type_preferred): Likewise.
* break-catch-sig.c (signal_catchpoint_insert_location): Likewise.
(signal_catchpoint_remove_location): Likewise.
(signal_catchpoint_breakpoint_hit): Likewise.
(signal_catchpoint_print_one): Likewise.
(signal_catchpoint_print_mention): Likewise.
(signal_catchpoint_print_recreate): Likewise.
* break-catch-syscall.c (get_catch_syscall_inferior_data): Likewise.
* breakpoint.c (do_cleanup_counted_command_line): Likewise.
(bp_location_compare_addrs): Likewise.
(get_first_locp_gte_addr): Likewise.
(check_tracepoint_command): Likewise.
(do_map_commands_command): Likewise.
(get_breakpoint_objfile_data): Likewise.
(free_breakpoint_probes): Likewise.
(do_captured_breakpoint_query): Likewise.
(compare_breakpoints): Likewise.
(bp_location_compare): Likewise.
(bpstat_remove_breakpoint_callback): Likewise.
(do_delete_breakpoint_cleanup): Likewise.
* bsd-uthread.c (bsd_uthread_set_supply_uthread): Likewise.
(bsd_uthread_set_collect_uthread): Likewise.
(bsd_uthread_activate): Likewise.
(bsd_uthread_fetch_registers): Likewise.
(bsd_uthread_store_registers): Likewise.
* btrace.c (check_xml_btrace_version): Likewise.
(parse_xml_btrace_block): Likewise.
(parse_xml_btrace_pt_config_cpu): Likewise.
(parse_xml_btrace_pt_raw): Likewise.
(parse_xml_btrace_pt): Likewise.
(parse_xml_btrace_conf_bts): Likewise.
(parse_xml_btrace_conf_pt): Likewise.
(do_btrace_data_cleanup): Likewise.
* c-typeprint.c (find_typedef_for_canonicalize): Likewise.
* charset.c (cleanup_iconv): Likewise.
(do_cleanup_iterator): Likewise.
* cli-out.c (cli_uiout_dtor): Likewise.
(cli_table_begin): Likewise.
(cli_table_body): Likewise.
(cli_table_end): Likewise.
(cli_table_header): Likewise.
(cli_begin): Likewise.
(cli_end): Likewise.
(cli_field_int): Likewise.
(cli_field_skip): Likewise.
(cli_field_string): Likewise.
(cli_field_fmt): Likewise.
(cli_spaces): Likewise.
(cli_text): Likewise.
(cli_message): Likewise.
(cli_wrap_hint): Likewise.
(cli_flush): Likewise.
(cli_redirect): Likewise.
(out_field_fmt): Likewise.
(field_separator): Likewise.
(cli_out_set_stream): Likewise.
* cli/cli-cmds.c (compare_symtabs): Likewise.
* cli/cli-dump.c (call_dump_func): Likewise.
(restore_section_callback): Likewise.
* cli/cli-script.c (clear_hook_in_cleanup): Likewise.
(do_restore_user_call_depth): Likewise.
(do_free_command_lines_cleanup): Likewise.
* coff-pe-read.c (get_section_vmas): Likewise.
(pe_as16): Likewise.
(pe_as32): Likewise.
* coffread.c (coff_symfile_read): Likewise.
* common/agent.c (agent_look_up_symbols): Likewise.
* common/filestuff.c (do_close_cleanup): Likewise.
* common/format.c (free_format_pieces_cleanup): Likewise.
* common/vec.c (vec_o_reserve): Likewise.
* compile/compile-c-support.c (print_one_macro): Likewise.
* compile/compile-c-symbols.c (hash_symbol_error): Likewise.
(eq_symbol_error): Likewise.
(del_symbol_error): Likewise.
(error_symbol_once): Likewise.
(gcc_convert_symbol): Likewise.
(gcc_symbol_address): Likewise.
(hash_symname): Likewise.
(eq_symname): Likewise.
* compile/compile-c-types.c (hash_type_map_instance): Likewise.
(eq_type_map_instance): Likewise.
(insert_type): Likewise.
(convert_type): Likewise.
* compile/compile-object-load.c (munmap_listp_free_cleanup): Likewise.
(setup_sections): Likewise.
(link_hash_table_free): Likewise.
(copy_sections): Likewise.
* compile/compile-object-run.c (do_module_cleanup): Likewise.
* compile/compile.c (compile_print_value): Likewise.
(do_rmdir): Likewise.
(cleanup_compile_instance): Likewise.
(cleanup_unlink_file): Likewise.
* completer.c (free_completion_tracker): Likewise.
* corelow.c (add_to_spuid_list): Likewise.
* cp-namespace.c (reset_directive_searched): Likewise.
* cp-support.c (reset_directive_searched): Likewise.
* cris-tdep.c (cris_sigtramp_frame_unwind_cache): Likewise.
(cris_frame_unwind_cache): Likewise.
* d-lang.c (builtin_d_type): Likewise.
* d-namespace.c (reset_directive_searched): Likewise.
* dbxread.c (dbx_free_symfile_info): Likewise.
(do_free_bincl_list_cleanup): Likewise.
* disasm.c (hash_dis_line_entry): Likewise.
(eq_dis_line_entry): Likewise.
(dis_asm_print_address): Likewise.
(fprintf_disasm): Likewise.
(do_ui_file_delete): Likewise.
* doublest.c (convert_floatformat_to_doublest): Likewise.
* dummy-frame.c (pop_dummy_frame_bpt): Likewise.
(dummy_frame_prev_register): Likewise.
(dummy_frame_this_id): Likewise.
* dwarf2-frame-tailcall.c (cache_hash): Likewise.
(cache_eq): Likewise.
(cache_find): Likewise.
(tailcall_frame_this_id): Likewise.
(dwarf2_tailcall_prev_register_first): Likewise.
(tailcall_frame_prev_register): Likewise.
(tailcall_frame_dealloc_cache): Likewise.
(tailcall_frame_prev_arch): Likewise.
* dwarf2-frame.c (dwarf2_frame_state_free): Likewise.
(dwarf2_frame_set_init_reg): Likewise.
(dwarf2_frame_init_reg): Likewise.
(dwarf2_frame_set_signal_frame_p): Likewise.
(dwarf2_frame_signal_frame_p): Likewise.
(dwarf2_frame_set_adjust_regnum): Likewise.
(dwarf2_frame_adjust_regnum): Likewise.
(clear_pointer_cleanup): Likewise.
(dwarf2_frame_cache): Likewise.
(find_cie): Likewise.
(dwarf2_frame_find_fde): Likewise.
* dwarf2expr.c (dwarf_expr_address_type): Likewise.
(free_dwarf_expr_context_cleanup): Likewise.
* dwarf2loc.c (locexpr_find_frame_base_location): Likewise.
(locexpr_get_frame_base): Likewise.
(loclist_find_frame_base_location): Likewise.
(loclist_get_frame_base): Likewise.
(dwarf_expr_dwarf_call): Likewise.
(dwarf_expr_get_base_type): Likewise.
(dwarf_expr_push_dwarf_reg_entry_value): Likewise.
(dwarf_expr_get_obj_addr): Likewise.
(entry_data_value_coerce_ref): Likewise.
(entry_data_value_copy_closure): Likewise.
(entry_data_value_free_closure): Likewise.
(get_frame_address_in_block_wrapper): Likewise.
(dwarf2_evaluate_property): Likewise.
(dwarf2_compile_property_to_c): Likewise.
(needs_frame_read_addr_from_reg): Likewise.
(needs_frame_get_reg_value): Likewise.
(needs_frame_frame_base): Likewise.
(needs_frame_frame_cfa): Likewise.
(needs_frame_tls_address): Likewise.
(needs_frame_dwarf_call): Likewise.
(needs_dwarf_reg_entry_value): Likewise.
(get_ax_pc): Likewise.
(locexpr_read_variable): Likewise.
(locexpr_read_variable_at_entry): Likewise.
(locexpr_read_needs_frame): Likewise.
(locexpr_describe_location): Likewise.
(locexpr_tracepoint_var_ref): Likewise.
(locexpr_generate_c_location): Likewise.
(loclist_read_variable): Likewise.
(loclist_read_variable_at_entry): Likewise.
(loclist_describe_location): Likewise.
(loclist_tracepoint_var_ref): Likewise.
(loclist_generate_c_location): Likewise.
* dwarf2read.c (line_header_hash_voidp): Likewise.
(line_header_eq_voidp): Likewise.
(dwarf2_has_info): Likewise.
(dwarf2_get_section_info): Likewise.
(locate_dwz_sections): Likewise.
(hash_file_name_entry): Likewise.
(eq_file_name_entry): Likewise.
(delete_file_name_entry): Likewise.
(dw2_setup): Likewise.
(dw2_get_file_names_reader): Likewise.
(dw2_find_pc_sect_compunit_symtab): Likewise.
(hash_signatured_type): Likewise.
(eq_signatured_type): Likewise.
(add_signatured_type_cu_to_table): Likewise.
(create_debug_types_hash_table): Likewise.
(lookup_dwo_signatured_type): Likewise.
(lookup_dwp_signatured_type): Likewise.
(lookup_signatured_type): Likewise.
(hash_type_unit_group): Likewise.
(eq_type_unit_group): Likewise.
(get_type_unit_group): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(sort_tu_by_abbrev_offset): Likewise.
(process_skeletonless_type_unit): Likewise.
(psymtabs_addrmap_cleanup): Likewise.
(dwarf2_read_symtab): Likewise.
(psymtab_to_symtab_1): Likewise.
(die_hash): Likewise.
(die_eq): Likewise.
(load_full_comp_unit_reader): Likewise.
(reset_die_in_process): Likewise.
(free_cu_line_header): Likewise.
(handle_DW_AT_stmt_list): Likewise.
(hash_dwo_file): Likewise.
(eq_dwo_file): Likewise.
(hash_dwo_unit): Likewise.
(eq_dwo_unit): Likewise.
(create_dwo_cu_reader): Likewise.
(create_dwo_unit_in_dwp_v1): Likewise.
(create_dwo_unit_in_dwp_v2): Likewise.
(lookup_dwo_unit_in_dwp): Likewise.
(dwarf2_locate_dwo_sections): Likewise.
(dwarf2_locate_common_dwp_sections): Likewise.
(dwarf2_locate_v2_dwp_sections): Likewise.
(hash_dwp_loaded_cutus): Likewise.
(eq_dwp_loaded_cutus): Likewise.
(lookup_dwo_cutu): Likewise.
(abbrev_table_free_cleanup): Likewise.
(dwarf2_free_abbrev_table): Likewise.
(find_partial_die_in_comp_unit): Likewise.
(free_line_header_voidp): Likewise.
(follow_die_offset): Likewise.
(follow_die_sig_1): Likewise.
(free_heap_comp_unit): Likewise.
(free_stack_comp_unit): Likewise.
(dwarf2_free_objfile): Likewise.
(per_cu_offset_and_type_hash): Likewise.
(per_cu_offset_and_type_eq): Likewise.
(get_die_type_at_offset): Likewise.
(partial_die_hash): Likewise.
(partial_die_eq): Likewise.
(dwarf2_per_objfile_free): Likewise.
(hash_strtab_entry): Likewise.
(eq_strtab_entry): Likewise.
(add_string): Likewise.
(hash_symtab_entry): Likewise.
(eq_symtab_entry): Likewise.
(delete_symtab_entry): Likewise.
(cleanup_mapped_symtab): Likewise.
(add_indices_to_cpool): Likewise.
(hash_psymtab_cu_index): Likewise.
(eq_psymtab_cu_index): Likewise.
(add_address_entry_worker): Likewise.
(unlink_if_set): Likewise.
(write_one_signatured_type): Likewise.
(save_gdb_index_command): Likewise.
* elfread.c (elf_symtab_read): Likewise.
(elf_gnu_ifunc_cache_hash): Likewise.
(elf_gnu_ifunc_cache_eq): Likewise.
(elf_gnu_ifunc_record_cache): Likewise.
(elf_gnu_ifunc_resolve_by_cache): Likewise.
(elf_get_probes): Likewise.
(probe_key_free): Likewise.
* f-lang.c (builtin_f_type): Likewise.
* frame-base.c (frame_base_append_sniffer): Likewise.
(frame_base_set_default): Likewise.
(frame_base_find_by_frame): Likewise.
* frame-unwind.c (frame_unwind_prepend_unwinder): Likewise.
(frame_unwind_append_unwinder): Likewise.
(frame_unwind_find_by_frame): Likewise.
* frame.c (frame_addr_hash): Likewise.
(frame_addr_hash_eq): Likewise.
(frame_stash_find): Likewise.
(do_frame_register_read): Likewise.
(unwind_to_current_frame): Likewise.
(frame_cleanup_after_sniffer): Likewise.
* frv-linux-tdep.c (frv_linux_sigtramp_frame_cache): Likewise.
* frv-tdep.c (frv_frame_unwind_cache): Likewise.
* ft32-tdep.c (ft32_frame_cache): Likewise.
* gcore.c (do_bfd_delete_cleanup): Likewise.
(gcore_create_callback): Likewise.
* gdb_bfd.c (hash_bfd): Likewise.
(eq_bfd): Likewise.
(gdb_bfd_open): Likewise.
(free_one_bfd_section): Likewise.
(gdb_bfd_ref): Likewise.
(gdb_bfd_unref): Likewise.
(get_section_descriptor): Likewise.
(gdb_bfd_map_section): Likewise.
(gdb_bfd_crc): Likewise.
(gdb_bfd_mark_parent): Likewise.
(gdb_bfd_record_inclusion): Likewise.
(gdb_bfd_requires_relocations): Likewise.
(print_one_bfd): Likewise.
* gdbtypes.c (type_pair_hash): Likewise.
(type_pair_eq): Likewise.
(builtin_type): Likewise.
(objfile_type): Likewise.
* gnu-v3-abi.c (vtable_ptrdiff_type): Likewise.
(vtable_address_point_offset): Likewise.
(gnuv3_get_vtable): Likewise.
(hash_value_and_voffset): Likewise.
(eq_value_and_voffset): Likewise.
(compare_value_and_voffset): Likewise.
(compute_vtable_size): Likewise.
(gnuv3_get_typeid_type): Likewise.
* go-lang.c (builtin_go_type): Likewise.
* guile/scm-block.c (bkscm_hash_block_smob): Likewise.
(bkscm_eq_block_smob): Likewise.
(bkscm_objfile_block_map): Likewise.
(bkscm_del_objfile_blocks): Likewise.
* guile/scm-breakpoint.c (bpscm_build_bp_list): Likewise.
* guile/scm-disasm.c (gdbscm_disasm_read_memory_worker): Likewise.
(gdbscm_disasm_print_address): Likewise.
* guile/scm-frame.c (frscm_hash_frame_smob): Likewise.
(frscm_eq_frame_smob): Likewise.
(frscm_inferior_frame_map): Likewise.
(frscm_del_inferior_frames): Likewise.
* guile/scm-gsmob.c (gdbscm_add_objfile_ref): Likewise.
* guile/scm-objfile.c (ofscm_handle_objfile_deleted): Likewise.
(ofscm_objfile_smob_from_objfile): Likewise.
* guile/scm-ports.c (ioscm_write): Likewise.
(ioscm_file_port_delete): Likewise.
(ioscm_file_port_rewind): Likewise.
(ioscm_file_port_put): Likewise.
(ioscm_file_port_write): Likewise.
* guile/scm-progspace.c (psscm_handle_pspace_deleted): Likewise.
(psscm_pspace_smob_from_pspace): Likewise.
* guile/scm-safe-call.c (scscm_recording_pre_unwind_handler): Likewise.
(scscm_recording_unwind_handler): Likewise.
(gdbscm_with_catch): Likewise.
(scscm_call_0_body): Likewise.
(scscm_call_1_body): Likewise.
(scscm_call_2_body): Likewise.
(scscm_call_3_body): Likewise.
(scscm_call_4_body): Likewise.
(scscm_apply_1_body): Likewise.
(scscm_eval_scheme_string): Likewise.
(gdbscm_safe_eval_string): Likewise.
(scscm_source_scheme_script): Likewise.
(gdbscm_safe_source_script): Likewise.
* guile/scm-string.c (gdbscm_call_scm_to_stringn): Likewise.
(gdbscm_call_scm_from_stringn): Likewise.
* guile/scm-symbol.c (syscm_hash_symbol_smob): Likewise.
(syscm_eq_symbol_smob): Likewise.
(syscm_get_symbol_map): Likewise.
(syscm_del_objfile_symbols): Likewise.
* guile/scm-symtab.c (stscm_hash_symtab_smob): Likewise.
(stscm_eq_symtab_smob): Likewise.
(stscm_objfile_symtab_map): Likewise.
(stscm_del_objfile_symtabs): Likewise.
* guile/scm-type.c (tyscm_hash_type_smob): Likewise.
(tyscm_eq_type_smob): Likewise.
(tyscm_type_map): Likewise.
(tyscm_copy_type_recursive): Likewise.
(save_objfile_types): Likewise.
* guile/scm-utils.c (extract_arg): Likewise.
* h8300-tdep.c (h8300_frame_cache): Likewise.
* hppa-linux-tdep.c (hppa_linux_sigtramp_frame_unwind_cache): Likewise.
* hppa-tdep.c (compare_unwind_entries): Likewise.
(find_unwind_entry): Likewise.
(hppa_frame_cache): Likewise.
(hppa_stub_frame_unwind_cache): Likewise.
* hppanbsd-tdep.c (hppanbsd_supply_gregset): Likewise.
* hppaobsd-tdep.c (hppaobsd_supply_gregset): Likewise.
(hppaobsd_supply_fpregset): Likewise.
* i386-cygwin-tdep.c (core_process_module_section): Likewise.
* i386-linux-tdep.c (i386_linux_init_abi): Likewise.
* i386-tdep.c (i386_frame_cache): Likewise.
(i386_epilogue_frame_cache): Likewise.
(i386_sigtramp_frame_cache): Likewise.
(i386_supply_gregset): Likewise.
(i386_collect_gregset): Likewise.
(i386_gdbarch_init): Likewise.
* i386obsd-tdep.c (i386obsd_aout_supply_regset): Likewise.
(i386obsd_trapframe_cache): Likewise.
* i387-tdep.c (i387_supply_fsave): Likewise.
(i387_collect_fsave): Likewise.
(i387_supply_fxsave): Likewise.
(i387_collect_fxsave): Likewise.
(i387_supply_xsave): Likewise.
(i387_collect_xsave): Likewise.
* ia64-tdep.c (ia64_frame_cache): Likewise.
(ia64_sigtramp_frame_cache): Likewise.
* infcmd.c (attach_command_continuation): Likewise.
(attach_command_continuation_free_args): Likewise.
* inferior.c (restore_inferior): Likewise.
(delete_thread_of_inferior): Likewise.
* inflow.c (inflow_inferior_data_cleanup): Likewise.
(get_inflow_inferior_data): Likewise.
(inflow_inferior_exit): Likewise.
* infrun.c (displaced_step_clear_cleanup): Likewise.
(restore_current_uiout_cleanup): Likewise.
(release_stop_context_cleanup): Likewise.
(do_restore_infcall_suspend_state_cleanup): Likewise.
(do_restore_infcall_control_state_cleanup): Likewise.
(restore_inferior_ptid): Likewise.
* inline-frame.c (block_starting_point_at): Likewise.
* iq2000-tdep.c (iq2000_frame_cache): Likewise.
* jit.c (get_jit_objfile_data): Likewise.
(get_jit_program_space_data): Likewise.
(jit_object_close_impl): Likewise.
(jit_find_objf_with_entry_addr): Likewise.
(jit_breakpoint_deleted): Likewise.
(jit_unwind_reg_set_impl): Likewise.
(jit_unwind_reg_get_impl): Likewise.
(jit_dealloc_cache): Likewise.
(jit_frame_sniffer): Likewise.
(jit_frame_prev_register): Likewise.
(jit_prepend_unwinder): Likewise.
(jit_inferior_exit_hook): Likewise.
(free_objfile_data): Likewise.
* jv-lang.c (jv_per_objfile_free): Likewise.
(get_dynamics_objfile): Likewise.
(get_java_class_symtab): Likewise.
(builtin_java_type): Likewise.
* language.c (language_string_char_type): Likewise.
(language_bool_type): Likewise.
(language_lookup_primitive_type): Likewise.
(language_lookup_primitive_type_as_symbol): Likewise.
* linespec.c (hash_address_entry): Likewise.
(eq_address_entry): Likewise.
(iterate_inline_only): Likewise.
(iterate_name_matcher): Likewise.
(decode_line_2_compare_items): Likewise.
(collect_one_symbol): Likewise.
(compare_symbols): Likewise.
(compare_msymbols): Likewise.
(add_symtabs_to_list): Likewise.
(collect_symbols): Likewise.
(compare_msyms): Likewise.
(add_minsym): Likewise.
(cleanup_linespec_result): Likewise.
* linux-fork.c (inferior_call_waitpid_cleanup): Likewise.
* linux-nat.c (delete_lwp_cleanup): Likewise.
(count_events_callback): Likewise.
(select_event_lwp_callback): Likewise.
(resume_stopped_resumed_lwps): Likewise.
* linux-tdep.c (get_linux_gdbarch_data): Likewise.
(invalidate_linux_cache_inf): Likewise.
(get_linux_inferior_data): Likewise.
(linux_find_memory_regions_thunk): Likewise.
(linux_make_mappings_callback): Likewise.
(linux_corefile_thread_callback): Likewise.
(find_mapping_size): Likewise.
* linux-thread-db.c (find_new_threads_callback): Likewise.
* lm32-tdep.c (lm32_frame_cache): Likewise.
* m2-lang.c (builtin_m2_type): Likewise.
* m32c-tdep.c (m32c_analyze_frame_prologue): Likewise.
* m32r-linux-tdep.c (m32r_linux_sigtramp_frame_cache): Likewise.
(m32r_linux_supply_gregset): Likewise.
(m32r_linux_collect_gregset): Likewise.
* m32r-tdep.c (m32r_frame_unwind_cache): Likewise.
* m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise.
* m68k-tdep.c (m68k_frame_cache): Likewise.
* m68kbsd-tdep.c (m68kbsd_supply_fpregset): Likewise.
(m68kbsd_supply_gregset): Likewise.
* m68klinux-tdep.c (m68k_linux_sigtramp_frame_cache): Likewise.
* m88k-tdep.c (m88k_frame_cache): Likewise.
(m88k_supply_gregset): Likewise.
gdb/gdbserver/ChangeLog:
* dll.c (match_dll): Add cast(s).
(unloaded_dll): Likewise.
* linux-low.c (second_thread_of_pid_p): Likewise.
(delete_lwp_callback): Likewise.
(count_events_callback): Likewise.
(select_event_lwp_callback): Likewise.
(linux_set_resume_request): Likewise.
* server.c (accumulate_file_name_length): Likewise.
(emit_dll_description): Likewise.
(handle_qxfer_threads_worker): Likewise.
(visit_actioned_threads): Likewise.
* thread-db.c (any_thread_of): Likewise.
* tracepoint.c (same_process_p): Likewise.
(match_blocktype): Likewise.
(build_traceframe_info_xml): Likewise.
gdb/testsuite/ChangeLog:
* gdb.gdb/selftest.exp (do_steps_and_nexts): Adjust expected
source line.
2015-09-25 20:08:07 +02:00
|
|
|
|
ptid_t *wait_ptid_p = (ptid_t *) data;
|
2010-02-08 16:44:09 +01:00
|
|
|
|
|
PR threads/18600: Threads left stopped after fork+thread spawn
When a program forks and another process start threads while gdb is
handling the fork event, newly created threads are left stuck stopped
by gdb, even though gdb presents them as "running", to the user.
This can be seen with the test added by this patch. The test has the
inferior fork a certain number of times and waits for all children to
exit. Each fork child spawns a number of threads that do nothing and
joins them immediately. Normally, the program should run unimpeded
(from the point of view of the user) and exit very quickly. Without
this fix, it doesn't because of some threads left stopped by gdb, so
inferior 1 never exits.
The program triggers when a new clone thread is found while inside the
linux_stop_and_wait_all_lwps call in linux-thread-db.c:
linux_stop_and_wait_all_lwps ();
ALL_LWPS (lp)
if (ptid_get_pid (lp->ptid) == pid)
thread_from_lwp (lp->ptid);
linux_unstop_all_lwps ();
Within linux_stop_and_wait_all_lwps, we reach
linux_handle_extended_wait with the "stopping" parameter set to 1, and
because of that we don't mark the new lwp as resumed. As consequence,
the subsequent resume_stopped_resumed_lwps, called from
linux_unstop_all_lwps, never resumes the new LWP.
There's lots of cruft in linux_handle_extended_wait that no longer
makes sense. On systems with CLONE events support, we don't rely on
libthread_db for thread listing anymore, so the code that preserves
stop_requested and the handling of last_resume_kind is all dead.
So the fix is to remove all that, and simply always mark the new LWP
as resumed, so that resume_stopped_resumed_lwps re-resumes it.
gdb/ChangeLog:
2015-07-30 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
PR threads/18600
* linux-nat.c (linux_handle_extended_wait): On CLONE event, always
mark the new thread as resumed. Remove STOPPING parameter.
(wait_lwp): Adjust call to linux_handle_extended_wait.
(linux_nat_filter_event): Adjust call to
linux_handle_extended_wait.
(resume_stopped_resumed_lwps): Add debug output.
gdb/testsuite/ChangeLog:
2015-07-30 Simon Marchi <simon.marchi@ericsson.com>
Pedro Alves <palves@redhat.com>
PR threads/18600
* gdb.threads/fork-plus-threads.c: New file.
* gdb.threads/fork-plus-threads.exp: New file.
2015-07-30 19:50:29 +02:00
|
|
|
|
if (!lp->stopped)
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"RSRL: NOT resuming LWP %s, not stopped\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
}
|
|
|
|
|
else if (!lp->resumed)
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"RSRL: NOT resuming LWP %s, not resumed\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
}
|
|
|
|
|
else if (lwp_status_pending_p (lp))
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"RSRL: NOT resuming LWP %s, has pending status\n",
|
|
|
|
|
target_pid_to_str (lp->ptid));
|
|
|
|
|
}
|
|
|
|
|
else
|
2010-02-08 16:44:09 +01:00
|
|
|
|
{
|
2011-12-05 19:49:49 +01:00
|
|
|
|
struct regcache *regcache = get_thread_regcache (lp->ptid);
|
2017-10-25 17:37:03 +02:00
|
|
|
|
struct gdbarch *gdbarch = regcache->arch ();
|
2011-12-05 19:49:49 +01:00
|
|
|
|
|
Fix race exposed by gdb.threads/killed.exp
On GNU/Linux, this test sometimes FAILs like this:
(gdb) run
Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
ptrace: No such process.
(gdb)
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
Note the suspicious "No such process" line (that's errno==ESRCH).
Adding debug output we see:
linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Stopped (signal) (stopped)
LNW: waitpid(-1, ...) returned 18461, ERRNO-OK
LLW: waitpid 18461 received Trace/breakpoint trap (stopped)
LLW: Handling extended status 0x03057f
LHEW: Got clone event from LWP 18461, new child is LWP 18465
LNW: waitpid(-1, ...) returned 0, ERRNO-OK
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
sigchld
ptrace: No such process.
(gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Killed (terminated)
LLW: LWP 18465 exited.
LNW: waitpid(-1, ...) returned 18461, No child processes
LLW: waitpid 18461 received Killed (terminated)
Process 18461 exited
LNW: waitpid(-1, ...) returned -1, No child processes
LLW: exit
sigchld
infrun: target_wait (-1, status) =
infrun: 18461 [process 18461],
infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL
infrun: TARGET_WAITKIND_SIGNALLED
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
infrun: stop_waiting
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
The issue is that here:
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
The first line shows we had just resumed LWP 18465, which does:
void *
child_func (void *dummy)
{
kill (pid, SIGKILL);
exit (1);
}
So if the kernel manages to schedule that thread fast enough, the
process may be killed before GDB has a chance to resume LWP 18461.
GDBserver has code at the tail end of linux_resume_one_lwp to cope
with this:
~~~
ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread),
(PTRACE_TYPE_ARG3) 0,
/* Coerce to a uintptr_t first to avoid potential gcc warning
of coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG4) (uintptr_t) signal);
current_thread = saved_thread;
if (errno)
{
/* ESRCH from ptrace either means that the thread was already
running (an error) or that it is gone (a race condition). If
it's gone, we will get a notification the next time we wait,
so we can ignore the error. We could differentiate these
two, but it's tricky without waiting; the thread still exists
as a zombie, so sending it signal 0 would succeed. So just
ignore ESRCH. */
if (errno == ESRCH)
return;
perror_with_name ("ptrace");
}
~~~
However, that's not a complete fix, because between starting to handle
the resume request and getting that PTRACE_CONTINUE, we run other
ptrace calls that can also fail with ESRCH, and that end up throwing
an error (with perror_with_name).
In the case above, I indeed sometimes see resume_stopped_resumed_lwps
fail in the registers read:
resume_stopped_resumed_lwps (struct lwp_info *lp, void *data)
{
...
CORE_ADDR pc = regcache_read_pc (regcache);
Or e.g., in 32-bit mode, i386_linux_resume has several calls that can
throw too.
Whether to ignore ptrace errors or not depends on context that is only
available somewhere up the call chain. So the fix is to let ptrace
errors throw as they do today, and wrap the resume request in a
TRY/CATCH that swallows it iff the lwp that we were trying to resume
is no longer ptrace-stopped.
gdb/gdbserver/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
gdb/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
(resume_stopped_resumed_lwps): Try register reads in TRY/CATCH and
swallows errors if the LWP is gone. Use
linux_resume_one_lwp_throw instead of linux_resume_one_lwp.
2015-03-19 16:12:33 +01:00
|
|
|
|
TRY
|
2010-02-08 16:44:09 +01:00
|
|
|
|
{
|
Fix race exposed by gdb.threads/killed.exp
On GNU/Linux, this test sometimes FAILs like this:
(gdb) run
Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
ptrace: No such process.
(gdb)
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
Note the suspicious "No such process" line (that's errno==ESRCH).
Adding debug output we see:
linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Stopped (signal) (stopped)
LNW: waitpid(-1, ...) returned 18461, ERRNO-OK
LLW: waitpid 18461 received Trace/breakpoint trap (stopped)
LLW: Handling extended status 0x03057f
LHEW: Got clone event from LWP 18461, new child is LWP 18465
LNW: waitpid(-1, ...) returned 0, ERRNO-OK
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
sigchld
ptrace: No such process.
(gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Killed (terminated)
LLW: LWP 18465 exited.
LNW: waitpid(-1, ...) returned 18461, No child processes
LLW: waitpid 18461 received Killed (terminated)
Process 18461 exited
LNW: waitpid(-1, ...) returned -1, No child processes
LLW: exit
sigchld
infrun: target_wait (-1, status) =
infrun: 18461 [process 18461],
infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL
infrun: TARGET_WAITKIND_SIGNALLED
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
infrun: stop_waiting
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
The issue is that here:
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
The first line shows we had just resumed LWP 18465, which does:
void *
child_func (void *dummy)
{
kill (pid, SIGKILL);
exit (1);
}
So if the kernel manages to schedule that thread fast enough, the
process may be killed before GDB has a chance to resume LWP 18461.
GDBserver has code at the tail end of linux_resume_one_lwp to cope
with this:
~~~
ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread),
(PTRACE_TYPE_ARG3) 0,
/* Coerce to a uintptr_t first to avoid potential gcc warning
of coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG4) (uintptr_t) signal);
current_thread = saved_thread;
if (errno)
{
/* ESRCH from ptrace either means that the thread was already
running (an error) or that it is gone (a race condition). If
it's gone, we will get a notification the next time we wait,
so we can ignore the error. We could differentiate these
two, but it's tricky without waiting; the thread still exists
as a zombie, so sending it signal 0 would succeed. So just
ignore ESRCH. */
if (errno == ESRCH)
return;
perror_with_name ("ptrace");
}
~~~
However, that's not a complete fix, because between starting to handle
the resume request and getting that PTRACE_CONTINUE, we run other
ptrace calls that can also fail with ESRCH, and that end up throwing
an error (with perror_with_name).
In the case above, I indeed sometimes see resume_stopped_resumed_lwps
fail in the registers read:
resume_stopped_resumed_lwps (struct lwp_info *lp, void *data)
{
...
CORE_ADDR pc = regcache_read_pc (regcache);
Or e.g., in 32-bit mode, i386_linux_resume has several calls that can
throw too.
Whether to ignore ptrace errors or not depends on context that is only
available somewhere up the call chain. So the fix is to let ptrace
errors throw as they do today, and wrap the resume request in a
TRY/CATCH that swallows it iff the lwp that we were trying to resume
is no longer ptrace-stopped.
gdb/gdbserver/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
gdb/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
(resume_stopped_resumed_lwps): Try register reads in TRY/CATCH and
swallows errors if the LWP is gone. Use
linux_resume_one_lwp_throw instead of linux_resume_one_lwp.
2015-03-19 16:12:33 +01:00
|
|
|
|
CORE_ADDR pc = regcache_read_pc (regcache);
|
|
|
|
|
int leave_stopped = 0;
|
2010-02-08 16:44:09 +01:00
|
|
|
|
|
Fix race exposed by gdb.threads/killed.exp
On GNU/Linux, this test sometimes FAILs like this:
(gdb) run
Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
ptrace: No such process.
(gdb)
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
Note the suspicious "No such process" line (that's errno==ESRCH).
Adding debug output we see:
linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Stopped (signal) (stopped)
LNW: waitpid(-1, ...) returned 18461, ERRNO-OK
LLW: waitpid 18461 received Trace/breakpoint trap (stopped)
LLW: Handling extended status 0x03057f
LHEW: Got clone event from LWP 18461, new child is LWP 18465
LNW: waitpid(-1, ...) returned 0, ERRNO-OK
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
sigchld
ptrace: No such process.
(gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Killed (terminated)
LLW: LWP 18465 exited.
LNW: waitpid(-1, ...) returned 18461, No child processes
LLW: waitpid 18461 received Killed (terminated)
Process 18461 exited
LNW: waitpid(-1, ...) returned -1, No child processes
LLW: exit
sigchld
infrun: target_wait (-1, status) =
infrun: 18461 [process 18461],
infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL
infrun: TARGET_WAITKIND_SIGNALLED
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
infrun: stop_waiting
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
The issue is that here:
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
The first line shows we had just resumed LWP 18465, which does:
void *
child_func (void *dummy)
{
kill (pid, SIGKILL);
exit (1);
}
So if the kernel manages to schedule that thread fast enough, the
process may be killed before GDB has a chance to resume LWP 18461.
GDBserver has code at the tail end of linux_resume_one_lwp to cope
with this:
~~~
ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread),
(PTRACE_TYPE_ARG3) 0,
/* Coerce to a uintptr_t first to avoid potential gcc warning
of coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG4) (uintptr_t) signal);
current_thread = saved_thread;
if (errno)
{
/* ESRCH from ptrace either means that the thread was already
running (an error) or that it is gone (a race condition). If
it's gone, we will get a notification the next time we wait,
so we can ignore the error. We could differentiate these
two, but it's tricky without waiting; the thread still exists
as a zombie, so sending it signal 0 would succeed. So just
ignore ESRCH. */
if (errno == ESRCH)
return;
perror_with_name ("ptrace");
}
~~~
However, that's not a complete fix, because between starting to handle
the resume request and getting that PTRACE_CONTINUE, we run other
ptrace calls that can also fail with ESRCH, and that end up throwing
an error (with perror_with_name).
In the case above, I indeed sometimes see resume_stopped_resumed_lwps
fail in the registers read:
resume_stopped_resumed_lwps (struct lwp_info *lp, void *data)
{
...
CORE_ADDR pc = regcache_read_pc (regcache);
Or e.g., in 32-bit mode, i386_linux_resume has several calls that can
throw too.
Whether to ignore ptrace errors or not depends on context that is only
available somewhere up the call chain. So the fix is to let ptrace
errors throw as they do today, and wrap the resume request in a
TRY/CATCH that swallows it iff the lwp that we were trying to resume
is no longer ptrace-stopped.
gdb/gdbserver/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
gdb/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
(resume_stopped_resumed_lwps): Try register reads in TRY/CATCH and
swallows errors if the LWP is gone. Use
linux_resume_one_lwp_throw instead of linux_resume_one_lwp.
2015-03-19 16:12:33 +01:00
|
|
|
|
/* Don't bother if there's a breakpoint at PC that we'd hit
|
|
|
|
|
immediately, and we're not waiting for this LWP. */
|
|
|
|
|
if (!ptid_match (lp->ptid, *wait_ptid_p))
|
|
|
|
|
{
|
2017-11-02 16:15:41 +01:00
|
|
|
|
if (breakpoint_inserted_here_p (regcache->aspace (), pc))
|
Fix race exposed by gdb.threads/killed.exp
On GNU/Linux, this test sometimes FAILs like this:
(gdb) run
Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
ptrace: No such process.
(gdb)
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
Note the suspicious "No such process" line (that's errno==ESRCH).
Adding debug output we see:
linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Stopped (signal) (stopped)
LNW: waitpid(-1, ...) returned 18461, ERRNO-OK
LLW: waitpid 18461 received Trace/breakpoint trap (stopped)
LLW: Handling extended status 0x03057f
LHEW: Got clone event from LWP 18461, new child is LWP 18465
LNW: waitpid(-1, ...) returned 0, ERRNO-OK
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
sigchld
ptrace: No such process.
(gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Killed (terminated)
LLW: LWP 18465 exited.
LNW: waitpid(-1, ...) returned 18461, No child processes
LLW: waitpid 18461 received Killed (terminated)
Process 18461 exited
LNW: waitpid(-1, ...) returned -1, No child processes
LLW: exit
sigchld
infrun: target_wait (-1, status) =
infrun: 18461 [process 18461],
infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL
infrun: TARGET_WAITKIND_SIGNALLED
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
infrun: stop_waiting
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
The issue is that here:
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
The first line shows we had just resumed LWP 18465, which does:
void *
child_func (void *dummy)
{
kill (pid, SIGKILL);
exit (1);
}
So if the kernel manages to schedule that thread fast enough, the
process may be killed before GDB has a chance to resume LWP 18461.
GDBserver has code at the tail end of linux_resume_one_lwp to cope
with this:
~~~
ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread),
(PTRACE_TYPE_ARG3) 0,
/* Coerce to a uintptr_t first to avoid potential gcc warning
of coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG4) (uintptr_t) signal);
current_thread = saved_thread;
if (errno)
{
/* ESRCH from ptrace either means that the thread was already
running (an error) or that it is gone (a race condition). If
it's gone, we will get a notification the next time we wait,
so we can ignore the error. We could differentiate these
two, but it's tricky without waiting; the thread still exists
as a zombie, so sending it signal 0 would succeed. So just
ignore ESRCH. */
if (errno == ESRCH)
return;
perror_with_name ("ptrace");
}
~~~
However, that's not a complete fix, because between starting to handle
the resume request and getting that PTRACE_CONTINUE, we run other
ptrace calls that can also fail with ESRCH, and that end up throwing
an error (with perror_with_name).
In the case above, I indeed sometimes see resume_stopped_resumed_lwps
fail in the registers read:
resume_stopped_resumed_lwps (struct lwp_info *lp, void *data)
{
...
CORE_ADDR pc = regcache_read_pc (regcache);
Or e.g., in 32-bit mode, i386_linux_resume has several calls that can
throw too.
Whether to ignore ptrace errors or not depends on context that is only
available somewhere up the call chain. So the fix is to let ptrace
errors throw as they do today, and wrap the resume request in a
TRY/CATCH that swallows it iff the lwp that we were trying to resume
is no longer ptrace-stopped.
gdb/gdbserver/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
gdb/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
(resume_stopped_resumed_lwps): Try register reads in TRY/CATCH and
swallows errors if the LWP is gone. Use
linux_resume_one_lwp_throw instead of linux_resume_one_lwp.
2015-03-19 16:12:33 +01:00
|
|
|
|
leave_stopped = 1;
|
|
|
|
|
}
|
2010-02-08 16:44:09 +01:00
|
|
|
|
|
Fix race exposed by gdb.threads/killed.exp
On GNU/Linux, this test sometimes FAILs like this:
(gdb) run
Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
ptrace: No such process.
(gdb)
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
Note the suspicious "No such process" line (that's errno==ESRCH).
Adding debug output we see:
linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Stopped (signal) (stopped)
LNW: waitpid(-1, ...) returned 18461, ERRNO-OK
LLW: waitpid 18461 received Trace/breakpoint trap (stopped)
LLW: Handling extended status 0x03057f
LHEW: Got clone event from LWP 18461, new child is LWP 18465
LNW: waitpid(-1, ...) returned 0, ERRNO-OK
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
sigchld
ptrace: No such process.
(gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG]
LLW: enter
LNW: waitpid(-1, ...) returned 18465, ERRNO-OK
LLW: waitpid 18465 received Killed (terminated)
LLW: LWP 18465 exited.
LNW: waitpid(-1, ...) returned 18461, No child processes
LLW: waitpid 18461 received Killed (terminated)
Process 18461 exited
LNW: waitpid(-1, ...) returned -1, No child processes
LLW: exit
sigchld
infrun: target_wait (-1, status) =
infrun: 18461 [process 18461],
infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL
infrun: TARGET_WAITKIND_SIGNALLED
Program terminated with signal SIGKILL, Killed.
The program no longer exists.
infrun: stop_waiting
FAIL: gdb.threads/killed.exp: run program to completion (timeout)
The issue is that here:
RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0
RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0
The first line shows we had just resumed LWP 18465, which does:
void *
child_func (void *dummy)
{
kill (pid, SIGKILL);
exit (1);
}
So if the kernel manages to schedule that thread fast enough, the
process may be killed before GDB has a chance to resume LWP 18461.
GDBserver has code at the tail end of linux_resume_one_lwp to cope
with this:
~~~
ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread),
(PTRACE_TYPE_ARG3) 0,
/* Coerce to a uintptr_t first to avoid potential gcc warning
of coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG4) (uintptr_t) signal);
current_thread = saved_thread;
if (errno)
{
/* ESRCH from ptrace either means that the thread was already
running (an error) or that it is gone (a race condition). If
it's gone, we will get a notification the next time we wait,
so we can ignore the error. We could differentiate these
two, but it's tricky without waiting; the thread still exists
as a zombie, so sending it signal 0 would succeed. So just
ignore ESRCH. */
if (errno == ESRCH)
return;
perror_with_name ("ptrace");
}
~~~
However, that's not a complete fix, because between starting to handle
the resume request and getting that PTRACE_CONTINUE, we run other
ptrace calls that can also fail with ESRCH, and that end up throwing
an error (with perror_with_name).
In the case above, I indeed sometimes see resume_stopped_resumed_lwps
fail in the registers read:
resume_stopped_resumed_lwps (struct lwp_info *lp, void *data)
{
...
CORE_ADDR pc = regcache_read_pc (regcache);
Or e.g., in 32-bit mode, i386_linux_resume has several calls that can
throw too.
Whether to ignore ptrace errors or not depends on context that is only
available somewhere up the call chain. So the fix is to let ptrace
errors throw as they do today, and wrap the resume request in a
TRY/CATCH that swallows it iff the lwp that we were trying to resume
is no longer ptrace-stopped.
gdb/gdbserver/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
gdb/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_resume_one_lwp): Rename to ...
(linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here,
instead call perror_with_name.
(check_ptrace_stopped_lwp_gone): New function.
(linux_resume_one_lwp): Reimplement as wrapper around
linux_resume_one_lwp_throw that swallows errors if the LWP is
gone.
(resume_stopped_resumed_lwps): Try register reads in TRY/CATCH and
swallows errors if the LWP is gone. Use
linux_resume_one_lwp_throw instead of linux_resume_one_lwp.
2015-03-19 16:12:33 +01:00
|
|
|
|
if (!leave_stopped)
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"RSRL: resuming stopped-resumed LWP %s at "
|
|
|
|
|
"%s: step=%d\n",
|
|
|
|
|
target_pid_to_str (lp->ptid),
|
|
|
|
|
paddress (gdbarch, pc),
|
|
|
|
|
lp->step);
|
|
|
|
|
|
|
|
|
|
linux_resume_one_lwp_throw (lp, lp->step, GDB_SIGNAL_0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CATCH (ex, RETURN_MASK_ERROR)
|
|
|
|
|
{
|
|
|
|
|
if (!check_ptrace_stopped_lwp_gone (lp))
|
|
|
|
|
throw_exception (ex);
|
|
|
|
|
}
|
|
|
|
|
END_CATCH
|
2010-02-08 16:44:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
static ptid_t
|
|
|
|
|
linux_nat_wait (struct target_ops *ops,
|
2009-05-21 17:48:42 +02:00
|
|
|
|
ptid_t ptid, struct target_waitstatus *ourstatus,
|
|
|
|
|
int target_options)
|
2009-05-11 14:08:03 +02:00
|
|
|
|
{
|
|
|
|
|
ptid_t event_ptid;
|
|
|
|
|
|
|
|
|
|
if (debug_linux_nat)
|
2012-07-20 18:57:32 +02:00
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
2009-05-11 14:08:03 +02:00
|
|
|
|
|
|
|
|
|
/* Flush the async file first. */
|
2015-02-03 16:07:53 +01:00
|
|
|
|
if (target_is_async_p ())
|
2009-05-11 14:08:03 +02:00
|
|
|
|
async_file_flush ();
|
|
|
|
|
|
2010-02-08 16:44:09 +01:00
|
|
|
|
/* Resume LWPs that are currently stopped without any pending status
|
|
|
|
|
to report, but are resumed from the core's perspective. LWPs get
|
|
|
|
|
in this state if we find them stopping at a time we're not
|
|
|
|
|
interested in reporting the event (target_wait on a
|
|
|
|
|
specific_process, for example, see linux_nat_wait_1), and
|
|
|
|
|
meanwhile the event became uninteresting. Don't bother resuming
|
|
|
|
|
LWPs we're not going to wait for if they'd stop immediately. */
|
Implement all-stop on top of a target running non-stop mode
This finally implements user-visible all-stop mode running with the
target_ops backend always in non-stop mode. This is a stepping stone
towards finer-grained control of threads, being able to do interesting
things like thread groups, associating groups with breakpoints, etc.
From the user's perspective, all-stop mode is really just a special
case of being able to stop and resume specific sets of threads, so it
makes sense to do this step first.
With this, even in all-stop, the target is no longer in charge of
stopping all threads before reporting an event to the core -- the core
takes care of it when it sees fit. For example, when "next"- or
"step"-ing, we can avoid stopping and resuming all threads at each
internal single-step, and instead only stop all threads when we're
about to present the stop to the user.
The implementation is almost straight forward, as the heavy lifting
has been done already in previous patches. Basically, we replace
checks for "set non-stop on/off" (the non_stop global), with calls to
a new target_is_non_stop_p function. In a few places, if "set
non-stop off", we stop all threads explicitly, and in a few other
places we resume all threads explicitly, making use of existing
methods that were added for teaching non-stop to step over breakpoints
without displaced stepping.
This adds a new "maint set target-non-stop on/off/auto" knob that
allows both disabling the feature if we find problems, and
force-enable it for development (useful when teaching a target about
this. The default is "auto", which means the feature is enabled if a
new target method says it should be enabled. The patch implements the
method in linux-nat.c, just for illustration, because it still returns
false. We'll need a few follow up fixes before turning it on by
default. This is a separate target method from indicating regular
non-stop support, because e.g., while e.g., native linux-nat.c is
close to regression free with all-stop-non-stop (with following
patches will fixing the remaining regressions), remote.c+gdbserver
will still need more fixing, even though it supports "set non-stop
on".
Tested on x86_64 Fedora 20, native, with and without "set displaced
off", and with and without "maint set target-non-stop on"; and also
against gdbserver.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* NEWS: Mention "maint set/show target-non-stop".
* breakpoint.c (update_global_location_list): Check
target_is_non_stop_p instead of non_stop.
* infcmd.c (attach_command_post_wait, attach_command): Likewise.
* infrun.c (show_can_use_displaced_stepping)
(can_use_displaced_stepping_p, start_step_over_inferior):
Likewise.
(internal_resume_ptid): New function.
(resume): Use it.
(proceed): Check target_is_non_stop_p instead of non_stop. If in
all-stop mode but the target is always in non-stop mode, start all
the other threads that are implicitly resumed too.
(for_each_just_stopped_thread, fetch_inferior_event)
(adjust_pc_after_break, stop_all_threads): Check
target_is_non_stop_p instead of non_stop.
(handle_inferior_event): Likewise. Handle detach-fork in all-stop
with the target always in non-stop mode.
(handle_signal_stop) <random signal>: Check target_is_non_stop_p
instead of non_stop.
(switch_back_to_stepped_thread): Check target_is_non_stop_p
instead of non_stop.
(keep_going_stepped_thread): Use internal_resume_ptid.
(stop_waiting): If in all-stop mode, and the target is in non-stop
mode, stop all threads.
(keep_going_pass): Likewise, when starting a new in-line step-over
sequence.
* linux-nat.c (get_pending_status, select_event_lwp)
(linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check
target_is_non_stop_p instead of non_stop.
(linux_nat_always_non_stop_p): New function.
(linux_nat_stop): Check target_is_non_stop_p instead of non_stop.
(linux_nat_add_target): Install linux_nat_always_non_stop_p.
* target-delegates.c: Regenerate.
* target.c (target_is_non_stop_p): New function.
(target_non_stop_enabled, target_non_stop_enabled_1): New globals.
(maint_set_target_non_stop_command)
(maint_show_target_non_stop_command): New functions.
(_initilize_target): Install "maint set/show target-non-stop"
commands.
* target.h (struct target_ops) <to_always_non_stop_p>: New field.
(target_non_stop_enabled): New declaration.
(target_is_non_stop_p): New declaration.
gdb/doc/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
target-non-stop".
2015-08-07 18:24:01 +02:00
|
|
|
|
if (target_is_non_stop_p ())
|
2010-02-08 16:44:09 +01:00
|
|
|
|
iterate_over_lwps (minus_one_ptid, resume_stopped_resumed_lwps, &ptid);
|
|
|
|
|
|
2009-05-21 17:48:42 +02:00
|
|
|
|
event_ptid = linux_nat_wait_1 (ops, ptid, ourstatus, target_options);
|
2009-05-11 14:08:03 +02:00
|
|
|
|
|
|
|
|
|
/* If we requested any event, and something came out, assume there
|
|
|
|
|
may be more. If we requested a specific lwp or process, also
|
|
|
|
|
assume there may be more. */
|
2015-02-03 16:07:53 +01:00
|
|
|
|
if (target_is_async_p ()
|
2011-11-10 21:17:52 +01:00
|
|
|
|
&& ((ourstatus->kind != TARGET_WAITKIND_IGNORE
|
|
|
|
|
&& ourstatus->kind != TARGET_WAITKIND_NO_RESUMED)
|
2009-05-11 14:08:03 +02:00
|
|
|
|
|| !ptid_equal (ptid, minus_one_ptid)))
|
|
|
|
|
async_file_mark ();
|
|
|
|
|
|
|
|
|
|
return event_ptid;
|
|
|
|
|
}
|
|
|
|
|
|
Fix PR 19494: hang when killing unfollowed fork children
linux_nat_kill relies on get_last_target_status to determine whether
the current inferior is stopped at a unfollowed fork/vfork event.
This is bad because many things can happen ever since we caught the
fork/vfork event... This commit rewrites that code to instead walk
the thread list looking for unfollowed fork events, similarly to what
was done for remote.c.
New test included. The main idea of the test is make sure that when
the program stops for a fork catchpoint, and the user kills the
parent, gdb also kills the unfollowed fork child. Since the child
hasn't been added as an inferior at that point, we need some other
portable way to detect that the child is gone. The test uses a pipe
for that. The program forks twice, so you have grandparent, child and
grandchild. The grandchild inherits the write side of the pipe. The
grandparent hangs reading from the pipe, since nothing ever writes to
it. If, when GDB kills the child, it also kills the grandchild, then
the grandparent's pipe read returns 0/EOF and the test passes.
Otherwise, if GDB doesn't kill the grandchild, then the pipe read
never returns and the test times out, like:
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork: kill parent (timeout)
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill: vfork: kill parent (timeout)
No regressions on x86_64 Fedora 20. New test passes with gdbserver as
well.
gdb/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* linux-nat.c (kill_one_lwp): New, factored out from ...
(kill_callback): ... this.
(kill_wait_callback): New, factored out from ...
(kill_wait_one_lwp): ... this.
(kill_unfollowed_fork_children): New function.
(linux_nat_kill): Use it.
gdb/testsuite/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* gdb.base/catch-fork-kill.c: New file.
* gdb.base/catch-fork-kill.exp: New file.
2016-01-25 13:00:20 +01:00
|
|
|
|
/* Kill one LWP. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
kill_one_lwp (pid_t pid)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
2011-05-18 20:03:30 +02:00
|
|
|
|
/* PTRACE_KILL may resume the inferior. Send SIGKILL first. */
|
|
|
|
|
|
|
|
|
|
errno = 0;
|
Fix PR 19494: hang when killing unfollowed fork children
linux_nat_kill relies on get_last_target_status to determine whether
the current inferior is stopped at a unfollowed fork/vfork event.
This is bad because many things can happen ever since we caught the
fork/vfork event... This commit rewrites that code to instead walk
the thread list looking for unfollowed fork events, similarly to what
was done for remote.c.
New test included. The main idea of the test is make sure that when
the program stops for a fork catchpoint, and the user kills the
parent, gdb also kills the unfollowed fork child. Since the child
hasn't been added as an inferior at that point, we need some other
portable way to detect that the child is gone. The test uses a pipe
for that. The program forks twice, so you have grandparent, child and
grandchild. The grandchild inherits the write side of the pipe. The
grandparent hangs reading from the pipe, since nothing ever writes to
it. If, when GDB kills the child, it also kills the grandchild, then
the grandparent's pipe read returns 0/EOF and the test passes.
Otherwise, if GDB doesn't kill the grandchild, then the pipe read
never returns and the test times out, like:
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork: kill parent (timeout)
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill: vfork: kill parent (timeout)
No regressions on x86_64 Fedora 20. New test passes with gdbserver as
well.
gdb/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* linux-nat.c (kill_one_lwp): New, factored out from ...
(kill_callback): ... this.
(kill_wait_callback): New, factored out from ...
(kill_wait_one_lwp): ... this.
(kill_unfollowed_fork_children): New function.
(linux_nat_kill): Use it.
gdb/testsuite/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* gdb.base/catch-fork-kill.c: New file.
* gdb.base/catch-fork-kill.exp: New file.
2016-01-25 13:00:20 +01:00
|
|
|
|
kill_lwp (pid, SIGKILL);
|
2011-05-18 20:03:30 +02:00
|
|
|
|
if (debug_linux_nat)
|
2014-07-15 17:22:14 +02:00
|
|
|
|
{
|
|
|
|
|
int save_errno = errno;
|
|
|
|
|
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
Fix PR 19494: hang when killing unfollowed fork children
linux_nat_kill relies on get_last_target_status to determine whether
the current inferior is stopped at a unfollowed fork/vfork event.
This is bad because many things can happen ever since we caught the
fork/vfork event... This commit rewrites that code to instead walk
the thread list looking for unfollowed fork events, similarly to what
was done for remote.c.
New test included. The main idea of the test is make sure that when
the program stops for a fork catchpoint, and the user kills the
parent, gdb also kills the unfollowed fork child. Since the child
hasn't been added as an inferior at that point, we need some other
portable way to detect that the child is gone. The test uses a pipe
for that. The program forks twice, so you have grandparent, child and
grandchild. The grandchild inherits the write side of the pipe. The
grandparent hangs reading from the pipe, since nothing ever writes to
it. If, when GDB kills the child, it also kills the grandchild, then
the grandparent's pipe read returns 0/EOF and the test passes.
Otherwise, if GDB doesn't kill the grandchild, then the pipe read
never returns and the test times out, like:
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork: kill parent (timeout)
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill: vfork: kill parent (timeout)
No regressions on x86_64 Fedora 20. New test passes with gdbserver as
well.
gdb/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* linux-nat.c (kill_one_lwp): New, factored out from ...
(kill_callback): ... this.
(kill_wait_callback): New, factored out from ...
(kill_wait_one_lwp): ... this.
(kill_unfollowed_fork_children): New function.
(linux_nat_kill): Use it.
gdb/testsuite/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* gdb.base/catch-fork-kill.c: New file.
* gdb.base/catch-fork-kill.exp: New file.
2016-01-25 13:00:20 +01:00
|
|
|
|
"KC: kill (SIGKILL) %ld, 0, 0 (%s)\n", (long) pid,
|
2014-07-15 17:22:14 +02:00
|
|
|
|
save_errno ? safe_strerror (save_errno) : "OK");
|
|
|
|
|
}
|
2011-05-18 20:03:30 +02:00
|
|
|
|
|
|
|
|
|
/* Some kernels ignore even SIGKILL for processes under ptrace. */
|
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
errno = 0;
|
Fix PR 19494: hang when killing unfollowed fork children
linux_nat_kill relies on get_last_target_status to determine whether
the current inferior is stopped at a unfollowed fork/vfork event.
This is bad because many things can happen ever since we caught the
fork/vfork event... This commit rewrites that code to instead walk
the thread list looking for unfollowed fork events, similarly to what
was done for remote.c.
New test included. The main idea of the test is make sure that when
the program stops for a fork catchpoint, and the user kills the
parent, gdb also kills the unfollowed fork child. Since the child
hasn't been added as an inferior at that point, we need some other
portable way to detect that the child is gone. The test uses a pipe
for that. The program forks twice, so you have grandparent, child and
grandchild. The grandchild inherits the write side of the pipe. The
grandparent hangs reading from the pipe, since nothing ever writes to
it. If, when GDB kills the child, it also kills the grandchild, then
the grandparent's pipe read returns 0/EOF and the test passes.
Otherwise, if GDB doesn't kill the grandchild, then the pipe read
never returns and the test times out, like:
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork: kill parent (timeout)
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill: vfork: kill parent (timeout)
No regressions on x86_64 Fedora 20. New test passes with gdbserver as
well.
gdb/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* linux-nat.c (kill_one_lwp): New, factored out from ...
(kill_callback): ... this.
(kill_wait_callback): New, factored out from ...
(kill_wait_one_lwp): ... this.
(kill_unfollowed_fork_children): New function.
(linux_nat_kill): Use it.
gdb/testsuite/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* gdb.base/catch-fork-kill.c: New file.
* gdb.base/catch-fork-kill.exp: New file.
2016-01-25 13:00:20 +01:00
|
|
|
|
ptrace (PTRACE_KILL, pid, 0, 0);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
if (debug_linux_nat)
|
2014-07-15 17:22:14 +02:00
|
|
|
|
{
|
|
|
|
|
int save_errno = errno;
|
|
|
|
|
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
Fix PR 19494: hang when killing unfollowed fork children
linux_nat_kill relies on get_last_target_status to determine whether
the current inferior is stopped at a unfollowed fork/vfork event.
This is bad because many things can happen ever since we caught the
fork/vfork event... This commit rewrites that code to instead walk
the thread list looking for unfollowed fork events, similarly to what
was done for remote.c.
New test included. The main idea of the test is make sure that when
the program stops for a fork catchpoint, and the user kills the
parent, gdb also kills the unfollowed fork child. Since the child
hasn't been added as an inferior at that point, we need some other
portable way to detect that the child is gone. The test uses a pipe
for that. The program forks twice, so you have grandparent, child and
grandchild. The grandchild inherits the write side of the pipe. The
grandparent hangs reading from the pipe, since nothing ever writes to
it. If, when GDB kills the child, it also kills the grandchild, then
the grandparent's pipe read returns 0/EOF and the test passes.
Otherwise, if GDB doesn't kill the grandchild, then the pipe read
never returns and the test times out, like:
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork: kill parent (timeout)
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill: vfork: kill parent (timeout)
No regressions on x86_64 Fedora 20. New test passes with gdbserver as
well.
gdb/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* linux-nat.c (kill_one_lwp): New, factored out from ...
(kill_callback): ... this.
(kill_wait_callback): New, factored out from ...
(kill_wait_one_lwp): ... this.
(kill_unfollowed_fork_children): New function.
(linux_nat_kill): Use it.
gdb/testsuite/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* gdb.base/catch-fork-kill.c: New file.
* gdb.base/catch-fork-kill.exp: New file.
2016-01-25 13:00:20 +01:00
|
|
|
|
"KC: PTRACE_KILL %ld, 0, 0 (%s)\n", (long) pid,
|
2014-07-15 17:22:14 +02:00
|
|
|
|
save_errno ? safe_strerror (save_errno) : "OK");
|
|
|
|
|
}
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
Fix PR 19494: hang when killing unfollowed fork children
linux_nat_kill relies on get_last_target_status to determine whether
the current inferior is stopped at a unfollowed fork/vfork event.
This is bad because many things can happen ever since we caught the
fork/vfork event... This commit rewrites that code to instead walk
the thread list looking for unfollowed fork events, similarly to what
was done for remote.c.
New test included. The main idea of the test is make sure that when
the program stops for a fork catchpoint, and the user kills the
parent, gdb also kills the unfollowed fork child. Since the child
hasn't been added as an inferior at that point, we need some other
portable way to detect that the child is gone. The test uses a pipe
for that. The program forks twice, so you have grandparent, child and
grandchild. The grandchild inherits the write side of the pipe. The
grandparent hangs reading from the pipe, since nothing ever writes to
it. If, when GDB kills the child, it also kills the grandchild, then
the grandparent's pipe read returns 0/EOF and the test passes.
Otherwise, if GDB doesn't kill the grandchild, then the pipe read
never returns and the test times out, like:
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork: kill parent (timeout)
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill: vfork: kill parent (timeout)
No regressions on x86_64 Fedora 20. New test passes with gdbserver as
well.
gdb/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* linux-nat.c (kill_one_lwp): New, factored out from ...
(kill_callback): ... this.
(kill_wait_callback): New, factored out from ...
(kill_wait_one_lwp): ... this.
(kill_unfollowed_fork_children): New function.
(linux_nat_kill): Use it.
gdb/testsuite/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* gdb.base/catch-fork-kill.c: New file.
* gdb.base/catch-fork-kill.exp: New file.
2016-01-25 13:00:20 +01:00
|
|
|
|
/* Wait for an LWP to die. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
kill_wait_one_lwp (pid_t pid)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
Fix PR 19494: hang when killing unfollowed fork children
linux_nat_kill relies on get_last_target_status to determine whether
the current inferior is stopped at a unfollowed fork/vfork event.
This is bad because many things can happen ever since we caught the
fork/vfork event... This commit rewrites that code to instead walk
the thread list looking for unfollowed fork events, similarly to what
was done for remote.c.
New test included. The main idea of the test is make sure that when
the program stops for a fork catchpoint, and the user kills the
parent, gdb also kills the unfollowed fork child. Since the child
hasn't been added as an inferior at that point, we need some other
portable way to detect that the child is gone. The test uses a pipe
for that. The program forks twice, so you have grandparent, child and
grandchild. The grandchild inherits the write side of the pipe. The
grandparent hangs reading from the pipe, since nothing ever writes to
it. If, when GDB kills the child, it also kills the grandchild, then
the grandparent's pipe read returns 0/EOF and the test passes.
Otherwise, if GDB doesn't kill the grandchild, then the pipe read
never returns and the test times out, like:
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork: kill parent (timeout)
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill: vfork: kill parent (timeout)
No regressions on x86_64 Fedora 20. New test passes with gdbserver as
well.
gdb/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* linux-nat.c (kill_one_lwp): New, factored out from ...
(kill_callback): ... this.
(kill_wait_callback): New, factored out from ...
(kill_wait_one_lwp): ... this.
(kill_unfollowed_fork_children): New function.
(linux_nat_kill): Use it.
gdb/testsuite/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* gdb.base/catch-fork-kill.c: New file.
* gdb.base/catch-fork-kill.exp: New file.
2016-01-25 13:00:20 +01:00
|
|
|
|
pid_t res;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
/* We must make sure that there are no pending events (delayed
|
|
|
|
|
SIGSTOPs, pending SIGTRAPs, etc.) to make sure the current
|
|
|
|
|
program doesn't interfere with any following debugging session. */
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
Fix PR 19494: hang when killing unfollowed fork children
linux_nat_kill relies on get_last_target_status to determine whether
the current inferior is stopped at a unfollowed fork/vfork event.
This is bad because many things can happen ever since we caught the
fork/vfork event... This commit rewrites that code to instead walk
the thread list looking for unfollowed fork events, similarly to what
was done for remote.c.
New test included. The main idea of the test is make sure that when
the program stops for a fork catchpoint, and the user kills the
parent, gdb also kills the unfollowed fork child. Since the child
hasn't been added as an inferior at that point, we need some other
portable way to detect that the child is gone. The test uses a pipe
for that. The program forks twice, so you have grandparent, child and
grandchild. The grandchild inherits the write side of the pipe. The
grandparent hangs reading from the pipe, since nothing ever writes to
it. If, when GDB kills the child, it also kills the grandchild, then
the grandparent's pipe read returns 0/EOF and the test passes.
Otherwise, if GDB doesn't kill the grandchild, then the pipe read
never returns and the test times out, like:
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork: kill parent (timeout)
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill: vfork: kill parent (timeout)
No regressions on x86_64 Fedora 20. New test passes with gdbserver as
well.
gdb/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* linux-nat.c (kill_one_lwp): New, factored out from ...
(kill_callback): ... this.
(kill_wait_callback): New, factored out from ...
(kill_wait_one_lwp): ... this.
(kill_unfollowed_fork_children): New function.
(linux_nat_kill): Use it.
gdb/testsuite/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* gdb.base/catch-fork-kill.c: New file.
* gdb.base/catch-fork-kill.exp: New file.
2016-01-25 13:00:20 +01:00
|
|
|
|
res = my_waitpid (pid, NULL, __WALL);
|
|
|
|
|
if (res != (pid_t) -1)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
2008-01-29 23:47:20 +01:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
Fix PR 19494: hang when killing unfollowed fork children
linux_nat_kill relies on get_last_target_status to determine whether
the current inferior is stopped at a unfollowed fork/vfork event.
This is bad because many things can happen ever since we caught the
fork/vfork event... This commit rewrites that code to instead walk
the thread list looking for unfollowed fork events, similarly to what
was done for remote.c.
New test included. The main idea of the test is make sure that when
the program stops for a fork catchpoint, and the user kills the
parent, gdb also kills the unfollowed fork child. Since the child
hasn't been added as an inferior at that point, we need some other
portable way to detect that the child is gone. The test uses a pipe
for that. The program forks twice, so you have grandparent, child and
grandchild. The grandchild inherits the write side of the pipe. The
grandparent hangs reading from the pipe, since nothing ever writes to
it. If, when GDB kills the child, it also kills the grandchild, then
the grandparent's pipe read returns 0/EOF and the test passes.
Otherwise, if GDB doesn't kill the grandchild, then the pipe read
never returns and the test times out, like:
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork: kill parent (timeout)
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill: vfork: kill parent (timeout)
No regressions on x86_64 Fedora 20. New test passes with gdbserver as
well.
gdb/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* linux-nat.c (kill_one_lwp): New, factored out from ...
(kill_callback): ... this.
(kill_wait_callback): New, factored out from ...
(kill_wait_one_lwp): ... this.
(kill_unfollowed_fork_children): New function.
(linux_nat_kill): Use it.
gdb/testsuite/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* gdb.base/catch-fork-kill.c: New file.
* gdb.base/catch-fork-kill.exp: New file.
2016-01-25 13:00:20 +01:00
|
|
|
|
"KWC: wait %ld received unknown.\n",
|
|
|
|
|
(long) pid);
|
2015-12-17 15:20:51 +01:00
|
|
|
|
/* The Linux kernel sometimes fails to kill a thread
|
|
|
|
|
completely after PTRACE_KILL; that goes from the stop
|
|
|
|
|
point in do_fork out to the one in get_signal_to_deliver
|
|
|
|
|
and waits again. So kill it again. */
|
Fix PR 19494: hang when killing unfollowed fork children
linux_nat_kill relies on get_last_target_status to determine whether
the current inferior is stopped at a unfollowed fork/vfork event.
This is bad because many things can happen ever since we caught the
fork/vfork event... This commit rewrites that code to instead walk
the thread list looking for unfollowed fork events, similarly to what
was done for remote.c.
New test included. The main idea of the test is make sure that when
the program stops for a fork catchpoint, and the user kills the
parent, gdb also kills the unfollowed fork child. Since the child
hasn't been added as an inferior at that point, we need some other
portable way to detect that the child is gone. The test uses a pipe
for that. The program forks twice, so you have grandparent, child and
grandchild. The grandchild inherits the write side of the pipe. The
grandparent hangs reading from the pipe, since nothing ever writes to
it. If, when GDB kills the child, it also kills the grandchild, then
the grandparent's pipe read returns 0/EOF and the test passes.
Otherwise, if GDB doesn't kill the grandchild, then the pipe read
never returns and the test times out, like:
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork: kill parent (timeout)
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill: vfork: kill parent (timeout)
No regressions on x86_64 Fedora 20. New test passes with gdbserver as
well.
gdb/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* linux-nat.c (kill_one_lwp): New, factored out from ...
(kill_callback): ... this.
(kill_wait_callback): New, factored out from ...
(kill_wait_one_lwp): ... this.
(kill_unfollowed_fork_children): New function.
(linux_nat_kill): Use it.
gdb/testsuite/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* gdb.base/catch-fork-kill.c: New file.
* gdb.base/catch-fork-kill.exp: New file.
2016-01-25 13:00:20 +01:00
|
|
|
|
kill_one_lwp (pid);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
Fix PR 19494: hang when killing unfollowed fork children
linux_nat_kill relies on get_last_target_status to determine whether
the current inferior is stopped at a unfollowed fork/vfork event.
This is bad because many things can happen ever since we caught the
fork/vfork event... This commit rewrites that code to instead walk
the thread list looking for unfollowed fork events, similarly to what
was done for remote.c.
New test included. The main idea of the test is make sure that when
the program stops for a fork catchpoint, and the user kills the
parent, gdb also kills the unfollowed fork child. Since the child
hasn't been added as an inferior at that point, we need some other
portable way to detect that the child is gone. The test uses a pipe
for that. The program forks twice, so you have grandparent, child and
grandchild. The grandchild inherits the write side of the pipe. The
grandparent hangs reading from the pipe, since nothing ever writes to
it. If, when GDB kills the child, it also kills the grandchild, then
the grandparent's pipe read returns 0/EOF and the test passes.
Otherwise, if GDB doesn't kill the grandchild, then the pipe read
never returns and the test times out, like:
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork: kill parent (timeout)
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill: vfork: kill parent (timeout)
No regressions on x86_64 Fedora 20. New test passes with gdbserver as
well.
gdb/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* linux-nat.c (kill_one_lwp): New, factored out from ...
(kill_callback): ... this.
(kill_wait_callback): New, factored out from ...
(kill_wait_one_lwp): ... this.
(kill_unfollowed_fork_children): New function.
(linux_nat_kill): Use it.
gdb/testsuite/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* gdb.base/catch-fork-kill.c: New file.
* gdb.base/catch-fork-kill.exp: New file.
2016-01-25 13:00:20 +01:00
|
|
|
|
while (res == pid);
|
|
|
|
|
|
|
|
|
|
gdb_assert (res == -1 && errno == ECHILD);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback for iterate_over_lwps. */
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
Fix PR 19494: hang when killing unfollowed fork children
linux_nat_kill relies on get_last_target_status to determine whether
the current inferior is stopped at a unfollowed fork/vfork event.
This is bad because many things can happen ever since we caught the
fork/vfork event... This commit rewrites that code to instead walk
the thread list looking for unfollowed fork events, similarly to what
was done for remote.c.
New test included. The main idea of the test is make sure that when
the program stops for a fork catchpoint, and the user kills the
parent, gdb also kills the unfollowed fork child. Since the child
hasn't been added as an inferior at that point, we need some other
portable way to detect that the child is gone. The test uses a pipe
for that. The program forks twice, so you have grandparent, child and
grandchild. The grandchild inherits the write side of the pipe. The
grandparent hangs reading from the pipe, since nothing ever writes to
it. If, when GDB kills the child, it also kills the grandchild, then
the grandparent's pipe read returns 0/EOF and the test passes.
Otherwise, if GDB doesn't kill the grandchild, then the pipe read
never returns and the test times out, like:
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork: kill parent (timeout)
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill: vfork: kill parent (timeout)
No regressions on x86_64 Fedora 20. New test passes with gdbserver as
well.
gdb/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* linux-nat.c (kill_one_lwp): New, factored out from ...
(kill_callback): ... this.
(kill_wait_callback): New, factored out from ...
(kill_wait_one_lwp): ... this.
(kill_unfollowed_fork_children): New function.
(linux_nat_kill): Use it.
gdb/testsuite/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* gdb.base/catch-fork-kill.c: New file.
* gdb.base/catch-fork-kill.exp: New file.
2016-01-25 13:00:20 +01:00
|
|
|
|
static int
|
|
|
|
|
kill_callback (struct lwp_info *lp, void *data)
|
|
|
|
|
{
|
|
|
|
|
kill_one_lwp (ptid_get_lwp (lp->ptid));
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
Fix PR 19494: hang when killing unfollowed fork children
linux_nat_kill relies on get_last_target_status to determine whether
the current inferior is stopped at a unfollowed fork/vfork event.
This is bad because many things can happen ever since we caught the
fork/vfork event... This commit rewrites that code to instead walk
the thread list looking for unfollowed fork events, similarly to what
was done for remote.c.
New test included. The main idea of the test is make sure that when
the program stops for a fork catchpoint, and the user kills the
parent, gdb also kills the unfollowed fork child. Since the child
hasn't been added as an inferior at that point, we need some other
portable way to detect that the child is gone. The test uses a pipe
for that. The program forks twice, so you have grandparent, child and
grandchild. The grandchild inherits the write side of the pipe. The
grandparent hangs reading from the pipe, since nothing ever writes to
it. If, when GDB kills the child, it also kills the grandchild, then
the grandparent's pipe read returns 0/EOF and the test passes.
Otherwise, if GDB doesn't kill the grandchild, then the pipe read
never returns and the test times out, like:
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork: kill parent (timeout)
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill: vfork: kill parent (timeout)
No regressions on x86_64 Fedora 20. New test passes with gdbserver as
well.
gdb/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* linux-nat.c (kill_one_lwp): New, factored out from ...
(kill_callback): ... this.
(kill_wait_callback): New, factored out from ...
(kill_wait_one_lwp): ... this.
(kill_unfollowed_fork_children): New function.
(linux_nat_kill): Use it.
gdb/testsuite/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* gdb.base/catch-fork-kill.c: New file.
* gdb.base/catch-fork-kill.exp: New file.
2016-01-25 13:00:20 +01:00
|
|
|
|
/* Callback for iterate_over_lwps. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
kill_wait_callback (struct lwp_info *lp, void *data)
|
|
|
|
|
{
|
|
|
|
|
kill_wait_one_lwp (ptid_get_lwp (lp->ptid));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Kill the fork children of any threads of inferior INF that are
|
|
|
|
|
stopped at a fork event. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
kill_unfollowed_fork_children (struct inferior *inf)
|
|
|
|
|
{
|
|
|
|
|
struct thread_info *thread;
|
|
|
|
|
|
|
|
|
|
ALL_NON_EXITED_THREADS (thread)
|
|
|
|
|
if (thread->inf == inf)
|
|
|
|
|
{
|
|
|
|
|
struct target_waitstatus *ws = &thread->pending_follow;
|
|
|
|
|
|
|
|
|
|
if (ws->kind == TARGET_WAITKIND_FORKED
|
|
|
|
|
|| ws->kind == TARGET_WAITKIND_VFORKED)
|
|
|
|
|
{
|
|
|
|
|
ptid_t child_ptid = ws->value.related_pid;
|
|
|
|
|
int child_pid = ptid_get_pid (child_ptid);
|
|
|
|
|
int child_lwp = ptid_get_lwp (child_ptid);
|
|
|
|
|
|
|
|
|
|
kill_one_lwp (child_lwp);
|
|
|
|
|
kill_wait_one_lwp (child_lwp);
|
|
|
|
|
|
|
|
|
|
/* Let the arch-specific native code know this process is
|
|
|
|
|
gone. */
|
|
|
|
|
linux_nat_forget_process (child_pid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
static void
|
Add a target_ops parameter to the to_kill method in struct target_ops.
* target.h (struct target_ops): Add a "target_ops *" parameter to
method to_kill.
(target_kill): Remove macro. Add declaration.
* target.c (debug_to_kill): Delete, no longer necessary.
(target_kill): New function.
(update_current_target): Stop inheriting the to_kill method.
Do not de_fault it to no_process either.
(setup_target_debug): Do not set current_target.to_kill.
* gnu-nat.c, go32-nat.c, hpux-thread.c, inf-ptrace.c, inf-ttrace.c,
linux-nat.c, monitor.c, nto-procfs.c, procfs.c, remote-m32r-sdi.c,
remote-mips.c, remote-sim.c, remote.c, windows-nat.c: Update
accordingly.
2009-03-17 20:28:09 +01:00
|
|
|
|
linux_nat_kill (struct target_ops *ops)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
/* If we're stopped while forking and we haven't followed yet,
|
|
|
|
|
kill the other task. We need to do this first because the
|
|
|
|
|
parent will be sleeping if this is a vfork. */
|
Fix PR 19494: hang when killing unfollowed fork children
linux_nat_kill relies on get_last_target_status to determine whether
the current inferior is stopped at a unfollowed fork/vfork event.
This is bad because many things can happen ever since we caught the
fork/vfork event... This commit rewrites that code to instead walk
the thread list looking for unfollowed fork events, similarly to what
was done for remote.c.
New test included. The main idea of the test is make sure that when
the program stops for a fork catchpoint, and the user kills the
parent, gdb also kills the unfollowed fork child. Since the child
hasn't been added as an inferior at that point, we need some other
portable way to detect that the child is gone. The test uses a pipe
for that. The program forks twice, so you have grandparent, child and
grandchild. The grandchild inherits the write side of the pipe. The
grandparent hangs reading from the pipe, since nothing ever writes to
it. If, when GDB kills the child, it also kills the grandchild, then
the grandparent's pipe read returns 0/EOF and the test passes.
Otherwise, if GDB doesn't kill the grandchild, then the pipe read
never returns and the test times out, like:
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork: kill parent (timeout)
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill: vfork: kill parent (timeout)
No regressions on x86_64 Fedora 20. New test passes with gdbserver as
well.
gdb/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* linux-nat.c (kill_one_lwp): New, factored out from ...
(kill_callback): ... this.
(kill_wait_callback): New, factored out from ...
(kill_wait_one_lwp): ... this.
(kill_unfollowed_fork_children): New function.
(linux_nat_kill): Use it.
gdb/testsuite/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* gdb.base/catch-fork-kill.c: New file.
* gdb.base/catch-fork-kill.exp: New file.
2016-01-25 13:00:20 +01:00
|
|
|
|
kill_unfollowed_fork_children (current_inferior ());
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
|
|
|
|
|
if (forks_exist_p ())
|
2009-05-11 14:08:03 +02:00
|
|
|
|
linux_fork_killall ();
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
ptid_t ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
|
2010-05-15 01:41:05 +02:00
|
|
|
|
|
2008-07-11 00:58:37 +02:00
|
|
|
|
/* Stop all threads before killing them, since ptrace requires
|
|
|
|
|
that the thread is stopped to sucessfully PTRACE_KILL. */
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
iterate_over_lwps (ptid, stop_callback, NULL);
|
2008-07-11 00:58:37 +02:00
|
|
|
|
/* ... and wait until all of them have reported back that
|
|
|
|
|
they're no longer running. */
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
iterate_over_lwps (ptid, stop_wait_callback, NULL);
|
2008-07-11 00:58:37 +02:00
|
|
|
|
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
/* Kill all LWP's ... */
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
iterate_over_lwps (ptid, kill_callback, NULL);
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
|
|
|
|
|
/* ... and wait until we've flushed all events. */
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
iterate_over_lwps (ptid, kill_wait_callback, NULL);
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
Consolidate target_mourn_inferior between GDB and gdbserver
This patch consolidates the API of target_mourn_inferior between GDB
and gdbserver, in my continuing efforts to make sharing the
fork_inferior function possible between both.
GDB's version of the function did not care about the inferior's ptid
being mourned, but gdbserver's needed to know this information. Since
it actually makes sense to pass the ptid as an argument, instead of
depending on a global value directly (which GDB's version did), I
decided to make the generic API to accept it. I then went on and
extended all calls being made on GDB to include a ptid argument (which
ended up being inferior_ptid most of the times, anyway), and now we
have a more sane interface.
On GDB's side, after talking to Pedro a bit about it, we decided that
just an assertion to make sure that the ptid being passed is equal to
inferior_ptid would be enough for now, on the GDB side. We can remove
the assertion and perform more operations later if we ever pass
anything different than inferior_ptid.
Regression tested on our BuildBot, everything OK.
I'd appreciate a special look at gdb/windows-nat.c's modification
because I wasn't really sure what to do there. It seemed to me that
maybe I should build a ptid out of the process information there, but
then I am almost sure the assertion on GDB's side would trigger.
gdb/ChangeLog:
2016-09-19 Sergio Durigan Junior <sergiodj@redhat.com>
* darwin-nat.c (darwin_kill_inferior): Adjusting call to
target_mourn_inferior to include ptid_t argument.
* fork-child.c (startup_inferior): Likewise.
* gnu-nat.c (gnu_kill_inferior): Likewise.
* inf-ptrace.c (inf_ptrace_kill): Likewise.
* infrun.c (handle_inferior_event_1): Likewise.
* linux-nat.c (linux_nat_attach): Likewise.
(linux_nat_kill): Likewise.
* nto-procfs.c (interrupt_query): Likewise.
(procfs_interrupt): Likewise.
(procfs_kill_inferior): Likewise.
* procfs.c (procfs_kill_inferior): Likewise.
* record.c (record_mourn_inferior): Likewise.
* remote-sim.c (gdbsim_kill): Likewise.
* remote.c (remote_detach_1): Likewise.
(remote_kill): Likewise.
* target.c (target_mourn_inferior): Change declaration to accept
new ptid_t argument; use gdb_assert on it.
* target.h (target_mourn_inferior): Move function prototype from
here...
* target/target.h (target_mourn_inferior): ... to here. Adjust it
to accept new ptid_t argument.
* windows-nat.c (get_windows_debug_event): Adjusting call to
target_mourn_inferior to include ptid_t argument.
gdb/gdbserver/ChangeLog:
2016-09-19 Sergio Durigan Junior <sergiodj@redhat.com>
* server.c (start_inferior): Call target_mourn_inferior instead of
mourn_inferior; pass ptid_t argument to it.
(resume): Likewise.
(handle_target_event): Likewise.
* target.c (target_mourn_inferior): New function.
* target.h (mourn_inferior): Delete macro.
2016-09-12 05:45:31 +02:00
|
|
|
|
target_mourn_inferior (inferior_ptid);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
Kill pthread_ops_hack
* target.h (struct target_ops): Make to_attach, to_detach,
to_create_inferior and to_mourn_inferior accept a pointer
to struct target_ops.
(target_attach, target_create_inferior, target_create_inferior):
Convert from macros to function. Find the right target to
invoke a method of.
(find_default_attach, find_default_create_inferior): New parameter
ops.
* corefile.c (core_file_command): Pass target to to_detach.
* corelow.c (core_detach): Add 'ops' parameter.
* fork-child.c (fork_inferior): Return the pid. Allow
init_trace_fun to be NULL.
* inf-ptrace (ptrace_ops_hack): Remove.
(inf_ptrace_him): Remove, moving all logic into....
(inf_ptrace_create_inferior): ... here. Push the target
passed as parameter.
(inf_ptrace_mourn_inferior, inf_ptrace_attach, inf_ptrace_detach):
Push/pop target passed as parameter, no ptrace_ops_hack.
(inf_ptrace_target): Don't remember result.
* inferior.h (fork_inferior): Adjust prototype.
* linux-nat.c (linux_nat_create_inferior, linux_nat_attach)
(linux_nat_detach, linux_nat_mourn_inferior): New parameter ops.
Pass it to linux_ops target.
* linux-thread-db.c (thread_db_detach, thread_db_mourn_inferior):
New parameter ops. Pass it to the target beneath.
* remote.c (remote_mourn, extended_remote_mourn, remote_detach)
(extended_remote_create_inferior): New parameter ops. Pass it
further.
* target.c (debug_to_attach, debug_to_detach)
(debug_to_mourn_inferior): New parameter ops.
(target_create_inferior): New.
(update_current_target): Do not inherit to_attach, to_detach,
to_create_inferiour, to_mourn_inferior. Do not default
to_detach and to_mourn_inferior.
(target_detach): Find the right target to use.
(target_mourn_inferior): New.
(find_default_attach, find_default_create_inferior): New parameter
ops. Pass the found target when calling its method.
(init_dummy_target): Provide fallback definition of to_detach.
(target_attach): New.
(debug_to_attach, debug_to_detach, debug_to_create_inferior)
(debug_to_mourn_inferiour): New parameter ops.
* aix-thread.c: Adjust.
* bsd-uthread.c: Adjust.
* gnu-nat.c: Adjust.
* go32-nat.c: Adjust.
* hpux-thread.c: Adjust.
* inf-ttrace.c: Ajust.
* monitor.c: Adjust.
* nto-procfs.c: Adjust.
* procfs.c: Adjust.
* remote-m32r-sdi.c: Adjust.
* remote-mips.c: Adjust.
* remote-sim.c: Adjust.
* rs6000-nat.c: Adjust.
* sol-thread.c: Adjust.
* win32-nat.c: Adjust.
* dec-thread.c: Adjust.
2008-11-09 12:27:18 +01:00
|
|
|
|
linux_nat_mourn_inferior (struct target_ops *ops)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
[native x86 GNU/Linux] Access debug register mirror from the corresponding process.
While reviewing the native AArch64 patch, I noticed a problem:
On 02/06/2013 08:46 PM, Pedro Alves wrote:
>
>> > +static void
>> > +aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
>> > +{
>> > + struct arch_lwp_info *info = lwp->arch_private;
>> > +
>> > + /* NULL means this is the main thread still going through the shell,
>> > + or, no watchpoint has been set yet. In that case, there's
>> > + nothing to do. */
>> > + if (info == NULL)
>> > + return;
>> > +
>> > + if (DR_HAS_CHANGED (info->dr_changed_bp)
>> > + || DR_HAS_CHANGED (info->dr_changed_wp))
>> > + {
>> > + int tid = GET_LWP (lwp->ptid);
>> > + struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
> Hmm. This is always fetching the debug_reg_state of
> the current inferior, but may not be the inferior of lwp.
> I see the same bug on x86. Sorry about that. I'll fix it.
A natural fix would be to make xxx_get_debug_reg_state take an
inferior argument, but that doesn't work because of the case where we
detach breakpoints/watchpoints from the child fork, at a time there's
no inferior for the child fork at all. We do a nasty hack in
i386_inferior_data_get, but that relies on all callers pointing the
current inferior to the correct inferior, which isn't actually being
done by all callers, and I don't think we want to enforce that -- deep
in the bowls of linux-nat.c, there are many cases we resume lwps
behind the scenes, and it's be better to not have that code rely on
global state (as it doesn't today).
The fix is to decouple the watchpoints code from inferiors, making it
track target processes instead. This way, we can freely keep track of
the watchpoint mirrors for these processes behind the core's back.
Checkpoints also play dirty tricks with swapping the process behind
the inferior, so they get special treatment too in the patch (which
just amounts to calling a new hook). Instead of the old hack in
i386_inferior_data_get, where we returned a copy of the current
inferior's debug registers mirror, as soon as we detect a fork in the
target, we copy the debug register mirror from the parent to the child
process.
I don't have an old kernel handy to test, but I stepped through gdb doing
the watchpoint removal in the fork child in the watchpoint-fork test
seeing that the debug registers end up cleared in the child.
I didn't find the need for linux_nat_iterate_watchpoint_lwps. If
we use plain iterate_over_lwps instead, what happens is that
when removing watchpoints, that iterate_over_lwps doesn't actually
iterate over anything, since the fork child is not added to the
lwp list until later, at detach time, in linux_child_follow_fork.
And if we don't iterate over that lwp, we don't mark its debug
registers as needing update. But linux_child_follow_fork takes
care of doing that explicitly:
child_lp = add_lwp (inferior_ptid);
child_lp->stopped = 1;
child_lp->last_resume_kind = resume_stop;
make_cleanup (delete_lwp_cleanup, child_lp);
/* CHILD_LP has new PID, therefore linux_nat_new_thread is not called for it.
See i386_inferior_data_get for the Linux kernel specifics.
Ensure linux_nat_prepare_to_resume will reset the hardware debug
registers. It is done by the linux_nat_new_thread call, which is
being skipped in add_lwp above for the first lwp of a pid. */
gdb_assert (num_lwps (GET_PID (child_lp->ptid)) == 1);
if (linux_nat_new_thread != NULL)
linux_nat_new_thread (child_lp);
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (child_lp);
ptrace (PTRACE_DETACH, child_pid, 0, 0);
so unless I'm missing something (quite possible) it ends up all
the same. But, the !detach-on-fork, and the "follow-fork child" paths
should also call linux_nat_new_thread, and they don't presently. It
seems to me in those cases we're not clearing debug regs correctly
when that's needed. Instead of copying that bit that works around
add_lwp bypassing the linux_nat_new_thread call, I thought it'd
be better to add an add_initial_lwp call to be used in the case we
really need to bypass linux_nat_new_thread, and make
add_lwp always call linux_nat_new_thread.
i386_cleanup_dregs is rewritten to forget about the current process
debug mirrors, which takes cares of other i386 ports. Only a couple
of extra tweaks here and there were needed, as some targets wheren't
actually calling i386_cleanup_dregs.
Tested on Fedora 17 x86_64 -m64/-m32.
GDBserver already fetches the i386_debug_reg_state from the right
process, and, it doesn't handle forks at all, so no fix is needed over
there.
gdb/
2013-02-13 Pedro Alves <palves@redhat.com>
* amd64-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(amd64_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(amd64_linux_new_fork): New function.
(_initialize_amd64_linux_nat): Install amd64_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(i386_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(i386_linux_new_fork): New function.
(_initialize_i386_linux_nat): Install i386_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-nat.c (i386_init_dregs): Delete.
(i386_inferior_data, struct i386_inferior_data):
Delete.
(struct i386_process_info): New.
(i386_process_list): New global.
(i386_find_process_pid, i386_add_process, i386_process_info_get):
New functions.
(i386_inferior_data_get): Delete.
(i386_process_info_get): New function.
(i386_debug_reg_state): New parameter 'pid'. Reimplement.
(i386_forget_process): New function.
(i386_cleanup_dregs): Rewrite.
(i386_update_inferior_debug_regs, i386_insert_watchpoint)
(i386_remove_watchpoint, i386_region_ok_for_watchpoint)
(i386_stopped_data_address, i386_insert_hw_breakpoint)
(i386_remove_hw_breakpoint): Adjust to pass the current process id
to i386_debug_reg_state.
(i386_use_watchpoints): Don't register inferior data.
* i386-nat.h (i386_debug_reg_state): Add new 'pid' parameter, and
adjust comment.
(i386_forget_process): Declare.
* linux-fork.c (delete_fork): Call linux_nat_forget_process.
* linux-nat.c (linux_nat_new_fork, linux_nat_forget_process_hook):
New static globals.
(linux_child_follow_fork): Don't call linux_nat_new_thread here.
(add_initial_lwp): New, factored out from ...
(add_lwp): ... this. Don't check the number of lwps before
calling linux_nat_new_thread.
(linux_nat_iterate_watchpoint_lwps): Delete.
(linux_nat_attach): Use add_initial_lwp instead of add_lwp.
(linux_handle_extended_wait): Call the linux_nat_new_fork hook on
forks and vforks.
(linux_nat_wait_1): Use add_initial_lwp instead of add_lwp for the
initial lwp.
(linux_nat_kill, linux_nat_mourn_inferior): Call
linux_nat_forget_process.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New functions.
* linux-nat.h (linux_nat_iterate_watchpoint_lwps_ftype): Delete
type.
(linux_nat_iterate_watchpoint_lwps): Delete declaration.
(linux_nat_new_fork_ftype, linux_nat_forget_process_ftype): New
types.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New declarations.
* amd64fbsd-nat.c (super_mourn_inferior): New global.
(amd64fbsd_mourn_inferior): New function.
(_initialize_amd64fbsd_nat): Override to_mourn_inferior.
* windows-nat.c (windows_detach): Call i386_cleanup_dregs.
2013-02-13 15:59:49 +01:00
|
|
|
|
int pid = ptid_get_pid (inferior_ptid);
|
|
|
|
|
|
|
|
|
|
purge_lwp_list (pid);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
if (! forks_exist_p ())
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
/* Normal case, no other forks available. */
|
|
|
|
|
linux_ops->to_mourn_inferior (ops);
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
else
|
|
|
|
|
/* Multi-fork case. The current inferior_ptid has exited, but
|
|
|
|
|
there are other viable forks to debug. Delete the exiting
|
|
|
|
|
one and context-switch to the first available. */
|
|
|
|
|
linux_fork_mourn_inferior ();
|
[native x86 GNU/Linux] Access debug register mirror from the corresponding process.
While reviewing the native AArch64 patch, I noticed a problem:
On 02/06/2013 08:46 PM, Pedro Alves wrote:
>
>> > +static void
>> > +aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
>> > +{
>> > + struct arch_lwp_info *info = lwp->arch_private;
>> > +
>> > + /* NULL means this is the main thread still going through the shell,
>> > + or, no watchpoint has been set yet. In that case, there's
>> > + nothing to do. */
>> > + if (info == NULL)
>> > + return;
>> > +
>> > + if (DR_HAS_CHANGED (info->dr_changed_bp)
>> > + || DR_HAS_CHANGED (info->dr_changed_wp))
>> > + {
>> > + int tid = GET_LWP (lwp->ptid);
>> > + struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
> Hmm. This is always fetching the debug_reg_state of
> the current inferior, but may not be the inferior of lwp.
> I see the same bug on x86. Sorry about that. I'll fix it.
A natural fix would be to make xxx_get_debug_reg_state take an
inferior argument, but that doesn't work because of the case where we
detach breakpoints/watchpoints from the child fork, at a time there's
no inferior for the child fork at all. We do a nasty hack in
i386_inferior_data_get, but that relies on all callers pointing the
current inferior to the correct inferior, which isn't actually being
done by all callers, and I don't think we want to enforce that -- deep
in the bowls of linux-nat.c, there are many cases we resume lwps
behind the scenes, and it's be better to not have that code rely on
global state (as it doesn't today).
The fix is to decouple the watchpoints code from inferiors, making it
track target processes instead. This way, we can freely keep track of
the watchpoint mirrors for these processes behind the core's back.
Checkpoints also play dirty tricks with swapping the process behind
the inferior, so they get special treatment too in the patch (which
just amounts to calling a new hook). Instead of the old hack in
i386_inferior_data_get, where we returned a copy of the current
inferior's debug registers mirror, as soon as we detect a fork in the
target, we copy the debug register mirror from the parent to the child
process.
I don't have an old kernel handy to test, but I stepped through gdb doing
the watchpoint removal in the fork child in the watchpoint-fork test
seeing that the debug registers end up cleared in the child.
I didn't find the need for linux_nat_iterate_watchpoint_lwps. If
we use plain iterate_over_lwps instead, what happens is that
when removing watchpoints, that iterate_over_lwps doesn't actually
iterate over anything, since the fork child is not added to the
lwp list until later, at detach time, in linux_child_follow_fork.
And if we don't iterate over that lwp, we don't mark its debug
registers as needing update. But linux_child_follow_fork takes
care of doing that explicitly:
child_lp = add_lwp (inferior_ptid);
child_lp->stopped = 1;
child_lp->last_resume_kind = resume_stop;
make_cleanup (delete_lwp_cleanup, child_lp);
/* CHILD_LP has new PID, therefore linux_nat_new_thread is not called for it.
See i386_inferior_data_get for the Linux kernel specifics.
Ensure linux_nat_prepare_to_resume will reset the hardware debug
registers. It is done by the linux_nat_new_thread call, which is
being skipped in add_lwp above for the first lwp of a pid. */
gdb_assert (num_lwps (GET_PID (child_lp->ptid)) == 1);
if (linux_nat_new_thread != NULL)
linux_nat_new_thread (child_lp);
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (child_lp);
ptrace (PTRACE_DETACH, child_pid, 0, 0);
so unless I'm missing something (quite possible) it ends up all
the same. But, the !detach-on-fork, and the "follow-fork child" paths
should also call linux_nat_new_thread, and they don't presently. It
seems to me in those cases we're not clearing debug regs correctly
when that's needed. Instead of copying that bit that works around
add_lwp bypassing the linux_nat_new_thread call, I thought it'd
be better to add an add_initial_lwp call to be used in the case we
really need to bypass linux_nat_new_thread, and make
add_lwp always call linux_nat_new_thread.
i386_cleanup_dregs is rewritten to forget about the current process
debug mirrors, which takes cares of other i386 ports. Only a couple
of extra tweaks here and there were needed, as some targets wheren't
actually calling i386_cleanup_dregs.
Tested on Fedora 17 x86_64 -m64/-m32.
GDBserver already fetches the i386_debug_reg_state from the right
process, and, it doesn't handle forks at all, so no fix is needed over
there.
gdb/
2013-02-13 Pedro Alves <palves@redhat.com>
* amd64-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(amd64_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(amd64_linux_new_fork): New function.
(_initialize_amd64_linux_nat): Install amd64_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(i386_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(i386_linux_new_fork): New function.
(_initialize_i386_linux_nat): Install i386_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-nat.c (i386_init_dregs): Delete.
(i386_inferior_data, struct i386_inferior_data):
Delete.
(struct i386_process_info): New.
(i386_process_list): New global.
(i386_find_process_pid, i386_add_process, i386_process_info_get):
New functions.
(i386_inferior_data_get): Delete.
(i386_process_info_get): New function.
(i386_debug_reg_state): New parameter 'pid'. Reimplement.
(i386_forget_process): New function.
(i386_cleanup_dregs): Rewrite.
(i386_update_inferior_debug_regs, i386_insert_watchpoint)
(i386_remove_watchpoint, i386_region_ok_for_watchpoint)
(i386_stopped_data_address, i386_insert_hw_breakpoint)
(i386_remove_hw_breakpoint): Adjust to pass the current process id
to i386_debug_reg_state.
(i386_use_watchpoints): Don't register inferior data.
* i386-nat.h (i386_debug_reg_state): Add new 'pid' parameter, and
adjust comment.
(i386_forget_process): Declare.
* linux-fork.c (delete_fork): Call linux_nat_forget_process.
* linux-nat.c (linux_nat_new_fork, linux_nat_forget_process_hook):
New static globals.
(linux_child_follow_fork): Don't call linux_nat_new_thread here.
(add_initial_lwp): New, factored out from ...
(add_lwp): ... this. Don't check the number of lwps before
calling linux_nat_new_thread.
(linux_nat_iterate_watchpoint_lwps): Delete.
(linux_nat_attach): Use add_initial_lwp instead of add_lwp.
(linux_handle_extended_wait): Call the linux_nat_new_fork hook on
forks and vforks.
(linux_nat_wait_1): Use add_initial_lwp instead of add_lwp for the
initial lwp.
(linux_nat_kill, linux_nat_mourn_inferior): Call
linux_nat_forget_process.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New functions.
* linux-nat.h (linux_nat_iterate_watchpoint_lwps_ftype): Delete
type.
(linux_nat_iterate_watchpoint_lwps): Delete declaration.
(linux_nat_new_fork_ftype, linux_nat_forget_process_ftype): New
types.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New declarations.
* amd64fbsd-nat.c (super_mourn_inferior): New global.
(amd64fbsd_mourn_inferior): New function.
(_initialize_amd64fbsd_nat): Override to_mourn_inferior.
* windows-nat.c (windows_detach): Call i386_cleanup_dregs.
2013-02-13 15:59:49 +01:00
|
|
|
|
|
|
|
|
|
/* Let the arch-specific native code know this process is gone. */
|
|
|
|
|
linux_nat_forget_process (pid);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
* amd64-linux-nat.c (compat_int_t, compat_uptr_t, compat_time_t)
(compat_timer_t, compat_clock_t, struct compat_timeval)
(compat_sigval_t, compat_siginfo_t): New types.
(cpt_si_pid, cpt_si_uid, cpt_si_timerid, cpt_si_overrun)
(cpt_si_status, cpt_si_utime, cpt_si_stime, cpt_si_ptr)
(cpt_si_addr, cpt_si_band, cpt_si_fd): New defines.
(compat_siginfo_from_siginfo, siginfo_from_compat_siginfo)
(amd64_linux_siginfo_fixup): New.
* linux-nat.c (linux_nat_siginfo_fixup): New.
(siginfo_fixup): New.
(linux_xfer_siginfo): Use siginfo_fixup to convert between the
siginfo layout expected by ptrace and the siginfo layout of the
inferior.
(linux_nat_set_siginfo_fixup): New.
* linux-nat.h (linux_nat_set_siginfo_fixup): Declare.
2009-02-07 00:06:58 +01:00
|
|
|
|
/* Convert a native/host siginfo object, into/from the siginfo in the
|
|
|
|
|
layout of the inferiors' architecture. */
|
|
|
|
|
|
|
|
|
|
static void
|
2012-03-21 14:43:55 +01:00
|
|
|
|
siginfo_fixup (siginfo_t *siginfo, gdb_byte *inf_siginfo, int direction)
|
* amd64-linux-nat.c (compat_int_t, compat_uptr_t, compat_time_t)
(compat_timer_t, compat_clock_t, struct compat_timeval)
(compat_sigval_t, compat_siginfo_t): New types.
(cpt_si_pid, cpt_si_uid, cpt_si_timerid, cpt_si_overrun)
(cpt_si_status, cpt_si_utime, cpt_si_stime, cpt_si_ptr)
(cpt_si_addr, cpt_si_band, cpt_si_fd): New defines.
(compat_siginfo_from_siginfo, siginfo_from_compat_siginfo)
(amd64_linux_siginfo_fixup): New.
* linux-nat.c (linux_nat_siginfo_fixup): New.
(siginfo_fixup): New.
(linux_xfer_siginfo): Use siginfo_fixup to convert between the
siginfo layout expected by ptrace and the siginfo layout of the
inferior.
(linux_nat_set_siginfo_fixup): New.
* linux-nat.h (linux_nat_set_siginfo_fixup): Declare.
2009-02-07 00:06:58 +01:00
|
|
|
|
{
|
|
|
|
|
int done = 0;
|
|
|
|
|
|
|
|
|
|
if (linux_nat_siginfo_fixup != NULL)
|
|
|
|
|
done = linux_nat_siginfo_fixup (siginfo, inf_siginfo, direction);
|
|
|
|
|
|
|
|
|
|
/* If there was no callback, or the callback didn't do anything,
|
|
|
|
|
then just do a straight memcpy. */
|
|
|
|
|
if (!done)
|
|
|
|
|
{
|
|
|
|
|
if (direction == 1)
|
2012-03-21 14:43:55 +01:00
|
|
|
|
memcpy (siginfo, inf_siginfo, sizeof (siginfo_t));
|
* amd64-linux-nat.c (compat_int_t, compat_uptr_t, compat_time_t)
(compat_timer_t, compat_clock_t, struct compat_timeval)
(compat_sigval_t, compat_siginfo_t): New types.
(cpt_si_pid, cpt_si_uid, cpt_si_timerid, cpt_si_overrun)
(cpt_si_status, cpt_si_utime, cpt_si_stime, cpt_si_ptr)
(cpt_si_addr, cpt_si_band, cpt_si_fd): New defines.
(compat_siginfo_from_siginfo, siginfo_from_compat_siginfo)
(amd64_linux_siginfo_fixup): New.
* linux-nat.c (linux_nat_siginfo_fixup): New.
(siginfo_fixup): New.
(linux_xfer_siginfo): Use siginfo_fixup to convert between the
siginfo layout expected by ptrace and the siginfo layout of the
inferior.
(linux_nat_set_siginfo_fixup): New.
* linux-nat.h (linux_nat_set_siginfo_fixup): Declare.
2009-02-07 00:06:58 +01:00
|
|
|
|
else
|
2012-03-21 14:43:55 +01:00
|
|
|
|
memcpy (inf_siginfo, siginfo, sizeof (siginfo_t));
|
* amd64-linux-nat.c (compat_int_t, compat_uptr_t, compat_time_t)
(compat_timer_t, compat_clock_t, struct compat_timeval)
(compat_sigval_t, compat_siginfo_t): New types.
(cpt_si_pid, cpt_si_uid, cpt_si_timerid, cpt_si_overrun)
(cpt_si_status, cpt_si_utime, cpt_si_stime, cpt_si_ptr)
(cpt_si_addr, cpt_si_band, cpt_si_fd): New defines.
(compat_siginfo_from_siginfo, siginfo_from_compat_siginfo)
(amd64_linux_siginfo_fixup): New.
* linux-nat.c (linux_nat_siginfo_fixup): New.
(siginfo_fixup): New.
(linux_xfer_siginfo): Use siginfo_fixup to convert between the
siginfo layout expected by ptrace and the siginfo layout of the
inferior.
(linux_nat_set_siginfo_fixup): New.
* linux-nat.h (linux_nat_set_siginfo_fixup): Declare.
2009-02-07 00:06:58 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
static enum target_xfer_status
|
2009-02-06 23:59:01 +01:00
|
|
|
|
linux_xfer_siginfo (struct target_ops *ops, enum target_object object,
|
|
|
|
|
const char *annex, gdb_byte *readbuf,
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
|
|
|
|
|
ULONGEST *xfered_len)
|
2009-02-06 23:59:01 +01:00
|
|
|
|
{
|
|
|
|
|
int pid;
|
2012-03-21 14:43:55 +01:00
|
|
|
|
siginfo_t siginfo;
|
|
|
|
|
gdb_byte inf_siginfo[sizeof (siginfo_t)];
|
2009-02-06 23:59:01 +01:00
|
|
|
|
|
|
|
|
|
gdb_assert (object == TARGET_OBJECT_SIGNAL_INFO);
|
|
|
|
|
gdb_assert (readbuf || writebuf);
|
|
|
|
|
|
2013-09-30 13:50:12 +02:00
|
|
|
|
pid = ptid_get_lwp (inferior_ptid);
|
2009-02-06 23:59:01 +01:00
|
|
|
|
if (pid == 0)
|
2013-09-30 13:50:12 +02:00
|
|
|
|
pid = ptid_get_pid (inferior_ptid);
|
2009-02-06 23:59:01 +01:00
|
|
|
|
|
|
|
|
|
if (offset > sizeof (siginfo))
|
2014-01-27 10:32:33 +01:00
|
|
|
|
return TARGET_XFER_E_IO;
|
2009-02-06 23:59:01 +01:00
|
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
|
ptrace (PTRACE_GETSIGINFO, pid, (PTRACE_TYPE_ARG3) 0, &siginfo);
|
|
|
|
|
if (errno != 0)
|
2014-01-27 10:32:33 +01:00
|
|
|
|
return TARGET_XFER_E_IO;
|
2009-02-06 23:59:01 +01:00
|
|
|
|
|
* amd64-linux-nat.c (compat_int_t, compat_uptr_t, compat_time_t)
(compat_timer_t, compat_clock_t, struct compat_timeval)
(compat_sigval_t, compat_siginfo_t): New types.
(cpt_si_pid, cpt_si_uid, cpt_si_timerid, cpt_si_overrun)
(cpt_si_status, cpt_si_utime, cpt_si_stime, cpt_si_ptr)
(cpt_si_addr, cpt_si_band, cpt_si_fd): New defines.
(compat_siginfo_from_siginfo, siginfo_from_compat_siginfo)
(amd64_linux_siginfo_fixup): New.
* linux-nat.c (linux_nat_siginfo_fixup): New.
(siginfo_fixup): New.
(linux_xfer_siginfo): Use siginfo_fixup to convert between the
siginfo layout expected by ptrace and the siginfo layout of the
inferior.
(linux_nat_set_siginfo_fixup): New.
* linux-nat.h (linux_nat_set_siginfo_fixup): Declare.
2009-02-07 00:06:58 +01:00
|
|
|
|
/* When GDB is built as a 64-bit application, ptrace writes into
|
|
|
|
|
SIGINFO an object with 64-bit layout. Since debugging a 32-bit
|
|
|
|
|
inferior with a 64-bit GDB should look the same as debugging it
|
|
|
|
|
with a 32-bit GDB, we need to convert it. GDB core always sees
|
|
|
|
|
the converted layout, so any read/write will have to be done
|
|
|
|
|
post-conversion. */
|
|
|
|
|
siginfo_fixup (&siginfo, inf_siginfo, 0);
|
|
|
|
|
|
2009-02-06 23:59:01 +01:00
|
|
|
|
if (offset + len > sizeof (siginfo))
|
|
|
|
|
len = sizeof (siginfo) - offset;
|
|
|
|
|
|
|
|
|
|
if (readbuf != NULL)
|
* amd64-linux-nat.c (compat_int_t, compat_uptr_t, compat_time_t)
(compat_timer_t, compat_clock_t, struct compat_timeval)
(compat_sigval_t, compat_siginfo_t): New types.
(cpt_si_pid, cpt_si_uid, cpt_si_timerid, cpt_si_overrun)
(cpt_si_status, cpt_si_utime, cpt_si_stime, cpt_si_ptr)
(cpt_si_addr, cpt_si_band, cpt_si_fd): New defines.
(compat_siginfo_from_siginfo, siginfo_from_compat_siginfo)
(amd64_linux_siginfo_fixup): New.
* linux-nat.c (linux_nat_siginfo_fixup): New.
(siginfo_fixup): New.
(linux_xfer_siginfo): Use siginfo_fixup to convert between the
siginfo layout expected by ptrace and the siginfo layout of the
inferior.
(linux_nat_set_siginfo_fixup): New.
* linux-nat.h (linux_nat_set_siginfo_fixup): Declare.
2009-02-07 00:06:58 +01:00
|
|
|
|
memcpy (readbuf, inf_siginfo + offset, len);
|
2009-02-06 23:59:01 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
* amd64-linux-nat.c (compat_int_t, compat_uptr_t, compat_time_t)
(compat_timer_t, compat_clock_t, struct compat_timeval)
(compat_sigval_t, compat_siginfo_t): New types.
(cpt_si_pid, cpt_si_uid, cpt_si_timerid, cpt_si_overrun)
(cpt_si_status, cpt_si_utime, cpt_si_stime, cpt_si_ptr)
(cpt_si_addr, cpt_si_band, cpt_si_fd): New defines.
(compat_siginfo_from_siginfo, siginfo_from_compat_siginfo)
(amd64_linux_siginfo_fixup): New.
* linux-nat.c (linux_nat_siginfo_fixup): New.
(siginfo_fixup): New.
(linux_xfer_siginfo): Use siginfo_fixup to convert between the
siginfo layout expected by ptrace and the siginfo layout of the
inferior.
(linux_nat_set_siginfo_fixup): New.
* linux-nat.h (linux_nat_set_siginfo_fixup): Declare.
2009-02-07 00:06:58 +01:00
|
|
|
|
memcpy (inf_siginfo + offset, writebuf, len);
|
|
|
|
|
|
|
|
|
|
/* Convert back to ptrace layout before flushing it out. */
|
|
|
|
|
siginfo_fixup (&siginfo, inf_siginfo, 1);
|
|
|
|
|
|
2009-02-06 23:59:01 +01:00
|
|
|
|
errno = 0;
|
|
|
|
|
ptrace (PTRACE_SETSIGINFO, pid, (PTRACE_TYPE_ARG3) 0, &siginfo);
|
|
|
|
|
if (errno != 0)
|
2014-01-27 10:32:33 +01:00
|
|
|
|
return TARGET_XFER_E_IO;
|
2009-02-06 23:59:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
*xfered_len = len;
|
|
|
|
|
return TARGET_XFER_OK;
|
2009-02-06 23:59:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
static enum target_xfer_status
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
linux_nat_xfer_partial (struct target_ops *ops, enum target_object object,
|
|
|
|
|
const char *annex, gdb_byte *readbuf,
|
|
|
|
|
const gdb_byte *writebuf,
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
enum target_xfer_status xfer;
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
2009-02-06 23:59:01 +01:00
|
|
|
|
if (object == TARGET_OBJECT_SIGNAL_INFO)
|
|
|
|
|
return linux_xfer_siginfo (ops, object, annex, readbuf, writebuf,
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
offset, len, xfered_len);
|
2009-02-06 23:59:01 +01:00
|
|
|
|
|
* target.h (struct target_ops): Make to_has_all_memory,
to_has_memory, to_has_stack, to_has_registers and to_has_execution
methods instead of variables.
(target_has_all_memory_1, target_has_memory_1, target_has_stack_1)
(target_has_registers_1, target_has_execution_1): Declare
functions.
(target_has_all_memory): Rewrite to call target_has_all_memory_1.
(target_has_memory): Rewrite to call target_has_memory_1.
(target_has_stack): Rewrite to call target_has_all_stack_1.
(target_has_registers): Rewrite to call target_has_registers_1.
(target_has_execution): Rewrite to call target_has_execution_1.
(default_child_has_all_memory, default_child_has_memory)
(default_child_has_stack, default_child_has_registers)
(default_child_has_execution): Declare.
(target_mark_running, target_mark_exited): Delete declarations.
* target.c (default_child_has_all_memory,
default_child_has_memory, default_child_has_stack,
default_child_has_registers, default_child_has_execution): New.
(target_has_all_memory_1, target_has_memory_1, target_has_stack_1,
target_has_registers_1, target_has_execution_1): New.
(add_target): Default the to_has_all_memory, to_has_all_memory,
to_has_memory, to_has_stack, to_has_registers and to_has_execution
callbacks to return 0.
(update_current_target): Do not inherit to_has_all_memory,
to_has_memory, to_has_stack, to_has_registers or to_has_execution.
(target_mark_running, target_mark_exited): Delete.
(memory_xfer_partial): Adjust.
(target_read_memory, target_write_memory, target_search_memory):
Dispatch to the the top-most target, not the flattened
current_target.
(target_info): Adjust.
(init_dummy_target): Install return_zero as callback for
to_has_all_memory, to_has_memory, to_has_stack, to_has_registers,
to_has_execution.
(set_maintenance_target_async_permitted): Use have_live_inferiors
instead of target_has_execution.
* target-memory.c (target_write_memory_blocks): Dispatch memory
writes to the the top-most target, not the flattened
current_target.
* breakpoint.c (insert_breakpoints): Don't check for
target_has_execution here.
(update_global_location_list): Check if there are live inferiors
to debug instead of target_has_execution.
* infcmd.c (kill_command, detach_command): Check if there are
inferiors instead of target_has_execution.
* inferior.h (have_live_inferiors): Declare.
* inferior.c (have_live_inferiors): New.
* infrun.c (normal_stop): Don't check for target_has_execution to
finish the thread states.
* thread.c (is_thread_state, is_stopped, is_exited, is_running)
(any_running, is_executing): Remove checks for
target_has_execution.
* top.c (kill_or_detach): Don't try to kill core inferiors.
(quit_target): Don't check for target_has_execution.
* corelow.c (core_has_memory, core_has_stack, core_has_registers):
New.
(init_core_ops): Install core_has_memory, core_has_stack and
core_has_registers.
* exec.c (exec_has_memory): New.
(init_exec_ops): Install exec_has_memory.
* remote.c (remote_add_inferior): Don't call target_mark_running.
(remote_start_remote): Don't call target_mark_exited or call
target_mark_running.
(remote_open_1): Use have_inferiors instead of
target_has_execution. Don't use target_mark_exited.
(init_remote_ops): Install deafult_child_has_all_memory,
default_child_has_memory, default_child_has_stack,
default_child_has_registers, default_child_has_execution.
* bsd-kvm.c (bsd_kvm_return_one): New.
(bsd_kvm_add_target): Register bsd_kvm_return_one as
to_has_memory, to_has_stack and to_has_registers callbacks.
* remote-m32r-sdi.c (m32r_return_one): New.
(init_m32r_ops): Register it.
* inf-child.c (inf_child_target): Adjust to register
default_child_has_all_memory, default_child_has_memory,
default_child_has_stack, default_child_has_registers,
default_child_has_execution callbacks.
* gnu-nat.c (init_gnu_ops): Likewise.
* go32-nat.c (init_go32_ops): Likewise.
* hpux-thread.c (init_hpux_thread_ops): Likewise.
* monitor.c (init_base_monitor_ops): Likewise.
* nto-procfs.c (init_procfs_ops): Likewise.
* remote-mips.c (_initialize_remote_mips): Likewise.
* windows-nat.c (init_windows_ops): Likewise.
* remote-sim.c (gdbsim_create_inferior): Don't use
target_mark_running or target_mark_exited.
(gdbsim_mourn_inferior): Don't call target_mark_exited.
(init_gdbsim_ops): Adjust to register
default_child_has_all_memory, default_child_has_memory,
default_child_has_stack, default_child_has_registers,
default_child_has_execution callbacks.
* linux-nat.c (linux_nat_xfer_partial): If reading memory, and
there's no inferior selected, defer to a lower stratum.
2009-06-07 18:46:48 +02:00
|
|
|
|
/* The target is connected but no live inferior is selected. Pass
|
|
|
|
|
this request down to a lower stratum (e.g., the executable
|
|
|
|
|
file). */
|
|
|
|
|
if (object == TARGET_OBJECT_MEMORY && ptid_equal (inferior_ptid, null_ptid))
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
return TARGET_XFER_EOF;
|
* target.h (struct target_ops): Make to_has_all_memory,
to_has_memory, to_has_stack, to_has_registers and to_has_execution
methods instead of variables.
(target_has_all_memory_1, target_has_memory_1, target_has_stack_1)
(target_has_registers_1, target_has_execution_1): Declare
functions.
(target_has_all_memory): Rewrite to call target_has_all_memory_1.
(target_has_memory): Rewrite to call target_has_memory_1.
(target_has_stack): Rewrite to call target_has_all_stack_1.
(target_has_registers): Rewrite to call target_has_registers_1.
(target_has_execution): Rewrite to call target_has_execution_1.
(default_child_has_all_memory, default_child_has_memory)
(default_child_has_stack, default_child_has_registers)
(default_child_has_execution): Declare.
(target_mark_running, target_mark_exited): Delete declarations.
* target.c (default_child_has_all_memory,
default_child_has_memory, default_child_has_stack,
default_child_has_registers, default_child_has_execution): New.
(target_has_all_memory_1, target_has_memory_1, target_has_stack_1,
target_has_registers_1, target_has_execution_1): New.
(add_target): Default the to_has_all_memory, to_has_all_memory,
to_has_memory, to_has_stack, to_has_registers and to_has_execution
callbacks to return 0.
(update_current_target): Do not inherit to_has_all_memory,
to_has_memory, to_has_stack, to_has_registers or to_has_execution.
(target_mark_running, target_mark_exited): Delete.
(memory_xfer_partial): Adjust.
(target_read_memory, target_write_memory, target_search_memory):
Dispatch to the the top-most target, not the flattened
current_target.
(target_info): Adjust.
(init_dummy_target): Install return_zero as callback for
to_has_all_memory, to_has_memory, to_has_stack, to_has_registers,
to_has_execution.
(set_maintenance_target_async_permitted): Use have_live_inferiors
instead of target_has_execution.
* target-memory.c (target_write_memory_blocks): Dispatch memory
writes to the the top-most target, not the flattened
current_target.
* breakpoint.c (insert_breakpoints): Don't check for
target_has_execution here.
(update_global_location_list): Check if there are live inferiors
to debug instead of target_has_execution.
* infcmd.c (kill_command, detach_command): Check if there are
inferiors instead of target_has_execution.
* inferior.h (have_live_inferiors): Declare.
* inferior.c (have_live_inferiors): New.
* infrun.c (normal_stop): Don't check for target_has_execution to
finish the thread states.
* thread.c (is_thread_state, is_stopped, is_exited, is_running)
(any_running, is_executing): Remove checks for
target_has_execution.
* top.c (kill_or_detach): Don't try to kill core inferiors.
(quit_target): Don't check for target_has_execution.
* corelow.c (core_has_memory, core_has_stack, core_has_registers):
New.
(init_core_ops): Install core_has_memory, core_has_stack and
core_has_registers.
* exec.c (exec_has_memory): New.
(init_exec_ops): Install exec_has_memory.
* remote.c (remote_add_inferior): Don't call target_mark_running.
(remote_start_remote): Don't call target_mark_exited or call
target_mark_running.
(remote_open_1): Use have_inferiors instead of
target_has_execution. Don't use target_mark_exited.
(init_remote_ops): Install deafult_child_has_all_memory,
default_child_has_memory, default_child_has_stack,
default_child_has_registers, default_child_has_execution.
* bsd-kvm.c (bsd_kvm_return_one): New.
(bsd_kvm_add_target): Register bsd_kvm_return_one as
to_has_memory, to_has_stack and to_has_registers callbacks.
* remote-m32r-sdi.c (m32r_return_one): New.
(init_m32r_ops): Register it.
* inf-child.c (inf_child_target): Adjust to register
default_child_has_all_memory, default_child_has_memory,
default_child_has_stack, default_child_has_registers,
default_child_has_execution callbacks.
* gnu-nat.c (init_gnu_ops): Likewise.
* go32-nat.c (init_go32_ops): Likewise.
* hpux-thread.c (init_hpux_thread_ops): Likewise.
* monitor.c (init_base_monitor_ops): Likewise.
* nto-procfs.c (init_procfs_ops): Likewise.
* remote-mips.c (_initialize_remote_mips): Likewise.
* windows-nat.c (init_windows_ops): Likewise.
* remote-sim.c (gdbsim_create_inferior): Don't use
target_mark_running or target_mark_exited.
(gdbsim_mourn_inferior): Don't call target_mark_exited.
(init_gdbsim_ops): Adjust to register
default_child_has_all_memory, default_child_has_memory,
default_child_has_stack, default_child_has_registers,
default_child_has_execution callbacks.
* linux-nat.c (linux_nat_xfer_partial): If reading memory, and
there's no inferior selected, defer to a lower stratum.
2009-06-07 18:46:48 +02:00
|
|
|
|
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
xfer = linux_ops->to_xfer_partial (ops, object, annex, readbuf, writebuf,
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
offset, len, xfered_len);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
return xfer;
|
|
|
|
|
}
|
|
|
|
|
|
* corelow.c (get_core_registers): Adjust.
(core_file_thread_alive): Rename to...
(core_thread_alive): ... this.
(core_pid_to_str): Try gdbarch_core_pid_to_str first.
(init_core_ops): Adjust.
(coreops_suppress_target): Delete.
(_initialize_corelow): Unconditionally add core_ops.
* procfs.c: Include "inf-child.h".
(procfs_ops): Delete.
(init_procfs_ops): Delete. Reimplement as...
(procfs_target): ... this, inheriting from inf-child.
(procfs_attach, procfs_detach, procfs_fetch_registers): Adjust.
(procfs_prepare_to_store): Delete.
(procfs_store_registers, procfs_resume): Adjust.
(procfs_open): Delete.
(procfs_suppress_run): Delete.
(procfs_can_run): Delete.
(procfs_mourn_inferior): Adjust.
(procfs_init_inferior): Add target_ops parameter. Adjust.
(procfs_create_inferior): Don't pass procfs_init_inferior to
fork_inferior. Instead call it after fork_inferior returns.
(procfs_find_new_threads): Adjust.
(_initialize_procfs): Adjust to use procfs_target instead of
init_procfs_ops.
* sol-thread.c (orig_core_ops, sol_core_ops): Delete.
(lwp_to_thread): Use target_thread_alive.
(sol_thread_open): Delete.
(sol_thread_attach): Delete.
(sol_thread_detach, sol_thread_resume, sol_thread_wait)
(sol_thread_fetch_registers, sol_thread_store_registers): Adjust
to use find_target_beneath.
(sol_thread_prepare_to_store, sol_thread_xfer_memory): Delete.
(sol_thread_xfer_partial): Adjust to use find_target_beneath.
(sol_thread_files_info, sol_thread_kill_inferior): Delete.
(check_for_thread_db): New.
(sol_thread_notice_signals, sol_thread_create_inferior): Delete.
(sol_thread_new_objfile): Call check_for_thread_db.
(sol_thread_mourn_inferior): Adjust to use find_target_beneath.
(sol_thread_can_run): Delete.
(sol_thread_alive): Adjust to use find_target_beneath.
(sol_thread_stop): Delete.
(rw_common): Use target_write_memory or target_read_memory.
(ps_lgetregs, ps_lgetfpregs): Use target_fetch_registers.
(ps_lsetregs, ps_lsetfpregs): Use target_store_registers.
(solaris_pid_to_str): Remove check for libthread_db initialization
failing.
(sol_find_new_threads): Remove check for libthread_db
initialization failing, or for an invalid inferior_ptid. Adjust
to use find_target_beneath.
(sol_core_open, sol_core_close, sol_core_detach,
sol_core_files_info, sol_find_memory_regions,
sol_make_note_section, ignore): Delete.
(init_sol_thread_ops): Make it a thread_stratum target. Remove
unneeded callback settings.
(init_sol_core_ops): Delete.
(_initialize_sol_thread): No longer call init_sol_core_ops, set
procfs_suppress_run, or hack with core_ops.
* target.h (struct target_ops): Add a target_ops * parameter to
to_resume, to_fetch_registers, to_store_registers, to_thread_alive
and to_find_new_threads.
(target_fetch_registers, target_store_registers)
(target_thread_alive, target_find_new_threads): Redeclare as
function.
* target.c (update_current_target): Do not inherit or de_fault
to_resume, to_fetch_registers, to_store_registers,
to_thread_alive, to_find_new_threads.
(target_resume): Adjust.
(target_thread_alive, target_find_new_threads): New.
(debug_to_resume, debug_to_fetch_registers): Delete.
(target_fetch_registers): New.
(debug_to_store_registers): Delete.
(target_store_registers): New.
(debug_to_thread_alive, debug_to_find_new_threads): Delete.
(setup_target_debug): Adjust.
* gdbcore.h (core_ops): Delete declaration.
* inf-ptrace.c, linux-nat.c, remote.c, amd64-linux-nat.c,
inf-child.c, linux-thread-db.c, bsd-uthread.c, inf-ttrace.c,
i386-sol2-tdep.c, darwin-nat.c, gnu-nat.c, go32-nat.c,
hpux-thread.c, i386-linux-nat.c, i386fbsd-nat.c, monitor.c,
nto-procfs.c, remote-m32r-sdi.c, remote-mips.c, windows-nat.c,
alphabsd-nat.c, amd64bsd-nat.c, arm-linux-nat.c, armnbsd-nat.c,
bsd-kvm.c, hppa-hpux-nat.c, hppa-linux-nat.c, hppabsd-nat.c,
hppanbsd-nat.c, i386-darwin-nat.c, i386bsd-nat.c,
ia64-linux-nat.c, m32r-linux-nat.c, m68kbsd-nat.c,
m68klinux-nat.c, m88kbsd-nat.c, mips-linux-nat.c,
mips64obsd-nat.c, mipsnbsd-nat.c, ppc-linux-nat.c, ppcnbsd-nat.c,
ppcobsd-nat.c, remote-sim.c, rs6000-nat.c, s390-nat.c,
shnbsd-nat.c, sparc-nat.c, sparc-nat.h, spu-linux-nat.c,
vaxbsd-nat.c, xtensa-linux-nat.c: Adjust to target_ops changes.
* gdbarch.sh (core_pid_to_str): New gdbarch callback.
* gdbarch.h, gdbarch.c: Regenerate.
* sol2-tdep.c: Include "inferior.h".
(sol2_core_pid_to_str): New.
* sol2-tdep.h (sol2_core_pid_to_str): Declare.
* amd64-sol2-tdep.c (amd64_sol2_init_abi): Set it.
* sparc-sol2-tdep.c (sparc32_sol2_init_abi): Set it.
* sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Set it.
* i386-sol2-tdep.c (i386_sol2_init_abi): Set it.
2009-02-23 01:03:50 +01:00
|
|
|
|
static int
|
|
|
|
|
linux_nat_thread_alive (struct target_ops *ops, ptid_t ptid)
|
|
|
|
|
{
|
2015-12-17 15:20:51 +01:00
|
|
|
|
/* As long as a PTID is in lwp list, consider it alive. */
|
|
|
|
|
return find_lwp_pid (ptid) != NULL;
|
* corelow.c (get_core_registers): Adjust.
(core_file_thread_alive): Rename to...
(core_thread_alive): ... this.
(core_pid_to_str): Try gdbarch_core_pid_to_str first.
(init_core_ops): Adjust.
(coreops_suppress_target): Delete.
(_initialize_corelow): Unconditionally add core_ops.
* procfs.c: Include "inf-child.h".
(procfs_ops): Delete.
(init_procfs_ops): Delete. Reimplement as...
(procfs_target): ... this, inheriting from inf-child.
(procfs_attach, procfs_detach, procfs_fetch_registers): Adjust.
(procfs_prepare_to_store): Delete.
(procfs_store_registers, procfs_resume): Adjust.
(procfs_open): Delete.
(procfs_suppress_run): Delete.
(procfs_can_run): Delete.
(procfs_mourn_inferior): Adjust.
(procfs_init_inferior): Add target_ops parameter. Adjust.
(procfs_create_inferior): Don't pass procfs_init_inferior to
fork_inferior. Instead call it after fork_inferior returns.
(procfs_find_new_threads): Adjust.
(_initialize_procfs): Adjust to use procfs_target instead of
init_procfs_ops.
* sol-thread.c (orig_core_ops, sol_core_ops): Delete.
(lwp_to_thread): Use target_thread_alive.
(sol_thread_open): Delete.
(sol_thread_attach): Delete.
(sol_thread_detach, sol_thread_resume, sol_thread_wait)
(sol_thread_fetch_registers, sol_thread_store_registers): Adjust
to use find_target_beneath.
(sol_thread_prepare_to_store, sol_thread_xfer_memory): Delete.
(sol_thread_xfer_partial): Adjust to use find_target_beneath.
(sol_thread_files_info, sol_thread_kill_inferior): Delete.
(check_for_thread_db): New.
(sol_thread_notice_signals, sol_thread_create_inferior): Delete.
(sol_thread_new_objfile): Call check_for_thread_db.
(sol_thread_mourn_inferior): Adjust to use find_target_beneath.
(sol_thread_can_run): Delete.
(sol_thread_alive): Adjust to use find_target_beneath.
(sol_thread_stop): Delete.
(rw_common): Use target_write_memory or target_read_memory.
(ps_lgetregs, ps_lgetfpregs): Use target_fetch_registers.
(ps_lsetregs, ps_lsetfpregs): Use target_store_registers.
(solaris_pid_to_str): Remove check for libthread_db initialization
failing.
(sol_find_new_threads): Remove check for libthread_db
initialization failing, or for an invalid inferior_ptid. Adjust
to use find_target_beneath.
(sol_core_open, sol_core_close, sol_core_detach,
sol_core_files_info, sol_find_memory_regions,
sol_make_note_section, ignore): Delete.
(init_sol_thread_ops): Make it a thread_stratum target. Remove
unneeded callback settings.
(init_sol_core_ops): Delete.
(_initialize_sol_thread): No longer call init_sol_core_ops, set
procfs_suppress_run, or hack with core_ops.
* target.h (struct target_ops): Add a target_ops * parameter to
to_resume, to_fetch_registers, to_store_registers, to_thread_alive
and to_find_new_threads.
(target_fetch_registers, target_store_registers)
(target_thread_alive, target_find_new_threads): Redeclare as
function.
* target.c (update_current_target): Do not inherit or de_fault
to_resume, to_fetch_registers, to_store_registers,
to_thread_alive, to_find_new_threads.
(target_resume): Adjust.
(target_thread_alive, target_find_new_threads): New.
(debug_to_resume, debug_to_fetch_registers): Delete.
(target_fetch_registers): New.
(debug_to_store_registers): Delete.
(target_store_registers): New.
(debug_to_thread_alive, debug_to_find_new_threads): Delete.
(setup_target_debug): Adjust.
* gdbcore.h (core_ops): Delete declaration.
* inf-ptrace.c, linux-nat.c, remote.c, amd64-linux-nat.c,
inf-child.c, linux-thread-db.c, bsd-uthread.c, inf-ttrace.c,
i386-sol2-tdep.c, darwin-nat.c, gnu-nat.c, go32-nat.c,
hpux-thread.c, i386-linux-nat.c, i386fbsd-nat.c, monitor.c,
nto-procfs.c, remote-m32r-sdi.c, remote-mips.c, windows-nat.c,
alphabsd-nat.c, amd64bsd-nat.c, arm-linux-nat.c, armnbsd-nat.c,
bsd-kvm.c, hppa-hpux-nat.c, hppa-linux-nat.c, hppabsd-nat.c,
hppanbsd-nat.c, i386-darwin-nat.c, i386bsd-nat.c,
ia64-linux-nat.c, m32r-linux-nat.c, m68kbsd-nat.c,
m68klinux-nat.c, m88kbsd-nat.c, mips-linux-nat.c,
mips64obsd-nat.c, mipsnbsd-nat.c, ppc-linux-nat.c, ppcnbsd-nat.c,
ppcobsd-nat.c, remote-sim.c, rs6000-nat.c, s390-nat.c,
shnbsd-nat.c, sparc-nat.c, sparc-nat.h, spu-linux-nat.c,
vaxbsd-nat.c, xtensa-linux-nat.c: Adjust to target_ops changes.
* gdbarch.sh (core_pid_to_str): New gdbarch callback.
* gdbarch.h, gdbarch.c: Regenerate.
* sol2-tdep.c: Include "inferior.h".
(sol2_core_pid_to_str): New.
* sol2-tdep.h (sol2_core_pid_to_str): Declare.
* amd64-sol2-tdep.c (amd64_sol2_init_abi): Set it.
* sparc-sol2-tdep.c (sparc32_sol2_init_abi): Set it.
* sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Set it.
* i386-sol2-tdep.c (i386_sol2_init_abi): Set it.
2009-02-23 01:03:50 +01:00
|
|
|
|
}
|
|
|
|
|
|
update thread list, delete exited threads
On GNU/Linux, if the running kernel supports clone events, then
linux-thread-db.c defers thread listing to the target beneath:
static void
thread_db_update_thread_list (struct target_ops *ops)
{
...
if (target_has_execution && !thread_db_use_events ())
ops->beneath->to_update_thread_list (ops->beneath);
else
thread_db_update_thread_list_td_ta_thr_iter (ops);
...
}
However, when live debugging, the target beneath, linux-nat.c, does
not implement the to_update_thread_list method. The result is that if
a thread is marked exited (because it can't be deleted right now,
e.g., it was the selected thread), then it won't ever be deleted,
until the process exits or is killed/detached.
A similar thing happens with the remote.c target. Because its
target_update_thread_list implementation skips exited threads when it
walks the current thread list looking for threads that no longer exits
on the target side, using ALL_NON_EXITED_THREADS_SAFE, stale exited
threads are never deleted.
This is not a big deal -- I can't think of any way this might be user
visible, other than gdb's memory growing a tiny bit whenever a thread
gets stuck in exited state. Still, might as well clean things up
properly.
All other targets use prune_threads, so are unaffected.
The fix adds a ALL_THREADS_SAFE macro, that like
ALL_NON_EXITED_THREADS_SAFE, walks the thread list and allows deleting
the iterated thread, and uses that in places that are walking the
thread list in order to delete threads. Actually, after converting
linux-nat.c and remote.c to use this, we find the only other user of
ALL_NON_EXITED_THREADS_SAFE is also walking the list to delete
threads. So we convert that too, and end up deleting
ALL_NON_EXITED_THREADS_SAFE.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog
2015-04-07 Pedro Alves <palves@redhat.com>
* gdbthread.h (ALL_NON_EXITED_THREADS_SAFE): Rename to ...
(ALL_THREADS_SAFE): ... this, and don't skip exited threads.
(delete_exited_threads): New declaration.
* infrun.c (follow_exec): Use ALL_THREADS_SAFE.
* linux-nat.c (linux_nat_update_thread_list): New function.
(linux_nat_add_target): Install it.
* remote.c (remote_update_thread_list): Use ALL_THREADS_SAFE.
* thread.c (prune_threads): Use ALL_THREADS_SAFE.
(delete_exited_threads): New function.
2015-04-07 16:47:22 +02:00
|
|
|
|
/* Implement the to_update_thread_list target method for this
|
|
|
|
|
target. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
linux_nat_update_thread_list (struct target_ops *ops)
|
|
|
|
|
{
|
2015-12-17 15:20:52 +01:00
|
|
|
|
struct lwp_info *lwp;
|
|
|
|
|
|
2015-12-17 15:20:51 +01:00
|
|
|
|
/* We add/delete threads from the list as clone/exit events are
|
|
|
|
|
processed, so just try deleting exited threads still in the
|
|
|
|
|
thread list. */
|
|
|
|
|
delete_exited_threads ();
|
2015-12-17 15:20:52 +01:00
|
|
|
|
|
|
|
|
|
/* Update the processor core that each lwp/thread was last seen
|
|
|
|
|
running on. */
|
|
|
|
|
ALL_LWPS (lwp)
|
2016-05-24 15:47:57 +02:00
|
|
|
|
{
|
|
|
|
|
/* Avoid accessing /proc if the thread hasn't run since we last
|
|
|
|
|
time we fetched the thread's core. Accessing /proc becomes
|
|
|
|
|
noticeably expensive when we have thousands of LWPs. */
|
|
|
|
|
if (lwp->core == -1)
|
|
|
|
|
lwp->core = linux_common_core_of_thread (lwp->ptid);
|
|
|
|
|
}
|
update thread list, delete exited threads
On GNU/Linux, if the running kernel supports clone events, then
linux-thread-db.c defers thread listing to the target beneath:
static void
thread_db_update_thread_list (struct target_ops *ops)
{
...
if (target_has_execution && !thread_db_use_events ())
ops->beneath->to_update_thread_list (ops->beneath);
else
thread_db_update_thread_list_td_ta_thr_iter (ops);
...
}
However, when live debugging, the target beneath, linux-nat.c, does
not implement the to_update_thread_list method. The result is that if
a thread is marked exited (because it can't be deleted right now,
e.g., it was the selected thread), then it won't ever be deleted,
until the process exits or is killed/detached.
A similar thing happens with the remote.c target. Because its
target_update_thread_list implementation skips exited threads when it
walks the current thread list looking for threads that no longer exits
on the target side, using ALL_NON_EXITED_THREADS_SAFE, stale exited
threads are never deleted.
This is not a big deal -- I can't think of any way this might be user
visible, other than gdb's memory growing a tiny bit whenever a thread
gets stuck in exited state. Still, might as well clean things up
properly.
All other targets use prune_threads, so are unaffected.
The fix adds a ALL_THREADS_SAFE macro, that like
ALL_NON_EXITED_THREADS_SAFE, walks the thread list and allows deleting
the iterated thread, and uses that in places that are walking the
thread list in order to delete threads. Actually, after converting
linux-nat.c and remote.c to use this, we find the only other user of
ALL_NON_EXITED_THREADS_SAFE is also walking the list to delete
threads. So we convert that too, and end up deleting
ALL_NON_EXITED_THREADS_SAFE.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog
2015-04-07 Pedro Alves <palves@redhat.com>
* gdbthread.h (ALL_NON_EXITED_THREADS_SAFE): Rename to ...
(ALL_THREADS_SAFE): ... this, and don't skip exited threads.
(delete_exited_threads): New declaration.
* infrun.c (follow_exec): Use ALL_THREADS_SAFE.
* linux-nat.c (linux_nat_update_thread_list): New function.
(linux_nat_add_target): Install it.
* remote.c (remote_update_thread_list): Use ALL_THREADS_SAFE.
* thread.c (prune_threads): Use ALL_THREADS_SAFE.
(delete_exited_threads): New function.
2015-04-07 16:47:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-05 20:21:34 +02:00
|
|
|
|
static const char *
|
* linux-nat.c (linux_nat_wait): Adjust.
(linux_nat_pid_to_str): Adjust. Remove call to thread_db_init.
* linux-nat.h (thread_db_init): Delete declaration.
* linux-thread-db.c (target_beneath): Delete.
(thread_db_init): Delete.
(thread_db_detach): Use find_target_beneath.
(thread_db_wait): Adjust interface. Use find_target_beneath.
(thread_db_mourn_inferior): Use find_target_beneath.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): Delete.
(thread_db_pid_to_str): Adjust interface. Use
find_target_beneath.
(thread_db_get_thread_local_address): Adjust interface. Use
find_target_beneath.
(init_thread_db_ops): Delete references to delete functions.
* target.c (update_current_target): Don't inherit or default
to_wait. Don't inherit to_pid_to_str and
to_get_thread_local_address.
(target_translate_tls_address): Look for a pushed target that
implements to_get_thread_local_address, and use it instead of
checking for target_get_thread_local_address_p.
(target_wait, target_pid_to_str): Reimplement as functions.
(dummy_pid_to_str): New.
(init_dummy_target): Register it.
(debug_to_wait): Delete.
* target.h (struct target_ops): Make to_wait, to_pid_to_str and
to_get_thread_local_address accept a pointer to struct target_ops.
(target_wait): Delete macro, and declare as function.
(target_pid_to_str): Likewise.
(target_get_thread_local_address)
(target_get_thread_local_address_p): Delete.
(noprocess): Add NORETURN and ATTR_NORETURN tags.
* inf-ptrace.c (inf_ptrace_wait): Adjust.
(inf_ptrace_pid_to_str): New.
(inf_ptrace_target): Use inf_ptrace_pid_to_str.
* aix-thread.c (aix_thread_wait, aix_thread_pid_to_str): Adjust.
* bsd-kvm.c (bsd_kvm_pid_to_str): Adjust.
* bsd-uthread.c (bsd_uthread_wait, bsd_uthread_pid_to_str):
Adjust.
* corelow.c (core_pid_to_str): Adjust.
* darwin-nat.c (darwin_wait, darwin_pid_to_str): Adjust.
* dec-thread.c (dec_thread_wait, dec_thread_pid_to_str): Adjust.
* gnu-nat.c (gnu_wait, gnu_pid_to_str): Adjust.
* go32-nat.c (go32_wait, go32_pid_to_str): Adjust.
* hpux-thread.c (hpux_thread_wait): Adjust.
* inf-ttrace.c (inf_ttrace_wait, inf_ttrace_pid_to_str): Adjust.
* monitor.c (monitor_wait, monitor_pid_to_str): Adjust.
* nto-procfs.c (procfs_wait, procfs_pid_to_str): Adjust.
* procfs.c (procfs_pid_to_str): Adjust.
* remote-m32r-sdi.c (m32r_wait, m32r_pid_to_str): Adjust.
* remote-mips.c (mips_wait): Adjust.
* remote-sim.c (gdbsim_wait, gdbsim_pid_to_str): Adjust.
* remote.c (remote_wait, remote_pid_to_str)
(remote_get_thread_local_address): Adjust.
* rs6000-nat.c (rs6000_wait): Adjust.
* sol-thread.c (procfs_pid_to_str): Adjust declaration.
(sol_thread_wait, solaris_pid_to_str): Adjust.
* spu-linux-nat.c (spu_child_wait): Adjust.
* windows-nat.c (windows_wait, windows_pid_to_str): Adjust.
2009-02-06 23:21:26 +01:00
|
|
|
|
linux_nat_pid_to_str (struct target_ops *ops, ptid_t ptid)
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
|
|
|
|
static char buf[64];
|
|
|
|
|
|
2013-09-30 13:50:12 +02:00
|
|
|
|
if (ptid_lwp_p (ptid)
|
|
|
|
|
&& (ptid_get_pid (ptid) != ptid_get_lwp (ptid)
|
|
|
|
|
|| num_lwps (ptid_get_pid (ptid)) > 1))
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
{
|
2013-09-30 13:50:12 +02:00
|
|
|
|
snprintf (buf, sizeof (buf), "LWP %ld", ptid_get_lwp (ptid));
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return normal_pid_to_str (ptid);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-26 15:49:03 +01:00
|
|
|
|
static const char *
|
2013-12-18 05:34:22 +01:00
|
|
|
|
linux_nat_thread_name (struct target_ops *self, struct thread_info *thr)
|
2011-01-19 18:21:39 +01:00
|
|
|
|
{
|
2015-11-26 15:49:04 +01:00
|
|
|
|
return linux_proc_tid_get_name (thr->ptid);
|
2011-01-19 18:21:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
/* Accepts an integer PID; Returns a string representing a file that
|
|
|
|
|
can be opened to get the symbols for the child process. */
|
|
|
|
|
|
2007-05-07 02:18:39 +02:00
|
|
|
|
static char *
|
2013-12-18 05:35:01 +01:00
|
|
|
|
linux_child_pid_to_exec_file (struct target_ops *self, int pid)
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
{
|
2015-04-17 10:47:30 +02:00
|
|
|
|
return linux_proc_pid_to_exec_file (pid);
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-14 11:14:49 +01:00
|
|
|
|
/* Implement the to_xfer_partial target method using /proc/<pid>/mem.
|
|
|
|
|
Because we can use a single read/write call, this can be much more
|
|
|
|
|
efficient than banging away at PTRACE_PEEKTEXT. */
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
static enum target_xfer_status
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
linux_proc_xfer_partial (struct target_ops *ops, enum target_object object,
|
|
|
|
|
const char *annex, gdb_byte *readbuf,
|
|
|
|
|
const gdb_byte *writebuf,
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
ULONGEST offset, LONGEST len, ULONGEST *xfered_len)
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
{
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
LONGEST ret;
|
|
|
|
|
int fd;
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
char filename[64];
|
|
|
|
|
|
2017-03-14 11:14:49 +01:00
|
|
|
|
if (object != TARGET_OBJECT_MEMORY)
|
2015-07-31 19:19:53 +02:00
|
|
|
|
return TARGET_XFER_EOF;
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
|
|
|
|
|
/* Don't bother for one word. */
|
|
|
|
|
if (len < 3 * sizeof (long))
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
return TARGET_XFER_EOF;
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
|
|
|
|
|
/* We could keep this file open and cache it - possibly one per
|
|
|
|
|
thread. That requires some juggling, but is even faster. */
|
Remove lwp -> pid conversion in linux_nat_xfer_partial
The linux_nat_xfer_partial does a conversion of inferior_ptid: if it's
an LWP (ptid::lwp != 0), it builds a new ptid with the lwp as
the pid and assigns that temporarily to inferior_ptid. For example, if
inferior_ptid is:
{ .pid = 1234, .lwp = 1235 }
it will assign this to inferior_ptid for the duration of the call:
{ .pid = 1235, .lwp = 0 }
Instead of doing this, this patch teaches the inf-ptrace implementation
of xfer_partial to deal with ptids representing lwps by using
get_ptrace_pid.
Also, in linux_proc_xfer_spu and linux_proc_xfer_partial, we use ptid_get_lwp
instead of ptid_get_pid. While not strictly necessary, since the content of
/proc/<pid> and /proc/<lwp> should be the same, it's a bit safer, because:
- some files under /proc/<pid>/ may not work if the <pid> thread is
running, just like ptrace requires a stopped thread. The current
thread's lwp id is more likely to be in the necessary state (stopped).
- if the leader (<pid>) had exited and is thus now zombie, then several
files under "/proc/<pid>" won't work, while they will if you use
"/proc/<lwp>".
The testsuite found no regression on native amd64 linux.
gdb/ChangeLog:
* inf-ptrace.c (inf_ptrace_xfer_partial): Get pid from ptid
using get_ptrace_pid.
* linux-nat.c (linux_nat_xfer_partial): Don't set/restore
inferior_ptid.
(linux_proc_xfer_partial, linux_proc_xfer_spu): Use lwp of
inferior_ptid instead of pid.
2017-03-22 15:35:07 +01:00
|
|
|
|
xsnprintf (filename, sizeof filename, "/proc/%ld/mem",
|
|
|
|
|
ptid_get_lwp (inferior_ptid));
|
2017-03-14 11:14:49 +01:00
|
|
|
|
fd = gdb_open_cloexec (filename, ((readbuf ? O_RDONLY : O_WRONLY)
|
|
|
|
|
| O_LARGEFILE), 0);
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
if (fd == -1)
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
return TARGET_XFER_EOF;
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
|
2017-03-14 11:14:49 +01:00
|
|
|
|
/* Use pread64/pwrite64 if available, since they save a syscall and can
|
|
|
|
|
handle 64-bit offsets even on 32-bit platforms (for instance, SPARC
|
|
|
|
|
debugging a SPARC64 application). */
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
#ifdef HAVE_PREAD64
|
2017-03-14 11:14:49 +01:00
|
|
|
|
ret = (readbuf ? pread64 (fd, readbuf, len, offset)
|
|
|
|
|
: pwrite64 (fd, writebuf, len, offset));
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
#else
|
2017-03-14 11:14:49 +01:00
|
|
|
|
ret = lseek (fd, offset, SEEK_SET);
|
|
|
|
|
if (ret != -1)
|
|
|
|
|
ret = (readbuf ? read (fd, readbuf, len)
|
|
|
|
|
: write (fd, writebuf, len));
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
close (fd);
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
|
2017-03-14 11:14:49 +01:00
|
|
|
|
if (ret == -1 || ret == 0)
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
return TARGET_XFER_EOF;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*xfered_len = ret;
|
|
|
|
|
return TARGET_XFER_OK;
|
|
|
|
|
}
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-07-31 17:25:22 +02:00
|
|
|
|
|
|
|
|
|
/* Enumerate spufs IDs for process PID. */
|
|
|
|
|
static LONGEST
|
2014-01-03 14:11:46 +01:00
|
|
|
|
spu_enumerate_spu_ids (int pid, gdb_byte *buf, ULONGEST offset, ULONGEST len)
|
2009-07-31 17:25:22 +02:00
|
|
|
|
{
|
* gdbarch.sh (target_gdbarch): Remove macro.
(get_target_gdbarch): Rename to target_gdbarch.
* gdbarch.c, gdbarch.h: Rebuild.
* ada-tasks.c, aix-thread.c, amd64-linux-nat.c, arch-utils.c,
arm-tdep.c, auxv.c, breakpoint.c, bsd-uthread.c, corefile.c,
darwin-nat-info.c, dcache.c, dsrec.c, exec.c, fbsd-nat.c,
filesystem.c, gcore.c, gnu-nat.c, i386-darwin-nat.c, i386-nat.c,
ia64-vms-tdep.c, inf-ptrace.c, infcmd.c, jit.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, m32r-rom.c, memattr.c,
mep-tdep.c, microblaze-tdep.c, mips-linux-nat.c,
mips-linux-tdep.c, mips-tdep.c, monitor.c, moxie-tdep.c,
nto-procfs.c, nto-tdep.c, ppc-linux-nat.c, proc-service.c,
procfs.c, progspace.c, ravenscar-thread.c, record.c,
remote-m32r-sdi.c, remote-mips.c, remote-sim.c, remote.c,
rl78-tdep.c, rs6000-nat.c, rx-tdep.c, s390-nat.c, sol-thread.c,
solib-darwin.c, solib-dsbt.c, solib-frv.c, solib-ia64-hpux.c,
solib-irix.c, solib-pa64.c, solib-som.c, solib-spu.c,
solib-sunos.c, solib-svr4.c, solib.c, spu-linux-nat.c,
spu-multiarch.c, spu-tdep.c, symfile-mem.c, symfile.c, symtab.c,
target-descriptions.c, target.c, target.h, tracepoint.c,
windows-nat.c, windows-tdep.c, xcoffsolib.c, cli/cli-dump.c,
common/agent.c, mi/mi-interp.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/python.c: Update.
2012-11-09 20:58:03 +01:00
|
|
|
|
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
|
2009-07-31 17:25:22 +02:00
|
|
|
|
LONGEST pos = 0;
|
|
|
|
|
LONGEST written = 0;
|
|
|
|
|
char path[128];
|
|
|
|
|
DIR *dir;
|
|
|
|
|
struct dirent *entry;
|
|
|
|
|
|
|
|
|
|
xsnprintf (path, sizeof path, "/proc/%d/fd", pid);
|
|
|
|
|
dir = opendir (path);
|
|
|
|
|
if (!dir)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
rewinddir (dir);
|
|
|
|
|
while ((entry = readdir (dir)) != NULL)
|
|
|
|
|
{
|
|
|
|
|
struct stat st;
|
|
|
|
|
struct statfs stfs;
|
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
|
|
fd = atoi (entry->d_name);
|
|
|
|
|
if (!fd)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
xsnprintf (path, sizeof path, "/proc/%d/fd/%d", pid, fd);
|
|
|
|
|
if (stat (path, &st) != 0)
|
|
|
|
|
continue;
|
|
|
|
|
if (!S_ISDIR (st.st_mode))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (statfs (path, &stfs) != 0)
|
|
|
|
|
continue;
|
|
|
|
|
if (stfs.f_type != SPUFS_MAGIC)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (pos >= offset && pos + 4 <= offset + len)
|
|
|
|
|
{
|
|
|
|
|
store_unsigned_integer (buf + pos - offset, 4, byte_order, fd);
|
|
|
|
|
written += 4;
|
|
|
|
|
}
|
|
|
|
|
pos += 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
closedir (dir);
|
|
|
|
|
return written;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implement the to_xfer_partial interface for the TARGET_OBJECT_SPU
|
|
|
|
|
object type, using the /proc file system. */
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
|
|
|
|
|
static enum target_xfer_status
|
2009-07-31 17:25:22 +02:00
|
|
|
|
linux_proc_xfer_spu (struct target_ops *ops, enum target_object object,
|
|
|
|
|
const char *annex, gdb_byte *readbuf,
|
|
|
|
|
const gdb_byte *writebuf,
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
|
2009-07-31 17:25:22 +02:00
|
|
|
|
{
|
|
|
|
|
char buf[128];
|
|
|
|
|
int fd = 0;
|
|
|
|
|
int ret = -1;
|
Remove lwp -> pid conversion in linux_nat_xfer_partial
The linux_nat_xfer_partial does a conversion of inferior_ptid: if it's
an LWP (ptid::lwp != 0), it builds a new ptid with the lwp as
the pid and assigns that temporarily to inferior_ptid. For example, if
inferior_ptid is:
{ .pid = 1234, .lwp = 1235 }
it will assign this to inferior_ptid for the duration of the call:
{ .pid = 1235, .lwp = 0 }
Instead of doing this, this patch teaches the inf-ptrace implementation
of xfer_partial to deal with ptids representing lwps by using
get_ptrace_pid.
Also, in linux_proc_xfer_spu and linux_proc_xfer_partial, we use ptid_get_lwp
instead of ptid_get_pid. While not strictly necessary, since the content of
/proc/<pid> and /proc/<lwp> should be the same, it's a bit safer, because:
- some files under /proc/<pid>/ may not work if the <pid> thread is
running, just like ptrace requires a stopped thread. The current
thread's lwp id is more likely to be in the necessary state (stopped).
- if the leader (<pid>) had exited and is thus now zombie, then several
files under "/proc/<pid>" won't work, while they will if you use
"/proc/<lwp>".
The testsuite found no regression on native amd64 linux.
gdb/ChangeLog:
* inf-ptrace.c (inf_ptrace_xfer_partial): Get pid from ptid
using get_ptrace_pid.
* linux-nat.c (linux_nat_xfer_partial): Don't set/restore
inferior_ptid.
(linux_proc_xfer_partial, linux_proc_xfer_spu): Use lwp of
inferior_ptid instead of pid.
2017-03-22 15:35:07 +01:00
|
|
|
|
int pid = ptid_get_lwp (inferior_ptid);
|
2009-07-31 17:25:22 +02:00
|
|
|
|
|
|
|
|
|
if (!annex)
|
|
|
|
|
{
|
|
|
|
|
if (!readbuf)
|
2014-01-27 10:32:33 +01:00
|
|
|
|
return TARGET_XFER_E_IO;
|
2009-07-31 17:25:22 +02:00
|
|
|
|
else
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
{
|
|
|
|
|
LONGEST l = spu_enumerate_spu_ids (pid, readbuf, offset, len);
|
|
|
|
|
|
|
|
|
|
if (l < 0)
|
|
|
|
|
return TARGET_XFER_E_IO;
|
|
|
|
|
else if (l == 0)
|
|
|
|
|
return TARGET_XFER_EOF;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*xfered_len = (ULONGEST) l;
|
|
|
|
|
return TARGET_XFER_OK;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-07-31 17:25:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xsnprintf (buf, sizeof buf, "/proc/%d/fd/%s", pid, annex);
|
PR gdb/7912:
* Makefile.in (SFILES): Add filestuff.c
(COMMON_OBS): Add filestuff.o.
(filestuff.o): New target.
* auto-load.c (auto_load_objfile_script_1): Use
gdb_fopen_cloexec.
* auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec.
* cli/cli-cmds.c (shell_escape): Call close_most_fds.
* cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec.
* common/agent.c (gdb_connect_sync_socket): Use
gdb_socket_cloexec.
* common/filestuff.c: New file.
* common/filestuff.h: New file.
* common/linux-osdata.c (linux_common_core_of_thread)
(command_from_pid, commandline_from_pid, print_source_lines)
(linux_xfer_osdata_shm, linux_xfer_osdata_sem)
(linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use
gdb_fopen_cloexec.
* common/linux-procfs.c (linux_proc_get_int)
(linux_proc_pid_has_state): Use gdb_fopen_cloexec.
* config.in, configure: Rebuild.
* configure.ac: Don't check for sys/socket.h. Check for
fdwalk, pipe2.
* corelow.c (core_open): Use gdb_open_cloexec.
* dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec.
* fork-child.c (fork_inferior): Call close_most_fds.
* gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec.
* inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec.
* linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals):
Use gdb_fopen_cloexec.
(linux_proc_xfer_partial, linux_proc_xfer_spu): Use
gdb_open_cloexec.
(linux_async_pipe): Use gdb_pipe_cloexec.
* remote-fileio.c (remote_fileio_func_open): Use
gdb_open_cloexec.
* remote.c (remote_file_put, remote_file_get): Use
gdb_fopen_cloexec.
* ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec,
close_most_fds.
* ser-tcp.c (net_open): Use gdb_socket_cloexec.
* ser-unix.c (hardwire_open): Use gdb_open_cloexec.
* solib.c (solib_find): Use gdb_open_cloexec.
* source.c (openp, find_and_open_source): Use gdb_open_cloexec.
* tracepoint.c (tfile_start): Use gdb_fopen_cloexec.
(tfile_open): Use gdb_open_cloexec.
* tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec.
* ui-file.c (gdb_fopen): Use gdb_fopen_cloexec.
* xml-support.c (xml_fetch_content_from_file): Use
gdb_fopen_cloexec.
* main.c (captured_main): Call notice_open_fds.
gdbserver
* Makefile.in (SFILES): Add filestuff.c.
(OBS): Add filestuff.o.
(filestuff.o): New target.
* config.in, configure: Rebuild.
* configure.ac: Check for fdwalk, pipe2.
2013-04-22 18:46:15 +02:00
|
|
|
|
fd = gdb_open_cloexec (buf, writebuf? O_WRONLY : O_RDONLY, 0);
|
2009-07-31 17:25:22 +02:00
|
|
|
|
if (fd <= 0)
|
2014-01-27 10:32:33 +01:00
|
|
|
|
return TARGET_XFER_E_IO;
|
2009-07-31 17:25:22 +02:00
|
|
|
|
|
|
|
|
|
if (offset != 0
|
|
|
|
|
&& lseek (fd, (off_t) offset, SEEK_SET) != (off_t) offset)
|
|
|
|
|
{
|
|
|
|
|
close (fd);
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
return TARGET_XFER_EOF;
|
2009-07-31 17:25:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (writebuf)
|
|
|
|
|
ret = write (fd, writebuf, (size_t) len);
|
|
|
|
|
else if (readbuf)
|
|
|
|
|
ret = read (fd, readbuf, (size_t) len);
|
|
|
|
|
|
|
|
|
|
close (fd);
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
|
return TARGET_XFER_E_IO;
|
|
|
|
|
else if (ret == 0)
|
|
|
|
|
return TARGET_XFER_EOF;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*xfered_len = (ULONGEST) ret;
|
|
|
|
|
return TARGET_XFER_OK;
|
|
|
|
|
}
|
2009-07-31 17:25:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
/* Parse LINE as a signal set and add its set bits to SIGS. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_line_to_sigset (const char *line, sigset_t *sigs)
|
|
|
|
|
{
|
|
|
|
|
int len = strlen (line) - 1;
|
|
|
|
|
const char *p;
|
|
|
|
|
int signum;
|
|
|
|
|
|
|
|
|
|
if (line[len] != '\n')
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Could not parse signal set: %s"), line);
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
|
|
|
|
|
p = line;
|
|
|
|
|
signum = len * 4;
|
|
|
|
|
while (len-- > 0)
|
|
|
|
|
{
|
|
|
|
|
int digit;
|
|
|
|
|
|
|
|
|
|
if (*p >= '0' && *p <= '9')
|
|
|
|
|
digit = *p - '0';
|
|
|
|
|
else if (*p >= 'a' && *p <= 'f')
|
|
|
|
|
digit = *p - 'a' + 10;
|
|
|
|
|
else
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Could not parse signal set: %s"), line);
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
|
|
|
|
|
signum -= 4;
|
|
|
|
|
|
|
|
|
|
if (digit & 1)
|
|
|
|
|
sigaddset (sigs, signum + 1);
|
|
|
|
|
if (digit & 2)
|
|
|
|
|
sigaddset (sigs, signum + 2);
|
|
|
|
|
if (digit & 4)
|
|
|
|
|
sigaddset (sigs, signum + 3);
|
|
|
|
|
if (digit & 8)
|
|
|
|
|
sigaddset (sigs, signum + 4);
|
|
|
|
|
|
|
|
|
|
p++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Find process PID's pending signals from /proc/pid/status and set
|
|
|
|
|
SIGS to match. */
|
|
|
|
|
|
|
|
|
|
void
|
2011-01-05 23:22:53 +01:00
|
|
|
|
linux_proc_pending_signals (int pid, sigset_t *pending,
|
|
|
|
|
sigset_t *blocked, sigset_t *ignored)
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
{
|
2013-07-01 13:28:30 +02:00
|
|
|
|
char buffer[PATH_MAX], fname[PATH_MAX];
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
|
|
|
|
|
sigemptyset (pending);
|
|
|
|
|
sigemptyset (blocked);
|
|
|
|
|
sigemptyset (ignored);
|
2013-11-04 04:16:37 +01:00
|
|
|
|
xsnprintf (fname, sizeof fname, "/proc/%d/status", pid);
|
Introduce and use gdb_file_up
This introduces gdb_file_up, a unique pointer holding a FILE*, and
then changes some code in gdb to use it. In particular
gdb_fopen_cloexec now returns a gdb_file_up. This allow removing some
cleanups.
ChangeLog
2017-08-03 Tom Tromey <tom@tromey.com>
* xml-support.c (xml_fetch_content_from_file): Update.
* ui-file.c (stdio_file::open): Update.
* tracefile-tfile.c (tfile_start): Update.
* remote.c (remote_file_put, remote_file_get): Update.
* nat/linux-procfs.c (linux_proc_get_int)
(linux_proc_pid_get_state, linux_proc_tid_get_name): Update.
* nat/linux-osdata.c (linux_common_core_of_thread): Update.
(command_from_pid, commandline_from_pid, linux_xfer_osdata_cpus)
(print_sockets, linux_xfer_osdata_shm, linux_xfer_osdata_sem)
(linux_xfer_osdata_msg, linux_xfer_osdata_modules): Update.
* nat/linux-btrace.c (linux_determine_kernel_start): Update.
* linux-nat.c (linux_proc_pending_signals): Update.
* dwarf2read.c (write_psymtabs_to_index): Use gdb_file_up.
(file_closer): Remove.
* compile/compile.c (compile_to_object): Update.
* common/filestuff.h (struct gdb_file_deleter): New.
(gdb_file_up): New typedef.
(gdb_fopen_cloexec): Change return type.
* common/filestuff.c (gdb_fopen_cloexec): Return gdb_file_up.
* cli/cli-dump.c (fopen_with_cleanup): Remove.
(dump_binary_file, restore_binary_file): Update.
* auto-load.c (auto_load_objfile_script_1): Update.
2017-04-27 05:39:46 +02:00
|
|
|
|
gdb_file_up procfile = gdb_fopen_cloexec (fname, "r");
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
if (procfile == NULL)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Could not open %s"), fname);
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
|
Introduce and use gdb_file_up
This introduces gdb_file_up, a unique pointer holding a FILE*, and
then changes some code in gdb to use it. In particular
gdb_fopen_cloexec now returns a gdb_file_up. This allow removing some
cleanups.
ChangeLog
2017-08-03 Tom Tromey <tom@tromey.com>
* xml-support.c (xml_fetch_content_from_file): Update.
* ui-file.c (stdio_file::open): Update.
* tracefile-tfile.c (tfile_start): Update.
* remote.c (remote_file_put, remote_file_get): Update.
* nat/linux-procfs.c (linux_proc_get_int)
(linux_proc_pid_get_state, linux_proc_tid_get_name): Update.
* nat/linux-osdata.c (linux_common_core_of_thread): Update.
(command_from_pid, commandline_from_pid, linux_xfer_osdata_cpus)
(print_sockets, linux_xfer_osdata_shm, linux_xfer_osdata_sem)
(linux_xfer_osdata_msg, linux_xfer_osdata_modules): Update.
* nat/linux-btrace.c (linux_determine_kernel_start): Update.
* linux-nat.c (linux_proc_pending_signals): Update.
* dwarf2read.c (write_psymtabs_to_index): Use gdb_file_up.
(file_closer): Remove.
* compile/compile.c (compile_to_object): Update.
* common/filestuff.h (struct gdb_file_deleter): New.
(gdb_file_up): New typedef.
(gdb_fopen_cloexec): Change return type.
* common/filestuff.c (gdb_fopen_cloexec): Return gdb_file_up.
* cli/cli-dump.c (fopen_with_cleanup): Remove.
(dump_binary_file, restore_binary_file): Update.
* auto-load.c (auto_load_objfile_script_1): Update.
2017-04-27 05:39:46 +02:00
|
|
|
|
while (fgets (buffer, PATH_MAX, procfile.get ()) != NULL)
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
{
|
|
|
|
|
/* Normal queued signals are on the SigPnd line in the status
|
|
|
|
|
file. However, 2.6 kernels also have a "shared" pending
|
|
|
|
|
queue for delivering signals to a thread group, so check for
|
|
|
|
|
a ShdPnd line also.
|
|
|
|
|
|
|
|
|
|
Unfortunately some Red Hat kernels include the shared pending
|
|
|
|
|
queue but not the ShdPnd status field. */
|
|
|
|
|
|
2015-03-06 10:42:06 +01:00
|
|
|
|
if (startswith (buffer, "SigPnd:\t"))
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
add_line_to_sigset (buffer + 8, pending);
|
2015-03-06 10:42:06 +01:00
|
|
|
|
else if (startswith (buffer, "ShdPnd:\t"))
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
add_line_to_sigset (buffer + 8, pending);
|
2015-03-06 10:42:06 +01:00
|
|
|
|
else if (startswith (buffer, "SigBlk:\t"))
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
add_line_to_sigset (buffer + 8, blocked);
|
2015-03-06 10:42:06 +01:00
|
|
|
|
else if (startswith (buffer, "SigIgn:\t"))
|
2004-09-28 Andrew Cagney <cagney@gnu.org>
* linux-proc.c: Delete file.
* Makefile.in: Update.
* config/sparc/linux64.mh (NATDEPFILES):
* config/sparc/linux.mh (NATDEPFILES): Update.
* config/s390/s390.mh (NATDEPFILES): Update.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Update.
* config/powerpc/linux.mh (NATDEPFILES): Update.
* config/pa/linux.mh (NATDEPFILES): Update.
* config/mips/linux.mh (NATDEPFILES): Update.
* config/m68k/linux.mh (NATDEPFILES): Update.
* config/ia64/linux.mh (NATDEPFILES): Update.
* config/i386/linux64.mh (NATDEPFILES): Update.
* config/i386/linux.mh (NATDEPFILES): Update.
* config/arm/linux.mh (NATDEPFILES): Update.
* config/alpha/alpha-linux.mh (NATDEPFILES): Update.
* linux-nat.c: Update copyright. Include <sys/param.h>,
<sys/procfs.h>, "elf-bfd.h", "gregset.h", <ctype.h>,
"gdbthread.h", "gdb_stat.h", <fcntl.h>.
(O_LARGEFILE): Possibly define.
(_initialize_linux_nat, linux_proc_pending_signals)
(add_line_to_sigset, linux_proc_xfer_memory)
(linux_nat_info_proc_cmd, linux_nat_make_corefile_notes)
(linux_nat_do_registers, linux_nat_corefile_thread_callback)
(struct linux_corefile_thread_data)
(linux_nat_do_thread_registers, linux_nat_find_memory_regions)
(child_pid_to_exec_file): Insert code previously in linux-proc.c.
2004-09-28 19:29:12 +02:00
|
|
|
|
add_line_to_sigset (buffer + 8, ignored);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
static enum target_xfer_status
|
2008-12-02 08:57:38 +01:00
|
|
|
|
linux_nat_xfer_osdata (struct target_ops *ops, enum target_object object,
|
2010-05-15 01:41:05 +02:00
|
|
|
|
const char *annex, gdb_byte *readbuf,
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
|
|
|
|
|
ULONGEST *xfered_len)
|
2008-12-02 08:57:38 +01:00
|
|
|
|
{
|
|
|
|
|
gdb_assert (object == TARGET_OBJECT_OSDATA);
|
|
|
|
|
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
*xfered_len = linux_common_xfer_osdata (annex, readbuf, offset, len);
|
|
|
|
|
if (*xfered_len == 0)
|
|
|
|
|
return TARGET_XFER_EOF;
|
|
|
|
|
else
|
|
|
|
|
return TARGET_XFER_OK;
|
2008-12-02 08:57:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
static enum target_xfer_status
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
linux_xfer_partial (struct target_ops *ops, enum target_object object,
|
|
|
|
|
const char *annex, gdb_byte *readbuf,
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
|
|
|
|
|
ULONGEST *xfered_len)
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
{
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
enum target_xfer_status xfer;
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
|
|
|
|
|
if (object == TARGET_OBJECT_AUXV)
|
2010-01-14 22:15:00 +01:00
|
|
|
|
return memory_xfer_auxv (ops, object, annex, readbuf, writebuf,
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
offset, len, xfered_len);
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
|
2008-12-02 08:57:38 +01:00
|
|
|
|
if (object == TARGET_OBJECT_OSDATA)
|
|
|
|
|
return linux_nat_xfer_osdata (ops, object, annex, readbuf, writebuf,
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
offset, len, xfered_len);
|
2008-12-02 08:57:38 +01:00
|
|
|
|
|
2009-07-31 17:25:22 +02:00
|
|
|
|
if (object == TARGET_OBJECT_SPU)
|
|
|
|
|
return linux_proc_xfer_spu (ops, object, annex, readbuf, writebuf,
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
offset, len, xfered_len);
|
2009-07-31 17:25:22 +02:00
|
|
|
|
|
2009-07-13 22:16:48 +02:00
|
|
|
|
/* GDB calculates all the addresses in possibly larget width of the address.
|
|
|
|
|
Address width needs to be masked before its final use - either by
|
|
|
|
|
linux_proc_xfer_partial or inf_ptrace_xfer_partial.
|
|
|
|
|
|
|
|
|
|
Compare ADDR_BIT first to avoid a compiler warning on shift overflow. */
|
|
|
|
|
|
|
|
|
|
if (object == TARGET_OBJECT_MEMORY)
|
|
|
|
|
{
|
* gdbarch.sh (target_gdbarch): Remove macro.
(get_target_gdbarch): Rename to target_gdbarch.
* gdbarch.c, gdbarch.h: Rebuild.
* ada-tasks.c, aix-thread.c, amd64-linux-nat.c, arch-utils.c,
arm-tdep.c, auxv.c, breakpoint.c, bsd-uthread.c, corefile.c,
darwin-nat-info.c, dcache.c, dsrec.c, exec.c, fbsd-nat.c,
filesystem.c, gcore.c, gnu-nat.c, i386-darwin-nat.c, i386-nat.c,
ia64-vms-tdep.c, inf-ptrace.c, infcmd.c, jit.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, m32r-rom.c, memattr.c,
mep-tdep.c, microblaze-tdep.c, mips-linux-nat.c,
mips-linux-tdep.c, mips-tdep.c, monitor.c, moxie-tdep.c,
nto-procfs.c, nto-tdep.c, ppc-linux-nat.c, proc-service.c,
procfs.c, progspace.c, ravenscar-thread.c, record.c,
remote-m32r-sdi.c, remote-mips.c, remote-sim.c, remote.c,
rl78-tdep.c, rs6000-nat.c, rx-tdep.c, s390-nat.c, sol-thread.c,
solib-darwin.c, solib-dsbt.c, solib-frv.c, solib-ia64-hpux.c,
solib-irix.c, solib-pa64.c, solib-som.c, solib-spu.c,
solib-sunos.c, solib-svr4.c, solib.c, spu-linux-nat.c,
spu-multiarch.c, spu-tdep.c, symfile-mem.c, symfile.c, symtab.c,
target-descriptions.c, target.c, target.h, tracepoint.c,
windows-nat.c, windows-tdep.c, xcoffsolib.c, cli/cli-dump.c,
common/agent.c, mi/mi-interp.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/python.c: Update.
2012-11-09 20:58:03 +01:00
|
|
|
|
int addr_bit = gdbarch_addr_bit (target_gdbarch ());
|
2009-07-13 22:16:48 +02:00
|
|
|
|
|
|
|
|
|
if (addr_bit < (sizeof (ULONGEST) * HOST_CHAR_BIT))
|
|
|
|
|
offset &= ((ULONGEST) 1 << addr_bit) - 1;
|
|
|
|
|
}
|
|
|
|
|
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
xfer = linux_proc_xfer_partial (ops, object, annex, readbuf, writebuf,
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
offset, len, xfered_len);
|
|
|
|
|
if (xfer != TARGET_XFER_EOF)
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
return xfer;
|
|
|
|
|
|
|
|
|
|
return super_xfer_partial (ops, object, annex, readbuf, writebuf,
|
Return target_xfer_status in to_xfer_partial
This patch does the conversion of to_xfer_partial from
LONGEST (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len);
to
enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len);
It changes to_xfer_partial return the transfer status and the transfered
length by *XFERED_LEN. Generally, the return status has three stats,
- TARGET_XFER_OK,
- TARGET_XFER_EOF,
- TARGET_XFER_E_XXXX,
See the comments to them in 'enum target_xfer_status'. Note that
Pedro suggested not name TARGET_XFER_DONE, as it is confusing,
compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF.
With this change, GDB core can handle unavailable data in a convenient
way.
The rationale behind this change was mentioned here
https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html
Consider an object/value like this:
0 100 150 200 512
DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III
where D is valid data, and xxx is unavailable data, and I is beyond
the end of the object (Invalid). Currently, if we start the
xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes.
The xfer machinery then retries fetching [100,512), and gets back
TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either
interested in either having the whole of the 512 bytes available,
or erroring out. But, in this scenario, we're interested in
the data at [150,512). The problem is that the last
TARGET_XFER_E_UNAVAILABLE gives us no indication where to
start the read next. We'd need something like:
get me [0,512) >>>
<<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK
get me [100,512) >>> (**1)
<<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE.
get me [150,512) >>>
<<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK.
get me [200,512) >>>
<<< no more data, return TARGET_XFER_EOF.
This naturally implies pushing down the decision of whether
to return TARGET_XFER_E_UNAVAILABLE or something else
down to the target. (Which kinds of leads back to tfile
itself reading from RO memory from file (though we could
export a function in exec.c for that that tfile delegates to,
instead of re-adding the old code).
Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to
check whether a status is an error or not, to stop using "status < 0".
This patch also eliminates the comparison between status and 0.
No target implementations to to_xfer_partial adapts this new
interface. The interface still behaves as before.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* target.h (enum target_xfer_error): Rename to ...
(enum target_xfer_status): ... it. New. All users updated.
(enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>:
New.
(TARGET_XFER_STATUS_ERROR_P): New macro.
(target_xfer_error_to_string): Remove declaration.
(target_xfer_status_to_string): Declare.
(target_xfer_partial_ftype): Adjust it.
(struct target_ops) <to_xfer_partial>: Return
target_xfer_status. Add argument xfered_len. Update
comments.
* target.c (target_xfer_error_to_string): Rename to ...
(target_xfer_status_to_string): ... it. New. All callers
updated.
(target_read_live_memory): Likewise. Call target_xfer_partial
instead of target_read.
(memory_xfer_live_readonly_partial): Return
target_xfer_status. Add argument xfered_len.
(raw_memory_xfer_partial): Likewise.
(memory_xfer_partial_1): Likewise.
(memory_xfer_partial): Likewise.
(target_xfer_partial): Likewise. Check *XFERED_LEN is set
properly. Update debug message.
(default_xfer_partial, current_xfer_partial): Likewise.
(target_write_partial): Likewise.
(target_read_partial): Likewise. All callers updated.
(read_whatever_is_readable): Likewise.
(target_write_with_progress): Likewise.
(target_read_alloc_1): Likewise.
* aix-thread.c (aix_thread_xfer_partial): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
(ld_so_xfer_auxv, memory_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* bsd-uthread.c (bsd_uthread_xfer_partia): Likewise.
* corefile.c (read_memory): Adjust.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise. All callers
updated.
(darwin_xfer_partial): Likewise.
* exec.c (section_table_xfer_memory_partial): Likewise. All
callers updated.
(exec_xfer_partial): Likewise.
* exec.h (section_table_xfer_memory_partial): Update
declaration.
* gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not
negative.
(gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise.
(ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise.
(ia64_hpux_xfer_solib_got): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change
type of 'partial_len' to ULONGEST.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo ): Likewise.
(linux_nat_xfer_partial): Likewise.
(linux_proc_xfer_partial, linux_xfer_partial): Likewise.
(linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
(monitor_xfer_partial): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-btrace.c (record_btrace_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_memory): Likewise.
(gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_bytes_aux): Likewise. All callers
updated.
(remote_write_bytes, remote_read_bytes): Likewise. All
callers updated.
(remote_flash_erase): Likewise. All callers updated.
(remote_write_qxfer): Likewise. All callers updated.
(remote_read_qxfer): Likewise. All callers updated.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sol-thread.c (sol_thread_xfer_partial): Likewise.
(sol_thread_xfer_partial): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
(sparc_xfer_partial): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers
updated.
(spu_xfer_partial): Likewise.
* spu-multiarch.c (spu_xfer_partial): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_memory): Likewise.
(windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
* valprint.c: Replace 'target_xfer_error' with
'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
|
|
|
|
offset, len, xfered_len);
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-03-03 10:51:29 +01:00
|
|
|
|
static void
|
|
|
|
|
cleanup_target_stop (void *arg)
|
|
|
|
|
{
|
|
|
|
|
ptid_t *ptid = (ptid_t *) arg;
|
|
|
|
|
|
|
|
|
|
gdb_assert (arg != NULL);
|
|
|
|
|
|
|
|
|
|
/* Unpause all */
|
Use target_continue{,_no_signal} instead of target_resume
This commit implements a new function, target_continue, on top of the
target_resume function. Then, it replaces all calls to target_resume
by calls to target_continue or to the already existing
target_continue_no_signal.
This is one of the (many) necessary steps needed to consolidate the
target interface between GDB and gdbserver. In particular, I am
interested in the impact this change will have on the unification of
the fork_inferior function (which I have been working on).
Tested on the BuildBot, no regressions introduced.
gdb/gdbserver/ChangeLog:
2016-09-31 Sergio Durigan Junior <sergiodj@redhat.com>
* server.c (start_inferior): New variable 'ptid'. Replace calls
to the_target->resume by target_continue{,_no_signal}, depending
on the case.
* target.c (target_stop_and_wait): Call target_continue_no_signal
instead of the_target->resume.
(target_continue): New function.
gdb/ChangeLog:
2016-09-31 Sergio Durigan Junior <sergiodj@redhat.com>
* fork-child.c (startup_inferior): Replace calls to target_resume
by target_continue{,_no_signal}, depending on the case.
* linux-nat.c (cleanup_target_stop): Call
target_continue_no_signal instead of target_resume.
* procfs.c (procfs_wait): Likewise.
* target.c (target_continue): New function.
* target/target.h (target_continue): New prototype.
2016-08-25 22:26:24 +02:00
|
|
|
|
target_continue_no_signal (*ptid);
|
2012-03-03 10:51:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-22 05:27:19 +01:00
|
|
|
|
static std::vector<static_tracepoint_marker>
|
2013-12-18 05:44:45 +01:00
|
|
|
|
linux_child_static_tracepoint_markers_by_strid (struct target_ops *self,
|
|
|
|
|
const char *strid)
|
2012-03-03 10:51:29 +01:00
|
|
|
|
{
|
|
|
|
|
char s[IPA_CMD_BUF_SIZE];
|
|
|
|
|
struct cleanup *old_chain;
|
|
|
|
|
int pid = ptid_get_pid (inferior_ptid);
|
2018-03-22 05:27:19 +01:00
|
|
|
|
std::vector<static_tracepoint_marker> markers;
|
Constify unpack_varlen_hex & fix fallout
I ran into non-const unpack_varlen_hex while working on something
else, and decided to just fix it first. Ends up constifying a good
deal of remote packet parsing.
gdb/ChangeLog:
2017-09-29 Pedro Alves <palves@redhat.com>
* common/rsp-low.c (unpack_varlen_hex): Constify.
* common/rsp-low.h (unpack_varlen_hex): Constify.
* linux-nat.c (linux_child_static_tracepoint_markers_by_strid):
Constify.
* remote.c (remote_set_permissions, read_ptid)
(remote_current_thread, remote_get_threads_with_qthreadinfo)
(remote_static_tracepoint_marker_at)
(remote_static_tracepoint_markers_by_strid)
(stop_reply_extract_thread, remote_parse_stop_reply): Constify.
* tracepoint.c (parse_trace_status, parse_tracepoint_status)
(parse_tracepoint_definition, parse_tsv_definition)
(parse_static_tracepoint_marker_definition): Constify.
* tracepoint.h (parse_static_tracepoint_marker_definition)
(parse_trace_status, parse_tracepoint_status)
(parse_tracepoint_definition, parse_tsv_definition): Constify.
gdb/gdbserver/ChangeLog:
2017-09-29 Pedro Alves <palves@redhat.com>
* ax.c (gdb_parse_agent_expr): Constify.
* ax.h (gdb_parse_agent_expr): Constify.
* mem-break.c (add_breakpoint_condition, add_breakpoint_commands):
Constify.
* mem-break.h (add_breakpoint_condition, add_breakpoint_commands): Constify.
* remote-utils.c (hex_or_minus_one, read_ptid): Constify.
* remote-utils.h (read_ptid): Constify.
* server.c (handle_qxfer_exec_file, handle_query, handle_v_cont)
(process_point_options, process_serial_event): Constify.
* tracepoint.c (add_tracepoint_action, cmd_qtdp, cmd_qtdpsrc)
(cmd_qtdv, cmd_qtenable_disable, cmd_qtro, cmd_qtframe, cmd_qtp)
(cmd_qtbuffer): Constify.
2017-09-29 18:15:36 +02:00
|
|
|
|
const char *p = s;
|
2012-03-03 10:51:29 +01:00
|
|
|
|
ptid_t ptid = ptid_build (pid, 0, 0);
|
2018-03-22 05:27:19 +01:00
|
|
|
|
static_tracepoint_marker marker;
|
2012-03-03 10:51:29 +01:00
|
|
|
|
|
|
|
|
|
/* Pause all */
|
|
|
|
|
target_stop (ptid);
|
|
|
|
|
|
|
|
|
|
memcpy (s, "qTfSTM", sizeof ("qTfSTM"));
|
|
|
|
|
s[sizeof ("qTfSTM")] = 0;
|
|
|
|
|
|
2012-04-16 13:24:47 +02:00
|
|
|
|
agent_run_command (pid, s, strlen (s) + 1);
|
2012-03-03 10:51:29 +01:00
|
|
|
|
|
2018-03-22 05:27:19 +01:00
|
|
|
|
old_chain = make_cleanup (cleanup_target_stop, &ptid);
|
2012-03-03 10:51:29 +01:00
|
|
|
|
|
|
|
|
|
while (*p++ == 'm')
|
|
|
|
|
{
|
|
|
|
|
do
|
|
|
|
|
{
|
2018-03-22 05:27:19 +01:00
|
|
|
|
parse_static_tracepoint_marker_definition (p, &p, &marker);
|
2012-03-03 10:51:29 +01:00
|
|
|
|
|
2018-03-22 05:27:19 +01:00
|
|
|
|
if (strid == NULL || marker.str_id == strid)
|
|
|
|
|
markers.push_back (std::move (marker));
|
2012-03-03 10:51:29 +01:00
|
|
|
|
}
|
|
|
|
|
while (*p++ == ','); /* comma-separated list */
|
|
|
|
|
|
|
|
|
|
memcpy (s, "qTsSTM", sizeof ("qTsSTM"));
|
|
|
|
|
s[sizeof ("qTsSTM")] = 0;
|
2012-04-16 13:24:47 +02:00
|
|
|
|
agent_run_command (pid, s, strlen (s) + 1);
|
2012-03-03 10:51:29 +01:00
|
|
|
|
p = s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
do_cleanups (old_chain);
|
|
|
|
|
|
|
|
|
|
return markers;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-11 21:35:29 +02:00
|
|
|
|
/* Create a prototype generic GNU/Linux target. The client can override
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
it with local methods. */
|
|
|
|
|
|
2007-04-26 00:17:48 +02:00
|
|
|
|
static void
|
|
|
|
|
linux_target_install_ops (struct target_ops *t)
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
{
|
2007-05-07 02:18:39 +02:00
|
|
|
|
t->to_insert_fork_catchpoint = linux_child_insert_fork_catchpoint;
|
2011-04-29 17:54:12 +02:00
|
|
|
|
t->to_remove_fork_catchpoint = linux_child_remove_fork_catchpoint;
|
2007-05-07 02:18:39 +02:00
|
|
|
|
t->to_insert_vfork_catchpoint = linux_child_insert_vfork_catchpoint;
|
2011-04-29 17:54:12 +02:00
|
|
|
|
t->to_remove_vfork_catchpoint = linux_child_remove_vfork_catchpoint;
|
2007-05-07 02:18:39 +02:00
|
|
|
|
t->to_insert_exec_catchpoint = linux_child_insert_exec_catchpoint;
|
2011-04-29 17:54:12 +02:00
|
|
|
|
t->to_remove_exec_catchpoint = linux_child_remove_exec_catchpoint;
|
2009-09-15 05:30:08 +02:00
|
|
|
|
t->to_set_syscall_catchpoint = linux_child_set_syscall_catchpoint;
|
2007-05-07 02:18:39 +02:00
|
|
|
|
t->to_pid_to_exec_file = linux_child_pid_to_exec_file;
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
t->to_post_startup_inferior = linux_child_post_startup_inferior;
|
2007-05-07 02:18:39 +02:00
|
|
|
|
t->to_post_attach = linux_child_post_attach;
|
|
|
|
|
t->to_follow_fork = linux_child_follow_fork;
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
|
|
|
|
|
super_xfer_partial = t->to_xfer_partial;
|
|
|
|
|
t->to_xfer_partial = linux_xfer_partial;
|
2012-03-03 10:51:29 +01:00
|
|
|
|
|
|
|
|
|
t->to_static_tracepoint_markers_by_strid
|
|
|
|
|
= linux_child_static_tracepoint_markers_by_strid;
|
2007-04-26 00:17:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct target_ops *
|
|
|
|
|
linux_target (void)
|
|
|
|
|
{
|
|
|
|
|
struct target_ops *t;
|
|
|
|
|
|
|
|
|
|
t = inf_ptrace_target ();
|
|
|
|
|
linux_target_install_ops (t);
|
|
|
|
|
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct target_ops *
|
2007-05-10 23:36:00 +02:00
|
|
|
|
linux_trad_target (CORE_ADDR (*register_u_offset)(struct gdbarch *, int, int))
|
2007-04-26 00:17:48 +02:00
|
|
|
|
{
|
|
|
|
|
struct target_ops *t;
|
|
|
|
|
|
|
|
|
|
t = inf_ptrace_trad_target (register_u_offset);
|
|
|
|
|
linux_target_install_ops (t);
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-10 20:11:14 +02:00
|
|
|
|
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
/* target_is_async_p implementation. */
|
|
|
|
|
|
|
|
|
|
static int
|
add "this" pointers to more target APIs
A subsequent pass introduces delegation helper functions to the target
API. This delegation is much cleaner if the target_ops pointer is
directly available at delegation time.
This patch adds the "this" pointer to various to_* methods for this
purpose.
This updates a number of ports which I am unable to test. Please give
them a look-over. Any possible problem here is trivial, though, as
all that is required is adding an argument to a function.
2014-02-19 Tom Tromey <tromey@redhat.com>
* aarch64-linux-nat.c (aarch64_linux_stopped_by_watchpoint):
Add 'ops' argument.
* arm-linux-nat.c (arm_linux_stopped_by_watchpoint): Add
'ops' argument.
* i386-nat.c (i386_stopped_by_watchpoint): Add 'ops' argument.
* ia64-linux-nat.c (ia64_linux_stopped_by_watchpoint): Add
'ops' argument.
* inf-ttrace.c (inf_ttrace_stopped_by_watchpoint): Add 'ops'
argument.
* linux-nat.c (save_sigtrap): Update.
(linux_nat_stopped_by_watchpoint, linux_nat_is_async_p)
(linux_nat_can_async_p, linux_nat_async): Add 'ops' argument.
(linux_nat_close): Update.
* mips-linux-nat.c (mips_linux_stopped_by_watchpoint): Add 'ops'
argument.
* ppc-linux-nat.c (ppc_linux_stopped_by_watchpoint): Add 'ops'
argument.
* procfs.c (procfs_stopped_by_watchpoint): Add 'ops' argument.
* record-full.c (record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_async, tmp_to_stopped_by_watchpoint)
(tmp_to_async): Add 'ops' argument.
(record_full_stopped_by_watchpoint, record_full_async)
(record_full_can_async_p, record_full_is_async_p): Add 'ops'
argument.
* remote-m32r-sdi.c (m32r_insert_breakpoint, m32r_remove_breakpoint)
(m32r_stopped_by_watchpoint): Add 'ops' argument.
* remote-mips.c (mips_stopped_by_watchpoint): Add 'ops' argument.
* remote.c (remote_stopped_by_watchpoint_p, remote_can_async_p)
(remote_is_async_p, remote_async): Add 'ops' argument.
(remote_stopped_data_address): Update.
* s390-nat.c (s390_stopped_by_watchpoint): Add 'ops' argument.
* target.c (update_current_target)
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Update.
(debug_to_stopped_by_watchpoint): Add 'ops' argument.
* target.h (struct target_ops) <to_stopped_by_watchpoint,
to_can_async_p, to_is_async_p, to_async>: Add 'ops' argument.
(target_can_async_p, target_is_async_p, target_async)
(target_stopped_by_watchpoint): Update.
2013-07-30 18:36:07 +02:00
|
|
|
|
linux_nat_is_async_p (struct target_ops *ops)
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
{
|
2015-01-23 12:12:39 +01:00
|
|
|
|
return linux_is_async_p ();
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* target_can_async_p implementation. */
|
|
|
|
|
|
|
|
|
|
static int
|
add "this" pointers to more target APIs
A subsequent pass introduces delegation helper functions to the target
API. This delegation is much cleaner if the target_ops pointer is
directly available at delegation time.
This patch adds the "this" pointer to various to_* methods for this
purpose.
This updates a number of ports which I am unable to test. Please give
them a look-over. Any possible problem here is trivial, though, as
all that is required is adding an argument to a function.
2014-02-19 Tom Tromey <tromey@redhat.com>
* aarch64-linux-nat.c (aarch64_linux_stopped_by_watchpoint):
Add 'ops' argument.
* arm-linux-nat.c (arm_linux_stopped_by_watchpoint): Add
'ops' argument.
* i386-nat.c (i386_stopped_by_watchpoint): Add 'ops' argument.
* ia64-linux-nat.c (ia64_linux_stopped_by_watchpoint): Add
'ops' argument.
* inf-ttrace.c (inf_ttrace_stopped_by_watchpoint): Add 'ops'
argument.
* linux-nat.c (save_sigtrap): Update.
(linux_nat_stopped_by_watchpoint, linux_nat_is_async_p)
(linux_nat_can_async_p, linux_nat_async): Add 'ops' argument.
(linux_nat_close): Update.
* mips-linux-nat.c (mips_linux_stopped_by_watchpoint): Add 'ops'
argument.
* ppc-linux-nat.c (ppc_linux_stopped_by_watchpoint): Add 'ops'
argument.
* procfs.c (procfs_stopped_by_watchpoint): Add 'ops' argument.
* record-full.c (record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_async, tmp_to_stopped_by_watchpoint)
(tmp_to_async): Add 'ops' argument.
(record_full_stopped_by_watchpoint, record_full_async)
(record_full_can_async_p, record_full_is_async_p): Add 'ops'
argument.
* remote-m32r-sdi.c (m32r_insert_breakpoint, m32r_remove_breakpoint)
(m32r_stopped_by_watchpoint): Add 'ops' argument.
* remote-mips.c (mips_stopped_by_watchpoint): Add 'ops' argument.
* remote.c (remote_stopped_by_watchpoint_p, remote_can_async_p)
(remote_is_async_p, remote_async): Add 'ops' argument.
(remote_stopped_data_address): Update.
* s390-nat.c (s390_stopped_by_watchpoint): Add 'ops' argument.
* target.c (update_current_target)
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Update.
(debug_to_stopped_by_watchpoint): Add 'ops' argument.
* target.h (struct target_ops) <to_stopped_by_watchpoint,
to_can_async_p, to_is_async_p, to_async>: Add 'ops' argument.
(target_can_async_p, target_is_async_p, target_async)
(target_stopped_by_watchpoint): Update.
2013-07-30 18:36:07 +02:00
|
|
|
|
linux_nat_can_async_p (struct target_ops *ops)
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
{
|
2017-01-12 17:04:53 +01:00
|
|
|
|
/* We're always async, unless the user explicitly prevented it with the
|
|
|
|
|
"maint set target-async" command. */
|
2011-06-06 14:47:07 +02:00
|
|
|
|
return target_async_permitted;
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
2008-08-19 15:22:14 +02:00
|
|
|
|
static int
|
2013-12-18 05:35:26 +01:00
|
|
|
|
linux_nat_supports_non_stop (struct target_ops *self)
|
2008-08-19 15:22:14 +02:00
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
Implement all-stop on top of a target running non-stop mode
This finally implements user-visible all-stop mode running with the
target_ops backend always in non-stop mode. This is a stepping stone
towards finer-grained control of threads, being able to do interesting
things like thread groups, associating groups with breakpoints, etc.
From the user's perspective, all-stop mode is really just a special
case of being able to stop and resume specific sets of threads, so it
makes sense to do this step first.
With this, even in all-stop, the target is no longer in charge of
stopping all threads before reporting an event to the core -- the core
takes care of it when it sees fit. For example, when "next"- or
"step"-ing, we can avoid stopping and resuming all threads at each
internal single-step, and instead only stop all threads when we're
about to present the stop to the user.
The implementation is almost straight forward, as the heavy lifting
has been done already in previous patches. Basically, we replace
checks for "set non-stop on/off" (the non_stop global), with calls to
a new target_is_non_stop_p function. In a few places, if "set
non-stop off", we stop all threads explicitly, and in a few other
places we resume all threads explicitly, making use of existing
methods that were added for teaching non-stop to step over breakpoints
without displaced stepping.
This adds a new "maint set target-non-stop on/off/auto" knob that
allows both disabling the feature if we find problems, and
force-enable it for development (useful when teaching a target about
this. The default is "auto", which means the feature is enabled if a
new target method says it should be enabled. The patch implements the
method in linux-nat.c, just for illustration, because it still returns
false. We'll need a few follow up fixes before turning it on by
default. This is a separate target method from indicating regular
non-stop support, because e.g., while e.g., native linux-nat.c is
close to regression free with all-stop-non-stop (with following
patches will fixing the remaining regressions), remote.c+gdbserver
will still need more fixing, even though it supports "set non-stop
on".
Tested on x86_64 Fedora 20, native, with and without "set displaced
off", and with and without "maint set target-non-stop on"; and also
against gdbserver.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* NEWS: Mention "maint set/show target-non-stop".
* breakpoint.c (update_global_location_list): Check
target_is_non_stop_p instead of non_stop.
* infcmd.c (attach_command_post_wait, attach_command): Likewise.
* infrun.c (show_can_use_displaced_stepping)
(can_use_displaced_stepping_p, start_step_over_inferior):
Likewise.
(internal_resume_ptid): New function.
(resume): Use it.
(proceed): Check target_is_non_stop_p instead of non_stop. If in
all-stop mode but the target is always in non-stop mode, start all
the other threads that are implicitly resumed too.
(for_each_just_stopped_thread, fetch_inferior_event)
(adjust_pc_after_break, stop_all_threads): Check
target_is_non_stop_p instead of non_stop.
(handle_inferior_event): Likewise. Handle detach-fork in all-stop
with the target always in non-stop mode.
(handle_signal_stop) <random signal>: Check target_is_non_stop_p
instead of non_stop.
(switch_back_to_stepped_thread): Check target_is_non_stop_p
instead of non_stop.
(keep_going_stepped_thread): Use internal_resume_ptid.
(stop_waiting): If in all-stop mode, and the target is in non-stop
mode, stop all threads.
(keep_going_pass): Likewise, when starting a new in-line step-over
sequence.
* linux-nat.c (get_pending_status, select_event_lwp)
(linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check
target_is_non_stop_p instead of non_stop.
(linux_nat_always_non_stop_p): New function.
(linux_nat_stop): Check target_is_non_stop_p instead of non_stop.
(linux_nat_add_target): Install linux_nat_always_non_stop_p.
* target-delegates.c: Regenerate.
* target.c (target_is_non_stop_p): New function.
(target_non_stop_enabled, target_non_stop_enabled_1): New globals.
(maint_set_target_non_stop_command)
(maint_show_target_non_stop_command): New functions.
(_initilize_target): Install "maint set/show target-non-stop"
commands.
* target.h (struct target_ops) <to_always_non_stop_p>: New field.
(target_non_stop_enabled): New declaration.
(target_is_non_stop_p): New declaration.
gdb/doc/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
target-non-stop".
2015-08-07 18:24:01 +02:00
|
|
|
|
/* to_always_non_stop_p implementation. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
linux_nat_always_non_stop_p (struct target_ops *self)
|
|
|
|
|
{
|
2015-08-06 19:23:01 +02:00
|
|
|
|
return 1;
|
Implement all-stop on top of a target running non-stop mode
This finally implements user-visible all-stop mode running with the
target_ops backend always in non-stop mode. This is a stepping stone
towards finer-grained control of threads, being able to do interesting
things like thread groups, associating groups with breakpoints, etc.
From the user's perspective, all-stop mode is really just a special
case of being able to stop and resume specific sets of threads, so it
makes sense to do this step first.
With this, even in all-stop, the target is no longer in charge of
stopping all threads before reporting an event to the core -- the core
takes care of it when it sees fit. For example, when "next"- or
"step"-ing, we can avoid stopping and resuming all threads at each
internal single-step, and instead only stop all threads when we're
about to present the stop to the user.
The implementation is almost straight forward, as the heavy lifting
has been done already in previous patches. Basically, we replace
checks for "set non-stop on/off" (the non_stop global), with calls to
a new target_is_non_stop_p function. In a few places, if "set
non-stop off", we stop all threads explicitly, and in a few other
places we resume all threads explicitly, making use of existing
methods that were added for teaching non-stop to step over breakpoints
without displaced stepping.
This adds a new "maint set target-non-stop on/off/auto" knob that
allows both disabling the feature if we find problems, and
force-enable it for development (useful when teaching a target about
this. The default is "auto", which means the feature is enabled if a
new target method says it should be enabled. The patch implements the
method in linux-nat.c, just for illustration, because it still returns
false. We'll need a few follow up fixes before turning it on by
default. This is a separate target method from indicating regular
non-stop support, because e.g., while e.g., native linux-nat.c is
close to regression free with all-stop-non-stop (with following
patches will fixing the remaining regressions), remote.c+gdbserver
will still need more fixing, even though it supports "set non-stop
on".
Tested on x86_64 Fedora 20, native, with and without "set displaced
off", and with and without "maint set target-non-stop on"; and also
against gdbserver.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* NEWS: Mention "maint set/show target-non-stop".
* breakpoint.c (update_global_location_list): Check
target_is_non_stop_p instead of non_stop.
* infcmd.c (attach_command_post_wait, attach_command): Likewise.
* infrun.c (show_can_use_displaced_stepping)
(can_use_displaced_stepping_p, start_step_over_inferior):
Likewise.
(internal_resume_ptid): New function.
(resume): Use it.
(proceed): Check target_is_non_stop_p instead of non_stop. If in
all-stop mode but the target is always in non-stop mode, start all
the other threads that are implicitly resumed too.
(for_each_just_stopped_thread, fetch_inferior_event)
(adjust_pc_after_break, stop_all_threads): Check
target_is_non_stop_p instead of non_stop.
(handle_inferior_event): Likewise. Handle detach-fork in all-stop
with the target always in non-stop mode.
(handle_signal_stop) <random signal>: Check target_is_non_stop_p
instead of non_stop.
(switch_back_to_stepped_thread): Check target_is_non_stop_p
instead of non_stop.
(keep_going_stepped_thread): Use internal_resume_ptid.
(stop_waiting): If in all-stop mode, and the target is in non-stop
mode, stop all threads.
(keep_going_pass): Likewise, when starting a new in-line step-over
sequence.
* linux-nat.c (get_pending_status, select_event_lwp)
(linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check
target_is_non_stop_p instead of non_stop.
(linux_nat_always_non_stop_p): New function.
(linux_nat_stop): Check target_is_non_stop_p instead of non_stop.
(linux_nat_add_target): Install linux_nat_always_non_stop_p.
* target-delegates.c: Regenerate.
* target.c (target_is_non_stop_p): New function.
(target_non_stop_enabled, target_non_stop_enabled_1): New globals.
(maint_set_target_non_stop_command)
(maint_show_target_non_stop_command): New functions.
(_initilize_target): Install "maint set/show target-non-stop"
commands.
* target.h (struct target_ops) <to_always_non_stop_p>: New field.
(target_non_stop_enabled): New declaration.
(target_is_non_stop_p): New declaration.
gdb/doc/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
target-non-stop".
2015-08-07 18:24:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
/* True if we want to support multi-process. To be removed when GDB
|
|
|
|
|
supports multi-exec. */
|
|
|
|
|
|
gdb/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* linux-nat.c (linux_child_follow_fork): If we're staying attached
to the child process, enable event reporting on it. Don't handle
checkpoints here. Instead, add the child fork to the lwp thread
and inferior lists without clobbering the previous inferior. Let
the thread_db layer learn about a new child process, even if
following the parent.
(linux_nat_switch_fork): Delete lwps of the current inferior only,
instead of clearing the whole list. Use thread_change_ptid to
give the core the illusion the new checkpoint is still the same
inferior. Clear the register cache.
(linux_handle_extended_wait): Handle checkpoints here.
(linux_multi_process): Turn on.
* linux-fork.c (struct fork_info) <pc>: Remove field.
(init_fork_list): Do not delete the checkpoint from the inferior
list (it is not there).
(fork_load_infrun_state): Don't switch inferior_ptid here. Pass
the new checkpoint's ptid to linux_nat_switch_fork.
(fork_save_infrun_state): Make static. Don't stop the pc field of
fork_info, it's gone.
(linux_fork_mourn_inferior): Don't delete the checkpoint from the
inferior list, it's not there.
(linux_fork_detach): Ditto.
(delete_fork_command): Replace mention of fork/checkpoint by
checkpoint only.
(detach_fork_command): Likewise. Don't delete the checkpoint from
the inferior list.
(info_forks_command): Adjust.
(restore_detach_fork): Delete.
(checkpointing_pid): New.
(linux_fork_checkpointing_p): New.
(save_detach_fork): Delete.
(checkpoint_command): Delete temp_detach_fork. Don't remove
breakpoints, that's a nop. Store the pid of the process we're
checkpointing, and use make_cleanup_restore_integer to restore it.
Don't reinsert breakpoints here.
(process_command, fork_command): Delete.
(restart_command): Update comments to only mention checkpoints,
not forks.
(_initialize_linux_fork): Delete "fork", "process", "info forks"
commands.
* linux-fork.h (fork_save_infrun_state, fork_list): Delete
declarations.
(linux_fork_checkpointing_p): Declare.
* cli/cli-cmds.c (killlist): New.
* cli/cli-cmds.h (killlist): Declare.
* gdbcmd.h (killlist): Declare.
* inferior.c: Include "gdbthread.h".
(detach_inferior_command, kill_inferior_command)
(inferior_command): New.
(info_inferiors_command): Allow specifying a specific inferior id.
(_initialize_inferiors): Register "inferior", "kill inferior" and
"detach inferior" commands.
* infcmd.c (_initialize_infcmd): Make "kill" a prefix command.
* gdbthread.h (any_thread_of_process): Declare.
* thread.c (any_thread_of_process): New.
* NEWS: Mention multi-inferior debugging. Mention 'info
inferiors', 'inferior', 'detach inferior' and 'kill inferior' as
new commands.
(Removed commands): New section, mentioning that 'info forks',
'fork', 'process', 'delete fork' and 'detach fork' are now gone.
gdb/testsuite/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.base/multi-forks.exp: Only run detach-on-fork tests on
linux. Adjust to use "inferior", "info inferiors", "detach
inferior" and "kill inferior" instead of "restart", "info fork",
"detach fork" and "delete fork".
* gdb.base/ending-run.exp: Spell out "info".
* gdb.base/help.exp: Adjust to use test_prefix_command_help for
the "kill" command.
gdb/doc/
2009-07-02 Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (Debugging multiple inferiors): Document the
"inferior", "detach inferior" and "kill inferior" commands.
(Debugging Programs with Multiple Processes): Adjust to mention
generic "inferior" commands. Delete mention of "detach fork" and
"delete fork". Cross reference to "Debugging multiple inferiors"
section.
2009-07-02 23:57:28 +02:00
|
|
|
|
int linux_multi_process = 1;
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
|
|
|
|
|
static int
|
2013-12-18 05:37:07 +01:00
|
|
|
|
linux_nat_supports_multi_process (struct target_ops *self)
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
{
|
|
|
|
|
return linux_multi_process;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-07 14:06:48 +02:00
|
|
|
|
static int
|
2013-12-18 05:37:32 +01:00
|
|
|
|
linux_nat_supports_disable_randomization (struct target_ops *self)
|
2011-10-07 14:06:48 +02:00
|
|
|
|
{
|
|
|
|
|
#ifdef HAVE_PERSONALITY
|
|
|
|
|
return 1;
|
|
|
|
|
#else
|
|
|
|
|
return 0;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
/* SIGCHLD handler that serves two purposes: In non-stop/async mode,
|
|
|
|
|
so we notice when any child changes state, and notify the
|
|
|
|
|
event-loop; it allows us to use sigsuspend in linux_nat_wait_1
|
|
|
|
|
above to wait for the arrival of a SIGCHLD. */
|
|
|
|
|
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
static void
|
2009-05-11 14:08:03 +02:00
|
|
|
|
sigchld_handler (int signo)
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
{
|
2009-05-11 14:08:03 +02:00
|
|
|
|
int old_errno = errno;
|
|
|
|
|
|
2011-05-13 19:31:07 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
ui_file_write_async_safe (gdb_stdlog,
|
|
|
|
|
"sigchld\n", sizeof ("sigchld\n") - 1);
|
2009-05-11 14:08:03 +02:00
|
|
|
|
|
|
|
|
|
if (signo == SIGCHLD
|
|
|
|
|
&& linux_nat_event_pipe[0] != -1)
|
|
|
|
|
async_file_mark (); /* Let the event loop know that there are
|
|
|
|
|
events to handle. */
|
|
|
|
|
|
|
|
|
|
errno = old_errno;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback registered with the target events file descriptor. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
handle_target_event (int error, gdb_client_data client_data)
|
|
|
|
|
{
|
Simplify target_async hook interface
All callers of target_async pass it the same callback
(inferior_event_handler). Since both common code and target backends
need to be able to put the target in and out of target async mode at
any given time, there's really no way that a different callback could
be passed. This commit simplifies things, and removes the indirection
altogether. Bonus: with this, gdb's target_async method ends up with
the same signature as gdbserver's.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog:
2015-03-25 Pedro Alves <palves@redhat.com>
* target.h <to_async>: Replace 'callback' and 'context' parameters
with boolean 'enable' parameter.
(target_async): Replace CALLBACK and CONTEXT parameters with
boolean ENABLE parameter.
* inf-loop.c (inferior_event_handler): Adjust.
* linux-nat.c (linux_nat_attach, linux_nat_resume)
(linux_nat_resume): Adjust.
(async_client_callback, async_client_context): Delete.
(handle_target_event): Call inferior_event_handler directly.
(linux_nat_async): Replace 'callback' and 'context' parameters
with boolean 'enable' parameter. Adjust. Remove references to
async_client_callback and async_client_context.
(linux_nat_close): Adjust.
* record-btrace.c (record_btrace_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_btrace_resume): Adjust.
* record-full.c (record_full_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_full_resume, record_full_core_resume): Adjust.
* remote.c (struct remote_state) <async_client_callback,
async_client_context>: Delete fields.
(remote_start_remote, extended_remote_attach_1, remote_resume)
(extended_remote_create_inferior): Adjust.
(remote_async_serial_handler): Call inferior_event_handler
directly.
(remote_async): Replace 'callback' and 'context' parameters with
boolean 'enable' parameter. Adjust.
* top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper):
Adjust.
* target-delegates.c: Regenerate.
2015-03-25 12:28:31 +01:00
|
|
|
|
inferior_event_handler (INF_REG_EVENT, NULL);
|
2009-05-11 14:08:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create/destroy the target events pipe. Returns previous state. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
linux_async_pipe (int enable)
|
|
|
|
|
{
|
2015-01-23 12:12:39 +01:00
|
|
|
|
int previous = linux_is_async_p ();
|
2009-05-11 14:08:03 +02:00
|
|
|
|
|
|
|
|
|
if (previous != enable)
|
|
|
|
|
{
|
|
|
|
|
sigset_t prev_mask;
|
|
|
|
|
|
linux-nat.c: no need to block child signals so aggressively.
In http://sourceware.org/ml/gdb-patches/2013-08/msg00174.html , the
issue of child signal handling around ptrace option support discovery
being different between GDB and GDBserver came up.
I recalled adding these block_child_signals calls, and the "We don't
want those ptrace calls to be interrupted" comment, but not exactly
why. So I looked into it. My first guess is that I got confused.
The patch that added this
<http://sourceware.org/ml/gdb-patches/2009-04/msg00125.html> rewrote
the linux native async support completely, and the old async support
code had the SIGCHLD handler itself do waitpid, so in places that we'd
want a blocking waitpid, we'd have to have the signal handler blocked.
That was probably the mindset I had at the time. Anyway, whatever the
case, looks like I was wrong on the need for this blocking.
Given GDBserver doesn't block like this, I investigated why this is
currently needed on GDB but not on GDBserver.
I removed the block_child_signals (and restore) calls, and hacked
linux-nat.c to call linux_test_for_tracefork in a loop, like:
@@ -534,7 +534,10 @@ static int
linux_supports_tracefork (int pid)
{
if (linux_supports_tracefork_flag == -1)
- linux_test_for_tracefork (pid);
+ {
+ while (1)
+ linux_test_for_tracefork (pid);
+ }
return linux_supports_tracefork_flag;
}
Running the resulting GDB, I then saw bad things happening.
Specifically, I'd end up with a bunch of zombies, and eventually, the
machine would refuse to spawn new processes, claming insufficient
resources.
The issue is that linux_test_for_tracefork test forks, and has the
child fork again. If we don't block SIGCHLD on entry to the function,
the children will inherit SIGCHLD's action/disposition (meaning,
SIGCHLD will be unblocked in the child). When the first child forks
again a second child, and that child exits, the first child gets a
SIGCHLD. Now, when we try to wrap up for the whole options test, we
kill the first child, and collect the waitstatus. Here, when SIGCHLD
isn't blocked, GDB will first see the child reporting a stop with
SIGCHLD. gdbserver's ptrace options test does a PTRACE_KILL loop at
the end, which catches the SIGCHLD, and retries the kill. The GDB
version did not do that. So the GDB version would proceed, leaving
the child zombie (until GDB exists), as nothing collected its final
waitstatus.
So this patch makes the GDB version of linux_test_for_tracefork do the
exact same as the GDBserver version, removes all this unnecessary
blocking throughout, and adds a couple comments at places that do need
it -- namely: places where we'll use sleep with sigsuspend; and
linux_async_pipe, as that destroys the pipe the signal handler
touches.
Tested on x86_64 Fedora 17, sync and async.
gdb/
2013-08-19 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_test_for_tracefork)
(linux_test_for_tracesysgood, linux_child_follow_fork)
(lin_lwp_attach_lwp, linux_nat_resume): Don't block child signals.
(linux_nat_wait_1): Extend comment.
(linux_async_pipe): Add comment.
2013-08-19 15:44:41 +02:00
|
|
|
|
/* Block child signals while we create/destroy the pipe, as
|
|
|
|
|
their handler writes to it. */
|
2009-05-11 14:08:03 +02:00
|
|
|
|
block_child_signals (&prev_mask);
|
|
|
|
|
|
|
|
|
|
if (enable)
|
|
|
|
|
{
|
PR gdb/7912:
* Makefile.in (SFILES): Add filestuff.c
(COMMON_OBS): Add filestuff.o.
(filestuff.o): New target.
* auto-load.c (auto_load_objfile_script_1): Use
gdb_fopen_cloexec.
* auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec.
* cli/cli-cmds.c (shell_escape): Call close_most_fds.
* cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec.
* common/agent.c (gdb_connect_sync_socket): Use
gdb_socket_cloexec.
* common/filestuff.c: New file.
* common/filestuff.h: New file.
* common/linux-osdata.c (linux_common_core_of_thread)
(command_from_pid, commandline_from_pid, print_source_lines)
(linux_xfer_osdata_shm, linux_xfer_osdata_sem)
(linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use
gdb_fopen_cloexec.
* common/linux-procfs.c (linux_proc_get_int)
(linux_proc_pid_has_state): Use gdb_fopen_cloexec.
* config.in, configure: Rebuild.
* configure.ac: Don't check for sys/socket.h. Check for
fdwalk, pipe2.
* corelow.c (core_open): Use gdb_open_cloexec.
* dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec.
* fork-child.c (fork_inferior): Call close_most_fds.
* gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec.
* inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec.
* linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals):
Use gdb_fopen_cloexec.
(linux_proc_xfer_partial, linux_proc_xfer_spu): Use
gdb_open_cloexec.
(linux_async_pipe): Use gdb_pipe_cloexec.
* remote-fileio.c (remote_fileio_func_open): Use
gdb_open_cloexec.
* remote.c (remote_file_put, remote_file_get): Use
gdb_fopen_cloexec.
* ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec,
close_most_fds.
* ser-tcp.c (net_open): Use gdb_socket_cloexec.
* ser-unix.c (hardwire_open): Use gdb_open_cloexec.
* solib.c (solib_find): Use gdb_open_cloexec.
* source.c (openp, find_and_open_source): Use gdb_open_cloexec.
* tracepoint.c (tfile_start): Use gdb_fopen_cloexec.
(tfile_open): Use gdb_open_cloexec.
* tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec.
* ui-file.c (gdb_fopen): Use gdb_fopen_cloexec.
* xml-support.c (xml_fetch_content_from_file): Use
gdb_fopen_cloexec.
* main.c (captured_main): Call notice_open_fds.
gdbserver
* Makefile.in (SFILES): Add filestuff.c.
(OBS): Add filestuff.o.
(filestuff.o): New target.
* config.in, configure: Rebuild.
* configure.ac: Check for fdwalk, pipe2.
2013-04-22 18:46:15 +02:00
|
|
|
|
if (gdb_pipe_cloexec (linux_nat_event_pipe) == -1)
|
2009-05-11 14:08:03 +02:00
|
|
|
|
internal_error (__FILE__, __LINE__,
|
|
|
|
|
"creating event pipe failed.");
|
|
|
|
|
|
|
|
|
|
fcntl (linux_nat_event_pipe[0], F_SETFL, O_NONBLOCK);
|
|
|
|
|
fcntl (linux_nat_event_pipe[1], F_SETFL, O_NONBLOCK);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
close (linux_nat_event_pipe[0]);
|
|
|
|
|
close (linux_nat_event_pipe[1]);
|
|
|
|
|
linux_nat_event_pipe[0] = -1;
|
|
|
|
|
linux_nat_event_pipe[1] = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
restore_child_signals_mask (&prev_mask);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return previous;
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* target_async implementation. */
|
|
|
|
|
|
|
|
|
|
static void
|
Simplify target_async hook interface
All callers of target_async pass it the same callback
(inferior_event_handler). Since both common code and target backends
need to be able to put the target in and out of target async mode at
any given time, there's really no way that a different callback could
be passed. This commit simplifies things, and removes the indirection
altogether. Bonus: with this, gdb's target_async method ends up with
the same signature as gdbserver's.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog:
2015-03-25 Pedro Alves <palves@redhat.com>
* target.h <to_async>: Replace 'callback' and 'context' parameters
with boolean 'enable' parameter.
(target_async): Replace CALLBACK and CONTEXT parameters with
boolean ENABLE parameter.
* inf-loop.c (inferior_event_handler): Adjust.
* linux-nat.c (linux_nat_attach, linux_nat_resume)
(linux_nat_resume): Adjust.
(async_client_callback, async_client_context): Delete.
(handle_target_event): Call inferior_event_handler directly.
(linux_nat_async): Replace 'callback' and 'context' parameters
with boolean 'enable' parameter. Adjust. Remove references to
async_client_callback and async_client_context.
(linux_nat_close): Adjust.
* record-btrace.c (record_btrace_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_btrace_resume): Adjust.
* record-full.c (record_full_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_full_resume, record_full_core_resume): Adjust.
* remote.c (struct remote_state) <async_client_callback,
async_client_context>: Delete fields.
(remote_start_remote, extended_remote_attach_1, remote_resume)
(extended_remote_create_inferior): Adjust.
(remote_async_serial_handler): Call inferior_event_handler
directly.
(remote_async): Replace 'callback' and 'context' parameters with
boolean 'enable' parameter. Adjust.
* top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper):
Adjust.
* target-delegates.c: Regenerate.
2015-03-25 12:28:31 +01:00
|
|
|
|
linux_nat_async (struct target_ops *ops, int enable)
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
{
|
Simplify target_async hook interface
All callers of target_async pass it the same callback
(inferior_event_handler). Since both common code and target backends
need to be able to put the target in and out of target async mode at
any given time, there's really no way that a different callback could
be passed. This commit simplifies things, and removes the indirection
altogether. Bonus: with this, gdb's target_async method ends up with
the same signature as gdbserver's.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog:
2015-03-25 Pedro Alves <palves@redhat.com>
* target.h <to_async>: Replace 'callback' and 'context' parameters
with boolean 'enable' parameter.
(target_async): Replace CALLBACK and CONTEXT parameters with
boolean ENABLE parameter.
* inf-loop.c (inferior_event_handler): Adjust.
* linux-nat.c (linux_nat_attach, linux_nat_resume)
(linux_nat_resume): Adjust.
(async_client_callback, async_client_context): Delete.
(handle_target_event): Call inferior_event_handler directly.
(linux_nat_async): Replace 'callback' and 'context' parameters
with boolean 'enable' parameter. Adjust. Remove references to
async_client_callback and async_client_context.
(linux_nat_close): Adjust.
* record-btrace.c (record_btrace_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_btrace_resume): Adjust.
* record-full.c (record_full_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_full_resume, record_full_core_resume): Adjust.
* remote.c (struct remote_state) <async_client_callback,
async_client_context>: Delete fields.
(remote_start_remote, extended_remote_attach_1, remote_resume)
(extended_remote_create_inferior): Adjust.
(remote_async_serial_handler): Call inferior_event_handler
directly.
(remote_async): Replace 'callback' and 'context' parameters with
boolean 'enable' parameter. Adjust.
* top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper):
Adjust.
* target-delegates.c: Regenerate.
2015-03-25 12:28:31 +01:00
|
|
|
|
if (enable)
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
{
|
2009-05-11 14:08:03 +02:00
|
|
|
|
if (!linux_async_pipe (1))
|
|
|
|
|
{
|
|
|
|
|
add_file_handler (linux_nat_event_pipe[0],
|
|
|
|
|
handle_target_event, NULL);
|
|
|
|
|
/* There may be pending events to handle. Tell the event loop
|
|
|
|
|
to poll them. */
|
|
|
|
|
async_file_mark ();
|
|
|
|
|
}
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
delete_file_handler (linux_nat_event_pipe[0]);
|
2009-05-11 14:08:03 +02:00
|
|
|
|
linux_async_pipe (0);
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-24 18:51:47 +02:00
|
|
|
|
/* Stop an LWP, and push a GDB_SIGNAL_0 stop status if no other
|
2008-10-24 01:11:21 +02:00
|
|
|
|
event came out. */
|
|
|
|
|
|
2008-07-11 00:58:37 +02:00
|
|
|
|
static int
|
2008-10-24 01:11:21 +02:00
|
|
|
|
linux_nat_stop_lwp (struct lwp_info *lwp, void *data)
|
2008-07-11 00:58:37 +02:00
|
|
|
|
{
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
if (!lwp->stopped)
|
2008-10-24 01:11:21 +02:00
|
|
|
|
{
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LNSL: running -> suspending %s\n",
|
|
|
|
|
target_pid_to_str (lwp->ptid));
|
2008-10-24 01:11:21 +02:00
|
|
|
|
|
|
|
|
|
|
2011-09-09 21:27:50 +02:00
|
|
|
|
if (lwp->last_resume_kind == resume_stop)
|
|
|
|
|
{
|
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"linux-nat: already stopping LWP %ld at "
|
|
|
|
|
"GDB's request\n",
|
|
|
|
|
ptid_get_lwp (lwp->ptid));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2008-10-24 01:11:21 +02:00
|
|
|
|
|
2011-09-09 21:27:50 +02:00
|
|
|
|
stop_callback (lwp, NULL);
|
|
|
|
|
lwp->last_resume_kind = resume_stop;
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Already known to be stopped; do nothing. */
|
2008-10-24 01:11:21 +02:00
|
|
|
|
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
if (debug_linux_nat)
|
|
|
|
|
{
|
2009-05-24 23:06:53 +02:00
|
|
|
|
if (find_thread_ptid (lwp->ptid)->stop_requested)
|
2011-01-05 23:22:53 +01:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LNSL: already stopped/stop_requested %s\n",
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
target_pid_to_str (lwp->ptid));
|
|
|
|
|
else
|
2011-01-05 23:22:53 +01:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
"LNSL: already stopped/no "
|
|
|
|
|
"stop_requested yet %s\n",
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
target_pid_to_str (lwp->ptid));
|
2008-10-24 01:11:21 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2008-07-11 00:58:37 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2013-12-18 05:34:36 +01:00
|
|
|
|
linux_nat_stop (struct target_ops *self, ptid_t ptid)
|
2008-07-11 00:58:37 +02:00
|
|
|
|
{
|
Fix interrupt-noterm.exp on targets always in non-stop
With "maint set target-non-stop on" we get:
@@ -66,13 +66,16 @@ Continuing.
interrupt
(gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt
-Program received signal SIGINT, Interrupt.
-PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT
-testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds
+[process 12119] #1 stopped.
+0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81
+81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
+FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout)
+testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds
That is, we get "[$thread] #1 stopped" instead of SIGINT.
The issue is that we don't currently distinguish send
"interrupt/ctrl-c" to target terminal vs "stop/pause" thread well;
both cases go through "target_stop".
And then, the native Linux backend (linux-nat.c) implements
target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop
mode. Since "maint set target-non-stop on" forces the backend to be
always running in non-stop mode, even though the user-visible behavior
is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of
the SIGINT the test expects.
Fix this by introducing a target_interrupt method to use in the
"interrupt/ctrl-c" case, so "set non-stop off" can always work the
same irrespective of "maint set target-non-stop on/off". I'm
explictly considering changing the "set non-stop on" behavior as out
of scope here.
Most of the patch is an across-the-board rename of to_stop hook
implementations to to_interrupt. The only targets where something
more than a rename is being done are linux-nat.c and remote.c, which
are the only targets that support async, and thus are the only ones
the core side calls target_stop on.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* darwin-nat.c (darwin_stop): Rename to ...
(darwin_interrupt): ... this.
(_initialize_darwin_inferior): Adjust.
* gnu-nat.c (gnu_stop): Delete.
(gnu_target): Don't install gnu_stop.
* inf-ptrace.c (inf_ptrace_stop): Rename to ...
(inf_ptrace_interrupt): ... this.
(inf_ptrace_target): Adjust.
* infcmd.c (interrupt_target_1): Use target_interrupt instead of
target_stop.
* linux-nat (linux_nat_stop): Rename to ...
(linux_nat_interrupt): ... this.
(linux_nat_stop): Reimplement.
(linux_nat_add_target): Install linux_nat_interrupt.
* nto-procfs.c (nto_interrupt_twice): Rename to ...
(nto_handle_sigint_twice): ... this.
(nto_interrupt): Rename to ...
(nto_handle_sigint): ... this. Call target_interrupt instead of
target_stop.
(procfs_wait): Adjust.
(procfs_stop): Rename to ...
(procfs_interrupt): ... this.
(init_procfs_targets): Adjust.
* procfs.c (procfs_stop): Rename to ...
(procfs_interrupt): ... this.
(procfs_target): Adjust.
* remote-m32r-sdi.c (m32r_stop): Rename to ...
(m32r_interrupt): ... this.
(init_m32r_ops): Adjust.
* remote-sim.c (gdbsim_stop_inferior): Rename to ...
(gdbsim_interrupt_inferior): ... this.
(gdbsim_stop): Rename to ...
(gdbsim_interrupt): ... this.
(gdbsim_cntrl_c): Adjust.
(init_gdbsim_ops): Adjust.
* remote.c (sync_remote_interrupt): Adjust comments.
(remote_stop_as): Rename to ...
(remote_interrupt_as): ... this.
(remote_stop): Adjust comment.
(remote_interrupt): New function.
(init_remote_ops): Install remote_interrupt.
* target.c (target_interrupt): New function.
* target.h (struct target_ops) <to_interrupt>: New field.
(target_interrupt): New declaration.
* windows-nat.c (windows_stop): Rename to ...
(windows_interrupt): ... this.
* target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
|
|
|
|
iterate_over_lwps (ptid, linux_nat_stop_lwp, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
static void
|
2013-12-18 05:27:56 +01:00
|
|
|
|
linux_nat_close (struct target_ops *self)
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
{
|
|
|
|
|
/* Unregister from the event loop. */
|
2014-08-25 21:19:01 +02:00
|
|
|
|
if (linux_nat_is_async_p (self))
|
Simplify target_async hook interface
All callers of target_async pass it the same callback
(inferior_event_handler). Since both common code and target backends
need to be able to put the target in and out of target async mode at
any given time, there's really no way that a different callback could
be passed. This commit simplifies things, and removes the indirection
altogether. Bonus: with this, gdb's target_async method ends up with
the same signature as gdbserver's.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog:
2015-03-25 Pedro Alves <palves@redhat.com>
* target.h <to_async>: Replace 'callback' and 'context' parameters
with boolean 'enable' parameter.
(target_async): Replace CALLBACK and CONTEXT parameters with
boolean ENABLE parameter.
* inf-loop.c (inferior_event_handler): Adjust.
* linux-nat.c (linux_nat_attach, linux_nat_resume)
(linux_nat_resume): Adjust.
(async_client_callback, async_client_context): Delete.
(handle_target_event): Call inferior_event_handler directly.
(linux_nat_async): Replace 'callback' and 'context' parameters
with boolean 'enable' parameter. Adjust. Remove references to
async_client_callback and async_client_context.
(linux_nat_close): Adjust.
* record-btrace.c (record_btrace_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_btrace_resume): Adjust.
* record-full.c (record_full_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_full_resume, record_full_core_resume): Adjust.
* remote.c (struct remote_state) <async_client_callback,
async_client_context>: Delete fields.
(remote_start_remote, extended_remote_attach_1, remote_resume)
(extended_remote_create_inferior): Adjust.
(remote_async_serial_handler): Call inferior_event_handler
directly.
(remote_async): Replace 'callback' and 'context' parameters with
boolean 'enable' parameter. Adjust.
* top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper):
Adjust.
* target-delegates.c: Regenerate.
2015-03-25 12:28:31 +01:00
|
|
|
|
linux_nat_async (self, 0);
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
|
|
|
|
|
if (linux_ops->to_close)
|
2013-12-18 05:27:56 +01:00
|
|
|
|
linux_ops->to_close (linux_ops);
|
Allow making GDB not automatically connect to the native target.
Sometimes it's useful to be able to disable the automatic connection
to the native target. E.g., sometimes GDB disconnects from the
extended-remote target I was debugging, without me noticing it, and
then I do "run". That starts the program locally, and only after a
little head scratch session do I figure out the program is running
locally instead of remotely as intended. Same thing with "attach",
"info os", etc.
With the patch, we now can have this instead:
(gdb) set auto-connect-native-target off
(gdb) target extended-remote :9999
...
*gdb disconnects*
(gdb) run
Don't know how to run. Try "help target".
To still be able to connect to the native target with
auto-connect-native-target set to off, I've made "target native" work
instead of erroring out as today.
Before:
(gdb) target native
Use the "run" command to start a native process.
After:
(gdb) target native
Done. Use the "run" command to start a process.
(gdb) maint print target-stack
The current target stack is:
- native (Native process)
- exec (Local exec file)
- None (None)
(gdb) run
Starting program: ./a.out
...
I've also wanted this for the testsuite, when running against the
native-extended-gdbserver.exp board (runs against gdbserver in
extended-remote mode). With a non-native-target board, it's always a
bug to launch a program with the native target. Turns out we still
have one such case this patch catches:
(gdb) break main
Breakpoint 1 at 0x4009e5: file ../../../src/gdb/testsuite/gdb.base/coremaker.c, line 138.
(gdb) run
Don't know how to run. Try "help target".
(gdb) FAIL: gdb.base/corefile.exp: run: with core
On the patch itself, probably the least obvious bit is the need to go
through all targets, and move the unpush_target call to after the
generic_mourn_inferior call instead of before. This is what
inf-ptrace.c does too, ever since multi-process support was added.
The reason inf-ptrace.c does things in that order is that in the
current multi-process/single-target model, we shouldn't unpush the
target if there are still other live inferiors being debugged. The
check for that is "have_inferiors ()" (a misnomer nowadays...), which
does:
have_inferiors (void)
{
for (inf = inferior_list; inf; inf = inf->next)
if (inf->pid != 0)
return 1;
It's generic_mourn_inferior that ends up clearing inf->pid, so we need
to call it before the have_inferiors check. To make all native
targets behave the same WRT to explicit "target native", I've added an
inf_child_maybe_unpush_target function that targets call instead of
calling unpush_target directly, and as that includes the
have_inferiors check, I needed to adjust the targets.
Tested on x86_64 Fedora 20, native, and also with the
extended-gdbserver board.
Confirmed a cross build of djgpp gdb still builds.
Smoke tested a cross build of Windows gdb under Wine.
Untested otherwise.
gdb/
2014-05-21 Pedro Alves <palves@redhat.com>
* inf-child.c (inf_child_ops, inf_child_explicitly_opened): New
globals.
(inf_child_open_target): New function.
(inf_child_open): Use inf_child_open_target to push the target
instead of erroring out.
(inf_child_disconnect, inf_child_close)
(inf_child_maybe_unpush_target): New functions.
(inf_child_target): Install inf_child_disconnect and
inf_child_close. Store a pointer to the returned object.
* inf-child.h (inf_child_open_target, inf_child_maybe_unpush): New
declarations.
* target.c (auto_connect_native_target): New global.
(show_default_run_target): New function.
(find_default_run_target): Return NULL if automatically connecting
to the native target is disabled.
(_initialize_target): Install set/show auto-connect-native-target.
* NEWS: Mention "set auto-connect-native-target", and "target
native".
* linux-nat.c (super_close): New global.
(linux_nat_close): Call super_close.
(linux_nat_add_target): Store a pointer to the base class's
to_close method.
* inf-ptrace.c (inf_ptrace_mourn_inferior, inf_ptrace_detach): Use
inf_child_maybe_unpush.
* inf-ttrace.c (inf_ttrace_him): Don't push the target if it is
already pushed.
(inf_ttrace_mourn_inferior): Only unpush the target after mourning
the inferior. Use inf_child_maybe_unpush_target.
(inf_ttrace_attach): Don't push the target if it is already
pushed.
(inf_ttrace_detach): Use inf_child_maybe_unpush_target.
* darwin-nat.c (darwin_mourn_inferior): Only unpush the target
after mourning the inferior. Use inf_child_maybe_unpush_target.
(darwin_attach_pid): Don't push the target if it is already
pushed.
* gnu-nat.c (gnu_mourn_inferior): Only unpush the target after
mourning the inferior. Use inf_child_maybe_unpush_target.
(gnu_detach): Use inf_child_maybe_unpush_target.
* go32-nat.c (go32_create_inferior): Don't push the target if it
is already pushed.
(go32_mourn_inferior): Use inf_child_maybe_unpush_target.
* nto-procfs.c (procfs_is_nto_target): Adjust comment.
(procfs_open): Rename to ...
(procfs_open_1): ... this. Add target_ops parameter. Adjust
comments. Can target_preopen before changing node. Call
inf_child_open_target to push the target explicitly.
(procfs_attach): Don't push the target if it is already pushed.
(procfs_detach): Use inf_child_maybe_unpush_target.
(procfs_create_inferior): Don't push the target if it is already
pushed.
(nto_native_ops): New global.
(procfs_open): Reimplement.
(procfs_native_open): New function.
(init_procfs_targets): Install procfs_native_open as to_open of
"target native". Store a pointer to the "native" target in
nto_native_ops.
* procfs.c (procfs_attach): Don't push the target if it is already
pushed.
(procfs_detach): Use inf_child_maybe_unpush_target.
(procfs_mourn_inferior): Only unpush the target after mourning the
inferior. Use inf_child_maybe_unpush_target.
(procfs_init_inferior): Don't push the target if it is already
pushed.
* windows-nat.c (do_initial_windows_stuff): Don't push the target
if it is already pushed.
(windows_detach): Use inf_child_maybe_unpush_target.
(windows_mourn_inferior): Only unpush the target after mourning
the inferior. Use inf_child_maybe_unpush_target.
gdb/doc/
2014-05-21 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Starting): Document "set/show
auto-connect-native-target".
(Target Commands): Document "target native".
gdb/testsuite/
2014-05-21 Pedro Alves <palves@redhat.com>
* boards/gdbserver-base.exp (GDBFLAGS): Set to "set
auto-connect-native-target off".
* gdb.base/auto-connect-native-target.c: New file.
* gdb.base/auto-connect-native-target.exp: New file.
2014-05-21 19:30:47 +02:00
|
|
|
|
|
|
|
|
|
super_close (self);
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-20 13:09:01 +02:00
|
|
|
|
/* When requests are passed down from the linux-nat layer to the
|
|
|
|
|
single threaded inf-ptrace layer, ptids of (lwpid,0,0) form are
|
|
|
|
|
used. The address space pointer is stored in the inferior object,
|
|
|
|
|
but the common code that is passed such ptid can't tell whether
|
|
|
|
|
lwpid is a "main" process id or not (it assumes so). We reverse
|
|
|
|
|
look up the "main" process id from the lwp here. */
|
|
|
|
|
|
2012-03-01 Pedro Alves <palves@redhat.com>
* amd64-linux-tdep.c (amd64_linux_record_signal): Make static.
* breakpoint.c (create_exception_master_breakpoint, trace_command)
(ftrace_command, strace_command): Make static.
* d-lang.c (_initialize_d_language): Declare.
* dwarf2expr.c (_initialize_dwarf2expr): Declare.
* dwarf2loc.c (_initialize_dwarf2loc):
* dwarf2read.c (process_psymtab_comp_unit): Make static.
* exec.c (exec_get_section_table): Make static.
* i386-linux-tdep.c (i386_linux_record_signal): Make static.
* infcmd.c (ensure_valid_thread, ensure_not_tfind_mode): Make static.
* inferior.c (remove_inferior_command, add_inferior_command)
(clone_inferior_command): Make static.
* linux-nat.c (linux_nat_thread_address_space)
(linux_nat_core_of_thread): Make static.
* linux-tdep.c (_initialize_linux_tdep): Declare.
* objc-lang.c (_initialize_objc_lang): Declare.
* opencl-lang.c (builtin_opencl_type, opencl_language_arch_info):
Make static.
(_initialize_opencl_language): Declare.
* record.c (_initialize_record): Declare.
* remote.c (demand_private_info, remote_get_tib_address)
(remote_supports_cond_tracepoints)
(remote_supports_fast_tracepoints, remote_get_tracepoint_status):
Make static.
* skip.c (_initialize_step_skip): Declare.
* symtab.c (skip_prologue_using_lineinfo): Make static.
* tracepoint.c (delete_trace_state_variable)
(trace_variable_command, delete_trace_variable_command)
(get_uploaded_tsv, find_matching_tracepoint_location)
(find_matching_tsv, create_tsv_from_upload, get_traceframe_info):
Make static.
* value.c (pack_unsigned_long): Make static.
* varobj.c (varobj_ensure_python_env): Make static.
* windows-tdep.c (_initialize_windows_tdep): Declare.
* xml-syscall.c (make_cleanup_free_syscalls_info): Make static.
2012-03-01 22:14:00 +01:00
|
|
|
|
static struct address_space *
|
2009-10-20 13:09:01 +02:00
|
|
|
|
linux_nat_thread_address_space (struct target_ops *t, ptid_t ptid)
|
|
|
|
|
{
|
|
|
|
|
struct lwp_info *lwp;
|
|
|
|
|
struct inferior *inf;
|
|
|
|
|
int pid;
|
|
|
|
|
|
2013-09-30 13:50:12 +02:00
|
|
|
|
if (ptid_get_lwp (ptid) == 0)
|
2009-10-20 13:09:01 +02:00
|
|
|
|
{
|
|
|
|
|
/* An (lwpid,0,0) ptid. Look up the lwp object to get at the
|
|
|
|
|
tgid. */
|
|
|
|
|
lwp = find_lwp_pid (ptid);
|
2013-09-30 13:50:12 +02:00
|
|
|
|
pid = ptid_get_pid (lwp->ptid);
|
2009-10-20 13:09:01 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* A (pid,lwpid,0) ptid. */
|
2013-09-30 13:50:12 +02:00
|
|
|
|
pid = ptid_get_pid (ptid);
|
2009-10-20 13:09:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inf = find_inferior_pid (pid);
|
|
|
|
|
gdb_assert (inf != NULL);
|
|
|
|
|
return inf->aspace;
|
|
|
|
|
}
|
|
|
|
|
|
Implement core awareness.
* bcache.c (compare_ints): Remove
(print_percentage): Use compare_positive_ints.
* defs.h (compare_positive_ints): Declare.
* linux-nat.h (struct lin_lwp): New field core.
(linux_nat_core_of_thread_1): Declare.
* linux-nat.c (add_lwp): Init the 'core' field.
(linux_nat_wait_1): Record the core.
(linux_nat_core_of_thread_1, linux_nat_core_of_thread): New.
(linux_nat_add_target): Register the above.
* linux-thread-db.c (update_thread_core): New.
(thread_db_find_new_threads): Update core information for
every thread.
* remote.c (struct private_thread_info): New.
(free_private_thread_info, demand_private_info): New.
(PACKET_qXfer_threads, use_osdata_threads): New.
(struct thread_item, threads_parsing_context
(start_thread, end_thread, thread_attributes)
(thread_children, threads_children, threads_elements): New.
(remote_threads_info): Try qXfer:threads before anything
else.
(remote_protocol_packets): Register qXfer:threads.
(remote_open_1): Init use_osdata_threads.
(struct stop_reply): New field 'core'.
(remote_parse_stop_reply): Parse core number.
(process_stop_reply): Record core number.
(remote_xfer_partial): Handle qXfer:threads.
(remote_core_of_thread): New.
(init_remote_ops): Register remote_core_of_thread.
(_initialize_remote): Register qXfer:read.
* target.c (target_core_of_thread): New
* target.h (enum target_object): New value TARGET_OBJECT_THREADS.
(struct target_ops): New field to_core_of_threads.
(target_core_of_thread): Declare.
* gdbthread.h (struct thread_info): New field private_dtor.
* thread.c (print_thread_info): Report the core.
* ui-out.c (MAX_UI_OUT_LEVELS): Increase.
* utils.c (compare_positive_ints): New.
* features/threads.dtd: New.
* mi/mi-interp.c (mi_on_normal_stop): Report the core.
* mi/mi-main.c (struct collect_cores_data, collect_cores)
(do_nothing, free_vector_of_osdata_items)
(splay_tree_int_comparator, free_splay_tree): New.
(print_one_inferior_data): Implemented printing of selected
inferiors. Collect and print cores.
(output_cores): New.
(mi_cmd_list_thread_groups): Support --recurse. Permit specifying
thread groups together with --available.
2010-01-12 22:40:25 +01:00
|
|
|
|
/* Return the cached value of the processor core for thread PTID. */
|
|
|
|
|
|
2012-03-01 Pedro Alves <palves@redhat.com>
* amd64-linux-tdep.c (amd64_linux_record_signal): Make static.
* breakpoint.c (create_exception_master_breakpoint, trace_command)
(ftrace_command, strace_command): Make static.
* d-lang.c (_initialize_d_language): Declare.
* dwarf2expr.c (_initialize_dwarf2expr): Declare.
* dwarf2loc.c (_initialize_dwarf2loc):
* dwarf2read.c (process_psymtab_comp_unit): Make static.
* exec.c (exec_get_section_table): Make static.
* i386-linux-tdep.c (i386_linux_record_signal): Make static.
* infcmd.c (ensure_valid_thread, ensure_not_tfind_mode): Make static.
* inferior.c (remove_inferior_command, add_inferior_command)
(clone_inferior_command): Make static.
* linux-nat.c (linux_nat_thread_address_space)
(linux_nat_core_of_thread): Make static.
* linux-tdep.c (_initialize_linux_tdep): Declare.
* objc-lang.c (_initialize_objc_lang): Declare.
* opencl-lang.c (builtin_opencl_type, opencl_language_arch_info):
Make static.
(_initialize_opencl_language): Declare.
* record.c (_initialize_record): Declare.
* remote.c (demand_private_info, remote_get_tib_address)
(remote_supports_cond_tracepoints)
(remote_supports_fast_tracepoints, remote_get_tracepoint_status):
Make static.
* skip.c (_initialize_step_skip): Declare.
* symtab.c (skip_prologue_using_lineinfo): Make static.
* tracepoint.c (delete_trace_state_variable)
(trace_variable_command, delete_trace_variable_command)
(get_uploaded_tsv, find_matching_tracepoint_location)
(find_matching_tsv, create_tsv_from_upload, get_traceframe_info):
Make static.
* value.c (pack_unsigned_long): Make static.
* varobj.c (varobj_ensure_python_env): Make static.
* windows-tdep.c (_initialize_windows_tdep): Declare.
* xml-syscall.c (make_cleanup_free_syscalls_info): Make static.
2012-03-01 22:14:00 +01:00
|
|
|
|
static int
|
Implement core awareness.
* bcache.c (compare_ints): Remove
(print_percentage): Use compare_positive_ints.
* defs.h (compare_positive_ints): Declare.
* linux-nat.h (struct lin_lwp): New field core.
(linux_nat_core_of_thread_1): Declare.
* linux-nat.c (add_lwp): Init the 'core' field.
(linux_nat_wait_1): Record the core.
(linux_nat_core_of_thread_1, linux_nat_core_of_thread): New.
(linux_nat_add_target): Register the above.
* linux-thread-db.c (update_thread_core): New.
(thread_db_find_new_threads): Update core information for
every thread.
* remote.c (struct private_thread_info): New.
(free_private_thread_info, demand_private_info): New.
(PACKET_qXfer_threads, use_osdata_threads): New.
(struct thread_item, threads_parsing_context
(start_thread, end_thread, thread_attributes)
(thread_children, threads_children, threads_elements): New.
(remote_threads_info): Try qXfer:threads before anything
else.
(remote_protocol_packets): Register qXfer:threads.
(remote_open_1): Init use_osdata_threads.
(struct stop_reply): New field 'core'.
(remote_parse_stop_reply): Parse core number.
(process_stop_reply): Record core number.
(remote_xfer_partial): Handle qXfer:threads.
(remote_core_of_thread): New.
(init_remote_ops): Register remote_core_of_thread.
(_initialize_remote): Register qXfer:read.
* target.c (target_core_of_thread): New
* target.h (enum target_object): New value TARGET_OBJECT_THREADS.
(struct target_ops): New field to_core_of_threads.
(target_core_of_thread): Declare.
* gdbthread.h (struct thread_info): New field private_dtor.
* thread.c (print_thread_info): Report the core.
* ui-out.c (MAX_UI_OUT_LEVELS): Increase.
* utils.c (compare_positive_ints): New.
* features/threads.dtd: New.
* mi/mi-interp.c (mi_on_normal_stop): Report the core.
* mi/mi-main.c (struct collect_cores_data, collect_cores)
(do_nothing, free_vector_of_osdata_items)
(splay_tree_int_comparator, free_splay_tree): New.
(print_one_inferior_data): Implemented printing of selected
inferiors. Collect and print cores.
(output_cores): New.
(mi_cmd_list_thread_groups): Support --recurse. Permit specifying
thread groups together with --available.
2010-01-12 22:40:25 +01:00
|
|
|
|
linux_nat_core_of_thread (struct target_ops *ops, ptid_t ptid)
|
|
|
|
|
{
|
|
|
|
|
struct lwp_info *info = find_lwp_pid (ptid);
|
2010-05-15 01:41:05 +02:00
|
|
|
|
|
Implement core awareness.
* bcache.c (compare_ints): Remove
(print_percentage): Use compare_positive_ints.
* defs.h (compare_positive_ints): Declare.
* linux-nat.h (struct lin_lwp): New field core.
(linux_nat_core_of_thread_1): Declare.
* linux-nat.c (add_lwp): Init the 'core' field.
(linux_nat_wait_1): Record the core.
(linux_nat_core_of_thread_1, linux_nat_core_of_thread): New.
(linux_nat_add_target): Register the above.
* linux-thread-db.c (update_thread_core): New.
(thread_db_find_new_threads): Update core information for
every thread.
* remote.c (struct private_thread_info): New.
(free_private_thread_info, demand_private_info): New.
(PACKET_qXfer_threads, use_osdata_threads): New.
(struct thread_item, threads_parsing_context
(start_thread, end_thread, thread_attributes)
(thread_children, threads_children, threads_elements): New.
(remote_threads_info): Try qXfer:threads before anything
else.
(remote_protocol_packets): Register qXfer:threads.
(remote_open_1): Init use_osdata_threads.
(struct stop_reply): New field 'core'.
(remote_parse_stop_reply): Parse core number.
(process_stop_reply): Record core number.
(remote_xfer_partial): Handle qXfer:threads.
(remote_core_of_thread): New.
(init_remote_ops): Register remote_core_of_thread.
(_initialize_remote): Register qXfer:read.
* target.c (target_core_of_thread): New
* target.h (enum target_object): New value TARGET_OBJECT_THREADS.
(struct target_ops): New field to_core_of_threads.
(target_core_of_thread): Declare.
* gdbthread.h (struct thread_info): New field private_dtor.
* thread.c (print_thread_info): Report the core.
* ui-out.c (MAX_UI_OUT_LEVELS): Increase.
* utils.c (compare_positive_ints): New.
* features/threads.dtd: New.
* mi/mi-interp.c (mi_on_normal_stop): Report the core.
* mi/mi-main.c (struct collect_cores_data, collect_cores)
(do_nothing, free_vector_of_osdata_items)
(splay_tree_int_comparator, free_splay_tree): New.
(print_one_inferior_data): Implemented printing of selected
inferiors. Collect and print cores.
(output_cores): New.
(mi_cmd_list_thread_groups): Support --recurse. Permit specifying
thread groups together with --available.
2010-01-12 22:40:25 +01:00
|
|
|
|
if (info)
|
|
|
|
|
return info->core;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-10 15:28:43 +02:00
|
|
|
|
/* Implementation of to_filesystem_is_local. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
linux_nat_filesystem_is_local (struct target_ops *ops)
|
|
|
|
|
{
|
|
|
|
|
struct inferior *inf = current_inferior ();
|
|
|
|
|
|
|
|
|
|
if (inf->fake_pid_p || inf->pid == 0)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return linux_ns_same (inf->pid, LINUX_NS_MNT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Convert the INF argument passed to a to_fileio_* method
|
|
|
|
|
to a process ID suitable for passing to its corresponding
|
|
|
|
|
linux_mntns_* function. If INF is non-NULL then the
|
|
|
|
|
caller is requesting the filesystem seen by INF. If INF
|
|
|
|
|
is NULL then the caller is requesting the filesystem seen
|
|
|
|
|
by the GDB. We fall back to GDB's filesystem in the case
|
|
|
|
|
that INF is non-NULL but its PID is unknown. */
|
|
|
|
|
|
|
|
|
|
static pid_t
|
|
|
|
|
linux_nat_fileio_pid_of (struct inferior *inf)
|
|
|
|
|
{
|
|
|
|
|
if (inf == NULL || inf->fake_pid_p || inf->pid == 0)
|
|
|
|
|
return getpid ();
|
|
|
|
|
else
|
|
|
|
|
return inf->pid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implementation of to_fileio_open. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
linux_nat_fileio_open (struct target_ops *self,
|
|
|
|
|
struct inferior *inf, const char *filename,
|
2015-08-21 18:09:20 +02:00
|
|
|
|
int flags, int mode, int warn_if_slow,
|
|
|
|
|
int *target_errno)
|
2015-06-10 15:28:43 +02:00
|
|
|
|
{
|
|
|
|
|
int nat_flags;
|
|
|
|
|
mode_t nat_mode;
|
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
|
|
if (fileio_to_host_openflags (flags, &nat_flags) == -1
|
|
|
|
|
|| fileio_to_host_mode (mode, &nat_mode) == -1)
|
|
|
|
|
{
|
|
|
|
|
*target_errno = FILEIO_EINVAL;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fd = linux_mntns_open_cloexec (linux_nat_fileio_pid_of (inf),
|
|
|
|
|
filename, nat_flags, nat_mode);
|
|
|
|
|
if (fd == -1)
|
|
|
|
|
*target_errno = host_to_fileio_error (errno);
|
|
|
|
|
|
|
|
|
|
return fd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implementation of to_fileio_readlink. */
|
|
|
|
|
|
2017-11-23 07:37:38 +01:00
|
|
|
|
static gdb::optional<std::string>
|
2015-06-10 15:28:43 +02:00
|
|
|
|
linux_nat_fileio_readlink (struct target_ops *self,
|
|
|
|
|
struct inferior *inf, const char *filename,
|
|
|
|
|
int *target_errno)
|
|
|
|
|
{
|
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
|
|
len = linux_mntns_readlink (linux_nat_fileio_pid_of (inf),
|
|
|
|
|
filename, buf, sizeof (buf));
|
|
|
|
|
if (len < 0)
|
|
|
|
|
{
|
|
|
|
|
*target_errno = host_to_fileio_error (errno);
|
2017-11-23 07:37:38 +01:00
|
|
|
|
return {};
|
2015-06-10 15:28:43 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-23 07:37:38 +01:00
|
|
|
|
return std::string (buf, len);
|
2015-06-10 15:28:43 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implementation of to_fileio_unlink. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
linux_nat_fileio_unlink (struct target_ops *self,
|
|
|
|
|
struct inferior *inf, const char *filename,
|
|
|
|
|
int *target_errno)
|
|
|
|
|
{
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
ret = linux_mntns_unlink (linux_nat_fileio_pid_of (inf),
|
|
|
|
|
filename);
|
|
|
|
|
if (ret == -1)
|
|
|
|
|
*target_errno = host_to_fileio_error (errno);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-24 15:47:56 +02:00
|
|
|
|
/* Implementation of the to_thread_events method. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
linux_nat_thread_events (struct target_ops *ops, int enable)
|
|
|
|
|
{
|
|
|
|
|
report_thread_events = enable;
|
|
|
|
|
}
|
|
|
|
|
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
void
|
|
|
|
|
linux_nat_add_target (struct target_ops *t)
|
|
|
|
|
{
|
|
|
|
|
/* Save the provided single-threaded target. We save this in a separate
|
|
|
|
|
variable because another target we've inherited from (e.g. inf-ptrace)
|
|
|
|
|
may have saved a pointer to T; we want to use it for the final
|
|
|
|
|
process stratum target. */
|
|
|
|
|
linux_ops_saved = *t;
|
|
|
|
|
linux_ops = &linux_ops_saved;
|
|
|
|
|
|
|
|
|
|
/* Override some methods for multithreading. */
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
t->to_create_inferior = linux_nat_create_inferior;
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
t->to_attach = linux_nat_attach;
|
|
|
|
|
t->to_detach = linux_nat_detach;
|
|
|
|
|
t->to_resume = linux_nat_resume;
|
|
|
|
|
t->to_wait = linux_nat_wait;
|
2011-04-27 15:29:15 +02:00
|
|
|
|
t->to_pass_signals = linux_nat_pass_signals;
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
t->to_xfer_partial = linux_nat_xfer_partial;
|
|
|
|
|
t->to_kill = linux_nat_kill;
|
|
|
|
|
t->to_mourn_inferior = linux_nat_mourn_inferior;
|
|
|
|
|
t->to_thread_alive = linux_nat_thread_alive;
|
update thread list, delete exited threads
On GNU/Linux, if the running kernel supports clone events, then
linux-thread-db.c defers thread listing to the target beneath:
static void
thread_db_update_thread_list (struct target_ops *ops)
{
...
if (target_has_execution && !thread_db_use_events ())
ops->beneath->to_update_thread_list (ops->beneath);
else
thread_db_update_thread_list_td_ta_thr_iter (ops);
...
}
However, when live debugging, the target beneath, linux-nat.c, does
not implement the to_update_thread_list method. The result is that if
a thread is marked exited (because it can't be deleted right now,
e.g., it was the selected thread), then it won't ever be deleted,
until the process exits or is killed/detached.
A similar thing happens with the remote.c target. Because its
target_update_thread_list implementation skips exited threads when it
walks the current thread list looking for threads that no longer exits
on the target side, using ALL_NON_EXITED_THREADS_SAFE, stale exited
threads are never deleted.
This is not a big deal -- I can't think of any way this might be user
visible, other than gdb's memory growing a tiny bit whenever a thread
gets stuck in exited state. Still, might as well clean things up
properly.
All other targets use prune_threads, so are unaffected.
The fix adds a ALL_THREADS_SAFE macro, that like
ALL_NON_EXITED_THREADS_SAFE, walks the thread list and allows deleting
the iterated thread, and uses that in places that are walking the
thread list in order to delete threads. Actually, after converting
linux-nat.c and remote.c to use this, we find the only other user of
ALL_NON_EXITED_THREADS_SAFE is also walking the list to delete
threads. So we convert that too, and end up deleting
ALL_NON_EXITED_THREADS_SAFE.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog
2015-04-07 Pedro Alves <palves@redhat.com>
* gdbthread.h (ALL_NON_EXITED_THREADS_SAFE): Rename to ...
(ALL_THREADS_SAFE): ... this, and don't skip exited threads.
(delete_exited_threads): New declaration.
* infrun.c (follow_exec): Use ALL_THREADS_SAFE.
* linux-nat.c (linux_nat_update_thread_list): New function.
(linux_nat_add_target): Install it.
* remote.c (remote_update_thread_list): Use ALL_THREADS_SAFE.
* thread.c (prune_threads): Use ALL_THREADS_SAFE.
(delete_exited_threads): New function.
2015-04-07 16:47:22 +02:00
|
|
|
|
t->to_update_thread_list = linux_nat_update_thread_list;
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
t->to_pid_to_str = linux_nat_pid_to_str;
|
2011-01-19 18:21:39 +01:00
|
|
|
|
t->to_thread_name = linux_nat_thread_name;
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
t->to_has_thread_control = tc_schedlock;
|
2009-10-20 13:09:01 +02:00
|
|
|
|
t->to_thread_address_space = linux_nat_thread_address_space;
|
2009-11-20 20:52:08 +01:00
|
|
|
|
t->to_stopped_by_watchpoint = linux_nat_stopped_by_watchpoint;
|
|
|
|
|
t->to_stopped_data_address = linux_nat_stopped_data_address;
|
2015-03-04 21:41:16 +01:00
|
|
|
|
t->to_stopped_by_sw_breakpoint = linux_nat_stopped_by_sw_breakpoint;
|
|
|
|
|
t->to_supports_stopped_by_sw_breakpoint = linux_nat_supports_stopped_by_sw_breakpoint;
|
|
|
|
|
t->to_stopped_by_hw_breakpoint = linux_nat_stopped_by_hw_breakpoint;
|
|
|
|
|
t->to_supports_stopped_by_hw_breakpoint = linux_nat_supports_stopped_by_hw_breakpoint;
|
2016-05-24 15:47:56 +02:00
|
|
|
|
t->to_thread_events = linux_nat_thread_events;
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
t->to_can_async_p = linux_nat_can_async_p;
|
|
|
|
|
t->to_is_async_p = linux_nat_is_async_p;
|
2008-08-19 15:22:14 +02:00
|
|
|
|
t->to_supports_non_stop = linux_nat_supports_non_stop;
|
Implement all-stop on top of a target running non-stop mode
This finally implements user-visible all-stop mode running with the
target_ops backend always in non-stop mode. This is a stepping stone
towards finer-grained control of threads, being able to do interesting
things like thread groups, associating groups with breakpoints, etc.
From the user's perspective, all-stop mode is really just a special
case of being able to stop and resume specific sets of threads, so it
makes sense to do this step first.
With this, even in all-stop, the target is no longer in charge of
stopping all threads before reporting an event to the core -- the core
takes care of it when it sees fit. For example, when "next"- or
"step"-ing, we can avoid stopping and resuming all threads at each
internal single-step, and instead only stop all threads when we're
about to present the stop to the user.
The implementation is almost straight forward, as the heavy lifting
has been done already in previous patches. Basically, we replace
checks for "set non-stop on/off" (the non_stop global), with calls to
a new target_is_non_stop_p function. In a few places, if "set
non-stop off", we stop all threads explicitly, and in a few other
places we resume all threads explicitly, making use of existing
methods that were added for teaching non-stop to step over breakpoints
without displaced stepping.
This adds a new "maint set target-non-stop on/off/auto" knob that
allows both disabling the feature if we find problems, and
force-enable it for development (useful when teaching a target about
this. The default is "auto", which means the feature is enabled if a
new target method says it should be enabled. The patch implements the
method in linux-nat.c, just for illustration, because it still returns
false. We'll need a few follow up fixes before turning it on by
default. This is a separate target method from indicating regular
non-stop support, because e.g., while e.g., native linux-nat.c is
close to regression free with all-stop-non-stop (with following
patches will fixing the remaining regressions), remote.c+gdbserver
will still need more fixing, even though it supports "set non-stop
on".
Tested on x86_64 Fedora 20, native, with and without "set displaced
off", and with and without "maint set target-non-stop on"; and also
against gdbserver.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* NEWS: Mention "maint set/show target-non-stop".
* breakpoint.c (update_global_location_list): Check
target_is_non_stop_p instead of non_stop.
* infcmd.c (attach_command_post_wait, attach_command): Likewise.
* infrun.c (show_can_use_displaced_stepping)
(can_use_displaced_stepping_p, start_step_over_inferior):
Likewise.
(internal_resume_ptid): New function.
(resume): Use it.
(proceed): Check target_is_non_stop_p instead of non_stop. If in
all-stop mode but the target is always in non-stop mode, start all
the other threads that are implicitly resumed too.
(for_each_just_stopped_thread, fetch_inferior_event)
(adjust_pc_after_break, stop_all_threads): Check
target_is_non_stop_p instead of non_stop.
(handle_inferior_event): Likewise. Handle detach-fork in all-stop
with the target always in non-stop mode.
(handle_signal_stop) <random signal>: Check target_is_non_stop_p
instead of non_stop.
(switch_back_to_stepped_thread): Check target_is_non_stop_p
instead of non_stop.
(keep_going_stepped_thread): Use internal_resume_ptid.
(stop_waiting): If in all-stop mode, and the target is in non-stop
mode, stop all threads.
(keep_going_pass): Likewise, when starting a new in-line step-over
sequence.
* linux-nat.c (get_pending_status, select_event_lwp)
(linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check
target_is_non_stop_p instead of non_stop.
(linux_nat_always_non_stop_p): New function.
(linux_nat_stop): Check target_is_non_stop_p instead of non_stop.
(linux_nat_add_target): Install linux_nat_always_non_stop_p.
* target-delegates.c: Regenerate.
* target.c (target_is_non_stop_p): New function.
(target_non_stop_enabled, target_non_stop_enabled_1): New globals.
(maint_set_target_non_stop_command)
(maint_show_target_non_stop_command): New functions.
(_initilize_target): Install "maint set/show target-non-stop"
commands.
* target.h (struct target_ops) <to_always_non_stop_p>: New field.
(target_non_stop_enabled): New declaration.
(target_is_non_stop_p): New declaration.
gdb/doc/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
target-non-stop".
2015-08-07 18:24:01 +02:00
|
|
|
|
t->to_always_non_stop_p = linux_nat_always_non_stop_p;
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
t->to_async = linux_nat_async;
|
Allow making GDB not automatically connect to the native target.
Sometimes it's useful to be able to disable the automatic connection
to the native target. E.g., sometimes GDB disconnects from the
extended-remote target I was debugging, without me noticing it, and
then I do "run". That starts the program locally, and only after a
little head scratch session do I figure out the program is running
locally instead of remotely as intended. Same thing with "attach",
"info os", etc.
With the patch, we now can have this instead:
(gdb) set auto-connect-native-target off
(gdb) target extended-remote :9999
...
*gdb disconnects*
(gdb) run
Don't know how to run. Try "help target".
To still be able to connect to the native target with
auto-connect-native-target set to off, I've made "target native" work
instead of erroring out as today.
Before:
(gdb) target native
Use the "run" command to start a native process.
After:
(gdb) target native
Done. Use the "run" command to start a process.
(gdb) maint print target-stack
The current target stack is:
- native (Native process)
- exec (Local exec file)
- None (None)
(gdb) run
Starting program: ./a.out
...
I've also wanted this for the testsuite, when running against the
native-extended-gdbserver.exp board (runs against gdbserver in
extended-remote mode). With a non-native-target board, it's always a
bug to launch a program with the native target. Turns out we still
have one such case this patch catches:
(gdb) break main
Breakpoint 1 at 0x4009e5: file ../../../src/gdb/testsuite/gdb.base/coremaker.c, line 138.
(gdb) run
Don't know how to run. Try "help target".
(gdb) FAIL: gdb.base/corefile.exp: run: with core
On the patch itself, probably the least obvious bit is the need to go
through all targets, and move the unpush_target call to after the
generic_mourn_inferior call instead of before. This is what
inf-ptrace.c does too, ever since multi-process support was added.
The reason inf-ptrace.c does things in that order is that in the
current multi-process/single-target model, we shouldn't unpush the
target if there are still other live inferiors being debugged. The
check for that is "have_inferiors ()" (a misnomer nowadays...), which
does:
have_inferiors (void)
{
for (inf = inferior_list; inf; inf = inf->next)
if (inf->pid != 0)
return 1;
It's generic_mourn_inferior that ends up clearing inf->pid, so we need
to call it before the have_inferiors check. To make all native
targets behave the same WRT to explicit "target native", I've added an
inf_child_maybe_unpush_target function that targets call instead of
calling unpush_target directly, and as that includes the
have_inferiors check, I needed to adjust the targets.
Tested on x86_64 Fedora 20, native, and also with the
extended-gdbserver board.
Confirmed a cross build of djgpp gdb still builds.
Smoke tested a cross build of Windows gdb under Wine.
Untested otherwise.
gdb/
2014-05-21 Pedro Alves <palves@redhat.com>
* inf-child.c (inf_child_ops, inf_child_explicitly_opened): New
globals.
(inf_child_open_target): New function.
(inf_child_open): Use inf_child_open_target to push the target
instead of erroring out.
(inf_child_disconnect, inf_child_close)
(inf_child_maybe_unpush_target): New functions.
(inf_child_target): Install inf_child_disconnect and
inf_child_close. Store a pointer to the returned object.
* inf-child.h (inf_child_open_target, inf_child_maybe_unpush): New
declarations.
* target.c (auto_connect_native_target): New global.
(show_default_run_target): New function.
(find_default_run_target): Return NULL if automatically connecting
to the native target is disabled.
(_initialize_target): Install set/show auto-connect-native-target.
* NEWS: Mention "set auto-connect-native-target", and "target
native".
* linux-nat.c (super_close): New global.
(linux_nat_close): Call super_close.
(linux_nat_add_target): Store a pointer to the base class's
to_close method.
* inf-ptrace.c (inf_ptrace_mourn_inferior, inf_ptrace_detach): Use
inf_child_maybe_unpush.
* inf-ttrace.c (inf_ttrace_him): Don't push the target if it is
already pushed.
(inf_ttrace_mourn_inferior): Only unpush the target after mourning
the inferior. Use inf_child_maybe_unpush_target.
(inf_ttrace_attach): Don't push the target if it is already
pushed.
(inf_ttrace_detach): Use inf_child_maybe_unpush_target.
* darwin-nat.c (darwin_mourn_inferior): Only unpush the target
after mourning the inferior. Use inf_child_maybe_unpush_target.
(darwin_attach_pid): Don't push the target if it is already
pushed.
* gnu-nat.c (gnu_mourn_inferior): Only unpush the target after
mourning the inferior. Use inf_child_maybe_unpush_target.
(gnu_detach): Use inf_child_maybe_unpush_target.
* go32-nat.c (go32_create_inferior): Don't push the target if it
is already pushed.
(go32_mourn_inferior): Use inf_child_maybe_unpush_target.
* nto-procfs.c (procfs_is_nto_target): Adjust comment.
(procfs_open): Rename to ...
(procfs_open_1): ... this. Add target_ops parameter. Adjust
comments. Can target_preopen before changing node. Call
inf_child_open_target to push the target explicitly.
(procfs_attach): Don't push the target if it is already pushed.
(procfs_detach): Use inf_child_maybe_unpush_target.
(procfs_create_inferior): Don't push the target if it is already
pushed.
(nto_native_ops): New global.
(procfs_open): Reimplement.
(procfs_native_open): New function.
(init_procfs_targets): Install procfs_native_open as to_open of
"target native". Store a pointer to the "native" target in
nto_native_ops.
* procfs.c (procfs_attach): Don't push the target if it is already
pushed.
(procfs_detach): Use inf_child_maybe_unpush_target.
(procfs_mourn_inferior): Only unpush the target after mourning the
inferior. Use inf_child_maybe_unpush_target.
(procfs_init_inferior): Don't push the target if it is already
pushed.
* windows-nat.c (do_initial_windows_stuff): Don't push the target
if it is already pushed.
(windows_detach): Use inf_child_maybe_unpush_target.
(windows_mourn_inferior): Only unpush the target after mourning
the inferior. Use inf_child_maybe_unpush_target.
gdb/doc/
2014-05-21 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Starting): Document "set/show
auto-connect-native-target".
(Target Commands): Document "target native".
gdb/testsuite/
2014-05-21 Pedro Alves <palves@redhat.com>
* boards/gdbserver-base.exp (GDBFLAGS): Set to "set
auto-connect-native-target off".
* gdb.base/auto-connect-native-target.c: New file.
* gdb.base/auto-connect-native-target.exp: New file.
2014-05-21 19:30:47 +02:00
|
|
|
|
|
|
|
|
|
super_close = t->to_close;
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
t->to_close = linux_nat_close;
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
|
2008-07-11 00:58:37 +02:00
|
|
|
|
t->to_stop = linux_nat_stop;
|
|
|
|
|
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
|
t->to_supports_multi_process = linux_nat_supports_multi_process;
|
|
|
|
|
|
2011-10-07 14:06:48 +02:00
|
|
|
|
t->to_supports_disable_randomization
|
|
|
|
|
= linux_nat_supports_disable_randomization;
|
|
|
|
|
|
Implement core awareness.
* bcache.c (compare_ints): Remove
(print_percentage): Use compare_positive_ints.
* defs.h (compare_positive_ints): Declare.
* linux-nat.h (struct lin_lwp): New field core.
(linux_nat_core_of_thread_1): Declare.
* linux-nat.c (add_lwp): Init the 'core' field.
(linux_nat_wait_1): Record the core.
(linux_nat_core_of_thread_1, linux_nat_core_of_thread): New.
(linux_nat_add_target): Register the above.
* linux-thread-db.c (update_thread_core): New.
(thread_db_find_new_threads): Update core information for
every thread.
* remote.c (struct private_thread_info): New.
(free_private_thread_info, demand_private_info): New.
(PACKET_qXfer_threads, use_osdata_threads): New.
(struct thread_item, threads_parsing_context
(start_thread, end_thread, thread_attributes)
(thread_children, threads_children, threads_elements): New.
(remote_threads_info): Try qXfer:threads before anything
else.
(remote_protocol_packets): Register qXfer:threads.
(remote_open_1): Init use_osdata_threads.
(struct stop_reply): New field 'core'.
(remote_parse_stop_reply): Parse core number.
(process_stop_reply): Record core number.
(remote_xfer_partial): Handle qXfer:threads.
(remote_core_of_thread): New.
(init_remote_ops): Register remote_core_of_thread.
(_initialize_remote): Register qXfer:read.
* target.c (target_core_of_thread): New
* target.h (enum target_object): New value TARGET_OBJECT_THREADS.
(struct target_ops): New field to_core_of_threads.
(target_core_of_thread): Declare.
* gdbthread.h (struct thread_info): New field private_dtor.
* thread.c (print_thread_info): Report the core.
* ui-out.c (MAX_UI_OUT_LEVELS): Increase.
* utils.c (compare_positive_ints): New.
* features/threads.dtd: New.
* mi/mi-interp.c (mi_on_normal_stop): Report the core.
* mi/mi-main.c (struct collect_cores_data, collect_cores)
(do_nothing, free_vector_of_osdata_items)
(splay_tree_int_comparator, free_splay_tree): New.
(print_one_inferior_data): Implemented printing of selected
inferiors. Collect and print cores.
(output_cores): New.
(mi_cmd_list_thread_groups): Support --recurse. Permit specifying
thread groups together with --available.
2010-01-12 22:40:25 +01:00
|
|
|
|
t->to_core_of_thread = linux_nat_core_of_thread;
|
|
|
|
|
|
2015-06-10 15:28:43 +02:00
|
|
|
|
t->to_filesystem_is_local = linux_nat_filesystem_is_local;
|
|
|
|
|
t->to_fileio_open = linux_nat_fileio_open;
|
|
|
|
|
t->to_fileio_readlink = linux_nat_fileio_readlink;
|
|
|
|
|
t->to_fileio_unlink = linux_nat_fileio_unlink;
|
|
|
|
|
|
* linux-nat.c (linux_ops_saved): New.
(super_mourn_inferior, kill_inferior, threaded, linux_nat_ops)
(child_mourn_inferior, child_wait, linux_nat_create_inferior)
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete.
(init_lwp_list): Don't set threaded.
(add_lwp): Don't modify threaded.
(delete_lwp): Don't mention non-threaded mode.
(linux_nat_switch_fork): New.
(linux_nat_attach): Update inferior_ptid.
(linux_nat_wait): Handle num_lwps == 0 at entry. Don't check
threaded flag.
(linux_nat_kill): Handle pending forks and saved forks.
(linux_nat_mourn_inferior): Handle saved forks.
(linux_nat_pid_to_str): Don't use the LWP form when there is
only one thread.
(linux_target): Don't set to_wait, to_kill, or to_mourn_inferior.
(linux_nat_add_target): New.
(_initialize_linux_nat): Don't initialize the linux native target
here.
* linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New
prototypes.
* linux-fork.c: Include "linux-nat.h".
(add_fork): Update initial PID.
(fork_load_infrun_state): Call linux_nat_switch_fork.
* Makefile.in (linux-fork.o): Update.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
linux_nat_add_target instead of add_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise.
* arm-linux-nat.c (_initialize_arm_linux_nat): Likewise.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise.
* i386-linux-nat.c (_initialize_i386_linux_nat): Likewise.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise.
* mips-linux-nat.c (_initialize_mips_linux_nat): Likewise.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise.
* s390-nat.c (_initialize_s390_nat): Likewise.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise.
2006-03-25 00:08:16 +01:00
|
|
|
|
/* We don't change the stratum; this target will sit at
|
|
|
|
|
process_stratum and thread_db will set at thread_stratum. This
|
|
|
|
|
is a little strange, since this is a multi-threaded-capable
|
|
|
|
|
target, but we want to be on the stack below thread_db, and we
|
|
|
|
|
also want to be used for single-threaded processes. */
|
|
|
|
|
|
|
|
|
|
add_target (t);
|
|
|
|
|
}
|
|
|
|
|
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
/* Register a method to call whenever a new thread is attached. */
|
|
|
|
|
void
|
gdb/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* linux-nat.c (linux_nat_new_thread): Change parameter to an lwp
pointer.
(linux_nat_prepare_to_resume): New global.
(lwp_free): New.
(purge_lwp_list): Use it.
(add_lwp): Call linux_nat_new_thread even on the first LWP.
Adjust to interface change.
(delete_lwp): Call lwp_free instead of xfree.
(detach_callback, linux_nat_detach, resume_lwp, linux_nat_resume)
(linux_handle_syscall_trap, linux_handle_extended_wait)
(linux_nat_filter_event, resume_stopped_resumed_lwps): Call
linux_nat_prepare_to_resume before resuming.
(linux_stop_lwp): New.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* linux-nat.h (struct arch_lwp_info): Forward declare.
(struct lwp_info) <arch_private>: New field.
(linux_stop_lwp): Declare.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* i386-nat.c (DR_NADDR, DR_STATUS, DR_CONTROL)
(struct i386_debug_reg_state): Move to i386-nat.h.
(dr_mirror): Comment.
(i386_debug_reg_state): New.
(i386_update_inferior_debug_regs): Simplify.
(i386_stopped_data_address): Use the debug register state from the
inferior, not from the local cache.
* i386-nat.h (struct i386_dr_low_type): Delete reset_addr and
unset_status fields. New get_addr and get_control fields.
(DR_FIRSTADDR, DR_LASTADDR, DR_CONTROL): Moved from i386-nat.c.
(DR_NADDR, DR_STATUS): New.
(struct i386_debug_reg_state): Moved from i386-nat.c.
* amd64-linux-nat.c (struct arch_lwp_info): New.
(amd64_linux_dr): Delete global.
(amd64_linux_dr_get_addr): New.
(amd64_linux_dr_get_control): New.
(amd64_linux_dr_unset_status): Delete.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_dr_reset_addr): Delete.
(update_debug_registers_callback): New.
(amd64_linux_dr_set_control): Reimplement.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_prepare_to_resume): New.
(amd64_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_amd64_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
amd64_linux_dr_get_control as i386_dr_low.get_control. Install
amd64_linux_dr_get_addr as i386_dr_low.get_addr. Install
amd64_linux_prepare_to_resume.
* i386-linux-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(struct arch_lwp_info): New.
(i386_linux_dr): Delete global.
(i386_linux_dr_set_control): Reimplement.
(i386_linux_dr_get_addr): New.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_dr_get_control): New.
(update_debug_registers_callback): New.
(i386_linux_dr_unset_status): Delete.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_prepare_to_resume): New.
(i386_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_i386_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386_linux_dr_get_control as i386_dr_low.get_control. Install
i386_linux_dr_get_addr as i386_dr_low.get_addr. Install
i386_linux_prepare_to_resume.
* arm-linux-nat.c (arm_linux_new_thread): Change parameter to an
lwp pointer. Adjust.
* ia64-linux-nat.c (ia64_linux_new_thread): Likewise.
* mips-linux-nat.c (mips_linux_new_thread): Likewise.
* ppc-linux-nat.c (ppc_linux_new_thread): Likewise.
* s390-nat.c (s390_fix_watch_points): Likewise.
* i386-darwin-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(i386_darwin_dr_reset_addr): Delete.
(i386_darwin_dr_get_addr): New.
(i386_darwin_dr_get_control): New.
* go32-nat.c
(go32_get_dr7, go32_get_dr): New.
(init_go32_ops): No longer install i386_dr_low.reset_addr.
Install go32_get_dr7 as i386_dr_low.get_control. Install
go32_get_dr as i386_dr_low.get_addr.
* i386bsd-nat.c (i386bsd_dr_get): New.
(i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_status): Use i386bsd_dr_get.
(i386bsd_dr_get_control): New.
* i386bsd-nat.h (i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_control): New.
* i386fbsd-nat.c (_initialize_i386fbsd_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386bsd_dr_get_control as i386_dr_low.get_control. Install
i386bsd_dr_get_addr as i386_dr_low.get_addr.
* windows-nat.c (init_windows_ops): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
cygwin_get_dr7 as i386_dr_low.get_control. Install cygwin_get_dr
as i386_dr_low.get_addr.
(cygwin_get_dr): New.
(cygwin_get_dr7): New.
gdb/testsuite/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* gdb.mi/watch-nonstop.c: New file.
* gdb.mi/mi-watch-nonstop.exp: New file.
2011-12-14 18:20:32 +01:00
|
|
|
|
linux_nat_set_new_thread (struct target_ops *t,
|
|
|
|
|
void (*new_thread) (struct lwp_info *))
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
{
|
|
|
|
|
/* Save the pointer. We only support a single registered instance
|
|
|
|
|
of the GNU/Linux native target, so we do not need to map this to
|
|
|
|
|
T. */
|
|
|
|
|
linux_nat_new_thread = new_thread;
|
|
|
|
|
}
|
|
|
|
|
|
lwp_info: Make the arch code free arch_lwp_info
I have the goal of "poisoning" the XNEW/xfree-family of functions, so
that we catch their usages with non-POD types. A few things need to be
fixed in the mean time, this is one.
The common lwp code in linux-nat.c and gdbserver/linux-low.c xfrees the
private lwp data of type arch_lwp_info. However, that type is opaque
from its point of view, as its defined differently in each arch-specific
implementation. This trips on the std::is_pod<T> check, since the
compiler can't tell whether the type is POD or not if it doesn't know
about it.
My initial patch [1] made a class hierarchy with a virtual destructor.
However, as Pedro pointed out, we only have one native architecture at
the time built in gdb and gdbserver, so that's overkill. Instead, we
can move the responsibility of free'ing arch_lwp_info to the arch code
(which is also the one that allocated it in the first place). This is
what this patch does.
Also, I had the concern that if we wanted to use C++ features in these
structures, we would have a problem with the one-definition rule.
However, since a build will only have one version of arch_lwp_info,
that's not a problem.
There are changes in arch-specific files, I was only able to built-test
this patch with the following cross-compilers:
aarch64-linux-gnu
alpha-linux-gnu
arm-linux-gnueabihf
hppa-linux-gnu
m68k-linux-gnu
mips64el-linux-gnuabi64
powerpc64-linux-gnu
s390x-linux-gnu
sh4-linux-gnu
sparc64-linux-gnu
x86_64-linux-gnu
x86_64-w64-mingw32
A buildbot run didn't find any regression.
[1] https://sourceware.org/ml/gdb-patches/2017-08/msg00255.html
gdb/ChangeLog:
* linux-nat.h (linux_nat_set_delete_thread): New declaration.
* linux-nat.c (linux_nat_delete_thread): New variable.
(lwp_free): Invoke linux_nat_delete_thread if set.
(linux_nat_set_delete_thread): New function.
* aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Assign
thread delete callback.
* arm-linux-nat.c (arm_linux_delete_thread): New function.
(_initialize_arm_linux_nat): Assign thread delete callback.
* s390-linux-nat.c (s390_delete_thread): New function.
(_initialize_s390_nat): Assign thread delete callback.
* x86-linux-nat.c (x86_linux_add_target): Likewise.
* nat/aarch64-linux.c (aarch64_linux_delete_thread): New
function.
* nat/aarch64-linux.h (aarch64_linux_delete_thread): New
declaration.
* nat/x86-linux.c (x86_linux_delete_thread): New function.
* nat/x86-linux.h (x86_linux_delete_thread): New declaration.
gdb/gdbserver/ChangeLog:
* linux-aarch64-low.c (the_low_target): Add thread delete
callback.
* linux-arm-low.c (arm_delete_thread): New function.
(the_low_target): Add thread delete callback.
* linux-bfin-low.c (the_low_target): Likewise.
* linux-crisv32-low.c (the_low_target): Likewise.
* linux-low.c (delete_lwp): Invoke delete_thread callback if
set.
* linux-low.h (struct linux_target_ops) <delete_thread>: New
field.
* linux-m32r-low.c (the_low_target): Add thread delete callback.
* linux-mips-low.c (mips_linux_delete_thread): New function.
(the_low_target): Add thread delete callback.
* linux-ppc-low.c (the_low_target): Likewise.
* linux-s390-low.c (the_low_target): Likewise.
* linux-sh-low.c (the_low_target): Likewise.
* linux-tic6x-low.c (the_low_target): Likewise.
* linux-tile-low.c (the_low_target): Likewise.
* linux-x86-low.c (the_low_target): Likewise.
* linux-xtensa-low.c (the_low_target): Likewise.
2017-10-12 22:48:22 +02:00
|
|
|
|
/* Register a method to call whenever a new thread is attached. */
|
|
|
|
|
void
|
|
|
|
|
linux_nat_set_delete_thread (struct target_ops *t,
|
|
|
|
|
void (*delete_thread) (struct arch_lwp_info *))
|
|
|
|
|
{
|
|
|
|
|
/* Save the pointer. We only support a single registered instance
|
|
|
|
|
of the GNU/Linux native target, so we do not need to map this to
|
|
|
|
|
T. */
|
|
|
|
|
linux_nat_delete_thread = delete_thread;
|
|
|
|
|
}
|
|
|
|
|
|
[native x86 GNU/Linux] Access debug register mirror from the corresponding process.
While reviewing the native AArch64 patch, I noticed a problem:
On 02/06/2013 08:46 PM, Pedro Alves wrote:
>
>> > +static void
>> > +aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
>> > +{
>> > + struct arch_lwp_info *info = lwp->arch_private;
>> > +
>> > + /* NULL means this is the main thread still going through the shell,
>> > + or, no watchpoint has been set yet. In that case, there's
>> > + nothing to do. */
>> > + if (info == NULL)
>> > + return;
>> > +
>> > + if (DR_HAS_CHANGED (info->dr_changed_bp)
>> > + || DR_HAS_CHANGED (info->dr_changed_wp))
>> > + {
>> > + int tid = GET_LWP (lwp->ptid);
>> > + struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
> Hmm. This is always fetching the debug_reg_state of
> the current inferior, but may not be the inferior of lwp.
> I see the same bug on x86. Sorry about that. I'll fix it.
A natural fix would be to make xxx_get_debug_reg_state take an
inferior argument, but that doesn't work because of the case where we
detach breakpoints/watchpoints from the child fork, at a time there's
no inferior for the child fork at all. We do a nasty hack in
i386_inferior_data_get, but that relies on all callers pointing the
current inferior to the correct inferior, which isn't actually being
done by all callers, and I don't think we want to enforce that -- deep
in the bowls of linux-nat.c, there are many cases we resume lwps
behind the scenes, and it's be better to not have that code rely on
global state (as it doesn't today).
The fix is to decouple the watchpoints code from inferiors, making it
track target processes instead. This way, we can freely keep track of
the watchpoint mirrors for these processes behind the core's back.
Checkpoints also play dirty tricks with swapping the process behind
the inferior, so they get special treatment too in the patch (which
just amounts to calling a new hook). Instead of the old hack in
i386_inferior_data_get, where we returned a copy of the current
inferior's debug registers mirror, as soon as we detect a fork in the
target, we copy the debug register mirror from the parent to the child
process.
I don't have an old kernel handy to test, but I stepped through gdb doing
the watchpoint removal in the fork child in the watchpoint-fork test
seeing that the debug registers end up cleared in the child.
I didn't find the need for linux_nat_iterate_watchpoint_lwps. If
we use plain iterate_over_lwps instead, what happens is that
when removing watchpoints, that iterate_over_lwps doesn't actually
iterate over anything, since the fork child is not added to the
lwp list until later, at detach time, in linux_child_follow_fork.
And if we don't iterate over that lwp, we don't mark its debug
registers as needing update. But linux_child_follow_fork takes
care of doing that explicitly:
child_lp = add_lwp (inferior_ptid);
child_lp->stopped = 1;
child_lp->last_resume_kind = resume_stop;
make_cleanup (delete_lwp_cleanup, child_lp);
/* CHILD_LP has new PID, therefore linux_nat_new_thread is not called for it.
See i386_inferior_data_get for the Linux kernel specifics.
Ensure linux_nat_prepare_to_resume will reset the hardware debug
registers. It is done by the linux_nat_new_thread call, which is
being skipped in add_lwp above for the first lwp of a pid. */
gdb_assert (num_lwps (GET_PID (child_lp->ptid)) == 1);
if (linux_nat_new_thread != NULL)
linux_nat_new_thread (child_lp);
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (child_lp);
ptrace (PTRACE_DETACH, child_pid, 0, 0);
so unless I'm missing something (quite possible) it ends up all
the same. But, the !detach-on-fork, and the "follow-fork child" paths
should also call linux_nat_new_thread, and they don't presently. It
seems to me in those cases we're not clearing debug regs correctly
when that's needed. Instead of copying that bit that works around
add_lwp bypassing the linux_nat_new_thread call, I thought it'd
be better to add an add_initial_lwp call to be used in the case we
really need to bypass linux_nat_new_thread, and make
add_lwp always call linux_nat_new_thread.
i386_cleanup_dregs is rewritten to forget about the current process
debug mirrors, which takes cares of other i386 ports. Only a couple
of extra tweaks here and there were needed, as some targets wheren't
actually calling i386_cleanup_dregs.
Tested on Fedora 17 x86_64 -m64/-m32.
GDBserver already fetches the i386_debug_reg_state from the right
process, and, it doesn't handle forks at all, so no fix is needed over
there.
gdb/
2013-02-13 Pedro Alves <palves@redhat.com>
* amd64-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(amd64_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(amd64_linux_new_fork): New function.
(_initialize_amd64_linux_nat): Install amd64_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-linux-nat.c (update_debug_registers_callback):
Update comment.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use
iterate_over_lwps.
(i386_linux_prepare_to_resume): Pass the lwp's pid to
i386_debug_reg_state.
(i386_linux_new_fork): New function.
(_initialize_i386_linux_nat): Install i386_linux_new_fork as
linux_nat_new_fork hook, and i386_forget_process as
linux_nat_forget_process hook.
* i386-nat.c (i386_init_dregs): Delete.
(i386_inferior_data, struct i386_inferior_data):
Delete.
(struct i386_process_info): New.
(i386_process_list): New global.
(i386_find_process_pid, i386_add_process, i386_process_info_get):
New functions.
(i386_inferior_data_get): Delete.
(i386_process_info_get): New function.
(i386_debug_reg_state): New parameter 'pid'. Reimplement.
(i386_forget_process): New function.
(i386_cleanup_dregs): Rewrite.
(i386_update_inferior_debug_regs, i386_insert_watchpoint)
(i386_remove_watchpoint, i386_region_ok_for_watchpoint)
(i386_stopped_data_address, i386_insert_hw_breakpoint)
(i386_remove_hw_breakpoint): Adjust to pass the current process id
to i386_debug_reg_state.
(i386_use_watchpoints): Don't register inferior data.
* i386-nat.h (i386_debug_reg_state): Add new 'pid' parameter, and
adjust comment.
(i386_forget_process): Declare.
* linux-fork.c (delete_fork): Call linux_nat_forget_process.
* linux-nat.c (linux_nat_new_fork, linux_nat_forget_process_hook):
New static globals.
(linux_child_follow_fork): Don't call linux_nat_new_thread here.
(add_initial_lwp): New, factored out from ...
(add_lwp): ... this. Don't check the number of lwps before
calling linux_nat_new_thread.
(linux_nat_iterate_watchpoint_lwps): Delete.
(linux_nat_attach): Use add_initial_lwp instead of add_lwp.
(linux_handle_extended_wait): Call the linux_nat_new_fork hook on
forks and vforks.
(linux_nat_wait_1): Use add_initial_lwp instead of add_lwp for the
initial lwp.
(linux_nat_kill, linux_nat_mourn_inferior): Call
linux_nat_forget_process.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New functions.
* linux-nat.h (linux_nat_iterate_watchpoint_lwps_ftype): Delete
type.
(linux_nat_iterate_watchpoint_lwps): Delete declaration.
(linux_nat_new_fork_ftype, linux_nat_forget_process_ftype): New
types.
(linux_nat_set_new_fork, linux_nat_set_forget_process)
(linux_nat_forget_process): New declarations.
* amd64fbsd-nat.c (super_mourn_inferior): New global.
(amd64fbsd_mourn_inferior): New function.
(_initialize_amd64fbsd_nat): Override to_mourn_inferior.
* windows-nat.c (windows_detach): Call i386_cleanup_dregs.
2013-02-13 15:59:49 +01:00
|
|
|
|
/* See declaration in linux-nat.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
linux_nat_set_new_fork (struct target_ops *t,
|
|
|
|
|
linux_nat_new_fork_ftype *new_fork)
|
|
|
|
|
{
|
|
|
|
|
/* Save the pointer. */
|
|
|
|
|
linux_nat_new_fork = new_fork;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See declaration in linux-nat.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
linux_nat_set_forget_process (struct target_ops *t,
|
|
|
|
|
linux_nat_forget_process_ftype *fn)
|
|
|
|
|
{
|
|
|
|
|
/* Save the pointer. */
|
|
|
|
|
linux_nat_forget_process_hook = fn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See declaration in linux-nat.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
linux_nat_forget_process (pid_t pid)
|
|
|
|
|
{
|
|
|
|
|
if (linux_nat_forget_process_hook != NULL)
|
|
|
|
|
linux_nat_forget_process_hook (pid);
|
|
|
|
|
}
|
|
|
|
|
|
* amd64-linux-nat.c (compat_int_t, compat_uptr_t, compat_time_t)
(compat_timer_t, compat_clock_t, struct compat_timeval)
(compat_sigval_t, compat_siginfo_t): New types.
(cpt_si_pid, cpt_si_uid, cpt_si_timerid, cpt_si_overrun)
(cpt_si_status, cpt_si_utime, cpt_si_stime, cpt_si_ptr)
(cpt_si_addr, cpt_si_band, cpt_si_fd): New defines.
(compat_siginfo_from_siginfo, siginfo_from_compat_siginfo)
(amd64_linux_siginfo_fixup): New.
* linux-nat.c (linux_nat_siginfo_fixup): New.
(siginfo_fixup): New.
(linux_xfer_siginfo): Use siginfo_fixup to convert between the
siginfo layout expected by ptrace and the siginfo layout of the
inferior.
(linux_nat_set_siginfo_fixup): New.
* linux-nat.h (linux_nat_set_siginfo_fixup): Declare.
2009-02-07 00:06:58 +01:00
|
|
|
|
/* Register a method that converts a siginfo object between the layout
|
|
|
|
|
that ptrace returns, and the layout in the architecture of the
|
|
|
|
|
inferior. */
|
|
|
|
|
void
|
|
|
|
|
linux_nat_set_siginfo_fixup (struct target_ops *t,
|
2012-03-21 14:43:55 +01:00
|
|
|
|
int (*siginfo_fixup) (siginfo_t *,
|
* amd64-linux-nat.c (compat_int_t, compat_uptr_t, compat_time_t)
(compat_timer_t, compat_clock_t, struct compat_timeval)
(compat_sigval_t, compat_siginfo_t): New types.
(cpt_si_pid, cpt_si_uid, cpt_si_timerid, cpt_si_overrun)
(cpt_si_status, cpt_si_utime, cpt_si_stime, cpt_si_ptr)
(cpt_si_addr, cpt_si_band, cpt_si_fd): New defines.
(compat_siginfo_from_siginfo, siginfo_from_compat_siginfo)
(amd64_linux_siginfo_fixup): New.
* linux-nat.c (linux_nat_siginfo_fixup): New.
(siginfo_fixup): New.
(linux_xfer_siginfo): Use siginfo_fixup to convert between the
siginfo layout expected by ptrace and the siginfo layout of the
inferior.
(linux_nat_set_siginfo_fixup): New.
* linux-nat.h (linux_nat_set_siginfo_fixup): Declare.
2009-02-07 00:06:58 +01:00
|
|
|
|
gdb_byte *,
|
|
|
|
|
int))
|
|
|
|
|
{
|
|
|
|
|
/* Save the pointer. */
|
|
|
|
|
linux_nat_siginfo_fixup = siginfo_fixup;
|
|
|
|
|
}
|
|
|
|
|
|
gdb/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* linux-nat.c (linux_nat_new_thread): Change parameter to an lwp
pointer.
(linux_nat_prepare_to_resume): New global.
(lwp_free): New.
(purge_lwp_list): Use it.
(add_lwp): Call linux_nat_new_thread even on the first LWP.
Adjust to interface change.
(delete_lwp): Call lwp_free instead of xfree.
(detach_callback, linux_nat_detach, resume_lwp, linux_nat_resume)
(linux_handle_syscall_trap, linux_handle_extended_wait)
(linux_nat_filter_event, resume_stopped_resumed_lwps): Call
linux_nat_prepare_to_resume before resuming.
(linux_stop_lwp): New.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* linux-nat.h (struct arch_lwp_info): Forward declare.
(struct lwp_info) <arch_private>: New field.
(linux_stop_lwp): Declare.
(linux_nat_set_new_thread): Adjust.
(linux_nat_set_prepare_to_resume): New.
* i386-nat.c (DR_NADDR, DR_STATUS, DR_CONTROL)
(struct i386_debug_reg_state): Move to i386-nat.h.
(dr_mirror): Comment.
(i386_debug_reg_state): New.
(i386_update_inferior_debug_regs): Simplify.
(i386_stopped_data_address): Use the debug register state from the
inferior, not from the local cache.
* i386-nat.h (struct i386_dr_low_type): Delete reset_addr and
unset_status fields. New get_addr and get_control fields.
(DR_FIRSTADDR, DR_LASTADDR, DR_CONTROL): Moved from i386-nat.c.
(DR_NADDR, DR_STATUS): New.
(struct i386_debug_reg_state): Moved from i386-nat.c.
* amd64-linux-nat.c (struct arch_lwp_info): New.
(amd64_linux_dr): Delete global.
(amd64_linux_dr_get_addr): New.
(amd64_linux_dr_get_control): New.
(amd64_linux_dr_unset_status): Delete.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_dr_reset_addr): Delete.
(update_debug_registers_callback): New.
(amd64_linux_dr_set_control): Reimplement.
(amd64_linux_dr_set_addr): Reimplement.
(amd64_linux_prepare_to_resume): New.
(amd64_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_amd64_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
amd64_linux_dr_get_control as i386_dr_low.get_control. Install
amd64_linux_dr_get_addr as i386_dr_low.get_addr. Install
amd64_linux_prepare_to_resume.
* i386-linux-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(struct arch_lwp_info): New.
(i386_linux_dr): Delete global.
(i386_linux_dr_set_control): Reimplement.
(i386_linux_dr_get_addr): New.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_dr_get_control): New.
(update_debug_registers_callback): New.
(i386_linux_dr_unset_status): Delete.
(i386_linux_dr_set_addr): Reimplement.
(i386_linux_prepare_to_resume): New.
(i386_linux_new_thread): Change parameter to an lwp pointer.
Reimplement.
(_initialize_i386_linux_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386_linux_dr_get_control as i386_dr_low.get_control. Install
i386_linux_dr_get_addr as i386_dr_low.get_addr. Install
i386_linux_prepare_to_resume.
* arm-linux-nat.c (arm_linux_new_thread): Change parameter to an
lwp pointer. Adjust.
* ia64-linux-nat.c (ia64_linux_new_thread): Likewise.
* mips-linux-nat.c (mips_linux_new_thread): Likewise.
* ppc-linux-nat.c (ppc_linux_new_thread): Likewise.
* s390-nat.c (s390_fix_watch_points): Likewise.
* i386-darwin-nat.c (DR_FIRSTADDR, DR_LASTADDR, DR_STATUS)
(DR_CONTROL): Delete.
(i386_darwin_dr_reset_addr): Delete.
(i386_darwin_dr_get_addr): New.
(i386_darwin_dr_get_control): New.
* go32-nat.c
(go32_get_dr7, go32_get_dr): New.
(init_go32_ops): No longer install i386_dr_low.reset_addr.
Install go32_get_dr7 as i386_dr_low.get_control. Install
go32_get_dr as i386_dr_low.get_addr.
* i386bsd-nat.c (i386bsd_dr_get): New.
(i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_status): Use i386bsd_dr_get.
(i386bsd_dr_get_control): New.
* i386bsd-nat.h (i386bsd_dr_reset_addr): Delete.
(i386bsd_dr_get_addr): New.
(i386bsd_dr_get_control): New.
* i386fbsd-nat.c (_initialize_i386fbsd_nat): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
i386bsd_dr_get_control as i386_dr_low.get_control. Install
i386bsd_dr_get_addr as i386_dr_low.get_addr.
* windows-nat.c (init_windows_ops): No longer install
i386_dr_low.reset_addr and i386_dr_low.unset_status. Install
cygwin_get_dr7 as i386_dr_low.get_control. Install cygwin_get_dr
as i386_dr_low.get_addr.
(cygwin_get_dr): New.
(cygwin_get_dr7): New.
gdb/testsuite/
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
* gdb.mi/watch-nonstop.c: New file.
* gdb.mi/mi-watch-nonstop.exp: New file.
2011-12-14 18:20:32 +01:00
|
|
|
|
/* Register a method to call prior to resuming a thread. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
linux_nat_set_prepare_to_resume (struct target_ops *t,
|
|
|
|
|
void (*prepare_to_resume) (struct lwp_info *))
|
|
|
|
|
{
|
|
|
|
|
/* Save the pointer. */
|
|
|
|
|
linux_nat_prepare_to_resume = prepare_to_resume;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-06 18:49:43 +02:00
|
|
|
|
/* See linux-nat.h. */
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
linux_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo)
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
{
|
2012-07-06 18:52:20 +02:00
|
|
|
|
int pid;
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
|
2013-09-30 13:50:12 +02:00
|
|
|
|
pid = ptid_get_lwp (ptid);
|
2012-07-06 18:52:20 +02:00
|
|
|
|
if (pid == 0)
|
2013-09-30 13:50:12 +02:00
|
|
|
|
pid = ptid_get_pid (ptid);
|
2012-07-06 18:49:43 +02:00
|
|
|
|
|
2012-07-06 18:52:20 +02:00
|
|
|
|
errno = 0;
|
|
|
|
|
ptrace (PTRACE_GETSIGINFO, pid, (PTRACE_TYPE_ARG3) 0, siginfo);
|
|
|
|
|
if (errno != 0)
|
|
|
|
|
{
|
|
|
|
|
memset (siginfo, 0, sizeof (*siginfo));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2012-07-06 18:49:43 +02:00
|
|
|
|
return 1;
|
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
2007-10-01 02:22:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-24 15:05:43 +01:00
|
|
|
|
/* See nat/linux-nat.h. */
|
|
|
|
|
|
|
|
|
|
ptid_t
|
|
|
|
|
current_lwp_ptid (void)
|
|
|
|
|
{
|
|
|
|
|
gdb_assert (ptid_lwp_p (inferior_ptid));
|
|
|
|
|
return inferior_ptid;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
void
|
|
|
|
|
_initialize_linux_nat (void)
|
|
|
|
|
{
|
2012-08-02 11:36:40 +02:00
|
|
|
|
add_setshow_zuinteger_cmd ("lin-lwp", class_maintenance,
|
|
|
|
|
&debug_linux_nat, _("\
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
Set debugging of GNU/Linux lwp module."), _("\
|
|
|
|
|
Show debugging of GNU/Linux lwp module."), _("\
|
|
|
|
|
Enables printf debugging output."),
|
2012-08-02 11:36:40 +02:00
|
|
|
|
NULL,
|
|
|
|
|
show_debug_linux_nat,
|
|
|
|
|
&setdebuglist, &showdebuglist);
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
|
2015-06-10 15:28:43 +02:00
|
|
|
|
add_setshow_boolean_cmd ("linux-namespaces", class_maintenance,
|
|
|
|
|
&debug_linux_namespaces, _("\
|
|
|
|
|
Set debugging of GNU/Linux namespaces module."), _("\
|
|
|
|
|
Show debugging of GNU/Linux namespaces module."), _("\
|
|
|
|
|
Enables printf debugging output."),
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
&setdebuglist, &showdebuglist);
|
|
|
|
|
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
/* Save this mask as the default. */
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
sigprocmask (SIG_SETMASK, NULL, &normal_mask);
|
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
/* Install a SIGCHLD handler. */
|
|
|
|
|
sigchld_action.sa_handler = sigchld_handler;
|
|
|
|
|
sigemptyset (&sigchld_action.sa_mask);
|
|
|
|
|
sigchld_action.sa_flags = SA_RESTART;
|
gdb/
* target.h (struct target_ops): Delete to_async_mask_value and add
to_async_mask.
(target_is_async_p, target_async): Formatting.
(target_async_mask_value): Delete.
(target_async_mask): Delete function declaration, and add new
target macro with the same name.
* target.c (update_current_target): Replace to_async_mask_value by
to_async_mask. Default to_async_mask to return_one.
(target_async_mask): Delete.
(find_default_can_async_p, find_default_is_async_p): New.
(init_dummy_target): register find_default_can_async_p and
find_default_is_async_p on the dummy target.
* linux-nat.c: Include inf-loop.h, event-loop.h and event-top.h.
(debug_linux_nat_async): New global.
(show_debug_linux_nat_async): New function.
(linux_nat_async_enabled, linux_nat_async_mask_value)
(linux_nat_event_pipe, linux_nat_num_queued_events)
(linux_nat_async_events_enabled): New globals.
(struct waitpid_result): New struct.
(waitpid_queue): New global.
(queued_waitpid, push_waitpid, drain_queued_events): New.
(my_waitpid): Call queued_waitpid.
(linux_child_follow_fork): Disable async events during the call.
(blocked_mask): Delete.
(sync_sigchld_action, async_sigchld_action): New globals.
(lin_lwp_attach_lwp): In sync mode, don't reblock SIGCHLD. In
async mode, block events during the call.
(linux_nat_create_inferior): New.
(linux_nat_attach): In sync mode, restore the mask states. In
async mode, wake the event loop immediatelly.
(detach_callback): Drain all queued events of the lwp we're
detaching from.
(linux_nat_detach): Block async mode, and drain events of the main
process.
(linux_nat_resume): If in async mode, mask async events during the
call. If short circuiting, force event loop to wake up. If
resuming, set target_executing, and register target events in the
event loop.
(pipe_to_local_event_queue, local_event_queue_to_pipe): New.
(linux_nat_wait): In async mode, block events during the call.
Only enable/disable passing SIGINT to the inferior in sync mode.
Get events from local waitpid queue. If no interesting events was
found, return to events loop. Reregister target events in the
event loop on exit. In sync mode, no need to reblock SIGCHLD.
(linux_nat_kill): Disable events on entry.
(linux_nat_mourn_inferior): In sync mode, don't restore the masks
here. Detach async mode from the event loop if there are no more
forks available, otherwise leave it on.
(sigchld_handler): Assure this is called only in sync mode.
(linux_async_permitted, linux_async_permitted_1): New globals.
(set_maintenance_linux_async_permitted)
(show_maintenance_linux_async_permitted): New functions.
(linux_nat_is_async_p, linux_nat_can_async_p)
(linux_nat_async_mask): New.
(linux_nat_event_pipe_pop, linux_nat_event_pipe_push): New.
(get_pending_events, async_sigchld_handler): New.
(linux_nat_async_events): New.
(async_terminal_is_ours): New global.
(linux_nat_terminal_inferior, linux_nat_terminal_ours): New.
(async_client_callback, async_client_context): New.
(linux_nat_async_file_handler, linux_nat_async)
(linux_nat_disable_async, linux_nat_enable_async): New.
(linux_nat_add_target): Register linux_nat_create_inferior,
linux_nat_can_async_p, linux_nat_is_async_p, linux_nat_async,
linux_nat_async_mask, linux_nat_terminal_inferior and
linux_nat_terminal_ours.
(_initialize_linux_nat): Remove local action variable, and update
code that used it to use sync_sigchld_action. Add new
"lin-lwp-async" debug set/show command. Put the "lin-lwp" debug
set/show command in the maintenance class. Add new "linux-async"
maintenance set/show command. Block SIGCHLD by default. Setup
async_sichld_action, and sync_sigchld_action. Install the default
async mode.
(lin_thread_get_thread_signals): Use a local sigset_t for blocking
the cancel signals.
* linux-thread-db.c (re_check_for_thread_db): New.
(clear_lwpid_callback): Handle TARGET_WAITKIND_IGNORE.
(thread_db_can_async_p, thread_db_is_async_p, thread_db_async)
(thread_db_async_mask): New.
(init_thread_db_ops): Register thread_db_can_async_p,
thread_db_is_async_p, thread_db_async and thread_db_async_mask.
* remote.c (remote_async_mask_value): New.
(remote_return_zero): New.
(init_remote_ops): Register remote_return_zero as callbacks of
to_can_async_p and to_is_async_p.
(remote_can_async_p, remote_is_async_p, remote_async): Update to
use remote_async_mask_value.
(remote_async_mask): New.
(init_remote_async_ops): Remove to_async_mask_value setting and
register remote_async_mask as to_async_mask callback in
remote_async_ops.
* Makefile.in (linux-nat.o): Update.
gdb/doc/
* gdb.texinfo (Debugging Output): Document
"set/show debug lin-lwp-async".
(Maintenance Commands): Document "maint set/show linux-async".
2008-03-21 18:09:35 +01:00
|
|
|
|
|
|
|
|
|
/* Make it the default. */
|
2009-05-11 14:08:03 +02:00
|
|
|
|
sigaction (SIGCHLD, &sigchld_action, NULL);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
|
|
|
|
|
/* Make sure we don't block SIGCHLD during a sigsuspend. */
|
|
|
|
|
sigprocmask (SIG_SETMASK, NULL, &suspend_mask);
|
|
|
|
|
sigdelset (&suspend_mask, SIGCHLD);
|
|
|
|
|
|
2009-05-11 14:08:03 +02:00
|
|
|
|
sigemptyset (&blocked_mask);
|
[Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:
- captured_main
- 93.61% catch_command_errors
- 87.41% attach_command
- 87.40% linux_nat_attach
- 87.40% linux_proc_attach_tgid_threads
- 82.38% attach_proc_task_lwp_callback
- 81.01% find_lwp_pid
5.30% ptid_get_lwp
+ 0.10% ptid_lwp_p
+ 0.64% add_thread
+ 0.26% set_running
+ 0.24% set_executing
0.12% ptid_get_lwp
+ 0.01% ptrace
+ 0.01% add_lwp
attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory. In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known. Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic. We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads. So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.
Fix this by adding a hash table keyed by LWP PID, for fast lookup.
The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1). An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted. For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list. So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.
gdb/ChangeLog:
2016-05-24 Pedro Alves <palves@redhat.com>
PR gdb/19828
* linux-nat.c (lwp_lwpid_htab): New htab.
(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
(lwp_lwpid_htab_add_lwp): New functions.
(lwp_list): Tweak comment.
(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
functions.
(purge_lwp_list): Rewrite, using htab_traverse_noresize.
(add_initial_lwp): Add lwp to htab too. Use lwp_list_add.
(delete_lwp): Use lwp_list_remove. Remove htab too.
(find_lwp_pid): Search in htab.
(_initialize_linux_nat): Call lwp_lwpid_htab_create.
* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 15:47:57 +02:00
|
|
|
|
|
|
|
|
|
lwp_lwpid_htab_create ();
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* FIXME: kettenis/2000-08-26: The stuff on this page is specific to
|
|
|
|
|
the GNU/Linux Threads library and therefore doesn't really belong
|
|
|
|
|
here. */
|
|
|
|
|
|
|
|
|
|
/* Return the set of signals used by the threads library in *SET. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
lin_thread_get_thread_signals (sigset_t *set)
|
|
|
|
|
{
|
|
|
|
|
sigemptyset (set);
|
|
|
|
|
|
2015-12-17 15:20:51 +01:00
|
|
|
|
/* NPTL reserves the first two RT signals, but does not provide any
|
|
|
|
|
way for the debugger to query the signal numbers - fortunately
|
|
|
|
|
they don't change. */
|
|
|
|
|
sigaddset (set, __SIGRTMIN);
|
|
|
|
|
sigaddset (set, __SIGRTMIN + 1);
|
2004-09-16 Andrew Cagney <cagney@gnu.org>
* lin-lwp.c: Delete file.
* linux-nat.c: Include "gdb_assert.h", "gdb_string.h", <unistd.h>,
<sys/syscall.h>, "gdbthread.h", "gdbcmd.h", "regcache.h".
(status_to_str, init_lwp_list, add_lwp, delete_lwp)
(find_lwp_pid, iterate_over_lwps, lin_lwp_attach_lwp)
(linux_nat_attach, detach_callback, linux_nat_detach)
(resume_callback, resume_clear_callback, linux_nat_resume)
(kill_lwp, linux_nat_handle_extended, wait_lwp, stop_callback)
(stop_wait_callback, linux_nat_has_pending, flush_callback)
(status_callback, running_callback, count_events_callback)
(select_singlestep_lwp_callback, select_event_lwp_callback)
(cancel_breakpoints_callback, select_event_lwp, resumed_callback)
(child_wait, stop_and_resume_callback, linux_nat_wait)
(kill_callback, kill_wait_callback, linux_nat_kill)
(linux_nat_create_inferior, linux_nat_mourn_inferior)
(linux_nat_xfer_memory, linux_nat_thread_alive)
(linux_nat_pid_to_str, init_linux_nat_ops, sigchld_handler)
(_initialize_linux_nat): New functions.
* Makefile.in: Update all dependencies.
* config/sparc/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/sparc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/s390/s390.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/powerpc/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/pa/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/mips/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/m68k/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/ia64/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux64.mh (NATDEPFILES): Remove lin-lwp.o.
* config/i386/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/arm/linux.mh (NATDEPFILES): Remove lin-lwp.o.
* config/alpha/alpha-linux.mh (NATDEPFILES): Remove lin-lwp.o.
2004-09-27 21:55:18 +02:00
|
|
|
|
}
|